;+
;  Sample.Mar
;  (21-Mar-88 : v1.0)
;
;                  (C) Copyright 1988 by
;               Rand P. Hall and M.P.Gerlek
;                   All Rights Reserved
;
;  This macro routine is called by the get_rates subroutine in MPAP.
;  In kernel mode, it scoops out the "bad stuff".
;
;  Inputs:  (none)
;  Outputs:
;	 integer*4 faults       pms$gl_faults    {# faults sys-wide}
;	 integer*4 readios      pms$gl_preadio   {# of "page faults
;                                                   resulting in page reads"}
; 	 integer*4 sysfaults    phd$l_pageflts() {system pagefaults}
;	 integer*4 inswaps      swp$gl_iswpcnt   {inswaps since boot}
;-

	.title	sample

	.library	/sys$library:lib.mlb/
	$ipldef
	$pcbdef
	$phddef


; Interrupts Macros

	.macro	dsbint	ipl=#31, dst=-(SP)	; macro to disable interrupts
	mfpr	s^#pr$_ipl,dst			;    after saving ipl
	mtpr	ipl,s^#pr$_ipl
	.endm	dsbint

	.macro	enbint	src=(SP)+		; macro to enable interrupts
	mtpr	src, s^#pr$_ipl			;    at previous ipl
	.endm	enbint



; call nasty code w/ CMKRNL

	.psect	code	pic,nowrt,shr,long
	.entry	sample,	^m<r8>
	movl	ap, r8				;preserve the AP
	$cmkrnl_s	routin=smpl             ;do SMPL in kernel mode
	movl	#ss$_normal, r0
	ret



; This is the actual cmkrnl routine code that gets the data:
;    sys-wide faults, hard faults, system page faults, inswaps

	.entry	smpl,	^m<r8>
	movl	r8,ap				; restore AP
	movl	4(ap),r2			; set first address pointer
	dsbint	#IPL$_SYNCH			; (ensure no changes during
						;   data collection)
	movl	G^PMS$GL_FAULTS, (r2)+		; get number of faults sys-wide
  	movl	G^PMS$GL_PREADIO, (r2)+		; get disk reads due
                                                ;   to page faults
	moval	G^MMG$AL_SYSPCB, R4		; R4 -> System PCB
      	movl	PCB$L_PHD(R4), R4		; R4 -> System PHD
	movl	PHD$L_PAGEFLTS(R4), (r2)+	; get system page fault count
	movl	G^SWP$GL_ISWPCNT, (r2)	       	; inswaps since boot
	enbint
	movl	#ss$_normal, r0
	ret
	.end
