Skip to content

Commit 486e65b

Browse files
committed
Update crate to work with latest nightlies
1 parent 5814c52 commit 486e65b

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

BUILDING.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@ The following steps allow you to build a simple UEFI app.
1616

1717
- Create a new `#![no_std]` binary, add `#![no_main]` to use a custom entry point,
1818
and make sure you have an entry point function which matches the one below:
19-
20-
```rust
21-
#![feature(abi_efiapi)]
22-
use uefi::prelude::*;
23-
24-
#[entry]
25-
fn efi_main(handle: Handle, system_table: SystemTable<Boot>) -> Status;
26-
```
19+
```rust
20+
#![feature(abi_efiapi)]
21+
use uefi::prelude::*;
22+
23+
#[entry]
24+
fn efi_main(handle: Handle, system_table: SystemTable<Boot>) -> Status;
25+
```
26+
You will also want to add a dependency to the
27+
[`compiler-builtins`](https://github.com/rust-lang/compiler-builtins) crate,
28+
to avoid linking errors.
2729

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

src/exts.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Utility functions for the most common UEFI patterns.
22
33
use alloc_api::{
4-
alloc::{handle_alloc_error, AllocRef, Global},
4+
alloc::{handle_alloc_error, AllocInit, AllocRef, Global, MemoryBlock},
55
boxed::Box,
66
};
77
use core::{alloc::Layout, slice};
@@ -16,9 +16,10 @@ pub fn allocate_buffer(layout: Layout) -> Box<[u8]> {
1616
handle_alloc_error(layout);
1717
}
1818
unsafe {
19-
match Global.alloc(layout) {
20-
Ok((mem, len)) => Box::from_raw(slice::from_raw_parts_mut(mem.as_ptr(), len)),
19+
let MemoryBlock { ptr, size } = match Global.alloc(layout, AllocInit::Uninitialized) {
20+
Ok(block) => block,
2121
Err(_) => handle_alloc_error(layout),
22-
}
22+
};
23+
Box::from_raw(slice::from_raw_parts_mut(ptr.as_ptr(), size))
2324
}
2425
}

uefi-services/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ is-it-maintained-issue-resolution = { repository = "rust-osdev/uefi-rs" }
1515
is-it-maintained-open-issues = { repository = "rust-osdev/uefi-rs" }
1616

1717
[dependencies]
18-
rlibc = "1.0.0"
1918
x86_64 = "0.8.3"
2019

2120
uefi = { version = "0.4.4", features = ["alloc", "logger"] }

uefi-services/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@
1111
1212
#![no_std]
1313
#![feature(alloc_error_handler)]
14-
#![feature(asm)]
14+
#![feature(llvm_asm)]
1515
#![feature(lang_items)]
1616
#![feature(panic_info_message)]
1717

18-
// These crates are required.
19-
extern crate rlibc;
20-
2118
// Core types.
2219
extern crate uefi;
2320

@@ -177,7 +174,7 @@ fn panic_handler(info: &core::panic::PanicInfo) -> ! {
177174
loop {
178175
unsafe {
179176
// Try to at least keep CPU from running at 100%
180-
asm!("hlt" :::: "volatile");
177+
llvm_asm!("hlt" :::: "volatile");
181178
}
182179
}
183180
}

uefi-test-runner/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ uefi-services = { path = "../uefi-services" }
1111

1212
log = { version = "0.4.8", default-features = false }
1313

14+
compiler_builtins = { git = "https://github.com/rust-lang/compiler-builtins" }
15+
1416
[features]
1517
qemu = ["uefi-services/qemu"]

uefi-test-runner/src/main.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#![feature(asm)]
44
#![feature(abi_efiapi)]
55

6+
extern crate compiler_builtins;
7+
68
#[macro_use]
79
extern crate log;
810
#[macro_use]

0 commit comments

Comments
 (0)