Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/uefi/src/helpers/mod.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / uefi / src / helpers / mod.rs` 60 lines ยท 1923 bytes Raw Blame History 1 // SPDX-License-Identifier: MIT OR Apache-2.0 2 3 //! This module provides miscellaneous opinionated but optional helpers to 4 //! better integrate your application with the Rust runtime and the Rust 5 //! ecosystem. 6 //! 7 //! For now, this includes: 8 //! - using [`uefi::allocator::Allocator`] as global allocator (feature `global_allocator`) 9 //! - an implementation of [`log::Log`] (feature `logger`) which logs to 10 //! the stdout text protocol of UEFI (as long as boot services were not 11 //! excited) and to the [debugcon device](https://phip1611.de/blog/how-to-use-qemus-debugcon-feature/) 12 //! (only on x86) (feature `log-debugcon`). 13 //! - [`print!`][print_macro] and [`println!`][println_macro] macros defaulting 14 //! to the uefi boot service stdout stream 15 //! - default panic handler (feature `panic_handler`) 16 //! 17 //! **Note:** These helpers are meant for the pre-exit boot-services epoch. 18 //! 19 //! [print_macro]: uefi::print! 20 //! [println_macro]: uefi::println! 21 22 use crate::Result; 23 #[doc(hidden)] 24 pub use println::_print; 25 26 #[cfg(feature = "global_allocator")] 27 mod global_allocator; 28 #[cfg(feature = "logger")] 29 mod logger; 30 #[cfg(feature = "panic_handler")] 31 mod panic_handler; 32 mod println; 33 34 /// Initialize all helpers defined in [`uefi::helpers`] whose Cargo features 35 /// are activated. 36 /// 37 /// This must be called as early as possible, before trying to use logging. 38 /// 39 /// **Note:** These helpers are meant for the pre-exit boot-services epoch. 40 /// Limited functionality might work after exiting them, such as logging 41 /// to the debugcon device. 42 /// 43 /// # Panics 44 /// 45 /// This function may panic if called more than once. 46 pub fn init() -> Result<()> { 47 // Set up logging. 48 #[cfg(feature = "logger")] 49 // SAFETY: Called exactly once here during crate init, before any logging. 50 unsafe { 51 logger::init(); 52 } 53 54 Ok(()) 55 } 56 57 pub(crate) fn exit() { 58 #[cfg(feature = "logger")] 59 logger::disable(); 60 }