Add RSDP address to loader_struct
This commit is contained in:
parent
4951d2c509
commit
e60249c5da
3 changed files with 14 additions and 2 deletions
|
@ -10,6 +10,7 @@ pub struct LoaderStruct {
|
||||||
pub magic: u64,
|
pub magic: u64,
|
||||||
pub phys_kernel_start: u64,
|
pub phys_kernel_start: u64,
|
||||||
pub phys_heap_start: u64,
|
pub phys_heap_start: u64,
|
||||||
|
pub rsdp_address: u64,
|
||||||
pub available_memory: [LoaderStructMemoryRegion; 1024],
|
pub available_memory: [LoaderStructMemoryRegion; 1024],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
use kernel_common::loader_struct::{LoaderStruct, LoaderStructMemoryRegion, LOADER_STRUCT_MAGIC};
|
use kernel_common::loader_struct::{LoaderStruct, LoaderStructMemoryRegion, LOADER_STRUCT_MAGIC};
|
||||||
use uefi::table::boot::{MemoryMap, MemoryType};
|
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 {
|
let mut loader_struct = LoaderStruct {
|
||||||
magic: LOADER_STRUCT_MAGIC,
|
magic: LOADER_STRUCT_MAGIC,
|
||||||
phys_kernel_start: phys_start,
|
phys_kernel_start: phys_start,
|
||||||
phys_heap_start: heap_start,
|
phys_heap_start: heap_start,
|
||||||
|
rsdp_address,
|
||||||
available_memory: [LoaderStructMemoryRegion { initial_page: 0, page_count: 0 }; 1024],
|
available_memory: [LoaderStructMemoryRegion { initial_page: 0, page_count: 0 }; 1024],
|
||||||
};
|
};
|
||||||
let mut next_entry = 0;
|
let mut next_entry = 0;
|
||||||
|
|
|
@ -44,13 +44,23 @@ fn main(image_handle: Handle, mut system_table: SystemTable<Boot>) -> Status {
|
||||||
.boot_services()
|
.boot_services()
|
||||||
.allocate_pages(AllocateType::AnyPages, MemoryType::LOADER_DATA, KERNEL_HEAP_INITIAL_SIZE / 0x1000)
|
.allocate_pages(AllocateType::AnyPages, MemoryType::LOADER_DATA, KERNEL_HEAP_INITIAL_SIZE / 0x1000)
|
||||||
.unwrap();
|
.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;
|
let memory_map;
|
||||||
unsafe {
|
unsafe {
|
||||||
memory_map = system_table.exit_boot_services(MemoryType::LOADER_DATA).1;
|
memory_map = system_table.exit_boot_services(MemoryType::LOADER_DATA).1;
|
||||||
}
|
}
|
||||||
let pml4 = setup_paging(&memory_map, heap_start);
|
let pml4 = setup_paging(&memory_map, heap_start);
|
||||||
map_kernel(KERNEL, pml4, kernel_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...");
|
info!("Jumping to kernel...");
|
||||||
unsafe {
|
unsafe {
|
||||||
(mem::transmute::<_, extern "C" fn(&LoaderStruct) -> !>(kernel_entry))(&loader_struct);
|
(mem::transmute::<_, extern "C" fn(&LoaderStruct) -> !>(kernel_entry))(&loader_struct);
|
||||||
|
|
Loading…
Add table
Reference in a new issue