diff --git a/Cargo.lock b/Cargo.lock index 2e40f57..e69368e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,137 +1,53 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "array-init" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "bit_field" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "bitflags" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "cast" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "cortex-a" version = "3.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6922a40af4d1a2deac8c963b9f3e57311b8912490740234f1ad182425c547f80" dependencies = [ - "register 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "register", ] -[[package]] -name = "nodrop" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "qemu-exit" -version = "0.1.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "x86_64 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)", -] +checksum = "b73ae13954572c7ca0ec48ba9fe6a59c0392066eba62f8cb384ffd5addf538c5" [[package]] name = "r0" -version = "0.2.2" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd7a31eed1591dcbc95d92ad7161908e72f4677f8fabf2a32ca49b4237cbf211" [[package]] name = "register" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "deaba5b0e477d21f61a57504bb5cef4a1e86de30300b457d38971c1cfc98b815" dependencies = [ - "tock-registers 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tock-registers", ] [[package]] name = "rlibc" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe" [[package]] name = "tock-registers" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ux" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70323afdb8082186c0986da0e10f6e4ed103d681c921c00597e98d9806dac20f" [[package]] name = "vesper" version = "0.0.1" dependencies = [ - "cortex-a 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "qemu-exit 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "rlibc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cortex-a", + "qemu-exit", + "r0", + "rlibc", ] - -[[package]] -name = "x86_64" -version = "0.7.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "array-init 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "ux 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - -[metadata] -"checksum array-init 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "23589ecb866b460d3a0f1278834750268c607e8e28a1b982c907219f3178cd72" -"checksum bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed8765909f9009617974ab6b7d332625b320b33c326b1e9321382ef1999b5d56" -"checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" -"checksum cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" -"checksum cortex-a 3.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "6922a40af4d1a2deac8c963b9f3e57311b8912490740234f1ad182425c547f80" -"checksum nodrop 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" -"checksum qemu-exit 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "95533662c327a4b3be4203123662b7eca1c39d73d66020c52280e4ff0e9c9a41" -"checksum r0 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e2a38df5b15c8d5c7e8654189744d8e396bddc18ad48041a500ce52d6948941f" -"checksum register 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "deaba5b0e477d21f61a57504bb5cef4a1e86de30300b457d38971c1cfc98b815" -"checksum rlibc 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fc874b127765f014d792f16763a81245ab80500e2ad921ed4ee9e82481ee08fe" -"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum tock-registers 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "70323afdb8082186c0986da0e10f6e4ed103d681c921c00597e98d9806dac20f" -"checksum ux 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "88dfeb711b61ce620c0cb6fd9f8e3e678622f0c971da2a63c4b3e25e88ed012f" -"checksum x86_64 0.7.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1f27d9168654aee1b0c1b73746caeb4aa33248f8b8c8f6e100e697fcc2a794b2" diff --git a/nucleus/Cargo.toml b/nucleus/Cargo.toml index ce580a9..895ebd4 100644 --- a/nucleus/Cargo.toml +++ b/nucleus/Cargo.toml @@ -22,5 +22,5 @@ qemu = ["qemu-exit"] [dependencies] r0 = "1.0" rlibc = "1.0" -qemu-exit = { version = "0.1", optional = true } +qemu-exit = { version = "1.0", optional = true } cortex-a = "3.0" diff --git a/nucleus/src/macros.rs b/nucleus/src/macros.rs index c986bb9..7707f61 100644 --- a/nucleus/src/macros.rs +++ b/nucleus/src/macros.rs @@ -28,5 +28,5 @@ pub fn _print(_args: core::fmt::Arguments) { pub fn _print(args: core::fmt::Arguments) { use crate::{qemu, write_to}; let mut buf = [0u8; 512]; - qemu::semihosting_sys_write0_call(write_to::c_show(&mut buf, args).unwrap()); + qemu::semihosting::sys_write0_call(write_to::c_show(&mut buf, args).unwrap()); } diff --git a/nucleus/src/qemu.rs b/nucleus/src/qemu.rs index 0612d81..d8ff082 100644 --- a/nucleus/src/qemu.rs +++ b/nucleus/src/qemu.rs @@ -1,11 +1,22 @@ -#[cfg(test)] -pub fn semihosting_sys_write0_call(text: &str) { - // SAFETY: text must be \0-terminated! - unsafe { - asm!( +pub mod semihosting { + pub fn exit_success() { + use qemu_exit::QEMUExit; + + #[cfg(target_arch = "aarch64")] + let qemu_exit_handle = qemu_exit::AArch64::new(); + + qemu_exit_handle.exit_success(); + } + + #[cfg(test)] + pub fn sys_write0_call(text: &str) { + // SAFETY: text must be \0-terminated! + unsafe { + asm!( "mov w0, #0x04 hlt #0xF000" - , in("x1") text.as_ptr() as u64 - ); + , in("x1") text.as_ptr() as u64 + ); + } } } diff --git a/nucleus/src/tests.rs b/nucleus/src/tests.rs index cae6ed9..56e9400 100644 --- a/nucleus/src/tests.rs +++ b/nucleus/src/tests.rs @@ -1,7 +1,7 @@ //============================================================================ // Testing environment //============================================================================ -use crate::println; +use crate::{println, qemu}; #[cfg(test)] pub fn test_runner(tests: &[&dyn Fn()]) { @@ -10,5 +10,5 @@ pub fn test_runner(tests: &[&dyn Fn()]) { test(); } println!("[success]"); - qemu_exit::aarch64::exit_success(); + qemu::semihosting::exit_success(); }