Skip to content

Commit d6eb99e

Browse files
authored
Merge pull request #1404 from rust-osdev/bishop-remove-rt
Delete deprecated RuntimeServices struct
2 parents 5ad1504 + bdb925c commit d6eb99e

File tree

11 files changed

+25
-746
lines changed

11 files changed

+25
-746
lines changed

uefi-test-runner/src/main.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![no_std]
22
#![no_main]
33
// TODO: temporarily allow deprecated code so that we can continue to test
4-
// SystemTable/BootServices/RuntimeServices.
4+
// SystemTable/BootServices.
55
#![allow(deprecated)]
66

77
#[macro_use]
@@ -63,7 +63,7 @@ fn efi_main(image: Handle, mut st: SystemTable<Boot>) -> Status {
6363
// probably want to test them after exit_boot_services. However,
6464
// exit_boot_services is currently called during shutdown.
6565

66-
runtime::test(st.runtime_services());
66+
runtime::test();
6767

6868
shutdown(st);
6969
}
@@ -218,7 +218,7 @@ fn shutdown(mut st: SystemTable<Boot>) -> ! {
218218
info!("Testing complete, exiting boot services...");
219219

220220
// Exit boot services as a proof that it works :)
221-
let (st, mmap) = unsafe { st.exit_boot_services(MemoryType::LOADER_DATA) };
221+
let mmap = unsafe { uefi::boot::exit_boot_services(MemoryType::LOADER_DATA) };
222222

223223
info!("Memory Map:");
224224
for desc in mmap.entries() {
@@ -235,9 +235,6 @@ fn shutdown(mut st: SystemTable<Boot>) -> ! {
235235

236236
#[cfg(target_arch = "x86_64")]
237237
{
238-
// Prevent unused variable warning.
239-
let _ = st;
240-
241238
use qemu_exit::QEMUExit;
242239
let custom_exit_success = 3;
243240
let qemu_exit_handle = qemu_exit::X86::new(0xF4, custom_exit_success);
@@ -247,11 +244,6 @@ fn shutdown(mut st: SystemTable<Boot>) -> ! {
247244
#[cfg(not(target_arch = "x86_64"))]
248245
{
249246
// Shut down the system
250-
let rt = unsafe { st.runtime_services() };
251-
rt.reset(
252-
uefi::table::runtime::ResetType::SHUTDOWN,
253-
Status::SUCCESS,
254-
None,
255-
);
247+
uefi::runtime::reset(uefi::runtime::ResetType::SHUTDOWN, Status::SUCCESS, None);
256248
}
257249
}

uefi-test-runner/src/proto/media.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use uefi::proto::media::file::{
1313
};
1414
use uefi::proto::media::fs::SimpleFileSystem;
1515
use uefi::proto::media::partition::{MbrOsType, PartitionInfo};
16-
use uefi::table::runtime::{Daylight, Time, TimeParams};
16+
use uefi::runtime::{Daylight, Time, TimeParams};
1717

1818
/// Test directory entry iteration.
1919
fn test_existing_dir(directory: &mut Directory) {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use uefi::prelude::*;
22
use uefi::proto::misc::ResetNotification;
3-
use uefi::table::runtime;
3+
use uefi::runtime::ResetType;
44

55
pub fn test(bt: &BootServices) {
66
test_reset_notification(bt);
@@ -19,7 +19,7 @@ pub fn test_reset_notification(bt: &BootServices) {
1919

2020
// value efi_reset_fn is the type of ResetSystemFn, a function pointer
2121
unsafe extern "efiapi" fn efi_reset_fn(
22-
rt: runtime::ResetType,
22+
rt: ResetType,
2323
status: Status,
2424
data_size: usize,
2525
data: *const u8,

uefi-test-runner/src/runtime/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
mod vars;
22

33
use uefi::runtime::{self, Daylight, Time, TimeParams};
4-
use uefi::table::runtime::RuntimeServices;
54

6-
pub fn test(rt: &RuntimeServices) {
5+
pub fn test() {
76
info!("Testing runtime services");
8-
vars::test(rt);
7+
vars::test();
98
test_time();
109
}
1110

uefi-test-runner/src/runtime/vars.rs

Lines changed: 8 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use log::info;
22
use uefi::prelude::*;
3-
use uefi::table::runtime::{VariableAttributes, VariableVendor};
3+
use uefi::runtime::{VariableAttributes, VariableVendor};
44
use uefi::{guid, runtime, CStr16, Error};
55

66
/// Test variable name.
@@ -16,63 +16,8 @@ const VALUE: &[u8] = b"TestValue";
1616
const ATTRS: VariableAttributes =
1717
VariableAttributes::BOOTSERVICE_ACCESS.union(VariableAttributes::RUNTIME_ACCESS);
1818

19-
fn test_variables(rt: &RuntimeServices) {
20-
info!("Testing set_variable");
21-
rt.set_variable(NAME, VENDOR, ATTRS, VALUE)
22-
.expect("failed to set variable");
23-
24-
info!("Testing get_variable_size");
25-
let size = rt
26-
.get_variable_size(NAME, VENDOR)
27-
.expect("failed to get variable size");
28-
assert_eq!(size, VALUE.len());
29-
30-
info!("Testing get_variable");
31-
let mut buf = [0u8; 9];
32-
let (data, attrs) = rt
33-
.get_variable(NAME, VENDOR, &mut buf)
34-
.expect("failed to get variable");
35-
assert_eq!(data, VALUE);
36-
assert_eq!(attrs, ATTRS);
37-
38-
info!("Testing get_variable_boxed");
39-
let (data, attrs) = rt
40-
.get_variable_boxed(NAME, VENDOR)
41-
.expect("failed to get variable");
42-
assert_eq!(&*data, VALUE);
43-
assert_eq!(attrs, ATTRS);
44-
45-
info!("Testing variable_keys");
46-
let variable_keys = rt.variable_keys().expect("failed to get variable keys");
47-
info!("Found {} variables", variable_keys.len());
48-
// There are likely a bunch of variables, only print out the first one
49-
// during the test to avoid spamming the log.
50-
if let Some(key) = variable_keys.first() {
51-
info!("First variable: {}", key);
52-
}
53-
54-
// Test that the `runtime::variable_keys` iterator gives exactly the same
55-
// list as the `RuntimeServices::variable_keys` function.
56-
assert_eq!(
57-
runtime::variable_keys()
58-
.map(|k| k.unwrap())
59-
.collect::<alloc::vec::Vec<_>>(),
60-
variable_keys
61-
);
62-
63-
info!("Testing delete_variable()");
64-
rt.delete_variable(NAME, VENDOR)
65-
.expect("failed to delete variable");
66-
assert_eq!(
67-
rt.get_variable(NAME, VENDOR, &mut buf)
68-
.unwrap_err()
69-
.status(),
70-
Status::NOT_FOUND
71-
);
72-
}
73-
7419
/// Test the variable functions in `uefi::runtime`.
75-
fn test_variables_freestanding() {
20+
fn test_variables() {
7621
assert!(!runtime::variable_exists(NAME, VENDOR).unwrap());
7722

7823
// Create the test variable.
@@ -121,20 +66,17 @@ fn test_variables_freestanding() {
12166
assert!(!find_by_key());
12267
}
12368

124-
fn test_variable_info(rt: &RuntimeServices) {
69+
fn test_variable_info() {
12570
let attr = VariableAttributes::BOOTSERVICE_ACCESS | VariableAttributes::NON_VOLATILE;
126-
let info = rt.query_variable_info(attr).unwrap();
71+
let info = runtime::query_variable_info(attr).unwrap();
12772
info!("Storage for non-volatile boot-services variables: {info:?}");
128-
assert_eq!(info, runtime::query_variable_info(attr).unwrap());
12973

13074
let attr = VariableAttributes::BOOTSERVICE_ACCESS | VariableAttributes::RUNTIME_ACCESS;
131-
let info = rt.query_variable_info(attr).unwrap();
75+
let info = runtime::query_variable_info(attr).unwrap();
13276
info!("Storage for volatile runtime variables: {info:?}");
133-
assert_eq!(info, runtime::query_variable_info(attr).unwrap());
13477
}
13578

136-
pub fn test(rt: &RuntimeServices) {
137-
test_variables(rt);
138-
test_variable_info(rt);
139-
test_variables_freestanding();
79+
pub fn test() {
80+
test_variable_info();
81+
test_variables();
14082
}

uefi/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# uefi - [Unreleased]
22

3+
See [Deprecating SystemTable/BootServices/RuntimeServices][funcmigrate] for
4+
details of the deprecated items that were removed in this release.
5+
36
## Changed
4-
- **Breaking:** Deleted deprecated function `helpers::system_table`.
7+
- **Breaking:** Deleted the deprecated `RuntimeServices` struct.
8+
- **Breaking:** Deleted deprecated functions `helpers::system_table` and
9+
`table::system_table_runtime`.
510
- **Breaking:** `FileSystem` no longer has a lifetime parameter, and the
611
deprecated conversion from `uefi::table::boot::ScopedProtocol` has been
712
removed.

uefi/src/prelude.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,4 @@ pub use crate::{
1010
#[allow(deprecated)]
1111
pub use crate::table::boot::BootServices;
1212
#[allow(deprecated)]
13-
pub use crate::table::runtime::RuntimeServices;
14-
#[allow(deprecated)]
1513
pub use crate::table::{Boot, SystemTable};

uefi/src/table/boot.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -882,30 +882,6 @@ impl BootServices {
882882
)
883883
}
884884

885-
/// Exits the UEFI boot services
886-
///
887-
/// This unsafe method is meant to be an implementation detail of the safe
888-
/// `SystemTable<Boot>::exit_boot_services()` method, which is why it is not
889-
/// public.
890-
///
891-
/// Everything that is explained in the documentation of the high-level
892-
/// `SystemTable<Boot>` method is also true here, except that this function
893-
/// is one-shot (no automatic retry) and does not prevent you from shooting
894-
/// yourself in the foot by calling invalid boot services after a failure.
895-
///
896-
/// # Errors
897-
///
898-
/// See section `EFI_BOOT_SERVICES.ExitBootServices()` in the UEFI Specification for more details.
899-
///
900-
/// * [`uefi::Status::INVALID_PARAMETER`]
901-
pub(super) unsafe fn exit_boot_services(
902-
&self,
903-
image: Handle,
904-
mmap_key: MemoryMapKey,
905-
) -> Result {
906-
(self.0.exit_boot_services)(image.as_ptr(), mmap_key.0).to_result()
907-
}
908-
909885
/// Stalls the processor for an amount of time.
910886
///
911887
/// The time is in microseconds.

uefi/src/table/mod.rs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
33
pub mod boot;
44
pub mod cfg;
5-
pub mod runtime;
65

76
mod header;
87
mod system;
98

109
pub use header::Header;
1110
#[allow(deprecated)]
12-
pub use system::{Boot, Runtime, SystemTable};
11+
pub use system::{Boot, SystemTable};
1312
pub use uefi_raw::table::Revision;
1413

1514
use core::ptr::{self, NonNull};
@@ -79,25 +78,6 @@ pub fn system_table_boot() -> Option<SystemTable<Boot>> {
7978
}
8079
}
8180

82-
/// Get the system table while runtime services are active.
83-
#[deprecated = "Use the uefi::runtime module instead. See https://github.com/rust-osdev/uefi-rs/blob/HEAD/docs/funcs_migration.md"]
84-
#[allow(deprecated)]
85-
pub fn system_table_runtime() -> Option<SystemTable<Runtime>> {
86-
let st = SYSTEM_TABLE.load(Ordering::Acquire);
87-
if st.is_null() {
88-
return None;
89-
}
90-
91-
// SAFETY: the system table is valid per the requirements of `set_system_table`.
92-
unsafe {
93-
if (*st).runtime_services.is_null() {
94-
None
95-
} else {
96-
Some(SystemTable::<Runtime>::from_ptr(st.cast()).unwrap())
97-
}
98-
}
99-
}
100-
10181
/// Common trait implemented by all standard UEFI tables.
10282
pub trait Table {
10383
/// A unique number assigned by the UEFI specification

0 commit comments

Comments
 (0)