h6. [[OS_DynamicArea]] h6(. » OS_DynamicArea 0 h2. OS_DynamicArea 0 h5. (SWI &66) |_<^{width:3em}. Entry | | |<^. R0 |<^. 0 (reason code) | |<^. R1 |<^. -1 (or new area number 128-255; reserved for internal use) | |<^. R2 |<^. Initial logical size of area, in bytes | |<^. R3 |<^. -1 (or base of area; reserved for internal use) | |<^. R4 |<^. [[Dynamic Area Flags|Area flags]] vary by OS; see note | |<^. R5 |<^. Maximum logical size of area in bytes, or -1 for unlimited (see notes) | |<^. R6 |<^. [[Dynamic Area Handler Code|Handler routine]] | |<^. R7 |<^. Pointer to workspace for handler, or -1 for base of area | |<^. R8 |<^. Pointer to name of area (limited to 31-chars in 3.80+) | |<^. R9 |<^. Initial maximum physical size of [[Physical Memory Pool|PMP]] in pages (if area is a PMP; otherwise, unused) | |_<^{width:3em}. Exit | | |<^. R1 |<^. Allocated area number | |<^. R3 |<^. Base of area | |<^. R5 |<^. Maximum logical size of area | |<^. R9 |<^. Maximum physical size of area (if area is a PMP; otherwise, preserved) | |\2<^. All other registers preserved | h4. Use The purpose of this call is to create a new dynamic area. h4. Notes Area numbers allocated are greater than or equal to 256. The setting R5 as -1 is *strongly* deprecated due to the problems of address space exhaustion on large memory machines. Also, a maximum size of -1 has no valid meaning for [[Sparse Dynamic Areas|Sparse]] areas. New code should set the smallest maximum size that is sensible for the use required. Because old code may often use -1, a clamp may be set via [[OS_DynamicArea 8]] in order to limit the address space exhaustion problem. Area flags in b12-15 vary by OS version - specifically if [[OS_Byte 129 (OS)]] returns &AA. h4. PMPs When creating a PMP, arguments must be set as follows: * The "Requires specific pages" flag (bit 8) must be set * The "Sparse" (bit 10), doubly-mapped (bit 6) and DMA auto-alloc (bit 15) flags must be clear * The initial logical size (R2) must be zero * A handler routine (R6) must be provided When the PMP is created it will have no pages assigned to it. If necessary, the maximum physical size specified in R9 will be clamped to the total number of pages in the system - therefore you can specify -1 in order to create the largest possible PMP. However this will also require the kernel to allocate a large amount of memory for storing the page list, so to reduce memory wastage it's recommended to dynamically adjust the maximum physical size of the PMP in order to avoid situations where a large PMP only has a small number of pages allocated to it. The maximum logical size of a PMP will be clamped using the same rules as for regular dynamic areas. If the maximum logical size was zero then the PMP will have no logical space allocated to it and will return with R3 equal to zero. h4. See also * [[Dynamic Area Flags]] * [[Dynamic Area Handler Code]] * [[OS_DynamicArea]] * [[OS_DynamicArea 8]] * [[Sparse Dynamic Areas]] * [[Physical Memory Pool]]