Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/patches/cbf9f69cb4fd7296 # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers ## GitHub aien-dev/aienux#5 (code only) closed derived `cbf9f69cb4fd7296` #5 Imported from GitHub aien-dev/aienux#5 (code only) GitHub's metadata for this pull request is unavailable: its state is DERIVED from the commits (merged: the head is reachable from this project's main; open: GitHub kept a merge ref; else closed). Base `f9e55d3f2e67533fd17826f19381589856dcd92d` · Head `70480f3c2807e647643f154866c5ae61e4b22c3b` ### Apply it ``` git checkout -b patch-cbf9f69cb4fd7296 f9e55d3f2e67533fd17826f19381589856dcd92d curl -fsSL https://interplane.io/drakestapleton/aienux/patches/cbf9f69cb4fd7296.patch | git am ``` Raw patch (mbox) · Diff ### Provenance This proposal is imported from GitHub; it is not signed by its author. Its import statement and source record: ``` github-import 1 aien-dev/aienux 5 70480f3c2807e647643f154866c5ae61e4b22c3b ``` ``` {"kind":"github-import","owner":"aien-dev","repo":"aienux","number":5,"url":"https://github.com/aien-dev/aienux/pull/5","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:36Z","metadata":"unavailable","state_derived":true} ``` ### Changes ``` diff --git a/Cargo.lock b/Cargo.lock index 25de2299..bba4ae3e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -27,6 +27,7 @@ dependencies = [ name = "aienos-boot" version = "0.1.0" dependencies = [ + "aienos-kernel", "uefi", ] diff --git a/README.md b/README.md index 0e99bedc..2ac4517f 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ An optional compatibility island (for example, Linux with vendor drivers) may si Power on, AIENOS boots directly on the NVIDIA DGX Spark (no Linux host), the AIEN agent starts on a local console, a local model loads, you talk to it, and its state persists across reboot. CPU inference is acceptable for this milestone. -The current UEFI image is a firmware-entry diagnostic. It prints a banner and returns to firmware. It does not yet transfer control to the native kernel, load a model, or meet this milestone. The host verification script checks its AArch64 EFI image format without changing the host boot configuration. +Two UEFI images are available. The default diagnostic prints a banner and returns to firmware. The separate handoff image exits UEFI boot services, counts conventional-memory pages, enters the early kernel UART path, and halts. Neither image has been booted on the DGX Spark. The handoff does not yet initialize the frame allocator, mount storage, recover agent state, or load a model, so this milestone remains open. Host verification checks their AArch64 EFI image format without changing the boot configuration. ## Principles diff --git a/crates/aienos-boot/Cargo.toml b/crates/aienos-boot/Cargo.toml index 39b823af..55d8665a 100644 --- a/crates/aienos-boot/Cargo.toml +++ b/crates/aienos-boot/Cargo.toml @@ -10,11 +10,18 @@ description = "AArch64 UEFI entry diagnostic for AIENOS native boot bring-up" [features] default = [] firmware = ["dep:uefi"] +handoff = ["firmware", "dep:aienos-kernel"] [dependencies] uefi = { version = "0.41", default-features = false, features = ["panic_handler"], optional = true } +aienos-kernel = { path = "../aienos-kernel", default-features = false, optional = true } [[bin]] name = "aienos-boot" path = "src/main.rs" required-features = ["firmware"] + +[[bin]] +name = "aienos-handoff" +path = "src/handoff.rs" +required-features = ["handoff"] diff --git a/crates/aienos-boot/src/handoff.rs b/crates/aienos-boot/src/handoff.rs new file mode 100644 index 00000000..74253465 --- /dev/null +++ b/crates/aienos-boot/src/handoff.rs @@ -0,0 +1,24 @@ +#![no_std] +#![no_main] + +use uefi::mem::memory_map::{MemoryMap, MemoryType}; +use uefi::prelude::*; + +/// Explicit native handoff image. Building it does not install or boot it. +#[entry] +fn main() -> Status { + uefi::println!("AIENOS: exiting firmware boot services"); + + // No UEFI protocol, allocator, console, or boot-service reference is used + // after this point. The returned map owns its backing allocation and stays + // live while the early kernel path executes. + let memory_map = unsafe { uefi::boot::exit_boot_services(None) }; + let conventional_pages = memory_map + .entries() + .filter(|descriptor| descriptor.ty == MemoryType::CONVENTIONAL) + .fold(0u64, |total, descriptor| { + total.saturating_add(descriptor.page_count) + }); + + aienos_kernel::boot::early_kernel_init(conventional_pages.saturating_mul(4)) +} diff --git a/crates/aienos-kernel/src/arch/aarch64.rs b/crates/aienos-kernel/src/arch/aarch64.rs index 6709ad45..00af5cc3 100644 --- a/crates/aienos-kernel/src/arch/aarch64.rs +++ b/crates/aienos-kernel/src/arch/aarch64.rs @@ -202,6 +202,23 @@ impl EarlyUart { } } + /// Write an unsigned decimal number without heap allocation. + pub fn write_u64(&self, mut value: u64) { + let mut digits = [0u8; 20]; + let mut start = digits.len(); + loop { + start -= 1; + digits[start] = b'0' + (value % 10) as u8; + value /= 10; + if value == 0 { + break; + } + } + for digit in &digits[start..] { + self.write_byte(*digit); + } + } + /// Attempt to read a single byte from UART receive FIFO without blocking. /// Returns None if receive FIFO is empty (RXFE == 1). pub fn try_read_byte(&self) -> Option { diff --git a/crates/aienos-kernel/src/boot.rs b/crates/aienos-kernel/src/boot.rs index 3aceb0e5..9fa46e16 100644 --- a/crates/aienos-kernel/src/boot.rs +++ b/crates/aienos-kernel/src/boot.rs @@ -1,7 +1,6 @@ //! AIENOS Bare-Metal Boot Spine (§Step 2 of Systems Integration Sequence). //! -//! Provides the canonical reset vector / UEFI entry point `_start`, -//! the unadorned console banner, and the structured BootReceipt definition. +//! Provides the bare-metal entry path, early serial banner, and BootReceipt. use crate::arch::aarch64::{ current_el, disable_interrupts, dsb, halt, isb, EarlyUart, SPARK_16550_UART_BASE, @@ -36,7 +35,7 @@ impl BootReceipt { } /// Early kernel boot initialization executed directly from UEFI or reset vector. -pub fn early_kernel_init() -> ! { +pub fn early_kernel_init(conventional_memory_kb: u64) -> ! { // 1. Disable maskable interrupts disable_interrupts(); @@ -50,6 +49,9 @@ pub fn early_kernel_init() -> ! { uart.write_str("\nAIENOS\n"); uart.write_str("arch: aarch64\n"); uart.write_str("boot: native\n"); + uart.write_str("conventional_memory_kb: "); + uart.write_u64(conventional_memory_kb); + uart.write_str("\n"); let el = current_el(); uart.write_str("exception_level: EL"); @@ -64,8 +66,8 @@ pub fn early_kernel_init() -> ! { } /// Canonical bare-metal entry point when compiling for `#![no_std]` targets. -#[cfg(all(not(feature = "std"), not(test)))] +#[cfg(all(target_os = "none", not(feature = "std"), not(test)))] #[no_mangle] pub unsafe extern "C" fn _start() -> ! { - early_kernel_init(); + early_kernel_init(0); } diff --git a/crates/aienos-kernel/src/lib.rs b/crates/aienos-kernel/src/lib.rs index 7714e819..89bdfa9b 100644 --- a/crates/aienos-kernel/src/lib.rs +++ b/crates/aienos-kernel/src/lib.rs @@ -16,7 +16,7 @@ pub mod recovery; pub mod store; pub mod sync; -#[cfg(all(not(feature = "std"), not(test)))] +#[cfg(all(target_os = "none", not(feature = "std"), not(test)))] #[panic_handler] fn panic(_info: &core::panic::PanicInfo) -> ! { arch::aarch64::halt(); diff --git a/scripts/verify_all.sh b/scripts/verify_all.sh index 13ab956c..0705fcf5 100755 --- a/scripts/verify_all.sh +++ b/scripts/verify_all.sh @@ -41,14 +41,16 @@ cargo build -p aienos-kernel --target aarch64-unknown-none --no-default-features # Step 5: Build an AArch64 UEFI diagnostic image and inspect its PE header. # This verifies the firmware entry artifact format, not a hardware boot. echo "" -echo "--- [AArch64 UEFI Diagnostic Image Build] ---" -cargo build -p aienos-boot --target aarch64-unknown-uefi --features firmware --bin aienos-boot -python3 scripts/verify_uefi_image.py target/aarch64-unknown-uefi/debug/aienos-boot.efi +echo "--- [AArch64 UEFI Image Builds] ---" +cargo build --release -p aienos-boot --target aarch64-unknown-uefi --features firmware --bin aienos-boot +python3 scripts/verify_uefi_image.py target/aarch64-unknown-uefi/release/aienos-boot.efi +cargo build --release -p aienos-boot --target aarch64-unknown-uefi --features handoff --bin aienos-handoff +python3 scripts/verify_uefi_image.py target/aarch64-unknown-uefi/release/aienos-handoff.efi echo "" echo "============================================================" echo "HOST VERIFICATIONS PASSED." echo "Config A: observed capture and three local inference samples verified." echo "Kernel: aarch64-unknown-none library compiles. Native boot remains untested." -echo "UEFI: AArch64 EFI application builds; kernel handoff remains unimplemented." +echo "UEFI: diagnostic and ExitBootServices handoff images build; hardware boot remains untested." echo "============================================================" ```