From 0c6c07cab00b8eea90ddf09f8e8674ed8bce8e8e Mon Sep 17 00:00:00 2001 From: Graham MacDonald Date: Sun, 17 Sep 2023 14:15:48 +0100 Subject: [PATCH] Tidy Signed-off-by: Graham MacDonald --- aarch64/src/registers.rs | 75 +--------------------------------------- aarch64/src/vm.rs | 2 ++ 2 files changed, 3 insertions(+), 74 deletions(-) diff --git a/aarch64/src/registers.rs b/aarch64/src/registers.rs index 5919510..fa7152d 100644 --- a/aarch64/src/registers.rs +++ b/aarch64/src/registers.rs @@ -179,6 +179,7 @@ bitstruct! { } } +#[allow(dead_code)] impl EsrEl1IssInstructionAbort { pub fn from_esr_el1(r: EsrEl1) -> Option { r.exception_class_enum() @@ -235,36 +236,6 @@ pub enum InstructionFaultStatusCode { UnsupportedAtomicHardwareUpdateFault = 49, } -bitstruct! { - #[derive(Copy, Clone)] - pub struct Vaddr4K4K(pub u64) { - offset: u16 = 0..12; - l4idx: u16 = 12..21; - l3idx: u16 = 21..30; - l2idx: u16 = 30..39; - l1idx: u16 = 39..48; - } -} - -bitstruct! { - #[derive(Copy, Clone)] - pub struct Vaddr4K2M(pub u64) { - offset: u32 = 0..21; - l3idx: u16 = 21..30; - l2idx: u16 = 30..39; - l1idx: u16 = 39..48; - } -} - -bitstruct! { - #[derive(Copy, Clone)] - pub struct Vaddr4K1G(pub u64) { - offset: u32 = 0..30; - l2idx: u16 = 30..39; - l1idx: u16 = 39..48; - } -} - #[cfg(test)] mod tests { use super::*; @@ -289,48 +260,4 @@ mod tests { InstructionFaultStatusCode::TranslationFaultLevel0 ); } - - #[test] - fn breakdown_vadder() { - let va = Vaddr4K4K(0xffff_8000_0000_0000); - assert_eq!(va.l1idx(), 256); - assert_eq!(va.l2idx(), 0); - assert_eq!(va.l3idx(), 0); - assert_eq!(va.l4idx(), 0); - assert_eq!(va.offset(), 0); - - let va = Vaddr4K4K(0x0000_0000_0008_00a8); - assert_eq!(va.l1idx(), 0); - assert_eq!(va.l2idx(), 0); - assert_eq!(va.l3idx(), 0); - assert_eq!(va.l4idx(), 128); - assert_eq!(va.offset(), 168); - - let va = Vaddr4K2M(0xffff_8000_3f00_0000); - assert_eq!(va.l1idx(), 256); - assert_eq!(va.l2idx(), 0); - assert_eq!(va.l3idx(), 504); - assert_eq!(va.offset(), 0); - - let va = Vaddr4K2M(0xffff_8000_fe00_0000); - assert_eq!(va.l1idx(), 256); - assert_eq!(va.l2idx(), 3); - assert_eq!(va.l3idx(), 496); - assert_eq!(va.offset(), 0); - - let va = Vaddr4K1G(0xffff_8000_0000_0000); - assert_eq!(va.l1idx(), 256); - assert_eq!(va.l2idx(), 0); - assert_eq!(va.offset(), 0); - - let va = Vaddr4K1G(0x0000_0000_0008_00a8); - assert_eq!(va.l1idx(), 0); - assert_eq!(va.l2idx(), 0); - assert_eq!(va.offset(), 524456); - - let va = Vaddr4K1G(0xffff_8000_0010_00c8); - assert_eq!(va.l1idx(), 256); - assert_eq!(va.l2idx(), 0); - assert_eq!(va.offset(), 0x1000c8); - } } diff --git a/aarch64/src/vm.rs b/aarch64/src/vm.rs index 6633632..f9ba865 100644 --- a/aarch64/src/vm.rs +++ b/aarch64/src/vm.rs @@ -20,6 +20,7 @@ pub const PAGE_SIZE_4K: usize = 4 * 1024; pub const PAGE_SIZE_2M: usize = 2 * 1024 * 1024; pub const PAGE_SIZE_1G: usize = 1 * 1024 * 1024 * 1024; +#[allow(dead_code)] #[derive(Debug, Clone, Copy)] pub enum PageSize { Page4K, @@ -271,6 +272,7 @@ impl Table { Some(unsafe { &*(raw_ptr as *const Table) }) } + #[allow(dead_code)] fn next(&self, level: Level, va: usize) -> Option<&Table> { let index = Self::index(level, va); let entry = self.entries[index];