1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 /***************************************************************************
4 * Copyright (C) 2018 by Square, Inc. *
5 * Steven Stallion <stallion@squareup.com> *
6 * James Zhao <hjz@squareup.com> *
7 ***************************************************************************/
9 #ifndef OPENOCD_TARGET_ESIRISC_H
10 #define OPENOCD_TARGET_ESIRISC_H
12 #include <helper/types.h>
13 #include <target/breakpoints.h>
14 #include <target/register.h>
15 #include <target/target.h>
17 #include "esirisc_jtag.h"
18 #include "esirisc_regs.h"
19 #include "esirisc_trace.h"
21 #define MAX_BREAKPOINTS 8
22 #define MAX_WATCHPOINTS 8
25 #define EID_RESET 0x00
26 #define EID_HARDWARE_FAILURE 0x01
28 #define EID_INST_BREAKPOINT 0x03
29 #define EID_DATA_BREAKPOINT 0x04
30 #define EID_UNSUPPORTED 0x05
31 #define EID_PRIVILEGE_VIOLATION 0x06
32 #define EID_INST_BUS_ERROR 0x07
33 #define EID_DATA_BUS_ERROR 0x08
34 #define EID_ALIGNMENT_ERROR 0x09
35 #define EID_ARITHMETIC_ERROR 0x0a
36 #define EID_SYSTEM_CALL 0x0b
37 #define EID_MEMORY_MANAGEMENT 0x0c
38 #define EID_UNRECOVERABLE 0x0d
39 #define EID_INTERRUPT_N 0x20
41 /* Exception Entry Points */
42 #define ENTRY_RESET 0x00
43 #define ENTRY_UNRECOVERABLE 0x01
44 #define ENTRY_HARDWARE_FAILURE 0x02
45 #define ENTRY_RUNTIME 0x03
46 #define ENTRY_MEMORY 0x04
47 #define ENTRY_SYSCALL 0x05
48 #define ENTRY_DEBUG 0x06
49 #define ENTRY_NMI 0x07
50 #define ENTRY_INTERRUPT_N 0x08
52 /* Hardware Debug Control */
53 #define HWDC_R (1<<4) /* Reset & Hardware Failure */
54 #define HWDC_I (1<<3) /* Interrupts */
55 #define HWDC_S (1<<2) /* System Calls */
56 #define HWDC_E (1<<1) /* Program Errors */
57 #define HWDC_D (1<<0) /* Debug Exceptions */
60 ESIRISC_CACHE_VON_NEUMANN
,
61 ESIRISC_CACHE_HARVARD
,
64 struct esirisc_common
{
65 struct target
*target
;
66 struct esirisc_jtag jtag_info
;
67 enum esirisc_cache cache_arch
;
70 struct reg_cache
*reg_cache
;
85 struct breakpoint
*breakpoints_p
[MAX_BREAKPOINTS
];
88 struct watchpoint
*watchpoints_p
[MAX_WATCHPOINTS
];
90 struct esirisc_trace trace_info
;
93 union esirisc_memory
{
100 struct esirisc_common
*esirisc
;
105 int (*read
)(struct reg
*reg
);
106 int (*write
)(struct reg
*reg
);
109 static inline struct esirisc_common
*target_to_esirisc(struct target
*target
)
111 return (struct esirisc_common
*)target
->arch_info
;
114 static inline char *esirisc_cache_arch_name(struct esirisc_common
*esirisc
)
116 return esirisc
->cache_arch
== ESIRISC_CACHE_HARVARD
? "harvard" : "von_neumann";
119 static inline bool esirisc_has_cache(struct esirisc_common
*esirisc
)
121 return esirisc
->has_icache
|| esirisc
->has_dcache
;
124 #endif /* OPENOCD_TARGET_ESIRISC_H */