1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#ifndef HEXAGON_CPU_H
19#define HEXAGON_CPU_H
20
21
22typedef struct CPUHexagonState CPUHexagonState;
23
24#include "fpu/softfloat-types.h"
25
26#include "qemu-common.h"
27#include "exec/cpu-defs.h"
28#include "hex_regs.h"
29
30#define NUM_PREGS 4
31#define TOTAL_PER_THREAD_REGS 64
32
33#define SLOTS_MAX 4
34#define STORES_MAX 2
35#define REG_WRITES_MAX 32
36#define PRED_WRITES_MAX 5
37
38#define TYPE_HEXAGON_CPU "hexagon-cpu"
39
40#define HEXAGON_CPU_TYPE_SUFFIX "-" TYPE_HEXAGON_CPU
41#define HEXAGON_CPU_TYPE_NAME(name) (name HEXAGON_CPU_TYPE_SUFFIX)
42#define CPU_RESOLVING_TYPE TYPE_HEXAGON_CPU
43
44#define TYPE_HEXAGON_CPU_V67 HEXAGON_CPU_TYPE_NAME("v67")
45
46#define MMU_USER_IDX 0
47
48typedef struct {
49 target_ulong va;
50 uint8_t width;
51 uint32_t data32;
52 uint64_t data64;
53} MemLog;
54
55#define EXEC_STATUS_OK 0x0000
56#define EXEC_STATUS_STOP 0x0002
57#define EXEC_STATUS_REPLAY 0x0010
58#define EXEC_STATUS_LOCKED 0x0020
59#define EXEC_STATUS_EXCEPTION 0x0100
60
61
62#define EXCEPTION_DETECTED (env->status & EXEC_STATUS_EXCEPTION)
63#define REPLAY_DETECTED (env->status & EXEC_STATUS_REPLAY)
64#define CLEAR_EXCEPTION (env->status &= (~EXEC_STATUS_EXCEPTION))
65#define SET_EXCEPTION (env->status |= EXEC_STATUS_EXCEPTION)
66
67struct CPUHexagonState {
68 target_ulong gpr[TOTAL_PER_THREAD_REGS];
69 target_ulong pred[NUM_PREGS];
70 target_ulong branch_taken;
71 target_ulong next_PC;
72
73
74 target_ulong last_pc_dumped;
75 target_ulong stack_start;
76
77 uint8_t slot_cancelled;
78 target_ulong new_value[TOTAL_PER_THREAD_REGS];
79
80
81
82
83
84 target_ulong this_PC;
85 target_ulong reg_written[TOTAL_PER_THREAD_REGS];
86
87 target_ulong new_pred_value[NUM_PREGS];
88 target_ulong pred_written;
89
90 MemLog mem_log_stores[STORES_MAX];
91 target_ulong pkt_has_store_s1;
92 target_ulong dczero_addr;
93
94 float_status fp_status;
95
96 target_ulong llsc_addr;
97 target_ulong llsc_val;
98 uint64_t llsc_val_i64;
99
100 target_ulong is_gather_store_insn;
101 target_ulong gather_issued;
102};
103
104#define HEXAGON_CPU_CLASS(klass) \
105 OBJECT_CLASS_CHECK(HexagonCPUClass, (klass), TYPE_HEXAGON_CPU)
106#define HEXAGON_CPU(obj) \
107 OBJECT_CHECK(HexagonCPU, (obj), TYPE_HEXAGON_CPU)
108#define HEXAGON_CPU_GET_CLASS(obj) \
109 OBJECT_GET_CLASS(HexagonCPUClass, (obj), TYPE_HEXAGON_CPU)
110
111typedef struct HexagonCPUClass {
112
113 CPUClass parent_class;
114
115 DeviceRealize parent_realize;
116 DeviceReset parent_reset;
117} HexagonCPUClass;
118
119typedef struct HexagonCPU {
120
121 CPUState parent_obj;
122
123 CPUNegativeOffsetState neg;
124 CPUHexagonState env;
125
126 bool lldb_compat;
127 target_ulong lldb_stack_adjust;
128} HexagonCPU;
129
130#include "cpu_bits.h"
131
132#define cpu_signal_handler cpu_hexagon_signal_handler
133int cpu_hexagon_signal_handler(int host_signum, void *pinfo, void *puc);
134
135static inline void cpu_get_tb_cpu_state(CPUHexagonState *env, target_ulong *pc,
136 target_ulong *cs_base, uint32_t *flags)
137{
138 *pc = env->gpr[HEX_REG_PC];
139 *cs_base = 0;
140#ifdef CONFIG_USER_ONLY
141 *flags = 0;
142#else
143#error System mode not supported on Hexagon yet
144#endif
145}
146
147typedef struct CPUHexagonState CPUArchState;
148typedef HexagonCPU ArchCPU;
149
150void hexagon_translate_init(void);
151
152#include "exec/cpu-all.h"
153
154#endif
155