From 11f380f6d7222f2cad93c2cdf13701ea1f903d47 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 26 Aug 2026 13:27:46 -0300 Subject: One core behind N frontends, the board's own runner moved in, and every board cap on one screen MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## The wire is the effect stream, not a new protocol `pardes --detach` leaves a core running with no terminal; `pardes --attach` is a frontend that owns a terminal and a socket and nothing else. N frontends on one core all look at the same screen — `screen -x`, not N sessions. The codec (`src/detached/wire.zig`) carries exactly one `Event` or one `Host.VTable` call per message. That is not a coincidence and it is why there is no third vocabulary to keep in step: the core's IO seam was already a struct of function pointers with plain-data arguments, so a socket is a legal implementation of it. `nested.zig`'s socket could not be reused — it carries a builtin command line, and a command line cannot carry a frame. ARCHITECTURE-NEUTRAL on purpose, not as decoration. The frontend on the far end may be riscv32-freestanding on the ESP32-P4 while the core is x86_64 Linux, so every field is an explicit little-endian fixed width and no message is a blit of a native struct. A protocol that only works between two builds of the same compiler would have thrown away the one frontend that motivated it. ## The board comes in; its toolchain stays out `src/p4.zig` becomes `src/esp32p4.zig`, and the pardes half of `../05-zig-p4` — the vaxis-over- serial runner, the UART editor terminal, the keystroke rescue ring, the on-die test suite — moves into `src/esp32p4/`. `build.zig.zon` gains `.zig_p4 = .{ .path = "../05-zig-p4" }`, so `zig build -Dplatform=esp32p4 -Desp32p4-firmware` builds, flashes, monitors and self-tests the board from this repo's `build.zig`. The DIVISION is the point. What moved is what only pardes wants: the runner that drives a pardes core over a serial line. What stayed is everything a second project would also want — the HAL, the register/radio/oracle layers, the linker script, `_start`. `zig_p4` declares no dependencies of its own and its `build()` early-returns when it is not the root package, so this costs the package graph exactly zero packages and the editor's own builds nothing at all. ## limits.zig: nine forgettable places become one budget Nine `platform == .esp32p4` capacity tests lived in nine files. They were never nine decisions — they are ONE decision, how much memory this build may spend, taken nine times where no reader could see the total. `src/limits.zig` puts the whole budget on one screen with every cap named against what it is measured against, derived from two booleans. The payoff is testability on a machine that is not the board: the caps are ordinary comptime values, so a host build can be compiled against the board's numbers and the parking, eviction and clamping paths a 240 KiB core takes get exercised by the normal test suite instead of only over a UART. ## A bare `zig build` `zig build` with no arguments now builds the tty and GUI binaries and installs them into `~/.local/bin`, and says so once on stdout with the flag that overrides it. The old default built one binary into `zig-out` — a path nothing on a `PATH` ever looks at, which made "build it" and "use it" two different commands for no reason. --- src/board_memory.zig | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) (limited to 'src/board_memory.zig') diff --git a/src/board_memory.zig b/src/board_memory.zig index 79a9a2cf..ac567b34 100644 --- a/src/board_memory.zig +++ b/src/board_memory.zig @@ -7,7 +7,7 @@ //! some of them would be lying about where it is running. Under an OS the same words would be either //! a segfault or a syscall stub, so they are absent from those builds entirely rather than present //! and refusing. Absent means not compiled, not hidden: nothing below is analysed for a build whose -//! platform is not `p4`. +//! platform is not `esp32p4`. //! //! Everything here goes through `*allowzero volatile` pointers. A peripheral //! register is not memory: reading UART_STATUS twice is two reads and must not @@ -24,8 +24,9 @@ const builtin = @import("builtin"); const pardes = @import("pardes.zig"); const Pardes = pardes.Pardes; const output_pane = @import("output_pane.zig"); +const limits = @import("limits.zig"); -/// THE ONE GATE, and it names the p4 build, so `Peek`, `Poke`, `Hexdump` and `Gpio` are analysed +/// THE ONE GATE, and it names the esp32p4 build, so `Peek`, `Poke`, `Hexdump` and `Gpio` are analysed /// and emitted for that build and for no other. Nothing in this file reaches any other target's /// binary: not the volatile accessors, not the JP1 pinout, not the parsers. /// @@ -41,11 +42,11 @@ const output_pane = @import("output_pane.zig"); /// The old predicate's real work was excluding wasm, which is `freestanding` too - inside the /// browser's sandbox an address is an offset into a linear memory the engine owns, so a `Peek` /// would read a number that means nothing about any machine and a `Poke` would corrupt the heap -/// this same editor runs out of. Naming `p4` excludes it by construction rather than by a term +/// this same editor runs out of. Naming `esp32p4` excludes it by construction rather than by a term /// somebody has to keep remembering. -pub const enabled = pardes.platform == .p4; +pub const enabled = pardes.platform == .esp32p4; -// The target is now the WITNESS rather than the gate: whatever else `p4` means, it has to still be +// The target is now the WITNESS rather than the gate: whatever else `esp32p4` means, it has to still be // a machine whose addresses are the bus's, and a hosted or wasm build reaching this line means the // platform and the target disagree about what the firmware is. comptime { @@ -261,7 +262,7 @@ test "every literal is hex, with or without the prefix" { // grid the board is actually built with, and the alignment is asserted against the column the pin // numbers are supposed to share. test "the pinout fits the board's own grid, in two aligned columns" { - const cols: usize = @import("pardes_config").p4_cols; + const cols: usize = @import("pardes_config").esp32p4_cols; // Seven columns of the shell's grid go to the line-number gutter before a pane's text starts. const usable = cols - 7; @@ -427,23 +428,10 @@ pub fn gpio(p: *Pardes, id: usize, argument: []const u8) !void { p.setMessage(id, std.fmt.bufPrint(&buf, "GPIO {d}: {d}->{d}", .{ pin, was, now }) catch unreachable); } -/// Bytes per dumped row, and it is a different number on the board. -/// -/// `hexdump -C`'s sixteen is the layout everyone can already read, and it needs 79 columns: ten for -/// the address, forty-eight for the hex, a gap, and the eighteen-column ASCII gutter. The P4 drives -/// a 56-column grid of which seven go to the line-number gutter, so a sixteen-byte row wraps onto a -/// second display line and the columns stop lining up - which is the entire value of the layout. -/// -/// Eight fits in 46 and keeps every property that matters: address on the left, fixed-width hex -/// columns, ASCII on the right, and a gap at the halfway mark because the eye counts in fours and -/// eights rather than in sixteens. -/// -/// NO `0x` ON WHAT THESE WORDS PRINT, which is where two of those columns came from. It reads no -/// worse - every number here is hex, there is no other kind, and the words refuse a decimal one - and -/// it buys something better than the width: an address in a dump can now be typed straight back into -/// a `Peek` without editing it, because bare hex is exactly what the parser wants. Output that is -/// valid input is worth more than a prefix restating what the whole file already says. -const row_bytes: u32 = if (pardes.platform == .p4) 8 else 16; +/// Bytes per dumped row, and it is a different number on the board — see +/// `limits.hexdump_row_bytes`, which is where that number and its reasoning +/// live now. +const row_bytes: u32 = limits.hexdump_row_bytes; /// `Hexdump [len]` — len bytes, `row_bytes` to a row, hex columns and an ASCII gutter, in /// `hexdump -C`'s layout because that is the one everyone can already read. BYTE reads, so a partial -- cgit v1.3