.TITLE ADD_PERM_PER_PROCESS_DISPVEC .SUBTITLE Introduction ;++ ; ; Module: ADD_PERM_PER_PROCESS_DISPVEC ; ; Facility: EGP1 ; ; Function: Make a permanent entry in the P1 dispatch vector ; for: ; * Change mode to kernel dispatcher ; * Change mode to executive dispatcher ; * Rundown interceptor ; ; Invocation Protocol: VAX/VMS Procedure Calling Standard. ; ; CALL ADD_PERM_PER_PROCESS_DISPVEC ; (DISPATCH_ROUTINE_TYPE, DISPATCH_ROUTINE_ADDRESS, STATUS) ; ; DISPATCH_ROUTINE_TYPE ---> ; Longword integer. ; Type of dispatch vector routine. ; EGP1VEC_C_USRCHMK = Kernel Dispatcher ; EGP1VEC_C_USRCHME = Executive Dispatcher ; EGP1VEC_C_USRUNDWN = Rundown Routine ; ; DISPATCH_ROUTINE_ADDRESS ---> Longword. ; Address of routine. ; ; STATUS <--- Longword. ; Status of Operation. ; ; Status Returns: ; ; SS$_NORMAL Normal Successful Operation. ; SS$_INSFARG Bad Argument Count. ; EGP1VEC__BADVECCOD Invalid dispatch routine type. ; EGP1VEC__BADADDR Routine is not above base of P1 ; space and will not survive ; rundown. ; EGP1VEC__PRVVEC There is already a per-image vector ; in place. To proceed would cause ; temporary vectors to become permanent ; pointing to non-existent code. ; (Can happen if the image using this ; routine is linked with the debugger) ; ; Notes: ; 1. These entries are usually made as per-image entries ; by linking to a privileged shareable image (see ; example in SYS$EXAMPLES:USSDISP.MAR). The entries ; are removed by image rundown. This routine will ; cause a permanent entry to the dispatch table which ; is unaffected by rundown. ; ; 2. Routine added by this procedure is activated by JSB style ; call, and should therefore have no entry mask. ; ; Revision: 1.0 19-Sep-1985 Larry L. Johnson ; ; Language: VAX/VMS Macro-32 Assembler. ; ; Required Macro Libraries: ; STARLET The default VAX System Macro Library. ; (Automatically scanned.) ; ; External Status References: ; ; Facility Defined Status Values: ; EGP1VEC__BADVECCOD ; EGP1VEC__BADADDR ; EGP1VEC__PRVVEC ; ; VAX/VMS Common Run Time Library Status Values: None ; ; VAX/VMS RMS Status Values: None ; ; VAX/VMS System Service Status Values: None ; ; SS$_NORMAL Normal Successful Operation. ; SS$_INSFARG Bad Argument Count. ; ; External Data References: ; ; From SYS$SYSTEM:SYS.STB ; ; IAC$AW_VECSET Address of the vector size ; array in P1 space. ; IAC$AW_VECRESET Address of the original vector ; size array in P1 space. ; CTL$GL_CTLBASVA Pointer to address of end of ; base of P1 space. ; CTL$A_DISPVEC Pointer to address of first ; half-page vector in P1. ; ; External Routine References: ; ; Facility Defined Routines: None ; ; VAX/VMS Common Run Time Library Routines: None ; ; VAX/VMS RMS Routines: None ; ; VAX/VMS System Services: ; ; SYS$CMKRNL ; ;-- .PAGE .SUBTITLE Procedure Data ;....................................................................... ;... Argument List Offsets ............................................. ;....................................................................... ;Argument List Offset Definitions: DISPATCH_ROUTINE_TYPE = 4 DISPATCH_ROUTINE_ADDRESS = 8 STATUS = 12 ;....................................................................... ;... Local Read-Only Data Allocations .................................. ;....................................................................... .PSECT _EGP1_LOCAL_RO_DATA, - QUAD, CON, NOEXE, LCL, NOPIC, NOSHR, REL, NOWRT, NOVEC ;External Parameters: $OPDEF ;Define symbolic opcodes. $SSDEF ;Define system service status codes. ;Module Parameters: ;The code indicating absolute (PC relative deferred) ; in an instruction argument. ABSOLUTE_ADDRESSING_MODE = ^X9F ;The size of each vector in the dispatch area. ; The dispatch area is currently four vectors ; of one-half page each for Kernel Dispatch, ; Executive Dispatch, Rundown Dispatch, and ; per-image message vectors respectively. MAX_DISPATCH_VECTOR_SIZE = ^X100 ;....................................................................... ;... Local Writeable Data Allocations .................................. ;....................................................................... .PSECT _EGP1_LOCAL_RW_DATA, - QUAD, CON, NOEXE, LCL, NOPIC, NOSHR, REL, WRT, NOVEC ; Local Status Variable Allocations: None ; Local Variable Allocations: None .PAGE .SUBTITLE Main Procedure ;....................................................................... ;... Executable ........................................................ ;....................................................................... .PSECT _EGP1_CODE, - QUAD, CON, EXE, LCL, NOPIC, NOSHR, REL, NOWRT, NOVEC .ENTRY ADD_PERM_PER_PROCESS_DISPVEC, ^M ;Register Usage: ; ; R3 = Dispatch routine address. ; R4 - Not used. ; Cannot be used to pass info to kernel routine. ; R5 = Dispatch vector index for rundown vector. ; R6 = Address of VECSET array. ; R7 = Address of VECRESET array. ; R8 = Instruction load pointer. ; R9 = Address of original terminating RSB instruction. ; R10 = Address of size field of rundown vector. ; R11 = Dispatch vector offset to base of dispatch area. ; ;Initialize registers with primary data. ;Move arguments to registers MOVL @DISPATCH_ROUTINE_ADDRESS(AP), R3 MOVL @DISPATCH_ROUTINE_TYPE(AP), R5 ;Get the addresses of the VECSET and VECRESET arrays MOVL #IAC$AW_VECSET, R6 MOVL #IAC$AW_VECRESET, R7 ;Validate arguments. ;Validate argument count. CMPL #3, (AP) BEQL 10$ MOVL #SS$_INSFARG, R0 BRB COMMON_EXIT 10$: ;Validate dispatch selection code. TSTL R5 BGEQ 20$ MOVL #EGP1VEC__BADVECCOD, R0 BRB COMMON_EXIT 20$: CMPL R5, #EGP1VEC_C_USRUNDWN BLEQ 30$ MOVL #EGP1VEC__BADVECCOD, R0 BRB COMMON_EXIT 30$: ;Validate that routine address is at least ; above the base of P1 space. Anything ; lower is not going to exist, or will ; disappear during rundown. CMPL R3, @#CTL$GL_CTLBASVA BGEQU 40$ MOVL #EGP1VEC__BADADDR, R0 BRB COMMON_EXIT 40$: ;Validate environment ;Validate that no privileged shareable image vectors ; exist for this image. Return error if there are ; since this routine would make them permanent rundown ; vectors to code that would no longer exist after the ; first rundown. CMPW (R6)[R5], (R7)[R5] BEQL 50$ MOVL #EGP1VEC__PRVVEC, R0 BRB COMMON_EXIT 50$: ;Calculate addresses of data of interest in target dispatch vector. ;Get address of size byte (first longword of the half-page ; vector) -- the base of the vector. ;Calculate offset to vector of interest off ; base of dispatch vector area. MULL3 R5,- #MAX_DISPATCH_VECTOR_SIZE,- R10 ;Add to base of dispatch vector area to get address ; of desired vector. ADDL2 #CTL$A_DISPVEC, R10 ;Calculate address of the original terminating RSB instruction ; within vector (the first longword of the vector contains ; the offset to the terminating RSB off the base of the ; particular vector). ADDL3 (R10), R10, R9 ;Calculate the address of first byte to be loaded. ; (the RSB is going to be left in place until everything ; else is finished). ADDL3 #1, R9, R8 ;Write the vector instruction entry in kernel mode. $CMKRNL_S - ROUTIN = WRITE_VECTOR_INSTRUCTION COMMON_EXIT: MOVL R0, @STATUS(AP) RET .PAGE .SUBTITLE Write Vector Instruction ;************************************************************ ; Write vector instruction in kernel mode. WRITE_VECTOR_INSTRUCTION: .WORD ^M ;Register Usage: ; ; The following registers are assumed initialized with the following ; data, of which only R8, the instruction load pointer, is changed. ; ; R3 = Dispatch routine address. ; R4 = The usual PCB address provided by kernel dispatcher. ; (Restored by mask to avoid being lost by kernel dispatcher.) ; R5 = Dispatch vector index for rundown vector. ; R6 = Address of VECSET array. ; R7 = Address of VECRESET array. ; R8 = Instruction load pointer. ; R9 = Address of original terminating RSB instruction. ; R10 = Address of size field of rundown vector. ; ;Write the address mode (absolute). (Later the RSB will ; be converted to a JSB when everything is complete. This way ; if exit is forced, the vector will functionally appear ; to be as it was... no undefined states.) MOVB #ABSOLUTE_ADDRESSING_MODE, (R8)+ ;Write the address of the routine. MOVL R3, (R8)+ ;Write the new terminal RSB instruction. (Note that ; we don't auto-increment here. This will facilitate ; calculation of the offset to the terminal RSB to ; be placed in the vector and the vector offset arrays.) MOVB #OP$_RSB, (R8) ;Update the size field of the vector, the vector array, ; and the vector reset array. SUBL3 R10, R8, R0 ;Calculate the new size MOVL R0, (R10) ;Store in vector. MOVW R0, (R6)[R5] ; and the vector array MOVW R0, (R7)[R5] ; and the reset array ; (setting the reset ; array is what makes it ; permanent) ;Change the old terminal RSB to a JSB to activate the ; rundown vector. MOVB #OP$_JSB, (R9) ;Return success to the caller. MOVL #SS$_NORMAL, R0 RET ;************************************************************ .END