diff --git a/lib/kernel-common/src/loader_struct.rs b/lib/kernel-common/src/loader_struct.rs index 3a79398..65ae4fd 100644 --- a/lib/kernel-common/src/loader_struct.rs +++ b/lib/kernel-common/src/loader_struct.rs @@ -10,6 +10,7 @@ pub struct LoaderStruct { pub magic: u64, pub phys_kernel_start: u64, pub phys_heap_start: u64, + pub rsdp_address: u64, pub available_memory: [LoaderStructMemoryRegion; 1024], } diff --git a/loader/src/loader_struct.rs b/loader/src/loader_struct.rs index 1e76dcd..be5a4d2 100644 --- a/loader/src/loader_struct.rs +++ b/loader/src/loader_struct.rs @@ -1,11 +1,12 @@ use kernel_common::loader_struct::{LoaderStruct, LoaderStructMemoryRegion, LOADER_STRUCT_MAGIC}; use uefi::table::boot::{MemoryMap, MemoryType}; -pub fn generate_loader_struct(memory_map: &MemoryMap, phys_start: u64, heap_start: u64) -> LoaderStruct { +pub fn generate_loader_struct(memory_map: &MemoryMap, phys_start: u64, heap_start: u64, rsdp_address: u64) -> LoaderStruct { let mut loader_struct = LoaderStruct { magic: LOADER_STRUCT_MAGIC, phys_kernel_start: phys_start, phys_heap_start: heap_start, + rsdp_address, available_memory: [LoaderStructMemoryRegion { initial_page: 0, page_count: 0 }; 1024], }; let mut next_entry = 0; diff --git a/loader/src/main.rs b/loader/src/main.rs index 139c341..1f61011 100644 --- a/loader/src/main.rs +++ b/loader/src/main.rs @@ -44,13 +44,23 @@ fn main(image_handle: Handle, mut system_table: SystemTable) -> Status { .boot_services() .allocate_pages(AllocateType::AnyPages, MemoryType::LOADER_DATA, KERNEL_HEAP_INITIAL_SIZE / 0x1000) .unwrap(); + let mut rsdp = 0; + for i in system_table.config_table() { + if i.guid == uefi::table::cfg::ACPI2_GUID { + rsdp = i.address as u64; + break; + } + } + if rsdp == 0 { + panic!("RSDP not found"); + } let memory_map; unsafe { memory_map = system_table.exit_boot_services(MemoryType::LOADER_DATA).1; } let pml4 = setup_paging(&memory_map, heap_start); map_kernel(KERNEL, pml4, kernel_start); - let loader_struct = generate_loader_struct(&memory_map, kernel_start, heap_start); + let loader_struct = generate_loader_struct(&memory_map, kernel_start, heap_start, rsdp); info!("Jumping to kernel..."); unsafe { (mem::transmute::<_, extern "C" fn(&LoaderStruct) -> !>(kernel_entry))(&loader_struct);