Open4

uefi-std(x86_64-unknown-uefi)を追う

飯
use core::arch::asm; 

fn main() {
    println!("Hello!");
    loop {
        halt();
    }
}

#[inline]
fn halt() {
    unsafe { asm!("hlt"); }
}

これでQEMU上にHello!の文字を表示できる。

$ rustup target list --installed
x86_64-unknown-linux-gnu
x86_64-unknown-uefi 

必要に応じてrustup target add x86_64-unknown-uefiでターゲット追加。

cargo run --target x86_64-unknown-uefi -Zbuild-std=core,std,panic_abort

これで実行。

.cargo/config.toml
[build]
target = "x86_64-unknown-uefi"

[unstable]
build-std = ["core", "std", "panic_abort"]
unstable-options = true

[target.x86_64-unknown-uefi]
runner = "./runner.sh "

ファイルに記述してcargo runもOK。