Skip to content

Commit 895156d

Browse files
committed
uefi: mem: memory-map: break API
As deprecated re-exports are unsupported [0], we go the hard way and just make it a breaking change. Along the way, I reordered some statements in some files to follow our typical order of: - pub mod - private mod - pub use - private use
1 parent dd14f00 commit 895156d

File tree

13 files changed

+46
-41
lines changed

13 files changed

+46
-41
lines changed

uefi-test-runner/src/boot/memory.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use uefi::boot;
2-
use uefi::table::boot::{AllocateType, BootServices, MemoryMap, MemoryMapMut, MemoryType};
3-
41
use alloc::vec::Vec;
2+
use uefi::boot;
3+
use uefi::mem::memory_map::{MemoryMap, MemoryMapMut, MemoryType};
4+
use uefi::table::boot::{AllocateType, BootServices};
55

66
pub fn test(bt: &BootServices) {
77
info!("Testing memory functions");

uefi-test-runner/src/boot/misc.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ use core::ffi::c_void;
22
use core::ptr::{self, NonNull};
33

44
use core::mem;
5+
use uefi::mem::memory_map::MemoryType;
56
use uefi::proto::unsafe_protocol;
67
use uefi::table::boot::{
7-
BootServices, EventType, MemoryType, OpenProtocolAttributes, OpenProtocolParams, SearchType,
8-
TimerTrigger, Tpl,
8+
BootServices, EventType, OpenProtocolAttributes, OpenProtocolParams, SearchType, TimerTrigger,
9+
Tpl,
910
};
1011
use uefi::table::{Boot, SystemTable};
1112
use uefi::{guid, Event, Guid, Identify};

uefi-test-runner/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ extern crate alloc;
88

99
use alloc::string::ToString;
1010
use alloc::vec::Vec;
11+
use uefi::mem::memory_map::{MemoryMap, MemoryType};
1112
use uefi::prelude::*;
1213
use uefi::proto::console::serial::Serial;
1314
use uefi::proto::device_path::build::{self, DevicePathBuilder};
1415
use uefi::proto::device_path::messaging::Vendor;
15-
use uefi::table::boot::{MemoryMap, MemoryType};
1616
use uefi::{print, println, system, Result};
1717

1818
mod boot;

uefi/CHANGELOG.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,16 @@
2424
- **Breaking:** `PcrEvent::new_in_buffer` and `PcrEventInputs::new_in_buffer`
2525
now take an initialized buffer (`[u8`] instead of `[MaybeUninit<u8>]`), and if
2626
the buffer is too small the required size is returned in the error data.
27-
- Exports of Memory Map-related types from `uefi::table::boot` are now
28-
deprecated. Use `uefi::mem::memory_map` instead.
29-
27+
- **Breaking** Exports of Memory Map-related types from `uefi::table::boot` are
28+
now removed. Use `uefi::mem::memory_map` instead. The patch you have to apply
29+
to the `use` statements of your code might look as follows:
30+
```diff
31+
1c1,2
32+
< use uefi::table::boot::{BootServices, MemoryMap, MemoryMapMut, MemoryType};
33+
---
34+
> use uefi::mem::memory_map::{MemoryMap, MemoryMapMut, MemoryType};
35+
> use uefi::table::boot::BootServices;
36+
```
3037

3138
# uefi - 0.29.0 (2024-07-02)
3239

uefi/src/allocator.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ use core::ffi::c_void;
1616
use core::ptr;
1717
use core::sync::atomic::{AtomicPtr, AtomicU32, Ordering};
1818

19+
use crate::mem::memory_map::MemoryType;
1920
use crate::proto::loaded_image::LoadedImage;
20-
use crate::table::boot::{BootServices, MemoryType};
21+
use crate::table::boot::BootServices;
2122
use crate::table::{Boot, SystemTable};
2223

2324
/// Reference to the system table, used to call the boot services pool memory

