Skip to content

Commit

Permalink
Merge pull request #1379 from rust-osdev/bishop-deprecate-system
Browse files Browse the repository at this point in the history
uefi: Deprecate SystemTable
  • Loading branch information
phip1611 authored Aug 28, 2024
2 parents 781c608 + 13e8b34 commit 41a3cb4
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 11 deletions.
1 change: 1 addition & 0 deletions uefi-macros/tests/ui/fail/entry_bad_abi.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![allow(unused_imports)]
#![no_main]
#![allow(deprecated)]

use uefi::prelude::*;
use uefi_macros::entry;
Expand Down
4 changes: 2 additions & 2 deletions uefi-macros/tests/ui/fail/entry_bad_abi.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: Entry method must have no ABI modifier
--> tests/ui/fail/entry_bad_abi.rs:8:1
--> tests/ui/fail/entry_bad_abi.rs:9:1
|
8 | extern "C" fn main(_handle: Handle, _st: SystemTable<Boot>) -> Status {
9 | extern "C" fn main(_handle: Handle, _st: SystemTable<Boot>) -> Status {
| ^^^^^^
1 change: 1 addition & 0 deletions uefi-macros/tests/ui/fail/entry_bad_arg.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![allow(unused_imports)]
#![no_main]
#![allow(deprecated)]

use uefi::prelude::*;
use uefi_macros::entry;
Expand Down
4 changes: 2 additions & 2 deletions uefi-macros/tests/ui/fail/entry_bad_arg.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error[E0308]: mismatched types
--> tests/ui/fail/entry_bad_arg.rs:8:1
--> tests/ui/fail/entry_bad_arg.rs:9:1
|
8 | fn main(_handle: Handle, _st: SystemTable<Boot>, _x: usize) -> Status {
9 | fn main(_handle: Handle, _st: SystemTable<Boot>, _x: usize) -> Status {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters
|
= note: expected fn pointer `extern "efiapi" fn(uefi::Handle, uefi::prelude::SystemTable<uefi::prelude::Boot>) -> uefi::Status`
Expand Down
1 change: 1 addition & 0 deletions uefi-macros/tests/ui/fail/entry_bad_return_type.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![allow(unused_imports)]
#![no_main]
#![allow(deprecated)]

use uefi::prelude::*;
use uefi_macros::entry;
Expand Down
4 changes: 2 additions & 2 deletions uefi-macros/tests/ui/fail/entry_bad_return_type.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error[E0308]: mismatched types
--> tests/ui/fail/entry_bad_return_type.rs:8:1
--> tests/ui/fail/entry_bad_return_type.rs:9:1
|
8 | fn main(_handle: Handle, _st: SystemTable<Boot>) -> bool {
9 | fn main(_handle: Handle, _st: SystemTable<Boot>) -> bool {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Status`, found `bool`
|
= note: expected fn pointer `extern "efiapi" fn(uefi::Handle, uefi::prelude::SystemTable<uefi::prelude::Boot>) -> Status`
Expand Down
2 changes: 2 additions & 0 deletions uefi-macros/tests/ui/pass/entry.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(deprecated)]

use uefi::table::{Boot, SystemTable};
use uefi::{entry, Handle, Status};

Expand Down
2 changes: 2 additions & 0 deletions uefi-macros/tests/ui/pass/entry_docstring.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(deprecated)]

use uefi::table::{Boot, SystemTable};
use uefi::{entry, Handle, Status};

Expand Down
2 changes: 2 additions & 0 deletions uefi-macros/tests/ui/pass/entry_unsafe.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(deprecated)]

use uefi::table::{Boot, SystemTable};
use uefi::{entry, Handle, Status};

Expand Down
5 changes: 3 additions & 2 deletions uefi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ how to integrate the `uefi` crate into them.
- Added `Handle::new`

## Changed
- The `BootServices` and `RuntimeServices` structs have been deprecated. Use
the `uefi::runtime` and `uefi::boot` modules instead.
- The `BootServices`, `RuntimeServices`, and `SystemTable` structs have been
deprecated. Use the `uefi::boot` and `uefi::runtime`, and `uefi::system`
modules instead.
- In `uefi::table::boot`, `ScopedProtocol`, `TplGuard`, `ProtocolsPerHandle`,
and `HandleBuffer` have been deprecated. Use the structs of the same name in
`uefi::boot` instead.
Expand Down
3 changes: 2 additions & 1 deletion uefi/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ use core::sync::atomic::{AtomicU32, Ordering};
use crate::boot;
use crate::mem::memory_map::MemoryType;
use crate::proto::loaded_image::LoadedImage;
#[allow(deprecated)]
use crate::table::{Boot, SystemTable};

/// Deprecated; this function is now a no-op.
#[deprecated = "this function is now a no-op"]
#[allow(unused_unsafe, clippy::missing_safety_doc)]
#[allow(deprecated, unused_unsafe, clippy::missing_safety_doc)]
pub unsafe fn init(_: &mut SystemTable<Boot>) {}

/// Deprecated; this function is now a no-op.
Expand Down
3 changes: 2 additions & 1 deletion uefi/src/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//! [print_macro]: uefi::print!
//! [println_macro]: uefi::println!
#[allow(deprecated)]
use crate::prelude::{Boot, SystemTable};
use crate::{table, Result};
#[doc(hidden)]
Expand All @@ -41,8 +42,8 @@ mod println;
/// The returned pointer is only valid until boot services are exited.
#[must_use]
#[deprecated(note = "use uefi::table::system_table_boot instead")]
#[allow(deprecated)]
pub fn system_table() -> SystemTable<Boot> {
#[allow(deprecated)]
table::system_table_boot().expect("boot services are not active")
}

Expand Down
1 change: 1 addition & 0 deletions uefi/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ pub use crate::{cstr16, cstr8, entry, Handle, ResultExt, Status, StatusExt};
pub use crate::table::boot::BootServices;
#[allow(deprecated)]
pub use crate::table::runtime::RuntimeServices;
#[allow(deprecated)]
pub use crate::table::{Boot, SystemTable};
3 changes: 3 additions & 0 deletions uefi/src/table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ mod header;
mod system;

pub use header::Header;
#[allow(deprecated)]
pub use system::{Boot, Runtime, SystemTable};
pub use uefi_raw::table::Revision;

Expand Down Expand Up @@ -61,6 +62,7 @@ pub unsafe fn set_system_table(ptr: *const uefi_raw::table::system::SystemTable)

/// Get the system table while boot services are active.
#[deprecated = "Use the uefi::boot module instead. See https://github.com/rust-osdev/uefi-rs/blob/HEAD/docs/funcs_migration.md"]
#[allow(deprecated)]
pub fn system_table_boot() -> Option<SystemTable<Boot>> {
let st = SYSTEM_TABLE.load(Ordering::Acquire);
if st.is_null() {
Expand All @@ -79,6 +81,7 @@ pub fn system_table_boot() -> Option<SystemTable<Boot>> {

/// Get the system table while runtime services are active.
#[deprecated = "Use the uefi::runtime module instead. See https://github.com/rust-osdev/uefi-rs/blob/HEAD/docs/funcs_migration.md"]
#[allow(deprecated)]
pub fn system_table_runtime() -> Option<SystemTable<Runtime>> {
let st = SYSTEM_TABLE.load(Ordering::Acquire);
if st.is_null() {
Expand Down
3 changes: 2 additions & 1 deletion uefi/src/table/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ impl SystemTableView for Runtime {}
/// documented in the UEFI spec. At that point, the boot view of the system
/// table will be destroyed (which conveniently invalidates all references to
/// UEFI boot services in the eye of the Rust borrow checker) and a runtime view
/// will be provided to replace it.
/// will be provided to replace it
#[deprecated = "Use the uefi::system, uefi::boot, and uefi::runtime modules instead. See https://github.com/rust-osdev/uefi-rs/blob/HEAD/docs/funcs_migration.md"]
#[derive(Debug)]
#[repr(transparent)]
pub struct SystemTable<View: SystemTableView> {
Expand Down

0 comments on commit 41a3cb4

Please sign in to comment.