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

Drop memmove and set_mem from boot services #906

Merged
merged 1 commit into from Aug 1, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -14,6 +14,10 @@
- `FileSystem::try_exists` now returns `FileSystemResult<bool>`.
- `FileSystem::copy` is now more efficient for large files.

### Removed
- `BootServices::memmove` and `BootServices::set_mem` have been removed, use
standard functions like `core::ptr::copy` and `core::ptr::write_bytes` instead.

## uefi-macros - [Unreleased]

## uefi-services - [Unreleased]
Expand Down
23 changes: 0 additions & 23 deletions uefi-test-runner/src/boot/memory.rs
Expand Up @@ -8,7 +8,6 @@ pub fn test(bt: &BootServices) {
allocate_pages(bt);
vec_alloc();
alloc_alignment();
memmove(bt);

memory_map(bt);
}
Expand Down Expand Up @@ -57,28 +56,6 @@ fn alloc_alignment() {
assert_eq!(value.as_ptr() as usize % 0x100, 0, "Wrong alignment");
}

// Test that the `memmove` / `set_mem` functions work.
fn memmove(bt: &BootServices) {
info!("Testing the `memmove` / `set_mem` functions");

let src = [1, 2, 3, 4];
let mut dest = [0u8; 4];

// Fill the buffer with a value
unsafe {
bt.set_mem(dest.as_mut_ptr(), dest.len(), 1);
}

assert_eq!(dest, [1; 4], "Failed to set memory");

// Copy other values on it
unsafe {
bt.memmove(dest.as_mut_ptr(), src.as_ptr(), dest.len());
}

assert_eq!(dest, src, "Failed to copy memory");
}

fn memory_map(bt: &BootServices) {
info!("Testing memory map functions");

Expand Down
20 changes: 0 additions & 20 deletions uefi/src/table/boot.rs
Expand Up @@ -1320,26 +1320,6 @@ impl BootServices {
})
}

/// Copies memory from source to destination. The buffers can overlap.
///
/// # Safety
///
/// This function is unsafe as it can be used to violate most safety
/// invariants of the Rust type system.
pub unsafe fn memmove(&self, dest: *mut u8, src: *const u8, size: usize) {
(self.0.copy_mem)(dest, src, size);
}

/// Sets a buffer to a certain value.
///
/// # Safety
///
/// This function is unsafe as it can be used to violate most safety
/// invariants of the Rust type system.
pub unsafe fn set_mem(&self, buffer: *mut u8, size: usize, value: u8) {
(self.0.set_mem)(buffer, size, value);
}

/// Retrieves a [`SimpleFileSystem`] protocol associated with the device the given
/// image was loaded from.
///
Expand Down