88 lines
1.7 KiB
Rust
88 lines
1.7 KiB
Rust
#![feature(
|
|
global_asm,
|
|
llvm_asm,
|
|
const_panic,
|
|
maybe_uninit_uninit_array,
|
|
alloc_error_handler,
|
|
const_fn_trait_bound
|
|
)]
|
|
#![no_std]
|
|
#![no_main]
|
|
|
|
#[macro_use]
|
|
extern crate cfg_if;
|
|
extern crate alloc;
|
|
|
|
#[macro_use]
|
|
pub mod debug;
|
|
|
|
pub mod arch;
|
|
pub mod boot;
|
|
pub mod dev;
|
|
#[cfg(feature = "fdt-rs")]
|
|
pub mod fdt;
|
|
pub mod mem;
|
|
pub mod time;
|
|
pub mod proc;
|
|
pub mod sync;
|
|
|
|
pub use mem::KernelSpace;
|
|
|
|
use address::PhysicalAddress;
|
|
use arch::{timer, cpu, intrin};
|
|
use dev::irq::{self, InterruptController};
|
|
use dev::virtio::Display;
|
|
use dev::pcie::HostPci;
|
|
|
|
#[no_mangle]
|
|
extern "C" fn kernel_bsp_main(fdt_base: PhysicalAddress) -> ! {
|
|
cpu::init(0);
|
|
dev::serial::init();
|
|
|
|
cfg_if! {
|
|
if #[cfg(feature = "fdt-rs")] {
|
|
// Initialize memory from FDT information
|
|
fdt::init_phys_memory(fdt_base);
|
|
fdt::init(fdt_base);
|
|
} else {
|
|
// Platform-specific memory init
|
|
mem::phys::init_from_platform();
|
|
}
|
|
}
|
|
mem::heap::init();
|
|
arch::machine::init();
|
|
|
|
// Enable IRQs for SERIAL0
|
|
let intc = irq::get_intc();
|
|
irq::set_irq_handler(arch::machine::IRQ_UART, &dev::serial::SERIAL0);
|
|
unsafe {
|
|
intc.enable_irq(arch::machine::IRQ_UART);
|
|
}
|
|
|
|
debug!("BSP init finished\n");
|
|
unsafe {
|
|
irq::init();
|
|
timer::enable_local_timer();
|
|
}
|
|
|
|
let mut bus = HostPci::new(PhysicalAddress::new(0x10000000));
|
|
unsafe {
|
|
use dev::Device;
|
|
bus.enable();
|
|
}
|
|
//let mut display = Display::new();
|
|
|
|
loop {}
|
|
//proc::enter();
|
|
}
|
|
|
|
use core::panic::PanicInfo;
|
|
#[panic_handler]
|
|
fn panic_handler(pi: &PanicInfo) -> ! {
|
|
unsafe {
|
|
intrin::disable_irq();
|
|
}
|
|
debug!("PANIC: {:?}\n", pi);
|
|
loop {}
|
|
}
|