B4: the disk remembers whether the last start arrived
The loader marks the superblock before it hands over and the system clears the mark when it reaches its prompt, so a system that crashes on the way there leaves it set. The loader finding it still set next time is how a machine that will not start says so to the only thing in a position to do anything about it. Without that, pointing boot.cfg at something that dies before the shell is a machine that can never be told anything again - the shell is the only way to change the file, and the file is what stops the shell from starting. Three states rather than two, and the third is the one worth having: 0 settled the last start arrived; use the configuration 1 trying handed over, and nothing came back to say it got there 2 fell back a try failed and the fallback was used, until settled With only 0 and 1 the machine alternates for ever: fall back, reach a prompt, clear the mark, retry the broken system, crash, fall back. State 2 stops that. A system known not to start is not tried again until somebody says the situation has changed. REACHING THE PROMPT IS A DELIBERATE THRESHOLD. It is not a claim that the system works - a shell can be reached by something broken in every other way. It is the point where a person can type, which is exactly what the fallback exists to give back: anything wrong past there is fixable from the prompt and nothing wrong before it is fixable at all. The routines live in sbfs.asm because both the loader and the system read and write this byte, and two pieces of code with their own idea of where a byte lives is what this format has two implementations and a byte for byte comparison to avoid. And the trap this system documents in its own manual caught me anyway: the first version handed the state back in A, which CALL restores, so every read got whatever the caller happened to be holding. It comes back in memory now, and the comment says why. Three disks differing only in the state on them, so the tests read as three consecutive starts of one machine while none depends on another running.
This commit is contained in:
+24
-1
@@ -53,7 +53,8 @@
|
||||
// 12 2 Free blocks, a cache rather than the authority
|
||||
// 14 2 Blocks in each boot slot, or zero for a disk that cannot be booted
|
||||
// 16 1 Which boot slot is live, 0 or 1
|
||||
// 17 Reserved to the end of the block
|
||||
// 17 1 How the last start went. See below.
|
||||
// 18 Reserved to the end of the block
|
||||
|
||||
#define SBFS_SUPER_VERSION 4
|
||||
#define SBFS_SUPER_DISK 6
|
||||
@@ -86,6 +87,28 @@
|
||||
// 1 .. bootBlocks slot 0
|
||||
// bootBlocks+1 .. 2*bootBlocks slot 1
|
||||
// directoryStart .. the directory, and then files
|
||||
// ---- How the last start went ----
|
||||
//
|
||||
// Written by the loader before it hands over and cleared by the system once it is running,
|
||||
// so that a system which never gets that far leaves a mark saying so. THE MARK IS WHAT
|
||||
// MAKES A NEW SYSTEM SAFE TO TRY: without it, pointing boot.cfg at something that crashes
|
||||
// before the prompt is a machine that cannot be told anything ever again.
|
||||
//
|
||||
// What clears it is reaching the shell, and that is a deliberate choice of threshold. It
|
||||
// does not mean the system works - a shell can be reached by something that is broken in
|
||||
// every other way. It means A PERSON HAS CONTROL AGAIN, which is exactly what the fallback
|
||||
// exists to restore and therefore exactly when it has done its job.
|
||||
//
|
||||
// 0 Settled. The last start finished. Start what the configuration says.
|
||||
// 1 Trying. The loader handed over and nothing came back to say it arrived.
|
||||
// 2 Fell back. A try failed and the fallback was used instead. Stays until somebody
|
||||
// settles it, so that a system which crashes is not retried every other
|
||||
// boot for ever.
|
||||
#define SBFS_SUPER_BOOTSTATE 17
|
||||
#define SBFS_BOOT_SETTLED 0
|
||||
#define SBFS_BOOT_TRYING 1
|
||||
#define SBFS_BOOT_FELLBACK 2
|
||||
|
||||
#define SBFS_BOOT_SLOTS 2
|
||||
#define SBFS_FIRST_BOOT_BLOCK 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user