From 28a0b5e6e18cb483e523fd352e65e7648f032d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 23 Aug 2023 16:33:26 +0200 Subject: [PATCH 1/5] fix: only export print, println and dbg for bare-metal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- src/macros.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/macros.rs b/src/macros.rs index 197ebb635f..5658b709ad 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -3,6 +3,7 @@ /// Adapted from [`std::print`]. /// /// [`std::print`]: https://doc.rust-lang.org/stable/std/macro.print.html +#[cfg(target_os = "none")] #[macro_export] macro_rules! print { ($($arg:tt)*) => {{ @@ -15,6 +16,7 @@ macro_rules! print { /// Adapted from [`std::println`]. /// /// [`std::println`]: https://doc.rust-lang.org/stable/std/macro.println.html +#[cfg(target_os = "none")] #[macro_export] macro_rules! println { () => { @@ -28,6 +30,7 @@ macro_rules! println { /// Prints and returns the value of a given expression for quick and dirty /// debugging. // Copied from std/macros.rs +#[cfg(target_os = "none")] #[macro_export] macro_rules! dbg { // NOTE: We cannot use `concat!` to make a static string as a format argument From 267d435ce309d70c8b1966278bd975b89588546f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 23 Aug 2023 16:36:34 +0200 Subject: [PATCH 2/5] fix(aarch64): include start assembly only on bare-metal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- src/arch/aarch64/kernel/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/arch/aarch64/kernel/mod.rs b/src/arch/aarch64/kernel/mod.rs index fc409ca975..19ecf8629f 100644 --- a/src/arch/aarch64/kernel/mod.rs +++ b/src/arch/aarch64/kernel/mod.rs @@ -34,6 +34,7 @@ pub(crate) static CPU_ONLINE: AtomicU32 = AtomicU32::new(0); pub(crate) static CURRENT_STACK_ADDRESS: AtomicU64 = AtomicU64::new(0); +#[cfg(target_os = "none")] global_asm!(include_str!("start.s")); /// Kernel header to announce machine features From bda612eadcb07f9627e9cc288ecc482f08aef5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 23 Aug 2023 16:37:40 +0200 Subject: [PATCH 3/5] fix(x86_64): remove unnecessary output_message_buf and test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- src/arch/x86_64/kernel/mod.rs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/arch/x86_64/kernel/mod.rs b/src/arch/x86_64/kernel/mod.rs index 5e6d8406bc..c9c0e7900d 100644 --- a/src/arch/x86_64/kernel/mod.rs +++ b/src/arch/x86_64/kernel/mod.rs @@ -188,7 +188,6 @@ pub fn message_output_init() { *COM1.lock() = Some(serial_port); } -#[cfg(target_os = "none")] pub fn output_message_buf(buf: &[u8]) { // Output messages to the serial port and VGA screen in unikernel mode. COM1.lock().as_mut().unwrap().send(buf); @@ -201,13 +200,6 @@ pub fn output_message_buf(buf: &[u8]) { } } -#[cfg(not(target_os = "none"))] -pub fn output_message_buf(buf: &[u8]) { - use std::io::Write; - - std::io::stderr().write_all(buf).unwrap(); -} - /// Real Boot Processor initialization as soon as we have put the first Welcome message on the screen. #[cfg(target_os = "none")] pub fn boot_processor_init() { @@ -333,13 +325,3 @@ unsafe extern "C" fn pre_init(boot_info: &'static RawBootInfo, cpu_id: u32) -> ! crate::application_processor_main(); } } - -#[cfg(all(test, not(target_os = "none")))] -mod tests { - use super::*; - - #[test] - fn test_output() { - output_message_buf(b"test message\n"); - } -} From a923dddc973732b50c0e23ea044cf4990e791f42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 23 Aug 2023 16:40:08 +0200 Subject: [PATCH 4/5] ci: don't specify unit test target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index abd5abed6b..0deb7c2201 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -98,7 +98,7 @@ jobs: - uses: mkroening/rust-toolchain-toml@main - uses: Swatinem/rust-cache@v2 - name: Unit tests - run: cargo test --lib --target x86_64-unknown-linux-gnu + run: cargo test --lib env: RUSTFLAGS: -Awarnings - name: Download loader From 2710e87f852f229d8b8cfd47a56daa43c8d547ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 23 Aug 2023 16:43:16 +0200 Subject: [PATCH 5/5] fix: define entry version only on bare-metal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 41199c9452..55acdf62c5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -80,6 +80,7 @@ mod scheduler; mod synch; mod syscalls; +#[cfg(target_os = "none")] hermit_entry::define_entry_version!(); #[doc(hidden)]