Unix pages
Home -> UNIX software -> JOYCE -> The Cirtech Gem drive

The Cirtech Gem drive

Hardware

Physically, the Gem drive (at least the one I have) is a Seagate ST351A/X IDE drive, jumpered for XT mode. If the jumpers are set for AT mode it is possible to connect it to a modern PC and access the data at a sector level. Jumper settings for the ST351A/X can be found on Dell's website.

In XT mode the drive has four registers, mimicking an XT hard drive controller. On the PCW they can be found at ports 0A8h to 0ABh. The information below is adapted from the Interrupt List entry for ports 0320h-0323h, which is where the registers appear on a PC. For full programming information, see the IBM PC technical reference, pages 1-187 to 1-201.

0A8h
Data register.
0A9h
When read: controller status. When written: Reset controller.
0AAh
When read: controller DIP switches. When written: Generate controller-select pulse.
0ABh
When written: DMA and interrupt mask (not used on the PCW)

In addition, the Gem interface has a 4k boot ROM. It would appear that on initial startup, memory accesses with A7 reset go to the boot ROM, while memory accesses with A7 set go to the PCW mainboard. So the 4k ROM is mapped into memory from 0000-007F, 0100-017F, 0200-027F, ..., 1F00-1F7F.

The first thing the GEM boot rom does is to mimic the normal PCW boot process by copying the standard floppy boot image into memory. It does this by repeated memory reads (from address 80h, so with A7 set) until the sequence D3 F8 [OUT (0F8h),A] is encountered. Then it executes its own write to that port to switch to normal execution, and copies itself into RAM.

While the ROM is paged in, all I/O port accesses use 16-bit I/O [OUT (C),A style], with the top 8 bits of the address set to 80h. The first instruction after the boot ROM has been copied into RAM is IN A,(0A9h), with A=0. Presumably this I/O read, with the top 8 bits of the address all 0, pages the boot ROM out.

In a Gem-2 (mirrored) configuration, the 'main' drive is drive 1 (ie, jumpered as slave) and the 'backup' drive is drive 0 (ie, jumpered as master).

The system track

The first track of the Gem drive contains a boot image, which is loaded and executed by the 4k boot ROM. The hard drive setup program provided with the drive will write this when asked to repartition the drive or update the boot loader. On the utilities diskette it is stored in a file called HD.SYS.

The boot image starts with a header, corresponding to the MBR on an IBM-formatted hard drive:

Offset Size Description
0 Word Offset to boot programs table
2 Word Offset to image of HDRIVER.FID
4 Word Offset to the splash screen
6 Word Total length of the boot image
8 Byte Options byte
9 17 bytes CP/M Plus DPB (used for all partitions, so they all have to be the same size)
26 Byte Sectors per track
27 Word Start cylinder for partition 1
29 Word Start cylinder for partition 2
31 Word Start cylinder for partition 3, 0 if none
33 Word Start cylinder for partition 4, 0 if none
35 Byte 8-bit checksum of bytes 0-34

Note that the SPT field in the DPB at offset 9 gives sectors per cylinder, while the 'Sectors per track' at offset 1Ah really does give sectors per track. For example, a Gem drive with 5 heads and 17 sectors would have SPT = 5 * 17 = 85, while the field at offset 26 would hold 17.

Three bits of the options byte are used:

Bit 7
Set to load CP/M by default, clear to load LocoScript by default. Hold the ALT key when booting to load the other OS.
Bit 4
Set if this is a Gem-2 (mirrored) system. In this configuration, sectors are read from drive 1 (the main drive) and written to both drive 1 (the main drive) and drive 0 (the backup drive). Hold the B key when booting to disable mirroring and boot from the backup drive.
Bit 0
Set if a splash screen is present.

The boot programs table

This table contains a list of boot programs. Each entry is five bytes long:
Offset Size Meaning
0 Byte 8-bit checksum of the first 512 bytes of the EMS/EMT file
1 Word Offset of boot program from start of table
3 Word Length of boot program

