$compact debug pw(79) rom term_mod: DO; $INCLUDE (:RMX:inc/rmxplm.ext) $if rmx=3 DECLARE SIZE$OF$OFFSET LITERALLY 'DWORD'; $else DECLARE SIZE$OF$OFFSET LITERALLY 'WORD'; $endif DECLARE CONNECTION$OBJECT$TYPE LITERALLY '101H', PARAMETER$OBJECT$TYPE LITERALLY '2', WAIT$FOREVER LITERALLY '0FFFFH', PHYSICAL$FILE$DRIVER LITERALLY '1', READ$WRITE LITERALLY '3', SHARE$ALL LITERALLY '3', DRAU LITERALLY '00001111B', NO$NPX LITERALLY '0', E$OK LITERALLY '0', TRUE LITERALLY '0FFH', FALSE LITERALLY '0', CR LITERALLY '0DH', LF LITERALLY '0AH', FOREVER LITERALLY 'WHILE 1', MY$JOB$DIRECTORY LITERALLY 'SELECTOR$OF(NIL)'; strlen: PROCEDURE (str$ptr) BYTE EXTERNAL; DECLARE str$ptr POINTER; END strlen; termin_task: PROCEDURE PUBLIC; /* termin_task receives messages at term$in$mbox. It performs a * read operation and returns a zero terminated strung to the * response mailbox specified during the receive message. */ DECLARE actual SIZE$OF$OFFSET, bios$response$mbox TOKEN, buffer$token TOKEN, console$token TOKEN, parameter$object$token TOKEN, status WORD, term$in$mbox TOKEN, user$response$mbox TOKEN, buffer BASED buffer$token (128) BYTE; /* Create the mailbox at which keyboard input requests will be received. */ term$in$mbox = rq$create$mailbox (0, @status); /* Catalog the mailbox as "TERMIN" in the parent job. */ parameter$object$token = rq$get$task$tokens (PARAMETER$OBJECT$TYPE, @status); CALL rq$catalog$object (parameter$object$token, term$in$mbox, @(6,'TERMIN'), @status); /* Lookup the open connection for the keyboard. */ console$token = rq$lookup$object (MY$JOB$DIRECTORY, @(7,'CONSOLE'), WAIT$FOREVER, @status); /* Create the response mailbox to be used wth BIOS system calls. */ bios$response$mbox = rq$create$mailbox (0, @status); /* Loop forever, waiting for input requests. */ DO FOREVER; /* Wait for an input request. */ buffer$token = rq$receive$message (term$in$mbox, WAIT$FOREVER, @user$response$mbox, @status); /* Send a read request to the keyboard. */ CALL rq$a$read (console$token, @buffer, SIZE(buffer), bios$response$mbox, @status); /* Wait for a input from the keyboard. */ actual = rq$wait$io (console$token, bios$response$mbox, WAIT$FOREVER, @status); /* The terminal driver will append a after the . * We don't want either of them so zero out the next to last * character. */ IF (actual >= 2) THEN buffer (WORD (actual) - 2) = 0; ELSE buffer (0) = 0; /* Send the zero terminated string back to whomever requested it. */ CALL rq$send$message (user$response$mbox, buffer$token, SELECTOR$OF(NIL), @status); END; /* DO FOREVER */ END termin_task; termout_task: PROCEDURE PUBLIC; /* termout_task expects to receive zero terminated strings at * term$out$mbox. It will then write these strings out to the console. */ DECLARE actual SIZE$OF$OFFSET, bios$response$mbox TOKEN, buffer$token TOKEN, console$token TOKEN, parameter$object$token TOKEN, status WORD, term$out$mbox TOKEN, user$response$mbox TOKEN, buffer BASED buffer$token (1) BYTE; /* Create the mailbox at which console output messages will be received. */ term$out$mbox = rq$create$mailbox (0, @status); /* Catalog the mailbox as "termout" in the parent job. */ parameter$object$token = rq$get$task$tokens (PARAMETER$OBJECT$TYPE, @status); CALL rq$catalog$object (parameter$object$token, term$out$mbox, @(7,'TERMOUT'), @status); /* Lookup the open connection for the console. */ console$token = rq$lookup$object (MY$JOB$DIRECTORY, @(7,'CONSOLE'), WAIT$FOREVER, @status); /* Create the response mailbox to be used wth BIOS system calls. */ bios$response$mbox = rq$create$mailbox (0, @status); /* Loop forever, waiting for output messages. */ DO FOREVER; /* Wait for an output message. */ buffer$token = rq$receive$message (term$out$mbox, WAIT$FOREVER, @user$response$mbox, @status); /* Write the message to the console. */ CALL rq$a$read (console$token, @buffer, strlen(@buffer), bios$response$mbox, @status); /* Wait for the message to be output. */ actual = rq$wait$io (console$token, bios$response$mbox, WAIT$FOREVER, @status); /* Delete the segment which we received at term$out$mbox. */ CALL rq$delete$segment (buffer$token, @status); END; /* DO FOREVER */ END termout_task; term_init_task: PROCEDURE PUBLIC; /* term_init_task is responsible for setting up the connections to * the console and creating the tasks termin_task and termout_task. */ DECLARE bios$response$mbox TOKEN, dummy$mbox TOKEN, iors$token TOKEN, status WORD, term$dev$conn TOKEN, term$file$conn TOKEN, termin$task$token TOKEN, termout$task$token TOKEN, buffer (256) BYTE, sign$on$message (*) BYTE DATA ('Terminal online -- ready for processing.',CR,LF), iors BASED iors$token STRUCTURE ( status WORD, unit$status WORD, actual SIZE$OF$OFFSET); /* Create the response mailbox to be used with BIOS system calls. */ bios$response$mbox = rq$create$mailbox (0, @status); /* Create a device connection to the terminal. */ CALL rq$a$physical$attach$device (@(2,'T0'), PHYSICAL$FILE$DRIVER, bios$response$mbox, @status); /* Wait for the device connection token to be returned by the BIOS. */ term$dev$conn = rq$receive$message (bios$response$mbox, WAIT$FOREVER, NIL, @status); /* Create a file connection on the terminal device. */ CALL rq$a$create$file ( SELECTOR$OF(NIL), /* User token ignored for physical files. */ term$dev$conn, /* device connection */ NIL, /* Subpath ptr ignored for physical files. */ DRAU, /* access bits */ 0,0, /* Granularity and size are ignored for */ /* physical files. */ 0, /* must create flag is FALSE */ bios$response$mbox, @status); /* Wait for the file connection token to be returned by the BIOS. */ term$file$conn = rq$receive$message (bios$response$mbox, WAIT$FOREVER, NIL, @status); /* Open the terminal file for both read and write. */ CALL rq$a$open (term$file$conn, READ$WRITE, SHARE$ALL, bios$response$mbox, @status); /* Wait for the I/O result segment token to be returned by the BIOS. */ iors$token = rq$receive$message (bios$response$mbox, WAIT$FOREVER, NIL, @status); /* Catalog the connection token for the open file in the local * job as "CONSOLE." */ CALL rq$catalog$object (MY$JOB$DIRECTORY, term$file$conn, @(7,'CONSOLE'), @status); /* Create the task that will handle keyboard input. */ termin$task$token = rq$create$task ( 139, /* task priority */ @termin_task, /* task start address */ SELECTOR$OF(@status), /* Initialize the DS since we are in */ /* compact mode. */ NIL, /* Let iRMX assign the stack */ 600H, /* stack size */ NO$NPX, /* This task doesn't use NPX. */ @status); /* Create the task that will handle console output. */ termout$task$token = rq$create$task ( 139, /* task priority */ @termout_task, /* task start address */ SELECTOR$OF(@status), /* Initialize the DS since we are in */ /* compact mode. */ NIL, /* Let iRMX assign the stack */ 600H, /* stack size */ NO$NPX, /* This task doesn't use NPX. */ @status); /* Initialization complete. Goodby cruel world! */ CALL rq$delete$task (SELECTOR$OF(NIL), @status); /* Just in case suicide wasn't successful .... */ IF (status <> E$OK) THEN CAUSE$INTERRUPT (3); END term_init_task; END term_mod;