xref: /aosp_15_r20/external/igt-gpu-tools/lib/debug.h (revision d83cc019efdc2edc6c4b16e9034a3ceb8d35d77c)
1 /*
2  * Copyright © 2011 Intel Corporation
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  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * 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 NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  *
23  * Authors:
24  *    Ben Widawsky <[email protected]>
25  *
26  */
27 
28 #ifndef _DEBUG_H_
29 #define _DEBUG_H_
30 
31 #define DEBUG_PROTOCOL_VERSION 1
32 #define COMMUNICATION_OFFSET 0xc00
33 #define COMMUNICATION_QWORD 0xc0
34 
35 #define STATE_EU_MSG 0x47534d65 /* eMSG */
36 #define STATE_CPU_ACK 0x4b434163 /* cACK */
37 #define STATE_OFFSET 0xc20
38 #define STATE_QWORD 0xc2
39 
40 #define TX_OFFSET 0xc40
41 #define TX_QWORD 0xc4
42 #define RX_OFFSET 0xc60
43 #define RX_QWORD 0xc6
44 
45 #ifndef GEN_ASM
46 typedef uint32_t grf[8];
47 typedef uint32_t mrf[8];
48 typedef uint8_t cr[12];
49 typedef uint32_t sr;
50 
51 #define DWORD8(x) {x, x, x, x, x, x, x, x}
52 
53 const static grf protocol_version = DWORD8(DEBUG_PROTOCOL_VERSION);
54 const static grf eu_msg = DWORD8(STATE_EU_MSG);
55 const static grf cpu_ack = DWORD8(STATE_CPU_ACK);
56 
57 struct eu_state {
58 	mrf m_regs[15];
59 	grf g_regs[16];
60 	grf pad;
61 
62 /* 0x400 */
63 	cr cr0;
64 	sr sr0;
65 	uint32_t beef_pad[4];
66 	uint8_t pad2[992 + 1024];
67 
68 /* 0xc00 COMMUNICATION_OFFSET */
69 	grf version;
70 	grf state_magic;
71 	grf eu_tx;
72 	grf eu_rx;
73 
74 	uint8_t pad3[896];
75 } __attribute__((packed));
76 
77 static inline void
print_reg(uint8_t reg[32])78 print_reg(uint8_t reg[32]) {
79 	uint32_t *dwords = (uint32_t *)reg;
80 	printf("%08x %08x %08x %08x %08x %08x %08x %08x",
81 		dwords[7], dwords[6], dwords[5], dwords[4],
82 		dwords[3], dwords[2], dwords[1], dwords[0]);
83 }
84 
85 static inline void
print_creg(uint8_t reg[12])86 print_creg(uint8_t reg[12]) {
87 	uint32_t *dwords = (uint32_t *)reg;
88 	printf("%08x %08x %08x", dwords[2], dwords[1], dwords[0]);
89 }
90 #endif
91 
92 #endif
93