Showing changes from revision #3 to #4:
Added | Removed | Changed
Entry | |
---|---|
R0 | 21 (reason code) |
R1 | Area number |
R2 | Pointer to page list |
R3 | Number of entries in page list |
Exit | |
---|---|
R2 | Advanced to first entry not processed (or end of list) |
R3 | Number of entries not processed |
This call is used to claim/release physical memory pages in a Physical Memory Pool.
Each entry in the page list is 12 bytes in length, structured as follows:
Word | |
---|---|
0 | PMP page index (From zero to the max physical size of PMP) |
1 | Physical page number: |
-2: Kernel picks page number | |
-1: Release the page | |
Other: A standard physical page number, e.g. as returned by OS_Memory 12 | |
2 | Page flags: |
Bit 7: Page was previously reserved via OS_Memory 23 | |
Bit 15: Lock page to prevent it from being claimed by another dynamic area | |
Other bits: Reserved (ignored). Specify zero for future compatibility. |
The entries in the page list will be processed in order. For each entry the kernel will compare the state given in the list with the current state of that PMP page index and perform the appropriate action – claiming a page, releasing a page, or altering its flags. If the state of the page matches the state given in the list (or is a close enough match) then no action will be taken. E.g. if a page had previously been claimed by providing a specific page number, and then a new request is made for that page with the magic page number -2, no action will be performed. However if a different specific page number is given then the old page will be released and the new page will be claimed. Note that when pages are swapped in this manner the contents of the page will not be preserved.
If an error occurs then R2 and R3 will be updated to point to the first entry that has not been processed. However this may not be the entry that generated the error (it might be caused by an entry further on in the list).
When requesting specific page numbers, it’s recommended to also set bit 15 of the page flags, to prevent other dynamic areas from claiming the page. This will produce behaviour that is consistent with standard dynamic areas which request specific physical pages via their PreGrow handler . When locking a page in this manner, bit 7 must be specified if the page had been previously reserved viaOS_Memory 23. This is a simple safety feature aimed at reducing the risk of buggy dynamic area handlers accidentally claiming pages which had been reserved by someone else.
When releasing a page, the flags specified in word 2 of the page list entry are ignored.
The initial state of a page after it has been allocated to a PMP is for it to not be mapped in to the logical address space. To map or unmap pages within your logical address space you must use OS_DynamicArea 22.
Attempting to release or swap a page which is currently mapped in will fail – you must first unmap the page via OS_DynamicArea 22.