Debian Codegraph @

.cargo/vendor/r-efi/examples/freestanding.rs

raw
1 // Example: Freestanding
2 //
3 // This example is a plain UEFI application without any external requirements
4 // but `core`. It immediately returns control to the caller upon execution,
5 // yielding the exit code 0.
6 //
7 // The `main` function serves as entry-point. Depending on your
8 // target-configuration, it must be exported with a pre-configured name so the
9 // linker will correctly mark it as entry-point. The target configurations
10 // shipped with upstream rust-lang use `efi_main` as symbol name.
11 //
12 // Additionally, a panic handler is provided. This is executed by rust on
13 // panic. For simplicity, we simply end up in an infinite loop. For real
14 // applications, this method should probably call into
15 // `SystemTable->boot_services->exit()` to exit the UEFI application. Note,
16 // however, that UEFI applications are likely to run in the same address space
17 // as the entire firmware. Hence, halting the machine might be a viable
18 // alternative. All that is out-of-scope for this example, though.
19 //
20 // Note that as of rust-1.31.0, all features used here are stabilized. No
21 // unstable features are required, nor do we rely on nightly compilers.
22
23 #![no_main]
24 #![no_std]
25
26 #[panic_handler]
27 fn panic_handler(_info: &core::panic::PanicInfo) -> ! {
28 loop {}
29 }
30
31 #[export_name = "efi_main"]
32 pub extern "C" fn main(_h: *mut core::ffi::c_void, _st: *mut core::ffi::c_void) -> usize {
33 0
34 }