Skip to content

Commit cbbc355

Browse files
committed
Add a lot more registers.
The values are taken from the Cortex-R52 Reference Manual. We only have basic reads/writes for the new ones - I haven't drilled down into the bitfields.
1 parent 763daec commit cbbc355

File tree

234 files changed

+7670
-100
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

234 files changed

+7670
-100
lines changed

cortex-r-examples/src/bin/gic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn dump_cpsr() {
4242
/// Called by [`kmain`].
4343
fn main() -> Result<(), core::fmt::Error> {
4444
// Get the GIC address by reading CBAR
45-
let periphbase = cortex_r::register::Cbar::read().periphbase();
45+
let periphbase = cortex_r::register::ImpCbar::read().periphbase();
4646
println!("Found PERIPHBASE {:010p}", periphbase);
4747
let gicd_base = periphbase.wrapping_byte_add(GICD_BASE_OFFSET);
4848
let gicr_base = periphbase.wrapping_byte_add(GICR_BASE_OFFSET);

cortex-r-examples/src/bin/registers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub extern "C" fn kmain() {
2222
println!("{:?}", cortex_r::register::Cpsr::read());
2323
#[cfg(arm_architecture = "v8-r")]
2424
{
25-
println!("{:?}", cortex_r::register::Cbar::read());
25+
println!("{:?}", cortex_r::register::ImpCbar::read());
2626
println!("{:?}", cortex_r::register::Vbar::read());
2727
// This only works in EL2 and start-up put us in EL1
2828
// println!("{:?}", cortex_r::register::Hvbar::read());

cortex-r/src/register/actlr.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//! Code for managing ACTLR (*Auxiliary Control Register*)
2+
3+
use crate::register::{SysReg, SysRegRead, SysRegWrite};
4+
5+
/// ACTLR (*Auxiliary Control Register*)
6+
pub struct Actlr(pub u32);
7+
impl SysReg for Actlr {
8+
const CP: u32 = 15;
9+
const CRN: u32 = 1;
10+
const OP1: u32 = 0;
11+
const CRM: u32 = 0;
12+
const OP2: u32 = 1;
13+
}
14+
impl crate::register::SysRegRead for Actlr {}
15+
impl Actlr {
16+
#[inline]
17+
/// Reads ACTLR (*Auxiliary Control Register*)
18+
pub fn read() -> Actlr {
19+
unsafe { Self(<Self as SysRegRead>::read_raw()) }
20+
}
21+
}
22+
impl crate::register::SysRegWrite for Actlr {}
23+
impl Actlr {
24+
#[inline]
25+
/// Writes ACTLR (*Auxiliary Control Register*)
26+
///
27+
/// # Safety
28+
///
29+
/// Ensure that this value is appropriate for this register
30+
pub unsafe fn write(value: Self) {
31+
unsafe {
32+
<Self as SysRegWrite>::write_raw(value.0);
33+
}
34+
}
35+
}

cortex-r/src/register/actlr2.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//! Code for managing ACTLR2 (*Auxiliary Control Register 2*)
2+
3+
use crate::register::{SysReg, SysRegRead, SysRegWrite};
4+
5+
/// ACTLR2 (*Auxiliary Control Register 2*)
6+
pub struct Actlr2(pub u32);
7+
impl SysReg for Actlr2 {
8+
const CP: u32 = 15;
9+
const CRN: u32 = 1;
10+
const OP1: u32 = 0;
11+
const CRM: u32 = 0;
12+
const OP2: u32 = 3;
13+
}
14+
impl crate::register::SysRegRead for Actlr2 {}
15+
impl Actlr2 {
16+
#[inline]
17+
/// Reads ACTLR2 (*Auxiliary Control Register 2*)
18+
pub fn read() -> Actlr2 {
19+
unsafe { Self(<Self as SysRegRead>::read_raw()) }
20+
}
21+
}
22+
impl crate::register::SysRegWrite for Actlr2 {}
23+
impl Actlr2 {
24+
#[inline]
25+
/// Writes ACTLR2 (*Auxiliary Control Register 2*)
26+
///
27+
/// # Safety
28+
///
29+
/// Ensure that this value is appropriate for this register
30+
pub unsafe fn write(value: Self) {
31+
unsafe {
32+
<Self as SysRegWrite>::write_raw(value.0);
33+
}
34+
}
35+
}

cortex-r/src/register/adfsr.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//! Code for managing ADFSR (*Auxiliary Data Fault Status Register*)
2+
3+
use crate::register::{SysReg, SysRegRead, SysRegWrite};
4+
5+
/// ADFSR (*Auxiliary Data Fault Status Register*)
6+
pub struct Adfsr(pub u32);
7+
impl SysReg for Adfsr {
8+
const CP: u32 = 15;
9+
const CRN: u32 = 5;
10+
const OP1: u32 = 0;
11+
const CRM: u32 = 1;
12+
const OP2: u32 = 0;
13+
}
14+
impl crate::register::SysRegRead for Adfsr {}
15+
impl Adfsr {
16+
#[inline]
17+
/// Reads ADFSR (*Auxiliary Data Fault Status Register*)
18+
pub fn read() -> Adfsr {
19+
unsafe { Self(<Self as SysRegRead>::read_raw()) }
20+
}
21+
}
22+
impl crate::register::SysRegWrite for Adfsr {}
23+
impl Adfsr {
24+
#[inline]
25+
/// Writes ADFSR (*Auxiliary Data Fault Status Register*)
26+
///
27+
/// # Safety
28+
///
29+
/// Ensure that this value is appropriate for this register
30+
pub unsafe fn write(value: Self) {
31+
unsafe {
32+
<Self as SysRegWrite>::write_raw(value.0);
33+
}
34+
}
35+
}

cortex-r/src/register/aidr.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//! Code for managing AIDR (*Auxiliary ID Register*)
2+
3+
use crate::register::{SysReg, SysRegRead};
4+
5+
/// AIDR (*Auxiliary ID Register*)
6+
pub struct Aidr(pub u32);
7+
impl SysReg for Aidr {
8+
const CP: u32 = 15;
9+
const CRN: u32 = 0;
10+
const OP1: u32 = 1;
11+
const CRM: u32 = 0;
12+
const OP2: u32 = 7;
13+
}
14+
impl crate::register::SysRegRead for Aidr {}
15+
impl Aidr {
16+
#[inline]
17+
/// Reads AIDR (*Auxiliary ID Register*)
18+
pub fn read() -> Aidr {
19+
unsafe { Self(<Self as SysRegRead>::read_raw()) }
20+
}
21+
}

cortex-r/src/register/aifsr.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//! Code for managing AIFSR (*Auxiliary Instruction Fault Status Register*)
2+
3+
use crate::register::{SysReg, SysRegRead, SysRegWrite};
4+
5+
/// AIFSR (*Auxiliary Instruction Fault Status Register*)
6+
pub struct Aifsr(pub u32);
7+
impl SysReg for Aifsr {
8+
const CP: u32 = 15;
9+
const CRN: u32 = 5;
10+
const OP1: u32 = 0;
11+
const CRM: u32 = 1;
12+
const OP2: u32 = 1;
13+
}
14+
impl crate::register::SysRegRead for Aifsr {}
15+
impl Aifsr {
16+
#[inline]
17+
/// Reads AIFSR (*Auxiliary Instruction Fault Status Register*)
18+
pub fn read() -> Aifsr {
19+
unsafe { Self(<Self as SysRegRead>::read_raw()) }
20+
}
21+
}
22+
impl crate::register::SysRegWrite for Aifsr {}
23+
impl Aifsr {
24+
#[inline]
25+
/// Writes AIFSR (*Auxiliary Instruction Fault Status Register*)
26+
///
27+
/// # Safety
28+
///
29+
/// Ensure that this value is appropriate for this register
30+
pub unsafe fn write(value: Self) {
31+
unsafe {
32+
<Self as SysRegWrite>::write_raw(value.0);
33+
}
34+
}
35+
}

cortex-r/src/register/amair0.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//! Code for managing AMAIR0 (*Auxiliary Memory Attribute Indirection Register 0*)
2+
3+
use crate::register::{SysReg, SysRegRead, SysRegWrite};
4+
5+
/// AMAIR0 (*Auxiliary Memory Attribute Indirection Register 0*)
6+
pub struct Amair0(pub u32);
7+
impl SysReg for Amair0 {
8+
const CP: u32 = 15;
9+
const CRN: u32 = 10;
10+
const OP1: u32 = 0;
11+
const CRM: u32 = 3;
12+
const OP2: u32 = 0;
13+
}
14+
impl crate::register::SysRegRead for Amair0 {}
15+
impl Amair0 {
16+
#[inline]
17+
/// Reads AMAIR0 (*Auxiliary Memory Attribute Indirection Register 0*)
18+
pub fn read() -> Amair0 {
19+
unsafe { Self(<Self as SysRegRead>::read_raw()) }
20+
}
21+
}
22+
impl crate::register::SysRegWrite for Amair0 {}
23+
impl Amair0 {
24+
#[inline]
25+
/// Writes AMAIR0 (*Auxiliary Memory Attribute Indirection Register 0*)
26+
///
27+
/// # Safety
28+
///
29+
/// Ensure that this value is appropriate for this register
30+
pub unsafe fn write(value: Self) {
31+
unsafe {
32+
<Self as SysRegWrite>::write_raw(value.0);
33+
}
34+
}
35+
}

cortex-r/src/register/amair1.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//! Code for managing AMAIR1 (*Auxiliary Memory Attribute Indirection Register 1*)
2+
3+
use crate::register::{SysReg, SysRegRead, SysRegWrite};
4+
5+
/// AMAIR1 (*Auxiliary Memory Attribute Indirection Register 1*)
6+
pub struct Amair1(pub u32);
7+
impl SysReg for Amair1 {
8+
const CP: u32 = 15;
9+
const CRN: u32 = 10;
10+
const OP1: u32 = 0;
11+
const CRM: u32 = 3;
12+
const OP2: u32 = 1;
13+
}
14+
impl crate::register::SysRegRead for Amair1 {}
15+
impl Amair1 {
16+
#[inline]
17+
/// Reads AMAIR1 (*Auxiliary Memory Attribute Indirection Register 1*)
18+
pub fn read() -> Amair1 {
19+
unsafe { Self(<Self as SysRegRead>::read_raw()) }
20+
}
21+
}
22+
impl crate::register::SysRegWrite for Amair1 {}
23+
impl Amair1 {
24+
#[inline]
25+
/// Writes AMAIR1 (*Auxiliary Memory Attribute Indirection Register 1*)
26+
///
27+
/// # Safety
28+
///
29+
/// Ensure that this value is appropriate for this register
30+
pub unsafe fn write(value: Self) {
31+
unsafe {
32+
<Self as SysRegWrite>::write_raw(value.0);
33+
}
34+
}
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//! Code for managing CNTHCTL (*Counter-timer Hyp Control Register*)
2+
3+
use crate::register::{SysReg, SysRegRead, SysRegWrite};
4+
5+
/// CNTHCTL (*Counter-timer Hyp Control Register*)
6+
pub struct Cnthctl(pub u32);
7+
impl SysReg for Cnthctl {
8+
const CP: u32 = 15;
9+
const CRN: u32 = 14;
10+
const OP1: u32 = 4;
11+
const CRM: u32 = 1;
12+
const OP2: u32 = 0;
13+
}
14+
impl crate::register::SysRegRead for Cnthctl {}
15+
impl Cnthctl {
16+
#[inline]
17+
/// Reads CNTHCTL (*Counter-timer Hyp Control Register*)
18+
pub fn read() -> Cnthctl {
19+
unsafe { Self(<Self as SysRegRead>::read_raw()) }
20+
}
21+
}
22+
impl crate::register::SysRegWrite for Cnthctl {}
23+
impl Cnthctl {
24+
#[inline]
25+
/// Writes CNTHCTL (*Counter-timer Hyp Control Register*)
26+
///
27+
/// # Safety
28+
///
29+
/// Ensure that this value is appropriate for this register
30+
pub unsafe fn write(value: Self) {
31+
unsafe {
32+
<Self as SysRegWrite>::write_raw(value.0);
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)