-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f928d7
commit 2115246
Showing
1 changed file
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
); | ||
} | ||
} |