SparcSoftcardOpsImpl.Mesa
Copyright Ó 1988 by Xerox Corporation. All rights reserved.
Christophe Cuenod, October 18, 1988 9:26:44 am PDT
Bill Jackson (bj) April 19, 1988 3:34:37 am PDT
Christian Le Cocq October 31, 1988 9:33:59 am PST
DIRECTORY
Basics USING [ BITAND, HighHalf, LowHalf, DoubleShiftRight],
DoveInputOutput USING [ Peek, Poke ],
SparcSoftcard,
SparcSoftcardOps;
Test for the presence of a Sparc softcard and initialize the map properly for the CP and the IOP.
Daybreak range [1.5 thru 3.5 Mbytes] is mapped onto [0 thru 2.0 Mbytes] of the Sparc softcard.
SparcSoftcardOpsImpl: PROGRAM
IMPORTS Basics, DoveInputOutput
EXPORTS SparcSoftcardOps ~ {
OPEN SparcSoftcard;
Utilities
PeekAtByteAd: PROC [byteAd: CARD32] RETURNS [content: CARD16] ~ {
wordAd: CARD32 ← Basics.DoubleShiftRight[[lc [byteAd]], 1].lc; -- /2
content ← DoveInputOutput.Peek[wordAd];
};
PokeAtByteAd: PROC [byteAd: CARD32, content: CARD16] ~ {
wordAd: CARD32 ← Basics.DoubleShiftRight[[lc [byteAd]], 1].lc; -- /2
DoveInputOutput.Poke[wordAd, content];
};
ControlBitWrite: PUBLIC PROC [ byteAddress: CARD32, polarity: Polarity, value: BOOL ] ~ {
IF ((byteAddress MOD 8) # 7) THEN ERROR;
If error here the address for the control bit is false.
SELECT TRUE FROM
(polarity=ActiveLow) AND value => PokeAtByteAd[byteAddress, 0];
(polarity=ActiveLow) AND (NOT value) => PokeAtByteAd[byteAddress, commandBitMask];
(polarity=ActiveHigh) AND value => PokeAtByteAd[byteAddress, commandBitMask];
(polarity=ActiveHigh) AND (NOT value) => PokeAtByteAd[byteAddress, 0];
ENDCASE;
};
ControlBitRead: PUBLIC PROC [ byteAddress: CARD32, polarity: Polarity ]
RETURNS [ value: BOOL ] ~ {
read: CARD16 ~ Basics.BITAND[commandBitMask, PeekAtByteAd[byteAddress]];
IF ((byteAddress MOD 8) # 7) THEN ERROR;
If error here the address for the control bit is false.
SELECT TRUE FROM
( ( polarity = ActiveLow ) AND ( read = 0) ) => { value ← TRUE };
( ( polarity = ActiveLow ) AND ( read # 0) ) => { value ← FALSE };
( ( polarity = ActiveHigh ) AND ( read = 0) ) => { value ← FALSE };
( ( polarity = ActiveHigh ) AND ( read # 0) ) => { value ← TRUE };
ENDCASE;
};
Sparc Operations
SparcReset: PUBLIC PROC ~ {
ControlBitWrite[sparcResetRegisterByte, sparcResetPolarity, TRUE];
ResetSparcToIOPInt[];
ResetSparcToMesaInt[];
ResetSparcToSparcInt[];
ResetIOPToSparcInt[];
ResetMesaToSparcInt[];
};
SparcResetAndStart: PUBLIC PROC ~ {
ControlBitWrite[sparcResetRegisterByte, sparcResetPolarity, TRUE];
ControlBitWrite[sparcResetRegisterByte, sparcResetPolarity, FALSE];
ResetSparcToIOPInt[];
ResetSparcToMesaInt[];
ResetSparcToSparcInt[];
ResetIOPToSparcInt[];
ResetMesaToSparcInt[];
};
TestSparcError: PUBLIC PROC RETURNS [ error: BOOLEAN ] ~ {
error ← ControlBitRead[sparcErrorRegisterByte, sparcErrorPolarity];
};
Cache Operations
SparcCacheDisable: PUBLIC PROC ~ {
ControlBitWrite[sparcCacheEnableRegisterByte, sparcCacheEnablePolarity, FALSE];
};
Interrupt Operations
SetSparcToIOPInt: PUBLIC PROC ~ {
ControlBitWrite[sparcToIOPIntRegisterByte, sparcToIOPIntPolarity, TRUE];
};
ResetSparcToIOPInt: PUBLIC PROC ~ {
ControlBitWrite[sparcToIOPIntRegisterByte, sparcToIOPIntPolarity, FALSE];
};
SetSparcToMesaInt: PUBLIC PROC ~ {
ControlBitWrite[sparcToMesaIntRegisterByte, sparcToMesaIntPolarity, TRUE];
};
ResetSparcToMesaInt: PUBLIC PROC ~ {
ControlBitWrite[sparcToMesaIntRegisterByte, sparcToMesaIntPolarity, FALSE];
};
SetSparcToSparcInt: PUBLIC PROC ~ {
ControlBitWrite[sparcToSparcIntRegisterByte, sparcToSparcIntPolarity, TRUE];
};
ResetSparcToSparcInt: PUBLIC PROC ~ {
ControlBitWrite[sparcToSparcIntRegisterByte, sparcToSparcIntPolarity, FALSE];
};
SetIOPToSparcInt: PUBLIC PROC ~ {
ControlBitWrite[iOPToSparcIntRegisterByte, iOPToSparcIntPolarity, TRUE];
};
ResetIOPToSparcInt: PUBLIC PROC ~ {
ControlBitWrite[iOPToSparcIntRegisterByte, iOPToSparcIntPolarity, FALSE];
};
SetMesaToSparcInt: PUBLIC PROC ~ {
ControlBitWrite[mesaToSparcIntRegisterByte, mesaToSparcIntPolarity, TRUE];
};
ResetMesaToSparcInt: PUBLIC PROC ~ {
ControlBitWrite[mesaToSparcIntRegisterByte, mesaToSparcIntPolarity, FALSE];
};
SetSparcAbortInt: PUBLIC PROC ~ {
ControlBitWrite[sparcAbortIntRegisterByte, sparcAbortIntPolarity, TRUE];
};
ResetSparcAbortInt: PUBLIC PROC ~ {
ControlBitWrite[sparcAbortIntRegisterByte, sparcAbortIntPolarity, FALSE];
};
EnableInt: PUBLIC PROC ~ {
ControlBitWrite[enableIntRegisterByte, enableIntPolarity, TRUE];
};
DisableInt: PUBLIC PROC ~ {
ControlBitWrite[enableIntRegisterByte, enableIntPolarity, FALSE];
};
DMA Operations
DMAState: TYPE = SparcSoftcardOps.DMAState;
SetDMAState: PUBLIC PROC [dMAState: DMAState] ~ {
IF dMAState = active THEN
ControlBitWrite[dMAActiveRegisterByte, dMAActivePolarity, TRUE]
ELSE
ControlBitWrite[dMAActiveRegisterByte, dMAActivePolarity, FALSE];
};
DMAMode: TYPE = SparcSoftcardOps.DMAMode;
SetDMAMode: PUBLIC PROC [dMAMode: DMAMode]~ {
SELECT dMAMode FROM
= printer => {
ControlBitWrite[dMAMode0RegisterByte, dMAMode0Polarity, FALSE];
ControlBitWrite[dMAMode1RegisterByte, dMAMode1Polarity, FALSE];
};
= display => {
ControlBitWrite[dMAMode0RegisterByte, dMAMode0Polarity, FALSE];
ControlBitWrite[dMAMode1RegisterByte, dMAMode1Polarity, TRUE];
};
= versatecOneShot => {
ControlBitWrite[dMAMode0RegisterByte, dMAMode0Polarity, TRUE];
ControlBitWrite[dMAMode1RegisterByte, dMAMode1Polarity, FALSE];
};
= versatecStream => {
ControlBitWrite[dMAMode0RegisterByte, dMAMode0Polarity, TRUE];
ControlBitWrite[dMAMode1RegisterByte, dMAMode1Polarity, TRUE];
};
ENDCASE;
};
DMAAddressRegisterLoad: PUBLIC PROC [ byteAddress: CARD32 ] ~ {
address: CARD32 ← Basics.DoubleShiftRight[[lc [byteAddress]], 3].lc; -- /8
PokeAtByteAd[dMAAddressRegisterHighByte, Basics.HighHalf[address]];
PokeAtByteAd[dMAAddressRegisterLowByte, Basics.LowHalf[address]];
};
Versatec Operations
VersatecMode: TYPE = SparcSoftcardOps.VersatecMode;
SetVersatecMode: PUBLIC PROC [versatecMode: VersatecMode] ~ {
IF ( versatecMode = print OR versatecMode = SPPPrint ) THEN {
ControlBitWrite[versatecPrintRegisterByte, versatecPrintPolarity, TRUE];
}
ELSE {
ControlBitWrite[versatecPrintRegisterByte, versatecPrintPolarity, FALSE];
};
IF ( versatecMode = SPPPrint OR versatecMode = SPPPlot ) THEN {
ControlBitWrite[versatecSPPRegisterByte, versatecSPPPolarity, TRUE];
}
ELSE {
ControlBitWrite[versatecSPPRegisterByte, versatecSPPPolarity, FALSE];
};
};
VersatecRCommand: TYPE = SparcSoftcardOps.VersatecRCommand;
SendVersatecRCommand: PUBLIC PROC [versatecRCommand: VersatecRCommand] RETURNS [ ok: BOOLEAN ]~ {
Reading the correct location sends the command
byteAddress: CARD32;
SELECT versatecRCommand FROM
= CLEAR =>  byteAddress ← SparcSoftcard.versatecClearByte;
= RESET =>  byteAddress ← SparcSoftcard.versatecResetByte;
= RLTER =>  byteAddress ← SparcSoftcard.versatecRLTERByte;
= RFFED =>  byteAddress ← SparcSoftcard.versatecRFFEDByte;
= REOTR =>  byteAddress ← SparcSoftcard.versatecREOTRByte;
ENDCASE;
[] ← PeekAtByteAd[byteAddress];
};
VersatecCommandTermin: PUBLIC PROC [] RETURNS [terminated: BOOLEAN] ~ {
terminated ← ControlBitRead[pVEndRegisterByte, pVEndPolarity];
};
VersatecSendOneByte: PUBLIC PROC [ byteAddress: CARD32 ] RETURNS [ ok: BOOLEAN ] ~ {
SetDMAState[inactive];
SetDMAMode[versatecOneShot];
DMAAddressRegisterLoad[byteAddress];
SetDMAState[active];
WHILE NOT VersatecCommandTermin[] DO
ENDLOOP;
SetDMAState[inactive];
};
Memory configuration
}.