1#![cfg_attr(freestanding, no_std)]
5
6#[macro_use]
7pub mod macros;
8#[macro_use]
9pub mod utils;
10pub mod faults;
11pub mod mem;
12pub mod print;
13pub mod sched;
14pub mod services;
15pub mod sync;
16pub mod syscalls;
17pub mod time;
18pub mod uspace;
19
20use core::ffi::c_char;
21
22use hal::Machinelike;
23
24#[repr(packed, C)]
29pub struct MemMapEntry {
30 size: u32,
32 addr: u64,
34 length: u64,
36 ty: u32,
38}
39
40#[repr(C)]
42pub struct BootInfo {
43 pub implementer: *const c_char,
45 pub variant: *const c_char,
47 pub mmap: [MemMapEntry; 8],
49 pub mmap_len: usize,
51}
52
53#[unsafe(no_mangle)]
57pub unsafe extern "C" fn kernel_init(boot_info: *const BootInfo) -> ! {
58 hal::Machine::init();
60
61 hal::Machine::bench_start();
64
65 let boot_info = unsafe { &*boot_info };
66
67 print::print_header();
68 print::print_boot_info(boot_info);
69
70 if let Err(e) = mem::init_memory(boot_info) {
72 panic!(
73 "[Kernel] Error: failed to initialize memory allocator. Error: {:?}",
74 e
75 );
76 }
77
78 if let Err(e) = services::init_services() {
80 panic!(
81 "[Kernel] Error: failed to initialize services. Error: {:?}",
82 e
83 );
84 }
85
86 sched::enable_scheduler(false);
87
88 let (cyc, ns) = hal::Machine::bench_end();
89 kprintln!(
90 "[Osiris] Init took {} cycles taking {} ms",
91 cyc,
92 ns / 1e6f32
93 );
94
95 sched::enable_scheduler(true);
96
97 loop {
98 hal::asm::nop!();
99 }
100}