@@ -21,12 +21,12 @@ let qemu_exit_handle = qemu_exit::AArch64::new();
2121
2222// addr: The address of sifive_test.
2323#[cfg(target_arch = " riscv64" )]
24- let qemu_exit_handle = qemu_exit :: RISCV64 :: new (addr );
24+ let qemu_exit_handle = unsafe { qemu_exit :: RISCV64 :: new (addr ) } ;
2525
2626// io_base: I/O-base of isa-debug-exit.
2727// custom_exit_success: A custom success code; Must be an odd number.
2828#[cfg(any(target_arch = " x86" , target_arch = " x86_64" ))]
29- let qemu_exit_handle = qemu_exit :: X86 :: new (io_base , custom_exit_success );
29+ let qemu_exit_handle = unsafe { qemu_exit :: X86 :: new (io_base , custom_exit_success ) } ;
3030
3131qemu_exit_handle . exit (1337 );
3232qemu_exit_handle . exit_success ();
@@ -38,6 +38,7 @@ qemu_exit_handle.exit_failure();
3838### AArch64/AArch32
3939
4040Pass the ` -semihosting ` argument to the QEMU invocation, e.g.:
41+
4142```
4243qemu-system-aarch64 -M raspi3 -serial stdio -semihosting -kernel kernel8.img
4344qemu-system-arm -nographic -M mps2-an500 -cpu cortex-m7 -serial mon:stdio -semihosting -kernel
@@ -47,13 +48,15 @@ kernel.img
4748### RISCV64
4849
4950You need to chose a machine with the ` sifive_test ` device, for exemple ` -M virt ` :
51+
5052```
5153qemu-system-riscv64 -M virt -nographic -monitor none -serial stdio -kernel kernel.elf
5254```
5355
5456### x86/x86_64
5557
5658Add the special ISA debug exit device by passing the flags:
59+
5760```
5861-device isa-debug-exit,iobase=0xf4,iosize=0x04
5962```
@@ -67,14 +70,15 @@ binary-OR'ed with `0x1`. This is hardcoded and therefore, with `isa-debug-exit`,
6770possible to let QEMU invoke ` exit(0) ` .
6871
6972``` rust
70- let qemu_exit_handle = qemu_exit :: X86 :: new (io_base , custom_exit_success );
73+ let qemu_exit_handle = unsafe { qemu_exit :: X86 :: new (io_base , custom_exit_success ) } ;
7174```
7275
7376#### x86/x86_64 Linux
7477
7578To use this mechanism from Linux userspace, the kernel must be compiled with
7679` CONFIG_X86_IOPL_IOPERM=y ` (which is the default) and the process must start with root privileges
7780(or ` CAP_SYS_RAWIO ` ) and call: [ ` ioperm(2) ` ] ( https://man7.org/linux/man-pages/man2/ioperm.2.html ) :
81+
7882``` rust
7983nix :: errno :: Errno :: result (unsafe { libc :: ioperm ( 0xf4 , 4 , 1 )}). expect (" ioperm failed" );
8084```
0 commit comments