.title AST_TEMPLATE Template AST routine .subtitle Example special KERNEL mode AST routine ;++ ; AST_TEMPLATE ; ; Author: Nick de Smith ; Date : 19-Dec-88 ; ; Description: ; ; This is a template for writing your our special KERNEL mode AST routines. ; Modify this template to include your own special functions, and then link ; your module with the common code, K_AST as follows: ; ; $ MACRO AST_TEMPLATE ; $ LINK AST_TEMPLATE,K_MAIN,K_AST ; $ RUN AST_TEMPLATE ! Requires CMKRNL (surprise!) ; ; Note that the entry point of the resulting program is in K_MAIN. ; If K_MAIN does not provide a sufficient user interface, include a version of ; K_MAIN in your code. See NEW_PROMPT and NEW_NAME for examples of this. ; ; See PDUMP.MAR for a complicated example using this template, and PDEALLOC.MAR ; for a simple one. ; ; Edit Edit date By Why ; 2.01 19-Dec-88 NMdS VMS V5, integrate with common AST code. ;-- .ident /V02.01/ .library "Sys$Library:Lib" ; Save tedious MACRO commands $acbdef ; AST Control Block definitions $psldef ; Process status definitions $ssdef ; Define system statii .subtitle AST_CODE Code to execute in target process ;++ ; AST_CODE Code to execute in target process ; ; Input Parameters: ; ; R4 => PCB of target process ; ie. The process in whose context this routine executes. ; R5 => Extended ACB ; KERNEL mode at IPL$_ASTDEL ; ; Output Parameters: ; ; R0-R5 Can be destroyed ; R6-R11 Must be preserved ; IPL Can be 0. SCH$ASTDEL will obtain the SCHED spinlock (and maybe ; raise IPL) before checking for the next AST to deliver. ; ; Calling sequence: ; ; JSB @ACB$L_KAST(R5) ; From SCH$ASTDEL at IPL$_ASTDEL ; which is the same as: ; JSB g^AST_CODE ; at IPL$_ASTDEL ; ; At IPL$_ASTDEL it is safe to page fault, but lower your IPL before using ; most system services. The general rule is: If you don't need elevated IPL, ; don't use it. Set your IPL to 0 if in doubt. The reason that we are ; delivered at IPL$_ASTDEL(2) is that at IPL 2 we cannot be deleted, therefore ; the system would not be left with an unowned ACB due to this routine not ; completing. ;-- .psect AST_CODE Rd, NoWrt, NoExe, Pic, Long AST_CODE:: pushr #^m ; Save registers ; SETIPL #0 ; Drop IPL to 0 (elevation not needed) ;;++ ;; Put your functionality here ;;-- popr #^m ; Restore registers ; ; It is the responsibility of this routine to dispose of the ACB. ; movl r5, r0 ; Addr of ACB jmp g^EXE$DEANONPAGED ; Deallocate ACB ; And dismiss the AST AST_LENGTH == . - AST_CODE ; Length of all AST code .subtitle Extended ACB format ; ; Define extended AST Control Block ; ; This is included in the template code so that you can add your own fields, ; eg. an IOSB. Add your fields between the ";++" and ";--". ACB_L_SPID is ; filled in by K_AST.MAR with the IPID of the sending process. This enables ; you to send the ACB back to the sender, with, say, a completed IOSB. ; $defini ACB, GLOBAL, ACB$K_LENGTH ; Must be global symbols, Get past normal ACB fields $def ACB_L_SPID ; Source PID .blkl 1 ;++ ; Add your fields here ;-- $def ACB_T_AST_CODE .blkb AST_LENGTH ; All AST code $def ACB_K_NEW_LENGTH ; Symbol for extended length $defend ACB ; ; The length of an ACB (like all NPAGE pool blocks) is stored in a word ; The maximum length of the extended ACB is therefore 65535 bytes. Check this. ; (the check is rather academic, but we should be careful in case an error has ; been made - non-paged pool could be consumed, never to re-appear!). ; .if greater .warn ; Too much AST code specified. .print ; Some non-paged pool will be left allocated by this program. .endc .end