1#![no_std]
8
9use core::fmt::Write;
10
11pub mod mpu {
12 use kernel::utilities::StaticRef;
13
14 pub type MPU = cortexm::mpu::MPU<8, 32>;
15
16 const MPU_BASE_ADDRESS: StaticRef<cortexm::mpu::MpuRegisters> =
17 unsafe { StaticRef::new(0xE000ED90 as *const cortexm::mpu::MpuRegisters) };
18
19 pub unsafe fn new() -> MPU {
20 MPU::new(MPU_BASE_ADDRESS)
21 }
22}
23
24pub use cortexm::dwt;
25pub use cortexm::initialize_ram_jump_to_main;
26pub use cortexm::nvic;
27pub use cortexm::scb;
28pub use cortexm::support;
29pub use cortexm::systick;
30pub use cortexm::thread_id;
31pub use cortexm::unhandled_interrupt;
32pub use cortexm::CortexMVariant;
33
34pub enum CortexM4 {}
38
39impl cortexm::CortexMVariant for CortexM4 {
40 const GENERIC_ISR: unsafe extern "C" fn() = cortexv7m::generic_isr_arm_v7m;
41 const SYSTICK_HANDLER: unsafe extern "C" fn() = cortexv7m::systick_handler_arm_v7m;
42 const SVC_HANDLER: unsafe extern "C" fn() = cortexv7m::svc_handler_arm_v7m;
43 const HARD_FAULT_HANDLER: unsafe extern "C" fn() = cortexv7m::hard_fault_handler_arm_v7m;
44
45 #[cfg(all(target_arch = "arm", target_os = "none"))]
46 unsafe fn switch_to_user(
47 user_stack: *const usize,
48 process_regs: &mut [usize; 8],
49 ) -> *const usize {
50 cortexv7m::switch_to_user_arm_v7m(user_stack, process_regs)
51 }
52
53 #[cfg(not(all(target_arch = "arm", target_os = "none")))]
54 unsafe fn switch_to_user(
55 _user_stack: *const usize,
56 _process_regs: &mut [usize; 8],
57 ) -> *const usize {
58 unimplemented!()
59 }
60
61 #[inline]
62 unsafe fn print_cortexm_state(writer: &mut dyn Write) {
63 cortexm::print_cortexm_state(writer)
64 }
65}
66
67pub mod syscall {
68 pub type SysCall = cortexm::syscall::SysCall<crate::CortexM4>;
69}