uefi/src/mem/memory_map/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! # Usecase: Obtain UEFI Memory Map
1010
//!
1111
//! You can use [`SystemTable::exit_boot_services`] or
12-
//! [`BootServices::memory_map`], which returns an properly initialized
12+
//! [`BootServices::memory_map`], which returns an properly initialized
1313
//! [`MemoryMapOwned`].
1414
//!
1515
//! # Usecase: Parse Memory Slice as UEFI Memory Map
@@ -70,7 +70,7 @@ pub struct MemoryMapMeta {
7070
/// and never `size_of::<MemoryDescriptor>()`!
7171
pub desc_size: usize,
7272
/// A unique memory key bound to a specific memory map version/state.
73-
pub map_key: crate::table::boot::MemoryMapKey,
73+
pub map_key: MemoryMapKey,
7474
/// The version of the descriptor struct.
7575
pub desc_version: u32,
7676
}

uefi/src/proto/device_path/device_path_gen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
// See `/xtask/src/device_path/README.md` for more details.
77

88
use crate::data_types::UnalignedSlice;
9+
use crate::mem::memory_map::MemoryType;
910
use crate::polyfill::maybe_uninit_slice_as_mut_ptr;
1011
use crate::proto::device_path::{
1112
DevicePathHeader, DevicePathNode, DeviceSubType, DeviceType, NodeConversionError,
1213
};
1314
use crate::proto::network::IpAddress;
14-
use crate::table::boot::MemoryType;
1515
use crate::{guid, Guid};
1616
use bitflags::bitflags;
1717
use core::mem::{size_of, size_of_val};

uefi/src/proto/loaded_image.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! `LoadedImage` protocol.
22
33
use crate::data_types::FromSliceWithNulError;
4+
use crate::mem::memory_map::MemoryType;
45
use crate::proto::device_path::DevicePath;
56
use crate::proto::unsafe_protocol;
6-
use crate::table::boot::MemoryType;
77
use crate::util::usize_from_u32;
88
use crate::{CStr16, Handle, Status};
99
use core::ffi::c_void;

uefi/src/proto/security/memory_protection.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::data_types::PhysicalAddress;
2+
use crate::mem::memory_map::MemoryAttribute;
23
use crate::proto::unsafe_protocol;
3-
use crate::table::boot::MemoryAttribute;
44
use crate::{Result, StatusExt};
55
use core::ops::Range;
66
use uefi_raw::protocol::memory_protection::MemoryAttributeProtocol;

uefi/src/table/boot.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
11
//! UEFI services available during boot.
22
3+
pub use uefi_raw::table::boot::{EventType, InterfaceType, Tpl};
4+
35
use super::Revision;
46
use crate::data_types::PhysicalAddress;
7+
use crate::mem::memory_map::*;
58
use crate::proto::device_path::DevicePath;
69
use crate::proto::loaded_image::LoadedImage;
710
use crate::proto::media::fs::SimpleFileSystem;
811
use crate::proto::{Protocol, ProtocolPointer};
912
use crate::util::opt_nonnull_to_ptr;
1013
use crate::{Char16, Error, Event, Guid, Handle, Result, Status, StatusExt};
14+
#[cfg(feature = "alloc")]
15+
use alloc::vec::Vec;
1116
use core::cell::UnsafeCell;
1217
use core::ffi::c_void;
18+
use core::fmt::Debug;
1319
use core::mem::{self, MaybeUninit};
1420
use core::ops::{Deref, DerefMut};
1521
use core::ptr::NonNull;
1622
use core::sync::atomic::{AtomicPtr, Ordering};
1723
use core::{ptr, slice};
1824

