diff --git a/uefi/CHANGELOG.md b/uefi/CHANGELOG.md index 2fa03d39f..dc1961baa 100644 --- a/uefi/CHANGELOG.md +++ b/uefi/CHANGELOG.md @@ -1,6 +1,7 @@ # uefi - [Unreleased] ## Added +- Made memory map types `#[repr(C)]` ## Changed diff --git a/uefi/src/mem/memory_map/impl_.rs b/uefi/src/mem/memory_map/impl_.rs index b0f4c79e5..74cfb197a 100644 --- a/uefi/src/mem/memory_map/impl_.rs +++ b/uefi/src/mem/memory_map/impl_.rs @@ -44,6 +44,7 @@ impl core::error::Error for MemoryMapError {} /// Implementation of [`MemoryMap`] for the given buffer. #[derive(Debug)] +#[repr(C)] pub struct MemoryMapRef<'a> { buf: &'a [u8], meta: MemoryMapMeta, @@ -107,6 +108,7 @@ impl Index for MemoryMapRef<'_> { /// Implementation of [`MemoryMapMut`] for the given buffer. #[derive(Debug)] +#[repr(C)] pub struct MemoryMapRefMut<'a> { buf: &'a mut [u8], meta: MemoryMapMeta, @@ -287,6 +289,7 @@ impl IndexMut for MemoryMapRefMut<'_> { /// /// [`boot::get_memory_map`]: crate::boot::get_memory_map #[derive(Debug)] +#[repr(C)] pub(crate) struct MemoryMapBackingMemory(NonNull<[u8]>); impl MemoryMapBackingMemory { @@ -386,6 +389,7 @@ impl Drop for MemoryMapBackingMemory { /// Implementation of [`MemoryMapMut`] that owns the buffer on the UEFI heap. #[derive(Debug)] +#[repr(C)] pub struct MemoryMapOwned { /// Backing memory, properly initialized at this point. pub(crate) buf: MemoryMapBackingMemory, diff --git a/uefi/src/mem/memory_map/mod.rs b/uefi/src/mem/memory_map/mod.rs index d32c2a253..541723bef 100644 --- a/uefi/src/mem/memory_map/mod.rs +++ b/uefi/src/mem/memory_map/mod.rs @@ -66,6 +66,7 @@ pub struct MemoryMapKey(pub(crate) usize); /// called. All following invocations (hidden, subtle, and asynchronous ones) /// will likely invalidate this. #[derive(Copy, Clone, Debug)] +#[repr(C)] pub struct MemoryMapMeta { /// The actual size of the map. pub map_size: usize,