Skip to content

Commit

Permalink
Merge pull request #27 from islet-project/main
Browse files Browse the repository at this point in the history
Add multiple registers and update fields
  • Loading branch information
berkus authored Oct 25, 2024
2 parents 4a07a8e + 9107714 commit 0a39fbd
Show file tree
Hide file tree
Showing 47 changed files with 1,619 additions and 4 deletions.
80 changes: 80 additions & 0 deletions src/registers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ mod cntp_ctl_el0;
mod cntp_cval_el0;
mod cntp_tval_el0;
mod cntpct_el0;
mod cntpoff_el2;
mod cntv_ctl_el0;
mod cntv_cval_el0;
mod cntv_tval_el0;
mod cntvct_el0;
mod cntvoff_el2;
mod cpacr_el1;
mod cptr_el2;
mod csselr_el1;
mod currentel;
mod dacr32_el2;
Expand All @@ -52,10 +54,48 @@ mod far_el2;
mod far_el3;
mod fp;
mod hcr_el2;
mod hpfar_el2;
mod icc_ctlr_el1;
mod icc_sre_el2;
mod ich_ap0r0_el2;
mod ich_ap0r1_el2;
mod ich_ap0r2_el2;
mod ich_ap0r3_el2;
mod ich_ap1r0_el2;
mod ich_ap1r1_el2;
mod ich_ap1r2_el2;
mod ich_ap1r3_el2;
mod ich_hcr_el2;
mod ich_lr0_el2;
mod ich_lr10_el2;
mod ich_lr11_el2;
mod ich_lr12_el2;
mod ich_lr13_el2;
mod ich_lr14_el2;
mod ich_lr15_el2;
mod ich_lr1_el2;
mod ich_lr2_el2;
mod ich_lr3_el2;
mod ich_lr4_el2;
mod ich_lr5_el2;
mod ich_lr6_el2;
mod ich_lr7_el2;
mod ich_lr8_el2;
mod ich_lr9_el2;
mod ich_misr_el2;
mod ich_vmcr_el2;
mod ich_vtr_el2;
mod id_aa64afr0_el1;
mod id_aa64afr1_el1;
mod id_aa64dfr0_el1;
mod id_aa64dfr1_el1;
mod id_aa64isar0_el1;
mod id_aa64isar1_el1;
mod id_aa64mmfr0_el1;
mod id_aa64mmfr1_el1;
mod id_aa64mmfr2_el1;
mod id_aa64pfr0_el1;
mod id_aa64pfr1_el1;
mod lr;
mod mair_el1;
mod mair_el2;
Expand Down Expand Up @@ -116,12 +156,14 @@ pub use cntp_ctl_el0::CNTP_CTL_EL0;
pub use cntp_cval_el0::CNTP_CVAL_EL0;
pub use cntp_tval_el0::CNTP_TVAL_EL0;
pub use cntpct_el0::CNTPCT_EL0;
pub use cntpoff_el2::CNTPOFF_EL2;
pub use cntv_ctl_el0::CNTV_CTL_EL0;
pub use cntv_cval_el0::CNTV_CVAL_EL0;
pub use cntv_tval_el0::CNTV_TVAL_EL0;
pub use cntvct_el0::CNTVCT_EL0;
pub use cntvoff_el2::CNTVOFF_EL2;
pub use cpacr_el1::CPACR_EL1;
pub use cptr_el2::CPTR_EL2;
pub use csselr_el1::CSSELR_EL1;
pub use currentel::CurrentEL;
pub use dacr32_el2::DACR32_EL2;
Expand All @@ -140,10 +182,48 @@ pub use far_el2::FAR_EL2;
pub use far_el3::FAR_EL3;
pub use fp::FP;
pub use hcr_el2::HCR_EL2;
pub use hpfar_el2::HPFAR_EL2;
pub use icc_ctlr_el1::ICC_CTLR_EL1;
pub use icc_sre_el2::ICC_SRE_EL2;
pub use ich_ap0r0_el2::ICH_AP0R0_EL2;
pub use ich_ap0r1_el2::ICH_AP0R1_EL2;
pub use ich_ap0r2_el2::ICH_AP0R2_EL2;
pub use ich_ap0r3_el2::ICH_AP0R3_EL2;
pub use ich_ap1r0_el2::ICH_AP1R0_EL2;
pub use ich_ap1r1_el2::ICH_AP1R1_EL2;
pub use ich_ap1r2_el2::ICH_AP1R2_EL2;
pub use ich_ap1r3_el2::ICH_AP1R3_EL2;
pub use ich_hcr_el2::ICH_HCR_EL2;
pub use ich_lr0_el2::ICH_LR0_EL2;
pub use ich_lr10_el2::ICH_LR10_EL2;
pub use ich_lr11_el2::ICH_LR11_EL2;
pub use ich_lr12_el2::ICH_LR12_EL2;
pub use ich_lr13_el2::ICH_LR13_EL2;
pub use ich_lr14_el2::ICH_LR14_EL2;
pub use ich_lr15_el2::ICH_LR15_EL2;
pub use ich_lr1_el2::ICH_LR1_EL2;
pub use ich_lr2_el2::ICH_LR2_EL2;
pub use ich_lr3_el2::ICH_LR3_EL2;
pub use ich_lr4_el2::ICH_LR4_EL2;
pub use ich_lr5_el2::ICH_LR5_EL2;
pub use ich_lr6_el2::ICH_LR6_EL2;
pub use ich_lr7_el2::ICH_LR7_EL2;
pub use ich_lr8_el2::ICH_LR8_EL2;
pub use ich_lr9_el2::ICH_LR9_EL2;
pub use ich_misr_el2::ICH_MISR_EL2;
pub use ich_vmcr_el2::ICH_VMCR_EL2;
pub use ich_vtr_el2::ICH_VTR_EL2;
pub use id_aa64afr0_el1::ID_AA64AFR0_EL1;
pub use id_aa64afr1_el1::ID_AA64AFR1_EL1;
pub use id_aa64dfr0_el1::ID_AA64DFR0_EL1;
pub use id_aa64dfr1_el1::ID_AA64DFR1_EL1;
pub use id_aa64isar0_el1::ID_AA64ISAR0_EL1;
pub use id_aa64isar1_el1::ID_AA64ISAR1_EL1;
pub use id_aa64mmfr0_el1::ID_AA64MMFR0_EL1;
pub use id_aa64mmfr1_el1::ID_AA64MMFR1_EL1;
pub use id_aa64mmfr2_el1::ID_AA64MMFR2_EL1;
pub use id_aa64pfr0_el1::ID_AA64PFR0_EL1;
pub use id_aa64pfr1_el1::ID_AA64PFR1_EL1;
pub use lr::LR;
pub use mair_el1::MAIR_EL1;
pub use mair_el2::MAIR_EL2;
Expand Down
4 changes: 2 additions & 2 deletions src/registers/cntkctl_el1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
//! Counter-timer Kernel Control register - EL1
//!
//! When FEAT_VHE is implemented and HCR_EL2.{E2H, TGE} is {1, 1}, this register does not
//! cause any event stream from the virtual counter to be generated, and does not control access to the
//! counters and timers. The access to counters and timers at EL0 is controlled by CNTHCTL_EL2.
//! cause any event stream from the virtual counter to be generated, and does not control access to
//! the counters and timers. The access to counters and timers at EL0 is controlled by CNTHCTL_EL2.
//!
//! When FEAT_VHE is not implemented, or when HCR_EL2.{E2H, TGE} is not {1, 1}, this register
//! controls the generation of an event stream from the virtual counter, and access from EL0 to the
Expand Down
32 changes: 32 additions & 0 deletions src/registers/cntpoff_el2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// Copyright (c) 2024 by the author(s)
//
// Author(s):
// - Sangwan Kwon <sangwan.kwon@samsung.com>

