h6. [[OS SWI Calls]] h6(. » [[OS_Memory]] h6((. » OS_Memory 23 h2. OS_Memory 23 h5. (SWI &68) |_<^{width:4em}. Entry | | |/3<^. R0 |<^. 23, and flags: | |<^. Bit 8: 0 to reserve, 1 to release reservation | |<^. Bits 9+: Reserved (set to 0) | |<^. R1 |<^. Base page number | |<^. R2 |<^. Number of pages | |_<^{width:4em}. Exit | | |<^. R0 |<^. Preserved | |<^. R1 |<^. Preserved | |<^. R2 |<^. Preserved | h4. Use The purpose of this call is to reserve a consecutive number of RAM pages, or to release the reservation of a consecutive number of RAM pages. This is the only call which can alter bit 7 of the [[Memory Page Access Flags]]. h4. Notes When reserving a range of pages, if any of the pages are already reserved the operation will fail with an error without modifying the reservation state of any of the pages. h4. Behaviour of reserved pages Reserved pages differ from un-reserved pages in the following ways: * [[OS_Memory 12]] will not recommend a range containing reserved pages * [[Dynamic Area PreGrow]] handlers will not be allowed to add the page to a dynamic area, unless the special "RESV" return value is used * [[OS_DynamicArea 21]] will be prevented from locking the page into the dynamic area, unless the entry in the page block also sets bit 7 to 1 ** If bit 7 is not set in the page block, but the page number is set to -2 (indicating the kernel can pick a page), the kernel will attempt to swap the reserved page for an un-reserved page Reserved pages are intended to be used in situations where a program knows that it needs a certain set of physical pages (e.g. for future use by another bus master), but it doesn't need all of the pages right now. For example, the PCI heap (used for [[PCI_RAMAlloc]] & [[PCI_RAMFree]]) and the legacy screen dynamic area are both dynamic areas which grow and shrink on demand, but also require physically contiguous memory to operate correctly. It's always been the case that pages which have been explicitly requested by PreGrow handlers won't be recommended by [[OS_Memory 12]], and can't be requested by other dynamic areas. This protects the memory which the PCI heap & screen are currently using. But [[OS_Memory 12]] has no knowledge about what memory they may want to use in the future. So if a third dynamic area comes along which wants physically contiguous pages, [[OS_Memory 12]] may recommend that it uses pages which the PCI module was intending to use. When the third dynamic area makes use of that memory, it will be blocking the PCI heap from growing above a certain size, even if there's plenty of other free memory spare in the system. OS_Memory 23 solves this problem by allowing the dynamic area owners to signify their intent to use the memory (in addition to providing some protection against dynamic areas accidentally using pages which have been reserved by other systems). h4. See also * [[OS_Memory]] * [[OS_Memory 12]] * [[Memory Page Access Flags]] * [[Dynamic Area PreGrow]] * [[OS_DynamicArea 21]]