Skip to content

Commit 4b33da6

Browse files
committed
doc: add "Comparison to other Projects in the Ecosystem" to lib.rs
This is especially interesting as the `std` implementation of Rust is upcoming.
1 parent e508cd9 commit 4b33da6

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

uefi/src/lib.rs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,74 @@
115115
//! Contributions in the form of a PR are also highly welcome. Check our
116116
//! [contributing guide][contributing] for details.
117117
//!
118+
//! # Comparison to other Projects in the Ecosystem
119+
//!
120+
//! ## Rust `std` implementation
121+
//!
122+
//! There is an ongoing effort for a [`std` implementation][rustc-uefi-std] of
123+
//! the Rust standard library, which allows you to write UEFI programs that look
124+
//! very similar to normal Rust programs running on top of an OS.
125+
//!
126+
//! It is still under development. You can track the progress in the
127+
//! corresponding [tracking issue][uefi-std-tr-issue].
128+
//!
129+
//! Using the `std` implementation simplifies the overall process of producing
130+
//! the binary. For example, our [`#[entry]`][entry-macro] macro won't be
131+
//! required any longer. As the `std` implementation evolves over time, you'll
132+
//! need fewer and fewer abstractions of this crate. For everything not covered
133+
//! by the `std` implementation, you can obtain relevant structures to work with
134+
//! our crate via:
135+
//! - `std::os::uefi::env::boot_services()`
136+
//! - `std::os::uefi::env::get_system_handle()`
137+
//! - `std::os::uefi::env::get_system_table()`
138+
//!
139+
//! ### Example
140+
//!
141+
//! A minimal Rust app utilizing the uefi `std` implementation and leveraging
142+
//! functionality from `uefi` might look like as follows:
143+
//!
144+
//! ```ignore
145+
//! #![feature(uefi_std)]
146+
//! #![feature(uefi_std)]
147+
//!
148+
//! use std::os::uefi as uefi_std;
149+
//! use uefi::{Handle, Status};
150+
//! use uefi::runtime::ResetType;
151+
//!
152+
//! /// Performs the necessary setup code for the `uefi` crate.
153+
//! fn setup_uefi_crate() {
154+
//! let st = uefi_std::env::system_table();
155+
//! let ih = uefi_std::env::image_handle();
156+
//!
157+
//! // Mandatory setup code for `uefi` crate.
158+
//! unsafe {
159+
//! uefi::table::set_system_table(st.as_ptr().cast());
160+
//!
161+
//! let ih = Handle::from_ptr(ih.as_ptr().cast()).unwrap();
162+
//! uefi::boot::set_image_handle(ih);
163+
//! }
164+
//! }
165+
//!
166+
//! fn main() {
167+
//! println!("Hello World from uefi_std");
168+
//! setup_uefi_crate();
169+
//! println!("UEFI-Version is {}", uefi::system::uefi_revision());
170+
//! uefi::runtime::reset(ResetType::SHUTDOWN, Status::SUCCESS, None);
171+
//! }
172+
//! ```
173+
//!
174+
//! ## `r-efi`
175+
//!
176+
//! [`r-efi`] provides Raw UEFI bindings without high-level convenience similar
177+
//! to our `uefi-raw` crate, which is part of this project, but more
178+
//! feature-complete. It targets a lower-level than our `uefi` crate does.
179+
//!
180+
//! # MSRV
181+
//! <!-- Keep in Sync with README! -->
182+
//!
183+
//! The minimum supported Rust version is currently 1.70.
184+
//! Our policy is to support at least the past two stable releases.
185+
//!
118186
//! # License
119187
//! <!-- Keep in Sync with README! -->
120188
//!
@@ -129,18 +197,23 @@
129197
//! Both "EFI" and "UEFI" can be used interchangeably, such as "UEFI image" or
130198
//! "EFI image". We prefer "UEFI" in our crate and its documentation.
131199
//!
200+
//!
132201
//! [LICENSE]: https://github.com/rust-osdev/uefi-rs/blob/main/uefi/LICENSE
133202
//! [Rust UEFI Book]: https://rust-osdev.github.io/uefi-rs/HEAD/
134203
//! [UEFI]: https://uefi.org/
135204
//! [Zulip]: https://rust-osdev.zulipchat.com
136205
//! [`BootServices`]: table::boot::BootServices
137206
//! [`GlobalAlloc`]: alloc::alloc::GlobalAlloc
138207
//! [`SystemTable`]: table::SystemTable
208+
//! [`r-efi`]: https://crates.io/crates/r-efi
209+
//! [`entry-macro`]: uefi_macros::entry
139210
//! [`unsafe_protocol`]: proto::unsafe_protocol
140211
//! [contributing]: https://github.com/rust-osdev/uefi-rs/blob/main/CONTRIBUTING.md
141212
//! [issue tracker]: https://github.com/rust-osdev/uefi-rs/issues
142213
//! [spec]: https://uefi.org/specifications
143214
//! [unstable features]: https://doc.rust-lang.org/unstable-book/
215+
//! [rustc-uefi-std]: https://doc.rust-lang.org/nightly/rustc/platform-support/unknown-uefi.html
216+
//! [uefi-std-tr-issue]: https://github.com/rust-lang/rust/issues/100499
144217
145218
#![cfg_attr(all(feature = "unstable", feature = "alloc"), feature(allocator_api))]
146219
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

0 commit comments

Comments
 (0)