rgx_mips.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. /*************************************************************************/ /*!
  2. @File rgx_mips.h
  3. @Title
  4. @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
  5. @Platform RGX
  6. @Description RGX MIPS definitions, kernel/user space
  7. @License Dual MIT/GPLv2
  8. The contents of this file are subject to the MIT license as set out below.
  9. Permission is hereby granted, free of charge, to any person obtaining a copy
  10. of this software and associated documentation files (the "Software"), to deal
  11. in the Software without restriction, including without limitation the rights
  12. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. copies of the Software, and to permit persons to whom the Software is
  14. furnished to do so, subject to the following conditions:
  15. The above copyright notice and this permission notice shall be included in
  16. all copies or substantial portions of the Software.
  17. Alternatively, the contents of this file may be used under the terms of
  18. the GNU General Public License Version 2 ("GPL") in which case the provisions
  19. of GPL are applicable instead of those above.
  20. If you wish to allow use of your version of this file only under the terms of
  21. GPL, and not to allow others to use your version of this file under the terms
  22. of the MIT license, indicate your decision by deleting the provisions above
  23. and replace them with the notice and other provisions required by GPL as set
  24. out in the file called "GPL-COPYING" included in this distribution. If you do
  25. not delete the provisions above, a recipient may use your version of this file
  26. under the terms of either the MIT license or GPL.
  27. This License is also included in this distribution in the file called
  28. "MIT-COPYING".
  29. EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
  30. PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
  31. BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  32. PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
  33. COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  34. IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  35. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  36. */ /**************************************************************************/
  37. #if !defined(RGX_MIPS_H)
  38. #define RGX_MIPS_H
  39. /*
  40. * Utility defines for memory management
  41. */
  42. #define RGXMIPSFW_LOG2_PAGE_SIZE_4K (12)
  43. #define RGXMIPSFW_PAGE_SIZE_4K (0x1 << RGXMIPSFW_LOG2_PAGE_SIZE_4K)
  44. #define RGXMIPSFW_PAGE_MASK_4K (RGXMIPSFW_PAGE_SIZE_4K - 1)
  45. #define RGXMIPSFW_LOG2_PAGE_SIZE_64K (16)
  46. #define RGXMIPSFW_PAGE_SIZE_64K (0x1 << RGXMIPSFW_LOG2_PAGE_SIZE_64K)
  47. #define RGXMIPSFW_PAGE_MASK_64K (RGXMIPSFW_PAGE_SIZE_64K - 1)
  48. #define RGXMIPSFW_LOG2_PAGE_SIZE_256K (18)
  49. #define RGXMIPSFW_PAGE_SIZE_256K (0x1 << RGXMIPSFW_LOG2_PAGE_SIZE_256K)
  50. #define RGXMIPSFW_PAGE_MASK_256K (RGXMIPSFW_PAGE_SIZE_256K - 1)
  51. #define RGXMIPSFW_LOG2_PAGE_SIZE_1MB (20)
  52. #define RGXMIPSFW_PAGE_SIZE_1MB (0x1 << RGXMIPSFW_LOG2_PAGE_SIZE_1MB)
  53. #define RGXMIPSFW_PAGE_MASK_1MB (RGXMIPSFW_PAGE_SIZE_1MB - 1)
  54. #define RGXMIPSFW_LOG2_PAGE_SIZE_4MB (22)
  55. #define RGXMIPSFW_PAGE_SIZE_4MB (0x1 << RGXMIPSFW_LOG2_PAGE_SIZE_4MB)
  56. #define RGXMIPSFW_PAGE_MASK_4MB (RGXMIPSFW_PAGE_SIZE_4MB - 1)
  57. #define RGXMIPSFW_LOG2_PTE_ENTRY_SIZE (2)
  58. /* log2 page table sizes dependent on FW heap size and page size (for each OS) */
  59. #define RGXMIPSFW_LOG2_PAGETABLE_SIZE_4K (RGX_FIRMWARE_HEAP_SHIFT - RGXMIPSFW_LOG2_PAGE_SIZE_4K + RGXMIPSFW_LOG2_PTE_ENTRY_SIZE)
  60. #define RGXMIPSFW_LOG2_PAGETABLE_SIZE_64K (RGX_FIRMWARE_HEAP_SHIFT - RGXMIPSFW_LOG2_PAGE_SIZE_64K + RGXMIPSFW_LOG2_PTE_ENTRY_SIZE)
  61. /* Maximum number of page table pages (both Host and MIPS pages) */
  62. #define RGXMIPSFW_MAX_NUM_PAGETABLE_PAGES (4)
  63. /* Total number of TLB entries */
  64. #define RGXMIPSFW_NUMBER_OF_TLB_ENTRIES (16)
  65. /* "Uncached" caching policy */
  66. #define RGXMIPSFW_UNCACHED_CACHE_POLICY (0X00000002)
  67. /* "Write-back write-allocate" caching policy */
  68. #define RGXMIPSFW_WRITEBACK_CACHE_POLICY (0X00000003)
  69. /* "Write-through no write-allocate" caching policy */
  70. #define RGXMIPSFW_WRITETHROUGH_CACHE_POLICY (0X00000001)
  71. /* Cached policy used by MIPS in case of physical bus on 32 bit */
  72. #define RGXMIPSFW_CACHED_POLICY (RGXMIPSFW_WRITEBACK_CACHE_POLICY)
  73. /* Cached policy used by MIPS in case of physical bus on more than 32 bit */
  74. #define RGXMIPSFW_CACHED_POLICY_ABOVE_32BIT (RGXMIPSFW_WRITETHROUGH_CACHE_POLICY)
  75. /* Total number of Remap entries */
  76. #define RGXMIPSFW_NUMBER_OF_REMAP_ENTRIES (2 * RGXMIPSFW_NUMBER_OF_TLB_ENTRIES)
  77. /*
  78. * MIPS EntryLo/PTE format
  79. */
  80. #define RGXMIPSFW_ENTRYLO_READ_INHIBIT_SHIFT (31U)
  81. #define RGXMIPSFW_ENTRYLO_READ_INHIBIT_CLRMSK (0X7FFFFFFF)
  82. #define RGXMIPSFW_ENTRYLO_READ_INHIBIT_EN (0X80000000)
  83. #define RGXMIPSFW_ENTRYLO_EXEC_INHIBIT_SHIFT (30U)
  84. #define RGXMIPSFW_ENTRYLO_EXEC_INHIBIT_CLRMSK (0XBFFFFFFF)
  85. #define RGXMIPSFW_ENTRYLO_EXEC_INHIBIT_EN (0X40000000)
  86. /* Page Frame Number */
  87. #define RGXMIPSFW_ENTRYLO_PFN_SHIFT (6)
  88. #define RGXMIPSFW_ENTRYLO_PFN_ALIGNSHIFT (12)
  89. /* Mask used for the MIPS Page Table in case of physical bus on 32 bit */
  90. #define RGXMIPSFW_ENTRYLO_PFN_MASK (0x03FFFFC0)
  91. #define RGXMIPSFW_ENTRYLO_PFN_SIZE (20)
  92. /* Mask used for the MIPS Page Table in case of physical bus on more than 32 bit */
  93. #define RGXMIPSFW_ENTRYLO_PFN_MASK_ABOVE_32BIT (0x3FFFFFC0)
  94. #define RGXMIPSFW_ENTRYLO_PFN_SIZE_ABOVE_32BIT (24)
  95. #define RGXMIPSFW_ADDR_TO_ENTRYLO_PFN_RSHIFT (RGXMIPSFW_ENTRYLO_PFN_ALIGNSHIFT - \
  96. RGXMIPSFW_ENTRYLO_PFN_SHIFT)
  97. #define RGXMIPSFW_ENTRYLO_CACHE_POLICY_SHIFT (3U)
  98. #define RGXMIPSFW_ENTRYLO_CACHE_POLICY_CLRMSK (0XFFFFFFC7)
  99. #define RGXMIPSFW_ENTRYLO_DIRTY_SHIFT (2U)
  100. #define RGXMIPSFW_ENTRYLO_DIRTY_CLRMSK (0XFFFFFFFB)
  101. #define RGXMIPSFW_ENTRYLO_DIRTY_EN (0X00000004)
  102. #define RGXMIPSFW_ENTRYLO_VALID_SHIFT (1U)
  103. #define RGXMIPSFW_ENTRYLO_VALID_CLRMSK (0XFFFFFFFD)
  104. #define RGXMIPSFW_ENTRYLO_VALID_EN (0X00000002)
  105. #define RGXMIPSFW_ENTRYLO_GLOBAL_SHIFT (0U)
  106. #define RGXMIPSFW_ENTRYLO_GLOBAL_CLRMSK (0XFFFFFFFE)
  107. #define RGXMIPSFW_ENTRYLO_GLOBAL_EN (0X00000001)
  108. #define RGXMIPSFW_ENTRYLO_DVG (RGXMIPSFW_ENTRYLO_DIRTY_EN | \
  109. RGXMIPSFW_ENTRYLO_VALID_EN | \
  110. RGXMIPSFW_ENTRYLO_GLOBAL_EN)
  111. #define RGXMIPSFW_ENTRYLO_UNCACHED (RGXMIPSFW_UNCACHED_CACHE_POLICY << \
  112. RGXMIPSFW_ENTRYLO_CACHE_POLICY_SHIFT)
  113. #define RGXMIPSFW_ENTRYLO_DVG_UNCACHED (RGXMIPSFW_ENTRYLO_DVG | RGXMIPSFW_ENTRYLO_UNCACHED)
  114. /* Remap Range Config Addr Out */
  115. /* These defines refer to the upper half of the Remap Range Config register */
  116. #define RGXMIPSFW_REMAP_RANGE_ADDR_OUT_MASK (0x0FFFFFF0)
  117. #define RGXMIPSFW_REMAP_RANGE_ADDR_OUT_SHIFT (4) /* wrt upper half of the register */
  118. #define RGXMIPSFW_REMAP_RANGE_ADDR_OUT_ALIGNSHIFT (12)
  119. #define RGXMIPSFW_ADDR_TO_RR_ADDR_OUT_RSHIFT (RGXMIPSFW_REMAP_RANGE_ADDR_OUT_ALIGNSHIFT - \
  120. RGXMIPSFW_REMAP_RANGE_ADDR_OUT_SHIFT)
  121. #if defined(SECURE_FW_CODE_OSID) && (SECURE_FW_CODE_OSID + 1 > 2)
  122. #define MIPS_FW_CODE_OSID (SECURE_FW_CODE_OSID)
  123. #elif defined(SECURE_FW_CODE_OSID)
  124. #define MIPS_FW_CODE_OSID (1U)
  125. #endif
  126. /*
  127. * Pages to trampoline problematic physical addresses:
  128. * - RGXMIPSFW_BOOT_REMAP_PHYS_ADDR_IN : 0x1FC0_0000
  129. * - RGXMIPSFW_DATA_REMAP_PHYS_ADDR_IN : 0x1FC0_1000
  130. * - RGXMIPSFW_CODE_REMAP_PHYS_ADDR_IN : 0x1FC0_2000
  131. * - (benign trampoline) : 0x1FC0_3000
  132. * that would otherwise be erroneously remapped by the MIPS wrapper
  133. * (see "Firmware virtual layout and remap configuration" section below)
  134. */
  135. #define RGXMIPSFW_TRAMPOLINE_LOG2_NUMPAGES (2)
  136. #define RGXMIPSFW_TRAMPOLINE_NUMPAGES (1 << RGXMIPSFW_TRAMPOLINE_LOG2_NUMPAGES)
  137. #define RGXMIPSFW_TRAMPOLINE_SIZE (RGXMIPSFW_TRAMPOLINE_NUMPAGES << RGXMIPSFW_LOG2_PAGE_SIZE_4K)
  138. #define RGXMIPSFW_TRAMPOLINE_LOG2_SEGMENT_SIZE (RGXMIPSFW_TRAMPOLINE_LOG2_NUMPAGES + RGXMIPSFW_LOG2_PAGE_SIZE_4K)
  139. #define RGXMIPSFW_TRAMPOLINE_TARGET_PHYS_ADDR (RGXMIPSFW_BOOT_REMAP_PHYS_ADDR_IN)
  140. #define RGXMIPSFW_TRAMPOLINE_OFFSET(a) (a - RGXMIPSFW_BOOT_REMAP_PHYS_ADDR_IN)
  141. #define RGXMIPSFW_SENSITIVE_ADDR(a) (RGXMIPSFW_BOOT_REMAP_PHYS_ADDR_IN == (~((1UL << RGXMIPSFW_TRAMPOLINE_LOG2_SEGMENT_SIZE)-1) & a))
  142. /*
  143. * Firmware virtual layout and remap configuration
  144. */
  145. /*
  146. * For each remap region we define:
  147. * - the virtual base used by the Firmware to access code/data through that region
  148. * - the microAptivAP physical address correspondent to the virtual base address,
  149. * used as input address and remapped to the actual physical address
  150. * - log2 of size of the region remapped by the MIPS wrapper, i.e. number of bits from
  151. * the bottom of the base input address that survive onto the output address
  152. * (this defines both the alignment and the maximum size of the remapped region)
  153. * - one or more code/data segments within the remapped region
  154. */
  155. /* Boot remap setup */
  156. #define RGXMIPSFW_BOOT_REMAP_VIRTUAL_BASE (0xBFC00000)
  157. #define RGXMIPSFW_BOOT_REMAP_PHYS_ADDR_IN (0x1FC00000)
  158. #define RGXMIPSFW_BOOT_REMAP_LOG2_SEGMENT_SIZE (12)
  159. #define RGXMIPSFW_BOOT_NMI_CODE_VIRTUAL_BASE (RGXMIPSFW_BOOT_REMAP_VIRTUAL_BASE)
  160. /* Data remap setup */
  161. #define RGXMIPSFW_DATA_REMAP_VIRTUAL_BASE (0xBFC01000)
  162. #define RGXMIPSFW_DATA_CACHED_REMAP_VIRTUAL_BASE (0x9FC01000)
  163. #define RGXMIPSFW_DATA_REMAP_PHYS_ADDR_IN (0x1FC01000)
  164. #define RGXMIPSFW_DATA_REMAP_LOG2_SEGMENT_SIZE (12)
  165. #define RGXMIPSFW_BOOT_NMI_DATA_VIRTUAL_BASE (RGXMIPSFW_DATA_REMAP_VIRTUAL_BASE)
  166. /* Code remap setup */
  167. #define RGXMIPSFW_CODE_REMAP_VIRTUAL_BASE (0x9FC02000)
  168. #define RGXMIPSFW_CODE_REMAP_PHYS_ADDR_IN (0x1FC02000)
  169. #define RGXMIPSFW_CODE_REMAP_LOG2_SEGMENT_SIZE (12)
  170. #define RGXMIPSFW_EXCEPTIONS_VIRTUAL_BASE (RGXMIPSFW_CODE_REMAP_VIRTUAL_BASE)
  171. /* Permanent mappings setup */
  172. #define RGXMIPSFW_PT_VIRTUAL_BASE (0xCF000000)
  173. #define RGXMIPSFW_REGISTERS_VIRTUAL_BASE (0xCF800000)
  174. #define RGXMIPSFW_STACK_VIRTUAL_BASE (0xCF600000)
  175. /*
  176. * Bootloader configuration data
  177. */
  178. /* Bootloader configuration offset (where RGXMIPSFW_BOOT_DATA lives)
  179. * within the bootloader/NMI data page */
  180. #define RGXMIPSFW_BOOTLDR_CONF_OFFSET (0x0)
  181. /*
  182. * NMI shared data
  183. */
  184. /* Base address of the shared data within the bootloader/NMI data page */
  185. #define RGXMIPSFW_NMI_SHARED_DATA_BASE (0x100)
  186. /* Size used by Debug dump data */
  187. #define RGXMIPSFW_NMI_SHARED_SIZE (0x2B0)
  188. /* Offsets in the NMI shared area in 32-bit words */
  189. #define RGXMIPSFW_NMI_SYNC_FLAG_OFFSET (0x0)
  190. #define RGXMIPSFW_NMI_STATE_OFFSET (0x1)
  191. #define RGXMIPSFW_NMI_ERROR_STATE_SET (0x1)
  192. /*
  193. * MIPS boot stage
  194. */
  195. #define RGXMIPSFW_BOOT_STAGE_OFFSET (0x400)
  196. /*
  197. * MIPS private data in the bootloader data page.
  198. * Memory below this offset is used by the FW only, no interface data allowed.
  199. */
  200. #define RGXMIPSFW_PRIVATE_DATA_OFFSET (0x800)
  201. /* The things that follow are excluded when compiling assembly sources */
  202. #if !defined(RGXMIPSFW_ASSEMBLY_CODE)
  203. #include "img_types.h"
  204. #include "km/rgxdefs_km.h"
  205. typedef struct
  206. {
  207. IMG_UINT64 ui64StackPhyAddr;
  208. IMG_UINT64 ui64RegBase;
  209. IMG_UINT64 aui64PTPhyAddr[RGXMIPSFW_MAX_NUM_PAGETABLE_PAGES];
  210. IMG_UINT32 ui32PTLog2PageSize;
  211. IMG_UINT32 ui32PTNumPages;
  212. IMG_UINT32 ui32Reserved1;
  213. IMG_UINT32 ui32Reserved2;
  214. } RGXMIPSFW_BOOT_DATA;
  215. #define RGXMIPSFW_GET_OFFSET_IN_DWORDS(offset) (offset / sizeof(IMG_UINT32))
  216. #define RGXMIPSFW_GET_OFFSET_IN_QWORDS(offset) (offset / sizeof(IMG_UINT64))
  217. /* Used for compatibility checks */
  218. #define RGXMIPSFW_ARCHTYPE_VER_CLRMSK (0xFFFFE3FFU)
  219. #define RGXMIPSFW_ARCHTYPE_VER_SHIFT (10U)
  220. #define RGXMIPSFW_CORE_ID_VALUE (0x001U)
  221. #define RGXFW_PROCESSOR_MIPS "MIPS"
  222. /* microAptivAP cache line size */
  223. #define RGXMIPSFW_MICROAPTIVEAP_CACHELINE_SIZE (16U)
  224. /* The SOCIF transactions are identified with the top 16 bits of the physical address emitted by the MIPS */
  225. #define RGXMIPSFW_WRAPPER_CONFIG_REGBANK_ADDR_ALIGN (16U)
  226. /* Values to put in the MIPS selectors for performance counters */
  227. #define RGXMIPSFW_PERF_COUNT_CTRL_ICACHE_ACCESSES_C0 (9U) /* Icache accesses in COUNTER0 */
  228. #define RGXMIPSFW_PERF_COUNT_CTRL_ICACHE_MISSES_C1 (9U) /* Icache misses in COUNTER1 */
  229. #define RGXMIPSFW_PERF_COUNT_CTRL_DCACHE_ACCESSES_C0 (10U) /* Dcache accesses in COUNTER0 */
  230. #define RGXMIPSFW_PERF_COUNT_CTRL_DCACHE_MISSES_C1 (11U) /* Dcache misses in COUNTER1 */
  231. #define RGXMIPSFW_PERF_COUNT_CTRL_ITLB_INSTR_ACCESSES_C0 (5U) /* ITLB instruction accesses in COUNTER0 */
  232. #define RGXMIPSFW_PERF_COUNT_CTRL_JTLB_INSTR_MISSES_C1 (7U) /* JTLB instruction accesses misses in COUNTER1 */
  233. #define RGXMIPSFW_PERF_COUNT_CTRL_INSTR_COMPLETED_C0 (1U) /* Instructions completed in COUNTER0 */
  234. #define RGXMIPSFW_PERF_COUNT_CTRL_JTLB_DATA_MISSES_C1 (8U) /* JTLB data misses in COUNTER1 */
  235. #define RGXMIPSFW_PERF_COUNT_CTRL_EVENT_SHIFT (5U) /* Shift for the Event field in the MIPS perf ctrl registers */
  236. /* Additional flags for performance counters. See MIPS manual for further reference */
  237. #define RGXMIPSFW_PERF_COUNT_CTRL_COUNT_USER_MODE (8U)
  238. #define RGXMIPSFW_PERF_COUNT_CTRL_COUNT_KERNEL_MODE (2U)
  239. #define RGXMIPSFW_PERF_COUNT_CTRL_COUNT_EXL (1U)
  240. #define RGXMIPSFW_C0_NBHWIRQ 8
  241. /* Macros to decode C0_Cause register */
  242. #define RGXMIPSFW_C0_CAUSE_EXCCODE(CAUSE) (((CAUSE) & 0x7c) >> 2)
  243. #define RGXMIPSFW_C0_CAUSE_EXCCODE_FWERROR 9
  244. /* Use only when Coprocessor Unusable exception */
  245. #define RGXMIPSFW_C0_CAUSE_UNUSABLE_UNIT(CAUSE) (((CAUSE) >> 28) & 0x3)
  246. #define RGXMIPSFW_C0_CAUSE_PENDING_HWIRQ(CAUSE) (((CAUSE) & 0x3fc00) >> 10)
  247. #define RGXMIPSFW_C0_CAUSE_FDCIPENDING (1UL << 21)
  248. #define RGXMIPSFW_C0_CAUSE_IV (1UL << 23)
  249. #define RGXMIPSFW_C0_CAUSE_IC (1UL << 25)
  250. #define RGXMIPSFW_C0_CAUSE_PCIPENDING (1UL << 26)
  251. #define RGXMIPSFW_C0_CAUSE_TIPENDING (1UL << 30)
  252. #define RGXMIPSFW_C0_CAUSE_BRANCH_DELAY (1UL << 31)
  253. /* Macros to decode C0_Debug register */
  254. #define RGXMIPSFW_C0_DEBUG_EXCCODE(DEBUG) (((DEBUG) >> 10) & 0x1f)
  255. #define RGXMIPSFW_C0_DEBUG_DSS (1UL << 0)
  256. #define RGXMIPSFW_C0_DEBUG_DBP (1UL << 1)
  257. #define RGXMIPSFW_C0_DEBUG_DDBL (1UL << 2)
  258. #define RGXMIPSFW_C0_DEBUG_DDBS (1UL << 3)
  259. #define RGXMIPSFW_C0_DEBUG_DIB (1UL << 4)
  260. #define RGXMIPSFW_C0_DEBUG_DINT (1UL << 5)
  261. #define RGXMIPSFW_C0_DEBUG_DIBIMPR (1UL << 6)
  262. #define RGXMIPSFW_C0_DEBUG_DDBLIMPR (1UL << 18)
  263. #define RGXMIPSFW_C0_DEBUG_DDBSIMPR (1UL << 19)
  264. #define RGXMIPSFW_C0_DEBUG_IEXI (1UL << 20)
  265. #define RGXMIPSFW_C0_DEBUG_DBUSEP (1UL << 21)
  266. #define RGXMIPSFW_C0_DEBUG_CACHEEP (1UL << 22)
  267. #define RGXMIPSFW_C0_DEBUG_MCHECKP (1UL << 23)
  268. #define RGXMIPSFW_C0_DEBUG_IBUSEP (1UL << 24)
  269. #define RGXMIPSFW_C0_DEBUG_DM (1UL << 30)
  270. #define RGXMIPSFW_C0_DEBUG_DBD (1UL << 31)
  271. /* Macros to decode TLB entries */
  272. #define RGXMIPSFW_TLB_GET_MASK(PAGE_MASK) (((PAGE_MASK) >> 13) & 0XFFFFU)
  273. #define RGXMIPSFW_TLB_GET_PAGE_SIZE(PAGE_MASK) ((((PAGE_MASK) | 0x1FFF) + 1) >> 11) /* page size in KB */
  274. #define RGXMIPSFW_TLB_GET_PAGE_MASK(PAGE_SIZE) ((((PAGE_SIZE) << 11) - 1) & ~0x7FF) /* page size in KB */
  275. #define RGXMIPSFW_TLB_GET_VPN2(ENTRY_HI) ((ENTRY_HI) >> 13)
  276. #define RGXMIPSFW_TLB_GET_COHERENCY(ENTRY_LO) (((ENTRY_LO) >> 3) & 0x7U)
  277. #define RGXMIPSFW_TLB_GET_PFN(ENTRY_LO) (((ENTRY_LO) >> 6) & 0XFFFFFU)
  278. /* GET_PA uses a non-standard PFN mask for 36 bit addresses */
  279. #define RGXMIPSFW_TLB_GET_PA(ENTRY_LO) (((IMG_UINT64)(ENTRY_LO) & RGXMIPSFW_ENTRYLO_PFN_MASK_ABOVE_32BIT) << 6)
  280. #define RGXMIPSFW_TLB_GET_INHIBIT(ENTRY_LO) (((ENTRY_LO) >> 30) & 0x3U)
  281. #define RGXMIPSFW_TLB_GET_DGV(ENTRY_LO) ((ENTRY_LO) & 0x7U)
  282. #define RGXMIPSFW_TLB_GLOBAL (1U)
  283. #define RGXMIPSFW_TLB_VALID (1U << 1)
  284. #define RGXMIPSFW_TLB_DIRTY (1U << 2)
  285. #define RGXMIPSFW_TLB_XI (1U << 30)
  286. #define RGXMIPSFW_TLB_RI (1U << 31)
  287. typedef struct {
  288. IMG_UINT32 ui32TLBPageMask;
  289. IMG_UINT32 ui32TLBHi;
  290. IMG_UINT32 ui32TLBLo0;
  291. IMG_UINT32 ui32TLBLo1;
  292. } RGX_MIPS_TLB_ENTRY;
  293. typedef struct {
  294. IMG_UINT32 ui32RemapAddrIn; /* always 4k aligned */
  295. IMG_UINT32 ui32RemapAddrOut; /* always 4k aligned */
  296. IMG_UINT32 ui32RemapRegionSize;
  297. } RGX_MIPS_REMAP_ENTRY;
  298. typedef struct {
  299. IMG_UINT32 ui32ErrorState; /* This must come first in the structure */
  300. IMG_UINT32 ui32ErrorEPC;
  301. IMG_UINT32 ui32StatusRegister;
  302. IMG_UINT32 ui32CauseRegister;
  303. IMG_UINT32 ui32BadRegister;
  304. IMG_UINT32 ui32EPC;
  305. IMG_UINT32 ui32SP;
  306. IMG_UINT32 ui32Debug;
  307. IMG_UINT32 ui32DEPC;
  308. IMG_UINT32 ui32BadInstr;
  309. IMG_UINT32 ui32UnmappedAddress;
  310. RGX_MIPS_TLB_ENTRY asTLB[RGXMIPSFW_NUMBER_OF_TLB_ENTRIES];
  311. RGX_MIPS_REMAP_ENTRY asRemap[RGXMIPSFW_NUMBER_OF_REMAP_ENTRIES];
  312. } RGX_MIPS_STATE;
  313. #endif /* RGXMIPSFW_ASSEMBLY_CODE */
  314. #endif /* RGX_MIPS_H */