test: DO; /*********************************************************************** * * Illustrates usage of RQE$Alt$SysReq with various function codes * * README file describes the supported functions. * ***********************************************************************/ $include(/rmx386/inc/rmxplm.ext) $include(/rmx386/inc/error.lit) $include(/rmx386/inc/common.lit) $include(/rmx386/inc/io.lit) RQE$Alt$SysReq: PROCEDURE (cmd, status$p) BYTE EXTERNAL; DECLARE cmd BYTE, status$p POINTER; END RQE$Alt$SysReq; DECLARE /* RQE$Alt$SysReq Programmatic functions */ LOCK$CMD LITERALLY '1', UNLOCK$CMD LITERALLY '2', SWITCH$TO$RMX LITERALLY '3', SWITCH$TO$DOS LITERALLY '4', QUERY$OWNER LITERALLY '5', /* Return values for RQE$Alt$SysReq calls */ DOS$OWNS LITERALLY '0H', RMX$OWNS LITERALLY '0FFH', /* The program breaks to the monitor on any error */ error LITERALLY 'CAUSE$INTERRUPT(3)'; /* Globals */ DECLARE status WORD, dummy BYTE, prev$owner BYTE, current$owner BYTE; /* ----------- Exercise each of the functions in a loop --------- */ DO WHILE 1; /* Infinite loop - terminate with Control-C */ /* * Step 1 ==> Acquire Lock */ current$owner = RQE$alt$sysReq (LOCK$CMD, @status); IF status <> E$OK THEN error; IF current$owner <> RMX$OWNS THEN error; /* current owner must be RMX */ /* * Step 2 ==> Switch to DOS */ prev$owner = RQE$alt$sysReq (SWITCH$TO$DOS, @status); IF status <> E$OK THEN error; IF (prev$owner <> RMX$OWNS) THEN error; /* previous owner must be RMX */ /* * Step 3 ==> Now switch to DOS again - already in DOS */ prev$owner = RQE$alt$sysReq (SWITCH$TO$DOS, @status); IF status <> E$OK THEN error; IF (prev$owner <> DOS$OWNS) THEN error; /* previous owner must be DOS */ /* * Step 4 ==> Query the current owner */ current$owner = RQE$alt$sysReq (QUERY$owner, @status); IF status <> E$OK THEN error; IF (current$owner <> DOS$OWNS) THEN error; /* current owner must be DOS */ /* * Pause for 2 seconds on the DOS screen */ CALL rq$sleep (200, @status); /* * Step 5 ==> Now switch back to RMX */ prev$owner = RQE$alt$sysReq (SWITCH$TO$RMX, @status); IF status <> E$OK THEN error; IF (prev$owner <> DOS$OWNS) THEN error; /* previous owner must be DOS */ /* * Step 6 ==> Now query current owner */ current$owner = RQE$alt$sysReq (QUERY$owner, @status); IF status <> E$OK THEN error; IF (current$owner <> RMX$OWNS) THEN error; /* current owner must be RMX */ /* * Step 7 ==> Now switch to RMX again - already in RMX */ prev$owner = RQE$alt$sysReq (SWITCH$TO$RMX, @status); IF status <> E$OK THEN error; IF (prev$owner <> RMX$OWNS) THEN error; /* previous owner must be RMX */ /* * Pause for 2 seconds on the RMX screen */ CALL rq$sleep (200, @status); /* * Step 8 ==> Release Lock */ dummy = RQE$alt$sysReq (UNLOCK$CMD, @status); IF status <> E$OK THEN error; /* * NOTE!!! * Releasing the lock also allows program termination * on a Control-C. * * A program that holds the lock cannot be deleted since * it has entered a region !!!! */ END; /* Loop forever */ CALL dq$exit (0); END test;