diff --git a/api/Cargo.toml b/api/Cargo.toml index ef687b0c..8d075843 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -6,9 +6,5 @@ repository.workspace = true edition = "2021" description = "Makes a kernel compatible with the bootloader crate" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[dependencies] - [dev-dependencies] rand = "0.8.4" diff --git a/api/src/info.rs b/api/src/info.rs index 965fcf40..064c4216 100644 --- a/api/src/info.rs +++ b/api/src/info.rs @@ -63,6 +63,9 @@ pub struct BootInfo { /// Virtual address of the loaded kernel image. pub kernel_image_offset: u64, + /// UEFI runtime table address (if running on UEFI) + pub rt_table_addr: Optional, + #[doc(hidden)] pub _test_sentinel: u64, } @@ -85,6 +88,7 @@ impl BootInfo { kernel_addr: 0, kernel_len: 0, kernel_image_offset: 0, + rt_table_addr: Optional::None, _test_sentinel: 0, } } diff --git a/bios/stage-4/src/main.rs b/bios/stage-4/src/main.rs index 260dd622..a6361c47 100644 --- a/bios/stage-4/src/main.rs +++ b/bios/stage-4/src/main.rs @@ -164,6 +164,7 @@ pub extern "C" fn _start(info: &mut BiosInfo) -> ! { _ => Some(info.ramdisk.start), }, ramdisk_len: info.ramdisk.len, + rt_table_addr: None, }; load_and_switch_to_kernel(kernel, config, frame_allocator, page_tables, system_info); diff --git a/common/src/lib.rs b/common/src/lib.rs index 3c407644..20c5c4cc 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -5,7 +5,7 @@ use crate::legacy_memory_region::{LegacyFrameAllocator, LegacyMemoryRegion}; use bootloader_api::{ config::Mapping, - info::{FrameBuffer, FrameBufferInfo, MemoryRegion, TlsTemplate}, + info::{FrameBuffer, FrameBufferInfo, MemoryRegion, Optional, TlsTemplate}, BootInfo, BootloaderConfig, }; use bootloader_boot_config::{BootConfig, LevelFilter}; @@ -80,6 +80,11 @@ pub struct SystemInfo { pub rsdp_addr: Option, pub ramdisk_addr: Option, pub ramdisk_len: u64, + + /// UEFI runtime table address (if running on UEFI). + /// + /// Use a raw pointer from your kernel to this address to access UEFI Runtime Services. + pub rt_table_addr: Option, } /// The physical address of the framebuffer and information about the framebuffer. @@ -551,6 +556,11 @@ where info.kernel_len = mappings.kernel_slice_len as _; info.kernel_image_offset = mappings.kernel_image_offset.as_u64(); info._test_sentinel = boot_config._test_sentinel; + info.rt_table_addr = if let Some(addr) = system_info.rt_table_addr { + Optional::Some(addr) + } else { + Optional::None + }; info }); diff --git a/uefi/src/main.rs b/uefi/src/main.rs index 93dfb6c7..2c39e877 100644 --- a/uefi/src/main.rs +++ b/uefi/src/main.rs @@ -166,6 +166,7 @@ fn main_inner(image: Handle, mut st: SystemTable) -> Status { }, ramdisk_addr, ramdisk_len, + rt_table_addr: Some(system_table.get_current_system_table_addr()), }; bootloader_x86_64_common::load_and_switch_to_kernel(