1 /*
2  * Copyright (c) 2020 Intel Corporation.
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 /**
8  * @file
9  * @brief IA-32 specific gdbstub interface header
10  */
11 
12 #ifndef ZEPHYR_INCLUDE_ARCH_X86_GDBSTUB_SYS_H_
13 #define ZEPHYR_INCLUDE_ARCH_X86_GDBSTUB_SYS_H_
14 
15 #ifndef _ASMLANGUAGE
16 
17 #include <stdint.h>
18 #include <zephyr/toolchain.h>
19 
20 /**
21  * @brief Number of register used by gdbstub in IA-32
22  */
23 #define GDB_STUB_NUM_REGISTERS 16
24 
25 /**
26  * @brief GDB interruption context
27  *
28  * The exception stack frame contents used by gdbstub. The contents
29  * of this struct are used to display information about the current
30  * cpu state.
31  */
32 
33 struct gdb_interrupt_ctx {
34 	uint32_t ss;
35 	uint32_t gs;
36 	uint32_t fs;
37 	uint32_t es;
38 	uint32_t ds;
39 	uint32_t edi;
40 	uint32_t esi;
41 	uint32_t ebp;
42 	uint32_t esp;
43 	uint32_t ebx;
44 	uint32_t edx;
45 	uint32_t ecx;
46 	uint32_t eax;
47 	uint32_t vector;
48 	uint32_t error_code;
49 	uint32_t eip;
50 	uint32_t cs;
51 	uint32_t eflags;
52 } __packed;
53 
54 /**
55  * @brief IA-32 register used in gdbstub
56  */
57 
58 enum GDB_REGISTER {
59 	GDB_EAX,
60 	GDB_ECX,
61 	GDB_EDX,
62 	GDB_EBX,
63 	GDB_ESP,
64 	GDB_EBP,
65 	GDB_ESI,
66 	GDB_EDI,
67 	GDB_PC,
68 	GDB_EFLAGS,
69 	GDB_CS,
70 	GDB_SS,
71 	GDB_DS,
72 	GDB_ES,
73 	GDB_FS,
74 	GDB_GS,
75 	GDB_ORIG_EAX = 41,
76 };
77 
78 struct gdb_ctx {
79 	unsigned int exception;
80 	unsigned int registers[GDB_STUB_NUM_REGISTERS];
81 };
82 
83 #endif /* _ASMLANGUAGE */
84 
85 #endif /* ZEPHYR_INCLUDE_ARCH_X86_GDBSTUB_SYS_H_ */
86