Skip to content

Commit 9eb1852

Browse files
committed
Fix TFTP boot
1 parent 253a4c0 commit 9eb1852

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

Diff for: uefi/src/main.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ use x86_64::{
4444
mod memory_descriptor;
4545

4646
static SYSTEM_TABLE: RacyCell<Option<SystemTable<Boot>>> = RacyCell::new(None);
47-
static KERNEL_FILENAME: &str = "kernel-x86_64\0";
48-
static RAMDISK_FILENAME: &str = "ramdisk-x86_64\0";
4947

5048
struct RacyCell<T>(UnsafeCell<T>);
5149

@@ -210,15 +208,15 @@ fn load_ramdisk(
210208
st: &mut SystemTable<Boot>,
211209
boot_mode: BootMode,
212210
) -> Option<&'static mut [u8]> {
213-
load_file_from_boot_method(image, st, RAMDISK_FILENAME, boot_mode)
211+
load_file_from_boot_method(image, st, "ramdisk-x86_64\0", boot_mode)
214212
}
215213

216214
fn load_kernel(
217215
image: Handle,
218216
st: &mut SystemTable<Boot>,
219217
boot_mode: BootMode,
220218
) -> Option<Kernel<'static>> {
221-
let kernel_slice = load_file_from_boot_method(image, st, KERNEL_FILENAME, boot_mode)?;
219+
let kernel_slice = load_file_from_boot_method(image, st, "kernel-x86_64\0", boot_mode)?;
222220
Some(Kernel::parse(kernel_slice))
223221
}
224222

@@ -377,8 +375,7 @@ fn load_file_from_tftp_boot_server(
377375

378376
// Determine the kernel file size.
379377
let file_size = base_code
380-
.tftp_get_file_size(&server_ip, &filename)
381-
.expect("Failed to query the file size");
378+
.tftp_get_file_size(&server_ip, &filename).ok()?;
382379
let kernel_size = usize::try_from(file_size).expect("The file size should fit into usize");
383380

384381
// Allocate some memory for the kernel file.

0 commit comments

Comments
 (0)