Skip to content
Closed
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
17 changes: 17 additions & 0 deletions uefi/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
fn allocate_loader_data(size: usize) -> &'static mut [u8] {
let mut ptr = boot::allocate_pages(
AllocateType::AnyPages,
MemoryType::LOADER_DATA,

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

View workflow job for this annotation

GitHub Actions / Clippy

variable does not need to be mutable

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

View workflow job for this annotation

GitHub Actions / Check

variable does not need to be mutable
((size - 1) / 4096) + 1,
)
.expect("Failed to allocate memory for the file");
Expand Down Expand Up @@ -445,3 +445,20 @@
unsafe { asm!("cli; hlt") };
}
}

/// Provide `wcslen` for the `uefi` crate which needs it for wide string
/// handling (e.g. `FileInfo::from_uefi`). The `x86_64-unknown-uefi` target
/// has no C runtime, so this must be supplied explicitly.
///
/// See: https://github.com/rust-osdev/bootloader/issues/579
#[unsafe(no_mangle)]
pub unsafe extern "C" fn wcslen(s: *const u16) -> usize {
let mut len = 0;
// SAFETY: caller guarantees `s` points to a null-terminated wide string.
unsafe {
while *s.add(len) != 0 {
len += 1;
}
}
len
}

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

View workflow job for this annotation

GitHub Actions / Clippy

unsafe function's docs are missing a `# Safety` section
Loading