-- RDC.mesa (last edited by: McJones on: July 18, 1980 5:25 PM)

DIRECTORY
Environment USING [Base],
File USING [Type],
PilotDisk USING [nullAddress],
SA4000Face USING [DiskAddress, Operation];

RDC: DEFINITIONS =
BEGIN

-- RDC I/O Command Block
IOCB: TYPE = MACHINE DEPENDENT RECORD [ -- 16-word aligned
operation (0): SA4000Face.Operation,
serviceLateRetryCount (15B): CARDINAL, -- microcode retry count
rdcCommand (16B): WORD, -- command to be executed by the RDC
next (17B): IOCBshortPtr, -- points to next IOCB in the queue, set by Initiate
clientHeader (20B): SA4000Face.DiskAddress,
dontcare (22B): RECORD [a, b: UNSPECIFIED], -- clobbered by disk microcode
clientLabel (24B): PackedLabel, -- input to verify and write label operations
diskLabel (34B): PackedLabel, -- output from verify and read label operations
rateErrorRetryCount (44B): CARDINAL]; -- microcode retry count

IOCBshortPtr: TYPE = Environment.Base RELATIVE POINTER TO IOCB;
IOCBlongPtr: TYPE = LONG POINTER TO IOCB;

-- Restore the explicit bit positions in the following declaration as soon as Mesa AR 4670 is fixed:
PackedLabel: TYPE = MACHINE DEPENDENT RECORD [
sequence0Bit2 --(0:0..0)--: CARDINAL[0..2),
processorID0 --(0:1..15)--: CARDINAL[0..32768),
processorID1 --(1)--: CARDINAL,
processorID2 --(2)--: CARDINAL,
sequence1 --(3)--: CARDINAL,
sequence0Bits3Thru15 --(4:0..12)--: CARDINAL[0..8192),
immutable --(4:13..13)--: BOOLEAN, -- clear after first (or every) page in run
temporary --(4:14..14)--: BOOLEAN, -- clear after first (or every) page in run
zeroSize --(4:15..15)--: BOOLEAN, -- clear after first (or every) page in run
filePageLo --(5)--: CARDINAL, -- increment after every page in run
type --(6)--: File.Type,
vp --(7)--: SELECT OVERLAID * FROM
volumeFile => [
fill: CARDINAL[0..512) ← 0, -- delete when Mesa AR 4670 is fixed
filePageHi --(7)--: CARDINAL[0..128)],
normalFile => [bootChainLink --(7)--: PackedDiskAddress],
ENDCASE];

PackedDiskAddress: TYPE = MACHINE DEPENDENT RECORD [
cylinder (0:0..7): [0..256), -- =fixedHeadCylinder => next field is a fixed head
head (0:8..10): [0..8),
sector (0:11..15): [0..32)];

eof: PackedDiskAddress = LOOPHOLE[-1]; -- cylinder=255;
fixedHeadCylinder: CARDINAL = 254;
firstFixedHead: CARDINAL = 8;

PackDiskAddress: PROCEDURE [da: SA4000Face.DiskAddress] RETURNS [PackedDiskAddress] =
INLINE BEGIN
IF da=LOOPHOLE[PilotDisk.nullAddress] THEN
RETURN[eof]
ELSE IF da.head>=firstFixedHead THEN
RETURN[[cylinder: fixedHeadCylinder, head: da.head-firstFixedHead, sector: da.sector]]
ELSE
RETURN[[cylinder: da.cylinder, head: da.head, sector: da.sector]]
END;

UnpackDiskAddress: PROCEDURE [pda: PackedDiskAddress] RETURNS [SA4000Face.DiskAddress] =
INLINE BEGIN
IF pda=eof THEN
RETURN[LOOPHOLE[PilotDisk.nullAddress]]
ELSE IF pda.cylinder=fixedHeadCylinder THEN
RETURN[[cylinder: 0, head: pda.head+firstFixedHead, sector: pda.sector]]
ELSE
RETURN[[cylinder: pda.cylinder, head: pda.head, sector: pda.sector]]
END;

DeviceStatus: TYPE = MACHINE DEPENDENT RECORD [
outcome (0: 0..3): Outcome,
rdcBits (0: 4..15): RDCStatusBits];

Outcome: TYPE = MACHINE DEPENDENT {inProgress (0), goodCompletion, dataError, labelError,
labelCheck, seekTimeout, sectorTimeout, notReady, headerError};

RDCStatusBits: TYPE = MACHINE DEPENDENT RECORD [
unused (0:0..0),
serviceLate (0:1..1),
one (0:2..2), -- should always be 1
rateError (0:3..3),
sector00S (0:4..4),
track00S (0:5..5),
seekCompS (0:6..6),
devSelOK (0:7..7),
bufErr (0:8..8),
rdErr (0:9..9),
writeFault (0:10..10),
oFault (0:11..11): BOOLEAN];

END.

LOG
Time: November 19, 1979 6:32 PM
By: FrandeenAction: Create file
Time: June 3, 1980 10:22 AM
By: McJonesAction: 48-bit processor ids