1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#ifndef TILEGX_CPU_H
21#define TILEGX_CPU_H
22
23#include "qemu-common.h"
24
25#define TARGET_LONG_BITS 64
26
27#define CPUArchState struct CPUTLGState
28
29#include "exec/cpu-defs.h"
30
31
32
33#define TILEGX_R_RE 0
34#define TILEGX_R_ERR 1
35#define TILEGX_R_NR 10
36#define TILEGX_R_BP 52
37#define TILEGX_R_TP 53
38#define TILEGX_R_SP 54
39#define TILEGX_R_LR 55
40#define TILEGX_R_COUNT 56
41#define TILEGX_R_SN 56
42#define TILEGX_R_IDN0 57
43#define TILEGX_R_IDN1 58
44#define TILEGX_R_UDN0 59
45#define TILEGX_R_UDN1 60
46#define TILEGX_R_UDN2 61
47#define TILEGX_R_UDN3 62
48#define TILEGX_R_ZERO 63
49#define TILEGX_R_NOREG 255
50
51
52enum {
53 TILEGX_SPR_CMPEXCH = 0,
54 TILEGX_SPR_CRITICAL_SEC = 1,
55 TILEGX_SPR_SIM_CONTROL = 2,
56 TILEGX_SPR_EX_CONTEXT_0_0 = 3,
57 TILEGX_SPR_EX_CONTEXT_0_1 = 4,
58 TILEGX_SPR_COUNT
59};
60
61
62typedef enum {
63 TILEGX_EXCP_NONE = 0,
64 TILEGX_EXCP_SYSCALL = 1,
65 TILEGX_EXCP_SIGNAL = 2,
66 TILEGX_EXCP_OPCODE_UNKNOWN = 0x101,
67 TILEGX_EXCP_OPCODE_UNIMPLEMENTED = 0x102,
68 TILEGX_EXCP_OPCODE_CMPEXCH = 0x103,
69 TILEGX_EXCP_OPCODE_CMPEXCH4 = 0x104,
70 TILEGX_EXCP_OPCODE_EXCH = 0x105,
71 TILEGX_EXCP_OPCODE_EXCH4 = 0x106,
72 TILEGX_EXCP_OPCODE_FETCHADD = 0x107,
73 TILEGX_EXCP_OPCODE_FETCHADD4 = 0x108,
74 TILEGX_EXCP_OPCODE_FETCHADDGEZ = 0x109,
75 TILEGX_EXCP_OPCODE_FETCHADDGEZ4 = 0x10a,
76 TILEGX_EXCP_OPCODE_FETCHAND = 0x10b,
77 TILEGX_EXCP_OPCODE_FETCHAND4 = 0x10c,
78 TILEGX_EXCP_OPCODE_FETCHOR = 0x10d,
79 TILEGX_EXCP_OPCODE_FETCHOR4 = 0x10e,
80 TILEGX_EXCP_REG_IDN_ACCESS = 0x181,
81 TILEGX_EXCP_REG_UDN_ACCESS = 0x182,
82 TILEGX_EXCP_UNALIGNMENT = 0x201,
83 TILEGX_EXCP_DBUG_BREAK = 0x301
84} TileExcp;
85
86typedef struct CPUTLGState {
87 uint64_t regs[TILEGX_R_COUNT];
88 uint64_t spregs[TILEGX_SPR_COUNT];
89 uint64_t pc;
90
91#if defined(CONFIG_USER_ONLY)
92 uint64_t excaddr;
93 uint64_t atomic_srca;
94 uint64_t atomic_srcb;
95 uint32_t atomic_dstr;
96 uint32_t signo;
97 uint32_t sigcode;
98#endif
99
100
101 struct {} end_reset_fields;
102
103 CPU_COMMON
104} CPUTLGState;
105
106#include "qom/cpu.h"
107
108#define TYPE_TILEGX_CPU "tilegx-cpu"
109
110#define TILEGX_CPU_CLASS(klass) \
111 OBJECT_CLASS_CHECK(TileGXCPUClass, (klass), TYPE_TILEGX_CPU)
112#define TILEGX_CPU(obj) \
113 OBJECT_CHECK(TileGXCPU, (obj), TYPE_TILEGX_CPU)
114#define TILEGX_CPU_GET_CLASS(obj) \
115 OBJECT_GET_CLASS(TileGXCPUClass, (obj), TYPE_TILEGX_CPU)
116
117
118
119
120
121
122
123
124typedef struct TileGXCPUClass {
125
126 CPUClass parent_class;
127
128
129 DeviceRealize parent_realize;
130 void (*parent_reset)(CPUState *cpu);
131} TileGXCPUClass;
132
133
134
135
136
137
138
139typedef struct TileGXCPU {
140
141 CPUState parent_obj;
142
143
144 CPUTLGState env;
145} TileGXCPU;
146
147static inline TileGXCPU *tilegx_env_get_cpu(CPUTLGState *env)
148{
149 return container_of(env, TileGXCPU, env);
150}
151
152#define ENV_GET_CPU(e) CPU(tilegx_env_get_cpu(e))
153
154#define ENV_OFFSET offsetof(TileGXCPU, env)
155
156
157#define TARGET_PAGE_BITS 16
158#define TARGET_PHYS_ADDR_SPACE_BITS 42
159#define TARGET_VIRT_ADDR_SPACE_BITS 64
160#define MMU_USER_IDX 0
161
162#include "exec/cpu-all.h"
163
164void tilegx_tcg_init(void);
165int cpu_tilegx_signal_handler(int host_signum, void *pinfo, void *puc);
166
167#define cpu_init(cpu_model) cpu_generic_init(TYPE_TILEGX_CPU, cpu_model)
168
169#define cpu_signal_handler cpu_tilegx_signal_handler
170
171static inline void cpu_get_tb_cpu_state(CPUTLGState *env, target_ulong *pc,
172 target_ulong *cs_base, uint32_t *flags)
173{
174 *pc = env->pc;
175 *cs_base = 0;
176 *flags = 0;
177}
178
179#endif
180