mod apic;
mod boot;
mod dtables;
mod uart16550;
pub mod mem;
pub mod misc;
pub mod time;
#[cfg(feature = "smp")]
pub mod mp;
#[cfg(feature = "irq")]
pub mod irq {
pub use super::apic::*;
}
pub mod console {
pub use super::uart16550::*;
}
extern "C" {
fn rust_main(cpu_id: usize, dtb: usize) -> !;
#[cfg(feature = "smp")]
fn rust_main_secondary(cpu_id: usize) -> !;
}
fn current_cpu_id() -> usize {
match raw_cpuid::CpuId::new().get_feature_info() {
Some(finfo) => finfo.initial_local_apic_id() as usize,
None => 0,
}
}
unsafe extern "C" fn rust_entry(magic: usize, _mbi: usize) {
if magic == self::boot::MULTIBOOT_BOOTLOADER_MAGIC {
crate::mem::clear_bss();
crate::cpu::init_primary(current_cpu_id());
self::uart16550::init();
self::dtables::init_primary();
self::time::init_early();
rust_main(current_cpu_id(), 0);
}
}
#[allow(unused_variables)]
unsafe extern "C" fn rust_entry_secondary(magic: usize) {
#[cfg(feature = "smp")]
if magic == self::boot::MULTIBOOT_BOOTLOADER_MAGIC {
crate::cpu::init_secondary(current_cpu_id());
self::dtables::init_secondary();
rust_main_secondary(current_cpu_id());
}
}
pub fn platform_init() {
self::apic::init_primary();
self::time::init_primary();
}
#[cfg(feature = "smp")]
pub fn platform_init_secondary() {
self::apic::init_secondary();
self::time::init_secondary();
}