Skip to content

Commit 99a258c

Browse files
Add documentation about logging/allocating after exiting boot services
The logger and allocator provided by the uefi crate can't be used after calling exit_boot_services. Add a paragraph to `exit_boot_services` to document that. Add a similar paragraph to the `uefi-services` crate documentation.
1 parent fc67fab commit 99a258c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/table/system.rs

+11
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ impl SystemTable<Boot> {
111111
/// `SystemTable<Boot>` view of the System Table and returning a more
112112
/// restricted `SystemTable<Runtime>` view as an output.
113113
///
114+
/// Once boot services are exited, the logger and allocator provided by
115+
/// this crate can no longer be used. The logger should be disabled using
116+
/// the [`Logger::disable`] method, and the allocator should be disabled by
117+
/// calling [`alloc::exit_boot_services`]. Note that if the logger and
118+
/// allocator were initialized with [`uefi_services::init`], they will be
119+
/// disabled automatically when `exit_boot_services` is called.
120+
///
114121
/// The handle passed must be the one of the currently executing image,
115122
/// which is received by the entry point of the UEFI application. In
116123
/// addition, the application must provide storage for a memory map, which
@@ -132,6 +139,10 @@ impl SystemTable<Boot> {
132139
/// system table which more accurately reflects the state of the UEFI
133140
/// firmware following exit from boot services, along with a high-level
134141
/// iterator to the UEFI memory map.
142+
///
143+
/// [`alloc::exit_boot_services`]: crate::alloc::exit_boot_services
144+
/// [`Logger::disable`]: crate::logger::Logger::disable
145+
/// [`uefi_services::init`]: https://docs.rs/uefi-services/latest/uefi_services/fn.init.html
135146
pub fn exit_boot_services(
136147
self,
137148
image: Handle,

uefi-services/src/lib.rs

+7
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@
33
//! It initializes the memory allocation and logging crates,
44
//! allowing code to use Rust's data structures and to log errors.
55
//!
6+
//! Logging and allocation are only allowed while boot services are
7+
//! active. Once runtime services are activated by calling
8+
//! [`exit_boot_services`], the logger will be disabled and the
9+
//! allocator will always return null.
10+
//!
611
//! It also stores a global reference to the UEFI system table,
712
//! in order to reduce the redundant passing of references to it.
813
//!
914
//! Library code can simply use global UEFI functions
1015
//! through the reference provided by `system_table`.
16+
//!
17+
//! [`exit_boot_services`]: uefi::table::SystemTable::exit_boot_services
1118
1219
#![no_std]
1320
#![feature(alloc_error_handler)]

0 commit comments

Comments
 (0)