Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the UEFI runtime table address #394

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 4 additions & 0 deletions api/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64>,

#[doc(hidden)]
pub _test_sentinel: u64,
}
Expand All @@ -85,6 +88,7 @@ impl BootInfo {
kernel_addr: 0,
kernel_len: 0,
kernel_image_offset: 0,
rt_table_addr: Optional::None,
_test_sentinel: 0,
}
}
Expand Down
1 change: 1 addition & 0 deletions bios/stage-4/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 11 additions & 1 deletion common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -80,6 +80,11 @@ pub struct SystemInfo {
pub rsdp_addr: Option<PhysAddr>,
pub ramdisk_addr: Option<u64>,
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<u64>,
}

/// The physical address of the framebuffer and information about the framebuffer.
Expand Down Expand Up @@ -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
});

Expand Down
1 change: 1 addition & 0 deletions uefi/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@
},
ramdisk_addr,
ramdisk_len,
rt_table_addr: Some(system_table.get_current_system_table_addr()),
};

bootloader_x86_64_common::load_and_switch_to_kernel(
Expand Down Expand Up @@ -210,7 +211,7 @@

fn load_file_from_boot_method(
image: Handle,
st: &mut SystemTable<Boot>,

Check warning on line 214 in uefi/src/main.rs

View workflow job for this annotation

GitHub Actions / Clippy

this argument is a mutable reference, but not used mutably
filename: &str,
boot_mode: BootMode,
) -> Option<&'static mut [u8]> {
Expand Down
Loading