$RPBDEF $NDTDEF LOCAL_MEMORY: .LONG SHARED_MEMORY: .LONG MEM_PHY_PAGES: .LONG .SBTTL SHOW MEMORY USAGE ;+ ; Show physical memory ; ; This routine returns information about the physical memory; ; The number of blocks is returned. ; Calling sequence : mem = memory (), mem will contain the size ; of physical memory in blocks ;- .ENTRY MEMORY,^M<> $CMEXEC_S SIZE_MEMORY ; Calculate physical memory size CMPL MEM_PHY_PAGES,G^MMG$GL_PHYPGCNT ; MINIMIZE PHYSICAL PAGE BLEQU 10$ ; COUNT WITH SYSGEN SPECIFIED MOVL G^MMG$GL_PHYPGCNT,MEM_PHY_PAGES ; PAGE COUNT 10$: MOVL MEM_PHY_PAGES,R0 RET .SUBTITLE SIZE_MEMORY Get Amount of Physical Memory ;+ ; SIZE_MEMORY Get Amount of Physical Memory ; ; This routine uses the memory descriptors in the Restart Parameter Block ; to determine the amount of physical memory in use. A check is made to ; see if multiport memory should be counted as local memory. ; ; Calling sequence: ; ; CALLS #0,SIZE_MEMORY ; ; Input parameters: ; ; None ; ; Implicit Input: ; ; Memory descriptors in RPB ; ; Output parameters: ; ; LOCAL_MEMORY Total memory in local memory controllers ; ; SHARED_MEMORY Total memory in multiport emmory controllers ; ; MEM_PHY_PAGES Total amount of physical memory in use by system ; (This total does not include multiport memory ; being used as shared memory.) ; ;- SIZE_MEMORY: .WORD ^M ; Save some registers MOVL G^EXE$GL_CONFREGL,R0 ; Get address of TR/adapter type array MOVL G^EXE$GL_RPB,R1 ; GET ADDR OF RPB MOVAL RPB$L_MEMDSC(R1),R2 ; GET ADDR OF MEMORY DESCRIPTORS MOVL #RPB$C_NMEMDSC,R5 ; GET MAXIMUM # OF MEM DESC POSSIBLE CLRL LOCAL_MEMORY ; INIT PAGE COUNT CLRL SHARED_MEMORY ; INIT PAGE COUNT 10$: TSTL (R2) ; END OF MEMDSC LIST? BEQL 40$ ; YES - GO PRINT INFO EXTZV #RPB$V_TR,#RPB$S_TR,(R2),R3 ; GET TR NUMBER MOVL (R0)[R3],R3 ; CONVERT TO ADAPTER TYPE EXTZV #RPB$V_PAGCNT,#RPB$S_PAGCNT,(R2),R4 ; GET PAGE COUNT ; The following set of assumptions state that all multiport memory adapter ; type codes are bounded by NDT$_MPM0 and NDT$_MPM3 and that no adapter ; type codes in this range represent anything other than multiport memory. ASSUME NDT$_MPM0 LT NDT$_MPM1 ASSUME NDT$_MPM1 LT NDT$_MPM2 ASSUME NDT$_MPM2 LT NDT$_MPM3 CMPB R3,#NDT$_MPM0 ; Is adapter number below MPM range BLSSU 20$ ; If so, this is local memory CMPB R3,#NDT$_MPM3 ; Is adapter number above MPM range BGTRU 20$ ; If so, this is also local memory ADDL2 R4,SHARED_MEMORY ; Otherwise, this is multiport memory BRB 30$ ; Go to end of loop 20$: ADDL2 R4,LOCAL_MEMORY ; This is local memory 30$: ADDL2 #RPB$C_MEMDSCSIZ,R2 ; Point to next memory descriptor SOBGTR R5,10$ ; Loop back until at end of list ; There are four cases that can occur here. ; ; 1. There are no multiport memory controllers on the system. ; ; 2. Multiport memory is being used as global shared memory. ; ; 3. Multiport memory is being used as local memory. This case is ; distinguished by RPB$V_USEMPM being set in the RPB copy of R5. ; ; 4. Only multiport memory is being used as local memory. Any memory ; in local controllers is ignored. This is the multiprocessor ; configuration. This case is distinguished by RPB$V_USEMPM ; being set in the RPB copy of R5. 40$: BBS #RPB$V_MPM,RPB$L_BOOTR5(R1),50$ ; Multiprocessor configuration? MOVL LOCAL_MEMORY,MEM_PHY_PAGES ; Local memory is always counted BBC #RPB$V_USEMPM,RPB$L_BOOTR5(R1),60$ ; Also count shared memory? ADDL2 SHARED_MEMORY,MEM_PHY_PAGES ; Add it in if using as local memory BRB 60$ ; and return 50$: MOVL SHARED_MEMORY,MEM_PHY_PAGES ; Only count shared memory 60$: MOVZWL #SS$_NORMAL,R0 ; Indicate success RET ; and return .END