Skip to content

Use x86_64-unknown-uefi target #92

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 1 commit into from
Feb 6, 2019
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
13 changes: 5 additions & 8 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

UEFI applications are simple COFF (Windows) executables, with the special
`EFI_Application` subsystem, and some limitations (such as no dynamic linking).

The `x86_64-uefi.json` file describes a custom target for building UEFI apps.
[Rust supports building UEFI applications](https://github.com/rust-lang/rust/pull/56769)
though the `x86_64-unknown-uefi` target.

## Prerequisites

Expand All @@ -19,15 +19,12 @@ The following steps allow you to build a simple UEFI app.

```rust
#[no_mangle]
pub extern "win64" fn uefi_start(handle: Handle, system_table: SystemTable<Boot>) -> Status;
pub extern "C" fn efi_main(handle: Handle, system_table: SystemTable<Boot>) -> Status;
```

- Copy the `uefi-test-runner/x86_64-uefi.json` target file to your project's root.
You can customize it.

- Build using `cargo xbuild --target x86_64-uefi`.
- Build using `cargo xbuild --target x86_64-unknown-uefi`.

- The `target` directory will contain a `x86_64-uefi` subdirectory,
- The `target` directory will contain a `x86_64-unknown-uefi` subdirectory,
where you will find the `uefi_app.efi` file - a normal UEFI executable.

- To run this on a real computer:
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
OS loaders, hypervisors and other low-level applications. While it started out
as x86-specific, it has been adopted on other platforms, such as ARM.

This crates makes it easy to write UEFI applications in Rust.
This crate makes it easy to both:
- Write UEFI applications in Rust (via the [`x86_64-unknown-uefi`][rustc-uefi] target)
- Call UEFI functions from an OS (usually built with a [custom target][rustc-custom])

The objective is to provide **safe** and **performant** wrappers for UEFI interfaces,
and allow developers to write idiomatic Rust code.
Expand All @@ -20,6 +22,8 @@ and has been tested _only_ with **64-bit** UEFI.

[UEFI]: https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface
[gm-blog]: https://medium.com/@gil0mendes/an-efi-app-a-bit-rusty-82c36b745f49
[rustc-uefi]: https://github.com/rust-lang/rust/pull/56769
[rustc-custom]: https://doc.rust-lang.org/rustc/targets/custom.html

![uefi-rs running in QEMU](https://imgur.com/SFPSVuO.png)

Expand Down Expand Up @@ -49,7 +53,7 @@ This project contains multiple sub-crates:

## Building kernels which use UEFI

This crate makes it easy to start buildimg simple applications with UEFI.
This crate makes it easy to start building simple applications with UEFI.
However, there are some limitations you should be aware of:

- The global logger / allocator **can only be set once** per binary.
Expand Down Expand Up @@ -92,8 +96,6 @@ An example UEFI app is built in the `uefi-test-runner` directory.

Check out the testing [README.md](uefi-test-runner/README.md) for instructions on how to run the crate's tests.

This repo also contains a `x86_64-uefi.json` file, which is a custom Rust target for 64-bit UEFI applications.

## Building UEFI programs

For instructions on how to create your own UEFI apps, see the [BUILDING.md](BUILDING.md) file.
Expand Down
2 changes: 1 addition & 1 deletion uefi-test-runner/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# Run QEMU without showing GUI
'headless': False,
# Target to build for.
'target': 'x86_64-uefi',
'target': 'x86_64-unknown-uefi',
# Configuration to build.
'config': 'debug',
# QEMU executable to use
Expand Down
2 changes: 1 addition & 1 deletion uefi-test-runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod boot;
mod proto;

#[no_mangle]
pub extern "win64" fn uefi_start(image: uefi::Handle, st: SystemTable<Boot>) -> Status {
pub extern "C" fn efi_main(image: uefi::Handle, st: SystemTable<Boot>) -> Status {
// Initialize utilities (logging, memory allocation...)
uefi_services::init(&st).expect_success("Failed to initialize utilities");

Expand Down
26 changes: 0 additions & 26 deletions uefi-test-runner/x86_64-uefi.json

This file was deleted.