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