SparcSoftcardInitImpl.Mesa
Copyright Ó 1988 by Xerox Corporation. All rights reserved.
Christophe Cuenod, September 12, 1988 9:35:17 am PDT
Bill Jackson (bj) April 19, 1988 3:34:37 am PDT
Christian Le Cocq November 1, 1988 3:53:19 pm PST
DIRECTORY
Basics USING [ LowByte, DoubleShiftRight ],
DoveInputOutput USING [ Noop, Peek, Poke ],
SparcSoftcardInit,
PrincOps USING [ PageNumber, RealPageNumber, wordsPerPage ],
SparcSoftcard,
SparcSoftcardMap;
SparcSoftcardInitImpl: PROGRAM
IMPORTS Basics, DoveInputOutput, SparcSoftcardMap
EXPORTS SparcSoftcardInit ~ {
OPEN SparcSoftcard;
Private procs
PeekAtByteAd: PROC [byteAd: CARD32] RETURNS [content: CARD16] ~ {
wordAd: CARD32 ← Basics.DoubleShiftRight[[lc [byteAd]], 1].lc;
content ← DoveInputOutput.Peek[wordAd];
};
PokeAtByteAd: PROC [byteAd: CARD32, content: CARD16] ~ {
wordAd: CARD32 ← Basics.DoubleShiftRight[[lc [byteAd]], 1].lc;
DoveInputOutput.Poke[wordAd, content];
};
PeekPokePeekRestore: PROC [ byteAddress0: CARD32, content: CARD16, byteAddress1: CARD32 ]
RETURNS [ lowByte: BYTE ] ~ {
word0: CARD16 ~ PeekAtByteAd[byteAddress0];
PokeAtByteAd[byteAddress0, content];
{
word1: CARD16 ~ PeekAtByteAd[byteAddress1];
lowByte ← Basics.LowByte[word1];
};
PokeAtByteAd[byteAddress0, word0];
};
Public procs
SoftcardPresent: PUBLIC PROC RETURNS [ present: BOOL ] ~ {
magic: BYTE ~ 05Ah; -- Arbitrary constant
magicNot: BYTE ~ 0A5h; -- Another arbitrary constant
value: BYTE ~ PeekPokePeekRestore[tRegisterByte, magic, tRegisterAlternateByte];
valueNot: BYTE ~ PeekPokePeekRestore[tRegisterAlternateByte, magicNot, tRegisterByte];
present ← (value=magic) AND (valueNot=magicNot);
};
InitializeCPandIOPMaps: PUBLIC PROC ~ {
iOPEntry, cPEntry: SparcSoftcardMap.MapEntry;
iOPEntry.vMSpace.name ← iOP;
cPEntry.vMSpace.name ← cP;
iOPEntry.virtualAddressByte ← cedarMemoryExtensionBaseByte;
iOPEntry.realAddressByte ← 0;
cPEntry.virtualAddressByte ← cedarMemoryExtensionBaseByte;
cPEntry.realAddressByte ← 0;
FOR i: INT IN [0..cedarMemoryExtensionSizeByte/softcardPageSizeByte) DO
SparcSoftcardMap.WriteMapEntry[iOPEntry];
iOPEntry.virtualAddressByte ← iOPEntry.virtualAddressByte + softcardPageSizeByte;
iOPEntry.realAddressByte ← iOPEntry.realAddressByte+softcardPageSizeByte;
SparcSoftcardMap.WriteMapEntry[cPEntry];
cPEntry.virtualAddressByte ← cPEntry.virtualAddressByte+softcardPageSizeByte;
cPEntry.realAddressByte ← cPEntry.realAddressByte+softcardPageSizeByte;
ENDLOOP;
};
InsertSoftcardPhysicalMemory: PUBLIC PROC [
reclaim: PROC [ PrincOps.RealPageNumber ] ] ~ {
startingPage: NAT ~ cedarMemoryExtensionBaseByte / (2*PrincOps.wordsPerPage);
start memory at 1.5 meg in Daybreak adress space
endingPage: NAT ~ (cedarMemoryExtensionBaseByte+cedarMemoryExtensionSizeByte) / (2*PrincOps.wordsPerPage);
end memory at 3.5 meg in Daybreak adress space
FOR p: PrincOps.PageNumber IN [startingPage..endingPage) DO
reclaim[p];
ENDLOOP;
};
InitializeSoftcard: PUBLIC PROC [ reclaim: PROC [ real: PrincOps.RealPageNumber ] ] ~ {
IF ( NOT SoftcardPresent[] ) THEN RETURN;
InitializeCPandIOPMaps[];
InsertSoftcardPhysicalMemory[reclaim];
DoveInputOutput.Noop[];
};
ResetSoftcard: PUBLIC PROC ~ {
IF ( NOT SoftcardPresent[] ) THEN RETURN;
InitializeCPandIOPMaps[];
DoveInputOutput.Noop[];
};
}.