LisaList2

General Category => LisaList2 => Topic started by: stepleton on January 15, 2021, 07:40:07 pm

Title: (Aphid Selector) Preview
Post by: stepleton on January 15, 2021, 07:40:07 pm
On GitHub soon...
Title: Re: Preview
Post by: stepleton on January 15, 2021, 08:02:28 pm
"Magic blocks" used by the Cameo/Aphid drive image selector

16 January 2021, stepleton@gmail.com

The Cameo/Aphid drive image selector program ("the Selector" for short) is a computer program for the Apple Lisa that allows you to create, manage, and boot from ProFile drive image files on a Cameo/Aphid ProFile hard drive emulator. Behind the scenes, the Selector accomplishes this by sending specially formatted read and write commands to (as yet unreleased versions of) the drive emulator that target unusual hard drive blocks.

The Selector is not the only program that can use these "magic blocks", and any hard drive emulator that understands these special reads and writes will be compatible with the Selector. This document describes the format of these reads and writes for the benefit of anyone who wishes to take advantage of this compatibility.

This document was created as part of the Cameo/Aphid hard drive emulator project at https://github.com/stepleton/cameo/tree/master/aphid (https://github.com/stepleton/cameo/tree/master/aphid).

Block FFFFFF: "Magic block" capability identification

The Selector reads from block FFFFFF to identify whether the connected drive is a ProFile emulator that supports the "magic block" protocol described here. If bytes $20-$2B of the returned block are Cameo/Aphid and bytes $2C-$2F are a 32-bit integer greater than or equal to $30303031 (i.e. 0001), then the Selector may assume that it is talking to a compatible emulator.

Note that ordinary ProFile hard drives respond to reads on block FFFFFF with "artificial" block data that contains information about the hard drive. Drives with ROM version $0398 that allocate no bad blocks or spare blocks only need bytes $00-$1F to encode this information, so the adjacent bytes occupied by the "magic block" capability identifier will not interfere with it.

Block FFFFFD: Built-in emulator commands

Writes to block FFFFFD with write count and sparing threshold parameters FE and AF respectively will issue "built-in" commands to the hard drive emulator. These commands are encoded in the block data written to the drive. ("Built-in" refers to an implementation detail of the Cameo/Aphid emulator and is not important to this description.) There are currently two commands:
Neither command provides any response or any other overt indication of success or failure; programs should attempt to deduce the outcome in other ways.

(Note: the IDEfile emulator (http://john.ccac.rwth-aachen.de:8000/patrick/idefile.htm) uses a similar but distinct "magic block" mechanism on block FFFFFD for access to its volume table.)

Block FFFEFF: Durable key/value store

Reads and writes to block FFFEFF provide access to a durable (i.e. retained through reboots of the hard drive emulator) key/value store. Keys are 20 bytes long; values are 512 bytes long. This store remains accessible no matter which disk image file is currently in use by the emulator.

The facility presents as having a kind of volatile (that is, not retained through system reboots) write-through cache where the 65,535 cache entries are software controllable (as opposed to being controlled automatically, as with a CPU cache for example). Cache keys are 16-bit values formed by the concatenation of the retry count and the sparing threshold specified during a ProFile read or a write. Reads can only request items from the cache, so earlier writes must have directed the store to have loaded data there from the durable key/value store. For writes, software must specify both a cache key and the 20-byte store key; the data will be saved in both the cache and the durable store automatically.

Operations:
From a logical perspective, any store keys not yet associated with any data are paired with 512 $00 bytes, and any cache keys not yet associated with any data are associated with 532 $00 bytes (in other words, an all-$00 20-byte key and 512 bytes of all-$00 data).

Block FFFEFE: Filesystem operations

Reads and writes to this block enable some basic filesystem operations.  For safety, operations may be limited to files with a particular suffix.

Operations:
Filenames are sent to and from the emulator in the ISO-8859-1 (Latin-1) character encoding.

Block FFFEFD: Emulator status

Reads of this block retrieve basic system status information from the emulator. The format in use is a good fit for emulators that incorporate Unix-like operating systems (like Cameo/Aphid does) but may not be as useful for other implementations.

   Bytes   0-9: DDDDHHMMSS ASCII uptime; days right-justified space padded
   Bytes 10-24: ASCII right-aligned space-padded filesystem bytes free
   Bytes 25-31: ASCII null-terminated 1-minute load average
   Bytes 32-38: ASCII null-terminated 5-minute load average
   Bytes 39-45: ASCII null-terminated 15-minute load average
   Bytes 46-50: ASCII null-terminated number of processes running
   Bytes 51-55: ASCII null-terminated number of total processes
Title: Re: Preview
Post by: rayarachelian on January 15, 2021, 10:48:36 pm
Congrats! Very nice!
Title: Re: Preview
Post by: snuci on January 16, 2021, 09:22:33 pm
Looks VERY interesting!  Please keep us updated on your progress.