DeviceCleanup.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Andrew Birrell May 25, 1983 6:18 pm
Russ Atkinson (RRA) January 29, 1985 0:42:02 am PST
Doug Wyatt, February 26, 1985 5:18:32 pm PST
Provides the mechanism for turning devices on/off across germ swaps.
DeviceCleanup: DEFINITIONS
= BEGIN
The following example illustrates how to use this interface:
InitializeSampleCleanup: PROC [<parameters>] = {
item: DeviceCleanup.Item;
reason: DeviceCleanup.Reason;
<private state>
<initialization code - may call other procedures>
Following code loops forever - must not call other procedures except INLINE, fixed frame
DO
reason ← DeviceCleanup.Await[@item];
SELECT reason FROM
turnOff => <code to turn device off>;
turnOn => <code to turn device on>;
disconnect => <code to release resources such as special real memory>;
kill => <code to prepare for demise of controller microcode>;
ENDCASE => NULL <Any select arms irrelevant for a given device may be omitted>
ENDLOOP
};
Reason:
TYPE =
MACHINE
DEPENDENT {
turnOff(0) , -- stop fetches to memory other than to controller status block
turnOn, -- inverse of turnOff
disconnect, -- release resources e.g. special real memory in preparation for booting new system
kill, -- prepare for demise of controller microcode
(255)
};
Item: TYPE [2];
Linkage:
PRIVATE
TYPE =
RECORD [
Await: PROC [POINTER TO Item] RETURNS [Reason],
Perform: PROC [Reason]
];
linkage: PRIVATE Linkage;
Await:
PROC [pItem:
POINTER
TO Item]
RETURNS [Reason]
= INLINE { RETURN[linkage.Await[pItem]] };
Wait until next execution of Perform
Perform:
PROC [reason: Reason]
= INLINE { linkage.Perform[reason] };
Execute each waiting cleanup procedure, passing given reason.
Interrupts should have been previously disabled.
InitializeDeviceCleanup: PRIVATE PROC; -- called early on from DebugNub
END.