A disk made of memory, brought up by whoever owns it

THE MACHINE SUPPLIES BLOCKS AND SAYS WHAT A DRIVE IS. It says nothing about
filesystems, which is what leaves room for a system that would rather have
its own - and is why the volatile bit is a fact about the hardware rather
than a promise about SBFS.

  0x26        what the selected drive is: bit 0, contents do not survive
  0x27, 0x28  how many blocks it has
  --ram-disk N   a drive of N blocks with memory behind it

A drive of memory selects, reads, writes and has a size like any other, and
a program cannot tell the difference except by how fast it was. The one
thing it cannot work out for itself is that the contents are volatile,
because an empty disk and a volatile disk look identical from outside.

THAT BIT IS THE DIFFERENCE BETWEEN A DRIVE A SYSTEM MAY FORMAT ON SIGHT AND
ONE IT MUST NOT. CosmOS formats a volatile drive it cannot read, because
there was never anything on it to lose, and leaves every other unreadable
drive alone - an unformatted floppy is not an invitation, it is a blank
floppy. Removing that check formats somebody's blank disk, which is checked
rather than asserted: cosmosBlankDisk boots with one and requires it to be
refused.

So CosmOS grew a format. The size comes from the drive rather than from a
superblock, since a superblock states a size too and that is no use on a
disk which has not got one yet. Sixteen directory blocks, 128 names, chosen
rather than worked out: a scratch disk runs out of names long before room,
and this machine cannot divide.

The RAM disk is no faster on this emulator by default, and that is honest
rather than disappointing: the emulated disk has no seek time unless asked
for one. With --disk-cycles 10000 the same copy is 7.94M cycles against
8.70M, the difference being every write.

run.sh takes "ram:2048" where an image name goes, which needs no removing
between runs because there is nothing to remove.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-08-31 17:56:41 -04:00
co-authored by Claude Opus 5
parent 6b51d6391f
commit 04f1ffabd4
15 changed files with 351 additions and 6 deletions
+24 -1
View File
@@ -546,7 +546,7 @@ If nothing is installed for the vector a device refused with, the machine stops
| 0x00 - 0x05 | The console. See The Console. Writing to 0x00 sends a byte to standard output, reading takes one from standard input. It interrupts on 0x00, its base port, when asked to. | 0x02 |
| 0x10 | A test device. Writing anything to it puts its own line up, so that interrupt handling can be exercised without waiting on anything. The byte written is ignored. | 0x10 |
| 0x11 | A device that refuses everything, in both directions, so that refusal can be exercised without the memory controller. | 0x11 |
| 0x20 - 0x25 | The disk. See Storage. It interrupts on 0x20, its base port. | 0x13 |
| 0x20 - 0x28 | The disk. See Storage. It interrupts on 0x20, its base port. | 0x13 |
| 0x13 | The machine itself. Writing 1 asks it to start over: whatever put the first instruction in memory does it again, and the CPU begins where the boot vector points. A port rather than a service, because a reset has to work when the system does not - and a program that owns the whole machine has no system to ask. The disk is not unplugged and keeps what was written to it; the vector table is cleared, because a handler left behind would aim an interrupt into a program that is no longer running. | 0x04 |
| 0x12 | A device that owns 256 bytes of memory. Writing to its port fills that memory with the byte written, standing in for a disk controller reading a sector. Its memory is unreachable until it is registered as a bank. | 0x12 |
| 0x30 - 0x3F | The screen. See The Screen. It brings video memory, which is unreachable until it is registered as a bank. | 0x14 |
@@ -1249,6 +1249,29 @@ disk port. So the drive is a register, which is what a floppy controller has alw
| --- | --- |
| 0x24 | Drive. Which one the block, command and status registers refer to. Reads back. |
| 0x25 | Drives, read only. How many are plugged in. |
| 0x26 | What the selected drive is, read only. Bit 0: its contents do not survive the machine stopping. |
| 0x27, 0x28 | How many blocks the selected drive has, read only. |
### A Drive Made Of Memory:
A drive may have memory behind it instead of a file. It selects, reads, writes and has a size
like any other, and a filesystem on it is a filesystem - **a program cannot tell the
difference except by how fast it was.** What it has not got is anything that survives the
machine stopping.
That difference is the one thing a system cannot work out for itself, because an empty disk
and a volatile disk look identical from outside. So the machine says it, in bit 0 of 0x26, and
says nothing whatever about filesystems.
**Which is the whole point of saying it that way.** The bit is what separates a drive a system
may format on sight from one it must not: an unformatted floppy somebody put in deliberately
is not an invitation, while an unformatted drive made of memory never had anything to lose. A
system reads the bit and draws its own conclusion - and a system that would rather have a
different filesystem entirely reads the same bit and writes whatever it likes. **The machine
supplies blocks. Bringing them up is the system's job.**
The size registers exist for the same reason. A superblock states a disk's size too, and that
is no use at all on a disk which has not got one yet.
The block, command and status registers, **and the single buffer**, all belong to whichever
drive is selected. A program that changes drives is holding a buffer that no longer contains