OpenOCD
armv8.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 /***************************************************************************
4  * Copyright (C) 2015 by David Ung *
5  * *
6  * Copyright (C) 2018 by Liviu Ionescu *
7  * <ilg@livius.net> *
8  ***************************************************************************/
9 
10 #ifdef HAVE_CONFIG_H
11 #include "config.h"
12 #endif
13 
14 #include <helper/replacements.h>
15 
16 #include "armv8.h"
17 
18 #include "register.h"
19 #include <helper/binarybuffer.h>
20 #include <helper/string_choices.h>
21 #include <helper/command.h>
22 #include <helper/nvp.h>
23 
24 #include <stdlib.h>
25 #include <string.h>
26 #include <unistd.h>
27 
28 #include "armv8_opcodes.h"
29 #include "target.h"
30 #include "target_type.h"
31 #include "semihosting_common.h"
32 
33 static const char * const armv8_state_strings[] = {
34  "AArch32", "Thumb", "Jazelle", "ThumbEE", "AArch64",
35 };
36 
37 static const struct {
38  const char *name;
39  unsigned int psr;
40 } armv8_mode_data[] = {
41  {
42  .name = "USR",
43  .psr = ARM_MODE_USR,
44  },
45  {
46  .name = "FIQ",
47  .psr = ARM_MODE_FIQ,
48  },
49  {
50  .name = "IRQ",
51  .psr = ARM_MODE_IRQ,
52  },
53  {
54  .name = "SVC",
55  .psr = ARM_MODE_SVC,
56  },
57  {
58  .name = "MON",
59  .psr = ARM_MODE_MON,
60  },
61  {
62  .name = "ABT",
63  .psr = ARM_MODE_ABT,
64  },
65  {
66  .name = "HYP",
67  .psr = ARM_MODE_HYP,
68  },
69  {
70  .name = "UND",
71  .psr = ARM_MODE_UND,
72  },
73  {
74  .name = "SYS",
75  .psr = ARM_MODE_SYS,
76  },
77  {
78  .name = "EL0T",
79  .psr = ARMV8_64_EL0T,
80  },
81  {
82  .name = "EL1T",
83  .psr = ARMV8_64_EL1T,
84  },
85  {
86  .name = "EL1H",
87  .psr = ARMV8_64_EL1H,
88  },
89  {
90  .name = "EL2T",
91  .psr = ARMV8_64_EL2T,
92  },
93  {
94  .name = "EL2H",
95  .psr = ARMV8_64_EL2H,
96  },
97  {
98  .name = "EL3T",
99  .psr = ARMV8_64_EL3T,
100  },
101  {
102  .name = "EL3H",
103  .psr = ARMV8_64_EL3H,
104  },
105 };
106 
108 const char *armv8_mode_name(unsigned int psr_mode)
109 {
110  for (unsigned int i = 0; i < ARRAY_SIZE(armv8_mode_data); i++) {
111  if (armv8_mode_data[i].psr == psr_mode)
112  return armv8_mode_data[i].name;
113  }
114  LOG_ERROR("unrecognized psr mode: %#02x", psr_mode);
115  return "UNRECOGNIZED";
116 }
117 
118 static uint8_t armv8_pa_size(uint32_t ps)
119 {
120  uint8_t ret = 0;
121  switch (ps) {
122  case 0:
123  ret = 32;
124  break;
125  case 1:
126  ret = 36;
127  break;
128  case 2:
129  ret = 40;
130  break;
131  case 3:
132  ret = 42;
133  break;
134  case 4:
135  ret = 44;
136  break;
137  case 5:
138  ret = 48;
139  break;
140  default:
141  LOG_INFO("Unknown physical address size");
142  break;
143  }
144  return ret;
145 }
146 
147 static __attribute__((unused)) int armv8_read_ttbcr32(struct target *target)
148 {
149  struct armv8_common *armv8 = target_to_armv8(target);
150  struct arm_dpm *dpm = armv8->arm.dpm;
151  uint32_t ttbcr, ttbcr_n;
152  int retval = dpm->prepare(dpm);
153  if (retval != ERROR_OK)
154  goto done;
155  /* MRC p15,0,<Rt>,c2,c0,2 ; Read CP15 Translation Table Base Control Register*/
156  retval = dpm->instr_read_data_r0(dpm,
157  ARMV4_5_MRC(15, 0, 0, 2, 0, 2),
158  &ttbcr);
159  if (retval != ERROR_OK)
160  goto done;
161 
162  LOG_DEBUG("ttbcr %" PRIx32, ttbcr);
163 
164  ttbcr_n = ttbcr & 0x7;
165  armv8->armv8_mmu.ttbcr = ttbcr;
166 
167  /*
168  * ARM Architecture Reference Manual (ARMv7-A and ARMv7-R edition),
169  * document # ARM DDI 0406C
170  */
171  armv8->armv8_mmu.ttbr_range[0] = 0xffffffff >> ttbcr_n;
172  armv8->armv8_mmu.ttbr_range[1] = 0xffffffff;
173  armv8->armv8_mmu.ttbr_mask[0] = 0xffffffff << (14 - ttbcr_n);
174  armv8->armv8_mmu.ttbr_mask[1] = 0xffffffff << 14;
175 
176  LOG_DEBUG("ttbr1 %s, ttbr0_mask %" PRIx32 " ttbr1_mask %" PRIx32,
177  (ttbcr_n != 0) ? "used" : "not used",
178  armv8->armv8_mmu.ttbr_mask[0],
179  armv8->armv8_mmu.ttbr_mask[1]);
180 
181 done:
182  dpm->finish(dpm);
183  return retval;
184 }
185 
186 static int armv8_read_ttbcr(struct target *target)
187 {
188  struct armv8_common *armv8 = target_to_armv8(target);
189  struct arm_dpm *dpm = armv8->arm.dpm;
190  struct arm *arm = &armv8->arm;
191  uint32_t ttbcr;
192  uint64_t ttbcr_64;
193 
194  int retval = dpm->prepare(dpm);
195  if (retval != ERROR_OK)
196  goto done;
197 
198  /* clear ttrr1_used and ttbr0_mask */
199  memset(&armv8->armv8_mmu.ttbr1_used, 0, sizeof(armv8->armv8_mmu.ttbr1_used));
200  memset(&armv8->armv8_mmu.ttbr0_mask, 0, sizeof(armv8->armv8_mmu.ttbr0_mask));
201 
203  case SYSTEM_CUREL_EL3:
204  retval = dpm->instr_read_data_r0(dpm,
206  &ttbcr);
207  if (retval != ERROR_OK)
208  goto done;
209  retval = dpm->instr_read_data_r0_64(dpm,
211  &armv8->ttbr_base);
212  if (retval != ERROR_OK)
213  goto done;
214  armv8->va_size = 64 - (ttbcr & 0x3F);
215  armv8->pa_size = armv8_pa_size((ttbcr >> 16) & 7);
216  armv8->page_size = (ttbcr >> 14) & 3;
217  break;
218  case SYSTEM_CUREL_EL2:
219  retval = dpm->instr_read_data_r0(dpm,
221  &ttbcr);
222  if (retval != ERROR_OK)
223  goto done;
224  retval = dpm->instr_read_data_r0_64(dpm,
226  &armv8->ttbr_base);
227  if (retval != ERROR_OK)
228  goto done;
229  armv8->va_size = 64 - (ttbcr & 0x3F);
230  armv8->pa_size = armv8_pa_size((ttbcr >> 16) & 7);
231  armv8->page_size = (ttbcr >> 14) & 3;
232  break;
233  case SYSTEM_CUREL_EL0:
235  /* fall through */
236  case SYSTEM_CUREL_EL1:
237  retval = dpm->instr_read_data_r0_64(dpm,
239  &ttbcr_64);
240  if (retval != ERROR_OK)
241  goto done;
242  armv8->va_size = 64 - (ttbcr_64 & 0x3F);
243  armv8->pa_size = armv8_pa_size((ttbcr_64 >> 32) & 7);
244  armv8->page_size = (ttbcr_64 >> 14) & 3;
245  armv8->armv8_mmu.ttbr1_used = (((ttbcr_64 >> 16) & 0x3F) != 0) ? 1 : 0;
246  armv8->armv8_mmu.ttbr0_mask = 0x0000FFFFFFFFFFFFULL;
247  retval = dpm->instr_read_data_r0_64(dpm,
249  &armv8->ttbr_base);
250  if (retval != ERROR_OK)
251  goto done;
252  break;
253  default:
254  LOG_ERROR("unknown core state");
255  retval = ERROR_FAIL;
256  break;
257  }
258  if (retval != ERROR_OK)
259  goto done;
260 
261  if (armv8->armv8_mmu.ttbr1_used == 1)
262  LOG_INFO("TTBR0 access above %" PRIx64, (uint64_t)(armv8->armv8_mmu.ttbr0_mask));
263 
264 done:
266  dpm->finish(dpm);
267  return retval;
268 }
269 
270 static int armv8_get_pauth_mask(struct armv8_common *armv8, uint64_t *mask)
271 {
272  struct arm *arm = &armv8->arm;
273  int retval = ERROR_OK;
274  if (armv8->va_size == 0)
275  retval = armv8_read_ttbcr(arm->target);
276  if (retval != ERROR_OK)
277  return retval;
278 
279  *mask = ~(((uint64_t)1 << armv8->va_size) - 1);
280 
281  return retval;
282 }
283 
284 static int armv8_read_reg(struct armv8_common *armv8, int regnum, uint64_t *regval)
285 {
286  struct arm_dpm *dpm = &armv8->dpm;
287  unsigned int curel = armv8_curel_from_core_mode(dpm->arm->core_mode);
288  int retval;
289  uint32_t value;
290  uint64_t value_64;
291 
292  if (!regval)
293  return ERROR_FAIL;
294 
295  switch (regnum) {
296  case 0 ... 30:
297  retval = dpm->instr_read_data_dcc_64(dpm,
298  ARMV8_MSR_GP(SYSTEM_DBG_DBGDTR_EL0, regnum), &value_64);
299  break;
300  case ARMV8_SP:
301  retval = dpm->instr_read_data_r0_64(dpm,
302  ARMV8_MOVFSP_64(0), &value_64);
303  break;
304  case ARMV8_PC:
305  retval = dpm->instr_read_data_r0_64(dpm,
306  ARMV8_MRS_DLR(0), &value_64);
307  break;
308  case ARMV8_XPSR:
309  retval = dpm->instr_read_data_r0(dpm,
310  ARMV8_MRS_DSPSR(0), &value);
311  value_64 = value;
312  break;
313  case ARMV8_FPSR:
314  retval = dpm->instr_read_data_r0(dpm,
315  ARMV8_MRS_FPSR(0), &value);
316  value_64 = value;
317  break;
318  case ARMV8_FPCR:
319  retval = dpm->instr_read_data_r0(dpm,
320  ARMV8_MRS_FPCR(0), &value);
321  value_64 = value;
322  break;
323  case ARMV8_ELR_EL1:
324  if (curel < SYSTEM_CUREL_EL1) {
325  LOG_DEBUG("ELR_EL1 not accessible in EL%u", curel);
326  retval = ERROR_FAIL;
327  break;
328  }
329  retval = dpm->instr_read_data_r0_64(dpm,
330  ARMV8_MRS(SYSTEM_ELR_EL1, 0), &value_64);
331  break;
332  case ARMV8_ELR_EL2:
333  if (curel < SYSTEM_CUREL_EL2) {
334  LOG_DEBUG("ELR_EL2 not accessible in EL%u", curel);
335  retval = ERROR_FAIL;
336  break;
337  }
338  retval = dpm->instr_read_data_r0_64(dpm,
339  ARMV8_MRS(SYSTEM_ELR_EL2, 0), &value_64);
340  break;
341  case ARMV8_ELR_EL3:
342  if (curel < SYSTEM_CUREL_EL3) {
343  LOG_DEBUG("ELR_EL3 not accessible in EL%u", curel);
344  retval = ERROR_FAIL;
345  break;
346  }
347  retval = dpm->instr_read_data_r0_64(dpm,
348  ARMV8_MRS(SYSTEM_ELR_EL3, 0), &value_64);
349  break;
350  case ARMV8_ESR_EL1:
351  if (curel < SYSTEM_CUREL_EL1) {
352  LOG_DEBUG("ESR_EL1 not accessible in EL%u", curel);
353  retval = ERROR_FAIL;
354  break;
355  }
356  retval = dpm->instr_read_data_r0_64(dpm,
357  ARMV8_MRS(SYSTEM_ESR_EL1, 0), &value_64);
358  break;
359  case ARMV8_ESR_EL2:
360  if (curel < SYSTEM_CUREL_EL2) {
361  LOG_DEBUG("ESR_EL2 not accessible in EL%u", curel);
362  retval = ERROR_FAIL;
363  break;
364  }
365  retval = dpm->instr_read_data_r0_64(dpm,
366  ARMV8_MRS(SYSTEM_ESR_EL2, 0), &value_64);
367  break;
368  case ARMV8_ESR_EL3:
369  if (curel < SYSTEM_CUREL_EL3) {
370  LOG_DEBUG("ESR_EL3 not accessible in EL%u", curel);
371  retval = ERROR_FAIL;
372  break;
373  }
374  retval = dpm->instr_read_data_r0_64(dpm,
375  ARMV8_MRS(SYSTEM_ESR_EL3, 0), &value_64);
376  break;
377  case ARMV8_SPSR_EL1:
378  if (curel < SYSTEM_CUREL_EL1) {
379  LOG_DEBUG("SPSR_EL1 not accessible in EL%u", curel);
380  retval = ERROR_FAIL;
381  break;
382  }
383  retval = dpm->instr_read_data_r0_64(dpm,
384  ARMV8_MRS(SYSTEM_SPSR_EL1, 0), &value_64);
385  break;
386  case ARMV8_SPSR_EL2:
387  if (curel < SYSTEM_CUREL_EL2) {
388  LOG_DEBUG("SPSR_EL2 not accessible in EL%u", curel);
389  retval = ERROR_FAIL;
390  break;
391  }
392  retval = dpm->instr_read_data_r0_64(dpm,
393  ARMV8_MRS(SYSTEM_SPSR_EL2, 0), &value_64);
394  break;
395  case ARMV8_SPSR_EL3:
396  if (curel < SYSTEM_CUREL_EL3) {
397  LOG_DEBUG("SPSR_EL3 not accessible in EL%u", curel);
398  retval = ERROR_FAIL;
399  break;
400  }
401  retval = dpm->instr_read_data_r0_64(dpm,
402  ARMV8_MRS(SYSTEM_SPSR_EL3, 0), &value_64);
403  break;
404  case ARMV8_PAUTH_CMASK:
405  case ARMV8_PAUTH_DMASK:
406  retval = armv8_get_pauth_mask(armv8, &value_64);
407  break;
408  default:
409  retval = ERROR_FAIL;
410  break;
411  }
412 
413  if (retval == ERROR_OK)
414  *regval = value_64;
415 
416  return retval;
417 }
418 
419 static int armv8_read_reg_simdfp_aarch64(struct armv8_common *armv8, int regnum, uint64_t *lvalue, uint64_t *hvalue)
420 {
421  int retval = ERROR_FAIL;
422  struct arm_dpm *dpm = &armv8->dpm;
423 
424  switch (regnum) {
425  case ARMV8_V0 ... ARMV8_V31:
426  retval = dpm->instr_read_data_r0_64(dpm,
427  ARMV8_MOV_GPR_VFP(0, (regnum - ARMV8_V0), 1), hvalue);
428  if (retval != ERROR_OK)
429  return retval;
430  retval = dpm->instr_read_data_r0_64(dpm,
431  ARMV8_MOV_GPR_VFP(0, (regnum - ARMV8_V0), 0), lvalue);
432  break;
433 
434  default:
435  retval = ERROR_FAIL;
436  break;
437  }
438 
439  return retval;
440 }
441 
442 static int armv8_write_reg(struct armv8_common *armv8, int regnum, uint64_t value_64)
443 {
444  struct arm_dpm *dpm = &armv8->dpm;
445  unsigned int curel = armv8_curel_from_core_mode(dpm->arm->core_mode);
446  int retval;
447  uint32_t value;
448 
449  switch (regnum) {
450  case 0 ... 30:
451  retval = dpm->instr_write_data_dcc_64(dpm,
453  value_64);
454  break;
455  case ARMV8_SP:
456  retval = dpm->instr_write_data_r0_64(dpm,
457  ARMV8_MOVTSP_64(0),
458  value_64);
459  break;
460  case ARMV8_PC:
461  retval = dpm->instr_write_data_r0_64(dpm,
462  ARMV8_MSR_DLR(0),
463  value_64);
464  break;
465  case ARMV8_XPSR:
466  value = value_64;
467  retval = dpm->instr_write_data_r0(dpm,
468  ARMV8_MSR_DSPSR(0),
469  value);
470  break;
471  case ARMV8_FPSR:
472  value = value_64;
473  retval = dpm->instr_write_data_r0(dpm,
474  ARMV8_MSR_FPSR(0),
475  value);
476  break;
477  case ARMV8_FPCR:
478  value = value_64;
479  retval = dpm->instr_write_data_r0(dpm,
480  ARMV8_MSR_FPCR(0),
481  value);
482  break;
483  /* registers clobbered by taking exception in debug state */
484  case ARMV8_ELR_EL1:
485  if (curel < SYSTEM_CUREL_EL1) {
486  LOG_DEBUG("ELR_EL1 not accessible in EL%u", curel);
487  retval = ERROR_FAIL;
488  break;
489  }
490  retval = dpm->instr_write_data_r0_64(dpm,
491  ARMV8_MSR_GP(SYSTEM_ELR_EL1, 0), value_64);
492  break;
493  case ARMV8_ELR_EL2:
494  if (curel < SYSTEM_CUREL_EL2) {
495  LOG_DEBUG("ELR_EL2 not accessible in EL%u", curel);
496  retval = ERROR_FAIL;
497  break;
498  }
499  retval = dpm->instr_write_data_r0_64(dpm,
500  ARMV8_MSR_GP(SYSTEM_ELR_EL2, 0), value_64);
501  break;
502  case ARMV8_ELR_EL3:
503  if (curel < SYSTEM_CUREL_EL3) {
504  LOG_DEBUG("ELR_EL3 not accessible in EL%u", curel);
505  retval = ERROR_FAIL;
506  break;
507  }
508  retval = dpm->instr_write_data_r0_64(dpm,
509  ARMV8_MSR_GP(SYSTEM_ELR_EL3, 0), value_64);
510  break;
511  case ARMV8_ESR_EL1:
512  if (curel < SYSTEM_CUREL_EL1) {
513  LOG_DEBUG("ESR_EL1 not accessible in EL%u", curel);
514  retval = ERROR_FAIL;
515  break;
516  }
517  retval = dpm->instr_write_data_r0_64(dpm,
518  ARMV8_MSR_GP(SYSTEM_ESR_EL1, 0), value_64);
519  break;
520  case ARMV8_ESR_EL2:
521  if (curel < SYSTEM_CUREL_EL2) {
522  LOG_DEBUG("ESR_EL2 not accessible in EL%u", curel);
523  retval = ERROR_FAIL;
524  break;
525  }
526  retval = dpm->instr_write_data_r0_64(dpm,
527  ARMV8_MSR_GP(SYSTEM_ESR_EL2, 0), value_64);
528  break;
529  case ARMV8_ESR_EL3:
530  if (curel < SYSTEM_CUREL_EL3) {
531  LOG_DEBUG("ESR_EL3 not accessible in EL%u", curel);
532  retval = ERROR_FAIL;
533  break;
534  }
535  retval = dpm->instr_write_data_r0_64(dpm,
536  ARMV8_MSR_GP(SYSTEM_ESR_EL3, 0), value_64);
537  break;
538  case ARMV8_SPSR_EL1:
539  if (curel < SYSTEM_CUREL_EL1) {
540  LOG_DEBUG("SPSR_EL1 not accessible in EL%u", curel);
541  retval = ERROR_FAIL;
542  break;
543  }
544  retval = dpm->instr_write_data_r0_64(dpm,
545  ARMV8_MSR_GP(SYSTEM_SPSR_EL1, 0), value_64);
546  break;
547  case ARMV8_SPSR_EL2:
548  if (curel < SYSTEM_CUREL_EL2) {
549  LOG_DEBUG("SPSR_EL2 not accessible in EL%u", curel);
550  retval = ERROR_FAIL;
551  break;
552  }
553  retval = dpm->instr_write_data_r0_64(dpm,
554  ARMV8_MSR_GP(SYSTEM_SPSR_EL2, 0), value_64);
555  break;
556  case ARMV8_SPSR_EL3:
557  if (curel < SYSTEM_CUREL_EL3) {
558  LOG_DEBUG("SPSR_EL3 not accessible in EL%u", curel);
559  retval = ERROR_FAIL;
560  break;
561  }
562  retval = dpm->instr_write_data_r0_64(dpm,
563  ARMV8_MSR_GP(SYSTEM_SPSR_EL3, 0), value_64);
564  break;
565  default:
566  retval = ERROR_FAIL;
567  break;
568  }
569 
570  return retval;
571 }
572 
573 static int armv8_write_reg_simdfp_aarch64(struct armv8_common *armv8, int regnum, uint64_t lvalue, uint64_t hvalue)
574 {
575  int retval = ERROR_FAIL;
576  struct arm_dpm *dpm = &armv8->dpm;
577 
578  switch (regnum) {
579  case ARMV8_V0 ... ARMV8_V31:
580  retval = dpm->instr_write_data_r0_64(dpm,
581  ARMV8_MOV_VFP_GPR((regnum - ARMV8_V0), 0, 1), hvalue);
582  if (retval != ERROR_OK)
583  return retval;
584  retval = dpm->instr_write_data_r0_64(dpm,
585  ARMV8_MOV_VFP_GPR((regnum - ARMV8_V0), 0, 0), lvalue);
586  break;
587 
588  default:
589  retval = ERROR_FAIL;
590  break;
591  }
592 
593  return retval;
594 }
595 
596 static int armv8_read_reg32(struct armv8_common *armv8, int regnum, uint64_t *regval)
597 {
598  struct arm_dpm *dpm = &armv8->dpm;
599  uint32_t value = 0;
600  int retval;
601 
602  if (!regval)
603  return ERROR_FAIL;
604 
605  switch (regnum) {
606  case ARMV8_R0 ... ARMV8_R14:
607  /* return via DCC: "MCR p14, 0, Rnum, c0, c5, 0" */
608  retval = dpm->instr_read_data_dcc(dpm,
609  ARMV4_5_MCR(14, 0, regnum, 0, 5, 0),
610  &value);
611  break;
612  case ARMV8_SP:
613  retval = dpm->instr_read_data_dcc(dpm,
614  ARMV4_5_MCR(14, 0, 13, 0, 5, 0),
615  &value);
616  break;
617  case ARMV8_PC:
618  retval = dpm->instr_read_data_r0(dpm,
619  ARMV8_MRC_DLR(0),
620  &value);
621  break;
622  case ARMV8_XPSR:
623  retval = dpm->instr_read_data_r0(dpm,
624  ARMV8_MRC_DSPSR(0),
625  &value);
626  break;
627  case ARMV8_ELR_EL1: /* mapped to LR_svc */
628  retval = dpm->instr_read_data_dcc(dpm,
629  ARMV4_5_MCR(14, 0, 14, 0, 5, 0),
630  &value);
631  break;
632  case ARMV8_ELR_EL2: /* mapped to ELR_hyp */
633  retval = dpm->instr_read_data_r0(dpm,
634  ARMV8_MRS_T1(0, 14, 0, 1),
635  &value);
636  break;
637  case ARMV8_ELR_EL3: /* mapped to LR_mon */
638  retval = dpm->instr_read_data_dcc(dpm,
639  ARMV4_5_MCR(14, 0, 14, 0, 5, 0),
640  &value);
641  break;
642  case ARMV8_ESR_EL1: /* mapped to DFSR */
643  retval = dpm->instr_read_data_r0(dpm,
644  ARMV4_5_MRC(15, 0, 0, 5, 0, 0),
645  &value);
646  break;
647  case ARMV8_ESR_EL2: /* mapped to HSR */
648  retval = dpm->instr_read_data_r0(dpm,
649  ARMV4_5_MRC(15, 4, 0, 5, 2, 0),
650  &value);
651  break;
652  case ARMV8_ESR_EL3: /* no equivalent in aarch32 */
653  retval = ERROR_FAIL;
654  break;
655  case ARMV8_SPSR_EL1: /* mapped to SPSR_svc */
656  retval = dpm->instr_read_data_r0(dpm,
657  ARMV8_MRS_XPSR_T1(1, 0),
658  &value);
659  break;
660  case ARMV8_SPSR_EL2: /* mapped to SPSR_hyp */
661  retval = dpm->instr_read_data_r0(dpm,
662  ARMV8_MRS_XPSR_T1(1, 0),
663  &value);
664  break;
665  case ARMV8_SPSR_EL3: /* mapped to SPSR_mon */
666  retval = dpm->instr_read_data_r0(dpm,
667  ARMV8_MRS_XPSR_T1(1, 0),
668  &value);
669  break;
670  case ARMV8_FPSR:
671  /* "VMRS r0, FPSCR"; then return via DCC */
672  retval = dpm->instr_read_data_r0(dpm,
673  ARMV4_5_VMRS(0), &value);
674  break;
675  default:
676  retval = ERROR_FAIL;
677  break;
678  }
679 
680  if (retval == ERROR_OK)
681  *regval = value;
682 
683  return retval;
684 }
685 
686 static int armv8_read_reg_simdfp_aarch32(struct armv8_common *armv8, int regnum, uint64_t *lvalue, uint64_t *hvalue)
687 {
688  int retval = ERROR_FAIL;
689  struct arm_dpm *dpm = &armv8->dpm;
690  struct reg *reg_r1 = dpm->arm->core_cache->reg_list + ARMV8_R1;
691  uint32_t value_r0 = 0, value_r1 = 0;
692  unsigned int num = (regnum - ARMV8_V0) << 1;
693 
694  switch (regnum) {
695  case ARMV8_V0 ... ARMV8_V15:
696  /* we are going to write R1, mark it dirty */
697  reg_r1->dirty = true;
698  /* move from double word register to r0:r1: "vmov r0, r1, vm"
699  * then read r0 via dcc
700  */
701  retval = dpm->instr_read_data_r0(dpm,
702  ARMV4_5_VMOV(1, 1, 0, (num >> 4), (num & 0xf)),
703  &value_r0);
704  if (retval != ERROR_OK)
705  return retval;
706  /* read r1 via dcc */
707  retval = dpm->instr_read_data_dcc(dpm,
708  ARMV4_5_MCR(14, 0, 1, 0, 5, 0),
709  &value_r1);
710  if (retval != ERROR_OK)
711  return retval;
712  *lvalue = value_r1;
713  *lvalue = ((*lvalue) << 32) | value_r0;
714 
715  num++;
716  /* repeat above steps for high 64 bits of V register */
717  retval = dpm->instr_read_data_r0(dpm,
718  ARMV4_5_VMOV(1, 1, 0, (num >> 4), (num & 0xf)),
719  &value_r0);
720  if (retval != ERROR_OK)
721  return retval;
722  retval = dpm->instr_read_data_dcc(dpm,
723  ARMV4_5_MCR(14, 0, 1, 0, 5, 0),
724  &value_r1);
725  if (retval != ERROR_OK)
726  return retval;
727  *hvalue = value_r1;
728  *hvalue = ((*hvalue) << 32) | value_r0;
729  break;
730  default:
731  retval = ERROR_FAIL;
732  break;
733  }
734 
735  return retval;
736 }
737 
738 static int armv8_write_reg32(struct armv8_common *armv8, int regnum, uint64_t value)
739 {
740  struct arm_dpm *dpm = &armv8->dpm;
741  int retval;
742 
743  switch (regnum) {
744  case ARMV8_R0 ... ARMV8_R14:
745  /* load register from DCC: "MRC p14, 0, Rnum, c0, c5, 0" */
746  retval = dpm->instr_write_data_dcc(dpm,
747  ARMV4_5_MRC(14, 0, regnum, 0, 5, 0), value);
748  break;
749  case ARMV8_SP:
750  retval = dpm->instr_write_data_dcc(dpm,
751  ARMV4_5_MRC(14, 0, 13, 0, 5, 0), value);
752  break;
753  case ARMV8_PC:/* PC
754  * read r0 from DCC; then "MOV pc, r0" */
755  retval = dpm->instr_write_data_r0(dpm,
756  ARMV8_MCR_DLR(0), value);
757  break;
758  case ARMV8_XPSR: /* CPSR */
759  /* read r0 from DCC, then "MCR r0, DSPSR" */
760  retval = dpm->instr_write_data_r0(dpm,
761  ARMV8_MCR_DSPSR(0), value);
762  break;
763  case ARMV8_ELR_EL1: /* mapped to LR_svc */
764  retval = dpm->instr_write_data_dcc(dpm,
765  ARMV4_5_MRC(14, 0, 14, 0, 5, 0),
766  value);
767  break;
768  case ARMV8_ELR_EL2: /* mapped to ELR_hyp */
769  retval = dpm->instr_write_data_r0(dpm,
770  ARMV8_MSR_GP_T1(0, 14, 0, 1),
771  value);
772  break;
773  case ARMV8_ELR_EL3: /* mapped to LR_mon */
774  retval = dpm->instr_write_data_dcc(dpm,
775  ARMV4_5_MRC(14, 0, 14, 0, 5, 0),
776  value);
777  break;
778  case ARMV8_ESR_EL1: /* mapped to DFSR */
779  retval = dpm->instr_write_data_r0(dpm,
780  ARMV4_5_MCR(15, 0, 0, 5, 0, 0),
781  value);
782  break;
783  case ARMV8_ESR_EL2: /* mapped to HSR */
784  retval = dpm->instr_write_data_r0(dpm,
785  ARMV4_5_MCR(15, 4, 0, 5, 2, 0),
786  value);
787  break;
788  case ARMV8_ESR_EL3: /* no equivalent in aarch32 */
789  retval = ERROR_FAIL;
790  break;
791  case ARMV8_SPSR_EL1: /* mapped to SPSR_svc */
792  retval = dpm->instr_write_data_r0(dpm,
793  ARMV8_MSR_GP_XPSR_T1(1, 0, 15),
794  value);
795  break;
796  case ARMV8_SPSR_EL2: /* mapped to SPSR_hyp */
797  retval = dpm->instr_write_data_r0(dpm,
798  ARMV8_MSR_GP_XPSR_T1(1, 0, 15),
799  value);
800  break;
801  case ARMV8_SPSR_EL3: /* mapped to SPSR_mon */
802  retval = dpm->instr_write_data_r0(dpm,
803  ARMV8_MSR_GP_XPSR_T1(1, 0, 15),
804  value);
805  break;
806  case ARMV8_FPSR:
807  /* move to r0 from DCC, then "VMSR FPSCR, r0" */
808  retval = dpm->instr_write_data_r0(dpm,
809  ARMV4_5_VMSR(0), value);
810  break;
811  default:
812  retval = ERROR_FAIL;
813  break;
814  }
815 
816  return retval;
817 
818 }
819 
820 static int armv8_write_reg_simdfp_aarch32(struct armv8_common *armv8, int regnum, uint64_t lvalue, uint64_t hvalue)
821 {
822  int retval = ERROR_FAIL;
823  struct arm_dpm *dpm = &armv8->dpm;
824  struct reg *reg_r1 = dpm->arm->core_cache->reg_list + ARMV8_R1;
825  uint32_t value_r0 = 0, value_r1 = 0;
826  unsigned int num = (regnum - ARMV8_V0) << 1;
827 
828  switch (regnum) {
829  case ARMV8_V0 ... ARMV8_V15:
830  /* we are going to write R1, mark it dirty */
831  reg_r1->dirty = true;
832  value_r1 = lvalue >> 32;
833  value_r0 = lvalue & 0xFFFFFFFF;
834  /* write value_r1 to r1 via dcc */
835  retval = dpm->instr_write_data_dcc(dpm,
836  ARMV4_5_MRC(14, 0, 1, 0, 5, 0),
837  value_r1);
838  if (retval != ERROR_OK)
839  return retval;
840  /* write value_r0 to r0 via dcc then,
841  * move to double word register from r0:r1: "vmov vm, r0, r1"
842  */
843  retval = dpm->instr_write_data_r0(dpm,
844  ARMV4_5_VMOV(0, 1, 0, (num >> 4), (num & 0xf)),
845  value_r0);
846  if (retval != ERROR_OK)
847  return retval;
848 
849  num++;
850  /* repeat above steps for high 64 bits of V register */
851  value_r1 = hvalue >> 32;
852  value_r0 = hvalue & 0xFFFFFFFF;
853  retval = dpm->instr_write_data_dcc(dpm,
854  ARMV4_5_MRC(14, 0, 1, 0, 5, 0),
855  value_r1);
856  if (retval != ERROR_OK)
857  return retval;
858  retval = dpm->instr_write_data_r0(dpm,
859  ARMV4_5_VMOV(0, 1, 0, (num >> 4), (num & 0xf)),
860  value_r0);
861  break;
862  default:
863  retval = ERROR_FAIL;
864  break;
865  }
866 
867  return retval;
868 }
869 
870 void armv8_select_reg_access(struct armv8_common *armv8, bool is_aarch64)
871 {
872  if (is_aarch64) {
873  armv8->read_reg_u64 = armv8_read_reg;
877 
878  } else {
883  }
884 }
885 
886 /* retrieve core id cluster id */
887 int armv8_read_mpidr(struct armv8_common *armv8)
888 {
889  int retval = ERROR_FAIL;
890  struct arm *arm = &armv8->arm;
891  struct arm_dpm *dpm = armv8->arm.dpm;
892  uint64_t mpidr;
893  uint8_t multi_processor_system;
894  uint8_t aff3;
895  uint8_t aff2;
896  uint8_t aff1;
897  uint8_t aff0;
898  uint8_t mt;
899 
900  retval = dpm->prepare(dpm);
901  if (retval != ERROR_OK)
902  goto done;
903 
904  /*
905  * TODO: BUG - routine armv8_dpm_modeswitch() doesn't re-evaluate 'arm->dpm->core_state'.
906  * If the core is halted in EL0 AArch32 while EL1 is in AArch64, the modeswitch moves the core
907  * to EL1, but there is no re-evaluation of dpm->arm->core_state. As a result, while the core
908  * is in AArch64, the code considers the system still in AArch32. The read of MPIDR would
909  * select the instruction based on the old core_state. The call to 'armv8_dpm_get_core_state()'
910  * below could also potentially return the incorrect execution state for the current EL.
911  */
912 
913  /* check if we're in an unprivileged mode */
915  retval = armv8_dpm_modeswitch(dpm, ARMV8_64_EL1H);
916  if (retval != ERROR_OK)
917  return retval;
918  }
919 
920  retval = dpm->instr_read_data_r0_64(dpm, armv8_opcode(armv8, READ_REG_MPIDR), &mpidr);
921  if (retval != ERROR_OK)
922  goto done;
923  if (mpidr & 1U<<31) {
924  multi_processor_system = (mpidr >> 30) & 1;
925  aff3 = (mpidr >> 32) & 0xff;
926  aff2 = (mpidr >> 16) & 0xff;
927  aff1 = (mpidr >> 8) & 0xff;
928  aff0 = mpidr & 0xff;
929  mt = (mpidr >> 24) & 0x1;
931  if (mt)
932  LOG_INFO("%s socket %" PRIu32 " cluster %" PRIu32 " core %" PRIu32 " thread %" PRIu32 " %s",
933  target_name(armv8->arm.target),
934  aff3, aff2, aff1, aff0,
935  multi_processor_system == 0 ? "multi core" : "single core");
936  else
937  LOG_INFO("%s socket %" PRIu32 " cluster %" PRIu32 " core %" PRIu32 " %s",
938  target_name(armv8->arm.target),
939  aff3, aff1, aff0,
940  multi_processor_system == 0 ? "multi core" : "single core");
941  } else {
942  if (mt)
943  LOG_INFO("%s cluster %" PRIu32 " core %" PRIu32 " thread %" PRIu32 " %s",
944  target_name(armv8->arm.target),
945  aff2, aff1, aff0,
946  multi_processor_system == 0 ? "multi core" : "single core");
947  else
948  LOG_INFO("%s cluster %" PRIu32 " core %" PRIu32 " %s",
949  target_name(armv8->arm.target),
950  aff1, aff0,
951  multi_processor_system == 0 ? "multi core" : "single core");
952  }
953  } else
954  LOG_ERROR("mpidr not in multiprocessor format");
955 
956 done:
958  dpm->finish(dpm);
959  return retval;
960 }
961 
967 void armv8_set_cpsr(struct arm *arm, uint32_t cpsr)
968 {
969  uint32_t mode = cpsr & 0x1F;
970 
971  /* NOTE: this may be called very early, before the register
972  * cache is set up. We can't defend against many errors, in
973  * particular against CPSRs that aren't valid *here* ...
974  */
975  if (arm->cpsr) {
976  buf_set_u32(arm->cpsr->value, 0, 32, cpsr);
977  arm->cpsr->valid = true;
978  arm->cpsr->dirty = false;
979  }
980 
981  /* Older ARMs won't have the J bit */
982  enum arm_state state = 0xFF;
983 
984  if ((cpsr & 0x10) != 0) {
985  /* Aarch32 state */
986  if (cpsr & (1 << 5)) { /* T */
987  if (cpsr & (1 << 24)) { /* J */
988  LOG_WARNING("ThumbEE -- incomplete support");
990  } else
992  } else {
993  if (cpsr & (1 << 24)) { /* J */
994  LOG_ERROR("Jazelle state handling is BROKEN!");
996  } else
998  }
999  } else {
1000  /* Aarch64 state */
1002  }
1003 
1004  arm->core_state = state;
1005  arm->core_mode = mode;
1006 
1007  LOG_DEBUG("set CPSR %#8.8" PRIx32 ": %s mode, %s state", cpsr,
1010 }
1011 
1012 static void armv8_show_fault_registers32(struct armv8_common *armv8)
1013 {
1014  uint32_t dfsr, ifsr, dfar, ifar;
1015  struct arm_dpm *dpm = armv8->arm.dpm;
1016  int retval;
1017 
1018  retval = dpm->prepare(dpm);
1019  if (retval != ERROR_OK)
1020  return;
1021 
1022  /* ARMV4_5_MRC(cpnum, op1, r0, crn, crm, op2) */
1023 
1024  /* c5/c0 - {data, instruction} fault status registers */
1025  retval = dpm->instr_read_data_r0(dpm,
1026  ARMV4_5_MRC(15, 0, 0, 5, 0, 0),
1027  &dfsr);
1028  if (retval != ERROR_OK)
1029  goto done;
1030 
1031  retval = dpm->instr_read_data_r0(dpm,
1032  ARMV4_5_MRC(15, 0, 0, 5, 0, 1),
1033  &ifsr);
1034  if (retval != ERROR_OK)
1035  goto done;
1036 
1037  /* c6/c0 - {data, instruction} fault address registers */
1038  retval = dpm->instr_read_data_r0(dpm,
1039  ARMV4_5_MRC(15, 0, 0, 6, 0, 0),
1040  &dfar);
1041  if (retval != ERROR_OK)
1042  goto done;
1043 
1044  retval = dpm->instr_read_data_r0(dpm,
1045  ARMV4_5_MRC(15, 0, 0, 6, 0, 2),
1046  &ifar);
1047  if (retval != ERROR_OK)
1048  goto done;
1049 
1050  LOG_USER("Data fault registers DFSR: %8.8" PRIx32
1051  ", DFAR: %8.8" PRIx32, dfsr, dfar);
1052  LOG_USER("Instruction fault registers IFSR: %8.8" PRIx32
1053  ", IFAR: %8.8" PRIx32, ifsr, ifar);
1054 
1055 done:
1056  dpm->finish(dpm);
1057 }
1058 
1059 static __attribute__((unused)) void armv8_show_fault_registers(struct target *target)
1060 {
1061  struct armv8_common *armv8 = target_to_armv8(target);
1062 
1063  if (armv8->arm.core_state != ARM_STATE_AARCH64)
1065 }
1066 
1067 static void armv8_decode_cacheability(int attr)
1068 {
1069  if (attr == 0) {
1070  LOG_USER_N("UNPREDICTABLE");
1071  return;
1072  }
1073  if (attr == 4) {
1074  LOG_USER_N("Non-cacheable");
1075  return;
1076  }
1077  switch (attr & 0xC) {
1078  case 0:
1079  LOG_USER_N("Write-Through Transient");
1080  break;
1081  case 0x4:
1082  LOG_USER_N("Write-Back Transient");
1083  break;
1084  case 0x8:
1085  LOG_USER_N("Write-Through Non-transient");
1086  break;
1087  case 0xC:
1088  LOG_USER_N("Write-Back Non-transient");
1089  break;
1090  }
1091  if (attr & 2)
1092  LOG_USER_N(" Read-Allocate");
1093  else
1094  LOG_USER_N(" No-Read Allocate");
1095  if (attr & 1)
1096  LOG_USER_N(" Write-Allocate");
1097  else
1098  LOG_USER_N(" No-Write Allocate");
1099 }
1100 
1101 static void armv8_decode_memory_attr(int attr)
1102 {
1103  if (attr == 0x40) {
1104  LOG_USER("Normal Memory, Inner Non-cacheable, "
1105  "Outer Non-cacheable, XS=0");
1106  } else if (attr == 0xA0) {
1107  LOG_USER("Normal Memory, Inner Write-through Cacheable, "
1108  "Outer Write-through Cacheable, Read-Allocate, "
1109  "No-Write Allocate, Non-transient, XS=0");
1110  } else if (attr == 0xF0) {
1111  LOG_USER("Tagged Normal Memory, Inner Write-Back, "
1112  "Outer Write-Back, Read-Allocate, Write-Allocate, "
1113  "Non-transient");
1114  } else if ((attr & 0xF0) == 0) {
1115  switch (attr & 0xC) {
1116  case 0:
1117  LOG_USER_N("Device-nGnRnE Memory");
1118  break;
1119  case 0x4:
1120  LOG_USER_N("Device-nGnRE Memory");
1121  break;
1122  case 0x8:
1123  LOG_USER_N("Device-nGRE Memory");
1124  break;
1125  case 0xC:
1126  LOG_USER_N("Device-GRE Memory");
1127  break;
1128  }
1129  if (attr & 1)
1130  LOG_USER(", XS=0");
1131  else
1132  LOG_USER_N("\n");
1133  } else {
1134  LOG_USER_N("Normal Memory, Inner ");
1135  armv8_decode_cacheability(attr & 0xF);
1136  LOG_USER_N(", Outer ");
1137  armv8_decode_cacheability(attr >> 4);
1138  LOG_USER_N("\n");
1139  }
1140 }
1141 
1142 /* V8 method VA TO PA */
1144  target_addr_t *val, int meminfo)
1145 {
1146  struct armv8_common *armv8 = target_to_armv8(target);
1147  struct arm *arm = target_to_arm(target);
1148  struct arm_dpm *dpm = &armv8->dpm;
1149  enum arm_mode target_mode = ARM_MODE_ANY;
1150  uint32_t retval;
1151  uint32_t instr = 0;
1152  uint64_t par;
1153 
1154  static const char * const shared_name[] = {
1155  "Non-", "UNDEFINED ", "Outer ", "Inner "
1156  };
1157 
1158  static const char * const secure_name[] = {
1159  "Secure", "Not Secure"
1160  };
1161 
1162  if (target->state != TARGET_HALTED) {
1163  LOG_TARGET_ERROR(target, "not halted");
1164  return ERROR_TARGET_NOT_HALTED;
1165  }
1166 
1167  retval = dpm->prepare(dpm);
1168  if (retval != ERROR_OK)
1169  return retval;
1170 
1172  case SYSTEM_CUREL_EL0:
1173  instr = ARMV8_SYS(SYSTEM_ATS12E0R, 0);
1174  /* can only execute instruction at EL2 */
1175  target_mode = ARMV8_64_EL2H;
1176  break;
1177  case SYSTEM_CUREL_EL1:
1178  instr = ARMV8_SYS(SYSTEM_ATS12E1R, 0);
1179  /* can only execute instruction at EL2 */
1180  target_mode = ARMV8_64_EL2H;
1181  break;
1182  case SYSTEM_CUREL_EL2:
1183  instr = ARMV8_SYS(SYSTEM_ATS1E2R, 0);
1184  break;
1185  case SYSTEM_CUREL_EL3:
1186  instr = ARMV8_SYS(SYSTEM_ATS1E3R, 0);
1187  break;
1188 
1189  default:
1190  break;
1191  };
1192 
1193  if (target_mode != ARM_MODE_ANY)
1194  armv8_dpm_modeswitch(dpm, target_mode);
1195 
1196  /* write VA to R0 and execute translation instruction */
1197  retval = dpm->instr_write_data_r0_64(dpm, instr, (uint64_t)va);
1198  /* read result from PAR_EL1 */
1199  if (retval == ERROR_OK)
1200  retval = dpm->instr_read_data_r0_64(dpm, ARMV8_MRS(SYSTEM_PAR_EL1, 0), &par);
1201 
1202  /* switch back to saved PE mode */
1203  if (target_mode != ARM_MODE_ANY)
1205 
1206  dpm->finish(dpm);
1207 
1208  if (retval != ERROR_OK)
1209  return retval;
1210 
1211  if (par & 1) {
1212  LOG_ERROR("Address translation failed at stage %i, FST=%x, PTW=%i",
1213  ((int)(par >> 9) & 1)+1, (int)(par >> 1) & 0x3f, (int)(par >> 8) & 1);
1214 
1215  *val = 0;
1216  retval = ERROR_FAIL;
1217  } else {
1218  *val = (par & 0xFFFFFFFFF000UL) | (va & 0xFFF);
1219  if (meminfo) {
1220  int SH = (par >> 7) & 3;
1221  int NS = (par >> 9) & 1;
1222  int ATTR = (par >> 56) & 0xFF;
1223 
1224  LOG_USER("%sshareable, %s",
1225  shared_name[SH], secure_name[NS]);
1227  }
1228  }
1229 
1230  return retval;
1231 }
1232 
1233 COMMAND_HANDLER(armv8_handle_exception_catch_command)
1234 {
1236  struct armv8_common *armv8 = target_to_armv8(target);
1237  uint32_t edeccr = 0;
1238  unsigned int argp = 0;
1239  int retval;
1240 
1241  static const struct nvp nvp_ecatch_modes[] = {
1242  { .name = "off", .value = 0 },
1243  { .name = "nsec_el1", .value = (1 << 5) },
1244  { .name = "nsec_el2", .value = (2 << 5) },
1245  { .name = "nsec_el12", .value = (3 << 5) },
1246  { .name = "sec_el1", .value = (1 << 1) },
1247  { .name = "sec_el3", .value = (4 << 1) },
1248  { .name = "sec_el13", .value = (5 << 1) },
1249  { .name = NULL, .value = -1 },
1250  };
1251  const struct nvp *n;
1252 
1253  if (CMD_ARGC == 0) {
1254  const char *sec = NULL, *nsec = NULL;
1255 
1256  retval = mem_ap_read_atomic_u32(armv8->debug_ap,
1257  armv8->debug_base + CPUV8_DBG_ECCR, &edeccr);
1258  if (retval != ERROR_OK)
1259  return retval;
1260 
1261  n = nvp_value2name(nvp_ecatch_modes, edeccr & 0x0f);
1262  if (n->name)
1263  sec = n->name;
1264 
1265  n = nvp_value2name(nvp_ecatch_modes, edeccr & 0xf0);
1266  if (n->name)
1267  nsec = n->name;
1268 
1269  if (!sec || !nsec) {
1270  LOG_WARNING("Exception Catch: unknown exception catch configuration: EDECCR = %02" PRIx32, edeccr & 0xff);
1271  return ERROR_FAIL;
1272  }
1273 
1274  command_print(CMD, "Exception Catch: Secure: %s, Non-Secure: %s", sec, nsec);
1275  return ERROR_OK;
1276  }
1277 
1278  while (argp < CMD_ARGC) {
1279  n = nvp_name2value(nvp_ecatch_modes, CMD_ARGV[argp]);
1280  if (!n->name) {
1281  LOG_ERROR("Unknown option: %s", CMD_ARGV[argp]);
1282  return ERROR_FAIL;
1283  }
1284 
1285  LOG_DEBUG("found: %s", n->name);
1286 
1287  edeccr |= n->value;
1288  argp++;
1289  }
1290 
1291  retval = mem_ap_write_atomic_u32(armv8->debug_ap,
1292  armv8->debug_base + CPUV8_DBG_ECCR, edeccr);
1293  if (retval != ERROR_OK)
1294  return retval;
1295 
1296  return ERROR_OK;
1297 }
1298 
1299 COMMAND_HANDLER(armv8_pauth_command)
1300 {
1302  struct armv8_common *armv8 = target_to_armv8(target);
1303  return CALL_COMMAND_HANDLER(handle_command_parse_bool,
1304  &armv8->enable_pauth,
1305  "pauth feature");
1306 }
1307 
1309  struct armv8_cache_common *armv8_cache)
1310 {
1311  if (!armv8_cache->info_valid) {
1312  command_print(cmd, "cache not yet identified");
1313  return ERROR_OK;
1314  }
1315 
1316  if (armv8_cache->display_cache_info)
1317  armv8_cache->display_cache_info(cmd, armv8_cache);
1318  return ERROR_OK;
1319 }
1320 
1321 static int armv8_setup_semihosting(struct target *target, int enable)
1322 {
1323  return ERROR_OK;
1324 }
1325 
1326 int armv8_init_arch_info(struct target *target, struct armv8_common *armv8)
1327 {
1328  struct arm *arm = &armv8->arm;
1329  arm->arch_info = armv8;
1330  target->arch_info = &armv8->arm;
1332  /* target is useful in all function arm v4 5 compatible */
1333  armv8->arm.target = target;
1336 
1338  armv8->armv8_mmu.armv8_cache.info_valid = false;
1341  return ERROR_OK;
1342 }
1343 
1344 static int armv8_aarch64_state(struct target *target)
1345 {
1346  struct arm *arm = target_to_arm(target);
1347 
1348  if (arm->common_magic != ARM_COMMON_MAGIC) {
1349  LOG_ERROR("BUG: called for a non-ARM target");
1350  return ERROR_FAIL;
1351  }
1352 
1353  LOG_USER("%s halted in %s state due to %s, current mode: %s\n"
1354  "cpsr: 0x%8.8" PRIx32 " pc: 0x%" PRIx64 "%s",
1359  buf_get_u32(arm->cpsr->value, 0, 32),
1360  buf_get_u64(arm->pc->value, 0, 64),
1361  (target->semihosting && target->semihosting->is_active) ? ", semihosting" : "");
1362 
1363  return ERROR_OK;
1364 }
1365 
1367 {
1368  struct armv8_common *armv8 = target_to_armv8(target);
1369  struct arm *arm = &armv8->arm;
1370 
1371  if (armv8->common_magic != ARMV8_COMMON_MAGIC) {
1372  LOG_ERROR("BUG: called for a non-Armv8 target");
1374  }
1375 
1378  else
1380 
1381  LOG_USER("MMU: %s, D-Cache: %s, I-Cache: %s",
1385 
1386  if (arm->core_mode == ARM_MODE_ABT)
1387  armv8_show_fault_registers(target);
1388 
1390  LOG_USER("Watchpoint triggered at " TARGET_ADDR_FMT, armv8->dpm.wp_addr);
1391 
1392  return ERROR_OK;
1393 }
1394 
1395 static struct reg_data_type aarch64_vector_base_types[] = {
1396  {REG_TYPE_IEEE_DOUBLE, "ieee_double", 0, {NULL} },
1397  {REG_TYPE_UINT64, "uint64", 0, {NULL} },
1398  {REG_TYPE_INT64, "int64", 0, {NULL} },
1399  {REG_TYPE_IEEE_SINGLE, "ieee_single", 0, {NULL} },
1400  {REG_TYPE_UINT32, "uint32", 0, {NULL} },
1401  {REG_TYPE_INT32, "int32", 0, {NULL} },
1402  {REG_TYPE_UINT16, "uint16", 0, {NULL} },
1403  {REG_TYPE_INT16, "int16", 0, {NULL} },
1404  {REG_TYPE_UINT8, "uint8", 0, {NULL} },
1405  {REG_TYPE_INT8, "int8", 0, {NULL} },
1406  {REG_TYPE_UINT128, "uint128", 0, {NULL} },
1407  {REG_TYPE_INT128, "int128", 0, {NULL} }
1408 };
1409 
1410 static struct reg_data_type_vector aarch64_vector_types[] = {
1411  {aarch64_vector_base_types + 0, 2},
1412  {aarch64_vector_base_types + 1, 2},
1413  {aarch64_vector_base_types + 2, 2},
1414  {aarch64_vector_base_types + 3, 4},
1415  {aarch64_vector_base_types + 4, 4},
1416  {aarch64_vector_base_types + 5, 4},
1417  {aarch64_vector_base_types + 6, 8},
1418  {aarch64_vector_base_types + 7, 8},
1419  {aarch64_vector_base_types + 8, 16},
1420  {aarch64_vector_base_types + 9, 16},
1421  {aarch64_vector_base_types + 10, 01},
1422  {aarch64_vector_base_types + 11, 01},
1423 };
1424 
1425 static struct reg_data_type aarch64_fpu_vector[] = {
1438 };
1439 
1443  {"s", aarch64_fpu_vector + 2, NULL},
1444 };
1445 
1449  {"s", aarch64_fpu_vector + 5, NULL},
1450 };
1451 
1454  {"s", aarch64_fpu_vector + 7, NULL},
1455 };
1456 
1459  {"s", aarch64_fpu_vector + 9, NULL},
1460 };
1461 
1464  {"s", aarch64_fpu_vector + 11, NULL},
1465 };
1466 
1467 static struct reg_data_type_union aarch64_union_types[] = {
1473 };
1474 
1475 static struct reg_data_type aarch64_fpu_union[] = {
1476  {REG_TYPE_ARCH_DEFINED, "vnd", REG_TYPE_CLASS_UNION, {.reg_type_union = aarch64_union_types + 0} },
1477  {REG_TYPE_ARCH_DEFINED, "vns", REG_TYPE_CLASS_UNION, {.reg_type_union = aarch64_union_types + 1} },
1478  {REG_TYPE_ARCH_DEFINED, "vnh", REG_TYPE_CLASS_UNION, {.reg_type_union = aarch64_union_types + 2} },
1479  {REG_TYPE_ARCH_DEFINED, "vnb", REG_TYPE_CLASS_UNION, {.reg_type_union = aarch64_union_types + 3} },
1480  {REG_TYPE_ARCH_DEFINED, "vnq", REG_TYPE_CLASS_UNION, {.reg_type_union = aarch64_union_types + 4} },
1481 };
1482 
1484  {"d", aarch64_fpu_union + 0, aarch64v_union_fields + 1},
1485  {"s", aarch64_fpu_union + 1, aarch64v_union_fields + 2},
1486  {"h", aarch64_fpu_union + 2, aarch64v_union_fields + 3},
1487  {"b", aarch64_fpu_union + 3, aarch64v_union_fields + 4},
1488  {"q", aarch64_fpu_union + 4, NULL},
1489 };
1490 
1491 static struct reg_data_type_union aarch64v_union[] = {
1493 };
1494 
1495 static struct reg_data_type aarch64v[] = {
1497  {.reg_type_union = aarch64v_union} },
1498 };
1499 
1500 static struct reg_data_type_bitfield aarch64_cpsr_bits[] = {
1501  { 0, 0, REG_TYPE_UINT8 },
1502  { 2, 3, REG_TYPE_UINT8 },
1503  { 4, 4, REG_TYPE_UINT8 },
1504  { 6, 6, REG_TYPE_BOOL },
1505  { 7, 7, REG_TYPE_BOOL },
1506  { 8, 8, REG_TYPE_BOOL },
1507  { 9, 9, REG_TYPE_BOOL },
1508  { 20, 20, REG_TYPE_BOOL },
1509  { 21, 21, REG_TYPE_BOOL },
1510  { 28, 28, REG_TYPE_BOOL },
1511  { 29, 29, REG_TYPE_BOOL },
1512  { 30, 30, REG_TYPE_BOOL },
1513  { 31, 31, REG_TYPE_BOOL },
1514 };
1515 
1517  { "SP", aarch64_cpsr_bits + 0, aarch64_cpsr_fields + 1 },
1518  { "EL", aarch64_cpsr_bits + 1, aarch64_cpsr_fields + 2 },
1519  { "nRW", aarch64_cpsr_bits + 2, aarch64_cpsr_fields + 3 },
1520  { "F", aarch64_cpsr_bits + 3, aarch64_cpsr_fields + 4 },
1521  { "I", aarch64_cpsr_bits + 4, aarch64_cpsr_fields + 5 },
1522  { "A", aarch64_cpsr_bits + 5, aarch64_cpsr_fields + 6 },
1523  { "D", aarch64_cpsr_bits + 6, aarch64_cpsr_fields + 7 },
1524  { "IL", aarch64_cpsr_bits + 7, aarch64_cpsr_fields + 8 },
1525  { "SS", aarch64_cpsr_bits + 8, aarch64_cpsr_fields + 9 },
1526  { "V", aarch64_cpsr_bits + 9, aarch64_cpsr_fields + 10 },
1527  { "C", aarch64_cpsr_bits + 10, aarch64_cpsr_fields + 11 },
1528  { "Z", aarch64_cpsr_bits + 11, aarch64_cpsr_fields + 12 },
1529  { "N", aarch64_cpsr_bits + 12, NULL }
1530 };
1531 
1532 static struct reg_data_type_flags aarch64_cpsr_flags[] = {
1533  { 4, aarch64_cpsr_fields }
1534 };
1535 
1536 static struct reg_data_type aarch64_flags_cpsr[] = {
1538  {.reg_type_flags = aarch64_cpsr_flags} },
1539 };
1540 
1541 static const struct {
1542  unsigned int id;
1543  const char *name;
1544  unsigned int bits;
1545  enum arm_mode mode;
1546  enum reg_type type;
1547  const char *group;
1548  const char *feature;
1550 } armv8_regs[] = {
1551  { ARMV8_R0, "x0", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1552  { ARMV8_R1, "x1", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1553  { ARMV8_R2, "x2", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1554  { ARMV8_R3, "x3", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1555  { ARMV8_R4, "x4", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1556  { ARMV8_R5, "x5", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1557  { ARMV8_R6, "x6", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1558  { ARMV8_R7, "x7", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1559  { ARMV8_R8, "x8", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1560  { ARMV8_R9, "x9", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1561  { ARMV8_R10, "x10", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1562  { ARMV8_R11, "x11", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1563  { ARMV8_R12, "x12", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1564  { ARMV8_R13, "x13", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1565  { ARMV8_R14, "x14", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1566  { ARMV8_R15, "x15", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1567  { ARMV8_R16, "x16", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1568  { ARMV8_R17, "x17", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1569  { ARMV8_R18, "x18", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1570  { ARMV8_R19, "x19", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1571  { ARMV8_R20, "x20", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1572  { ARMV8_R21, "x21", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1573  { ARMV8_R22, "x22", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1574  { ARMV8_R23, "x23", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1575  { ARMV8_R24, "x24", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1576  { ARMV8_R25, "x25", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1577  { ARMV8_R26, "x26", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1578  { ARMV8_R27, "x27", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1579  { ARMV8_R28, "x28", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1580  { ARMV8_R29, "x29", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1581  { ARMV8_R30, "x30", 64, ARM_MODE_ANY, REG_TYPE_UINT64, "general", "org.gnu.gdb.aarch64.core", NULL},
1582 
1583  { ARMV8_SP, "sp", 64, ARM_MODE_ANY, REG_TYPE_DATA_PTR, "general", "org.gnu.gdb.aarch64.core", NULL},
1584  { ARMV8_PC, "pc", 64, ARM_MODE_ANY, REG_TYPE_CODE_PTR, "general", "org.gnu.gdb.aarch64.core", NULL},
1586  "general", "org.gnu.gdb.aarch64.core", aarch64_flags_cpsr},
1587  { ARMV8_V0, "v0", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1588  { ARMV8_V1, "v1", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1589  { ARMV8_V2, "v2", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1590  { ARMV8_V3, "v3", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1591  { ARMV8_V4, "v4", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1592  { ARMV8_V5, "v5", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1593  { ARMV8_V6, "v6", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1594  { ARMV8_V7, "v7", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1595  { ARMV8_V8, "v8", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1596  { ARMV8_V9, "v9", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1597  { ARMV8_V10, "v10", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1598  { ARMV8_V11, "v11", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1599  { ARMV8_V12, "v12", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1600  { ARMV8_V13, "v13", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1601  { ARMV8_V14, "v14", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1602  { ARMV8_V15, "v15", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1603  { ARMV8_V16, "v16", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1604  { ARMV8_V17, "v17", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1605  { ARMV8_V18, "v18", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1606  { ARMV8_V19, "v19", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1607  { ARMV8_V20, "v20", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1608  { ARMV8_V21, "v21", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1609  { ARMV8_V22, "v22", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1610  { ARMV8_V23, "v23", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1611  { ARMV8_V24, "v24", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1612  { ARMV8_V25, "v25", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1613  { ARMV8_V26, "v26", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1614  { ARMV8_V27, "v27", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1615  { ARMV8_V28, "v28", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1616  { ARMV8_V29, "v29", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1617  { ARMV8_V30, "v30", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1618  { ARMV8_V31, "v31", 128, ARM_MODE_ANY, REG_TYPE_ARCH_DEFINED, "simdfp", "org.gnu.gdb.aarch64.fpu", aarch64v},
1619  { ARMV8_FPSR, "fpsr", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "simdfp", "org.gnu.gdb.aarch64.fpu", NULL},
1620  { ARMV8_FPCR, "fpcr", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "simdfp", "org.gnu.gdb.aarch64.fpu", NULL},
1621 
1622  { ARMV8_ELR_EL1, "ELR_EL1", 64, ARMV8_64_EL1H, REG_TYPE_CODE_PTR, "banked", "net.sourceforge.openocd.banked",
1623  NULL},
1624  { ARMV8_ESR_EL1, "ESR_EL1", 64, ARMV8_64_EL1H, REG_TYPE_UINT64, "banked", "net.sourceforge.openocd.banked",
1625  NULL},
1626  { ARMV8_SPSR_EL1, "SPSR_EL1", 64, ARMV8_64_EL1H, REG_TYPE_UINT64, "banked", "net.sourceforge.openocd.banked",
1627  NULL},
1628 
1629  { ARMV8_ELR_EL2, "ELR_EL2", 64, ARMV8_64_EL2H, REG_TYPE_CODE_PTR, "banked", "net.sourceforge.openocd.banked",
1630  NULL},
1631  { ARMV8_ESR_EL2, "ESR_EL2", 64, ARMV8_64_EL2H, REG_TYPE_UINT64, "banked", "net.sourceforge.openocd.banked",
1632  NULL},
1633  { ARMV8_SPSR_EL2, "SPSR_EL2", 64, ARMV8_64_EL2H, REG_TYPE_UINT64, "banked", "net.sourceforge.openocd.banked",
1634  NULL},
1635 
1636  { ARMV8_ELR_EL3, "ELR_EL3", 64, ARMV8_64_EL3H, REG_TYPE_CODE_PTR, "banked", "net.sourceforge.openocd.banked",
1637  NULL},
1638  { ARMV8_ESR_EL3, "ESR_EL3", 64, ARMV8_64_EL3H, REG_TYPE_UINT64, "banked", "net.sourceforge.openocd.banked",
1639  NULL},
1640  { ARMV8_SPSR_EL3, "SPSR_EL3", 64, ARMV8_64_EL3H, REG_TYPE_UINT64, "banked", "net.sourceforge.openocd.banked",
1641  NULL},
1642  { ARMV8_PAUTH_DMASK, "pauth_dmask", 64, ARM_MODE_ANY, REG_TYPE_UINT64, NULL, "org.gnu.gdb.aarch64.pauth", NULL},
1643  { ARMV8_PAUTH_CMASK, "pauth_cmask", 64, ARM_MODE_ANY, REG_TYPE_UINT64, NULL, "org.gnu.gdb.aarch64.pauth", NULL},
1644 };
1645 
1646 static const struct {
1647  unsigned int id;
1648  unsigned int mapping;
1649  const char *name;
1650  unsigned int bits;
1651  enum arm_mode mode;
1652  enum reg_type type;
1653  const char *group;
1654  const char *feature;
1655 } armv8_regs32[] = {
1656  { ARMV8_R0, 0, "r0", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "general", "org.gnu.gdb.arm.core" },
1657  { ARMV8_R1, 0, "r1", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "general", "org.gnu.gdb.arm.core" },
1658  { ARMV8_R2, 0, "r2", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "general", "org.gnu.gdb.arm.core" },
1659  { ARMV8_R3, 0, "r3", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "general", "org.gnu.gdb.arm.core" },
1660  { ARMV8_R4, 0, "r4", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "general", "org.gnu.gdb.arm.core" },
1661  { ARMV8_R5, 0, "r5", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "general", "org.gnu.gdb.arm.core" },
1662  { ARMV8_R6, 0, "r6", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "general", "org.gnu.gdb.arm.core" },
1663  { ARMV8_R7, 0, "r7", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "general", "org.gnu.gdb.arm.core" },
1664  { ARMV8_R8, 0, "r8", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "general", "org.gnu.gdb.arm.core" },
1665  { ARMV8_R9, 0, "r9", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "general", "org.gnu.gdb.arm.core" },
1666  { ARMV8_R10, 0, "r10", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "general", "org.gnu.gdb.arm.core" },
1667  { ARMV8_R11, 0, "r11", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "general", "org.gnu.gdb.arm.core" },
1668  { ARMV8_R12, 0, "r12", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "general", "org.gnu.gdb.arm.core" },
1669  { ARMV8_R13, 0, "sp", 32, ARM_MODE_ANY, REG_TYPE_DATA_PTR, "general", "org.gnu.gdb.arm.core" },
1670  { ARMV8_R14, 0, "lr", 32, ARM_MODE_ANY, REG_TYPE_CODE_PTR, "general", "org.gnu.gdb.arm.core" },
1671  { ARMV8_PC, 0, "pc", 32, ARM_MODE_ANY, REG_TYPE_CODE_PTR, "general", "org.gnu.gdb.arm.core" },
1672  { ARMV8_XPSR, 0, "cpsr", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "general", "org.gnu.gdb.arm.core" },
1673  { ARMV8_V0, 0, "d0", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1674  { ARMV8_V0, 8, "d1", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1675  { ARMV8_V1, 0, "d2", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1676  { ARMV8_V1, 8, "d3", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1677  { ARMV8_V2, 0, "d4", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1678  { ARMV8_V2, 8, "d5", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1679  { ARMV8_V3, 0, "d6", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1680  { ARMV8_V3, 8, "d7", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1681  { ARMV8_V4, 0, "d8", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1682  { ARMV8_V4, 8, "d9", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1683  { ARMV8_V5, 0, "d10", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1684  { ARMV8_V5, 8, "d11", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1685  { ARMV8_V6, 0, "d12", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1686  { ARMV8_V6, 8, "d13", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1687  { ARMV8_V7, 0, "d14", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1688  { ARMV8_V7, 8, "d15", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1689  { ARMV8_V8, 0, "d16", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1690  { ARMV8_V8, 8, "d17", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1691  { ARMV8_V9, 0, "d18", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1692  { ARMV8_V9, 8, "d19", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1693  { ARMV8_V10, 0, "d20", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1694  { ARMV8_V10, 8, "d21", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1695  { ARMV8_V11, 0, "d22", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1696  { ARMV8_V11, 8, "d23", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1697  { ARMV8_V12, 0, "d24", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1698  { ARMV8_V12, 8, "d25", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1699  { ARMV8_V13, 0, "d26", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1700  { ARMV8_V13, 8, "d27", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1701  { ARMV8_V14, 0, "d28", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1702  { ARMV8_V14, 8, "d29", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1703  { ARMV8_V15, 0, "d30", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1704  { ARMV8_V15, 8, "d31", 64, ARM_MODE_ANY, REG_TYPE_IEEE_DOUBLE, NULL, "org.gnu.gdb.arm.vfp"},
1705  { ARMV8_FPSR, 0, "fpscr", 32, ARM_MODE_ANY, REG_TYPE_UINT32, "float", "org.gnu.gdb.arm.vfp"},
1706 };
1707 
1708 #define ARMV8_NUM_REGS ARRAY_SIZE(armv8_regs)
1709 #define ARMV8_NUM_REGS32 ARRAY_SIZE(armv8_regs32)
1710 
1711 static int armv8_get_core_reg(struct reg *reg)
1712 {
1713  struct arm_reg *armv8_reg = reg->arch_info;
1714  struct target *target = armv8_reg->target;
1715  struct arm *arm = target_to_arm(target);
1716 
1717  if (target->state != TARGET_HALTED)
1718  return ERROR_TARGET_NOT_HALTED;
1719 
1720  return arm->read_core_reg(target, reg, armv8_reg->num, arm->core_mode);
1721 }
1722 
1723 static int armv8_set_core_reg(struct reg *reg, uint8_t *buf)
1724 {
1725  struct arm_reg *armv8_reg = reg->arch_info;
1726  struct target *target = armv8_reg->target;
1727  struct arm *arm = target_to_arm(target);
1728 
1729  if (target->state != TARGET_HALTED)
1730  return ERROR_TARGET_NOT_HALTED;
1731 
1732  if (reg->size <= 64) {
1733  uint64_t value = buf_get_u64(buf, 0, reg->size);
1734  if (reg == arm->cpsr)
1735  armv8_set_cpsr(arm, (uint32_t)value);
1736  else {
1737  buf_set_u64(reg->value, 0, reg->size, value);
1738  reg->valid = true;
1739  }
1740  } else if (reg->size <= 128) {
1741  uint64_t value = buf_get_u64(buf, 0, 64);
1742  uint64_t hvalue = buf_get_u64(buf + 8, 0, reg->size - 64);
1743 
1744  buf_set_u64(reg->value, 0, 64, value);
1745  buf_set_u64(reg->value + 8, 0, reg->size - 64, hvalue);
1746  reg->valid = true;
1747  }
1748 
1749  reg->dirty = true;
1750 
1751  return ERROR_OK;
1752 }
1753 
1754 static const struct reg_arch_type armv8_reg_type = {
1756  .set = armv8_set_core_reg,
1757 };
1758 
1759 static int armv8_get_core_reg32(struct reg *reg)
1760 {
1761  struct arm_reg *armv8_reg = reg->arch_info;
1762  struct target *target = armv8_reg->target;
1763  struct arm *arm = target_to_arm(target);
1764  struct reg_cache *cache = arm->core_cache;
1765  struct reg *reg64;
1766  int retval;
1767 
1768  if (target->state != TARGET_HALTED)
1769  return ERROR_TARGET_NOT_HALTED;
1770 
1771  /* get the corresponding Aarch64 register */
1772  reg64 = cache->reg_list + armv8_reg->num;
1773  if (reg64->valid) {
1774  reg->valid = true;
1775  return ERROR_OK;
1776  }
1777 
1778  retval = arm->read_core_reg(target, reg64, armv8_reg->num, arm->core_mode);
1779  if (retval == ERROR_OK)
1780  reg->valid = reg64->valid;
1781 
1782  return retval;
1783 }
1784 
1785 static int armv8_set_core_reg32(struct reg *reg, uint8_t *buf)
1786 {
1787  struct arm_reg *armv8_reg = reg->arch_info;
1788  struct target *target = armv8_reg->target;
1789  struct arm *arm = target_to_arm(target);
1790  struct reg_cache *cache = arm->core_cache;
1791  struct reg *reg64 = cache->reg_list + armv8_reg->num;
1792  uint32_t value = buf_get_u32(buf, 0, 32);
1793 
1794  if (target->state != TARGET_HALTED)
1795  return ERROR_TARGET_NOT_HALTED;
1796 
1797  if (reg64 == arm->cpsr) {
1799  } else {
1800  if (reg->size <= 32)
1801  buf_set_u32(reg->value, 0, 32, value);
1802  else if (reg->size <= 64) {
1803  uint64_t value64 = buf_get_u64(buf, 0, 64);
1804  buf_set_u64(reg->value, 0, 64, value64);
1805  }
1806  reg->valid = true;
1807  reg64->valid = true;
1808  }
1809 
1810  reg64->dirty = true;
1811 
1812  return ERROR_OK;
1813 }
1814 
1815 static const struct reg_arch_type armv8_reg32_type = {
1817  .set = armv8_set_core_reg32,
1818 };
1819 
1822 {
1823  struct armv8_common *armv8 = target_to_armv8(target);
1824  struct arm *arm = &armv8->arm;
1825  int num_regs = ARMV8_NUM_REGS;
1826  int num_regs32 = ARMV8_NUM_REGS32;
1827  struct reg_cache **cache_p = register_get_last_cache_p(&target->reg_cache);
1828  struct reg_cache *cache = malloc(sizeof(struct reg_cache));
1829  struct reg_cache *cache32 = malloc(sizeof(struct reg_cache));
1830  struct reg *reg_list = calloc(num_regs, sizeof(struct reg));
1831  struct reg *reg_list32 = calloc(num_regs32, sizeof(struct reg));
1832  struct arm_reg *arch_info = calloc(num_regs, sizeof(struct arm_reg));
1833  struct reg_feature *feature;
1834  int i;
1835 
1836  /* Build the process context cache */
1837  cache->name = "Aarch64 registers";
1838  cache->next = cache32;
1839  cache->reg_list = reg_list;
1840  cache->num_regs = num_regs;
1841 
1842  for (i = 0; i < num_regs; i++) {
1843  arch_info[i].num = armv8_regs[i].id;
1844  arch_info[i].mode = armv8_regs[i].mode;
1845  arch_info[i].target = target;
1846  arch_info[i].arm = arm;
1847 
1848  reg_list[i].name = armv8_regs[i].name;
1849  reg_list[i].size = armv8_regs[i].bits;
1850  reg_list[i].value = &arch_info[i].value[0];
1851  reg_list[i].type = &armv8_reg_type;
1852  reg_list[i].arch_info = &arch_info[i];
1853 
1854  reg_list[i].group = armv8_regs[i].group;
1855  reg_list[i].number = i;
1856  reg_list[i].exist = true;
1857 
1858  /* Registers which should be preserved across GDB inferior function calls.
1859  * Avoid saving ELx banked registers as a standard function should
1860  * not change them and higher EL registers are not accessible
1861  * in lower EL modes. */
1862  reg_list[i].caller_save = i < ARMV8_ELR_EL1;
1863 
1864  feature = calloc(1, sizeof(struct reg_feature));
1865  if (feature) {
1866  feature->name = armv8_regs[i].feature;
1867  reg_list[i].feature = feature;
1868  } else
1869  LOG_ERROR("unable to allocate feature list");
1870 
1871  reg_list[i].reg_data_type = calloc(1, sizeof(struct reg_data_type));
1872  if (reg_list[i].reg_data_type) {
1873  if (!armv8_regs[i].data_type)
1874  reg_list[i].reg_data_type->type = armv8_regs[i].type;
1875  else
1876  *reg_list[i].reg_data_type = *armv8_regs[i].data_type;
1877  } else
1878  LOG_ERROR("unable to allocate reg type list");
1879 
1880  if (i == ARMV8_PAUTH_CMASK || i == ARMV8_PAUTH_DMASK)
1881  reg_list[i].exist = armv8->enable_pauth;
1882  }
1883 
1884  arm->cpsr = reg_list + ARMV8_XPSR;
1885  arm->pc = reg_list + ARMV8_PC;
1886  arm->core_cache = cache;
1887 
1888  /* shadow cache for ARM mode registers */
1889  cache32->name = "Aarch32 registers";
1890  cache32->next = NULL;
1891  cache32->reg_list = reg_list32;
1892  cache32->num_regs = num_regs32;
1893 
1894  for (i = 0; i < num_regs32; i++) {
1895  reg_list32[i].name = armv8_regs32[i].name;
1896  reg_list32[i].size = armv8_regs32[i].bits;
1897  reg_list32[i].value = &arch_info[armv8_regs32[i].id].value[armv8_regs32[i].mapping];
1898  reg_list32[i].type = &armv8_reg32_type;
1899  reg_list32[i].arch_info = &arch_info[armv8_regs32[i].id];
1900  reg_list32[i].group = armv8_regs32[i].group;
1901  reg_list32[i].number = i;
1902  reg_list32[i].exist = true;
1903  reg_list32[i].caller_save = true;
1904 
1905  feature = calloc(1, sizeof(struct reg_feature));
1906  if (feature) {
1907  feature->name = armv8_regs32[i].feature;
1908  reg_list32[i].feature = feature;
1909  } else
1910  LOG_ERROR("unable to allocate feature list");
1911 
1912  reg_list32[i].reg_data_type = calloc(1, sizeof(struct reg_data_type));
1913  if (reg_list32[i].reg_data_type)
1914  reg_list32[i].reg_data_type->type = armv8_regs32[i].type;
1915  else
1916  LOG_ERROR("unable to allocate reg type list");
1917  }
1918 
1919  (*cache_p) = cache;
1920  return cache;
1921 }
1922 
1923 struct reg *armv8_reg_current(struct arm *arm, unsigned int regnum)
1924 {
1925  if (regnum > (ARMV8_LAST_REG - 1))
1926  return NULL;
1927 
1928  return arm->core_cache->reg_list + regnum;
1929 }
1930 
1931 static void armv8_free_cache(struct reg_cache *cache, bool regs32)
1932 {
1933  struct reg *reg;
1934  unsigned int i;
1935 
1936  if (!cache)
1937  return;
1938 
1939  for (i = 0; i < cache->num_regs; i++) {
1940  reg = &cache->reg_list[i];
1941 
1942  free(reg->feature);
1943  free(reg->reg_data_type);
1944  }
1945 
1946  if (!regs32)
1947  free(cache->reg_list[0].arch_info);
1948  free(cache->reg_list);
1949  free(cache);
1950 }
1951 
1953 {
1954  struct armv8_common *armv8 = target_to_armv8(target);
1955  struct arm *arm = &armv8->arm;
1956  struct reg_cache *cache = NULL, *cache32 = NULL;
1957 
1958  cache = arm->core_cache;
1959  if (cache)
1960  cache32 = cache->next;
1961  armv8_free_cache(cache32, true);
1962  armv8_free_cache(cache, false);
1963  arm->core_cache = NULL;
1964 }
1965 
1967  {
1968  .name = "catch_exc",
1969  .handler = armv8_handle_exception_catch_command,
1970  .mode = COMMAND_EXEC,
1971  .help = "configure exception catch",
1972  .usage = "[(nsec_el1,nsec_el2,sec_el1,sec_el3)+,off]",
1973  },
1974  {
1975  .name = "pauth",
1976  .handler = armv8_pauth_command,
1977  .mode = COMMAND_CONFIG,
1978  .help = "enable or disable providing GDB with an 8-bytes mask to "
1979  "remove signature bits added by pointer authentication."
1980  "Pointer authentication feature is broken until gdb 12.1, going to be fixed. "
1981  "Consider using a newer version of gdb if you want enable "
1982  "pauth feature.",
1983  .usage = "[on|off]",
1984  },
1986 };
1987 
1988 const char *armv8_get_gdb_arch(const struct target *target)
1989 {
1990  struct arm *arm = target_to_arm(target);
1991  return arm->core_state == ARM_STATE_AARCH64 ? "aarch64" : "arm";
1992 }
1993 
1995  struct reg **reg_list[], int *reg_list_size,
1996  enum target_register_class reg_class)
1997 {
1998  struct arm *arm = target_to_arm(target);
1999  int i;
2000 
2001  if (arm->core_state == ARM_STATE_AARCH64) {
2002 
2003  LOG_DEBUG("Creating Aarch64 register list for target %s", target_name(target));
2004 
2005  switch (reg_class) {
2006  case REG_CLASS_GENERAL:
2007  *reg_list_size = ARMV8_V0;
2008  *reg_list = malloc(sizeof(struct reg *) * (*reg_list_size));
2009 
2010  for (i = 0; i < *reg_list_size; i++)
2011  (*reg_list)[i] = armv8_reg_current(arm, i);
2012  return ERROR_OK;
2013 
2014  case REG_CLASS_ALL:
2015  *reg_list_size = ARMV8_LAST_REG;
2016  *reg_list = malloc(sizeof(struct reg *) * (*reg_list_size));
2017 
2018  for (i = 0; i < *reg_list_size; i++)
2019  (*reg_list)[i] = armv8_reg_current(arm, i);
2020 
2021  return ERROR_OK;
2022 
2023  default:
2024  LOG_ERROR("not a valid register class type in query.");
2025  return ERROR_FAIL;
2026  }
2027  } else {
2028  struct reg_cache *cache32 = arm->core_cache->next;
2029 
2030  LOG_DEBUG("Creating Aarch32 register list for target %s", target_name(target));
2031 
2032  switch (reg_class) {
2033  case REG_CLASS_GENERAL:
2034  *reg_list_size = ARMV8_R14 + 3;
2035  *reg_list = malloc(sizeof(struct reg *) * (*reg_list_size));
2036 
2037  for (i = 0; i < *reg_list_size; i++)
2038  (*reg_list)[i] = cache32->reg_list + i;
2039 
2040  return ERROR_OK;
2041  case REG_CLASS_ALL:
2042  *reg_list_size = cache32->num_regs;
2043  *reg_list = malloc(sizeof(struct reg *) * (*reg_list_size));
2044 
2045  for (i = 0; i < *reg_list_size; i++)
2046  (*reg_list)[i] = cache32->reg_list + i;
2047 
2048  return ERROR_OK;
2049  default:
2050  LOG_ERROR("not a valid register class type in query.");
2051  return ERROR_FAIL;
2052  }
2053  }
2054 }
2055 
2056 int armv8_set_dbgreg_bits(struct armv8_common *armv8, unsigned int reg, unsigned long mask, unsigned long value)
2057 {
2058  uint32_t tmp;
2059 
2060  /* Read register */
2061  int retval = mem_ap_read_atomic_u32(armv8->debug_ap,
2062  armv8->debug_base + reg, &tmp);
2063  if (retval != ERROR_OK)
2064  return retval;
2065 
2066  /* clear bitfield */
2067  tmp &= ~mask;
2068  /* put new value */
2069  tmp |= value & mask;
2070 
2071  /* write new value */
2072  return mem_ap_write_atomic_u32(armv8->debug_ap,
2073  armv8->debug_base + reg, tmp);
2074 }
int arm_arch_state(struct target *target)
Definition: armv4_5.c:797
#define ARM_COMMON_MAGIC
Definition: arm.h:167
arm_mode
Represent state of an ARM core.
Definition: arm.h:82
@ ARM_MODE_IRQ
Definition: arm.h:85
@ ARM_MODE_SYS
Definition: arm.h:92
@ ARM_MODE_HYP
Definition: arm.h:89
@ ARMV8_64_EL0T
Definition: arm.h:98
@ ARMV8_64_EL3H
Definition: arm.h:104
@ ARM_MODE_MON
Definition: arm.h:87
@ ARMV8_64_EL3T
Definition: arm.h:103
@ ARM_MODE_FIQ
Definition: arm.h:84
@ ARM_MODE_UND
Definition: arm.h:90
@ ARM_MODE_ANY
Definition: arm.h:106
@ ARMV8_64_EL1H
Definition: arm.h:100
@ ARM_MODE_USR
Definition: arm.h:83
@ ARM_MODE_SVC
Definition: arm.h:86
@ ARMV8_64_EL2H
Definition: arm.h:102
@ ARMV8_64_EL2T
Definition: arm.h:101
@ ARMV8_64_EL1T
Definition: arm.h:99
@ ARM_MODE_ABT
Definition: arm.h:88
static struct arm * target_to_arm(const struct target *target)
Convert target handle to generic ARM target state handle.
Definition: arm.h:262
arm_state
The PSR "T" and "J" bits define the mode of "classic ARM" cores.
Definition: arm.h:151
@ ARM_STATE_JAZELLE
Definition: arm.h:154
@ ARM_STATE_THUMB
Definition: arm.h:153
@ ARM_STATE_ARM
Definition: arm.h:152
@ ARM_STATE_AARCH64
Definition: arm.h:156
@ ARM_STATE_THUMB_EE
Definition: arm.h:155
int mem_ap_read_atomic_u32(struct adiv5_ap *ap, target_addr_t address, uint32_t *value)
Synchronous read of a word from memory or a system register.
Definition: arm_adi_v5.c:274
int mem_ap_write_atomic_u32(struct adiv5_ap *ap, target_addr_t address, uint32_t value)
Synchronous write of a word to memory or a system register.
Definition: arm_adi_v5.c:326
#define ARMV4_5_VMSR(rt)
Definition: arm_opcodes.h:146
#define ARMV4_5_MRC(cp, op1, rd, crn, crm, op2)
Definition: arm_opcodes.h:186
#define ARMV4_5_MCR(cp, op1, rd, crn, crm, op2)
Definition: arm_opcodes.h:209
#define ARMV4_5_VMOV(op, rt2, rt, m, vm)
Definition: arm_opcodes.h:134
#define ARMV4_5_VMRS(rt)
Definition: arm_opcodes.h:141
static int armv8_read_reg32(struct armv8_common *armv8, int regnum, uint64_t *regval)
Definition: armv8.c:596
int armv8_init_arch_info(struct target *target, struct armv8_common *armv8)
Definition: armv8.c:1326
static int armv8_get_core_reg32(struct reg *reg)
Definition: armv8.c:1759
int armv8_set_dbgreg_bits(struct armv8_common *armv8, unsigned int reg, unsigned long mask, unsigned long value)
Definition: armv8.c:2056
static int armv8_get_core_reg(struct reg *reg)
Definition: armv8.c:1711
const char * armv8_get_gdb_arch(const struct target *target)
Definition: armv8.c:1988
static const struct @88 armv8_regs32[]
static struct reg_data_type_flags_field aarch64_cpsr_fields[]
Definition: armv8.c:1516
static int armv8_write_reg_simdfp_aarch32(struct armv8_common *armv8, int regnum, uint64_t lvalue, uint64_t hvalue)
Definition: armv8.c:820
int armv8_read_mpidr(struct armv8_common *armv8)
Definition: armv8.c:887
static int armv8_write_reg32(struct armv8_common *armv8, int regnum, uint64_t value)
Definition: armv8.c:738
void armv8_free_reg_cache(struct target *target)
Definition: armv8.c:1952
static void armv8_show_fault_registers32(struct armv8_common *armv8)
Definition: armv8.c:1012
enum arm_mode mode
Definition: armv8.c:1545
static int armv8_get_pauth_mask(struct armv8_common *armv8, uint64_t *mask)
Definition: armv8.c:270
static struct reg_data_type_vector aarch64_vector_types[]
Definition: armv8.c:1410
static const struct @86 armv8_mode_data[]
static __attribute__((unused))
Definition: armv8.c:147
static int armv8_setup_semihosting(struct target *target, int enable)
Definition: armv8.c:1321
static struct reg_data_type_bitfield aarch64_cpsr_bits[]
Definition: armv8.c:1500
static int armv8_read_reg_simdfp_aarch64(struct armv8_common *armv8, int regnum, uint64_t *lvalue, uint64_t *hvalue)
Definition: armv8.c:419
static struct reg_data_type aarch64_fpu_union[]
Definition: armv8.c:1475
static int armv8_set_core_reg(struct reg *reg, uint8_t *buf)
Definition: armv8.c:1723
static int armv8_read_reg_simdfp_aarch32(struct armv8_common *armv8, int regnum, uint64_t *lvalue, uint64_t *hvalue)
Definition: armv8.c:686
struct reg * armv8_reg_current(struct arm *arm, unsigned int regnum)
Definition: armv8.c:1923
struct reg_data_type * data_type
Definition: armv8.c:1549
int armv8_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
Definition: armv8.c:1994
static const char *const armv8_state_strings[]
Definition: armv8.c:33
static const struct reg_arch_type armv8_reg_type
Definition: armv8.c:1754
const char * group
Definition: armv8.c:1547
static struct reg_data_type_union_field aarch64v_union_fields[]
Definition: armv8.c:1483
int armv8_arch_state(struct target *target)
Definition: armv8.c:1366
static struct reg_data_type aarch64v[]
Definition: armv8.c:1495
static void armv8_decode_cacheability(int attr)
Definition: armv8.c:1067
int armv8_mmu_translate_va_pa(struct target *target, target_addr_t va, target_addr_t *val, int meminfo)
Definition: armv8.c:1143
static struct reg_data_type_union_field aarch64_union_fields_vnh[]
Definition: armv8.c:1452
static int armv8_write_reg_simdfp_aarch64(struct armv8_common *armv8, int regnum, uint64_t lvalue, uint64_t hvalue)
Definition: armv8.c:573
static struct reg_data_type aarch64_flags_cpsr[]
Definition: armv8.c:1536
static void armv8_free_cache(struct reg_cache *cache, bool regs32)
Definition: armv8.c:1931
static int armv8_read_reg(struct armv8_common *armv8, int regnum, uint64_t *regval)
Definition: armv8.c:284
const struct command_registration armv8_command_handlers[]
Definition: armv8.c:1966
static struct reg_data_type_union aarch64v_union[]
Definition: armv8.c:1491
static struct reg_data_type_union_field aarch64_union_fields_vnd[]
Definition: armv8.c:1440
void armv8_set_cpsr(struct arm *arm, uint32_t cpsr)
Configures host-side ARM records to reflect the specified CPSR.
Definition: armv8.c:967
const char * name
Definition: armv8.c:38
#define ARMV8_NUM_REGS
Definition: armv8.c:1708
static struct reg_data_type_union_field aarch64_union_fields_vnq[]
Definition: armv8.c:1462
static int armv8_read_ttbcr(struct target *target)
Definition: armv8.c:186
static const struct @87 armv8_regs[]
unsigned int bits
Definition: armv8.c:1544
COMMAND_HANDLER(armv8_handle_exception_catch_command)
Definition: armv8.c:1233
static int armv8_set_core_reg32(struct reg *reg, uint8_t *buf)
Definition: armv8.c:1785
unsigned int psr
Definition: armv8.c:39
struct reg_cache * armv8_build_reg_cache(struct target *target)
Builds cache of architecturally defined registers.
Definition: armv8.c:1821
static uint8_t armv8_pa_size(uint32_t ps)
Definition: armv8.c:118
static struct reg_data_type aarch64_vector_base_types[]
Definition: armv8.c:1395
static struct reg_data_type_flags aarch64_cpsr_flags[]
Definition: armv8.c:1532
static struct reg_data_type_union_field aarch64_union_fields_vnb[]
Definition: armv8.c:1457
unsigned int mapping
Definition: armv8.c:1648
static int armv8_aarch64_state(struct target *target)
Definition: armv8.c:1344
void armv8_select_reg_access(struct armv8_common *armv8, bool is_aarch64)
Definition: armv8.c:870
static int armv8_write_reg(struct armv8_common *armv8, int regnum, uint64_t value_64)
Definition: armv8.c:442
static void armv8_decode_memory_attr(int attr)
Definition: armv8.c:1101
static struct reg_data_type_union_field aarch64_union_fields_vns[]
Definition: armv8.c:1446
const char * feature
Definition: armv8.c:1548
static const struct reg_arch_type armv8_reg32_type
Definition: armv8.c:1815
#define ARMV8_NUM_REGS32
Definition: armv8.c:1709
const char * armv8_mode_name(unsigned int psr_mode)
Map PSR mode bits to the name of an ARM processor operating mode.
Definition: armv8.c:108
int armv8_handle_cache_info_command(struct command_invocation *cmd, struct armv8_cache_common *armv8_cache)
Definition: armv8.c:1308
static struct reg_data_type_union aarch64_union_types[]
Definition: armv8.c:1467
static struct reg_data_type aarch64_fpu_vector[]
Definition: armv8.c:1425
static struct armv8_common * target_to_armv8(struct target *target)
Definition: armv8.h:234
#define CPUV8_DBG_ECCR
Definition: armv8.h:256
@ ARMV8_V27
Definition: armv8.h:81
@ ARMV8_R14
Definition: armv8.h:32
@ ARMV8_ESR_EL2
Definition: armv8.h:94
@ ARMV8_R20
Definition: armv8.h:38
@ ARMV8_V16
Definition: armv8.h:70
@ ARMV8_V1
Definition: armv8.h:55
@ ARMV8_V11
Definition: armv8.h:65
@ ARMV8_R0
Definition: armv8.h:18
@ ARMV8_V23
Definition: armv8.h:77
@ ARMV8_V2
Definition: armv8.h:56
@ ARMV8_R12
Definition: armv8.h:30
@ ARMV8_R21
Definition: armv8.h:39
@ ARMV8_R5
Definition: armv8.h:23
@ ARMV8_V5
Definition: armv8.h:59
@ ARMV8_ESR_EL1
Definition: armv8.h:90
@ ARMV8_V12
Definition: armv8.h:66
@ ARMV8_V4
Definition: armv8.h:58
@ ARMV8_V25
Definition: armv8.h:79
@ ARMV8_R7
Definition: armv8.h:25
@ ARMV8_V14
Definition: armv8.h:68
@ ARMV8_PAUTH_DMASK
Definition: armv8.h:102
@ ARMV8_R9
Definition: armv8.h:27
@ ARMV8_LAST_REG
Definition: armv8.h:105
@ ARMV8_V18
Definition: armv8.h:72
@ ARMV8_R17
Definition: armv8.h:35
@ ARMV8_R23
Definition: armv8.h:41
@ ARMV8_V6
Definition: armv8.h:60
@ ARMV8_R18
Definition: armv8.h:36
@ ARMV8_R1
Definition: armv8.h:19
@ ARMV8_SPSR_EL3
Definition: armv8.h:99
@ ARMV8_SPSR_EL2
Definition: armv8.h:95
@ ARMV8_R24
Definition: armv8.h:42
@ ARMV8_V19
Definition: armv8.h:73
@ ARMV8_R22
Definition: armv8.h:40
@ ARMV8_SP
Definition: armv8.h:50
@ ARMV8_R6
Definition: armv8.h:24
@ ARMV8_R29
Definition: armv8.h:47
@ ARMV8_V3
Definition: armv8.h:57
@ ARMV8_V7
Definition: armv8.h:61
@ ARMV8_V31
Definition: armv8.h:85
@ ARMV8_V17
Definition: armv8.h:71
@ ARMV8_V13
Definition: armv8.h:67
@ ARMV8_R25
Definition: armv8.h:43
@ ARMV8_V28
Definition: armv8.h:82
@ ARMV8_V9
Definition: armv8.h:63
@ ARMV8_V22
Definition: armv8.h:76
@ ARMV8_ELR_EL3
Definition: armv8.h:97
@ ARMV8_XPSR
Definition: armv8.h:52
@ ARMV8_R30
Definition: armv8.h:48
@ ARMV8_PAUTH_CMASK
Definition: armv8.h:103
@ ARMV8_V8
Definition: armv8.h:62
@ ARMV8_R27
Definition: armv8.h:45
@ ARMV8_R4
Definition: armv8.h:22
@ ARMV8_FPCR
Definition: armv8.h:87
@ ARMV8_V24
Definition: armv8.h:78
@ ARMV8_R8
Definition: armv8.h:26
@ ARMV8_PC
Definition: armv8.h:51
@ ARMV8_V0
Definition: armv8.h:54
@ ARMV8_SPSR_EL1
Definition: armv8.h:91
@ ARMV8_R13
Definition: armv8.h:31
@ ARMV8_ELR_EL2
Definition: armv8.h:93
@ ARMV8_V29
Definition: armv8.h:83
@ ARMV8_ESR_EL3
Definition: armv8.h:98
@ ARMV8_R10
Definition: armv8.h:28
@ ARMV8_V26
Definition: armv8.h:80
@ ARMV8_V10
Definition: armv8.h:64
@ ARMV8_R28
Definition: armv8.h:46
@ ARMV8_R3
Definition: armv8.h:21
@ ARMV8_R26
Definition: armv8.h:44
@ ARMV8_V21
Definition: armv8.h:75
@ ARMV8_V15
Definition: armv8.h:69
@ ARMV8_V20
Definition: armv8.h:74
@ ARMV8_R16
Definition: armv8.h:34
@ ARMV8_V30
Definition: armv8.h:84
@ ARMV8_R11
Definition: armv8.h:29
@ ARMV8_FPSR
Definition: armv8.h:86
@ ARMV8_ELR_EL1
Definition: armv8.h:89
@ ARMV8_R15
Definition: armv8.h:33
@ ARMV8_R2
Definition: armv8.h:20
@ ARMV8_R19
Definition: armv8.h:37
static unsigned int armv8_curel_from_core_mode(enum arm_mode core_mode)
Definition: armv8.h:298
#define ARMV8_COMMON_MAGIC
Definition: armv8.h:115
enum arm_state armv8_dpm_get_core_state(struct arm_dpm *dpm)
Get core state from EDSCR, without necessity to retrieve CPSR.
Definition: armv8_dpm.c:41
int armv8_dpm_modeswitch(struct arm_dpm *dpm, enum arm_mode mode)
Definition: armv8_dpm.c:538
#define ARMV8_MRC_DLR(rt)
#define SYSTEM_ESR_EL3
#define ARMV8_MCR_DLR(rt)
#define SYSTEM_CUREL_EL1
Definition: armv8_opcodes.h:15
#define ARMV8_MSR_GP(system, rt)
#define ARMV8_MSR_DLR(rt)
#define ARMV8_MCR_DSPSR(rt)
#define ARMV8_MOVTSP_64(rt)
#define SYSTEM_TTBR0_EL2
Definition: armv8_opcodes.h:87
#define SYSTEM_TTBR0_EL3
Definition: armv8_opcodes.h:88
#define SYSTEM_ELR_EL3
Definition: armv8_opcodes.h:35
#define SYSTEM_TCR_EL2
Definition: armv8_opcodes.h:83
#define SYSTEM_ESR_EL2
#define SYSTEM_CUREL_EL3
Definition: armv8_opcodes.h:17
#define SYSTEM_ATS12E0R
Definition: armv8_opcodes.h:93
#define ARMV8_MOV_VFP_GPR(rd, rn, index)
#define SYSTEM_ELR_EL1
Definition: armv8_opcodes.h:33
#define SYSTEM_CUREL_EL2
Definition: armv8_opcodes.h:16
#define ARMV8_MRS_DSPSR(rt)
#define ARMV8_MSR_FPCR(rt)
#define SYSTEM_TTBR0_EL1
Definition: armv8_opcodes.h:86
#define SYSTEM_SPSR_EL3
Definition: armv8_opcodes.h:56
#define ARMV8_MRS(system, rt)
#define SYSTEM_ATS12E1R
Definition: armv8_opcodes.h:94
#define ARMV8_MSR_FPSR(rt)
#define ARMV8_MRS_DLR(rt)
#define SYSTEM_ATS1E3R
Definition: armv8_opcodes.h:96
#define SYSTEM_PAR_EL1
Definition: armv8_opcodes.h:92
#define SYSTEM_ESR_EL1
#define SYSTEM_SPSR_EL2
Definition: armv8_opcodes.h:55
#define ARMV8_MRS_FPCR(rt)
#define SYSTEM_TCR_EL3
Definition: armv8_opcodes.h:84
#define ARMV8_MOV_GPR_VFP(rd, rn, index)
#define ARMV8_SYS(system, rt)
#define ARMV8_MRS_XPSR_T1(r, rd)
#define ARMV8_MSR_GP_XPSR_T1(r, rn, mask)
#define SYSTEM_SPSR_EL1
Definition: armv8_opcodes.h:54
#define ARMV8_MSR_GP_T1(r, m1, rd, m)
#define ARMV8_MSR_DSPSR(rt)
#define SYSTEM_CUREL_EL0
Definition: armv8_opcodes.h:14
armv8_opcode
@ READ_REG_MPIDR
#define SYSTEM_ATS1E2R
Definition: armv8_opcodes.h:95
#define SYSTEM_ELR_EL2
Definition: armv8_opcodes.h:34
#define SYSTEM_TCR_EL1
Definition: armv8_opcodes.h:82
#define ARMV8_MRS_FPSR(rt)
#define ARMV8_MRS_T1(r, m1, rd, m)
#define ARMV8_MRC_DSPSR(rt)
#define SYSTEM_DBG_DBGDTR_EL0
Definition: armv8_opcodes.h:64
#define ARMV8_MOVFSP_64(rt)
Support functions to access arbitrary bits in a byte array.
static uint32_t buf_get_u32(const uint8_t *_buffer, unsigned int first, unsigned int num)
Retrieves num bits from _buffer, starting at the first bit, returning the bits in a 32-bit word.
Definition: binarybuffer.h:104
static void buf_set_u32(uint8_t *_buffer, unsigned int first, unsigned int num, uint32_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
Definition: binarybuffer.h:34
static uint64_t buf_get_u64(const uint8_t *_buffer, unsigned int first, unsigned int num)
Retrieves num bits from _buffer, starting at the first bit, returning the bits in a 64-bit word.
Definition: binarybuffer.h:134
static void buf_set_u64(uint8_t *_buffer, unsigned int first, unsigned int num, uint64_t value)
Sets num bits in _buffer, starting at the first bit, using the bits in value.
Definition: binarybuffer.h:65
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:389
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:146
#define CALL_COMMAND_HANDLER(name, extra ...)
Use this to macro to call a command helper (or a nested handler).
Definition: command.h:123
#define CMD_ARGV
Use this macro to access the arguments for the command being handled, rather than accessing the varia...
Definition: command.h:161
#define ERROR_COMMAND_SYNTAX_ERROR
Definition: command.h:405
#define CMD_ARGC
Use this macro to access the number of arguments for the command being handled, rather than accessing...
Definition: command.h:156
#define CMD_CTX
Use this macro to access the context of the command being handled, rather than accessing the variable...
Definition: command.h:151
#define COMMAND_REGISTRATION_DONE
Use this as the last entry in an array of command_registration records.
Definition: command.h:256
@ COMMAND_CONFIG
Definition: command.h:41
@ COMMAND_EXEC
Definition: command.h:40
#define LOG_USER(expr ...)
Definition: log.h:150
#define LOG_WARNING(expr ...)
Definition: log.h:144
#define ERROR_FAIL
Definition: log.h:188
#define LOG_TARGET_ERROR(target, fmt_str,...)
Definition: log.h:176
#define LOG_USER_N(expr ...)
Definition: log.h:153
#define LOG_ERROR(expr ...)
Definition: log.h:147
#define LOG_INFO(expr ...)
Definition: log.h:141
#define LOG_DEBUG(expr ...)
Definition: log.h:124
#define ERROR_OK
Definition: log.h:182
const struct nvp * nvp_name2value(const struct nvp *p, const char *name)
Definition: nvp.c:29
const struct nvp * nvp_value2name(const struct nvp *p, int value)
Definition: nvp.c:39
uint8_t mask
Definition: parport.c:70
struct reg_cache ** register_get_last_cache_p(struct reg_cache **first)
Definition: register.c:72
reg_type
Definition: register.h:19
@ REG_TYPE_UINT16
Definition: register.h:29
@ REG_TYPE_BOOL
Definition: register.h:20
@ REG_TYPE_IEEE_DOUBLE
Definition: register.h:37
@ REG_TYPE_INT64
Definition: register.h:25
@ REG_TYPE_INT16
Definition: register.h:23
@ REG_TYPE_UINT32
Definition: register.h:30
@ REG_TYPE_CODE_PTR
Definition: register.h:33
@ REG_TYPE_DATA_PTR
Definition: register.h:34
@ REG_TYPE_INT32
Definition: register.h:24
@ REG_TYPE_INT128
Definition: register.h:26
@ REG_TYPE_UINT128
Definition: register.h:32
@ REG_TYPE_UINT64
Definition: register.h:31
@ REG_TYPE_INT8
Definition: register.h:22
@ REG_TYPE_ARCH_DEFINED
Definition: register.h:38
@ REG_TYPE_IEEE_SINGLE
Definition: register.h:36
@ REG_TYPE_UINT8
Definition: register.h:28
@ REG_TYPE_CLASS_VECTOR
Definition: register.h:93
@ REG_TYPE_CLASS_FLAGS
Definition: register.h:96
@ REG_TYPE_CLASS_UNION
Definition: register.h:94
struct target * target
Definition: rtt/rtt.c:26
static const char * str_enabled_disabled(bool value)
This wraps an implementation of DPM primitives.
Definition: arm_dpm.h:47
target_addr_t wp_addr
Target dependent watchpoint address.
Definition: arm_dpm.h:147
int(* instr_read_data_dcc)(struct arm_dpm *dpm, uint32_t opcode, uint32_t *data)
Runs one instruction, reading data from dcc after execution.
Definition: arm_dpm.h:91
int(* instr_write_data_r0_64)(struct arm_dpm *dpm, uint32_t opcode, uint64_t data)
Runs one instruction, writing data to R0 before execution.
Definition: arm_dpm.h:82
int(* instr_read_data_dcc_64)(struct arm_dpm *dpm, uint32_t opcode, uint64_t *data)
Definition: arm_dpm.h:94
int(* instr_write_data_dcc_64)(struct arm_dpm *dpm, uint32_t opcode, uint64_t data)
Definition: arm_dpm.h:68
int(* instr_write_data_r0)(struct arm_dpm *dpm, uint32_t opcode, uint32_t data)
Runs one instruction, writing data to R0 before execution.
Definition: arm_dpm.h:72
struct arm * arm
Definition: arm_dpm.h:48
int(* finish)(struct arm_dpm *dpm)
Invoke after a series of instruction operations.
Definition: arm_dpm.h:57
int(* instr_write_data_dcc)(struct arm_dpm *dpm, uint32_t opcode, uint32_t data)
Runs one instruction, writing data to DCC before execution.
Definition: arm_dpm.h:65
int(* prepare)(struct arm_dpm *dpm)
Invoke before a series of instruction operations.
Definition: arm_dpm.h:54
int(* instr_read_data_r0)(struct arm_dpm *dpm, uint32_t opcode, uint32_t *data)
Runs one instruction, reading data from r0 after execution.
Definition: arm_dpm.h:98
int(* instr_read_data_r0_64)(struct arm_dpm *dpm, uint32_t opcode, uint64_t *data)
Definition: arm_dpm.h:108
Definition: arm.h:281
int num
Definition: arm.h:282
struct arm * arm
Definition: arm.h:285
uint8_t value[16]
Definition: arm.h:286
enum arm_mode mode
Definition: arm.h:283
struct target * target
Definition: arm.h:284
Represents a generic ARM core, with standard application registers.
Definition: arm.h:176
void * arch_info
Definition: arm.h:252
enum arm_mode core_mode
Record the current core mode: SVC, USR, or some other mode.
Definition: arm.h:197
struct reg * cpsr
Handle to the CPSR/xPSR; valid in all core modes.
Definition: arm.h:185
struct reg * pc
Handle to the PC; valid in all core modes.
Definition: arm.h:182
int(* setup_semihosting)(struct target *target, int enable)
Definition: arm.h:208
int(* read_core_reg)(struct target *target, struct reg *reg, int num, enum arm_mode mode)
Retrieve a single core register.
Definition: arm.h:225
struct reg_cache * core_cache
Definition: arm.h:179
struct arm_dpm * dpm
Handle for the debug module, if one is present.
Definition: arm.h:214
unsigned int common_magic
Definition: arm.h:177
struct target * target
Backpointer to the target.
Definition: arm.h:211
enum arm_state core_state
Record the current core state: ARM, Thumb, or otherwise.
Definition: arm.h:200
bool d_u_cache_enabled
Definition: armv8.h:160
void * l2_cache
Definition: armv8.h:163
int(* display_cache_info)(struct command_invocation *cmd, struct armv8_cache_common *armv8_cache)
Definition: armv8.h:166
bool i_cache_enabled
Definition: armv8.h:159
int(* flush_all_data_cache)(struct target *target)
Definition: armv8.h:164
struct arm arm
Definition: armv8.h:188
uint8_t va_size
Definition: armv8.h:199
uint32_t page_size
Definition: armv8.h:201
struct arm_dpm dpm
Definition: armv8.h:192
uint64_t ttbr_base
Definition: armv8.h:202
target_addr_t debug_base
Definition: armv8.h:193
struct armv8_mmu_common armv8_mmu
Definition: armv8.h:205
int(* read_reg_u64)(struct armv8_common *armv8, int num, uint64_t *value)
Definition: armv8.h:218
int(* write_reg_u128)(struct armv8_common *armv8, int num, uint64_t lvalue, uint64_t hvalue)
Definition: armv8.h:224
struct adiv5_ap * debug_ap
Definition: armv8.h:194
int(* read_reg_u128)(struct armv8_common *armv8, int num, uint64_t *lvalue, uint64_t *hvalue)
Definition: armv8.h:222
unsigned int common_magic
Definition: armv8.h:186
int(* write_reg_u64)(struct armv8_common *armv8, int num, uint64_t value)
Definition: armv8.h:219
bool enable_pauth
Definition: armv8.h:210
uint8_t pa_size
Definition: armv8.h:200
int32_t ttbr1_used
Definition: armv8.h:172
uint64_t ttbr0_mask
Definition: armv8.h:173
uint32_t ttbr_mask[2]
Definition: armv8.h:176
uint32_t ttbcr
Definition: armv8.h:175
struct armv8_cache_common armv8_cache
Definition: armv8.h:181
uint32_t ttbr_range[2]
Definition: armv8.h:177
bool mmu_enabled
Definition: armv8.h:182
When run_command is called, a new instance will be created on the stack, filled with the proper value...
Definition: command.h:76
const char * name
Definition: command.h:239
Name Value Pairs, aka: NVP.
Definition: nvp.h:61
int value
Definition: nvp.h:63
const char * name
Definition: nvp.h:62
int(* get)(struct reg *reg)
Definition: register.h:152
const char * name
Definition: register.h:145
unsigned int num_regs
Definition: register.h:148
struct reg * reg_list
Definition: register.h:147
struct reg_cache * next
Definition: register.h:146
enum reg_type type
Definition: register.h:100
const char * id
Definition: register.h:101
Definition: register.h:111
bool caller_save
Definition: register.h:119
bool valid
Definition: register.h:126
bool exist
Definition: register.h:128
uint32_t size
Definition: register.h:132
const char * group
Definition: register.h:138
uint8_t * value
Definition: register.h:122
struct reg_feature * feature
Definition: register.h:117
struct reg_data_type * reg_data_type
Definition: register.h:135
uint32_t number
Definition: register.h:115
void * arch_info
Definition: register.h:140
bool dirty
Definition: register.h:124
const struct reg_arch_type * type
Definition: register.h:141
const char * name
Definition: register.h:113
bool is_active
A flag reporting whether semihosting is active.
Definition: target.h:119
struct semihosting * semihosting
Definition: target.h:222
enum target_debug_reason debug_reason
Definition: target.h:164
enum target_state state
Definition: target.h:167
struct reg_cache * reg_cache
Definition: target.h:168
void * arch_info
Definition: target.h:174
const char * debug_reason_name(const struct target *t)
Definition: target.c:258
struct target * get_current_target(struct command_context *cmd_ctx)
Definition: target.c:469
@ DBG_REASON_WATCHPOINT
Definition: target.h:74
target_register_class
Definition: target.h:113
@ REG_CLASS_GENERAL
Definition: target.h:115
@ REG_CLASS_ALL
Definition: target.h:114
#define ERROR_TARGET_NOT_HALTED
Definition: target.h:817
static const char * target_name(const struct target *target)
Returns the instance-specific name of the specified target.
Definition: target.h:246
@ TARGET_HALTED
Definition: target.h:58
#define TARGET_ADDR_FMT
Definition: types.h:286
#define ARRAY_SIZE(x)
Compute the number of elements of a variable length array.
Definition: types.h:57
uint64_t target_addr_t
Definition: types.h:279
#define NULL
Definition: usb.h:16
uint8_t cmd
Definition: vdebug.c:1
uint8_t state[4]
Definition: vdebug.c:21