Add RSDP address to loader_struct

This commit is contained in:
Mathieu Strypsteen 2024-07-08 21:26:13 +02:00
parent 4951d2c509
commit e60249c5da
3 changed files with 14 additions and 2 deletions

View file

@ -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],
}

View file

@ -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;

View file

@ -44,13 +44,23 @@ fn main(image_handle: Handle, mut system_table: SystemTable<Boot>) -> 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);