OSMem 11.4 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
; 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
29 30 31 32 33 34 35 36 37 38 39 40 41 42
ChangeDyn_VRAMRescue              # 1 ; 7  RISC OS 6
ChangeDyn_KernelBuffers           # 2 ; 8  RISC OS 6
ChangeDyn_AbortSVCAndIRQStackCopy # 1 ; 10 RISC OS 6
ChangeDyn_OperatingSystemROM      # 1 ; 11 RISC OS 6
ChangeDyn_SWIDispatchIRQWorkspace # 1 ; 12 RISC OS 6
ChangeDyn_SVCStack                # 1 ; 13 RISC OS 6
ChangeDyn_IRQStack                # 1 ; 14 RISC OS 6
ChangeDyn_UNDStack                # 1 ; 15 RISC OS 6
ChangeDyn_Level2PageTables        # 1 ; 16 RISC OS 6
ChangeDyn_SoftCAM                 # 1 ; 17 RISC OS 6
ChangeDyn_SystemInit              # 1 ; 18 RISC OS 6
                                  ^ 48
ChangeDyn_ZeroPage                # 1 ; 48 Pyromaniac
ChangeDyn_HighVectors             # 1 ; 49 Pyromaniac
43 44
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)

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
; 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
65
DAReason_AplSpaceLimit   * 26
66 67 68
DAReason_ReturnFreePages * 27
DAReason_EnumerateInfo2  * 28
DAReason_Limit           * 29   ;end of defined DA reasons
69 70 71

; Dynamic area / page flags

72 73 74 75
DynAreaFlags_APFull             *  0 :SHL:  0   ; user r/w/x, priv r/w/x
DynAreaFlags_APRead             *  1 :SHL:  0   ; user r/x, priv r/w/x
DynAreaFlags_APNone             *  2 :SHL:  0   ; user none, priv r/w/x
DynAreaFlags_APROM              *  3 :SHL:  0   ; user r/x, priv r/x
76 77 78 79 80 81 82 83 84 85
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
86
DynAreaFlags_CPShift            *          12   ; shift amount for the above
87
DynAreaFlags_NeedsDMA           *  1 :SHL: 15   ; only allocate from DMAable memory
Jeffrey Lee's avatar
Jeffrey Lee committed
88 89
DynAreaFlags_Abortable          *  1 :SHL: 16   ; "Abortable" DA which is integrated with the AbortTrap system
; Bits 17-19 are used by RISCOS Ltd. We can reuse them for internal flags, but
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
; 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.
110
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).
111 112 113 114 115 116 117 118 119

;
; 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.
;
120 121
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)
122 123 124 125 126 127 128 129 130 131 132 133


; 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

134 135
DAHandler_RESV          *       &56534552 ; "RESV" magic value for use by PreGrow handlers

136 137
; OS_Memory reason codes

138
OSMemReason_Convert                * 0  ; Convert PA <-> LA <-> PN, alter cacheability, with 32bit addresses
139 140 141 142 143 144 145 146 147 148 149
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
150
OSMemReason_DMAPrep                * 19 ; Convert PA <-> LA, perform cache maintenance required for DMA
151
OSMemReason_Compatibility          * 20 ; Get/set compatibility settings
152
OSMemReason_MapIO64Permanent       * 21 ; Map in IO area from 64-bit space
153
OSMemReason_AccessPhysAddr64       * 22 ; Temporarily map in 64-bit phys addr
154
OSMemReason_ReservePages           * 23 ; Reserve (or un-reserve) pages
155
OSMemReason_CheckMemoryAccess      * 24 ; Return attributes/permissions for a logical address range
156
OSMemReason_Convert64              * 64 ; Convert PA <-> LA <-> PN, alter cacheability, with 64bit addresses
157
OSMemReason_LogToPhys              * 65 ; Convert LA -> PA, supporting all page types
158 159 160 161 162 163 164 165 166

; 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

167 168 169 170
; 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
171
DMAPrep_Phys64         * 1<<11 ; Physical addresses are 64bit
172 173
DMAPrep_UseBounceBuffer * 1 ; Input/output function flag: Must use bounce buffer for this block

174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
; 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

Jeffrey Lee's avatar
Jeffrey Lee committed
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
; OS_AbortTrap reason codes
OSAbortTrap_Register   * 0
OSAbortTrap_Deregister * 1

; AbortTrap / abortable DA handler reason codes
AbortTrap_Reason_Store  * 0 ; Store to memory
AbortTrap_Reason_Load   * 1 ; Load from memory
AbortTrap_Reason_MemMap * 2 ; Map in memory with (at least) the indicated permissions
AbortTrap_Reason_Mask   * &F
AbortTrap_LoadStore_Privileged * &10 ; Indicates that Store or Load access is privileged
AbortTrap_MemMap_UserX  * 1<<4 ; Executable in user mode
AbortTrap_MemMap_UserW  * 1<<5 ; Writable in user mode
AbortTrap_MemMap_UserR  * 1<<6 ; Readable in user mode
AbortTrap_MemMap_PrivX  * 1<<7 ; Executable in privileged modes
AbortTrap_MemMap_PrivW  * 1<<8 ; Writable in privileged modes
AbortTrap_MemMap_PrivR  * 1<<9 ; Readable in privileged modes


210
        END