diff options
Diffstat (limited to '')
| -rw-r--r-- | bins/hello/Cargo.toml | 10 | ||||
| -rw-r--r-- | bins/hello/src/main.rs | 33 |
2 files changed, 43 insertions, 0 deletions
diff --git a/bins/hello/Cargo.toml b/bins/hello/Cargo.toml new file mode 100644 index 0000000..ac71ded --- /dev/null +++ b/bins/hello/Cargo.toml | |||
| @@ -0,0 +1,10 @@ | |||
| 1 | [package] | ||
| 2 | name = "hello" | ||
| 3 | version.workspace = true | ||
| 4 | edition.workspace = true | ||
| 5 | |||
| 6 | [lints] | ||
| 7 | workspace = true | ||
| 8 | |||
| 9 | [dependencies] | ||
| 10 | rsapi = { path = "../../rsapi" } | ||
diff --git a/bins/hello/src/main.rs b/bins/hello/src/main.rs new file mode 100644 index 0000000..d1d58df --- /dev/null +++ b/bins/hello/src/main.rs | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | //! hello — the first rs-dos external binary (ADR 0006 Phase 2 gate). | ||
| 2 | //! | ||
| 3 | //! Prints one line through the injected Exports table and exits 0. | ||
| 4 | //! Exercises the whole chain: PE32+ load, relocation, ABI call, task exit. | ||
| 5 | |||
| 6 | #![no_std] | ||
| 7 | #![no_main] | ||
| 8 | |||
| 9 | use rsapi::Exports; | ||
| 10 | |||
| 11 | #[panic_handler] | ||
| 12 | fn panic(_info: &core::panic::PanicInfo) -> ! { | ||
| 13 | loop { | ||
| 14 | core::hint::spin_loop(); | ||
| 15 | } | ||
| 16 | } | ||
| 17 | |||
| 18 | /// The image entry point — the loader jumps here with the ABI arguments | ||
| 19 | /// (exports table, argc, argv). The conventional UEFI name is kept so | ||
| 20 | /// the PE looks normal; the signature is the rs-dos ABI. | ||
| 21 | #[unsafe(no_mangle)] | ||
| 22 | pub extern "C" fn efi_main(exports: &'static Exports, _argc: usize, _argv: *const rsapi::Arg) -> i32 { | ||
| 23 | let msg = b"hello, world - from an external binary"; | ||
| 24 | let line = rsapi::Line { | ||
| 25 | ptr: msg.as_ptr(), | ||
| 26 | len: msg.len(), | ||
| 27 | }; | ||
| 28 | if (exports.put_line)(line) { | ||
| 29 | 0 | ||
| 30 | } else { | ||
| 31 | 1 | ||
| 32 | } | ||
| 33 | } | ||
