From 8ad2aed4a67bc3367668ff7422b8c3bfc61e83d0 Mon Sep 17 00:00:00 2001 From: Nipfswd Date: Wed, 1 Jul 2026 23:46:04 +0200 Subject: [PATCH 1/5] add rust toolchain for a persistant dev environment --- rust-toolchain.toml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 rust-toolchain.toml diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..deec43a --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,5 @@ +# rust-toolchain.toml +[toolchain] +channel = "nightly" +targets = ["x86_64-unknown-uefi"] +components = ["rust-src"] \ No newline at end of file From 9bf912be5a06e25b70cd965673e1ad5217f736ed Mon Sep 17 00:00:00 2001 From: Nipfswd Date: Wed, 1 Jul 2026 23:58:50 +0200 Subject: [PATCH 2/5] Fix build a bit to work over many computers --- .gitignore | 2 ++ run.sh | 43 ++++++++++++++++++++++++++++++++++--------- rust-toolchain.toml | 6 ++++-- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 7c3fd02..307d7f6 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ # Files GEMINI.md +nul +esp/NvVars \ No newline at end of file diff --git a/run.sh b/run.sh index 9e1f9f2..96473c2 100644 --- a/run.sh +++ b/run.sh @@ -1,19 +1,44 @@ -#!/bin/bash -set -e +#!/usr/bin/env bash +set -euo pipefail -echo "[build] Compiling kernel..." -cargo build --target x86_64-unknown-uefi +KERNEL_TARGET="x86_64-unknown-uefi" +USERLAND_TARGET="x86_64-unknown-none" +TARGETS=( + "$KERNEL_TARGET" + "$USERLAND_TARGET" +) +EFI_NAME="mana_os.efi" -echo "[build] Setting up ESP..." +if ! command -v rustup >/dev/null 2>&1; then + echo "[ERROR] rustup is required for reproducible target setup!!" + exit 1 +fi + +for TARGET in "${TARGETS[@]}"; do + if ! rustup target list --installed | grep -qx "$TARGET"; then + echo "[SETUP] Installing RUST target: $TARGET" + rustup target add "$TARGET" + fi +done + +echo "[BUILD] Compiling the KERNEL..." +cargo build --target "$KERNEL_TARGET" + +echo "[BUILD] Setting up ESP..." mkdir -p esp/EFI/BOOT -cp target/x86_64-unknown-uefi/debug/mana_os.efi esp/EFI/BOOT/BOOTX64.EFI +cp "target/$KERNEL_TARGET/debug/$EFI_NAME" esp/EFI/BOOT/BOOTX64.EFI if [ ! -f disk.img ]; then - echo "[build] Creating disk.img..." + echo "[BUILD] Creating disk.img..." dd if=/dev/zero of=disk.img bs=1M count=64 fi -echo "[run] Starting QEMU..." +if [ ! -f OVMF.fd ]; then + echo "[ERROR] Missing OVMF.fd. Install/copy OVMF firmware into the repo root." + exit 1 +fi + +echo "[RUN] Starting QEMU..." qemu-system-x86_64 \ -display gtk,zoom-to-fit=on \ -drive if=pflash,format=raw,readonly=on,file=OVMF.fd \ @@ -21,4 +46,4 @@ qemu-system-x86_64 \ -drive file=disk.img,if=none,id=drive0,format=raw \ -device ahci,id=ahci0 \ -device ide-hd,drive=drive0,bus=ahci0.0 \ - -serial stdio + -serial stdio \ No newline at end of file diff --git a/rust-toolchain.toml b/rust-toolchain.toml index deec43a..79384b6 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,5 +1,7 @@ -# rust-toolchain.toml [toolchain] channel = "nightly" -targets = ["x86_64-unknown-uefi"] +targets = [ + "x86_64-unknown-uefi", + "x86_64-unknown-none", +] components = ["rust-src"] \ No newline at end of file From dbbf194083ac0b0ec7f8ac3bb8343bbe04bcfef1 Mon Sep 17 00:00:00 2001 From: Nipfswd Date: Thu, 2 Jul 2026 00:07:08 +0200 Subject: [PATCH 3/5] __cpuid called without unsafe, core::arch::x86_64::__cpuid is an unsafe fn. --- src/arch/x86_64/cpu.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/arch/x86_64/cpu.rs b/src/arch/x86_64/cpu.rs index cd14650..54f47f3 100644 --- a/src/arch/x86_64/cpu.rs +++ b/src/arch/x86_64/cpu.rs @@ -38,7 +38,8 @@ impl SyscallEntryAddress { /// Check if the CPU supports APIC. #[allow(dead_code)] pub fn has_apic() -> bool { - let cpuid = core::arch::x86_64::__cpuid(1); + // SAFETY, CPUID leaf 1 is available on all AMD64 CPUs. + let cpuid = unsafe { core::arch::x86_64::__cpuid(1) }; (cpuid.edx & (1 << 9)) != 0 } From 7fd9fdbd6f97c6619701dc22bb3220028f501f26 Mon Sep 17 00:00:00 2001 From: Noah Juopperi <166116811+Nipfswd@users.noreply.github.com> Date: Thu, 2 Jul 2026 16:18:37 +0200 Subject: [PATCH 4/5] Revert changes to cpu.rs --- src/arch/x86_64/cpu.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/arch/x86_64/cpu.rs b/src/arch/x86_64/cpu.rs index 54f47f3..cd14650 100644 --- a/src/arch/x86_64/cpu.rs +++ b/src/arch/x86_64/cpu.rs @@ -38,8 +38,7 @@ impl SyscallEntryAddress { /// Check if the CPU supports APIC. #[allow(dead_code)] pub fn has_apic() -> bool { - // SAFETY, CPUID leaf 1 is available on all AMD64 CPUs. - let cpuid = unsafe { core::arch::x86_64::__cpuid(1) }; + let cpuid = core::arch::x86_64::__cpuid(1); (cpuid.edx & (1 << 9)) != 0 } From 8f7339c3e6046804dee9d8ed36564974afd348ab Mon Sep 17 00:00:00 2001 From: ReaQwQ <152592769+ReaQwQ@users.noreply.github.com> Date: Fri, 3 Jul 2026 15:02:52 +0900 Subject: [PATCH 5/5] Update .gitignore to include 'null' and remove 'nul' Remove 'nul' and add 'null' to .gitignore --- .gitignore | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 307d7f6..11f8f88 100644 --- a/.gitignore +++ b/.gitignore @@ -15,5 +15,6 @@ # Files GEMINI.md -nul -esp/NvVars \ No newline at end of file +nul +null +esp/NvVars