//! Counter-timer Physical Offset register - EL2
//!
//! Holds the 64-bit physical offset.
//! This is the offset for the AArch64 physical timers and counters
//! when Enhanced Counter Virtualization is enabled.
use tock_registers::interfaces::{Readable, Writeable};

pub struct Reg;

impl Readable for Reg {
type T = u64;
type R = ();

sys_coproc_read_raw!(u64, "CNTPOFF_EL2", "x");
}

impl Writeable for Reg {
type T = u64;
type R = ();

sys_coproc_write_raw!(u64, "CNTPOFF_EL2", "x");
}

pub const CNTPOFF_EL2: Reg = Reg {};
47 changes: 47 additions & 0 deletions src/registers/cptr_el2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// Copyright (c) 2024 by the author(s)
//
// Author(s):
// - Sangwan Kwon <sangwan.kwon@samsung.com>

//! Architectural Feature Trap Register - EL2
//!
//! Controls trapping to EL2 of accesses to CPACR, CPACR_EL1, trace, Activity Monitor, SME,
//! Streaming SVE, SVE, and Advanced SIMD and floating-point functionality.
use tock_registers::{
interfaces::{Readable, Writeable},
register_bitfields,
};

register_bitfields! {u64,
pub CPTR_EL2 [
/// Trap Activity Monitor access. Traps EL1 and EL0 accesses to all Activity Monitor
/// registers to EL2.
///
/// 0 Accesses from EL1 and EL0 to Activity Monitor registers are not trapped.
///
/// 1 Accesses from EL1 and EL0 to Activity Monitor registers are trapped to EL2,
/// when EL2 is enabled in the current Security state.
TAM OFFSET(30) NUMBITS(1) [],
]
}

