Support RAM banks with high physical addresses
Memory handling improvements & API extensions to add support for the use of RAM outside the low 4GB of the physical address space. Also, add support for runtime selection of whether long or short descriptor page tables are used, so that we can continue to use one ROM for all models of Pi.
Summary of API changes/extensions:
- OS_Memory 12 (RecommendPage) has been extended to allow R4-R7 to be used to specify a (64bit) physical address range which the recommended pages must lie within. For backwards compatibility this defaults to 0-4GB.
- Added OS_Memory 64, which is OS_Memory 0 but with 64bit addresses (64bit physical addresses for LPAE support, and 64bit logical addresses for AArch64 future-proofing)
- RISCOS_LogToPhys upgraded to allow it to cope with all page types (added support for 64KB "large" pages and lazily-mapped pages)
- Added OS_Memory 65, which calls through to RISCOS_LogToPhys, to allow regular software to do logical-to-physical conversions for all page types (other calls, like OS_Memory 0/64, typically only work with 4KB pages)
- Added Service_PagesUnsafe64 & Service_PagesSafe64, which are Service_PagesUnsafe / PagesSafe but with 64bit addresses (using same block format as OS_Memory 64, like their predecessors which used the OS_Memory 0 format)
- OS_Memory 19 (DMAPrep) has a flag to allow 64bit physical addresses to be used
- OS_PlatformFeatures 0 has a new flag (CPUFlag_HighRAM) which is set if any RAM is present which has a > 32bit physical address (a hint that apps should use the new 64bit APIs instead of older 32bit ones)
- PhysRamTable now stores addresses in page units instead of byte units. This change is advertised via OS_ReadSysInfo 6 item 89
- Note all the above changes apply to all kernel builds, regardless of whether long descriptor page table support is enabled
Since there are still some important bits of long descriptor page table support which haven't been sufficiently dealt with yet (e.g. support for the "usermode read-only, privileged read/write" memory permission), long descriptor page table support still remains disabled by default.
ROMs tested on 4GB IGEPv5 (short, long & runtime page table modes), Titanium (short & long), and IOMD (and other platforms with previous versions of the code - 8GB Pi 4, etc.).