fix(v4): the final review's four defects in the ROM boot
- The boot left the source's last new line in the console input, and the first KEY after the boot read it. What the ROM has not read when it starts the system is taken back (boot.c, rom_harness.h). hosted-check: KEY after the boot reads the key typed. - A comment or macro left open at the end of a blob ran on into the next, and the ROM accepted source text.c refuses. The loader ends each blob with FS (V4_ROM_BLOB_END) after its new line; the ROM ends a blob there as text.c ends a file: an open comment or macro is an error, and the word being assembled ends. test_host_rom_asm: seven blob pairs against text.c. - store to an address outside RAM faulted the ROM with no message. It is now refused, as text.c refuses it: ERR-RANGE, "address out of range". - The kernel build did not regenerate capsules/v4/sys/map-<w>.f18 before packing the capsule directory; it now does. ROM: 2084 words, rom_hash 0x4c458c6e48b35456. dict_hash unchanged, 0xe5a57f3eb72ff94a. make -C v4 test test-32 hosted-check pass. QEMU: amd64, aarch64, riscv64 to ok>, POST 538/538, POST: PASSED. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
a73580e949
commit
ff75e69e91
+11
-5
@@ -454,7 +454,7 @@ static const char *const rom_errors[] = {
|
||||
"FOR ... UNEXT must fit one instruction word and hold no literal", "not something to branch to",
|
||||
"never defined", "number does not fit a cell", "& needs a word that is already defined",
|
||||
"write the number, not @p", "a name, a target, a value or a string is missing", "macros nested too deep",
|
||||
"too many unresolved branches", "not a value", "the source ended with no start", "start of something not a word",
|
||||
"too many unresolved branches", "not a value", "the source ended with no start", "start of something not a word", "address out of range",
|
||||
};
|
||||
#define ROM_ERRORS (sizeof rom_errors / sizeof rom_errors[0])
|
||||
|
||||
@@ -474,8 +474,11 @@ static uint64_t rom_hash(void)
|
||||
|
||||
/* The machine starts in its ROM, and the boot is its console: it feeds the
|
||||
* system's source to the console a blob at a time, each found and checked
|
||||
* as any capsule is, with a new line after each, and then EOT, until the
|
||||
* ROM has assembled the system and started it. Then the node is where the
|
||||
* as any capsule is, with a new line and V4_ROM_BLOB_END after each (where
|
||||
* the ROM ends a blob as text.c ends a file), and then EOT, until the ROM
|
||||
* has assembled the system and started it. What the ROM had not read of
|
||||
* the source when it started the system is the source's, not the system's
|
||||
* console input, and is taken back. Then the node is where the
|
||||
* system waits for a message, and its host reads from the image record
|
||||
* what only the system knows (v4_image_from_node). If the ROM stops on an
|
||||
* error, the blob and line are said, and what the error is. */
|
||||
@@ -483,7 +486,7 @@ static int load_system(const v4_boot *b)
|
||||
{
|
||||
static const uint8_t *payload[SYSTEM_BLOBS];
|
||||
static uint32_t length[SYSTEM_BLOBS], first_line[SYSTEM_BLOBS];
|
||||
static const char newline = '\n', eot = EOT;
|
||||
static const char blob_end[2] = { '\n', V4_ROM_BLOB_END }, eot = EOT;
|
||||
v4_node *n = b->n;
|
||||
uint64_t steps = 0;
|
||||
uint32_t lines = 0, at = 0;
|
||||
@@ -513,7 +516,8 @@ static int load_system(const v4_boot *b)
|
||||
if (blob < SYSTEM_BLOBS && at < length[blob]) {
|
||||
at += v4_node_console_feed(n, payload[blob] + at, length[blob] - at);
|
||||
} else if (blob < SYSTEM_BLOBS) {
|
||||
if (v4_node_console_feed(n, &newline, 1)) { blob++; at = 0; }
|
||||
at += v4_node_console_feed(n, blob_end + (at - length[blob]), length[blob] + 2u - at);
|
||||
if (at == length[blob] + 2u) { blob++; at = 0; }
|
||||
} else if (v4_node_console_feed(n, &eot, 1)) {
|
||||
fed_all = 1;
|
||||
}
|
||||
@@ -534,6 +538,8 @@ static int load_system(const v4_boot *b)
|
||||
}
|
||||
}
|
||||
|
||||
n->input_pos = n->input_len = 0;
|
||||
|
||||
say(b, "PARITY:V4_ROM words="); say_dec(b, BOOT_ROM_WORDS);
|
||||
say(b, " rom_hash="); say_hex(b, rom_hash());
|
||||
say(b, " instructions="); say_dec(b, (uint32_t)b->es->anticlock);
|
||||
|
||||
Reference in New Issue
Block a user