Skip to content

uefi: Make MEMORY_DESCRIPTOR_VERSION an associated constant #785

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 1 commit into from
May 2, 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
method has been removed; usually the `guid!` macro is a more convenient
choice, but `new` or `from_bytes` can also be used if needed. There are also a
number of new `Guid` methods.
- The `MEMORY_DESCRIPTOR_VERSION` constant has been moved to
`MemoryDescriptor::VERSION`.

## uefi-macros - [Unreleased]

Expand Down
8 changes: 5 additions & 3 deletions uefi/src/table/boot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1893,9 +1893,6 @@ impl MemoryType {
}
}

/// Memory descriptor version number
pub const MEMORY_DESCRIPTOR_VERSION: u32 = 1;

/// A structure describing a region of memory.
#[derive(Debug, Copy, Clone)]
#[repr(C)]
Expand All @@ -1912,6 +1909,11 @@ pub struct MemoryDescriptor {
pub att: MemoryAttribute,
}

impl MemoryDescriptor {
/// Memory descriptor version number.
pub const VERSION: u32 = 1;
}

impl Default for MemoryDescriptor {
fn default() -> MemoryDescriptor {
MemoryDescriptor {
Expand Down
2 changes: 1 addition & 1 deletion uefi/src/table/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ impl SystemTable<Runtime> {
// See https://rust-lang.github.io/unsafe-code-guidelines/layout/arrays-and-slices.html
let map_size = core::mem::size_of_val(map);
let entry_size = core::mem::size_of::<MemoryDescriptor>();
let entry_version = crate::table::boot::MEMORY_DESCRIPTOR_VERSION;
let entry_version = MemoryDescriptor::VERSION;
let map_ptr = map.as_mut_ptr();
((*(*self.table).runtime).set_virtual_address_map)(
map_size,
Expand Down