18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright 2014 Advanced Micro Devices, Inc. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice shall be included in 128c2ecf20Sopenharmony_ci * all copies or substantial portions of the Software. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 158c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 168c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 178c2ecf20Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 188c2ecf20Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 198c2ecf20Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 208c2ecf20Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE. 218c2ecf20Sopenharmony_ci */ 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#ifndef KFD_DBGDEV_H_ 248c2ecf20Sopenharmony_ci#define KFD_DBGDEV_H_ 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_cienum { 278c2ecf20Sopenharmony_ci SQ_CMD_VMID_OFFSET = 28, 288c2ecf20Sopenharmony_ci ADDRESS_WATCH_CNTL_OFFSET = 24 298c2ecf20Sopenharmony_ci}; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_cienum { 328c2ecf20Sopenharmony_ci PRIV_QUEUE_SYNC_TIME_MS = 200 338c2ecf20Sopenharmony_ci}; 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci/* CONTEXT reg space definition */ 368c2ecf20Sopenharmony_cienum { 378c2ecf20Sopenharmony_ci CONTEXT_REG_BASE = 0xA000, 388c2ecf20Sopenharmony_ci CONTEXT_REG_END = 0xA400, 398c2ecf20Sopenharmony_ci CONTEXT_REG_SIZE = CONTEXT_REG_END - CONTEXT_REG_BASE 408c2ecf20Sopenharmony_ci}; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci/* USER CONFIG reg space definition */ 438c2ecf20Sopenharmony_cienum { 448c2ecf20Sopenharmony_ci USERCONFIG_REG_BASE = 0xC000, 458c2ecf20Sopenharmony_ci USERCONFIG_REG_END = 0x10000, 468c2ecf20Sopenharmony_ci USERCONFIG_REG_SIZE = USERCONFIG_REG_END - USERCONFIG_REG_BASE 478c2ecf20Sopenharmony_ci}; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci/* CONFIG reg space definition */ 508c2ecf20Sopenharmony_cienum { 518c2ecf20Sopenharmony_ci AMD_CONFIG_REG_BASE = 0x2000, /* in dwords */ 528c2ecf20Sopenharmony_ci AMD_CONFIG_REG_END = 0x2B00, 538c2ecf20Sopenharmony_ci AMD_CONFIG_REG_SIZE = AMD_CONFIG_REG_END - AMD_CONFIG_REG_BASE 548c2ecf20Sopenharmony_ci}; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci/* SH reg space definition */ 578c2ecf20Sopenharmony_cienum { 588c2ecf20Sopenharmony_ci SH_REG_BASE = 0x2C00, 598c2ecf20Sopenharmony_ci SH_REG_END = 0x3000, 608c2ecf20Sopenharmony_ci SH_REG_SIZE = SH_REG_END - SH_REG_BASE 618c2ecf20Sopenharmony_ci}; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci/* SQ_CMD definitions */ 648c2ecf20Sopenharmony_ci#define SQ_CMD 0x8DEC 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_cienum SQ_IND_CMD_CMD { 678c2ecf20Sopenharmony_ci SQ_IND_CMD_CMD_NULL = 0x00000000, 688c2ecf20Sopenharmony_ci SQ_IND_CMD_CMD_HALT = 0x00000001, 698c2ecf20Sopenharmony_ci SQ_IND_CMD_CMD_RESUME = 0x00000002, 708c2ecf20Sopenharmony_ci SQ_IND_CMD_CMD_KILL = 0x00000003, 718c2ecf20Sopenharmony_ci SQ_IND_CMD_CMD_DEBUG = 0x00000004, 728c2ecf20Sopenharmony_ci SQ_IND_CMD_CMD_TRAP = 0x00000005, 738c2ecf20Sopenharmony_ci}; 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_cienum SQ_IND_CMD_MODE { 768c2ecf20Sopenharmony_ci SQ_IND_CMD_MODE_SINGLE = 0x00000000, 778c2ecf20Sopenharmony_ci SQ_IND_CMD_MODE_BROADCAST = 0x00000001, 788c2ecf20Sopenharmony_ci SQ_IND_CMD_MODE_BROADCAST_QUEUE = 0x00000002, 798c2ecf20Sopenharmony_ci SQ_IND_CMD_MODE_BROADCAST_PIPE = 0x00000003, 808c2ecf20Sopenharmony_ci SQ_IND_CMD_MODE_BROADCAST_ME = 0x00000004, 818c2ecf20Sopenharmony_ci}; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ciunion SQ_IND_INDEX_BITS { 848c2ecf20Sopenharmony_ci struct { 858c2ecf20Sopenharmony_ci uint32_t wave_id:4; 868c2ecf20Sopenharmony_ci uint32_t simd_id:2; 878c2ecf20Sopenharmony_ci uint32_t thread_id:6; 888c2ecf20Sopenharmony_ci uint32_t:1; 898c2ecf20Sopenharmony_ci uint32_t force_read:1; 908c2ecf20Sopenharmony_ci uint32_t read_timeout:1; 918c2ecf20Sopenharmony_ci uint32_t unindexed:1; 928c2ecf20Sopenharmony_ci uint32_t index:16; 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci } bitfields, bits; 958c2ecf20Sopenharmony_ci uint32_t u32All; 968c2ecf20Sopenharmony_ci signed int i32All; 978c2ecf20Sopenharmony_ci float f32All; 988c2ecf20Sopenharmony_ci}; 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ciunion SQ_IND_CMD_BITS { 1018c2ecf20Sopenharmony_ci struct { 1028c2ecf20Sopenharmony_ci uint32_t data:32; 1038c2ecf20Sopenharmony_ci } bitfields, bits; 1048c2ecf20Sopenharmony_ci uint32_t u32All; 1058c2ecf20Sopenharmony_ci signed int i32All; 1068c2ecf20Sopenharmony_ci float f32All; 1078c2ecf20Sopenharmony_ci}; 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ciunion SQ_CMD_BITS { 1108c2ecf20Sopenharmony_ci struct { 1118c2ecf20Sopenharmony_ci uint32_t cmd:3; 1128c2ecf20Sopenharmony_ci uint32_t:1; 1138c2ecf20Sopenharmony_ci uint32_t mode:3; 1148c2ecf20Sopenharmony_ci uint32_t check_vmid:1; 1158c2ecf20Sopenharmony_ci uint32_t trap_id:3; 1168c2ecf20Sopenharmony_ci uint32_t:5; 1178c2ecf20Sopenharmony_ci uint32_t wave_id:4; 1188c2ecf20Sopenharmony_ci uint32_t simd_id:2; 1198c2ecf20Sopenharmony_ci uint32_t:2; 1208c2ecf20Sopenharmony_ci uint32_t queue_id:3; 1218c2ecf20Sopenharmony_ci uint32_t:1; 1228c2ecf20Sopenharmony_ci uint32_t vm_id:4; 1238c2ecf20Sopenharmony_ci } bitfields, bits; 1248c2ecf20Sopenharmony_ci uint32_t u32All; 1258c2ecf20Sopenharmony_ci signed int i32All; 1268c2ecf20Sopenharmony_ci float f32All; 1278c2ecf20Sopenharmony_ci}; 1288c2ecf20Sopenharmony_ci 1298c2ecf20Sopenharmony_ciunion SQ_IND_DATA_BITS { 1308c2ecf20Sopenharmony_ci struct { 1318c2ecf20Sopenharmony_ci uint32_t data:32; 1328c2ecf20Sopenharmony_ci } bitfields, bits; 1338c2ecf20Sopenharmony_ci uint32_t u32All; 1348c2ecf20Sopenharmony_ci signed int i32All; 1358c2ecf20Sopenharmony_ci float f32All; 1368c2ecf20Sopenharmony_ci}; 1378c2ecf20Sopenharmony_ci 1388c2ecf20Sopenharmony_ciunion GRBM_GFX_INDEX_BITS { 1398c2ecf20Sopenharmony_ci struct { 1408c2ecf20Sopenharmony_ci uint32_t instance_index:8; 1418c2ecf20Sopenharmony_ci uint32_t sh_index:8; 1428c2ecf20Sopenharmony_ci uint32_t se_index:8; 1438c2ecf20Sopenharmony_ci uint32_t:5; 1448c2ecf20Sopenharmony_ci uint32_t sh_broadcast_writes:1; 1458c2ecf20Sopenharmony_ci uint32_t instance_broadcast_writes:1; 1468c2ecf20Sopenharmony_ci uint32_t se_broadcast_writes:1; 1478c2ecf20Sopenharmony_ci } bitfields, bits; 1488c2ecf20Sopenharmony_ci uint32_t u32All; 1498c2ecf20Sopenharmony_ci signed int i32All; 1508c2ecf20Sopenharmony_ci float f32All; 1518c2ecf20Sopenharmony_ci}; 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ciunion TCP_WATCH_ADDR_H_BITS { 1548c2ecf20Sopenharmony_ci struct { 1558c2ecf20Sopenharmony_ci uint32_t addr:16; 1568c2ecf20Sopenharmony_ci uint32_t:16; 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci } bitfields, bits; 1598c2ecf20Sopenharmony_ci uint32_t u32All; 1608c2ecf20Sopenharmony_ci signed int i32All; 1618c2ecf20Sopenharmony_ci float f32All; 1628c2ecf20Sopenharmony_ci}; 1638c2ecf20Sopenharmony_ci 1648c2ecf20Sopenharmony_ciunion TCP_WATCH_ADDR_L_BITS { 1658c2ecf20Sopenharmony_ci struct { 1668c2ecf20Sopenharmony_ci uint32_t:6; 1678c2ecf20Sopenharmony_ci uint32_t addr:26; 1688c2ecf20Sopenharmony_ci } bitfields, bits; 1698c2ecf20Sopenharmony_ci uint32_t u32All; 1708c2ecf20Sopenharmony_ci signed int i32All; 1718c2ecf20Sopenharmony_ci float f32All; 1728c2ecf20Sopenharmony_ci}; 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_cienum { 1758c2ecf20Sopenharmony_ci QUEUESTATE__INVALID = 0, /* so by default we'll get invalid state */ 1768c2ecf20Sopenharmony_ci QUEUESTATE__ACTIVE_COMPLETION_PENDING, 1778c2ecf20Sopenharmony_ci QUEUESTATE__ACTIVE 1788c2ecf20Sopenharmony_ci}; 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_ciunion ULARGE_INTEGER { 1818c2ecf20Sopenharmony_ci struct { 1828c2ecf20Sopenharmony_ci uint32_t low_part; 1838c2ecf20Sopenharmony_ci uint32_t high_part; 1848c2ecf20Sopenharmony_ci } u; 1858c2ecf20Sopenharmony_ci unsigned long long quad_part; 1868c2ecf20Sopenharmony_ci}; 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci 1898c2ecf20Sopenharmony_ci#define KFD_CIK_VMID_START_OFFSET (8) 1908c2ecf20Sopenharmony_ci#define KFD_CIK_VMID_END_OFFSET (KFD_CIK_VMID_START_OFFSET + (8)) 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_civoid kfd_dbgdev_init(struct kfd_dbgdev *pdbgdev, struct kfd_dev *pdev, 1948c2ecf20Sopenharmony_ci enum DBGDEV_TYPE type); 1958c2ecf20Sopenharmony_ci 1968c2ecf20Sopenharmony_ciunion TCP_WATCH_CNTL_BITS { 1978c2ecf20Sopenharmony_ci struct { 1988c2ecf20Sopenharmony_ci uint32_t mask:24; 1998c2ecf20Sopenharmony_ci uint32_t vmid:4; 2008c2ecf20Sopenharmony_ci uint32_t atc:1; 2018c2ecf20Sopenharmony_ci uint32_t mode:2; 2028c2ecf20Sopenharmony_ci uint32_t valid:1; 2038c2ecf20Sopenharmony_ci } bitfields, bits; 2048c2ecf20Sopenharmony_ci uint32_t u32All; 2058c2ecf20Sopenharmony_ci signed int i32All; 2068c2ecf20Sopenharmony_ci float f32All; 2078c2ecf20Sopenharmony_ci}; 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_cienum { 2108c2ecf20Sopenharmony_ci ADDRESS_WATCH_REG_CNTL_ATC_BIT = 0x10000000UL, 2118c2ecf20Sopenharmony_ci ADDRESS_WATCH_REG_CNTL_DEFAULT_MASK = 0x00FFFFFF, 2128c2ecf20Sopenharmony_ci ADDRESS_WATCH_REG_ADDLOW_MASK_EXTENSION = 0x03000000, 2138c2ecf20Sopenharmony_ci /* extend the mask to 26 bits in order to match the low address field */ 2148c2ecf20Sopenharmony_ci ADDRESS_WATCH_REG_ADDLOW_SHIFT = 6, 2158c2ecf20Sopenharmony_ci ADDRESS_WATCH_REG_ADDHIGH_MASK = 0xFFFF 2168c2ecf20Sopenharmony_ci}; 2178c2ecf20Sopenharmony_ci 2188c2ecf20Sopenharmony_cienum { 2198c2ecf20Sopenharmony_ci MAX_TRAPID = 8, /* 3 bits in the bitfield. */ 2208c2ecf20Sopenharmony_ci MAX_WATCH_ADDRESSES = 4 2218c2ecf20Sopenharmony_ci}; 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_cienum { 2248c2ecf20Sopenharmony_ci ADDRESS_WATCH_REG_ADDR_HI = 0, 2258c2ecf20Sopenharmony_ci ADDRESS_WATCH_REG_ADDR_LO, 2268c2ecf20Sopenharmony_ci ADDRESS_WATCH_REG_CNTL, 2278c2ecf20Sopenharmony_ci ADDRESS_WATCH_REG_MAX 2288c2ecf20Sopenharmony_ci}; 2298c2ecf20Sopenharmony_ci 2308c2ecf20Sopenharmony_ci#endif /* KFD_DBGDEV_H_ */ 231