DIRECTORY DragOps USING [Word]; DragonStack: CEDAR DEFINITIONS ~ BEGIN DisableInterrupts: PROC; EnableInterrupts: PROC; MarkFrame: PROC ~ INLINE { status: StackedStatusWord _ GetYoungestStatus[]; status.mark _ TRUE; SetYoungestStatus[status]; }; MarkSignalHandler: PROC; SaveStack: PROC ~ INLINE { status: StackedStatusWord; IF GetEldestStatus[].mark THEN RETURN; status _ DragonStack.RemoveBogusFrame[]; DO mark: BOOL _ status.mark; status _ DragonStack.NakedSaveFrame[status]; IF mark THEN EXIT; ENDLOOP; DragonStack.InstallBogusFrame[status]; }; RemoveBogusFrame: PROC [] RETURNS [status: StackedStatusWord]; NakedSaveFrame: PROC[oldStatus: StackedStatusWord] RETURNS[newStatus: StackedStatusWord]; InstallBogusFrame: PROC [oldStatus: StackedStatusWord]; StackedStatusWord: PRIVATE TYPE = MACHINE DEPENDENT RECORD [ version (0: 00..07): [0..255] _ 0, padBits (0: 08..10): [0..7] _ 0, signalHandler (0: 11..11): BOOL _ FALSE, -- TRUE => this is a signalHander frame bogus (0: 12..12): BOOL _ FALSE, -- TRUE => this is the bogus frame mark (0: 13..13): BOOL _ FALSE, -- TRUE => last frame saved by SaveStack userMode (0: 14..14): BOOL _ FALSE, -- TRUE => user, FALSE => kernel trapsEnabled (0: 15..15): BOOL _ FALSE, padByte (0: 16..23): [0..255] _ 0, lBase (0: 24..31): [0..255] _ 0 ]; -- EU local frame base Nacho: TYPE ~ POINTER TO NachoRep; NachoRep: TYPE ~ RECORD [ link: Nacho, -- link to the next elder frame in the process stack nextPC: DragOps.Word, -- the continuation PC for the frame status: StackedStatusWord, -- the saved status register of the procedure others: Nacho, -- the link to the area for more saved registers regs: RegArray -- the saved registers (local variables) ]; RegArray: TYPE ~ ARRAY Reg OF DragOps.Word; Reg: TYPE ~ [0..15]; GetEldestStatus: PRIVATE PROC RETURNS [savedStatus: StackedStatusWord] ~ TRUSTED MACHINE CODE { 090H, 0F2H -- LIP EldestStatus }; SetEldestStatus: PRIVATE PROC [newStatus: StackedStatusWord] ~ TRUSTED MACHINE CODE { 091H, 0F2H -- SIP EldestStatus }; GetYoungestStatus: PRIVATE PROC RETURNS [savedStatus: StackedStatusWord] ~ TRUSTED MACHINE CODE { 090H, 0F0H -- LIP YoungestStatus }; SetYoungestStatus: PRIVATE PROC [newStatus: StackedStatusWord] ~ TRUSTED MACHINE CODE { 091H, 0F0H -- SIP YoungestStatus }; END. ζProcedures intended for more or less public use while in Kernel mode. Intended use: DisableInterrupts ... MarkFrame ... SaveStack Calling these without first disabling interrupts is a no-no. Calling SaveStack without first calling MarkFrame is a no-no. Must NOT be INLINE Disables interrupts in the caller's context when DisableInterrupts returns. Must NOT be INLINE Enables interrupts in the caller's context when EnableInterrupts returns. Notice that in many cases explicit calls to EnableInterrupts are unnecessary: a subsequent RETURN will implicitly enable interrupts. This procedure must be INLINE so it marks the correct frame Marks a frame for the SignalHandler. Must NOT be INLINE. ... saves the stack (updates the current value of the hook EU register). The stack is saved up to (and including) the eldest marked frame. Also updates the framesLeft EU register -- not yet. For excruciating details, see GenStack.mesa. Making this procedure INLINE saves a frame but is otherwise irrelevant. Eldest frame is the bogus frame; if it is marked do nothing bogus frame replaces the marked frame Procedures exported from the machine code generated by GenStack. It is very important that these be called in the order RemoveBogusFrame NakedSaveFrame* InstallBogusFrame passing along the status from returned result to argument at each step. Removes the bogus frame (normally the eldest frame) and returns the status of the new eldest frame. Removes the eldest frame, which must be a real frame and not younger than the marked frame, and returns the status of the new eldest frame. oldStatus should be the status returned by RemoveBogusFrame or the previous call to NakedSaveFrame. Installs a new bogus frame. oldStatus should be the previously returned status from NakedSaveFrame. Private Stuff Types StackedStatusWord must track DragOps.StackedStatusWord which contains the truth about the hardware. the next 3 bits are not interpreted by the hardware the next 2 bits are interpreted by the hardware Κ˜codešΟk ˜ Kšœœ˜K˜—KšΠln œœ ˜šœ˜K˜™EK™;K™K™šΟnœœ˜K™KšœK™KK™—šŸœœ˜K™KšœΟ™ΟK˜—šŸ œœœ˜K™;Kšœ0˜0Kšœ˜Kšœ˜K˜K˜—šŸœœ˜K™9K˜—šŸ œœœ˜Kšœ·™·K˜Kšœ˜K˜K™;Kšœœœ˜&K˜(š˜Kšœœ˜Kšœ,˜,Kšœœ˜Kšœ˜—K™%K˜&K˜K˜——™@™6Kšœ2™2—KšœI™IK˜šŸœœœ˜>K™cK™—šŸœœœ˜YKšœο™ο—K™šŸœœ ˜7Kšœd™d——K™K™ ™™Kšœc™cš œ œœ œœ˜