OSMem 9.22 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
; Copyright 2016 Castle Technology Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
;     http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;

; Definitions for OS_DynamicArea, OS_Memory and other related SWIs

18 19 20 21 22 23 24 25 26 27 28 29 30
; System-defined dynamic area numbers
                     ^ -1
ChangeDyn_AplSpace   # 1 ; -1, Not recognised by all APIs
ChangeDyn_SysHeap    # 1 ; 0
ChangeDyn_RMA        # 1 ; 1
ChangeDyn_Screen     # 1 ; 2
ChangeDyn_SpriteArea # 1 ; 3
ChangeDyn_FontArea   # 1 ; 4
ChangeDyn_RamFS      # 1 ; 5
ChangeDyn_FreePool   # 1 ; 6
ChangeDyn_MaxArea    # 0 ; For internal use by kernel
ReadDyn_ReturnMax    * 128 ; OS_ReadDynamicArea flag to return max size of area in R2 (for areas 0 to 127 inclusive; other areas always return max size)

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
; OS_DynamicArea reason codes

DAReason_Create          *  0
DAReason_Remove          *  1
DAReason_GetInfo         *  2
DAReason_Enumerate       *  3
DAReason_Renumber        *  4
DAReason_ReturnFree      *  5
DAReason_GetChangeInfo   *  6   ; Internal use only (intended for TaskManager)
DAReason_EnumerateInfo   *  7   ; Internal use only (intended for TaskManager)
DAReason_SetClamps       *  8
DAReason_SparseClaim     *  9
DAReason_SparseRelease   * 10
                                ; Reasons 11-19 allocated to ROL
DAReason_LocateAddress   * 20
DAReason_PMP_PhysOp      * 21
DAReason_PMP_LogOp       * 22
DAReason_PMP_Resize      * 23
DAReason_PMP_GetInfo     * 24
DAReason_PMP_GetPages    * 25
51
DAReason_AplSpaceLimit   * 26
52 53 54
DAReason_ReturnFreePages * 27
DAReason_EnumerateInfo2  * 28
DAReason_Limit           * 29   ;end of defined DA reasons
55 56 57 58 59 60 61 62 63 64 65 66 67

; Dynamic area / page flags

DynAreaFlags_APBits             * 15 :SHL:  0
DynAreaFlags_NotBufferable      *  1 :SHL:  4
DynAreaFlags_NotCacheable       *  1 :SHL:  5
DynAreaFlags_DoublyMapped       *  1 :SHL:  6
DynAreaFlags_NotUserDraggable   *  1 :SHL:  7
DynAreaFlags_NeedsSpecificPages *  1 :SHL:  8   ; whether area will ever require particular physical pages
DynAreaFlags_Shrinkable         *  1 :SHL:  9   ; whether area may be shrunk when need more space in free pool
DynAreaFlags_SparseMap          *  1 :SHL: 10   ; whether area may have non-contiguous mapping of pages (Holey dynamic areas Batman!)
DynAreaFlags_PiersBinding       *  1 :SHL: 11   ; whether area is bound to client application, and so may be swapped out with it (not implemented yet)
DynAreaFlags_CPBits             *  7 :SHL: 12   ; cache policy variant for NotBufferable and NotCacheable bits
68
DynAreaFlags_CPShift            *          12   ; shift amount for the above
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
DynAreaFlags_NeedsDMA           *  1 :SHL: 15   ; only allocate from DMAable memory
; Bits 16-19 are used by RISCOS Ltd. We can reuse them for internal flags, but
; should probably avoid allocating any public flags.
DynAreaFlags_PMP                *  1 :SHL: 20   ; DA is backed by PMP/page is member of PMP

; Cache policies
;
CP_NCNB_Default                 * 0             ; no policy variants

CP_NCB_Default                  * 0             ; OS decides buffer policy (currently always MergingIdempotent)
CP_NCB_NonMerging               * 1             ; Non-merging write buffer. If not available, unbuffered.
CP_NCB_Merging                  * 2             ; Merging write buffer. If not available, non-merging.
CP_NCB_MergingIdempotent        * 3             ; Merging write buffer with idempotent memory (i.e. VMSA "Normal" non-cacheable type). If not available, merging write buffer.

CP_CNB_Default                  * 0             ; OS decides cache policy (writethrough). NCNB if not available
CP_CNB_Writethrough             * 1             ; Writethrough cacheable, non-buffered. If not available, NCNB.
CP_CNB_Writeback                * 2             ; Writeback cacheable, non-buffered. If not available,CNB_Writethrough.

CP_CB_Default                   * 0             ; OS decides cache policy (WB if available, W alloc if HAL requests)
CP_CB_Writethrough              * 1             ; Writethrough cacheable, read allocate. If not available, NCB_Merging
CP_CB_WritebackReadAlloc        * 2             ; Writeback cacheable, read allocate. If not available, writethrough.
CP_CB_WritebackWriteAlloc       * 3             ; Writeback cacheable, write allocate. If not available, WB/R.
91
CP_CB_AlternativeDCache         * 4             ; Use XScale/SA11x0 mini-data cache. If not available, CB_Default. For ARMv6+, this selects inner write-through, outer write-back (write alloc).
92 93 94 95 96 97 98 99 100

