Skip to content
This repository was archived by the owner on Nov 7, 2022. It is now read-only.

Commit 936ac6e

Browse files
committed
Add the VTTBR_EL2 register
1 parent 6af3add commit 936ac6e

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

src/registers.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ mod ttbr1_el1;
6767
mod vbar_el1;
6868
mod vbar_el2;
6969
mod vtcr_el2;
70+
mod vttbr_el2;
7071

7172
pub use actlr_el1::ACTLR_EL1;
7273
pub use actlr_el2::ACTLR_EL2;
@@ -129,3 +130,4 @@ pub use ttbr1_el1::TTBR1_EL1;
129130
pub use vbar_el1::VBAR_EL1;
130131
pub use vbar_el2::VBAR_EL2;
131132
pub use vtcr_el2::VTCR_EL2;
133+
pub use vttbr_el2::VTTBR_EL2;

src/registers/vttbr_el2.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// SPDX-License-Identifier: Apache-2.0 OR MIT
2+
//
3+
// Copyright (c) 2018-2022 by the author(s)
4+
//
5+
// Author(s):
6+
// - KarimAllah Ahmed <karahmed@amazon.com>
7+
// - Andre Richter <andre.o.richter@gmail.com>
8+
9+
use tock_registers::{
10+
interfaces::{Readable, Writeable},
11+
register_bitfields,
12+
};
13+
14+
register_bitfields! {u64,
15+
pub VTTBR_EL2 [
16+
/// An VMID for the translation table
17+
///
18+
/// If the implementation only supports 8-bit VM IDs the top 8 bits are RES0
19+
VMID OFFSET(48) NUMBITS(16) [],
20+
21+
/// Translation table base address
22+
BADDR OFFSET(1) NUMBITS(48) [],
23+
24+
/// Common not Private
25+
CnP OFFSET(0) NUMBITS(1) []
26+
]
27+
}
28+
29+
pub struct Reg;
30+
31+
impl Readable for Reg {
32+
type T = u64;
33+
type R = VTTBR_EL2::Register;
34+
35+
sys_coproc_read_raw!(u64, "VTTBR_EL2", "x");
36+
}
37+
38+
impl Writeable for Reg {
39+
type T = u64;
40+
type R = VTTBR_EL2::Register;
41+
42+
sys_coproc_write_raw!(u64, "VTTBR_EL2", "x");
43+
}
44+
45+
impl Reg {
46+
#[inline(always)]
47+
pub fn get_baddr(&self) -> u64 {
48+
self.read(VTTBR_EL2::BADDR) << 1
49+
}
50+
51+
#[inline(always)]
52+
pub fn set_baddr(&self, addr: u64) {
53+
self.write(VTTBR_EL2::BADDR.val(addr >> 1));
54+
}
55+
}
56+
57+
pub const VTTBR_EL2: Reg = Reg {};

0 commit comments

Comments
 (0)