.NLIST TOC,SYM .TITLE $INIVM .SBTTL ULBLIB 028 - Initialize Virtual Memory .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. ;+ ; $INIVM ; This routine initializes the free dynamic memory, sets up the page address ; control list, and initializes the user's disk work file to enable ; memory-to-disk page swapping. The routine will first try to open the file ; on device WF:. If this fails, it will try to DK:. It will try to open the ; file with a size of 256. block (64kw maximum capacity). If this fails, it ; will ask for the largest available. The work file is opened first to allow ; the work file device handler to be fetched low, if desired. ; ; $FRHD:: .WORD starting address of free dynamic memory ; .WORD 0 ; W$KLUN == logical unit number of work file (channel number) ; N$MPAG == minimum number of pages before the fast page search ; will be used. The fast page search uses 2 pages. ; ; CALL $INIVM ; ; R1 = random ; ; C-bit = 0 => success ; R0 = 0 ; ; C-bit = 1 => failure ; R0 = -2 to indicate open failure for work file ; ($WRKPT)+F.ERR = the error code for the failure. ;- $INIVM:: JSR R5,$SAVRG ;Save non-volatile registers MOV #$FRHD,R5 ;R5 -> free dynamic memory list head MOV $WRKPT,R4 ;R4 -> work file FDB MOV #<^RWF >,@F.OPNM(R4); Try on device "WF" first. 1$: .OPEN R4,R5 ;Try to open the file BCC 5$ ;Branch if ok CMPB #FE.ILD,F.ERR(R4) ;Illegal device error? BNE 2$ ;Branch if not MOV #<^RDK >,@F.OPNM(R4) ;Try to open it on "DK" BR 1$ ; 2$: CMPB #FE.DVF,F.ERR(R4) ;Device full? BNE 3$ ;Branch if not TST F.OPLN(R4) ;Already failed once? BPL 4$ ;Branch if not 3$: MOV #-2,R0 ;Return open failure BR 10$ ; 4$: MOV #-1,F.OPLN(R4) ;Get the biggest we can. BR 1$ ;Try again. 5$: MOV #1,$HGVAD ;Set the high virtual address to 1 CLR $PAGHD ;Mark all pages non-resident CLR $PAGLS ;Clear the fast page search pointer 6$: MOV R5,R0 ;R0 -> free dynamic memory list head CALL $INIDM ;Initialize dynamic memory MOV R5,R0 ;R0 -> free memory list head MOV (R0)+,R1 ;R1 -> first free block CLR @R0 ;Second word must be 0 CMP 2(R1),# ;Got enough for fast page search? BLO 8$ ;Branch if not MOV #512.,R1 ;Allocate 2 blocks for resident page list CALL $ALBLK ;Allocate and zero it. MOV R0,$PAGLS ;Save the address of the list 8$: MOV #P$GSIZ,R1 ;R1 = page size CALL $ALBLK ;Allocate and zero the first page MOV R0,$PAGHD ;Link it to the resident page list head MOV $PAGLS,R1 ;Get address of resident page list BEQ 9$ ;Branch if none MOV R0,@R1 ;Mark page resident 9$: CLR $TIME ;Reset time-stamp CLR R0 ;Flag success TST (PC)+ ;Both ways 10$: SEC ;Flag failure RETURN .END