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 "amd_family.h" 28 29#include <stdbool.h> 30#include <stdint.h> 31#include <stdio.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#ifdef __cplusplus 40extern "C" { 41#endif 42 43struct ac_wave_info { 44 unsigned se; /* shader engine */ 45 unsigned sh; /* shader array */ 46 unsigned cu; /* compute unit */ 47 unsigned simd; 48 unsigned wave; 49 uint32_t status; 50 uint64_t pc; /* program counter */ 51 uint32_t inst_dw0; 52 uint32_t inst_dw1; 53 uint64_t exec; 54 bool matched; /* whether the wave is used by a currently-bound shader */ 55}; 56 57typedef void *(*ac_debug_addr_callback)(void *data, uint64_t addr); 58 59const char *ac_get_register_name(enum amd_gfx_level gfx_level, unsigned offset); 60void ac_dump_reg(FILE *file, enum amd_gfx_level gfx_level, unsigned offset, uint32_t value, 61 uint32_t field_mask); 62void ac_parse_ib_chunk(FILE *f, uint32_t *ib, int num_dw, const int *trace_ids, 63 unsigned trace_id_count, enum amd_gfx_level gfx_level, 64 ac_debug_addr_callback addr_callback, void *addr_callback_data); 65void ac_parse_ib(FILE *f, uint32_t *ib, int num_dw, const int *trace_ids, unsigned trace_id_count, 66 const char *name, enum amd_gfx_level gfx_level, ac_debug_addr_callback addr_callback, 67 void *addr_callback_data); 68 69bool ac_vm_fault_occured(enum amd_gfx_level gfx_level, uint64_t *old_dmesg_timestamp, 70 uint64_t *out_addr); 71 72unsigned ac_get_wave_info(enum amd_gfx_level gfx_level, 73 struct ac_wave_info waves[AC_MAX_WAVES_PER_CHIP]); 74 75#ifdef __cplusplus 76} 77#endif 78 79#endif 80