Skip to content

Commit

Permalink
wip: add lib.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
GZTimeWalker committed Jan 16, 2024
1 parent 2f928d7 commit 2115246
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions src/0x02/pkg/kernel/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#![no_std]
#![allow(dead_code)]
#![feature(naked_functions)]
#![feature(abi_x86_interrupt)]
#![feature(alloc_error_handler)]
#![feature(type_alias_impl_trait)]
#![feature(panic_info_message)]
#![feature(map_try_insert)]
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::result_unit_err)]

extern crate alloc;
#[macro_use]
extern crate log;
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate bitflags;
extern crate libm;

#[macro_use]
pub mod utils;
pub use utils::*;

#[macro_use]
pub mod drivers;
pub use drivers::*;

pub mod memory;
pub mod interrupt;

pub use alloc::format;
use boot::BootInfo;

pub fn init(boot_info: &'static BootInfo) {
serial::init(); // init serial output
logger::init(); // init logger system
memory::address::init(boot_info);
memory::gdt::init(); // init gdt
memory::allocator::init(); // init kernel heap allocator
interrupt::init(); // init interrupts
memory::init(boot_info); // init memory manager

x86_64::instructions::interrupts::enable();
info!("Interrupts Enabled.");

info!("YatSenOS initialized.");
}

pub fn shutdown(boot_info: &'static BootInfo) -> ! {
info!("YatSenOS shutting down.");
unsafe {
boot_info.system_table.runtime_services().reset(
boot::ResetType::SHUTDOWN,
boot::UefiStatus::SUCCESS,
None,
);
}
}

0 comments on commit 2115246

Please sign in to comment.