The end of the table is indicated by a boot program with offset 0. If the checksum of the first 512 bytes of the EMS/EMT file does not match any of the entries in the table, the boot ROM will give a single beep and refuse to execute it.

If a matching boot program is found, it will be copied to 0D000h and run with the following parameters:

The task of the boot program is to inject the HDRIVER.FID image into the loaded EMS / EMT file, so that it boots from the hard drive rather than the floppy. The version of the bootloader that I have studied can do this to six variants of the CP/M EMS file, and 64 variants of the LocoScript EMS file.

The HDRIVER.FID image

This is an exact copy of the HDRIVER.FID used to access the hard drive when booting from floppy.

The splash screen

This is a 720×146 bitmap. It is stored as 19 rows, each containing 90 8×8 character cells. The first row should be blank, because it is used to draw the 55 scanlines above and below the picture.

ATA Gem Drive

Since writing the above, I had the opportunity to examine another Gem drive. This was a 20Mb unit, given to me to be securely wiped before disposal. Unlike the drive described above, it was an ATA drive (a Conner Peripherals CP3024).

The drive was not detected by my interface (no surprise, since the interface was expecting an XTA drive, and getting an ATA drive). After a couple of false starts, I managed to connect the drive to a normal PC to wipe it. It would therefore seem that just because two drives describe themselves as Gem drives, that's no guarantee that they're compatible; if possible, the drives and their interfaces should be treated as matched pairs.

The interface that came with the drive, which I don't have, would have mapped the ATA controller at ports 0A8h-0AFh, and had some means of converting between the PCW's 8-bit data bus and the drive's 16-bit bus.

Insyder Drive

More recently still, I came into possession of an Insyder drive and its interface. (An Insyder is fitted internally to a PCW9512, rather than sitting beside it in a separate housing).

Physically, this drive is an IBM WDA-L42S. Like the 20Mb Gem drive, this is an ATA drive. The interface therefore maps the ATA controller at ports 0A8h-0AFh. It also appears to write 0 to port 0FF94h; this may reset the flip-flop that groups bytes read/written by the PCW into the words used by the ATA controller.

Possibly for timing reasons (perhaps so the PCW can process bytes as fast as the drive needs to), the sectors are stored with a non-obvious byte arrangement. Each 512-byte sector is stored as 256 little-endian words:

So on disc, a sector might read:

0000AA00   00 00 48 48  44 44 48 48  45 45 4C 4C  50 50 20 20  ..HHDDHHEELLPP
0000AA10   20 20 48 43  CC CF 50 4D  01 00 00 00  00 00 80 38    HC..PM.......8
0000AA20   0F 04 00 00  10 05 00 00  11 00 00 00  12 00 00 00  ................
0000AA30   13 00 00 00  14 00 00 00  15 00 00 00  16 00 00 00  ................
0000AA40   00 00 48 48  44 44 48 53  45 45 4C 54  50 55 20 50  ..HHDDHSEELTPU P
0000AA50   20 20 48 43  CC CF 50 4D  03 00 00 00  00 00 80 2B    HC..PM.......+
0000AA60   17 06 00 00  18 07 00 00  19 00 00 00  1A 00 00 00  ................
0000AA70   1B 00 00 00  1C 00 00 00  1D 00 00 00  1E 00 00 00  ................
0000AA80   00 00 48 4E  44 45 48 54  45 50 4C 49  50 43 20 20  ..HNDEHTEPLIPC
0000AA90   20 20 48 31  CC A0 50 20  04 00 00 00  00 00 36 11    H1..P ......6.
0000AAA0   1F 08 00 00  20 00 00 00  00 00 00 00  00 00 00 00  .... ...........
0000AAB0   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  ................
0000AAC0   00 00 52 48  45 44 53 20  54 20 4F 20  52 20 45 20  ..RHEDS T O R E
0000AAD0   20 20 43 53  CF D9 4D 53  00 01 00 00  00 00 55 0F    CS..MS......U.
0000AAE0   21 0A 00 00  22 0B 00 00  23 0C 00 00  00 0D 00 00  !..."...#.......
0000AAF0   00 0E 00 00  00 00 00 00  00 00 00 00  00 00 00 00  ................
0000AB00   00 00 4E 42  45 41 54 43  50 4B 49 55  43 50 20 20  ..NBEATCPKIUCP
0000AB10   20 20 30 43  A0 CF 20 4D  00 00 00 00  00 00 2D 5C    0C.. M......-\
0000AB20   09 24 00 00  2D 25 00 00  00 26 00 00  00 00 00 00  .$..-%...&......
0000AB30   00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  ................
0000AB40   00 00 52 44  41 49 4D 53  54 43 45 4B  53 49 54 54  ..RDAIMSTCEKSITT
0000AB50   20 20 43 43  CF CF 4D 4D  00 00 00 00  00 00 11 49    CC..MM.......I

