summaryrefslogtreecommitdiff
path: root/src/pardes.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/pardes.zig')
-rw-r--r--src/pardes.zig79
1 files changed, 59 insertions, 20 deletions
diff --git a/src/pardes.zig b/src/pardes.zig
index 9f20e0a3..4da64c3f 100644
--- a/src/pardes.zig
+++ b/src/pardes.zig
@@ -2418,6 +2418,64 @@ comptime {
/// syntax, terminal ANSI palettes, and PDF tint colors deliberately are not
/// here: those switch to `theme()` immediately while this small palette moves
/// between themes over a handful of display frames.
+/// WHAT THE BOARD BOOTS WITH. An empty buffer is honest and useless: the three words that make
+/// this board interesting take an address, and a board's address space is precisely the thing you
+/// cannot guess. So the buffer is a tour of it - every address below comes from this repository
+/// rather than from memory, which is why they are worth trusting: the two flash figures and the two
+/// RAM ones are the linker script's own ORIGINs (`05-zig-p4/build.zig`'s MEMORY block), and the
+/// peripheral bases are `DR_REG_*` from ESP-IDF's headers as `05-zig-p4/src/hal` uses them.
+///
+/// Each command sits alone on its line because an argument list ends at the last argument - a
+/// trailing comment would be `ExtraArgument` - so the notes go above the lines they describe. Run
+/// one by putting the cursor on it, `x` to select the line, Tab to execute.
+///
+/// EVERY LINE IS SHORT ENOUGH TO RENDER WHOLE, which is asserted rather than eyeballed: see the
+/// test below. A tour whose lines wrap is a worse first screen than no tour.
+const boot_buffer =
+ \\x selects a line, Tab runs it. 0x optional.
+ \\
+ \\-- flash: this image's rodata, then its code
+ \\Hexdump 40000020 40
+ \\Hexdump 40050000 40
+ \\-- L2MEM: firmware data, then the heap
+ \\Hexdump 4ff00000 40
+ \\Hexdump 4ff40000 40
+ \\-- the mask ROM
+ \\Hexdump 4fc00000 20
+ \\-- UART0, the console you are reading on
+ \\Peek 500ca000 4
+ \\-- LP_STORE0: write a word, read it back
+ \\Poke 5011002c deadbeef
+ \\Peek 5011002c
+ \\-- RNG_DATA: not memory. Run it twice.
+ \\Peek 501101a4
+ \\Peek 501101a4
+ \\-- the pins: Gpio draws JP1, Gpio 33 flips
+ \\Gpio
+ \\Gpio 33
+;
+
+// Three times in this port a line in that buffer has been one or two characters too long for the
+// board's 56-column grid, and every time it was found by reading the die's screen rather than by
+// reading the source - which is the expensive way to find a string literal's length. The bound is
+// the grid minus the line-number gutter minus a column, and the margin below it is deliberate:
+// pinning the exact gutter width would make this test a restatement of the renderer instead of a
+// statement about the text.
+test "every line of the board's boot buffer renders whole" {
+ const cols: usize = @import("pardes_config").p4_cols;
+ var it = std.mem.splitScalar(u8, boot_buffer, '\n');
+ while (it.next()) |line| {
+ std.testing.expect(line.len + 8 <= cols) catch |err| {
+ std.debug.print("boot buffer line is {d} of {d} usable: \"{s}\"\n", .{ line.len, cols - 8, line });
+ return err;
+ };
+ }
+ // and the tour still visits what it says it visits
+ try std.testing.expect(std.mem.indexOf(u8, boot_buffer, "Hexdump 40000020") != null);
+ try std.testing.expect(std.mem.indexOf(u8, boot_buffer, "Poke 5011002c deadbeef") != null);
+ try std.testing.expect(std.mem.indexOf(u8, boot_buffer, "\nGpio\n") != null);
+}
+
pub const ChromeTheme = struct {
tag_bg: [3]u8,
tag_fg: [3]u8,
@@ -5785,26 +5843,7 @@ pub const Pardes = struct {
// LP_SYSTEM_REG_RNG_DATA, the hardware random generator. Between them they demonstrate
// the whole point of a volatile read: one address gives back what was written and the
// other never gives the same answer twice. Both verified on this die.
- const content = try p.gpa.dupe(u8,
- \\x selects a line, Tab runs it. Hex, 0x optional.
- \\
- \\-- flash: this image's rodata, then its code
- \\Hexdump 40000020 40
- \\Hexdump 40050000 40
- \\-- L2MEM: firmware data, then the editor's heap
- \\Hexdump 4ff00000 40
- \\Hexdump 4ff40000 40
- \\-- the mask ROM
- \\Hexdump 4fc00000 20
- \\-- UART0, the console you are reading this on
- \\Peek 500ca000 4
- \\-- LP_STORE0: write a word, then read it back
- \\Poke 5011002c deadbeef
- \\Peek 5011002c
- \\-- RNG_DATA: a register is not memory. Run twice.
- \\Peek 501101a4
- \\Peek 501101a4
- );
+ const content = try p.gpa.dupe(u8, boot_buffer);
errdefer p.gpa.free(content);
_ = try output_pane.open(p, 0, "", .{ .cmd = .New }, "", content);
p.ncol = 1;