Skip to content

Add documentation about logging/allocating after exiting boot services #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/table/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,13 @@ impl SystemTable<Boot> {
/// `SystemTable<Boot>` view of the System Table and returning a more
/// restricted `SystemTable<Runtime>` view as an output.
///
/// Once boot services are exited, the logger and allocator provided by
/// this crate can no longer be used. The logger should be disabled using
/// the [`Logger::disable`] method, and the allocator should be disabled by
/// calling [`alloc::exit_boot_services`]. Note that if the logger and
/// allocator were initialized with [`uefi_services::init`], they will be
/// disabled automatically when `exit_boot_services` is called.
///
/// The handle passed must be the one of the currently executing image,
/// which is received by the entry point of the UEFI application. In
/// addition, the application must provide storage for a memory map, which
Expand All @@ -132,6 +139,10 @@ impl SystemTable<Boot> {
/// system table which more accurately reflects the state of the UEFI
/// firmware following exit from boot services, along with a high-level
/// iterator to the UEFI memory map.
///
/// [`alloc::exit_boot_services`]: crate::alloc::exit_boot_services
/// [`Logger::disable`]: crate::logger::Logger::disable
/// [`uefi_services::init`]: https://docs.rs/uefi-services/latest/uefi_services/fn.init.html
pub fn exit_boot_services(
self,
image: Handle,
Expand Down
7 changes: 7 additions & 0 deletions uefi-services/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
//! It initializes the memory allocation and logging crates,
//! allowing code to use Rust's data structures and to log errors.
//!
//! Logging and allocation are only allowed while boot services are
//! active. Once runtime services are activated by calling
//! [`exit_boot_services`], the logger will be disabled and the
//! allocator will always return null.
//!
//! It also stores a global reference to the UEFI system table,
//! in order to reduce the redundant passing of references to it.
//!
//! Library code can simply use global UEFI functions
//! through the reference provided by `system_table`.
//!
//! [`exit_boot_services`]: uefi::table::SystemTable::exit_boot_services

#![no_std]
#![feature(alloc_error_handler)]
Expand Down