This would decode to the memory data:

0000AA00   00 48 44 48  45 4C 50 20  20 43 CF 4D  00 00 00 38  .HDHELP  C.M...8
0000AA10   04 00 05 00  00 00 00 00  00 00 00 00  00 00 00 00  ................
0000AA20   00 48 44 53  45 54 55 50  20 43 CF 4D  00 00 00 2B  .HDSETUP C.M...+
0000AA30   06 00 07 00  00 00 00 00  00 00 00 00  00 00 00 00  ................
0000AA40   00 4E 45 54  50 49 43 20  20 31 A0 20  00 00 00 11  .NETPIC  1. ....
0000AA50   08 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  ................
0000AA60   00 48 44 20  20 20 20 20  20 53 D9 53  01 00 00 0F  .HD      S.S....
0000AA70   0A 00 0B 00  0C 00 0D 00  0E 00 00 00  00 00 00 00  ................
0000AA80   00 48 44 48  45 4C 50 20  20 48 CC 50  01 00 00 80  .HDHELP  H.P....
0000AA90   0F 00 10 00  11 00 12 00  13 00 14 00  15 00 16 00  ................
0000AAA0   00 48 44 48  45 4C 50 20  20 48 CC 50  03 00 00 80  .HDHELP  H.P....
0000AAB0   17 00 18 00  19 00 1A 00  1B 00 1C 00  1D 00 1E 00  ................
0000AAC0   00 48 44 48  45 4C 50 20  20 48 CC 50  04 00 00 36  .HDHELP  H.P...6
0000AAD0   1F 00 20 00  00 00 00 00  00 00 00 00  00 00 00 00  .. .............
0000AAE0   00 52 45 53  54 4F 52 45  20 43 CF 4D  00 00 00 55  .RESTORE C.M...U
0000AAF0   21 00 22 00  23 00 00 00  00 00 00 00  00 00 00 00  !.".#...........
0000AB00   00 42 41 43  4B 55 50 20  20 43 CF 4D  00 00 00 5C  .BACKUP  C.M...\
0000AB10   24 00 25 00  26 00 00 00  00 00 00 00  00 00 00 00  $.%.&...........
0000AB20   00 44 49 53  43 4B 49 54  20 43 CF 4D  00 00 00 49  .DISCKIT C.M...I
0000AB30   27 00 28 00  29 00 00 00  00 00 00 00  00 00 00 00  '.(.)...........
0000AB40   00 4D 41 4E  41 47 45 52  20 43 CF 4D  00 00 00 23  .MANAGER C.M...#
0000AB50   2A 00 2B 00  00 00 00 00  00 00 00 00  00 00 00 00  *.+.............
0000AB60   00 52 45 54  20 20 20 20  20 20 A0 20  00 00 00 1B  .RET      . ....

The boot track contains two versions of the hard disk driver (5.1.3S and 6.1.3S) as opposed to version 5.0.3X from my original Gem drive. (Is it too much of a stretch to suppose that 'X' drivers are for XTA drives?). Version 5.1.3S is used when booting CP/M, and 6.1.3S when booting LocoScript 4. The latter contains a FID header with a signature of "FIC" rather than "FID" or "FIB", and makes a SuperVisor Call I have not seen elsewhere, seemingly to inform LocoScript that it is booting from a hard drive and should save its settings to C: rather than A:.


John Elliott 3-2-2021