Skip to content

Update the hello-world tutorial #1397

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
Sep 12, 2024
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
19 changes: 7 additions & 12 deletions book/src/tutorial/app.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ used.

Next up are some `use` lines. Nothing too exciting here; the
`uefi::prelude` module is intended to be glob-imported, and exports a
number of commonly-used types.
number of commonly-used macros, modules, and types.

```rust
{{#include ../../../uefi-test-runner/examples/hello_world.rs:use}}
Expand All @@ -63,23 +63,18 @@ a little different from a standard Rust program.
{{#include ../../../uefi-test-runner/examples/hello_world.rs:entry}}
```

The `main` function in a Uefi application always takes two arguments,
the image handle and the system table. The image [handle] represents the
currently-running executable, and the system [table] provides access to
many different UEFI services. The `main` function returns a [`Status`],
which is essentially a numeric error (or success) code defined by UEFI.
The `main` function in a UEFI application takes no arguments and returns
a [`Status`], which is essentially a numeric error (or success) code
defined by UEFI. The `main` function must be marked with the `#[entry]`
macro.

The first thing we do inside of `main` is initialize `uefi_services`:
The first thing we do inside of `main` is initialize the `helpers`
module, which initializes logging:

```rust
{{#include ../../../uefi-test-runner/examples/hello_world.rs:services}}
```

The `uefi_services` crate is not strictly required to make a UEFI
application with the `uefi` crate, but it makes things much simpler by
setting a simple memory allocator, initializing the logger, and
providing a panic handler.

Next we use the standard `log` crate to output "Hello world!". Then we
call `stall` to make the system pause for 10 seconds. This just ensures
you have enough time to see the output.
Expand Down
1 change: 0 additions & 1 deletion uefi-test-runner/examples/hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

// ANCHOR: use
use log::info;
use uefi::boot;
use uefi::prelude::*;
// ANCHOR_END: use

Expand Down