diff options
| author | Jieyou Xu <jieyouxu@outlook.com> | 2025-09-05 16:28:10 +0800 |
|---|---|---|
| committer | Jieyou Xu <jieyouxu@outlook.com> | 2025-09-05 21:22:51 +0800 |
| commit | 7154d39231fd8051bc207dda3afba21a11b14fcd (patch) | |
| tree | 1d04e8f643f458d0155151a0130c29ec3000b402 /tests/run-make-cargo/uefi-qemu/uefi_qemu_test/src | |
| parent | aebcbe0a4b1bb7df327bccf94a82117b4ca99a9f (diff) | |
| download | rust-7154d39231fd8051bc207dda3afba21a11b14fcd.tar.gz rust-7154d39231fd8051bc207dda3afba21a11b14fcd.zip | |
tests: move `run-make` tests requiring in-tree cargo to `run-make-cargo` test suite
Diffstat (limited to 'tests/run-make-cargo/uefi-qemu/uefi_qemu_test/src')
| -rw-r--r-- | tests/run-make-cargo/uefi-qemu/uefi_qemu_test/src/main.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/run-make-cargo/uefi-qemu/uefi_qemu_test/src/main.rs b/tests/run-make-cargo/uefi-qemu/uefi_qemu_test/src/main.rs new file mode 100644 index 00000000000..f8e1212a9f6 --- /dev/null +++ b/tests/run-make-cargo/uefi-qemu/uefi_qemu_test/src/main.rs @@ -0,0 +1,39 @@ +// Code is adapted from this hello world example: +// https://doc.rust-lang.org/nightly/rustc/platform-support/unknown-uefi.html + +#![no_main] +#![no_std] + +use core::{panic, ptr}; + +use r_efi::efi::{Char16, Handle, RESET_SHUTDOWN, Status, SystemTable}; + +#[panic_handler] +fn panic_handler(_info: &panic::PanicInfo) -> ! { + loop {} +} + +#[export_name = "efi_main"] +pub extern "C" fn main(_h: Handle, st: *mut SystemTable) -> Status { + let s = b"Hello World!\n\0".map(|c| u16::from(c)); + + // Print "Hello World!". + let r = unsafe { ((*(*st).con_out).output_string)((*st).con_out, s.as_ptr() as *mut Char16) }; + if r.is_error() { + return r; + } + + // Shut down. + unsafe { + ((*((*st).runtime_services)).reset_system)( + RESET_SHUTDOWN, + Status::SUCCESS, + 0, + ptr::null_mut(), + ); + } + + // This should never be reached because `reset_system` should never + // return, so fail with an error if we get here. + Status::UNSUPPORTED +} |
