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
DIRECTORY
Basics USING [ LowByte ],
DoveInputOutput USING [ Noop, Peek, Poke ],
SparcSoftcardInit,
PrincOps USING [ PageNumber, RealPageNumber, wordsPerPage ],
Rope USING [ ],
SparcSoftcard,
SparcSoftcardOps;
SparcSoftcardInitImpl:
CEDAR
PROGRAM
IMPORTS Basics, DoveInputOutput, SparcSoftcardOps
EXPORTS SparcSoftcardInit ~ {
OPEN SparcSoftcard, SparcSoftcardOps;
Private procs
PeekPokePeekRestore:
PROC [ byteAddress0:
CARD32, content:
CARD16, byteAddress1:
CARD32 ]
RETURNS [ lowByte:
BYTE ] ~ {
address0: CARD32 ~ byteAddress0/2;
address1: CARD32 ~ byteAddress1/2;
word0: CARD16 ~ DoveInputOutput.Peek[address0];
DoveInputOutput.Poke[address0, content];
{
word1: CARD16 ~ DoveInputOutput.Peek[address1];
lowByte ← Basics.LowByte[word1];
};
DoveInputOutput.Poke[address0, 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 ←
SELECT
TRUE
FROM
( value # magic ) => FALSE,
( valueNot # magicNot ) => FALSE,
ENDCASE => TRUE;
};
InitializeCPandIOPMaps:
PUBLIC
PROC ~ {
iOPEntry, cPEntry: MapEntry;
iOPEntry.vMSpace.name ← iOP;
cPEntry.vMSpace.name ← cP;
FOR i:
INT
IN [0..cedarMemoryExtensionSizeByte/softcardPageSizeByte)
DO
iOPEntry.virtualAddressByte ← cedarMemoryExtensionBaseByte + i * softcardPageSizeByte;
iOPEntry.realAddressByte ← i * softcardPageSizeByte;
WriteMapEntry[iOPEntry];
cPEntry.virtualAddressByte ← cedarMemoryExtensionBaseByte + i * softcardPageSizeByte;
cPEntry.realAddressByte ← i * softcardPageSizeByte;
WriteMapEntry[cPEntry];
ENDLOOP;
};
InsertSoftcardPhyscialMemory:
PUBLIC
PROC [
reclaim:
PROC [ PrincOps.RealPageNumber ] ] ~ {
startingPage:
NAT ~ cedarMemoryExtensionBaseByte / PrincOps.wordsPerPage;
start memory at 1.5 meg in Daybreak adress space
endingPage:
NAT ~ ( cedarMemoryExtensionBaseByte + cedarMemoryExtensionSizeByte ) / 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[];
InsertSoftcardPhyscialMemory[reclaim];
DoveInputOutput.Noop[];
};
ResetSoftcard:
PUBLIC
PROC ~ {
IF ( NOT SoftcardPresent[] ) THEN RETURN;
InitializeCPandIOPMaps[];
DoveInputOutput.Noop[];
};
}.