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