19-
#[cfg(feature = "alloc")]
20-
use alloc::vec::Vec;
21-
use core::fmt::Debug;
22-
23-
#[deprecated = "Use the `uefi::mem::memory_map` module."]
24-
pub use crate::mem::memory_map::*;
25-
pub use uefi_raw::table::boot::{EventType, InterfaceType, Tpl};
26-
2725
/// Global image handle. This is only set by `BootServices::set_image_handle`,
2826
/// and it is only read by `BootServices::image_handle`.
2927
static IMAGE_HANDLE: AtomicPtr<c_void> = AtomicPtr::new(ptr::null_mut());

uefi/src/table/runtime.rs

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
//! UEFI services available at runtime, even after the OS boots.
22
3-
use super::Revision;
4-
use crate::table::boot::MemoryDescriptor;
5-
use crate::{CStr16, Error, Result, Status, StatusExt};
6-
use core::fmt::{self, Debug, Display, Formatter};
7-
use core::mem::{size_of, MaybeUninit};
8-
use core::ptr;
9-
103
pub use uefi_raw::capsule::{CapsuleBlockDescriptor, CapsuleFlags, CapsuleHeader};
114
pub use uefi_raw::table::runtime::{
125
ResetType, TimeCapabilities, VariableAttributes, VariableVendor,
136
};
147
pub use uefi_raw::time::Daylight;
158
pub use uefi_raw::PhysicalAddress;
169

10+
use super::Revision;
11+
use crate::{CStr16, Error, Result, Status, StatusExt};
12+
use core::fmt::{self, Debug, Display, Formatter};
13+
use core::mem::{size_of, MaybeUninit};
14+
use core::ptr;
1715
#[cfg(feature = "alloc")]
1816
use {
1917
crate::data_types::FromSliceWithNulError,
@@ -288,7 +286,7 @@ impl RuntimeServices {
288286
map_size: usize,
289287
desc_size: usize,
290288
desc_version: u32,
291-
virtual_map: *mut MemoryDescriptor,
289+
virtual_map: *mut crate::mem::memory_map::MemoryDescriptor,
292290
) -> Status {
293291
(self.0.set_virtual_address_map)(map_size, desc_size, desc_version, virtual_map)
294292
}
@@ -372,7 +370,7 @@ pub struct TimeParams {
372370
}
373371

374372
/// Error returned by [`Time`] methods. A bool value of `true` means
375-
/// the specified field is outside of its valid range.
373+
/// the specified field is outside its valid range.
376374
#[allow(missing_docs)]
377375
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
378376
pub struct TimeError {

uefi/src/table/system.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1+
use super::boot::BootServices;
2+
use super::runtime::{ResetType, RuntimeServices};
3+
use super::{cfg, Revision};
4+
use crate::proto::console::text;
5+
use crate::{CStr16, Result, Status, StatusExt};
16
use core::ffi::c_void;
27
use core::marker::PhantomData;
38
use core::ptr::NonNull;
49
use core::slice;
5-
use uefi::table::boot::{MemoryMapBackingMemory, MemoryMapMeta};
6-
7-
use crate::proto::console::text;
8-
use crate::{CStr16, Result, Status, StatusExt};
9-
10-
use super::boot::{BootServices, MemoryDescriptor, MemoryMapOwned, MemoryType};
11-
use super::runtime::{ResetType, RuntimeServices};
12-
use super::{cfg, Revision};
10+
use uefi::mem::memory_map::{
11+
MemoryDescriptor, MemoryMapBackingMemory, MemoryMapMeta, MemoryMapOwned, MemoryType,
12+
};
1313

1414
/// Marker trait used to provide different views of the UEFI System Table.
1515
pub trait SystemTableView {}

xtask/src/device_path/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn gen_code_as_string(groups: &[NodeGroup]) -> Result<String> {
2929
NodeConversionError,
3030
};
3131
use crate::proto::network::IpAddress;
32-
use crate::table::boot::MemoryType;
32+
use crate::mem::memory_map::MemoryType;
3333
use core::mem::{size_of, size_of_val};
3434
use core::ptr::addr_of;
3535
use core::{fmt, slice};

0 commit comments

Comments
 (0)