Skip to content

Commit ed7faf7

Browse files
committed
xxx
1 parent c450fbe commit ed7faf7

File tree

8 files changed

+40
-10
lines changed

8 files changed

+40
-10
lines changed

Cargo.lock

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

book/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
- [Introduction](introduction.md)
44
- [Tutorial](tutorial/introduction.md)
55
- [Creating a UEFI Application](tutorial/app.md)
6+
- [Combining Rust `std` with `uefi`](tutorial/rust-std.md)
67
- [Building](tutorial/building.md)
78
- [Running in a VM](tutorial/vm.md)
89
- [Running on Hardware](tutorial/hardware.md)

book/src/tutorial/rust-std.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Combining Rust `std` with `uefi`
2+
3+
In the `uefi` crate, we provide tooling to create a `#[no_std]` + `#[no_main]`
4+
binary, i.e., an UEFI image, in a convenient way. However, there is also the
5+
option to create a "standard" binary with Rust. The result is the same, but the
6+
build process and the overall programming is much more similar to regular
7+
Rust binaries written for Operating Systems, such as Linux, Windows, or macOS.
8+
9+
## About `std` for `uefi`
10+
11+
The Rust implementation of the standard library (_`std` implementation_) is
12+
ongoing and will evolve over the coming months and years. Over time, you will
13+
need less and less specific features of `uefi` and can utilize standard and
14+
well-known OS-independent APIs for that, as in the typical Linux application,
15+
for example.
16+
17+
The `uefi` crate is suited to extend the functionality of these "standard
18+
binaries".

shell.nix

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ pkgs.mkShell {
2121
rustToolchain
2222

2323
# Other
24+
mdbook
2425
yamlfmt
2526
which # used by "cargo xtask fmt"
2627
];

uefi-std-example/.cargo/config.toml

-2
This file was deleted.

uefi-std-example/Cargo.toml

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
[package]
22
name = "uefi-std-example"
3-
description = """
4-
5-
"""
63
version = "0.1.0"
74
authors = ["The Rust OSDev team"]
85
publish = false
96
edition = "2021"
107

118
[dependencies]
12-
uefi = { path = "../uefi", features = [], default-features = false }
13-
14-
log.workspace = true
9+
# Attention: Don't activate the panic_handler feature, as it will clash with
10+
# the one coming from `std`.
11+
uefi = { path = "../uefi", features = ["alloc"], default-features = false }

uefi-std-example/README.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Minimal Rust App using `std` and `uefi`
22

3+
Minimal example of a "standard Rust application" that showcases how `uefi` can
4+
be utilized and enhance the developers experience, when `std` is available.
5+
6+
For simplicity, this example is minimal and the documentation is focused on
7+
`x86_64-unknown-uefi`. However, it works similar for other supported UEFI
8+
platforms.
9+
310
## Build
411

5-
Build using `cargo +nightly build` to build an `x86_64-unknown-uefi` app.
12+
Build the app using
13+
`$ cargo +nightly build --target x86_64-unknown-uefi`. To build it from the root
14+
directory (the Cargo workspace), append `-p uefi-std-example`.
15+
16+
## Run
17+
18+
The resulting `.efi` file can be found in `target/x86_64-unknown-uefi/<debug|release>/uefi-std-example.efi`.

uefi-std-example/src/main.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Note: In Rust 1.82.0-nightly and before, the `uefi_std` feature is
2+
// required for accessing `std::os::uefi::env::*`. The default functionality
3+
// doesn't need a nightly toolchain.
14
#![feature(uefi_std)]
25

36
use std::os::uefi as uefi_std;

0 commit comments

Comments
 (0)