OpenOCD
esirisc.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /***************************************************************************
4  * Copyright (C) 2018 by Square, Inc. *
5  * Steven Stallion <stallion@squareup.com> *
6  * James Zhao <hjz@squareup.com> *
7  ***************************************************************************/
8 
9 #ifndef OPENOCD_TARGET_ESIRISC_H
10 #define OPENOCD_TARGET_ESIRISC_H
11 
12 #include <helper/types.h>
13 #include <target/breakpoints.h>
14 #include <target/register.h>
15 #include <target/target.h>
16 
17 #include "esirisc_jtag.h"
18 #include "esirisc_regs.h"
19 #include "esirisc_trace.h"
20 
21 #define MAX_BREAKPOINTS 8
22 #define MAX_WATCHPOINTS 8
23 
24 /* Exception IDs */
25 #define EID_RESET 0x00
26 #define EID_HARDWARE_FAILURE 0x01
27 #define EID_NMI 0x02
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
40 
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
51 
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 */
58 
62 };
63 
65  struct target *target;
66  struct esirisc_jtag jtag_info;
68  char *gdb_arch;
69 
71  struct reg *epc;
72  struct reg *ecas;
73  struct reg *eid;
74  struct reg *ed;
75  uint32_t etc_save;
76  uint32_t hwdc_save;
77 
78  int num_bits;
79  int num_regs;
80  bool has_icache;
81  bool has_dcache;
82  bool has_trace;
83 
86 
89 
91 };
92 
94  uint32_t word;
95  uint16_t hword;
96  uint8_t byte;
97 };
98 
99 struct esirisc_reg {
101 
102  uint8_t bank;
103  uint8_t csr;
104 
105  int (*read)(struct reg *reg);
106  int (*write)(struct reg *reg);
107 };
108 
109 static inline struct esirisc_common *target_to_esirisc(struct target *target)
110 {
111  return (struct esirisc_common *)target->arch_info;
112 }
113 
114 static inline char *esirisc_cache_arch_name(struct esirisc_common *esirisc)
115 {
116  return esirisc->cache_arch == ESIRISC_CACHE_HARVARD ? "harvard" : "von_neumann";
117 }
118 
119 static inline bool esirisc_has_cache(struct esirisc_common *esirisc)
120 {
121  return esirisc->has_icache || esirisc->has_dcache;
122 }
123 
124 #endif /* OPENOCD_TARGET_ESIRISC_H */
static struct esirisc_common * target_to_esirisc(struct target *target)
Definition: esirisc.h:109
#define MAX_BREAKPOINTS
Definition: esirisc.h:21
static char * esirisc_cache_arch_name(struct esirisc_common *esirisc)
Definition: esirisc.h:114
esirisc_cache
Definition: esirisc.h:59
@ ESIRISC_CACHE_HARVARD
Definition: esirisc.h:61
@ ESIRISC_CACHE_VON_NEUMANN
Definition: esirisc.h:60
#define MAX_WATCHPOINTS
Definition: esirisc.h:22
static bool esirisc_has_cache(struct esirisc_common *esirisc)
Definition: esirisc.h:119
struct watchpoint * watchpoints_p[MAX_WATCHPOINTS]
Definition: esirisc.h:88
struct target * target
Definition: esirisc.h:65
struct reg * eid
Definition: esirisc.h:73
struct breakpoint * breakpoints_p[MAX_BREAKPOINTS]
Definition: esirisc.h:85
int num_regs
Definition: esirisc.h:79
char * gdb_arch
Definition: esirisc.h:68
int num_breakpoints
Definition: esirisc.h:84
struct reg_cache * reg_cache
Definition: esirisc.h:70
struct esirisc_jtag jtag_info
Definition: esirisc.h:66
bool has_trace
Definition: esirisc.h:82
uint32_t etc_save
Definition: esirisc.h:75
enum esirisc_cache cache_arch
Definition: esirisc.h:67
uint32_t hwdc_save
Definition: esirisc.h:76
int num_watchpoints
Definition: esirisc.h:87
struct reg * ecas
Definition: esirisc.h:72
int num_bits
Definition: esirisc.h:78
struct esirisc_trace trace_info
Definition: esirisc.h:90
struct reg * epc
Definition: esirisc.h:71
bool has_icache
Definition: esirisc.h:80
struct reg * ed
Definition: esirisc.h:74
bool has_dcache
Definition: esirisc.h:81
uint8_t csr
Definition: esirisc.h:103
int(* write)(struct reg *reg)
Definition: esirisc.h:106
int(* read)(struct reg *reg)
Definition: esirisc.h:105
struct esirisc_common * esirisc
Definition: esirisc.h:100
uint8_t bank
Definition: esirisc.h:102
Definition: register.h:111
Definition: target.h:120
void * arch_info
Definition: target.h:169
uint32_t word
Definition: esirisc.h:94
uint8_t byte
Definition: esirisc.h:96
uint16_t hword
Definition: esirisc.h:95