diff --git a/src/arch/aarch64/interrupt/exception.rs b/src/arch/aarch64/interrupt/exception.rs index 63c68918ce..cb4c6c4ccf 100644 --- a/src/arch/aarch64/interrupt/exception.rs +++ b/src/arch/aarch64/interrupt/exception.rs @@ -147,21 +147,23 @@ unsafe fn instr_trapped_msr_mrs_inner( } exception_stack!(synchronous_exception_at_el1_with_spx, |stack| { - if !pf_inner( - stack, - exception_code(stack.iret.esr_el1), - "sync_exc_el1_spx", - ) { - println!("Synchronous exception at EL1 with SPx"); - if exception_code(stack.iret.esr_el1) == 0b100101 { - let far_el1 = far_el1(); - println!("FAR_EL1 = 0x{:08x}", far_el1); - } else if exception_code(stack.iret.esr_el1) == 0b100100 { - let far_el1 = far_el1(); - println!("USER FAR_EL1 = 0x{:08x}", far_el1); + unsafe { + if !pf_inner( + stack, + exception_code(stack.iret.esr_el1), + "sync_exc_el1_spx", + ) { + println!("Synchronous exception at EL1 with SPx"); + if exception_code(stack.iret.esr_el1) == 0b100101 { + let far_el1 = far_el1(); + println!("FAR_EL1 = 0x{:08x}", far_el1); + } else if exception_code(stack.iret.esr_el1) == 0b100100 { + let far_el1 = far_el1(); + println!("USER FAR_EL1 = 0x{:08x}", far_el1); + } + stack.trace(); + loop {} } - stack.trace(); - loop {} } }); unsafe fn pf_inner(stack: &mut InterruptStack, ty: u8, from: &str) -> bool { @@ -184,29 +186,31 @@ unsafe fn pf_inner(stack: &mut InterruptStack, ty: u8, from: &str) -> bool { } exception_stack!(synchronous_exception_at_el0, |stack| { - match exception_code(stack.iret.esr_el1) { - 0b010101 => { - let scratch = &stack.scratch; - let mut token = unsafe { CleanLockToken::new() }; - let ret = syscall::syscall( - scratch.x8, scratch.x0, scratch.x1, scratch.x2, scratch.x3, scratch.x4, scratch.x5, - &mut token, - ); - stack.scratch.x0 = ret; - } - - ty => { - if !pf_inner(stack, ty as u8, "sync_exc_el0") { - error!( - "FATAL: Not an SVC induced synchronous exception (ty={:b})", - ty + unsafe { + match exception_code(stack.iret.esr_el1) { + 0b010101 => { + let scratch = &stack.scratch; + let mut token = CleanLockToken::new(); + let ret = syscall::syscall( + scratch.x8, scratch.x0, scratch.x1, scratch.x2, scratch.x3, scratch.x4, + scratch.x5, &mut token, ); - println!("FAR_EL1: {:#0x}", far_el1()); - //crate::debugger::debugger(None); - stack.trace(); - excp_handler(Exception { - kind: 0, // TODO - }); + stack.scratch.x0 = ret; + } + + ty => { + if !pf_inner(stack, ty as u8, "sync_exc_el0") { + error!( + "FATAL: Not an SVC induced synchronous exception (ty={:b})", + ty + ); + println!("FAR_EL1: {:#0x}", far_el1()); + //crate::debugger::debugger(None); + stack.trace(); + excp_handler(Exception { + kind: 0, // TODO + }); + } } } } diff --git a/src/arch/aarch64/interrupt/handler.rs b/src/arch/aarch64/interrupt/handler.rs index 85b2b4546c..641babbfb7 100644 --- a/src/arch/aarch64/interrupt/handler.rs +++ b/src/arch/aarch64/interrupt/handler.rs @@ -26,12 +26,6 @@ pub struct ScratchRegisters { } impl ScratchRegisters { - pub fn a(&self) -> usize { - self.x0 - } - pub fn b(&self) -> usize { - self.x1 - } pub fn dump(&self) { println!("X0: {:>016X}", { self.x0 }); println!("X1: {:>016X}", { self.x1 }); @@ -387,9 +381,9 @@ macro_rules! exception_stack { #[unsafe(naked)] #[unsafe(no_mangle)] pub unsafe extern "C" fn $name(stack: &mut $crate::arch::aarch64::interrupt::InterruptStack) { - unsafe extern "C" fn inner($stack: &mut $crate::arch::aarch64::interrupt::InterruptStack) { unsafe { + unsafe extern "C" fn inner($stack: &mut $crate::arch::aarch64::interrupt::InterruptStack) { $code - }} + } core::arch::naked_asm!( // Backup all userspace registers to stack push_preserved!(), diff --git a/src/arch/aarch64/interrupt/irq.rs b/src/arch/aarch64/interrupt/irq.rs index e5851e1229..297205222e 100644 --- a/src/arch/aarch64/interrupt/irq.rs +++ b/src/arch/aarch64/interrupt/irq.rs @@ -15,26 +15,30 @@ unsafe fn irq_ack() -> (u32, Option) { } exception_stack!(irq_at_el0, |_stack| { - let mut token = unsafe { CleanLockToken::new() }; - let (irq, virq) = irq_ack(); - if let Some(virq) = virq - && virq < 1024 - { - IRQ_CHIP.trigger_virq(virq as u32, &mut token); - } else { - println!("unexpected irq num {}", irq); + unsafe { + let mut token = CleanLockToken::new(); + let (irq, virq) = irq_ack(); + if let Some(virq) = virq + && virq < 1024 + { + IRQ_CHIP.trigger_virq(virq as u32, &mut token); + } else { + println!("unexpected irq num {}", irq); + } } }); exception_stack!(irq_at_el1, |_stack| { - let mut token = unsafe { CleanLockToken::new() }; - let (irq, virq) = irq_ack(); - if let Some(virq) = virq - && virq < 1024 - { - IRQ_CHIP.trigger_virq(virq as u32, &mut token); - } else { - println!("unexpected irq num {}", irq); + unsafe { + let mut token = CleanLockToken::new(); + let (irq, virq) = irq_ack(); + if let Some(virq) = virq + && virq < 1024 + { + IRQ_CHIP.trigger_virq(virq as u32, &mut token); + } else { + println!("unexpected irq num {}", irq); + } } }); diff --git a/src/arch/aarch64/start.rs b/src/arch/aarch64/start.rs index a86f6d0517..6f87f7990e 100644 --- a/src/arch/aarch64/start.rs +++ b/src/arch/aarch64/start.rs @@ -76,12 +76,10 @@ unsafe extern "C" fn start(args_ptr: *const KernelArgs) -> ! { // Get hardware descriptor data //TODO: use env {DTB,RSDT}_{BASE,SIZE}? let hwdesc_data = if args.hwdesc_base != 0 { - Some(unsafe { - slice::from_raw_parts( - (crate::PHYS_OFFSET + args.hwdesc_base as usize) as *const u8, - args.hwdesc_size as usize, - ) - }) + Some(slice::from_raw_parts( + (crate::PHYS_OFFSET + args.hwdesc_base as usize) as *const u8, + args.hwdesc_size as usize, + )) } else { None }; diff --git a/src/arch/aarch64/stop.rs b/src/arch/aarch64/stop.rs index cab73fbbea..6c832f9d0e 100644 --- a/src/arch/aarch64/stop.rs +++ b/src/arch/aarch64/stop.rs @@ -21,7 +21,7 @@ pub unsafe fn emergency_reset() -> ! { } } -pub unsafe fn kstop(token: &mut CleanLockToken) -> ! { +pub unsafe fn kstop(_token: &mut CleanLockToken) -> ! { unsafe { println!("kstop"); diff --git a/src/arch/riscv64/interrupt/mod.rs b/src/arch/riscv64/interrupt/mod.rs index edd113e5d4..e60df94659 100644 --- a/src/arch/riscv64/interrupt/mod.rs +++ b/src/arch/riscv64/interrupt/mod.rs @@ -16,12 +16,6 @@ pub unsafe fn disable() { unsafe { asm!("csrci sstatus, 1 << 1") } } -/// Set interrupts -#[inline(always)] -pub unsafe fn enable() { - unsafe { asm!("csrsi sstatus, 1 << 1") } -} - /// Set interrupts and halt /// This will atomically wait for the next interrupt /// Performing enable followed by halt is not guaranteed to be atomic, use this instead! diff --git a/src/arch/riscv64/paging/mod.rs b/src/arch/riscv64/paging/mod.rs index 993f4b445b..96a5488557 100644 --- a/src/arch/riscv64/paging/mod.rs +++ b/src/arch/riscv64/paging/mod.rs @@ -4,7 +4,6 @@ pub use super::CurrentRmmArch as RmmA; pub use rmm::{Arch as RmmArch, PageFlags, PhysicalAddress, TableKind, VirtualAddress}; pub type PageMapper = rmm::PageMapper; -pub use crate::rmm::KernelMapper; pub mod mapper; diff --git a/src/arch/riscv64/rmm.rs b/src/arch/riscv64/rmm.rs index a4be789a32..453382c44c 100644 --- a/src/arch/riscv64/rmm.rs +++ b/src/arch/riscv64/rmm.rs @@ -1,18 +1,5 @@ use rmm::{Arch, PageFlags, VirtualAddress}; -pub struct KernelMapper { - mapper: crate::paging::PageMapper, - ro: bool, -} -impl KernelMapper { - pub fn lock() -> Self { - unimplemented!() - } - pub fn get_mut(&mut self) -> Option<&mut crate::paging::PageMapper> { - unimplemented!() - } -} - pub unsafe fn page_flags(virt: VirtualAddress) -> PageFlags { use crate::kernel_executable_offsets::*; let virt_addr = virt.data(); diff --git a/src/arch/riscv64/stop.rs b/src/arch/riscv64/stop.rs index 540883cd0a..920aa60793 100644 --- a/src/arch/riscv64/stop.rs +++ b/src/arch/riscv64/stop.rs @@ -9,7 +9,7 @@ pub unsafe fn emergency_reset() -> ! { unimplemented!() } -pub unsafe fn kstop(token: &mut CleanLockToken) -> ! { +pub unsafe fn kstop(_token: &mut CleanLockToken) -> ! { println!("kstop"); unimplemented!() }