-- DicentraDiskDriverImpl.mesa -- Driver for Century Data AMS-315 disk drive and Xylogics SMD controller -- Jim Gasbarro 19-Feb-85 14:04:11 -- -- ************** W A R N I N G ************** -- On the Dicentra, the left byte is even and the right byte is odd. Bits are numbered 0..7 -- from left to right. These conventions are opposite of those found in the Xylogics-450 -- controller manual. -- ******************************************* DIRECTORY DicentraDiskDriverUtils, DicentraDiskDriver, DicentraInputOutput, Inline, OthelloDefs, Process, ProcessorFace USING [SetMP], SpecialRuntime; DicentraDiskDriverImpl: MONITOR IMPORTS OthelloDefs, DicentraDiskDriverUtils, DicentraInputOutput, Inline, Process, ProcessorFace, SpecialRuntime EXPORTS DicentraDiskDriver = BEGIN Head: TYPE = DicentraDiskDriver.Head; Sector: TYPE = DicentraDiskDriver.Sector; Cylinder: TYPE = DicentraDiskDriver.Cylinder; Unit: TYPE = DicentraDiskDriver.Unit; tracksPerCylinder: CARDINAL = DicentraDiskDriver.tracksPerCylinder; sectorsPerTrack: CARDINAL = DicentraDiskDriver.sectorsPerTrack; cylindersPerSpindle: CARDINAL = DicentraDiskDriver.cylindersPerSpindle; wordsPerSector: CARDINAL = DicentraDiskDriver.wordsPerSector; -- Disk Controller Registers DiskControllerRegister: TYPE = { iOPBRelocHigh, iOPBRelocLow, iOPBAddHigh, iOPBAddLow, controllerResetAndUpdate, -- read to reset controller, write to update IOPB controlStatus }; -- controlStatus register bit definitions goBusy: CARDINAL = 80H; generalError: CARDINAL = 40H; doubleError: CARDINAL = 20H; intPending: CARDINAL = 10H; addMode: CARDINAL = 08H; attnReq: CARDINAL = 04H; attnAck: CARDINAL = 02H; driveReady: CARDINAL = 01H; -- IOPB Definition IOPB: TYPE = MACHINE DEPENDENT RECORD [ intMode: IntMode, diskCommand: DiskCommand, statusByte2: StatusByte2 _ success, statusByte1: StatusByte1, driveTypeAndSelect: DriveTypeAndSelect, throttle: Throttle, sectorAdd: [0..256) _ 0, headAdd: [0..256) _ 0, cylAddHigh: [0..256) _ 0, cylAddLow: [0..256) _ 0, sectorCountHigh: [0..256) _ 0, sectorCountLow: SectorCountLow _ [writeSectorCountLow[0]], dataAddHigh: [0..256) _ 0, dataAddLow: [0..256) _ 0, dataRelocHigh: [0..256) _ 0, -- can't address above 24 bits dataRelocLow: [0..256) _ 0, reserved: [0..256) _ 0, headOffset: [0..256) _ 0, nextIOPBAddHigh: [0..256) _ 0, nextIOPBAddLow: [0..256) _ 0, eCCMaskPatternLow: [0..256) _ 0, eCCMaskPatternHigh: [0..256) _ 0, eCCBitAddHigh: [0..256) _ 0, eCCBitAddLow: [0..256) _ 0 ]; DiskCommand: TYPE = MACHINE DEPENDENT RECORD [ autoUpdate (0: 0..0): BOOLEAN _ TRUE, relocate (0: 1..1): BOOLEAN _ FALSE, chainEnable (0: 2..2): BOOLEAN _ FALSE, intEnable (0: 3..3): BOOLEAN _ TRUE, command (0: 4..7): Command _ noOp ]; Command: TYPE = MACHINE DEPENDENT {noOp(0), write(1), read(2), writeHeaders(3), readHeaders(4), seek(5), driveReset(6), writeFormat(7), readHeaderDataECC(8), readDriveStatus(9), writeHeaderDataECC(10), setDriveSize(11), selfTest(12)}; IntMode: TYPE = MACHINE DEPENDENT RECORD [ reserved (0: 0..0): BOOLEAN _ FALSE, intOnEachIOPB (0: 1..1): BOOLEAN _ TRUE, intOnError (0: 2..2): BOOLEAN _ FALSE, holdDualPort (0: 3..3): BOOLEAN _ FALSE, autoSeekRetry (0: 4..4): BOOLEAN _ TRUE, enableExtendedFunc (0: 5..5): BOOLEAN _ FALSE, eCCMode (0: 6..7): ECCMode _ correct ]; ECCMode: TYPE = MACHINE DEPENDENT {patternAndOffset(0), noFlagOrCorrect(1), correct(2), flagAndNoCorrect(3)}; StatusByte1: TYPE = MACHINE DEPENDENT RECORD [ errorSummary (0: 0..0): BOOLEAN _ FALSE, reserved (0: 1..2): BOOLEAN _ FALSE, controllerType (0: 3..5): ControllerType _ type440Controller, reserved2 (0: 6..6): BOOLEAN _ FALSE, done (0: 7..7): BOOLEAN _ FALSE ]; ControllerType: TYPE = MACHINE DEPENDENT {type440Controller(0), type450Controller(1), type472Controller(2), nonExistent(3)}; StatusByte2: TYPE = MACHINE DEPENDENT { success(0), intPending(1), busyConflict(3), operationTimeOut(4), headerNotFound(5), hardECCError(6), illegalCylAdd(7), sectorSlipError(9), illegalSectorAdd(0AH), lastSectorTooSmall(0DH), slaveACKError(0EH), cylAndHeadHeaderError(12H), seekRetry(13H), writeProtectError(14H), unimplementedCommand(15H), driveNotReady(16H), sectorCountZero(17H), driveFaulted(18H), illegalSectorSize(19H), selfTestA(1AH), selfTestB(1BH), selfTestC(1CH), softECCError(1EH), softECCErrorRecovered(1FH), illegalHeadError(20H), diskSequencerError(21H), seekError(25H), (0FFH) }; Throttle: TYPE = MACHINE DEPENDENT RECORD [ byteMode (0: 0..0): BOOLEAN _ FALSE, interleaveFactor (0: 1..4): [0..15] _ 0, -- n+1 to 1 interleave factor, 0 => 1:1 throttleSetting (0: 5..7): [0..7] _ 5 -- 2**(n+1) DMA cycles per burst, ]; -- 5 => 32 words per burst DriveTypeAndSelect: TYPE = MACHINE DEPENDENT RECORD [ driveType (0: 0..1): DriveType _ cyl823Sect32Head19, reserved (0: 2..5): BOOLEAN _ FALSE, unit (0: 6..7): Unit _ 0 ]; DriveType: TYPE = MACHINE DEPENDENT {cyl823Sect32Head19 (0), cyl823Sect32Head5 (1), cyl842Sect46Head20 (2), cyl2047Sect128Head255 (3)}; SectorCountLow: TYPE = MACHINE DEPENDENT RECORD [ SELECT OVERLAID * FROM writeSectorCountLow => [bits: [0..256)], readDriveStatus => [iOPBByteA: IOPBByteA], ENDCASE]; IOPBByteA: TYPE = MACHINE DEPENDENT RECORD [ notOnCylinder (0: 0..0): BOOLEAN, diskNotReady (0: 1..1): BOOLEAN, diskWriteProtect (0: 2..2): BOOLEAN, dualPortDriveBusy (0: 3..3): BOOLEAN, hardSeekError (0: 4..4): BOOLEAN, diskFault (0: 5..5): BOOLEAN, reserved (0: 6..7): BOOLEAN _ FALSE ]; -- PUBLIC PROCEDURES ActivateIOPB: ENTRY PROC [hyperOffset: LONG CARDINAL] = BEGIN wordAdd: LONG CARDINAL _ LOOPHOLE[DicentraDiskDriverUtils.hyperStart]; byteAdd: LONG CARDINAL _ (wordAdd + hyperOffset) * 2; WriteByte[Inline.LowByte[Inline.LowHalf[byteAdd]], iOPBAddLow]; Dally[]; WriteByte[Inline.HighByte[Inline.LowHalf[byteAdd]], iOPBAddHigh]; Dally[]; WriteByte[Inline.LowByte[Inline.HighHalf[byteAdd]], iOPBRelocLow]; Dally[]; WriteByte[Inline.HighByte[Inline.HighHalf[byteAdd]], iOPBRelocHigh]; Dally[]; WriteByte[goBusy, controlStatus]; WHILE DiskControllerBusy[] DO WAIT cv^; ENDLOOP; WriteByte[intPending, controlStatus]; WriteByte[0, controlStatus]; END; DiskControllerBusy: PROC [] RETURNS [BOOLEAN] = BEGIN bits: CARDINAL _ ReadByte[controlStatus]; RETURN[Inline.BITAND[bits, goBusy] # 0]; END; RawFormat: PUBLIC PROC [unit: Unit _ 0, cmdOffset: CARDINAL] RETURNS [noHardErrors: BOOLEAN] = -- Formats all available sectors (leaves no spares). Only returns FALSE on a double -- error. Should never happen. This code only tries to format 32 sectors per track. -- By changing the drive switches and issuing 'setDriveSize' commands this can be increased to -- 34 sectors per track. CDC9766 compatability is easier for now since it is wired in the -- controller EPROM. BEGIN CylinderFormat: PROC [cylinder: Cylinder] RETURNS [status: StatusByte2] = BEGIN p: LONG POINTER _ @formatPB; formatPB: IOPB _ [ diskCommand: [command: writeFormat], driveTypeAndSelect: [unit: unit], headAdd: 0, sectorAdd: 0, sectorCountLow: Inline.LowByte[sectorsPerTrack * tracksPerCylinder], sectorCountHigh: Inline.HighByte[sectorsPerTrack * tracksPerCylinder] ]; formatPB.cylAddLow _ Inline.LowByte[cylinder]; formatPB.cylAddHigh _ Inline.HighByte[cylinder]; DicentraDiskDriverUtils.HyperStore[sourcePtr: p, destOffset: cmdOffset, wordCount: SIZE[IOPB]]; ActivateIOPB[hyperOffset: cmdOffset]; DicentraDiskDriverUtils.HyperRead[destPtr: p, sourceOffset: cmdOffset, wordCount: SIZE[IOPB]]; RETURN [formatPB.statusByte2]; END; hardError: BOOLEAN _ FALSE; result: StatusByte2; OthelloDefs.WriteLine["Begin Format"]; FOR currentCyl: CARDINAL IN [0..cylindersPerSpindle) DO ProcessorFace.SetMP[currentCyl]; FOR retry: CARDINAL IN [0..3) DO result _ CylinderFormat [cylinder: currentCyl]; IF DoubleError[] THEN LOOP; IF GoodCompletionCode[result] THEN EXIT; OthelloDefs.WriteString["Retry at Cylinder: "]; OthelloDefs.WriteLongNumber[currentCyl]; OthelloDefs.NewLine[]; REPEAT FINISHED => BEGIN OthelloDefs.WriteLine["ERROR: Hard Error on Format"]; hardError _ TRUE; END; ENDLOOP; ENDLOOP; OthelloDefs.WriteLine["Format Done"]; RETURN [hardError]; END; Read: PUBLIC PROC [head: Head, sector: Sector, cylinder: Cylinder, unit: Unit _ 0, sectorCount: CARDINAL, cmdOffset: CARDINAL, dataOffset: LONG CARDINAL] RETURNS [success: BOOLEAN] = BEGIN RawRead: PROC [] RETURNS [status: StatusByte2] = BEGIN wordAdd: LONG CARDINAL _ LOOPHOLE[DicentraDiskDriverUtils.hyperStart]; byteAdd: LONG CARDINAL _ (wordAdd + dataOffset) * 2; p: LONG POINTER _ @readPB; readPB: IOPB _ [diskCommand: [relocate: TRUE, command: read]]; readPB.driveTypeAndSelect.unit _ unit; readPB.headAdd _ head; readPB.sectorAdd _ sector; readPB.cylAddLow _ Inline.LowByte[cylinder]; readPB.cylAddHigh _ Inline.HighByte[cylinder]; readPB.sectorCountLow _ Inline.LowByte[sectorCount]; readPB.sectorCountHigh _ Inline.HighByte[sectorCount]; readPB.dataAddLow _ Inline.LowByte[Inline.LowHalf[byteAdd]]; readPB.dataAddHigh _ Inline.HighByte[Inline.LowHalf[byteAdd]]; readPB.dataRelocLow _ Inline.LowByte[Inline.HighHalf[byteAdd]]; DicentraDiskDriverUtils.HyperStore[sourcePtr: p, destOffset: cmdOffset, wordCount: SIZE[IOPB]]; ActivateIOPB[hyperOffset: cmdOffset]; DicentraDiskDriverUtils.HyperRead[destPtr: p, sourceOffset: cmdOffset, wordCount: SIZE[IOPB]]; RETURN [readPB.statusByte2]; END; bits: CARDINAL; result: StatusByte2; FOR retry: CARDINAL IN [0..3) DO result _ RawRead[]; IF DoubleError[] THEN LOOP; IF GoodCompletionCode[result] THEN EXIT; OthelloDefs.WriteString["Retry...StatusByte2: "]; OthelloDefs.WriteOctal[bits _ LOOPHOLE[result]]; OthelloDefs.NewLine[]; REPEAT FINISHED => BEGIN OthelloDefs.WriteString["ERROR: Hard Read Error at Cylinder: "]; OthelloDefs.WriteLongNumber[cylinder]; OthelloDefs.WriteString[" Head: "]; OthelloDefs.WriteLongNumber[head]; OthelloDefs.WriteString[" Sector: "]; OthelloDefs.WriteLongNumber[sector]; OthelloDefs.NewLine[]; ERROR; END; ENDLOOP; RETURN[TRUE]; END; Write: PUBLIC PROC [head: Head, sector: Sector, cylinder: Cylinder, unit: Unit _ 0, sectorCount: CARDINAL, cmdOffset: CARDINAL, dataOffset: LONG CARDINAL] RETURNS [success: BOOLEAN] = BEGIN RawWrite: PROC [] RETURNS [status: StatusByte2] = BEGIN wordAdd: LONG CARDINAL _ LOOPHOLE[DicentraDiskDriverUtils.hyperStart]; byteAdd: LONG CARDINAL _ (wordAdd + dataOffset) * 2; p: LONG POINTER _ @writePB; writePB: IOPB _ [diskCommand: [relocate: TRUE, command: write]]; writePB.driveTypeAndSelect.unit _ unit; writePB.headAdd _ head; writePB.sectorAdd _ sector; writePB.cylAddLow _ Inline.LowByte[cylinder]; writePB.cylAddHigh _ Inline.HighByte[cylinder]; writePB.sectorCountLow _ Inline.LowByte[sectorCount]; writePB.sectorCountHigh _ Inline.HighByte[sectorCount]; writePB.dataAddLow _ Inline.LowByte[Inline.LowHalf[byteAdd]]; writePB.dataAddHigh _ Inline.HighByte[Inline.LowHalf[byteAdd]]; writePB.dataRelocLow _ Inline.LowByte[Inline.HighHalf[byteAdd]]; DicentraDiskDriverUtils.HyperStore[sourcePtr: p, destOffset: 0, wordCount: SIZE[IOPB]]; ActivateIOPB[hyperOffset: 0]; DicentraDiskDriverUtils.HyperRead[destPtr: p, sourceOffset: 0, wordCount: SIZE[IOPB]]; RETURN [writePB.statusByte2]; END; bits: CARDINAL; result: StatusByte2; FOR retry: CARDINAL IN [0..3) DO result _ RawWrite []; IF DoubleError[] THEN LOOP; IF GoodCompletionCode[result] THEN EXIT; OthelloDefs.WriteString["Retry...StatusByte2: "]; OthelloDefs.WriteOctal[bits _ LOOPHOLE[result]]; OthelloDefs.NewLine[]; REPEAT FINISHED => BEGIN OthelloDefs.WriteString["ERROR: Hard Write Error at Cylinder "]; OthelloDefs.WriteLongNumber[cylinder]; OthelloDefs.WriteString[" Head: "]; OthelloDefs.WriteLongNumber[head]; OthelloDefs.WriteString[" Sector: "]; OthelloDefs.WriteLongNumber[sector]; OthelloDefs.NewLine[]; ERROR; END; ENDLOOP; RETURN[TRUE]; END; Seek: PUBLIC PROC [head: Head _ 0, cylinder: Cylinder _ 0, unit: Unit _ 0, cmdOffset: CARDINAL] RETURNS [success: BOOLEAN] = BEGIN RawSeek: PROC [] RETURNS [status: StatusByte2] = BEGIN p: LONG POINTER _ @seekPB; seekPB: IOPB _ [diskCommand: [relocate: TRUE, command: seek]]; seekPB.driveTypeAndSelect.unit _ unit; seekPB.headAdd _ head; seekPB.cylAddLow _ Inline.LowByte[cylinder]; seekPB.cylAddHigh _ Inline.HighByte[cylinder]; DicentraDiskDriverUtils.HyperStore[sourcePtr: p, destOffset: 0, wordCount: SIZE[IOPB]]; ActivateIOPB[hyperOffset: 0]; DicentraDiskDriverUtils.HyperRead[destPtr: p, sourceOffset: 0, wordCount: SIZE[IOPB]]; RETURN [seekPB.statusByte2]; END; bits: CARDINAL; result: StatusByte2; -- The controller does automatic retries, but I'll do them as well... FOR retry: CARDINAL IN [0..3) DO result _ RawSeek[]; IF DoubleError[] THEN LOOP; IF GoodCompletionCode[result] THEN EXIT; OthelloDefs.WriteString["Retry...StatusByte2: "]; OthelloDefs.WriteOctal[bits _ LOOPHOLE[result]]; OthelloDefs.NewLine[]; REPEAT FINISHED => BEGIN OthelloDefs.WriteString["ERROR: Hard Seek Error at Cylinder "]; OthelloDefs.WriteLongNumber[cylinder]; OthelloDefs.WriteString[" Head: "]; OthelloDefs.WriteLongNumber[head]; OthelloDefs.NewLine[]; RETURN[FALSE]; END; ENDLOOP; RETURN[TRUE]; END; DoubleError: PROC [] RETURNS [BOOLEAN] = BEGIN bits: CARDINAL; IF Inline.BITAND[bits _ ReadByte[controlStatus], doubleError] # 0 THEN BEGIN ErrorReset[]; DriveReset []; OthelloDefs.WriteString["ERROR: Double Error...CSR: "]; OthelloDefs.WriteOctal[bits]; OthelloDefs.NewLine[]; RETURN[TRUE]; END; RETURN[FALSE]; END; DriveReset: PROC [] = BEGIN p: LONG POINTER _ @resetPB; resetPB: IOPB _ [diskCommand: [relocate: TRUE, command: driveReset]]; DicentraDiskDriverUtils.HyperStore[sourcePtr: p, destOffset: 0, wordCount: SIZE[IOPB]]; ActivateIOPB[hyperOffset: 0]; END; ControllerReset: PROC [] = BEGIN -- reading has the side effect of resetting the controller, selecting drive 0, -- and testing the drive ready status bits: CARDINAL _ ReadByte[controllerResetAndUpdate]; Dally[100]; END; ErrorReset: PROC [] = BEGIN bits: CARDINAL; WriteByte[generalError, controlStatus]; Dally[]; IF Inline.BITAND[bits _ ReadByte[controlStatus], doubleError] # 0 OR Inline.BITAND[bits _ ReadByte[controlStatus], generalError] # 0 THEN OthelloDefs.WriteLine["ERROR ERROR: Could not clear error status"]; END; GoodCompletionCode: PROC [status: StatusByte2] RETURNS [BOOLEAN] = BEGIN bits: CARDINAL; IF Inline.BITAND[bits _ ReadByte[controlStatus], generalError] # 0 THEN BEGIN ErrorReset[]; OthelloDefs.WriteString["ERROR: General Error bit set...StatusByte2: "]; OthelloDefs.WriteOctal[bits _ LOOPHOLE[status]]; OthelloDefs.NewLine[]; END; SELECT status FROM success, seekRetry, softECCErrorRecovered => RETURN[TRUE]; operationTimeOut, headerNotFound, hardECCError => RETURN[FALSE]; cylAndHeadHeaderError, driveFaulted, driveNotReady, seekError => BEGIN ControllerReset[]; DriveReset[]; RETURN[FALSE]; END; intPending, busyConflict, illegalCylAdd, illegalSectorAdd, unimplementedCommand, sectorCountZero, illegalSectorSize, selfTestA, selfTestB, selfTestC, illegalHeadError => BEGIN OthelloDefs.WriteLine["ERROR: Program error or hard failure"]; ERROR; END; sectorSlipError => BEGIN OthelloDefs.WriteLine["ERROR: Sector Slip Error"]; ERROR; END; slaveACKError => BEGIN OthelloDefs.WriteLine["ERROR: XACK timeout"]; ERROR; END; lastSectorTooSmall, illegalSectorSize => BEGIN OthelloDefs.WriteLine["ERROR: Formatting Error, check drive configuration"]; ERROR; END; writeProtectError => BEGIN OthelloDefs.WriteLine["ERROR: Write Protect Error"]; ERROR; END; ENDCASE => BEGIN OthelloDefs.WriteLine["ERROR: Unknown Type"]; ERROR; END; END; Dally: PROC [i: CARDINAL _ 10] = BEGIN FOR j: CARDINAL IN [0..i) DO ENDLOOP; END; DiskInitialCheckout: PUBLIC PROC [] = BEGIN bits: CARDINAL _ 0; WHILE TRUE DO ControllerReset[]; bits _ Inline.BITAND[driveReady, ReadByte[controlStatus]]; Dally[]; IF bits # 0 THEN EXIT; OthelloDefs.WriteLine["Drive 0 Offline: Make sure drive is spun up and the A-access light is lit"]; Process.Pause[Process.SecondsToTicks[2]]; ENDLOOP; END; ReadDriveStatus: PUBLIC PROC [unit: Unit _ 0] RETURNS [] = BEGIN bits: CARDINAL; p: LONG POINTER _ @rdsPB; rdsPB: IOPB _ [ diskCommand: [relocate: TRUE, command: readDriveStatus], driveTypeAndSelect: [unit: unit] ]; DicentraDiskDriverUtils.HyperStore[sourcePtr: p, destOffset: 0, wordCount: SIZE[IOPB]]; ActivateIOPB[hyperOffset: 0]; DicentraDiskDriverUtils.HyperRead[destPtr: p, sourceOffset: 0, wordCount: SIZE[IOPB]]; OthelloDefs.WriteString["Status (see pg. 47 of controller manual): "]; OthelloDefs.WriteOctal[bits _ LOOPHOLE[rdsPB.statusByte2]]; OthelloDefs.WriteLine["B"]; OthelloDefs.WriteString["Max Head: "]; OthelloDefs.WriteLongNumber[bits _ LOOPHOLE[rdsPB.headAdd]]; OthelloDefs.WriteLine[""]; OthelloDefs.WriteString["Max Sector: "]; OthelloDefs.WriteLongNumber[bits _ LOOPHOLE[rdsPB.sectorAdd]]; OthelloDefs.WriteLine[""]; OthelloDefs.WriteString["Max Cylinder: "]; bits _ (CARDINAL[rdsPB.cylAddHigh] * 256) + CARDINAL[rdsPB.cylAddLow]; OthelloDefs.WriteLongNumber[bits]; OthelloDefs.WriteLine[""]; OthelloDefs.WriteString["Head Offset: "]; OthelloDefs.WriteLongNumber[bits _ LOOPHOLE[rdsPB.headOffset]]; OthelloDefs.WriteLine[""]; OthelloDefs.WriteString["Firmware Rev: "]; OthelloDefs.WriteOctal[bits _ LOOPHOLE[rdsPB.sectorCountHigh]]; OthelloDefs.WriteLine["B"]; OthelloDefs.WriteString["Sector Size: "]; bits _ (CARDINAL[rdsPB.dataAddHigh] * 256) + CARDINAL[rdsPB.dataAddLow]; OthelloDefs.WriteLongNumber[bits]; OthelloDefs.WriteLine[""]; OthelloDefs.WriteString["Disk Sectors per Track (including runts): "]; OthelloDefs.WriteLongNumber[bits _ LOOPHOLE[rdsPB.dataRelocLow]]; OthelloDefs.WriteLine[""]; END; SelfTest: PUBLIC PROC [] = BEGIN bits: CARDINAL; p: LONG POINTER _ @stPB; stPB: IOPB _ [diskCommand: [command: selfTest]]; DicentraDiskDriverUtils.HyperStore[sourcePtr: p, destOffset: 0, wordCount: SIZE[IOPB]]; ActivateIOPB[hyperOffset: 0]; DicentraDiskDriverUtils.HyperRead[destPtr: p, sourceOffset: 0, wordCount: SIZE[IOPB]]; OthelloDefs.WriteString["SelfTest: StatusByte1: "]; OthelloDefs.WriteOctal[bits _ LOOPHOLE[stPB.statusByte1]]; OthelloDefs.WriteString[" StatusByte2: "]; OthelloDefs.WriteOctal[bits _ LOOPHOLE[stPB.statusByte2]]; OthelloDefs.NewLine[]; END; NoOp: PROC [] = BEGIN bits: CARDINAL; p: LONG POINTER _ @noPB; noPB: IOPB _ [diskCommand: [command: noOp]]; DicentraDiskDriverUtils.HyperStore[sourcePtr: p, destOffset: 0, wordCount: SIZE[IOPB]]; ActivateIOPB[hyperOffset: 0]; DicentraDiskDriverUtils.HyperRead[destPtr: p, sourceOffset: 0, wordCount: SIZE[IOPB]]; OthelloDefs.WriteString["NoOp: StatusByte1: "]; OthelloDefs.WriteOctal[bits _ LOOPHOLE[noPB.statusByte1]]; OthelloDefs.WriteString[" StatusByte2: "]; OthelloDefs.WriteOctal[bits _ LOOPHOLE[noPB.statusByte2]]; OthelloDefs.NewLine[]; END; -- BEWARE HACKED TO BE BACKWARDS baseAddress: DicentraInputOutput.IOAddress = LOOPHOLE[LONG[4000H]]; ReadByte: PROC [y: DiskControllerRegister] RETURNS [CARDINAL] = BEGIN byteOffset: CARDINAL = y.ORD; IF (byteOffset MOD 2) # 0 THEN RETURN[DicentraInputOutput.InputByteEven[baseAddress+byteOffset/2]] ELSE RETURN[DicentraInputOutput.InputByteOdd[baseAddress+byteOffset/2]]; END; WriteByte: PROC [x: CARDINAL, y: DiskControllerRegister] = BEGIN byteOffset: CARDINAL = y.ORD; IF (byteOffset MOD 2) # 0 THEN DicentraInputOutput.OutputByteEven[x, baseAddress+byteOffset/2] ELSE DicentraInputOutput.OutputByteOdd[x, baseAddress+byteOffset/2]; END; cv: LONG POINTER TO CONDITION; mask: WORD; [cv, mask] _ SpecialRuntime.AllocateNakedCondition[]; [] _ DicentraInputOutput.SetWakeupMask[bits: mask, intLevel: disk]; Process.SetTimeout[cv, Process.SecondsToTicks[2]]; DiskInitialCheckout[]; END.