qemu-exit 0.1.1

Exit QEMU with user-defined code
Documentation

crates.io crates.io

qemu-exit

Exit QEMU with user-defined code.

Quit a running QEMU session with user-defined exit code. Useful for unit or integration tests using QEMU.

AArch64

Pass the -semihosting argument to QEMU invocation, e.g.:

qemu-system-aarch64 -M raspi3 -serial stdio -semihosting -kernel kernel8.img

Examples

Exit the QEMU session from anywhere in your code:

qemu_exit::aarch64::exit_success() // QEMU binary executes `exit(0)`.
qemu_exit::aarch64::exit_failure() // QEMU binary executes `exit(1)`.
qemu_exit::aarch64::exit(arg)      // Use a custom code. Argument must implement `Into<u64>`.

x86_64

Add the special ISA debug exit device by passing the flags:

-device isa-debug-exit,iobase=0xf4,iosize=0x04

Examples

The iobase is given as a const generic:

qemu_exit::x86::exit<{ 0xf4 }>(arg) // Use a custom code. Argument must implement `Into<u32>`.

Note

The QEMU binary will execute exit((arg << 1) | 1). The is hardcoded in the QEMU sources. Therefore, with isa-debug-exit, it is not possible to let QEMU invoke exit(0).

Literature

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.