.NLIST TOC,SYM .TITLE $GTCOR .SBTTL ULBLIB 026 - Get Core, Displace Virtual Page Buffers .IDENT \V01.00\ .PSECT .LIBC. .ENABL LC,GBL ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. ;+ ; $GTCOR ; This routine attempts to allocate requested dynamic memory blocks in two ; ways: ; ; o Allocation from the currently available space in the free dynamic ; memory. ; ; o Swapping unlocked page blocks from dynamic memory to disk to free ; previously allocated memory space for reallocation. ; ; R1 = number of bytes requested (<= 512.) ; ; CALL $GTCOR ; ; C-bit = 0 => success ; R0 = dynamic memory address ; R1, R2 = ??? ; ; C-bit = 1 => failure ; R0, R1, R2 = ??? ;- $GTCOR:: JSR R5,$SAVRG ;Save non-volatile registers 1$: MOV R1,-(SP) ;Save byte count MOV #$FRHD,R0 ;R0 -> free memory list head CALL $RQCB ;Request core block BCC 7$ ;Branch if we got requested space ; Insufficient storage is available. free up memory by displacing page buffers MOV #<$PAGHD-P$GNXT>,R4 ;Get listhead address minus offset CLR R2 ;Clear address of lru page MOV #-1,R3 ;Set maximum time CLR -(SP) ;Clear lru predecessor 2$: MOV R4,R5 ;Save predecessor MOV @R5,R4 ;Get next page BEQ 3$ ;Branch if done CMP P$GTIM(R4),R3 ;Test time of last use vs. least BHI 2$ ;If hi, this buffer not least TSTB P$GLOK(R4) ;This page locked in memory? BNE 2$ ;Branch if so MOV R4,R2 ;Mark buffer as lru MOV P$GTIM(R4),R3 ;Save time MOV R5,@SP ;Save predecessor for relink BR 2$ ;Go again 3$: TST R2 ;Find lru? SEC ;Assume no BEQ 6$ ;Branch if not BITB #PG$WRT,P$GSTS(R2) ;Page written into ? BEQ 4$ ;Branch if not CALL $WRPAG ;Write out page into vm 4$: MOV $PAGLS,R3 ;Get address of page list BEQ 5$ ;Branch if none CLR R0 ;Set for MOVB with no sign extend BISB P$GBLK(R2),R0 ;Get block number ASL R0 ;Convert to word offset ADD R0,R3 ;Compute location in list CLR @R3 ;Clear entry 5$: MOV (SP)+,R3 ;Retrieve lru predecessor MOV @R2,@R3 ;Relink remaining pages MOV #$FRHD,R0 ;R0 -> free memory list head MOV #P$GSIZ,R1 ;R1 = size of a page CALL $RLCB ;Release memory MOV (SP)+,R1 ;Restore count BR 1$ ;Go again 6$: INC (SP)+ ;Clean stack, leave C-bit intact 7$: INC (SP)+ ;Clean stack RETURN .END