include vmm.inc VMMcall _XchgFreePhysReg, <LinPgNum, PhysAddr, flags> cmp eax, 0FFFFFFFFh ; 0FFFFFFFFh if error je not_exchanged mov [PageTable], eax ; previous page-table entry |
The _XchgFreePhysReg service replaces the current physical address in a page-table entry with a new physical address. A virtual device typically uses this service to compact a free physical region by assigning pages that are present to adjacent linear addresses (that is, by removing not-present pages from between present pages).
This is an asynchronous service.
LinPgNum
Specifies the linear page number of the first page in the region to exchange. A linear page number is a linear address shifted right by 12 bits. The specified page must be within a free physical region previously allocated using the _PageAllocate service.
PhysAddr
Specifies the physical address to insert into the page-table entry specified by the LinPgNum parameter. This parameter must be a 32-bit physical address. If this parameter is zero, the service makes the page not present.
flags
Specifies the operation flags. This parameter must be set to 0.
The EAX register contains the previous physical address for the specified page if the service is successful. If the specified page is not present, EAX contains zero. Otherwise, EAX contains 0FFFFFFFFh to indicate an error, such as an invalid linear page number.
A virtual device typically makes a series of calls to _XchgFreePhysReg, using the physical address return by one call as the parameter in the next call. To start the series, the virtual device sets the PhysAddr parameter to zero, and specifies a page known to be present. This forces the present page to be not present. The virtual device continues calling the service, specifying different page numbers, until the service returns 0.
This service cannot be used to change the number of pages which were mapped using the PageFixed value with the _MapFreePhysReg service.
The virtual page swap device uses this service to read ahead, and write behind without having to copy data. Using the _XchgFreePhysReg service in this way is restricted to the virtual page swap device.
Failure to use this service properly can result in invalid page faults and loss of pages.
EAX