Returning PMP pages to original locations
Lee Noar (2750) 16 posts |
I’ve successfully moved pages within a PMP DA with OS_DynamicArea
Where page 1 is claimed, but not mapped and page 2 is claimed, mapped and contains data. What’s the correct way to move page 2 back to its original location? Is it:
Move the page at page location 1 back to page 2’s location, or:
Unmap the page at page location 1; will the page automatically be returned to its original page 2 location? Or:
Move page 2 to page 2’s location? Or something else? Thanks, |
Jeffrey Lee (213) 6048 posts |
I think you’re a bit confused over the different indexing schemes. Perhaps this hastily drawn diagram will help? (it’s a bit big, but it turns out I don’t have any vector graphics software on my work computer, so just deal with it) In total there are three different types of index (or I guess five if you include logical & physical addresses).
So looking at your first call: entry.da_page_number = 1; entry.pmp_page_index = 2; entry.flags = 0; The OS will actually perform the following process:
So to answer the question “What’s the correct way to move page 2 back to its original location?”, the correct way would be to first work out what the original location was (maybe your code already knows it, or maybe it should use OS_DynamicArea 25 to look it up), and then issue a call like the following: entry.da_page_number = original_location; entry.pmp_page_index = 2; entry.flags = 0; |
Rick Murray (539) 13851 posts |
How does task switching fit into this? I’m trying to work out how the AMB stuff works and what the Wimp does with it, but it’s not simple! |
Jeffrey Lee (213) 6048 posts |
Original AMB implementation: Each AMB stored a list of physical pages, and the code manipulated the memory map manually. This allowed the memory to be mapped in/out similar to how PMPs support it, but the code wasn’t very well integrated with the kernel’s core memory management, so some operations suffered from inefficiencies. New AMB implementation: Each AMB has a PMP dynamic area associated with it. This allows the standard DA/PMP memory mapping functions to be used (although for performance a number of the original AMB functions are still used – they were well optimised for their respective tasks and it’s hard for the generic DA/PMP functions to compete). But there’s still one horrible hack, which is that the DAs all overlap (they have a base address of &8000), so the system still has to be careful not to allow multiple AMBs to be mapped in ontop of each other (since the standard DA/PMP code isn’t designed to cope with that). Also to avoid confusing other software the dynamic areas aren’t included in the main dynamic area list (so OS_DynamicArea 3 will never return the DA), which also means that the AMB code has to use special backdoors into OS_DynamicArea which allow it to provide a direct pointer to the area instead of using DA numbers. |
Lee Noar (2750) 16 posts |
More than likely :-)
Yes, thanks. Just to be clear, when I talk about returning pages to their original location, I mean their original logical position from when I first claimed and mapped the pages.
Maybe this is where I’m going wrong. I’m using this code to generate the mapping arrays where client_library→map and client_library→unmap are arrays of pmp_log_page_entry.
So if I have mapped that page to DA page 1 as in the first call, will setting original_location to 2 cause it to be mapped back to DA page 2? Or is the page numbering not that simple? Sorry if I’m not getting it, hopefully it’ll click in the near future :-) |
Jeffrey Lee (213) 6048 posts |
When you claim a page using OS_DynamicArea 21, it won’t be mapped to any logical address (I’ll add that note to the wiki!) You can unmap pages by specifying a PMP page index of -1 to OS_DynamicArea 22; i.e. your loop probably wants to do the following: client_library->unmap[i].da_page_number = da_page_num; client_library->unmap[i].pmp_page_index = -1; (Note that the flags are ignored when mapping out) |