interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

GitHub aien-dev/aienux#3 (code only)

closed derived 607bea624478a653 #3

Imported from GitHub aien-dev/aienux#3 (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 bc25e736933c4ff0f53de193ed2f9386381ecfdc · Head 3b36a1901c8d4830f077a8ce8824eba27ac3edf0

Apply it

git checkout -b patch-607bea624478a653 bc25e736933c4ff0f53de193ed2f9386381ecfdc
curl -fsSL https://interplane.io/drakestapleton/aienux/patches/607bea624478a653.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
3
3b36a1901c8d4830f077a8ce8824eba27ac3edf0
{"kind":"github-import","owner":"aien-dev","repo":"aienux","number":3,"url":"https://github.com/aien-dev/aienux/pull/3","export_sha256":"967c79e26a893657b5cdaa45efd442be5dbd2ecfe68e25f9a8c1b5da4d60d452","imported_utc":"2026-11-18T16:36:10Z","metadata":"unavailable","state_derived":true}

Changes

diff --git a/crates/aienos-kernel/src/arch/aarch64.rs b/crates/aienos-kernel/src/arch/aarch64.rs
index 981229de..6709ad45 100644
--- a/crates/aienos-kernel/src/arch/aarch64.rs
+++ b/crates/aienos-kernel/src/arch/aarch64.rs
@@ -153,28 +153,19 @@ pub fn halt() -> ! {
     }
 }
 
-/// Reference MMIO base address for PL011 UART on NVIDIA DGX Spark (Cortex-X925).
-pub const SPARK_PL011_UART_BASE: usize = 0x16A0_0000;
+/// Serial MMIO base observed in the DGX Spark host kernel command line.
+/// The host uses earlycon=uart,mmio32,0x16A00000, the 8250 register layout.
+pub const SPARK_16550_UART_BASE: usize = 0x16A0_0000;
 
-/// Reference MMIO base address for PL011 UART on QEMU AArch64 Virt machine.
-pub const QEMU_VIRT_PL011_UART_BASE: usize = 0x0900_0000;
-
-/// Standard PL011 UART register offsets.
-pub mod pl011_regs {
-    pub const UARTDR: usize = 0x00;
-    pub const UARTFR: usize = 0x18;
-    pub const UARTIBRD: usize = 0x24;
-    pub const UARTFBRD: usize = 0x28;
-    pub const UARTLCR_H: usize = 0x2C;
-    pub const UARTCR: usize = 0x30;
-    pub const UARTIMSC: usize = 0x38;
-
-    pub const FR_BUSY: u32 = 1 << 3;
-    pub const FR_TXFF: u32 = 1 << 5;
-    pub const FR_RXFE: u32 = 1 << 4;
+/// 8250 register indices with the observed 32-bit register stride.
+pub mod uart16550_regs {
+    pub const DATA: usize = 0;
+    pub const LINE_STATUS: usize = 5 * 4;
+    pub const DATA_READY: u32 = 1;
+    pub const TX_HOLDING_EMPTY: u32 = 1 << 5;
 }
 
-/// Early boot UART driver for AArch64 bare-metal console output.
+/// Early 8250-compatible UART with 32-bit MMIO registers.
 pub struct EarlyUart {
     base_addr: usize,
 }
@@ -192,15 +183,13 @@ impl EarlyUart {
 
     /// Send a single byte through UART transmit FIFO.
     pub fn write_byte(&self, b: u8) {
-        let fr = self.reg(pl011_regs::UARTFR);
-        let dr = self.reg(pl011_regs::UARTDR);
+        let status = self.reg(uart16550_regs::LINE_STATUS);
+        let data = self.reg(uart16550_regs::DATA);
 
-        // Wait until transmit FIFO has space (TXFF == 0)
-        while (fr.read() & pl011_regs::FR_TXFF) != 0 {
+        while (status.read() & uart16550_regs::TX_HOLDING_EMPTY) == 0 {
             core::hint::spin_loop();
         }
-
-        dr.write(b as u32);
+        data.write(b as u32);
     }
 
     /// Transmit a UTF-8 string through UART.
@@ -216,13 +205,11 @@ impl EarlyUart {
     /// 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<u8> {
-        let fr = self.reg(pl011_regs::UARTFR);
-        if (fr.read() & pl011_regs::FR_RXFE) != 0 {
-            None
-        } else {
-            let dr = self.reg(pl011_regs::UARTDR);
-            Some((dr.read() & 0xFF) as u8)
+        let status = self.reg(uart16550_regs::LINE_STATUS);
+        if (status.read() & uart16550_regs::DATA_READY) == 0 {
+            return None;
         }
+        Some((self.reg(uart16550_regs::DATA).read() & 0xFF) as u8)
     }
 
     /// Read a single byte from UART, blocking until data arrives.
@@ -235,3 +222,21 @@ impl EarlyUart {
         }
     }
 }
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn spark_uart_uses_32_bit_16550_register_stride() {
+        let mut registers = [0u32; 8];
+        registers[5] = uart16550_regs::TX_HOLDING_EMPTY;
+        let uart = EarlyUart::new(registers.as_mut_ptr() as usize);
+        uart.write_byte(b'A');
+        assert_eq!(registers[0], b'A' as u32);
+        assert_eq!(uart.try_read_byte(), None);
+        MmioReg::new(registers.as_mut_ptr() as usize + uart16550_regs::LINE_STATUS)
+            .write(uart16550_regs::TX_HOLDING_EMPTY | uart16550_regs::DATA_READY);
+        assert_eq!(uart.try_read_byte(), Some(b'A'));
+    }
+}
diff --git a/crates/aienos-kernel/src/boot.rs b/crates/aienos-kernel/src/boot.rs
index d9c03f33..3aceb0e5 100644
--- a/crates/aienos-kernel/src/boot.rs
+++ b/crates/aienos-kernel/src/boot.rs
@@ -4,7 +4,7 @@
 //! the unadorned console banner, and the structured BootReceipt definition.
 
 use crate::arch::aarch64::{
-    current_el, disable_interrupts, dsb, halt, isb, EarlyUart, SPARK_PL011_UART_BASE,
+    current_el, disable_interrupts, dsb, halt, isb, EarlyUart, SPARK_16550_UART_BASE,
 };
 
 /// Deterministic, immutable boot receipt emitted by the native boot spine.
@@ -46,18 +46,18 @@ pub fn early_kernel_init() -> ! {
 
     // 3. Early console UART output on DGX Spark MMIO (0x16A00000)
     // Strictly unadorned console telemetry per Gate 2 specification
-    let uart = EarlyUart::new(SPARK_PL011_UART_BASE);
-    uart.write_str("\r\nAIENOS\r\n");
-    uart.write_str("arch: aarch64\r\n");
-    uart.write_str("boot: native\r\n");
+    let uart = EarlyUart::new(SPARK_16550_UART_BASE);
+    uart.write_str("\nAIENOS\n");
+    uart.write_str("arch: aarch64\n");
+    uart.write_str("boot: native\n");
 
     let el = current_el();
     uart.write_str("exception_level: EL");
     uart.write_byte(b'0' + el);
-    uart.write_str("\r\n");
+    uart.write_str("\n");
 
-    uart.write_str("kernel: alive\r\n");
-    uart.write_str("halt: clean\r\n");
+    uart.write_str("kernel: alive\n");
+    uart.write_str("halt: clean\n");
 
     // 4. Deterministic non-model halt loop
     halt();