57deba616732842c9e2f443e503495aee7667018
[openocd.git] / src / target / esirisc.h
1 /***************************************************************************
2 * Copyright (C) 2018 by Square, Inc. *
3 * Steven Stallion <stallion@squareup.com> *
4 * James Zhao <hjz@squareup.com> *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
18 ***************************************************************************/
19
20 #ifndef OPENOCD_TARGET_ESIRISC_H
21 #define OPENOCD_TARGET_ESIRISC_H
22
23 #include <helper/types.h>
24 #include <target/breakpoints.h>
25 #include <target/register.h>
26 #include <target/target.h>
27
28 #include "esirisc_jtag.h"
29 #include "esirisc_regs.h"
30 #include "esirisc_trace.h"
31
32 #define MAX_BREAKPOINTS 8
33 #define MAX_WATCHPOINTS 8
34
35 /* Exception IDs */
36 #define EID_RESET 0x00
37 #define EID_HARDWARE_FAILURE 0x01
38 #define EID_NMI 0x02
39 #define EID_INST_BREAKPOINT 0x03
40 #define EID_DATA_BREAKPOINT 0x04
41 #define EID_UNSUPPORTED 0x05
42 #define EID_PRIVILEGE_VIOLATION 0x06
43 #define EID_INST_BUS_ERROR 0x07
44 #define EID_DATA_BUS_ERROR 0x08
45 #define EID_ALIGNMENT_ERROR 0x09
46 #define EID_ARITHMETIC_ERROR 0x0a
47 #define EID_SYSTEM_CALL 0x0b
48 #define EID_MEMORY_MANAGEMENT 0x0c
49 #define EID_UNRECOVERABLE 0x0d
50 #define EID_INTERRUPTn 0x20
51
52 /* Exception Entry Points */
53 #define ENTRY_RESET 0x00
54 #define ENTRY_UNRECOVERABLE 0x01
55 #define ENTRY_HARDWARE_FAILURE 0x02
56 #define ENTRY_RUNTIME 0x03
57 #define ENTRY_MEMORY 0x04
58 #define ENTRY_SYSCALL 0x05
59 #define ENTRY_DEBUG 0x06
60 #define ENTRY_NMI 0x07
61 #define ENTRY_INTERRUPTn 0x08
62
63 /* Hardware Debug Control */
64 #define HWDC_R (1<<4) /* Reset & Hardware Failure */
65 #define HWDC_I (1<<3) /* Interrupts */
66 #define HWDC_S (1<<2) /* System Calls */
67 #define HWDC_E (1<<1) /* Program Errors */
68 #define HWDC_D (1<<0) /* Debug Exceptions */
69
70 enum esirisc_cache {
71 ESIRISC_CACHE_VON_NEUMANN,
72 ESIRISC_CACHE_HARVARD,
73 };
74
75 struct esirisc_common {
76 struct target *target;
77 struct esirisc_jtag jtag_info;
78 enum esirisc_cache cache_arch;
79 char *gdb_arch;
80
81 struct reg_cache *reg_cache;
82 struct reg *epc;
83 struct reg *ecas;
84 struct reg *eid;
85 struct reg *ed;
86 uint32_t etc_save;
87 uint32_t hwdc_save;
88
89 int num_bits;
90 int num_regs;
91 bool has_icache;
92 bool has_dcache;
93 bool has_trace;
94
95 int num_breakpoints;
96 struct breakpoint *breakpoints_p[MAX_BREAKPOINTS];
97
98 int num_watchpoints;
99 struct watchpoint *watchpoints_p[MAX_WATCHPOINTS];
100
101 struct esirisc_trace trace_info;
102 };
103
104 union esirisc_memory {
105 uint32_t word;
106 uint16_t hword;
107 uint8_t byte;
108 };
109
110 struct esirisc_reg {
111 struct esirisc_common *esirisc;
112
113 uint8_t bank;
114 uint8_t csr;
115
116 int (*read)(struct reg *reg);
117 int (*write)(struct reg *reg);
118 };
119
120 static inline struct esirisc_common *target_to_esirisc(struct target *target)
121 {
122 return (struct esirisc_common *)target->arch_info;
123 }
124
125 static inline char *esirisc_cache_arch_name(struct esirisc_common *esirisc)
126 {
127 return esirisc->cache_arch == ESIRISC_CACHE_HARVARD ? "harvard" : "von_neumann";
128 }
129
130 static inline bool esirisc_has_cache(struct esirisc_common *esirisc)
131 {
132 return esirisc->has_icache || esirisc->has_dcache;
133 }
134
135 #endif /* OPENOCD_TARGET_ESIRISC_H */

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)