;
; Public page flags (note - may overlap DA flags)
;
; APBits, NotBufferable, NotCacheable, DoublyMapped, CPBits and PMP are the
; DA flags which are also (public) page flags.
;
; N.B. not all public flags are writable.
;
101 102
PageFlags_Reserved              *  1 :SHL: 7    ; physical page has been reserved for future use. It can still be allocated to arbitrary DAs, but only the program that reserved it can claim it for exclusive use (PageFlags_Unavailable)
PageFlags_Unavailable           *  1 :SHL: 15   ; physical page has been claimed by someone for exclusive use (can't be requested by PreGrow handler or PMP PhysOp page list)
103 104 105 106 107 108 109 110 111 112 113 114


; Dynamic area handler reason codes

DAHandler_PreGrow       *       0
DAHandler_PostGrow      *       1
DAHandler_PreShrink     *       2
DAHandler_PostShrink    *       3
DAHandler_TestShrink    *       4       ; Shrinkable DAs: Find abount can shrink by
DAHandler_Abort         *       5       ; ROL abortable DAs
DAHandler_ResizePMP     *       6       ; PMP DAs: Called on OS_ChangeDynamicArea

115 116
DAHandler_RESV          *       &56534552 ; "RESV" magic value for use by PreGrow handlers

117 118 119 120 121 122 123 124 125 126 127 128 129 130
; OS_Memory reason codes

OSMemReason_Convert                * 0  ; Convert PA <-> LA <-> PN, alter cacheability
OSMemReason_PhysSize               * 6  ; Return physical memory arrangement table info
OSMemReason_ReadPhys               * 7  ; Read physical memory arrangement table
OSMemReason_Amounts                * 8  ; Return amounts of various memory types
OSMemReason_IOSpace                * 9  ; Return controller presence/base address
OSMemReason_RecommendPage          * 12 ; Recommend contiguous pages for DA grow handler
OSMemReason_MapIOPermanent         * 13 ; Map in IO area
OSMemReason_AccessPhysAddr         * 14 ; Temporarily map in phys addr
OSMemReason_ReleasePhysAddr        * 15 ; Release the temp mapping
OSMemReason_MemoryAreaInfo         * 16 ; Return size & location of various non-DA areas
OSMemReason_MemoryAccessPrivileges * 17 ; Decode AP numbers into permission flags
OSMemReason_FindAccessPrivilege    * 18 ; Find best AP number from given permission flags
131
OSMemReason_DMAPrep                * 19 ; Convert PA <-> LA, perform cache maintenance required for DMA
132
OSMemReason_Compatibility          * 20 ; Get/set compatibility settings
133
OSMemReason_MapIO64Permanent       * 21 ; Map in IO area from 64-bit space
134
OSMemReason_AccessPhysAddr64       * 22 ; Temporarily map in 64-bit phys addr
135
OSMemReason_ReservePages           * 23 ; Reserve (or un-reserve) pages
136 137 138 139 140 141 142 143 144 145
OSMemReason_CheckMemoryAccess      * 24 ; Return attributes/permissions for a logical address range

; OS_Memory 17/18 permission flags
MemPermission_UserX    * 1<<0 ; Executable in user mode
MemPermission_UserW    * 1<<1 ; Writable in user mode
MemPermission_UserR    * 1<<2 ; Readable in user mode
MemPermission_PrivX    * 1<<3 ; Executable in privileged modes
MemPermission_PrivW    * 1<<4 ; Writable in privileged modes
MemPermission_PrivR    * 1<<5 ; Readable in privileged modes

146 147 148 149 150 151
; OS_Memory 19 (DMAPrep) flags
DMAPrep_PhysProvided   * 1<<8  ; Input function provides physical addresses, not logical
DMAPrep_Write          * 1<<9  ; DMA is writing to RAM
DMAPrep_End            * 1<<10 ; DMA is complete, perform any post-op cache maintenance
DMAPrep_UseBounceBuffer * 1 ; Input/output function flag: Must use bounce buffer for this block

152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
; OS_Memory 24 (CheckMemoryAccess) flags
CMA_Completely_UserR   * 1<<0  ; completely readable in user mode
CMA_Completely_UserW   * 1<<1  ; completely writable in user mode
CMA_Completely_PrivR   * 1<<2  ; completely readable in privileged modes
CMA_Completely_PrivW   * 1<<3  ; completely writable in privileged modes
CMA_Partially_UserR    * 1<<4  ; partially readable in user mode
CMA_Partially_UserW    * 1<<5  ; partially writable in user mode
CMA_Partially_PrivR    * 1<<6  ; partially readable in privileged modes
CMA_Partially_PrivW    * 1<<7  ; partially writable in privileged modes
CMA_Completely_Phys    * 1<<8  ; completely physically mapped (i.e. IO memory)
CMA_Completely_Abort   * 1<<9  ; completely abortable (i.e. custom data abort handler)
CMA_Completely_UserXN  * 1<<10 ; completely non-executable in user mode
CMA_Completely_PrivXN  * 1<<11 ; completely non-executable in privileged modes
CMA_Partially_Phys     * 1<<12 ; partially physically mapped
CMA_Partially_Abort    * 1<<13 ; partially abortable
CMA_Partially_UserXN   * 1<<14 ; partially non-executable in user mode
CMA_Partially_PrivXN   * 1<<15 ; partially non-executable in privileged modes

        END