[mod.computers.vax] PC getter for VMS processes

{ATE.R/CHESTNUT}ONTYME@OFFICE-1.UUCP (07/02/86)

MSG#:J58311

   IN#:  

      TO: GATEWAY

         FROM: ATE      R/CHESTNUT

SENT: 30 JUN 86 11:50:10

READ: 30 JUN 86 11:56:48

To: info-vax@sri-kl.arpa

Subject: PC getter for VMS processes

Reply-to: rc.tym@office-1.arpa

Following is a function requested by pjs%chico@jpl-vlsi.arpa for process 
watching. After going through arpanet it may need some editing, specifically 
the up-arrows (carets) before the masks in .ENTRY statements and the up-arrows 
(carets) between the G and entry names in JSB or CALLS or CALLG statements. The
global variables G(caret)SCH$... may also loose their caret. (And they need 
them).

--------- Cut here --------------------------

;*******************************************************************

;

   ;       Program name: CHECKPRC

;

   ;       Function:     Look at the state and PC of a process

;

   ;       Privileges required:    CMKRNL

;******************************************************************

   .TITLE  CHECKPRC

;

   $PCBDEF

   $PHDDEF

   $STATEDEF

   $IPLDEF

;

pid=4

ret_sp=8

ret_state=12

ret_psl=16

proc_pc_off=4

proc_state_off=8

proc_sp_off=12

proc_psl_off=16

;

; CUR_PC = CHECKPRC(PID,CUR_SP,CUR_STATE,CUR_PSL)

   ;   PID is input

   ;   SP,STATE, PSL are output

;

   .PSECT  scratch pic,noexe,wrt

      proc_id:    .blkl 1

krnl_args:

   .long 4

   .address proc_pc

   .address proc_state

   .address proc_sp

   .address proc_psl

      proc_pc:    .blkl 1

proc_state: .blkl 1

   proc_sp:    .blkl 1

   proc_psl:    .blkl 1

.psect

.entry  checkprc,^m<>

           movl    @pid(ap),proc_id

           $cmkrnl_s       routin=take_care_of_pcb,arglst=krnl_args

           cmpl    r0,#ss$_nonexpr

           bneq    okeydokey

           mnegl   #1,r0

           brb     exit

okeydokey:

           movl    proc_sp,@ret_sp(ap)

           movl    proc_state,@ret_state(ap)

           movl    proc_psl,@ret_psl(ap)

           movl    proc_pc,r0

exit:   ret

;

   ;       kernel mode code

;

   .entry  take_care_of_pcb,^m<r2,r3,r5,r6,r7>

   .enable lsb

              movl    proc_pc_off(ap),r3      ;where to store the answer

              movl    proc_state_off(ap),r2   ;where to store the answer

              movl    proc_sp_off(ap),r5      ;where to store the answer

              movl    proc_psl_off(ap),r7     ;where to store the answer

              MOVZWL  PROC_ID,R0              ;get vector index from PID

              setipl  #ipl$_synch             ;synchronize

              JSB     G^EXE$EPID_TO_PCB

              BEQL    NON_EXISTANT_PROCESS

      ;       cmpw    r4,g^sch$gl_maxpix      ;PID too large?

      ;       bgeq    non_existant_process

      ;       movl    g^sch$gl_pcbvec,r1      ;get base of PCB vector

      ;       movl    (r1)[r4],r4             ;get PCB address

              CMPL    R0,G^SCH$GL_NULLPCB     ;don't do this to NULL

              beql    non_existant_process

              CMPL    R0,G^SCH$GL_SWPPCB      ;or SWAPPER

              beql    non_existant_process

              movzwl  pcb$w_state(r0),(r2)    ;return argument

              movl    pcb$l_phd(r0),r6

              movl    phd$l_pc(r6),(r3)       ;return argument

              movl    phd$l_psl(r6),(r7)      ;return argument

              movl    phd$l_usp(r6),(r5)      ;return argument

              movl    #ss$_normal,r0

      10$:    setipl  #0

   ret

non_existant_process:

           movl    #ss$_nonexpr,r0

           brb     10$

.end