Skip to content

Update uefi dependency to v0.20 #360

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

Merged
merged 7 commits into from
Apr 13, 2023
Merged
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
29 changes: 25 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 18 additions & 13 deletions tests/runner/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
use bootloader::BootConfig;
use bootloader::DiskImageBuilder;
use std::{io::Read, path::Path, process::Command};

const QEMU_ARGS: &[&str] = &[
"-device",
"isa-debug-exit,iobase=0xf4,iosize=0x04",
"-serial",
"stdio",
"-display",
"none",
"--no-reboot",
];
const SEPARATOR: &str = "\n____________________________________\n";
use std::path::Path;

pub fn run_test_kernel(kernel_binary_path: &str) {
run_test_kernel_internal(kernel_binary_path, None, None)
Expand Down Expand Up @@ -98,11 +87,27 @@ pub fn run_test_kernel_on_uefi_pxe(out_tftp_path: &Path) {
run_qemu(args);
}

#[cfg(any(feature = "uefi", feature = "bios"))]
fn run_qemu<'a, A>(args: A)
where
A: IntoIterator<Item = &'a str>,
{
use std::process::Stdio;
use std::{
io::Read,
process::{Command, Stdio},
};

const QEMU_ARGS: &[&str] = &[
"-device",
"isa-debug-exit,iobase=0xf4,iosize=0x04",
"-serial",
"stdio",
"-display",
"none",
"--no-reboot",
];

const SEPARATOR: &str = "\n____________________________________\n";

let mut run_cmd = Command::new("qemu-system-x86_64");
run_cmd.args(args);
Expand Down
2 changes: 1 addition & 1 deletion uefi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ bootloader_api = { workspace = true }
bootloader-x86_64-common = { workspace = true }
bootloader-boot-config = { workspace = true }
log = "0.4.14"
uefi = "0.18.0"
x86_64 = "0.14.8"
serde-json-core = "0.5.0"
uefi = "0.20.0"
30 changes: 2 additions & 28 deletions uefi/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,37 +136,11 @@ fn main_inner(image: Handle, mut st: SystemTable<Boot>) -> Status {
}
);

let mmap_storage = {
let mut memory_map_size = st.boot_services().memory_map_size();
loop {
let ptr = st
.boot_services()
.allocate_pool(MemoryType::LOADER_DATA, memory_map_size.map_size)
.expect("Failed to allocate memory for mmap storage");

let storage = unsafe { slice::from_raw_parts_mut(ptr, memory_map_size.map_size) };

if st.boot_services().memory_map(storage).is_ok() {
break storage;
}

// By measuring the size here, we can find out exactly how much we need.
// We may hit this code twice, if the map allocation ends up spanning more pages.
memory_map_size = st.boot_services().memory_map_size();
// allocated memory region was not big enough -> free it again
st.boot_services()
.free_pool(ptr)
.expect("Failed to free temporary memory for memory map!");
}
};

log::trace!("exiting boot services");
let (system_table, memory_map) = st
.exit_boot_services(image, mmap_storage)
.expect("Failed to exit boot services");
let (system_table, memory_map) = st.exit_boot_services();

let mut frame_allocator =
LegacyFrameAllocator::new(memory_map.copied().map(UefiMemoryDescriptor));
LegacyFrameAllocator::new(memory_map.entries().copied().map(UefiMemoryDescriptor));

let page_tables = create_page_tables(&mut frame_allocator);
let mut ramdisk_len = 0u64;
Expand Down