1 1.1 riastrad /* $NetBSD: kfd_dbgdev.h,v 1.3 2021/12/18 23:44:59 riastradh Exp $ */ 2 1.1 riastrad 3 1.1 riastrad /* 4 1.1 riastrad * Copyright 2014 Advanced Micro Devices, Inc. 5 1.1 riastrad * 6 1.1 riastrad * Permission is hereby granted, free of charge, to any person obtaining a 7 1.1 riastrad * copy of this software and associated documentation files (the "Software"), 8 1.1 riastrad * to deal in the Software without restriction, including without limitation 9 1.1 riastrad * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 1.1 riastrad * and/or sell copies of the Software, and to permit persons to whom the 11 1.1 riastrad * Software is furnished to do so, subject to the following conditions: 12 1.1 riastrad * 13 1.1 riastrad * The above copyright notice and this permission notice shall be included in 14 1.1 riastrad * all copies or substantial portions of the Software. 15 1.1 riastrad * 16 1.1 riastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 1.1 riastrad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 1.1 riastrad * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 1.1 riastrad * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 1.1 riastrad * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 1.1 riastrad * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 1.1 riastrad * OTHER DEALINGS IN THE SOFTWARE. 23 1.1 riastrad */ 24 1.1 riastrad 25 1.1 riastrad #ifndef KFD_DBGDEV_H_ 26 1.1 riastrad #define KFD_DBGDEV_H_ 27 1.1 riastrad 28 1.1 riastrad enum { 29 1.1 riastrad SQ_CMD_VMID_OFFSET = 28, 30 1.1 riastrad ADDRESS_WATCH_CNTL_OFFSET = 24 31 1.1 riastrad }; 32 1.1 riastrad 33 1.1 riastrad enum { 34 1.1 riastrad PRIV_QUEUE_SYNC_TIME_MS = 200 35 1.1 riastrad }; 36 1.1 riastrad 37 1.1 riastrad /* CONTEXT reg space definition */ 38 1.1 riastrad enum { 39 1.1 riastrad CONTEXT_REG_BASE = 0xA000, 40 1.1 riastrad CONTEXT_REG_END = 0xA400, 41 1.1 riastrad CONTEXT_REG_SIZE = CONTEXT_REG_END - CONTEXT_REG_BASE 42 1.1 riastrad }; 43 1.1 riastrad 44 1.1 riastrad /* USER CONFIG reg space definition */ 45 1.1 riastrad enum { 46 1.1 riastrad USERCONFIG_REG_BASE = 0xC000, 47 1.1 riastrad USERCONFIG_REG_END = 0x10000, 48 1.1 riastrad USERCONFIG_REG_SIZE = USERCONFIG_REG_END - USERCONFIG_REG_BASE 49 1.1 riastrad }; 50 1.1 riastrad 51 1.1 riastrad /* CONFIG reg space definition */ 52 1.1 riastrad enum { 53 1.1 riastrad AMD_CONFIG_REG_BASE = 0x2000, /* in dwords */ 54 1.1 riastrad AMD_CONFIG_REG_END = 0x2B00, 55 1.1 riastrad AMD_CONFIG_REG_SIZE = AMD_CONFIG_REG_END - AMD_CONFIG_REG_BASE 56 1.1 riastrad }; 57 1.1 riastrad 58 1.1 riastrad /* SH reg space definition */ 59 1.1 riastrad enum { 60 1.1 riastrad SH_REG_BASE = 0x2C00, 61 1.1 riastrad SH_REG_END = 0x3000, 62 1.1 riastrad SH_REG_SIZE = SH_REG_END - SH_REG_BASE 63 1.1 riastrad }; 64 1.1 riastrad 65 1.3 riastrad /* SQ_CMD definitions */ 66 1.3 riastrad #define SQ_CMD 0x8DEC 67 1.3 riastrad 68 1.1 riastrad enum SQ_IND_CMD_CMD { 69 1.1 riastrad SQ_IND_CMD_CMD_NULL = 0x00000000, 70 1.1 riastrad SQ_IND_CMD_CMD_HALT = 0x00000001, 71 1.1 riastrad SQ_IND_CMD_CMD_RESUME = 0x00000002, 72 1.1 riastrad SQ_IND_CMD_CMD_KILL = 0x00000003, 73 1.1 riastrad SQ_IND_CMD_CMD_DEBUG = 0x00000004, 74 1.1 riastrad SQ_IND_CMD_CMD_TRAP = 0x00000005, 75 1.1 riastrad }; 76 1.1 riastrad 77 1.1 riastrad enum SQ_IND_CMD_MODE { 78 1.1 riastrad SQ_IND_CMD_MODE_SINGLE = 0x00000000, 79 1.1 riastrad SQ_IND_CMD_MODE_BROADCAST = 0x00000001, 80 1.1 riastrad SQ_IND_CMD_MODE_BROADCAST_QUEUE = 0x00000002, 81 1.1 riastrad SQ_IND_CMD_MODE_BROADCAST_PIPE = 0x00000003, 82 1.1 riastrad SQ_IND_CMD_MODE_BROADCAST_ME = 0x00000004, 83 1.1 riastrad }; 84 1.1 riastrad 85 1.1 riastrad union SQ_IND_INDEX_BITS { 86 1.1 riastrad struct { 87 1.1 riastrad uint32_t wave_id:4; 88 1.1 riastrad uint32_t simd_id:2; 89 1.1 riastrad uint32_t thread_id:6; 90 1.1 riastrad uint32_t:1; 91 1.1 riastrad uint32_t force_read:1; 92 1.1 riastrad uint32_t read_timeout:1; 93 1.1 riastrad uint32_t unindexed:1; 94 1.1 riastrad uint32_t index:16; 95 1.1 riastrad 96 1.1 riastrad } bitfields, bits; 97 1.1 riastrad uint32_t u32All; 98 1.1 riastrad signed int i32All; 99 1.1 riastrad float f32All; 100 1.1 riastrad }; 101 1.1 riastrad 102 1.1 riastrad union SQ_IND_CMD_BITS { 103 1.1 riastrad struct { 104 1.1 riastrad uint32_t data:32; 105 1.1 riastrad } bitfields, bits; 106 1.1 riastrad uint32_t u32All; 107 1.1 riastrad signed int i32All; 108 1.1 riastrad float f32All; 109 1.1 riastrad }; 110 1.1 riastrad 111 1.1 riastrad union SQ_CMD_BITS { 112 1.1 riastrad struct { 113 1.1 riastrad uint32_t cmd:3; 114 1.1 riastrad uint32_t:1; 115 1.1 riastrad uint32_t mode:3; 116 1.1 riastrad uint32_t check_vmid:1; 117 1.1 riastrad uint32_t trap_id:3; 118 1.1 riastrad uint32_t:5; 119 1.1 riastrad uint32_t wave_id:4; 120 1.1 riastrad uint32_t simd_id:2; 121 1.1 riastrad uint32_t:2; 122 1.1 riastrad uint32_t queue_id:3; 123 1.1 riastrad uint32_t:1; 124 1.1 riastrad uint32_t vm_id:4; 125 1.1 riastrad } bitfields, bits; 126 1.1 riastrad uint32_t u32All; 127 1.1 riastrad signed int i32All; 128 1.1 riastrad float f32All; 129 1.1 riastrad }; 130 1.1 riastrad 131 1.1 riastrad union SQ_IND_DATA_BITS { 132 1.1 riastrad struct { 133 1.1 riastrad uint32_t data:32; 134 1.1 riastrad } bitfields, bits; 135 1.1 riastrad uint32_t u32All; 136 1.1 riastrad signed int i32All; 137 1.1 riastrad float f32All; 138 1.1 riastrad }; 139 1.1 riastrad 140 1.1 riastrad union GRBM_GFX_INDEX_BITS { 141 1.1 riastrad struct { 142 1.1 riastrad uint32_t instance_index:8; 143 1.1 riastrad uint32_t sh_index:8; 144 1.1 riastrad uint32_t se_index:8; 145 1.1 riastrad uint32_t:5; 146 1.1 riastrad uint32_t sh_broadcast_writes:1; 147 1.1 riastrad uint32_t instance_broadcast_writes:1; 148 1.1 riastrad uint32_t se_broadcast_writes:1; 149 1.1 riastrad } bitfields, bits; 150 1.1 riastrad uint32_t u32All; 151 1.1 riastrad signed int i32All; 152 1.1 riastrad float f32All; 153 1.1 riastrad }; 154 1.1 riastrad 155 1.1 riastrad union TCP_WATCH_ADDR_H_BITS { 156 1.1 riastrad struct { 157 1.1 riastrad uint32_t addr:16; 158 1.1 riastrad uint32_t:16; 159 1.1 riastrad 160 1.1 riastrad } bitfields, bits; 161 1.1 riastrad uint32_t u32All; 162 1.1 riastrad signed int i32All; 163 1.1 riastrad float f32All; 164 1.1 riastrad }; 165 1.1 riastrad 166 1.1 riastrad union TCP_WATCH_ADDR_L_BITS { 167 1.1 riastrad struct { 168 1.1 riastrad uint32_t:6; 169 1.1 riastrad uint32_t addr:26; 170 1.1 riastrad } bitfields, bits; 171 1.1 riastrad uint32_t u32All; 172 1.1 riastrad signed int i32All; 173 1.1 riastrad float f32All; 174 1.1 riastrad }; 175 1.1 riastrad 176 1.1 riastrad enum { 177 1.1 riastrad QUEUESTATE__INVALID = 0, /* so by default we'll get invalid state */ 178 1.1 riastrad QUEUESTATE__ACTIVE_COMPLETION_PENDING, 179 1.1 riastrad QUEUESTATE__ACTIVE 180 1.1 riastrad }; 181 1.1 riastrad 182 1.1 riastrad union ULARGE_INTEGER { 183 1.1 riastrad struct { 184 1.1 riastrad uint32_t low_part; 185 1.1 riastrad uint32_t high_part; 186 1.1 riastrad } u; 187 1.1 riastrad unsigned long long quad_part; 188 1.1 riastrad }; 189 1.1 riastrad 190 1.1 riastrad 191 1.1 riastrad #define KFD_CIK_VMID_START_OFFSET (8) 192 1.1 riastrad #define KFD_CIK_VMID_END_OFFSET (KFD_CIK_VMID_START_OFFSET + (8)) 193 1.1 riastrad 194 1.1 riastrad 195 1.1 riastrad void kfd_dbgdev_init(struct kfd_dbgdev *pdbgdev, struct kfd_dev *pdev, 196 1.1 riastrad enum DBGDEV_TYPE type); 197 1.1 riastrad 198 1.3 riastrad union TCP_WATCH_CNTL_BITS { 199 1.3 riastrad struct { 200 1.3 riastrad uint32_t mask:24; 201 1.3 riastrad uint32_t vmid:4; 202 1.3 riastrad uint32_t atc:1; 203 1.3 riastrad uint32_t mode:2; 204 1.3 riastrad uint32_t valid:1; 205 1.3 riastrad } bitfields, bits; 206 1.3 riastrad uint32_t u32All; 207 1.3 riastrad signed int i32All; 208 1.3 riastrad float f32All; 209 1.3 riastrad }; 210 1.3 riastrad 211 1.3 riastrad enum { 212 1.3 riastrad ADDRESS_WATCH_REG_CNTL_ATC_BIT = 0x10000000UL, 213 1.3 riastrad ADDRESS_WATCH_REG_CNTL_DEFAULT_MASK = 0x00FFFFFF, 214 1.3 riastrad ADDRESS_WATCH_REG_ADDLOW_MASK_EXTENSION = 0x03000000, 215 1.3 riastrad /* extend the mask to 26 bits in order to match the low address field */ 216 1.3 riastrad ADDRESS_WATCH_REG_ADDLOW_SHIFT = 6, 217 1.3 riastrad ADDRESS_WATCH_REG_ADDHIGH_MASK = 0xFFFF 218 1.3 riastrad }; 219 1.3 riastrad 220 1.3 riastrad enum { 221 1.3 riastrad MAX_TRAPID = 8, /* 3 bits in the bitfield. */ 222 1.3 riastrad MAX_WATCH_ADDRESSES = 4 223 1.3 riastrad }; 224 1.3 riastrad 225 1.3 riastrad enum { 226 1.3 riastrad ADDRESS_WATCH_REG_ADDR_HI = 0, 227 1.3 riastrad ADDRESS_WATCH_REG_ADDR_LO, 228 1.3 riastrad ADDRESS_WATCH_REG_CNTL, 229 1.3 riastrad ADDRESS_WATCH_REG_MAX 230 1.3 riastrad }; 231 1.3 riastrad 232 1.1 riastrad #endif /* KFD_DBGDEV_H_ */ 233