TeledebugImpl.mesa (last edited by: Forrest September 17, 1980 2:27 PM)
This is an initial, ugly, ugly, implementation.
Last Edited by: Birrell, October 31, 1983 12:13 pm
DIRECTORY
Basics USING [ LongDivMod ],
GermPrivate USING[ Assoc, Error, GetF, IsVacant, Value ],
MiniEthernetDefs USING [ActivateDriver, KillDriver, RecvPacket, ReturnPacket],
MPCodes USING [germDeviceError],
PrincOps USING [PageNumber, wordsPerPage],
PrincOpsUtils USING [AddressForPageNumber, BITAND, LongCOPY, LowHalf],
PupTypes,
SA4000Face,
TeledebugProtocol;
TeledebugImpl: PROGRAM
IMPORTS Basics, GermPrivate, MiniEthernetDefs, PrincOpsUtils, SA4000Face
EXPORTS GermPrivate--TeleDebug-- =
BEGIN
Ethernet buffer. This is merely storage for MiniDriver
bufSize: CARDINAL = 300;
fudge: CARDINAL = 30;
eBuff: ARRAY [0..bufSize + fudge + 3) OF UNSPECIFIED;
eBuffer: POINTER = PrincOpsUtils.BITAND[@eBuff + 3, 177774B];
etherIOCBSize: CARDINAL = 30;
"Locals" to Debug and RunDisk
MyPup: TYPE = RECORD [
SELECT OVERLAID * FROM
a => [coreStoreRequest: TeledebugProtocol.CoreStoreRequest],
b => [coreStoreAcknowledgement: TeledebugProtocol.CoreStoreAcknowledgement],
c => [coreFetchRequest: TeledebugProtocol.CoreFetchRequest],
d => [coreFetchAcknowledgement: TeledebugProtocol.CoreFetchAcknowledgement],
e => [diskStoreRequest: TeledebugProtocol.DiskStoreRequest],
f => [diskStoreAcknowledgement: TeledebugProtocol.DiskStoreAcknowledgement],
g => [diskFetchAcknowledgement: TeledebugProtocol.DiskFetchAcknowledgement],
h => [diskAddressSetRequest: TeledebugProtocol.DiskAddressSetRequest],
i => [diskAddressSetAcknowledgement:
TeledebugProtocol.DiskAddressSetAcknowledgement],
ENDCASE];
diskAddressPup: TeledebugProtocol.DiskAddressSetRequest;
bytes: INTEGER;
id: PupTypes.Pair;
pAllocateNext: LONG POINTER TO UNSPECIFIED; -- iocb's and stuff in first 64K
pup: MyPup;
sa4000IOCB: LONG POINTER TO SA4000Face.Operation;
sender: PupTypes.PupAddress;
temp: CARDINAL;
type: PupTypes.PupType;
TeleDebug: PUBLIC PROC [
scratchPage: PrincOps.PageNumber,
dFirst64KStorage: LONG DESCRIPTOR FOR ARRAY OF WORD] =
BEGIN
Allocate: PROC [size: CARDINAL] RETURNS [lp: LONG POINTER TO UNSPECIFIED] =
{pAllocateNext ← (lp ← pAllocateNext) + LONG[((size + 15)/16)*16]};
LongTime: PROC RETURNS [BOOLEAN] = {RETURN[FALSE]};
SetNoLabel: PROC [p: LONG POINTER] =
BEGIN
p^ ← -1; PrincOpsUtils.LongCOPY[from: p, to: p + 1, nwords: SIZE[TeledebugProtocol.Label] - 1];
END;
pAllocateNext ← BASE[dFirst64KStorage]; -- reset first 64K allocator
SA4000Face.Initialize[0,
LOOPHOLE[PrincOpsUtils.LowHalf[Allocate[SA4000Face.globalStateSize]]]];
sa4000IOCB ← Allocate[SA4000Face.operationSize];
IF ~MiniEthernetDefs.ActivateDriver[
eBuffer, bufSize, Allocate[etherIOCBSize], TRUE] THEN
GermPrivate.Error[MPCodes.germDeviceError];
DO
sender ← [[0], [0], [0, 0]]; -- talk to anybody
[bytes, id, type] ← MiniEthernetDefs.RecvPacket[
@sender, TeledebugProtocol.teleSwatSocket, @pup, SIZE[MyPup], LongTime];
SELECT type FROM
TeledebugProtocol.coreFetchRequest =>
BEGIN OPEN p: pup.coreFetchAcknowledgement;
pPage: PrincOps.PageNumber = p.page;
IF bytes # (2*SIZE[TeledebugProtocol.CoreFetchRequest]) THEN LOOP;
IF ~GermPrivate.IsVacant[pPage] THEN
BEGIN
p.flags ← LOOPHOLE[GermPrivate.GetF[pPage]];
PrincOpsUtils.LongCOPY[
from: PrincOpsUtils.AddressForPageNumber[pPage], to: @p.data, nwords: PrincOps.wordsPerPage];
GermPrivate.Assoc[pPage, LOOPHOLE[p.flags]];
END
ELSE p.flags ← TeledebugProtocol.vacantFlag;
bytes ← 2*TeledebugProtocol.coreFetchAcknowledgementSize;
END;
TeledebugProtocol.coreStoreRequest =>
BEGIN OPEN p: pup.coreStoreRequest;
pPage: PrincOps.PageNumber = p.page;
IF bytes # (2*SIZE[TeledebugProtocol.CoreStoreRequest]) THEN LOOP;
IF ~GermPrivate.IsVacant[pPage] THEN
BEGIN
v: GermPrivate.Value ← GermPrivate.GetF[pPage];
v.flags.readonly ← FALSE;
GermPrivate.Assoc[pPage, v];
PrincOpsUtils.LongCOPY[
to: PrincOpsUtils.AddressForPageNumber[pPage], from: @p.data, nwords: PrincOps.wordsPerPage];
GermPrivate.Assoc[pPage, LOOPHOLE[p.flags]];
END
ELSE p.flags ← TeledebugProtocol.vacantFlag;
bytes ← 2*TeledebugProtocol.coreStoreAcknowledgementSize;
END;
TeledebugProtocol.diskAddressSetRequest =>
BEGIN
IF bytes # (2*SIZE[TeledebugProtocol.DiskAddressSetRequest]) THEN LOOP;
PrincOpsUtils.LongCOPY[ -- just save it.
to: @diskAddressPup, from: @pup.diskAddressSetRequest,
nwords: SIZE[TeledebugProtocol.DiskAddressSetRequest]];
END;
TeledebugProtocol.diskFetchRequest =>
BEGIN OPEN p: pup.diskFetchAcknowledgement;
SELECT bytes FROM
0 => NULL;
2*SIZE[TeledebugProtocol.DiskAddressSetRequest] =>
PrincOpsUtils.LongCOPY[ -- save disk address request.
to: @diskAddressPup, from: @pup.diskAddressSetRequest,
nwords: SIZE[TeledebugProtocol.DiskAddressSetRequest]];
ENDCASE => LOOP; -- illegal request
IF ~RunDisk[vrr, scratchPage, @p.label, @p.data] THEN SetNoLabel[@p.label];
bytes ← 2*TeledebugProtocol.diskFetchAcknowledgementSize;
END;
TeledebugProtocol.diskStoreRequest =>
BEGIN OPEN p: pup.diskStoreRequest;
IF bytes # (2*SIZE[TeledebugProtocol.DiskStoreRequest]) THEN LOOP;
IF ~RunDisk[vvw, scratchPage, @p.label, @p.data] THEN
SetNoLabel[@pup.diskStoreAcknowledgement.label];
bytes ← 2*TeledebugProtocol.diskStoreAcknowledgementSize;
END;
TeledebugProtocol.go =>
BEGIN
GoConfirm: PROC RETURNS [BOOLEAN] = INLINE
BEGIN
tenSecondsCount: CARDINAL = LAST[CARDINAL];
MiniEthernetDefs.ReturnPacket[TeledebugProtocol.acknowledgement, @pup, 0];
temp ← tenSecondsCount;
[bytes, id, type] ← MiniEthernetDefs.RecvPacket[
@sender, TeledebugProtocol.teleSwatSocket, @pup, SIZE[MyPup], TenSeconds];
also check id??? (what to do if wrong)
RETURN[bytes = -1 OR type = TeledebugProtocol.goReply];
END;
TenSeconds: PROC RETURNS [BOOLEAN] = {RETURN[(temp ← temp - 1) = 0]};
IF bytes = 0 AND GoConfirm[] THEN {MiniEthernetDefs.KillDriver[]; RETURN}
ELSE LOOP; -- unexpected respose; ignore
END;
ENDCASE => LOOP;
Send ack
MiniEthernetDefs.ReturnPacket[TeledebugProtocol.acknowledgement, @pup, bytes];
ENDLOOP;
END;
RunDisk: PROC [
c: SA4000Face.Command, scratchPage: PrincOps.PageNumber,
labelP, dataP: POINTER] RETURNS [BOOLEAN] =
BEGIN OPEN o: sa4000IOCB, SA4000Face;
IF diskAddressPup.device # sa4000 THEN RETURN[FALSE];
o.device ← nullDeviceHandle;
THROUGH [0..diskAddressPup.deviceOrdinal] DO
IF (o.device ← GetNextDevice[o.device]) = nullDeviceHandle THEN RETURN[FALSE];
ENDLOOP;
[quotient: temp, remainder: o.clientHeader.sector] ← Basics.LongDivMod[
num: diskAddressPup.page, den: GetDeviceAttributes[o.device].sectorsPerTrack];
o.clientHeader.head ← temp MOD GetDeviceAttributes[o.device].movingHeads;
o.clientHeader.cylinder ← temp/GetDeviceAttributes[o.device].movingHeads;
o.labelPtr ← labelP; o.dataPtr ← PrincOpsUtils.AddressForPageNumber[scratchPage];
o.incrementDataPtr ← FALSE; o.command ← c; o.pageCount ← 1;
IF c = vvw THEN
PrincOpsUtils.LongCOPY[from: LONG[dataP], to: o.dataPtr, nwords: PrincOps.wordsPerPage];
THROUGH [0..8) DO
SA4000Face.Initiate[sa4000IOCB];
DO
SELECT SA4000Face.Poll[sa4000IOCB] FROM
inProgress => LOOP;
goodCompletion =>
BEGIN
IF c = vrr THEN PrincOpsUtils.LongCOPY[
to: LONG[dataP], from: o.dataPtr, nwords: PrincOps.wordsPerPage];
RETURN[TRUE];
END;
ENDCASE --ERROR-- => EXIT;
ENDLOOP;
ENDLOOP;
RETURN[FALSE];
END;
END.
LOG
Time: March 21, 1980 6:58 PM By: Forrest Action: Create file
Time: March 24, 1980 11:45 AM By: Forrest Action: initialize sender, fix maxVirtualPages
Time: April 1, 1980 2:53 PM By: Forrest Action: Add Disk Implementation
Time: April 7, 1980 7:11 PM By: Forrest Action: Added SetDiskAddress+Fetch enhancement
Time: April 10, 1980 12:19 PM By: Forrest Action: RCPProtocol => TeledebugProtocol
Time: April 22, 1980 5:41 PM By: McJones Action: Add avoidCleanup: TRUE to ActivateDriver call
Time: June 25, 1980 4:21 PM By: McJones Action: OISDisk=>PilotDisk; OISProcessorFace=>ProcessorFace; SA4000Face.Operation: clientLabel+diskLabel=>labelPtr
Time: September 17, 1980 12:45 PM By: Forrest Action: change to use returnPacket; zero socket each trip around loop; use GetF, Utilities.LongPointerFromPage
Time: May 24, 1983 12:06 pm By: Andrew Birrell Action: Fixed IsVacant for out-of-bounds pages