aarch64: Correct target state for hardware step
[openocd.git] / src / target / armv8.h
blob47e36680ed159a2a0a4d493acd0c4261e1dfc418
1 /***************************************************************************
2 * Copyright (C) 2015 by David Ung *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 ***************************************************************************/
19 #ifndef OPENOCD_TARGET_ARMV8_H
20 #define OPENOCD_TARGET_ARMV8_H
22 #include "arm_adi_v5.h"
23 #include "arm.h"
24 #include "armv4_5_mmu.h"
25 #include "armv4_5_cache.h"
26 #include "arm_dpm.h"
28 enum {
29 ARMV8_R0,
30 ARMV8_R1,
31 ARMV8_R2,
32 ARMV8_R3,
33 ARMV8_R4,
34 ARMV8_R5,
35 ARMV8_R6,
36 ARMV8_R7,
37 ARMV8_R8,
38 ARMV8_R9,
39 ARMV8_R10,
40 ARMV8_R11,
41 ARMV8_R12,
42 ARMV8_R13,
43 ARMV8_R14,
44 ARMV8_R15,
45 ARMV8_R16,
46 ARMV8_R17,
47 ARMV8_R18,
48 ARMV8_R19,
49 ARMV8_R20,
50 ARMV8_R21,
51 ARMV8_R22,
52 ARMV8_R23,
53 ARMV8_R24,
54 ARMV8_R25,
55 ARMV8_R26,
56 ARMV8_R27,
57 ARMV8_R28,
58 ARMV8_R29,
59 ARMV8_R30,
60 ARMV8_R31,
62 ARMV8_PC = 32,
63 ARMV8_xPSR = 33,
65 ARMV8_LAST_REG,
69 #define ARMV8_COMMON_MAGIC 0x0A450AAA
71 /* VA to PA translation operations opc2 values*/
72 #define V2PCWPR 0
73 #define V2PCWPW 1
74 #define V2PCWUR 2
75 #define V2PCWUW 3
76 #define V2POWPR 4
77 #define V2POWPW 5
78 #define V2POWUR 6
79 #define V2POWUW 7
80 /* L210/L220 cache controller support */
81 struct armv8_l2x_cache {
82 uint32_t base;
83 uint32_t way;
86 struct armv8_cachesize {
87 uint32_t level_num;
88 /* cache dimensionning */
89 uint32_t linelen;
90 uint32_t associativity;
91 uint32_t nsets;
92 uint32_t cachesize;
93 /* info for set way operation on cache */
94 uint32_t index;
95 uint32_t index_shift;
96 uint32_t way;
97 uint32_t way_shift;
100 struct armv8_cache_common {
101 int ctype;
102 struct armv8_cachesize d_u_size; /* data cache */
103 struct armv8_cachesize i_size; /* instruction cache */
104 int i_cache_enabled;
105 int d_u_cache_enabled;
106 /* l2 external unified cache if some */
107 void *l2_cache;
108 int (*flush_all_data_cache)(struct target *target);
109 int (*display_cache_info)(struct command_context *cmd_ctx,
110 struct armv8_cache_common *armv8_cache);
113 struct armv8_mmu_common {
114 /* following field mmu working way */
115 int32_t ttbr1_used; /* -1 not initialized, 0 no ttbr1 1 ttbr1 used and */
116 uint32_t ttbr0_mask;/* masked to be used */
117 uint32_t os_border;
119 int (*read_physical_memory)(struct target *target, target_addr_t address,
120 uint32_t size, uint32_t count, uint8_t *buffer);
121 struct armv8_cache_common armv8_cache;
122 uint32_t mmu_enabled;
125 struct armv8_common {
126 struct arm arm;
127 int common_magic;
128 struct reg_cache *core_cache;
130 /* Core Debug Unit */
131 struct arm_dpm dpm;
132 uint32_t debug_base;
133 struct adiv5_ap *debug_ap;
134 struct adiv5_ap *memory_ap;
135 bool memory_ap_available;
136 /* mdir */
137 uint8_t multi_processor_system;
138 uint8_t cluster_id;
139 uint8_t cpu_id;
140 bool is_armv7r;
142 /* cache specific to V7 Memory Management Unit compatible with v4_5*/
143 struct armv8_mmu_common armv8_mmu;
145 /* Direct processor core register read and writes */
146 int (*load_core_reg_u64)(struct target *target, uint32_t num, uint64_t *value);
147 int (*store_core_reg_u64)(struct target *target, uint32_t num, uint64_t value);
149 int (*examine_debug_reason)(struct target *target);
150 int (*post_debug_entry)(struct target *target);
152 void (*pre_restore_context)(struct target *target);
155 static inline struct armv8_common *
156 target_to_armv8(struct target *target)
158 return container_of(target->arch_info, struct armv8_common, arm);
161 /* register offsets from armv8.debug_base */
163 #define CPUDBG_WFAR 0x018
164 #define CPUDBG_DESR 0x020
165 #define CPUDBG_DECR 0x024
166 /* PCSR at 0x084 -or- 0x0a0 -or- both ... based on flags in DIDR */
167 #define CPUDBG_DSCR 0x088
168 #define CPUDBG_DRCR 0x090
169 #define CPUDBG_PRCR 0x310
170 #define CPUDBG_PRSR 0x314
172 #define CPUDBG_DTRRX 0x080
173 #define CPUDBG_ITR 0x084
174 #define CPUDBG_DTRTX 0x08c
176 #define CPUDBG_BVR_BASE 0x400
177 #define CPUDBG_BCR_BASE 0x408
178 #define CPUDBG_WVR_BASE 0x180
179 #define CPUDBG_WCR_BASE 0x1C0
180 #define CPUDBG_VCR 0x01C
182 #define CPUDBG_OSLAR 0x300
183 #define CPUDBG_OSLSR 0x304
184 #define CPUDBG_OSSRR 0x308
185 #define CPUDBG_ECR 0x024
187 #define CPUDBG_DSCCR 0x028
189 #define CPUDBG_AUTHSTATUS 0xFB8
191 int armv8_arch_state(struct target *target);
192 int armv8_identify_cache(struct target *target);
193 int armv8_init_arch_info(struct target *target, struct armv8_common *armv8);
194 int armv8_mmu_translate_va_pa(struct target *target, target_addr_t va,
195 target_addr_t *val, int meminfo);
196 int armv8_mmu_translate_va(struct target *target, uint32_t va, uint32_t *val);
198 int armv8_handle_cache_info_command(struct command_context *cmd_ctx,
199 struct armv8_cache_common *armv8_cache);
201 extern const struct command_registration armv8_command_handlers[];
203 #endif