Giter VIP home page Giter VIP logo

qemu-exit's Introduction

crates.io crates.io Build Test

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.

TL;DR

use qemu_exit::QEMUExit;

#[cfg(target_arch = "aarch64")]
let qemu_exit_handle = qemu_exit::AArch64::new();

// addr: The address of sifive_test.
#[cfg(target_arch = "riscv64")]
let qemu_exit_handle = qemu_exit::RISCV64::new(addr);

// io_base:             I/O-base of isa-debug-exit.
// custom_exit_success: A custom success code; Must be an odd number.
#[cfg(target_arch = "x86_64")]
let qemu_exit_handle = qemu_exit::X86::new(io_base, custom_exit_success);

qemu_exit_handle.exit(1337);
qemu_exit_handle.exit_success();
qemu_exit_handle.exit_failure();

Architecture Specific Configuration

AArch64

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

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

RISCV64

You need to chose a machine with the sifive_test device, for exemple -M virt:

qemu-system-riscv64 -M virt -nographic -monitor none -serial stdio -kernel kernel.elf

x86_64

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

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

When instantiating the handle, iobase must be given as the first parameter.

The second parameter must be an EXIT_SUCCESS code of your choice that is an odd number, aka bit number zero must be 1. This is needed because in QEMU, the provided code is internally binary-OR'ed with 0x1. This is hardcoded and therefore, with isa-debug-exit, it is not possible to let QEMU invoke exit(0).

let qemu_exit_handle = qemu_exit::X86::new(io_base, custom_exit_success);

Literature

Authors

License

Licensed under either of

at your option.

See the THIRD_PARTY_NOTICES.md for more information about utilized third party projects and their respective licenses.

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.

qemu-exit's People

Contributors

alilee avatar andre-richter avatar skallwar avatar toku-sa-n avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.