RTEM Data Structures ==================== Running in RTEM Environment ~~~~~~~~~~~~~~~~~~~~~~~~~~~ In an RTEM environment, RTEM service data and routines are available to programs and drivers. This data and routines are available through the fixed offsets of the RTEM Linkage Area. RSX-11 system directives can be used under RTEM. To check that the system is running under RTEM, you can check the value of the third bit of the SYSGEN Feature Word of RT-11 and check if RTEM Identification Word contains Rafix-50 value of "RTE". ;+ ;RMON fixed offsets and SYSGEN Feature word bits. ;- $SYSGE = 372 ;SYSGEN Feature Word offset RTEM$ = 10 ;RTEM system bit ;+ ;RTEM addresses and ID. ;- $RTELK = 250 ;Pointer to the RTEM Linkage Area $RTEID = 252 ;RTEM Identification Word RTE$ID = ^RRTE ;RTEM ID .GVAL #AREA,#$SYSGE ;Get SYSGEN Feature Word BIT #RTEM$,R0 ;Running under RTEM? BNE 20$ ;Branch if so 10$: .EXIT ;Else exit 20$: CMP #RTE$ID,@#$RTEID ;Is RTEM ID correct? BNE 10$ ;Branch if not MOV @#$RTELK,R5 ;Get address of RTEM Linkage Area RTEM Linkage Area fixed offsets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The following fixed offsets can be used to access RTEM data and routines. Offset Name Filled by Used by Description ------ ------ -------------- ---------------------- -------------------------------------------------------------------------- 000 ? RTEM DUP.SAV Address of VS$SET table. Data in this table gives information about the VSM.SYS private, shared, and read/write temporary files. This information is used by the VS driver to map these three files into a single virtual system device. DUP uses this table to SQUEEZE VS0: system disk. (S) shared, (P) private, (T) r/w temporary, (W) whole VS device Offset Name Image Description 000 VS$SSM S Number of directory segments to map 002 VS$PSM P Number of directory segments to map 004 VS$SDB S Number of last directory block 006 VS$SFW S Number of first r/w block 010 VS$SLW S Number of last r/w block 012 VS$SLB S Number of last file block 014 VS$PDB P Number of last directory block 016 VS$PLB P Number of last file block 020 VS$PHO P Number of highest open directory segment 022 VS$PLU P Private image file LUN 024 VS$SLU S Shared image file LUN 026 VS$TLU T Temporary image file LUN 030 VS$SIZ W Device size 032 VS$BRO W Bootstrap read offset 034 VS$PT1 - Patch space 036 VS$PT2 - ... 040 VS$PT3 - ... Size of table, $VSTSZ is 42 (34. words). If RTEM is not booted from VS0: all the table entries contain 0 except for VS$PLU, VS$SLU and VS$TLU. 002 ? RTEM JOAT.SAV Address of routine that can be used to exit RTEM with the status specified in ESXT DPB pointed to by offset 076. 004 ? RTEM JOAT.SAV Address of routine that can be used to execute RSX-11 directive in RT-11. RTEM.EXE/RTEM.TSK Usage: MOV @#250,R4 ;Get address of RTEM Linkage Area JSR R5,@4(R4) ;Enter RSX-11 mode (this saves @#46) .WORD isb ;Address of QIOW I/O status block or 0 DIR$ #dpb ;Call RSX-11 directive. CALL @(SP)+ ;If directive failed with IE.UPN or QIOW ;...failed with IE.NOD, wait for ;...significant event (RSX only) and try ;...again. BCS err ;Branch if directive or I/O failed. 006 .$CMKT RTEM RT-11 (BSTRAP) Address of $CMKT routine. BSTRAP patches RMON to use this routine to correctly cancel outstanding RSX-11 marktimes. 010 .$CRTI RTEM RT-11 (BSTRAP) Address of $CRTI routine. BSTRAP patches RMON to use this routine to correctly exit a completion routine. 012 .$DARL RTEM RT-11 (BSTRAP) Address of $DARLN routine. BSTRAP patches RMON to use this routine to correctly release RSX-11 LUNs at RT-11 job exit. 014 ? RTEM JOAT.SAV Address of routine that can be used to search for LUN assigned to RT-11 handlers device. This routine searches LUN table pointed to by offset 114 to find the device attached by JOAT.SAV or current RT-11 job. Usage: MOV #^RVS1,R0 ;Set device name MOV @#250,R4 ;Get address of RTEM Linkage Area CALL @14(R4) ;Search for LUN assigned to VS1: BCS err ;Branch if not found ;R0 contains LUN if C=0 016 .$FATA RTEM RT-11 (BSTRAP) Address of $FATAL routine. BSTRAP patches RMON to use this routine to correctly handle fatal system errors. 020 .$FORQ RTEM RT-11 (BSTRAP) Address of $FORQ routine. BSTRAP patches MTTINT to use this routine to correctly switch terminal input interrupts to fork level. 022 .$FPST RTEM RT-11 (BSTRAP) Address of $FPST routine. BSTRAP patches RMON to use this routine to correctly save the FPU status. 024 ? RTEM RTEM.EXE/RTEM.TSK Address of routine that can be used to get system date and time in RT-11 format. This routine uses 8-word GTIM buffer pointed to by offset 106 to get system time in RSX-11 format and converts it to RT-11 date (R2) and RT-11 time (R0:R1). R3-R5 are destroyed. 026 .$GETE RTEM RT-11 (BSTRAP) Address of $GETEN routine. BSTRAP patches RMON to use this routine to correctly handle a switch into System State by disabling RSX-11 AST's. 030 .$GETP RTEM RT-11 (BSTRAP) Address of $GETP routine. BSTRAP patches MTTEMT to use this routine to raise RTEM's effective priority to prevent race conditions by disabling RSX-11 AST's. 032 .$GTDA RTEM RT-11 (BSTRAP) Address of $GTDA routine. BSTRAP patches RMON to use this routine to correctly obtain the date, as the clock never ticks under RTEM. 034 ? RTEM JOAT.SAV Address of routine that can be used to assign LUN to RT-11 device. handlers If the device already attached for current RT-11 job (or RTEM), the routine returns existing LUN for the device. Usage: MOV #^RVS1,R0 ;Device name ;...(use 0 to get free LUN not yet ;...assigned to RT-11 device). MOV #^RRTE,R1 ;Assign device for RTEM ;...(or any other value for current job) MOV @#250,R4 ;Get address of RTEN Linkage Area CALL @34(R4) ;Assign new/get existing LUN for device. BCS err ;Branch if no LUN assigned and there's no ;...free LUN available. ;R0 contains LUN if C=0. 036 .$GTPS RTEM RT-11 (BSTRAP) Address of $GTPSW routine. BSTRAP patches RMON and MTTEMT to use this routine to correctly obtain the PSW in the RTEM environment. 040 .$GTTI RTEM RT-11 (BSTRAP) Address of $GTTI routine. BSTRAP patches RMON to use this routine to correctly obtain the time in the mulated environment, as the clock never ticks under RTEM-11. 042 .$IDLP RTEM RT-11 (BSTRAP) Address of $GTTI routine. BSTRAP patches RMON to use this routine to allow RTEM-11 to correctly become idle, by waiting on the idle loop event flag. 044 .$INTN RTEM RT-11 (BSTRAP) Address of $INTN routine. BSTRAP patches RMON and MTTINT to use this routine to correctly service inturrupts under RTEM-11. 046 ? RTEM handlers Address of routine that can be used to kill I/O on specified LUN. This routine uses QIOW DPB for IO.KIL function pointed to by offset 100. This routine uses EFN 4 for QIOW and after successful completion of IO.KIL stops for EFN equal to specified LUN (if RTEM boots from shared image, this EFN is replaced with 2, the EFN of shared image for LUN of private/temporary image file). Usage: MOV #lun,R4 ;Set LUN MOV @#250,R5 ;Get address of RTEM Linkage Area CALL @46(R5) ;Kill I/O on LUN ;Success ;...(if failed RTEM hants with fatal error) 050 .$MRKT RTEM RT-11 (BSTRAP) Address of $MRKT routine. BSTRAP patches RMON to use this routine to correctly setup a RSX-11 marktime request, since the clock never ticks under RTEM-11. 052 .$PTPS RTEM RT-11 (BSTRAP) Address of $PTPSW routine. BSTRAP patches RMON and MTTEMT to use this routine to correctly set the PSW in the emulated environment. 054 .$RDKM RTEM RT-11 (BSTRAP) Address of $RDKM routine. BSTRAP patches RMON to use this routine to correctly prevent an I/O error from looping indefinitly under RTEM-11 while reading KMON. 056 ? JOAT.SAV Address of routine that can be used to detach LUN from RT-11 device or handlers RSX-11 file and mark LUN as free. Usage: MOV #lun,R0 ;Set LUN MOV #^RRTE,R0 ;Unconditionaly deassign LUN ;...(use any other calue to make sure ;...LUN is used by current job) MOV @#250,R4 ;Get address of RTEM Linkage Area CALL @56(R4) ;Deaasign LUN BCC err ;Branch if we failed 060 .$RQSG RTEM RT-11 (BSTRAP) Address of $RQSIG routine. BSTRAP patches RMON to use this routine to correctly handle job runnability, by terminating the RTEM-11 idle loop. 062 .$RSCT RTEM RT-11 (BSTRAP) Address of $RSCT routine. BSTRAP patches RMON to use this routine to correctly reset CTRL/O under RTEM-11. 064 .$RSTT RTEM RT-11 (BSTRAP) Address of $RSTT routine. BSTRAP patches MTTINT to use this routine to allow terminal output inturrupts to be enabled correctly under RTEM-11. 066 .$RTIC RTEM RT-11 (BSTRAP) Address of $RTIC routine. BSTRAP patches RMON to use this routine to correctly enable AST recognition before returning, using the RTI instruction. 070 .$SPL0 RTEM RT-11 (BSTRAP) Address of $SPL0 routine. BSTRAP patches RMON to use this routine to correctly lower RTEM's effective priority by enabling RSX-11 AST's. 072 .$SPL7 RTEM RT-11 (BSTRAP) Address of $SPL7 routine. BSTRAP patches RMON to use this routine to correctly raise RTEM's effective priority by disabling RSX-11 AST's. 074 ? RTEM ? Address of QIOW DPB. 076 ? RTEM JOAT.SAV RTEM.EXE/RTEM.TSK Address of ESXT DPB. Used by routine pointed to by offset 002. 100 ? RTEM RTEM.EXE/RTEM.TSK Address of QIOW DPB with IO.KIL function and EFN 4. Used by routine pointed to by offset 046. 102 ? RTEM JOAT.SAV Address of QIOW DPB with IO.ATA function, LUN 1 (terminal) and EFN 24., the EFN for system use, max LUN plus 1. 104 ? RTEM ? Address of the table of files attached to VS devices. The table cotains 12 (10.) entries for files, each entry consists of 23 (19.) words. First two file entries are used for VS0 device, for shared and private image files (if RTEM isn't booted from shared image, the second entry isn't used). Next 7 entries are used for VS1-VS7. Entry format: 000 Status word and RT-11 job number plus 1 or 0 if the device is attached to RTEM. Status bits: 100000 - Read-only access to VS device 40000 - Entry used for open file 10000 - File opened in read-only mode 400 - Temporay file open 200 - VS device can't be detached via JOAT /D 002 File size in blocks. If RTEM booted from shared image, the first entry contains size of the whole VS0: disk. 004 RSX-11 file name in Rasix-50 006 " 010 " 012 RSX-11 file type in Radix-50 014 RSX-11 file version 016 RSX-11 device name in ASCII 020 RSX-11 device unit number 022 RSX-11/VMS directory name 024 " 026 " 030 " 032 " 034 " 036 " 040 " 042 " 044 " 106 ? RTEM RTEM.EXE/RTEM.TSK Address of 8.-word GTIM buffer. Used by routine pointed to by offset 024. 110 ? RTEM JOAT.SAV Address of RTEM-11 parameter table. RTEM.EXE/RTEM.TSK 000 RTEM option mask: VSM.SYS 000004 Booted from shared image 000002 RPA terminal mode is enabled 000001 Try to create contiguous image files 002 Used by FPP AST and $FPST routine to save FPP status 004 " 006 Host system ID: 1 RSX-11M 5 VAX/VMS 6 RSX-11M-PLUS or Micro/RSX 11 P/OS 010 Spool device name in ASCII 012 Spool directory File ID 014 " 016 " 020 Spool directory name in ASCII (UIC format) 022 " 024 " 026 Spool device unit number 030 Number of LUN's available for RTEM 032 Action on failure opening file in R/W mode: < 0 Ask to open in R/O mode = 0 Fail operation > 0 Open in R/O mode 034 Default size in blocks for created of image files 036 QIO read function (IO.RVB or IO.RLB) for system device 040 RTEM version ID in Radix-50 (^RV1.) 042 Block offset for I/O operation (0 for IO.RLB, 1 for IO.RVB) 044 First private directory degment number (on whole disk) which is mapped to the first directory segment on private image file. If private image file is opened in read-only mode, 100000 is added to this word. 046 Number of extra bytes in directory file entries for created image files 050 Reserved/patch space 052 " 054 " 056 " 060 " 112 ? RTEM ? ? 114 ? RTEM RTEM.EXE/RTEM.TSK Address of LUN file table. This table contains as many entries as number JOAT.SAV of LUN's available for RTEM. Each entry contains 2 words: VSM.SYS 000 Status word and RT-11 job number plus 1 or 0 if the device is attached to RTEM. Status bits: 100000 - Read-only access to LUN 40000 - LUN is used 20000 - excluide from search (used for files?) 200 - LUN can't be deassigned 002 RT-11 device name in Radix-50 or 0 if no RT-11 device attached. 116 ? RTEM ? Address of first QIO status block used for QIO/QIOW requests. There're 6 I/O status blocks 2-word each. This address is also used as the address beyound LUN table pointed by offset 114. Offsets: 000 QIO status block for terminal I/O 004 QIO status block for shared/private/temp image file I/O 010 ? 014 QIO status block used by QIO DPB pointed to by offset 074 020 QIO status block used by QIO DPB pointed to by offset 100 024 QIO status block used by QIO DPB pointed to by offset 102 120 .$TKS RTEM ? Fake console terminal registers. 122 .$TKB RTEM ? " 124 .$TPS RTEM ? " 126 .$TPB RTEM ? " 130 ? RTEM - Reserved. Point to the routine that halts RTEM with an error message 132 ? RTEM - "?RTEM-U-System error". 134 ? RTEM - " 136 ? RTEM - " 140 .EXUSE RT-11 (BSTRAP) RTEM.EXE/RTEM.TSK Address of EXUSER in RMON. 142 .FPPFL RT-11 (BSTRAP) RTEM.EXE/RTEM.TSK Address of FPPFLG in RMON. 144 .INTAC RT-11 (BSTRAP) RTEM.EXE/RTEM.TSK Address of INTACT in RMON. 146 .INTLV RT-11 (BSTRAP) RTEM.EXE/RTEM.TSK Address of INTLVL in RMON. 150 .LKQUE RT-11 (BSTRAP) RTEM.EXE/RTEM.TSK Address of LKQUE in RMON. 152 .PSCLO RT-11 (BSTRAP) RTEM.EXE/RTEM.TSK Address of PSCLOK in RMON. 154 .RMONS RT-11 (BSTRAP) RTEM.EXE/RTEM.TSK Address of RMONSP in RMON. 156 .SAVE3 RT-11 (BSTRAP) RTEM.EXE/RTEM.TSK Address of SAVE30 in RMON. 160 .SYS RT-11 (BSTRAP) RTEM.EXE/RTEM.TSK Address of $SYS in RMON. 162 .TASKS RT-11 (BSTRAP) RTEM.EXE/RTEM.TSK Address of TASKSP in RMON. 164 .TIKCT RT-11 (BSTRAP) RTEM.EXE/RTEM.TSK Address of TIKCTR in RMON. 166 .TTRSE RT-11 (BSTRAP) RTEM.EXE/RTEM.TSK Address of TTRSET in RMON. 170 .$ENSY RT-11 (BSTRAP) RTEM.EXE/RTEM.TSK Address of $ENSYS in RMON. 172 .$FORK RT-11 (BSTRAP) RTEM.EXE/RTEM.TSK Address of $FORM in RMON. 174 .$INTE RT-11 (BSTRAP) RTEM.EXE/RTEM.TSK Address of $INTEN in RMON. 176 .$RMP0 RTEM - Patch space. Point to the routine that halts RTEM with an error message 200 .$RMP1 RTEM - "?RTEM-U-System error". 202 .$RMP2 RTEM - " 204 .$RMP3 RTEM - " 206 ? RTEM RTEM.EXE/RTEM.TSK Task SST vector (odd address or nonexistent memory error). 210 ? RTEM RTEM.EXE/RTEM.TSK " (memory protect violation). 212 ? RTEM RTEM.EXE/RTEM.TSK " (T-bit trap or execution of a BPT instruction). 214 ? RTEM RTEM.EXE/RTEM.TSK " (execution of an IOT instruction). 216 ? RTEM RTEM.EXE/RTEM.TSK " (execution of a reserved instruction). 220 ? RTEM RTEM.EXE/RTEM.TSK " (execvution of a non-RSX EMT instruction). 222 ? RTEM RTEM.EXE/RTEM.TSK " (execution of a TRAP instruction). 224 ? RTEM RTEM.EXE/RTEM.TSK " (floating point exception). Volume Home Block ~~~~~~~~~~~~~~~~~ There are two interesting offsets of the home block of volume (LBN 0) or a virtual image file (VBN 2). If offset 700 contains RTEM identifier (^RRTE), then offset 702 is checked for a negative value by RTEM and JOAT. If the value of 702 is negative, then RT-11 device will be attached in read-only mode. RTEM Disk Handlers Boot Block ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Hardware bootstrap code for RTEM disk handlers should print error message and halt. Bootstrap process under RTEM uses read routine of the handler. This routine should use QIOW DPB pointed to by address 772 then call RTEM routine pointed to by address 774. See handler boot code example which works for any RTEM disk handler. .DRBOT DH,BOOT1,READ .=DHBOOT+40 BOOT1: JMP @#BOOT-DHBOOT ;Jump to HW bootstrap code .=DHBOOT+254 BOOT: JSR R0,BPRINT ;Print error message and halt .ASCII <0><0> .ASCII /?BOOT-U-Cannot boot RTEM standalone/<200> .ASSUME . LE DHBOOT+500,MESSAGE=<;HW boot code overflow> .=DHBOOT+500 ;+ ;Bootstrap read routine. ;Inputs: ; R0 - block number ; R1 - word count ; R2 - buffer address ;- READ: MOV R0,R3 ;Save block number MOV DHBOOT+772,R0 ;Get address of QIOW DPB MOV R2,Q.IOPL(R0) ;Set buffer address in DPB ASL R1 ;Convert word count to bytes MOV R1,Q.IOPL+2(R0) ;Set transfer length MOV R3,Q.IOPL+10(R0) ;Set block number JMP @DHBOOT+774 ;Call RTEM read routine and return ;+ ;We're about to overwrite standard RT-11 HW bootstrap code and should use ;.DRBOT macro before we do that. ;- .DREND DH .ASSYME . LE DHBOOT+550,MESSAGE=<;Read routine code overflow> .=DHBOOT+550 ; ;Boot print routine prints error message and halts processor. ;This routine should be at the address 550. ; BPRINT: TSTB @#TPS ;Terminal printer ready? BPL BPRINT ;Branch if not MOVB (R0)+,@#TPB ;Print character BPL BPRINT ;Branch if more characters to print HALT ;Halt BR .-2 ;Loop .ASSUME . LE DHBOOT+570,MESSAGE=<;BPRINT code overflow> .=DHBOOT+570 ;+ ;Boot I/O error routine for RTEM should be at the address 570. ;- JSR R1,10$ ;Call REPORT routine .WORD BTERR-DHBOOT ; 10$: MOV #BOOTU,R0 ;Print message prefix JSR R1,20$ ; MOV (R1)+,R0 ;Get address of message JSR R1,20$ ;Print it MOV #BCR2LF-DHBOOT,R0 ;Print at the end JSR R1,20$ ; INC @#34 ;Signal RTEM that I/O error occured TRAP 0 ; 20$: MOV R1,-(SP) ;Save volatile registers MOV R2,-(SP) ; MOV #BQIOW-DHBOOT,R2 ;Get address of QIOW DPB for terminal MOV R0,Q.IOPL(R2) ;Set message address in DPB MOV R0,R1 ;Copy address of message 30$: BITB #177,(R1)+ ;Compute message length BNE 30$ ; SUB R0,R1 ; DEC R1 ; MOV R1,Q.IOPL+2(R2) ;Set message length in DPB DIR$ R1 ;Execute QIOW directive MOV (SP)+,R2 ;Restore volatile registers MOV (SP)+,R1 ; RETURN ;Return BQIOW: QIOW$ IO.CCO,1,24 ;QIOW DPB for terminal I/O ;Use LUN 1 for terminal and EFN 24 BOOTU: .ASCII "?BOOT-U-"<200> BCR2LF: .ASCII <200> BTERR: .ASCII "I/O error"<200> .ASSUME . LE DHBOOT+772,MESSAGE=<;REPORT code overflow> VS handler .SPFUN codes ~~~~~~~~~~~~~~~~~~~~~~~ The following .SPFUN codes are supported by VS handler: 373 - get device size 374 - reset VS: tables Special function #374 is called by JOAT after virtual device mounted or unmounted to force VS handler to refresh it's internal tables. RTEM.TSK Offsets ~~~~~~~~~~~~~~~~ ZAP/AB SIPP/A Description ------- ------- --------------------------------------------------------------------------- 13:340 12340 Memory mode: <> 0 - extend RTEM task to use maximum of memory for RT-11 0 - don't extend RTEM, use memory specified with /INC keyword of INS 13:344 12344 File image creation mode: <> 0 - create contiguous image files 0 - create non-contiguous image files 13:346 12346 Action on failure opening file in R/W mode: < 0 - Ask to open in R/O mode = 0 - Fail operation > 0 - Open in R/O mode 13:350 12350 Default size in blocks for created image files. 13:352 12352 Extra bytes for RT-11 directory entries of created image files. JOAT.SAV Offsets ~~~~~~~~~~~~~~~~ SIPP/A Description ------- --------------------------------------------------------------------------- 1632 Print attached devices mode: <> 0 - print LUN's 0 - don't print LUN's