diff --git a/kernel/src/arch/aarch64/board/raspi3/mod.rs b/kernel/src/arch/aarch64/board/raspi3/mod.rs index dd1abdab..bfaa4f68 100644 --- a/kernel/src/arch/aarch64/board/raspi3/mod.rs +++ b/kernel/src/arch/aarch64/board/raspi3/mod.rs @@ -9,10 +9,16 @@ pub mod serial; pub const IO_REMAP_BASE: usize = bcm2837::IO_BASE; pub const IO_REMAP_END: usize = 0x40001000; -pub fn init() { +/// Some initializations must be done before other initializations. +pub fn init_early() { assert_has_not_been_called!("board::init must be called only once"); serial::SERIAL_PORT.lock().init(); println!("Hello Raspberry Pi!"); } + +/// Initialize raspi3 drivers +pub fn init_driver() { + timer::init(); +} diff --git a/kernel/src/arch/aarch64/driver/mod.rs b/kernel/src/arch/aarch64/driver/mod.rs new file mode 100644 index 00000000..43d8c43a --- /dev/null +++ b/kernel/src/arch/aarch64/driver/mod.rs @@ -0,0 +1,12 @@ +/// ARM64 drivers + +use once::*; + +use super::board; + +/// Initialize ARM64 common drivers +pub fn init() { + assert_has_not_been_called!(); + + board::init_driver(); +} diff --git a/kernel/src/arch/aarch64/mod.rs b/kernel/src/arch/aarch64/mod.rs index b96f24e4..1d9269ff 100644 --- a/kernel/src/arch/aarch64/mod.rs +++ b/kernel/src/arch/aarch64/mod.rs @@ -6,29 +6,25 @@ pub mod memory; pub mod interrupt; pub mod consts; pub mod cpu; +pub mod driver; #[cfg(feature = "board_raspi3")] #[path = "board/raspi3/mod.rs"] pub mod board; -pub use self::board::timer; - global_asm!(include_str!("boot/boot.S")); /// The entry point of kernel #[no_mangle] // don't mangle the name of this function pub extern "C" fn rust_main() -> ! { - // Enable mmu and paging - memory::init_mmu_early(); - - // Init board to enable serial port. - board::init(); + memory::init_mmu_early(); // Enable mmu and paging + board::init_early(); println!("{}", LOGO); crate::logging::init(); interrupt::init(); memory::init(); - timer::init(); + driver::init(); crate::process::init();