From 3feb78b3fce48cdfb461da59267fe1e17d71e3c1 Mon Sep 17 00:00:00 2001 From: Nicholas Bishop Date: Tue, 2 May 2023 00:48:08 -0400 Subject: [PATCH] uefi: Make MEMORY_DESCRIPTOR_VERSION an associated constant --- CHANGELOG.md | 2 ++ uefi/src/table/boot.rs | 8 +++++--- uefi/src/table/system.rs | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86c680359..0b980088c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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] diff --git a/uefi/src/table/boot.rs b/uefi/src/table/boot.rs index d8b85364a..cea80db6c 100644 --- a/uefi/src/table/boot.rs +++ b/uefi/src/table/boot.rs @@ -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)] @@ -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 { diff --git a/uefi/src/table/system.rs b/uefi/src/table/system.rs index fe4f968c9..385da563f 100644 --- a/uefi/src/table/system.rs +++ b/uefi/src/table/system.rs @@ -316,7 +316,7 @@ impl SystemTable { // 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::(); - 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,