.he VMS40 - LIM Memory Functions Page # .h2  .RRL ! ! ! ! ! ! ! ! R Definitions HANDLE A number in the range 0 to 255 that is assigned to a group of logical pages. It must be used whenever the group of pages is referenced. PAGE A 16K chunk of memory. It can be used for any purpose. type page : array[0..16383] of byte; WINDOW The area in normal memory for accessing pages. The window contains up to 4 pages, which are mapped into the window by various function calls. type window : array[0..3] of page; PHYSICAL PAGE A page in the window. Physical pages are referenced by 0 to 3. LOGICAL PAGE The page in EMS memory. For VMS40, this page resides on disk. They are referenced by number 0 to n-1, where n is the number of pages requested. MAPPING The process of copying logical pages into physical pages. Note that the mapping process saves the contents of previously mapped physical pages before moving the new pages in. You can only have 4 logical pages mapped at any one time, due to the fact that there are only 4 physical pages to hold the images in. MAP The record of which Logical pages reside in which Physical pages. Used internally by VMS40. Note that if you write TSRs that use LIM memory, you will need to save the mapping context (function 8) before using and restore the mapping context (function 9) before exiting. LIM CALLING SEQUENCE mov ah,function ;AH always determines service type .. .. ;Load other registers with specific .. ;values for the function int 67h ; call the LIM manager .pa LIM ERROR CODES After a call to the LIM memory manager, register AH will contain a zero if the function were successful or an error code in the range 80h-FFh Error Code Significance ====== ======================================================= 00 Function was successful 80h Internal Error in EMM software 81h Malfunction In Expanded memory hardware 82h Memory manager is busy 83h Invalid Handle 84h Function requested is not defined 85h No more EMM handles available 86h Error in Save or restore of mapping context 87h An allocation request specified more logical pages than are physically available in the system: no pages were allocated 88h An allocation request specified more logical pages than are currently available in the system (the request does not exceed the physical pages that exist, but some are already allocated to other handles); no pages were allocated 89h You cannot allocate zero pages 8Ah The logical page requested was outside the range of logical pages allocated to the handle 8Bh Illegal physical page number in mapping request (not in the range 0 to 3). 8Ch The save area for mapping contexts is full 8Dh Save of mapping context failed because the save area already contains a context associated with the handle. (did you forget to restore context? or have you done 2 consecutive saves?) 8Eh Restore of mapping context failed because save area does not contain a context for the handle 8Fh Subfunction parameter not defined 91h Unsuported function 93h Not enough pages owned to perform move (func 24) 95h Ptr Offset > 16k (func 24) 96h Move/exchange size > 1M (func 24) 98h Memory type invalid (func 24) A0h Handle name not found A1h Null handle found FFh VMS40 detected an error accessing the associated disk file .pa LIM MEMORY FUNCTIONS LIM memory functions are handled through interrupt 67H. The functions are numbered from 1, but for some reason function 1 has the value of 40h, and they go up from there. The function number is passed in AH.  .RRL > < > < > < > < R Function Name Action Called With Returns Comments  01 Get status Tests whether the LIM AH = 40h AH = status This call is used after the program has software and hardware or '@' established that the EMM is present using are functional the technique shown in EMS.PAS 02 Get Page Obtains the segment AH = 41h AH = status The page frame is divided into four 16K byte Frame Segment address of the EMM or 'A' BX = segment of pages, which are used to map the logical address page frame page frame expanded memory pages into the physical if AH = 0 memory of the 8088/8086 03 Get Obtains the total AH = 42h AH = status The application need not have already Unallocated Page number of logical or 'B' BX = unallocated acquired an EMM handle to use this function. count expanded memory pages pages present in the system DX = total pages and not already in system allocated 04 Get Handle Obtains an EMM handle AH = 43h or 'C' AH = status Equilavent to the file open function for the and Allocate and allocates logical BX = number of DX = handle if EMM. The handle that is returned is Memory EMS pages to be logical AH = 0 analogous to a file handle and owns a controlled by that pages to certain number of EMS pages. The handle must handle allocate be used with all subsequent requests to map memory, and must be released by a close operation when the application is finished. The function may fail because the EMM handles or EMS pages have been exhausted. 05 Map Memory Maps one of the AH = 44h or 'D' AH = status The logical page number must be in the range logical pages of AL = physical (0 to [n-1]), where n is the number of expanded memory page logical pages previously allocated to the currently assigned to (0 to 3) VMS40 handle with function 4. To access the a handle into one of BX = Logical page memory once it has been mapped to a physical the four physical (0 .. [n-1]) page, the application also needs the segment pages within the DX = handle of the EMM page frame, obtained with VMS40 page frame. function 2. 06 Release Deallocates the AH = 45h or 'E' AH = status This is the equivalent of a close operation Handle and Memory logical pages of DX = handle on a file. It notifies VMS40 that the expanded memory application will not be making further use currently assigned to of the data it may have stored within a handle and then expanded memory. releases the handle for re-use. 07 Get Version Returns the version AH = 46h or 'F' AH = status The value returned is the version of the EMS number of the EMM AL = version specification that the EMM driver complies software. (40h) with. It is returned as BCD, with the upper 4 bits being the integer part, and the lower 4 bits being the fraction. 08 Save Mapping Saves the contents of AH = 47h or 'G' AH = status This function is designed to be used by Context the page memory DX = handle interrupt handlers and resident drivers or variables, utilities that must access expanded memory. associating those The handle supplied to the function is the contents with a handle that was assigned to the interrupt specific handle. handler during its initialization sequence, not the one assigned to the program being interrupted. 09 Restore Restores the contents AH = 48h or 'H' AH = status Use of this function must be balanced by a Mapping Context of all mapping DX = handle previous call to EMS function 8. It allows variables saved under the interrupt handler or TSR that used EMS the given handle. to restore the mapping context to its state at the point of interrupt. 10 Reserved This function was defined in the EMS 3.0 standard, but is no longer documented under V3.2 or V4.0 11 Reserved This function was defined in the EMS 3.0 standard, but is no longer documented under V3.2 or V4.0 12 (0Ch) Get Returns the number of AH = 4Bh or 'K' AH = status If the returned number of handles is zero, Number active handles BX = number of none of the expanded memory is in use. The of handles number of active handles will ever exceed EMM handles 255 13 (0Dh) Get Returns the number of AH = 4Ch or 'L' AH = status A single program can make several allocation Pages Owned by logical pages owned DX = handle BX = logical requests, and therefore own several handles. handle by a specific handle pages The number of pages returned will always be greater than zero if the function is successful. With VMS40, the maximum is 2048 pages (= 32 Meg) 14 (0Eh) Get Returns an array that AH = 4Dh or 'M' AH = status The array is filled with 2 word entries. The pages for all contains all active DI = Offset of BX = number of first word of each entry contains a handle; Handles handles and the array to active the next word, the number of pages number of logical receive handles associated with that handle. BX gives the pages associated with information Array is only number of valid 2-word entries in the array. each handle ES = Array valid if AH = 0 Since the maximum number of active handles segment is 255, the array need not be larger than 1024 bytes. 15 (0Fh) Get/Set Saves or sets the AH = 4Eh or 'N' AH = status Subfunctions Page Map contents of the EMS AL = subfunction AL = bytes in 0 = get mapping registers into array page mapping number page mapping 1 = set mapping registers from array registers. (0 to 3) array 2 = get and set mapping registers in one DS:SI = array (subfunction operation holding mapping 3) 3 = return size needed for page mapping information Array pointed to array (subfunctions 1 by ES:DI receives and 2) mapping This function was added in EMS 3.2 and is ES:DI = array to information for designed to support multitasking operating receive subfunctions 0 systems. It should not be used ordinarily by information and 2 application software. (subfunction 0 and 2) The array contains hardware and software dependent information that is necessary to restore the EMS system to its previous state. 16 (10h) Get/Set Saves or Sets the AH = 4Fh or 'O' AH = status Subfunctions: Partial Page Map Contents of the EMS AL = Subfunction AL = size of 0 = get mapping registers into array ES:DI; page mapping number mapping DS:SI = word count of mapping entries registers, but only BX = count of array (sub- DS:SI+2 = word: segment of page ... for specified pages (sub- funtion 2) 1 = set mapping registers from array DS:SI physical pages. function 2) Array pointed to 2 = get size of mapping array -> AL DS:SI = array by ES:DI receives holding mapping Mapping Array: specifications information for word: count of pages to use (subfunctions subfunction 0 +2 word: logical page number 0 and 1) +4 word: Low address ES:DI = array for +6 word: Hi address mapping information Similar in function to #15, but for (subfunction 0) subfunction 0, array DS:SI points to normalized segment of physical page. IE physical page 0, use window segment, page 1 use window segment + 1024 etc. Offset will always be zero. 17 (11h) Map Used to map several AH = 50h or 'P' AH = status Subfunctions: Multiple Handle pages at the same AL = subfunction 0 = Physical page segment Pages time. number 1 = Physical page number CX = count of pages to map Used to map several pages in one call ( 1 to 4) DS:SI -> logical page id (word) DX = handle physical page id (word). DS:SI = pointer Repeated for each page to map, up to a Logical page maximum of 4. Physical page... .pa 18 (12h) Used to increase or AH = 51h or 'Q' AH = status If the number of pages requested is more Reallocate Pages decrease number of BX = new count than currently owned, then more will be pages assigned to a DX = handle allocated. If less, then the logical pages handle. greater than the number will be freed. 19 (13h) Get/Set Get or set attributes AH = 52h or 'R' AH = status THIS FUNCTION IS NOT SUPPORTED, although Handle Attributes for a handle AL = subfunction subfunctions zero and 2 will return a zero number status. Subfunction one will only return a BL = attribute zero status if called with BL = zero. DX = handle 20 (14h) Get/Set Returns or sets an 8 AH = 53h or 'S' AH = status Subfunctions: handle Name character name AL = subfunction DS:SI = handle 0 = Get handle name associated with number name 1 = Set handle name handle (like a file DX = handle name) DS:SI = array for Each handle can have an 8 character name handle name (8 associated with it. Naturally, the Get Name bytes) will not return valid data unless the name has previously been set. All names are initialized to nulls. 21 (15h) Get Returns a directory AH = 54h or 'T' AH = status Subfunctions: Handle Directory of handle names, with AL = subfunction 0 = Get directory of handles their number number BX = total number 1 = Search for named handle ES:DI = array to of handles 2 = Get total Handles (255) receive directory (subfunction 2) array (9 bytes This function is used to find out about per entry: DX = handle named handles. First call with subfunction 0 Number 1 byte (subfunction 1) to find out total handles in system. Target Name 8 bytes) array must be 9 bytes per entry. DS:SI = handle ES:DI directory name (subfunction (subfunction 0) On subfunction 1 supply a handle name. 1 only) Status of zero means found, otherwise not found (=> DX not valid) 22 (16h) Alter Used to execute code AH = 55h or 'U' AH = status This procedure maps up to 4 logical pages Page Map and Jump in LIM memory DX = handle into the physical, and then jumps to the DS:SI = pointer address supplied (after first exiting the to map data and interrupt) It can be used to load overlaid jump address code where there is no need to return to the DS:SI Dword Jump calling code. Addr DS:SI+4 count " +5 Dword ptr to Map info (like func 17) .pa 23 (17h) Alter Used to execute code AH = 56h or 'V' AH = status This procedure maps up to 4 logical pages Page map and Call in LIM memory DX = handle into the physical, and then calls the DS:SI = pointer address supplied (after first exiting the to map data and interrupt) It can be used to load overlaid call address code where you desire to return to the DS:SI Dword call calling code Addr DS:SI+4 count " +5 Dword ptr to Map info (like func 17) 24 (18h) Move / This routine is used AH = 57h or 'W' AH = status This function is used to copy up to one meg Exchange Memory to copy memory from AL = subfunction of memory from one location to another. Region one location to 0 = Move S -> D Depending on subfunction, memory regions are another, or to 1 = Exch S <-> D exchanged (AL=1) or the source is written exchange memory in DX = handle over the dest (AL=0). Either may start in one region with DS:SI = pointer conventional memory, and the process will another. to move handle overlaps (move only) structure: +0 Dword size The pages are moved through window 0 and 1, +4 Memory type src which are saved before and restored after. 0 = low mem Addresses over than 1M are deemed to be 1 = Extended extended memory, and are converted to +5 handle of Src physical page numbers (and thus disk +7 Dword Src Ptr addresses), while addresses less than 1M are +B Memory type dest deemed to be conventional memory. This 0 = Low mem process does not check that the low memory 1 = Extended actually exists. +C handle of Dest The handles of the source and dest may be +E Dword Dest Ptr the same, and must own sufficient pages to handle the move/exchange 25 (19h) Get Returns Segment of AH = 58h or 'X' AH = Status Subfunctions: mappable physical each physical page. AL = subfunction CX = number of 0 = Return segment of each page address array ES:DI = ptr to pages 1 = return number of physical pages array to receive ES:DI = array information. (Subfunction 0) Some EM managers can locate the window (Subfunction 0) 4 bytes per anywhere in normal memory, and can have more entry: than 4 pages. Segment : word VMS40 is restricted to 4 pages Page No : word 26 (1Ah) Get Only applicable to AH = 59h or 'Y' AH = status Returns some context information about Expanded Memory machines whose bios AL = subfunction Subfunction 0 : memory. Only valid if BIOS supports OS/2 Hardware contains support for ES:DI = ptr to ES:DI = 1024 functions Information OS2 functions array to receive (page size) information. +2 zero (word) Only sub function 0 supported. (Subfunction 0) +4 size of mapping array +6 zero (word) +8 zero (word) 27 (1Bh) Get Allocates a handle AH = 5Ah or 'Z' AH = status This is identical with function 4 handle and and pages in one BX = pages DX = handle (get handle and allocate memory) allocate pages function required 28 (1Ch) Save or set mapping AH = 5Bh or '[' AH = status Subfunctions: Alternate Map array information, AL = subfunction subfunction 0: 0 = Get alternate register set Register Set similar to function (0 to 8) ES:DI = mapping 1 = Set alternate register set 15 DS:SI = array info (as for 2 = Return size of mapping info array holding mapping 15.0) 3 = Deallocate map register set information subfunction 2: 4 = Deallocate Alternate map register set (subfunction 1) DX = bytes in 5 = Deallocate map register set ES:DI = array to page mapping 6,7,8 = unsupported receive mapping array information This function was added in EMS 4.0 and is (subfunction 0) designed to support multitasking operating systems. It should not be used ordinarily by application software. The array contains hardware and software dependent information that is necessary to restore the EMS system to its previous state. 29 (1Dh) This function is not Warmboot supported by VMS40 Preparations 30 (1Eh) OS/E This function checks AH = 5Dh or ']' AH = status If OS/E functions are available, then a functions the availability of AL = subfunction CX:BX = password password is created to allow the process to OS/E functions, and CX:BX password (Dword) access them. if available, returns a password Subfunctions: 0 = Enable Op Sys Functions 1 = Disable Op Sys Functions 2 = Clear password .RRL ! ! ! ! ! ! ! ! R