summaryrefslogtreecommitdiffstats
path: root/bins/hello/src/main.rs
blob: d1d58df00cb951ac25ae1f8a94b8d685dffdd5e7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//! hello — the first rs-dos external binary (ADR 0006 Phase 2 gate).
//!
//! Prints one line through the injected Exports table and exits 0.
//! Exercises the whole chain: PE32+ load, relocation, ABI call, task exit.

#![no_std]
#![no_main]

use rsapi::Exports;

#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
    loop {
        core::hint::spin_loop();
    }
}

/// The image entry point — the loader jumps here with the ABI arguments
/// (exports table, argc, argv).  The conventional UEFI name is kept so
/// the PE looks normal; the signature is the rs-dos ABI.
#[unsafe(no_mangle)]
pub extern "C" fn efi_main(exports: &'static Exports, _argc: usize, _argv: *const rsapi::Arg) -> i32 {
    let msg = b"hello, world - from an external binary";
    let line = rsapi::Line {
        ptr: msg.as_ptr(),
        len: msg.len(),
    };
    if (exports.put_line)(line) {
        0
    } else {
        1
    }
}