-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
5 changed files
with
57 additions
and
49 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
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 @@ | ||
nightly |
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 |
---|---|---|
@@ -1,3 +1,43 @@ | ||
pub mod acpi; | ||
pub mod console; | ||
pub mod uefifb; | ||
|
||
use acpi::rsdp; | ||
use console::{fbterm::init_fbterm, init_logger, uart::init_uart}; | ||
use uefifb::init_fb; | ||
use uefi::{ | ||
prelude::*, | ||
table::boot::{MemoryDescriptor, MemoryType}, | ||
}; | ||
|
||
pub fn init(image: uefi::Handle, st: SystemTable<Boot>){ | ||
let fb = init_fb(&st); | ||
init_logger(); | ||
init_fbterm(fb); | ||
init_uart(); | ||
let rsdp = rsdp(&st); | ||
let buffer = alloc_mmap(&st); | ||
let (st, map) = st | ||
.exit_boot_services(image, &mut buffer[..]) | ||
.expect_success("Failed to exit boot services"); | ||
let _rt = unsafe { st.runtime_services() }; | ||
for mem in map { | ||
trace!( | ||
"mem: 0x{:016X} Size(Page): {:8} Type: {:?}", | ||
mem.phys_start, | ||
mem.page_count, | ||
mem.ty | ||
); | ||
} | ||
trace!("RDSP: {:?}", rsdp); | ||
} | ||
|
||
fn alloc_mmap(st: &SystemTable<Boot>) -> &'static mut [u8] { | ||
let bt = st.boot_services(); | ||
let mmap_size = | ||
st.boot_services().memory_map_size() + 8 * core::mem::size_of::<MemoryDescriptor>(); | ||
let mmap_buffer = bt | ||
.allocate_pool(MemoryType::LOADER_DATA, mmap_size) | ||
.expect_success("alloc failed"); | ||
unsafe { core::slice::from_raw_parts_mut(mmap_buffer, mmap_size) } | ||
} |
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,9 @@ | ||
#![no_std] | ||
#![cfg_attr(test, no_main)] | ||
#![feature(custom_test_frameworks)] | ||
#![feature(decl_macro)] | ||
|
||
pub mod drivers; | ||
pub mod kmain; | ||
#[macro_use] | ||
extern crate log; |
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 |
---|---|---|
@@ -1,59 +1,21 @@ | ||
#![cfg_attr(not(test), no_std)] | ||
#![cfg_attr(not(test), no_main)] | ||
#![no_std] | ||
#![no_main] | ||
#![feature(decl_macro)] | ||
|
||
pub mod drivers; | ||
pub mod kmain; | ||
#[macro_use] | ||
extern crate log; | ||
|
||
use drivers::acpi::rsdp; | ||
use drivers::console::{fbterm::init_fbterm, init_logger, uart::init_uart}; | ||
use drivers::uefifb::init_fb; | ||
use kmain::kmain; | ||
use uefi::{ | ||
prelude::*, | ||
table::boot::{MemoryDescriptor, MemoryType}, | ||
}; | ||
use os::kmain::kmain; | ||
use os::drivers::init; | ||
use uefi::prelude::*; | ||
|
||
#[no_mangle] | ||
pub extern "C" fn efi_main(image: uefi::Handle, st: SystemTable<Boot>) -> ! { | ||
let fb = init_fb(&st); | ||
init_logger(); | ||
init_fbterm(fb); | ||
init_uart(); | ||
let rsdp = rsdp(&st); | ||
let buffer = alloc_mmap(&st); | ||
let (st, map) = st | ||
.exit_boot_services(image, &mut buffer[..]) | ||
.expect_success("Failed to exit boot services"); | ||
let _rt = unsafe { st.runtime_services() }; | ||
for mem in map { | ||
trace!( | ||
"mem: 0x{:016X} Size(Page): {:8} Type: {:?}", | ||
mem.phys_start, | ||
mem.page_count, | ||
mem.ty | ||
); | ||
} | ||
trace!("RDSP: {:?}", rsdp); | ||
init(image,st); | ||
kmain() | ||
} | ||
|
||
fn alloc_mmap(st: &SystemTable<Boot>) -> &'static mut [u8] { | ||
let bt = st.boot_services(); | ||
let mmap_size = | ||
st.boot_services().memory_map_size() + 8 * core::mem::size_of::<MemoryDescriptor>(); | ||
let mmap_buffer = bt | ||
.allocate_pool(MemoryType::LOADER_DATA, mmap_size) | ||
.expect_success("alloc failed"); | ||
unsafe { core::slice::from_raw_parts_mut(mmap_buffer, mmap_size) } | ||
} | ||
|
||
#[cfg(not(test))] | ||
#[panic_handler] | ||
fn panic(info: &core::panic::PanicInfo) -> ! { | ||
error!("{}", info); | ||
log::error!("{}", info); | ||
x86_64::instructions::hlt(); | ||
loop {} | ||
} |