Skip to content

Commit

Permalink
wip: Deprecate SystemTable/BootServices/RuntimeServices
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasbishop committed Aug 25, 2024
1 parent b678c8e commit 641251e
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions uefi-test-runner/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#![no_std]
#![no_main]
// TODO: temporarily allow deprecated code so that we can continue to test
// SystemTable/BootServices/RuntimeServices.
#![allow(deprecated)]

#[macro_use]
extern crate log;
Expand Down
4 changes: 3 additions & 1 deletion uefi/src/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ 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(unused_unsafe, clippy::missing_safety_doc, deprecated)]
pub unsafe fn init(_: &mut SystemTable<Boot>) {}

/// Deprecated; this function is now a no-op.
Expand Down
1 change: 1 addition & 0 deletions uefi/src/helpers/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
//! The last part also means that some Unicode characters might not be
//! supported by the UEFI console. Don't expect emoji output support.

#[allow(deprecated)]
use crate::prelude::{Boot, SystemTable};
use crate::proto::console::text::Output;
use core::fmt::{self, Write};
Expand Down
2 changes: 2 additions & 0 deletions 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,6 +42,7 @@ 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> {
table::system_table_boot().expect("boot services are not active")
}
Expand Down
3 changes: 3 additions & 0 deletions uefi/src/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
pub use crate::{cstr16, cstr8, entry, Handle, ResultExt, Status, StatusExt};

// Import the basic table types.
#[allow(deprecated)]
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/boot.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! UEFI services available during boot.

#![allow(deprecated)]

pub use crate::boot::{
AllocateType, EventNotifyFn, LoadImageSource, OpenProtocolAttributes, OpenProtocolParams,
ProtocolSearchKey, SearchType, TimerTrigger,
Expand Down Expand Up @@ -79,6 +81,7 @@ pub const PAGE_SIZE: usize = 4096;
///
/// [`Output`]: crate::proto::console::text::Output
/// [`open_protocol`]: BootServices::open_protocol
#[deprecated = "Use the uefi::boot module instead. See https://github.com/rust-osdev/uefi-rs/blob/HEAD/docs/funcs_migration.md"]
#[derive(Debug)]
#[repr(transparent)]
pub struct BootServices(uefi_raw::table::boot::BootServices);
Expand Down
5 changes: 5 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 @@ -60,6 +61,8 @@ 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 @@ -77,6 +80,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"]
pub fn system_table_runtime() -> Option<SystemTable<Runtime>> {
let st = SYSTEM_TABLE.load(Ordering::Acquire);
if st.is_null() {
Expand All @@ -88,6 +92,7 @@ pub fn system_table_runtime() -> Option<SystemTable<Runtime>> {
if (*st).runtime_services.is_null() {
None
} else {
#[allow(deprecated)]
Some(SystemTable::<Runtime>::from_ptr(st.cast()).unwrap())
}
}
Expand Down
3 changes: 3 additions & 0 deletions uefi/src/table/runtime.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! UEFI services available at runtime, even after the OS boots.

#![allow(deprecated)]

pub use crate::runtime::{
CapsuleInfo, Time, TimeByteConversionError, TimeError, TimeParams, VariableStorageInfo,
};
Expand Down Expand Up @@ -35,6 +37,7 @@ use {
/// A reference to `RuntimeServices` can only be accessed by calling [`SystemTable::runtime_services`].
///
/// [`SystemTable::runtime_services`]: crate::table::SystemTable::runtime_services
#[deprecated = "Use the uefi::runtime module instead. See https://github.com/rust-osdev/uefi-rs/blob/HEAD/docs/funcs_migration.md"]
#[derive(Debug)]
#[repr(C)]
pub struct RuntimeServices(uefi_raw::table::runtime::RuntimeServices);
Expand Down
4 changes: 4 additions & 0 deletions uefi/src/table/system.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(deprecated)]

use super::boot::BootServices;
use super::runtime::{ResetType, RuntimeServices};
use super::{cfg, Revision};
Expand All @@ -15,11 +17,13 @@ use uefi::mem::memory_map::{
pub trait SystemTableView {}

/// Marker struct associated with the boot view of the UEFI System Table.
#[deprecated = "Use the uefi::boot module instead. See https://github.com/rust-osdev/uefi-rs/blob/HEAD/docs/funcs_migration.md"]
#[derive(Debug)]
pub struct Boot;
impl SystemTableView for Boot {}

/// Marker struct associated with the run-time view of the UEFI System Table.
#[deprecated = "Use the uefi::runtime module instead. See https://github.com/rust-osdev/uefi-rs/blob/HEAD/docs/funcs_migration.md"]
#[derive(Debug)]
pub struct Runtime;
impl SystemTableView for Runtime {}
Expand Down

0 comments on commit 641251e

Please sign in to comment.