IDEDOS

From SinclairFAQ
Revision as of 22:20, 12 November 2011 by Guesser (talk | contribs) (Partition Table Entry Format)
Jump to: navigation, search


IDEDOS is a hard disk formatting scheme designed for ZX Spectrum computers and clones. It was designed by Garry Lancaster for his +3e ROMs and ResiDOS RAM based operating system, and extended by Jarek Adamski to support his ZXVGS, CPM22QED and YaPaDOS operating systems.

Format

Note: The following is not an official specification, it has been reverse engineered from hard disk images and information collected from various sources. The labels given to bytes are entirely arbitrary and should not be taken as the official labels.

IDEDOS supports up to 65535 partitions on a hard disk, with a theoretical maximum partition size of 2TB. However IDEDOS does not support LBA mode therefore the hard disk capacity is limited to 128GB by the limitations of CHS addressing.

8-bit vs 16-bit interfaces for Z80 based computers

Since the Z80 microprocessor has as an 8-bit data bus and IDE requires a 16-bit data bus some circuitry is required to combine a pair of 8-bit read/write operations into a single 16-bit operation. This extra circuitry increases cost and complexity in a hard disk interface so some interfaces omit this circuitry and simply treat the IDE bus as a normal 8-bit wide I/O device. This means that when any 16-bit word is read from or written to the hard disk, the upper byte is simply ignored, therefore half the hard disk's capacity cannot be utilised by computer. IDEDOS supports these halved capacity interfaces as it simply means that each hard disk sector contains 256 bytes instead of the standard 512 bytes. Software which reads from an IDEDOS formatted disk should not therefore make assumptions about the number of bytes per sector as it depends on the hardware used to format the disk.

The IDEDOS System Partition

The IDEDOS System Partition is normally the first partition on the drive located at Cylinder 0, Head 0, Sector 1 (C0/H0/S1). The specification also allows placing the system partition at Cylinder 0, Head 1, Sector 1 (C0/H1/S1) to allow an MS-DOS Master Boot Record to be present.

The IDEDOS System Partition contains the Partition Table for the drive. The Partition Table consists of a number of Partition Table Entries each 64 bytes long containing the partition type, location, size, and additional type specific information.

The first partition entry in the table describes the IDEDOS System Partition itself and contains information about the drive geometry and initialisation information for the +3e system ROMs

Partition Table Entry Format

All partition table entries conform to the following structure

IDEDOS Partition entry - 64 bytes
0x0000	PN PN PN PN PN PN PN PN PN PN PN PN PN PN PN PN	
0x0010	PT SC SC SH EC EC EH LS LS LS LS TI TI TI TI TI 
0x0020	TI TI TI TI TI TI TI TI TI TI TI TI TI TI TI TI 
0x0030	TI TI TI TI TI TI TI TI TI TI TI TI TI TI TI TI 	

Key:
PN: non case sensitive partition name. 16 byte un-terminated text string. Space padded.
PT: partition type.
SC: starting cylinder. 16 bit little endian word.
SH: starting head.
EC: ending cylinder. 16 bit little endian word.
EH: ending head.
LS: largest logical sector. 32 bit little endian word.
TI: partition type specific data.

Partition Types

There are numerous partition types defined

Partition Type 0x00 - Unused Partition

This is an empty partition table entry. Type 0x00 entries do not describe any disk space and should be left blank.

Partition Type 0x01 - The IDEDOS System Partition

The first partition entry in the partition table is always the IDEDOS system partition. There must only be one System Partition on a hard disk. The partition label must always be the string "PLUSIDEDOS" followed by six spaces (ascii 0x20) as this string is used to determine whether the disk was created using an 8 or 16-bit interface. The starting head and ending head are either zero or one depending on where the partition table has been written. The drive geometry is written in the type specific data in the bytes 0x0020 to 0x0027

0x0000	50 4C 55 53 49 44 45 44 4F 53 20 20 20 20 20 20		partition name "PLUSIDEDOS      "
0x0010	01 00 00 SH EC EC EH LS LS LS LS ?? ?? ?? ?? ??	
0x0020	NC NC NH ST SC SC MP MP EA BA UA UB UM M0 M1 MR	
0x0030	DD ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ??	

