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.

Postscript

Since writing the above, I have 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.

Presumably 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.


John Elliott 5-12-2008