pub struct Reg;

impl Readable for Reg {
type T = u64;
type R = CPTR_EL2::Register;

sys_coproc_read_raw!(u64, "CPTR_EL2", "x");
}

impl Writeable for Reg {
type T = u64;
type R = CPTR_EL2::Register;

sys_coproc_write_raw!(u64, "CPTR_EL2", "x");
}

pub const CPTR_EL2: Reg = Reg {};
2 changes: 1 addition & 1 deletion src/registers/esr_el1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl Readable for Reg {

impl Writeable for Reg {
type T = u64;
type R = ();
type R = ESR_EL1::Register;

sys_coproc_write_raw!(u64, "ESR_EL1", "x");
}
Expand Down
67 changes: 67 additions & 0 deletions src/registers/hcr_el2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,21 @@ register_bitfields! {u64,
EnableTrapSyncExtAbortsToEl2 = 1,
],

/// Trap accesses of Error Record registers. Enables a trap to EL2 on accesses of
/// Error Record registers.
///
/// 0 Accesses of the specified Error Record registers are not trapped by this mechanism.
/// 1 Accesses of the specified Error Record registers at EL1 are trapped to EL2,
/// unless the instruction generates a higher priority exception.
TERR OFFSET(36) NUMBITS(1) [],

/// Trap LOR registers. Traps Non-secure EL1 accesses to LORSA_EL1, LOREA_EL1, LORN_EL1,
/// LORC_EL1, and LORID_EL1 registers to EL2.
///
/// 0 This control does not cause any instructions to be trapped.
/// 1 Non-secure EL1 accesses to the LOR registers are trapped to EL2.
TLOR OFFSET(35) NUMBITS(1) [],

/// EL2 Host. Enables a configuration where a Host Operating System is running in EL2, and
/// the Host Operating System's applications are running in EL0.
E2H OFFSET(34) NUMBITS(1) [
Expand Down Expand Up @@ -128,6 +143,41 @@ register_bitfields! {u64,
EnableTrapGeneralExceptionsToEl2 = 1,
],

/// Trap data or unified cache maintenance instructions that operate by Set/Way.
/// Traps execution of those cache maintenance instructions at EL1 to EL2, when
/// EL2 is enabled in the current Security state.
///
/// 0 This control does not cause any instructions to be trapped.
/// 1 Execution of the specified instructions is trapped to EL2, when EL2 is enabled
/// in the current Security state.
TSW OFFSET(22) NUMBITS(1) [],

/// Trap Auxiliary Control Registers. Traps EL1 accesses to the Auxiliary Control Registers
/// to EL2, when EL2 is enabled in the current Security state
///
/// 0 This control does not cause any instructions to be trapped.
/// 1 EL1 accesses to the specified registers are trapped to EL2, when EL2 is enabled in the
/// current Security state.
TACR OFFSET(21) NUMBITS(1) [],

/// Trap IMPLEMENTATION DEFINED functionality. Traps EL1 accesses to the encodings reserved
/// for IMPLEMENTATION DEFINED functionality to EL2, when EL2 is enabled in the current
/// Security state
///
/// 0 This control does not cause any instructions to be trapped.
/// 1 EL1 accesses to or execution of the specified encodings reserved for IMPLEMENTATION
/// DEFINED functionality are trapped to EL2, when EL2 is enabled in the current Security
/// state.
TIDCP OFFSET(20) NUMBITS(1) [],

/// Trap ID group 3. Traps EL1 reads of group 3 ID registers to EL2, when EL2 is enabled
/// in the current Security state.
///
/// 0 This control does not cause any instructions to be trapped.
/// 1 The specified EL1 read accesses to ID group 3 registers are trapped to EL2, when EL2
/// is enabled in the current Security state.
TID3 OFFSET(18) NUMBITS(1) [],

/// Trap SMC instructions. Traps EL1 execution of SMC instructions to EL2, when EL2 is
/// enabled in the current Security state.
///
Expand Down Expand Up @@ -196,6 +246,23 @@ register_bitfields! {u64,
/// field behaves as 0 for all purposes other than a direct read of the value of this field.
DC OFFSET(12) NUMBITS(1) [],

/// Barrier Shareability upgrade. This field determines the minimum shareability domain that
/// is applied to any barrier instruction executed from EL1 or EL0.
BSU OFFSET(10) NUMBITS(2) [
NoEffect = 0b00,
InnerShareable = 0b01,
OuterShareable = 0b10,
FullSystem = 0b11
],

/// Force broadcast. Causes the following instructions to be broadcast within the Inner
/// Shareable domain when executed from EL1.
///
/// 0 This field has no effect on the operation of the specified instructions.
/// 1 When one of the specified instruction is executed at EL1, the instruction is broadcast
/// within the Inner Shareable shareability domain.
FB OFFSET(9) NUMBITS(1) [],

/// Physical SError interrupt routing.
/// - If bit is 1 when executing at any Exception level, and EL2 is enabled in the current
/// Security state:
Expand Down
33 changes: 33 additions & 0 deletions src/registers/hpfar_el2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// Copyright (c) 2024 by the author(s)
//
// Author(s):
// - Sangwan Kwon <sangwan.kwon@samsung.com>

//! Hypervisor IPA Fault Address Register - EL2
//!
//! Holds the faulting IPA for some aborts on a stage 2 translation taken to EL2.
use tock_registers::{interfaces::Readable, register_bitfields};

register_bitfields! {u64,
pub HPFAR_EL2 [
/// Faulting IPA address space.
NS OFFSET(63) NUMBITS(1) [],

/// Faulting Intermediate Physical Address.
FIPA OFFSET(4) NUMBITS(48) []
]
}

pub struct Reg;

impl Readable for Reg {
type T = u64;
type R = HPFAR_EL2::Register;

sys_coproc_read_raw!(u64, "HPFAR_EL2", "x");
}

pub const HPFAR_EL2: Reg = Reg {};
31 changes: 31 additions & 0 deletions src/registers/icc_ctlr_el1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// Copyright (c) 2024 by the author(s)
//
// Author(s):
// - Sangwan Kwon <sangwan.kwon@samsung.com>

//! Interrupt Controller Control Register - EL1
//!
//! Controls aspects of the behavior of the GIC CPU interface and provides information
//! about the features implemented.
use tock_registers::{interfaces::Readable, register_bitfields};

register_bitfields! {u64,
pub ICC_CTLR_EL1 [
/// Extended INTID range (read-only).
ExtRange OFFSET(19) NUMBITS(1) [],
]
}

pub struct Reg;

impl Readable for Reg {
type T = u64;
type R = ICC_CTLR_EL1::Register;

sys_coproc_read_raw!(u64, "ICC_CTLR_EL1", "x");
}

pub const ICC_CTLR_EL1: Reg = Reg {};
Loading

0 comments on commit 0a39fbd

Please sign in to comment.