Key:
NC: Number of cylinders available to IDEDOS. 16 bit little endian word.
NH: Number of heads.
ST: Number of sectors per track.
SC: Number of sectors per cylinder (equal to NH * ST). 16 bit little endian word.
MP: Maximum partition. 16 bit little endian word.
EA: Default +3 Editor colour attribute byte.
BA: Default +3 BASIC colour attribute byte.
UA: Un-map drive A in non-zero.
UB: Un-map drive B in non-zero.
UM: Un-map drive M in non-zero.
M0: Drive letter to map floppy unit 0.
M1: Drive letter to map floppy unit 1.
MR: Drive letter to map ramdisk.
DD: +3DOS default drive letter.
??: Unused.
Partition Type 0x02 - Swap Space

Swap partitions can be created with the +3e ROMs however no software is known to use them.

Partition Type 0x03 - +3DOS

The +3e ROMs create partitions of type 0x03 i.e. +3DOS partitions. The type specific data portion of the Partition Entries for these partitions contain a +3DOS XDPB (eXtended Disc Parameter Block) between 0x0020 to 0x003A and also the +3DOS drive letter to which the partition has been mapped (if any)

0x0000	PN PN PN PN PN PN PN PN PN PN PN PN PN PN PN PN	
0x0010	03 SC SC SH EC EC EH LS LS LS LS ?? ?? ?? ?? ??	
0x0020	DP DP DP DP DP DP DP DP DP DP DP DP DP DP DP DP	
0x0030	DP DP DP DP DP DP DP DP DP DP ?? ?? DL ?? ?? ??	

Key:
DP: +3DOS extended disk parameter block byte
DL: plus3dos drive letter
??: unused

The eXtended Disk Parameter Block data is ordered as follows

0x0020  SPT SPT BSH BLM EXM DSM DSM DRM DRM AL0 AL1 CKS CKS OFF OFF PSH
0x0030  PHM sid tps spt fsn ss  glr glf mms ff

key:
SPT: Records Per Track
BSH: Block Shift: 128 * 2^BSH
BLM: Block Mask: 128 * (BLM + 1)
EXM: Extent Mask
DSM: number of blocks - 1
DRM: number of directory entries - 1
AL0: AL0 directory bitmap
AL1: AL1 directory bitmap
CKS: size of checksum vector
OFF: reserved tracks
PSH: physical sector shift
PHM: sector size
sid: sidedness
tps: number of tracks per side
spt: number of sectors per track
fst: first sector number
ss:  (sector size / 128) - 1
glr: gap length (read/write)
glf: gap length (format)
mms: multitrack/modulation/skip
ff:  freeze flag


Partition Type 0x04 - CP/M Partition

CP/M partition with an XDPB which reflects the geometry of the physical disk. The partition must use a whole number of cylinders and use whole number of tracks. If the partition does not start at track 0 of the cylinder the area before the partition on that cylinder must be marked as reserved tracks in the XDPB.

Partition Type 0x05 - Boot Partition

A partition of type 0x05 is accessed as a single file. This can be used as a boot file for example a Timex FDD3000 with a YABUS.TF searches for a type 0x05 partition with the label "YABUS.TF". If found the contents of the partition are copied to RAM and executed.

Partition Type 0x0F - Movie Partition

Partition containing a sequence of screenshots (and sound).

Partition Type 0x10 - FAT-16 Partition

Partition containing a FAT-16 filesystem.

Partition Type 0x20 - UZI(X) Partition

Partition for UZI(X) the UNIX Implementation for MSX.

Partition Types 0x3x - Non-CP/M Disk Image Partitions

For partitions containing non-CP/M floppy disk images the type specific information defines a virtual geometry. More than one disk image partition can be present on each track, i.e. the partitions do not have to align to track boundaries. This is achieved by specifying a sector shift in the partition table entry. For example for a disk with 980 cylinders, 5 heads, 17 sectors per track and 512 bytes per sector, a 800kB partition takes 1600 sectors which is equal to 18 cylinders + 4 tracks + 2 sectors, so the shift for next partition is 2.

The following non-CP/M format disk image types are defined:


Partition Types 0x4x - CP/M Disk Image Partitions

The following CP/M format disk image types are defined:

  • 0x40: ZX Spectrum +3 image.
  • 0x41: Elwro 800 Junior image.
  • 0x48: Amstrad CPC image.
  • 0x49: Amstrad PCW image.


Partition Type 0xFE - Bad Disk Space

Drive space which should not be used.

Partition Type 0xFF - Free Disk Space

A Type 0xFF partition entry as created by the +3e ROMs is all blank except for the type byte and the location and size information. The type specific information is not used.