1 /* 2 * Copyright 2015 Advanced Micro Devices, Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * on the rights to use, copy, modify, merge, publish, distribute, sub 8 * license, and/or sell copies of the Software, and to permit persons to whom 9 * the Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 21 * USE OR OTHER DEALINGS IN THE SOFTWARE. 22 */ 23 24 #ifndef AC_DEBUG_H 25 #define AC_DEBUG_H 26 27 #include <stdint.h> 28 #include <stdio.h> 29 #include <stdbool.h> 30 31 #include "amd_family.h" 32 33 #define AC_ENCODE_TRACE_POINT(id) (0xcafe0000 | ((id) & 0xffff)) 34 #define AC_IS_TRACE_POINT(x) (((x) & 0xcafe0000) == 0xcafe0000) 35 #define AC_GET_TRACE_POINT_ID(x) ((x) & 0xffff) 36 37 #define AC_MAX_WAVES_PER_CHIP (64 * 40) 38 39 struct ac_wave_info { 40 unsigned se; /* shader engine */ 41 unsigned sh; /* shader array */ 42 unsigned cu; /* compute unit */ 43 unsigned simd; 44 unsigned wave; 45 uint32_t status; 46 uint64_t pc; /* program counter */ 47 uint32_t inst_dw0; 48 uint32_t inst_dw1; 49 uint64_t exec; 50 bool matched; /* whether the wave is used by a currently-bound shader */ 51 }; 52 53 typedef void *(*ac_debug_addr_callback)(void *data, uint64_t addr); 54 55 void ac_dump_reg(FILE *file, enum chip_class chip_class, unsigned offset, 56 uint32_t value, uint32_t field_mask); 57 void ac_parse_ib_chunk(FILE *f, uint32_t *ib, int num_dw, const int *trace_ids, 58 unsigned trace_id_count, enum chip_class chip_class, 59 ac_debug_addr_callback addr_callback, void *addr_callback_data); 60 void ac_parse_ib(FILE *f, uint32_t *ib, int num_dw, const int *trace_ids, 61 unsigned trace_id_count, const char *name, enum chip_class chip_class, 62 ac_debug_addr_callback addr_callback, void *addr_callback_data); 63 64 bool ac_vm_fault_occured(enum chip_class chip_class, 65 uint64_t *old_dmesg_timestamp, uint64_t *out_addr); 66 67 unsigned ac_get_wave_info(struct ac_wave_info waves[AC_MAX_WAVES_PER_CHIP]); 68 69 #endif 70