OpenOCD
arm920t.c
Go to the documentation of this file.
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 
3 
4 /***************************************************************************
5  * Copyright (C) 2005 by Dominic Rath *
6  * Dominic.Rath@gmx.de *
7  ***************************************************************************/
8 
9 #ifdef HAVE_CONFIG_H
10 #include "config.h"
11 #endif
12 
13 #include "arm920t.h"
14 #include <helper/time_support.h>
15 #include <helper/string_choices.h>
16 #include "target_type.h"
17 #include "register.h"
18 #include "arm_opcodes.h"
19 
20 /*
21  * For information about the ARM920T, see ARM DDI 0151C especially
22  * Chapter 9 about debug support, which shows how to manipulate each
23  * of the different scan chains:
24  *
25  * 0 ... ARM920 signals, e.g. to rest of SOC (unused here)
26  * 1 ... debugging; watchpoint and breakpoint status, etc; also
27  * MMU and cache access in conjunction with scan chain 15
28  * 2 ... EmbeddedICE
29  * 3 ... external boundary scan (SoC-specific, unused here)
30  * 4 ... access to cache tag RAM
31  * 6 ... ETM9
32  * 15 ... access coprocessor 15, "physical" or "interpreted" modes
33  * "interpreted" works with a few actual MRC/MCR instructions
34  * "physical" provides register-like behaviors. Section 9.6.7
35  * covers these details.
36  *
37  * The ARM922T is similar, but with smaller caches (8K each, vs 16K).
38  */
39 
40 #if 0
41 #define _DEBUG_INSTRUCTION_EXECUTION_
42 #endif
43 
44 /* Table 9-8 shows scan chain 15 format during physical access mode, using a
45  * dedicated 6-bit address space (encoded in bits 33:38). Writes use one
46  * JTAG scan, while reads use two.
47  *
48  * Table 9-9 lists the thirteen registers which support physical access.
49  * ARM920T_CP15_PHYS_ADDR() constructs the 6-bit reg_addr parameter passed
50  * to arm920t_read_cp15_physical() and arm920t_write_cp15_physical().
51  *
52  * x == bit[38]
53  * y == bits[37:34]
54  * z == bit[33]
55  */
56 #define ARM920T_CP15_PHYS_ADDR(x, y, z) ((x << 5) | (y << 1) << (z))
57 
58 /* Registers supporting physical Read access (from table 9-9) */
59 #define CP15PHYS_CACHETYPE ARM920T_CP15_PHYS_ADDR(0, 0x0, 1)
60 #define CP15PHYS_ICACHE_IDX ARM920T_CP15_PHYS_ADDR(1, 0xd, 1)
61 #define CP15PHYS_DCACHE_IDX ARM920T_CP15_PHYS_ADDR(1, 0xe, 1)
62 /* NOTE: several more registers support only physical read access */
63 
64 /* Registers supporting physical Read/Write access (from table 9-9) */
65 #define CP15PHYS_CTRL ARM920T_CP15_PHYS_ADDR(0, 0x1, 0)
66 #define CP15PHYS_PID ARM920T_CP15_PHYS_ADDR(0, 0xd, 0)
67 #define CP15PHYS_TESTSTATE ARM920T_CP15_PHYS_ADDR(0, 0xf, 0)
68 #define CP15PHYS_ICACHE ARM920T_CP15_PHYS_ADDR(1, 0x1, 1)
69 #define CP15PHYS_DCACHE ARM920T_CP15_PHYS_ADDR(1, 0x2, 1)
70 
72  int reg_addr, uint32_t *value)
73 {
74  struct arm920t_common *arm920t = target_to_arm920(target);
75  struct arm_jtag *jtag_info;
76  struct scan_field fields[4];
77  uint8_t access_type_buf = 1;
78  uint8_t reg_addr_buf = reg_addr & 0x3f;
79  uint8_t nr_w_buf = 0;
80  int retval;
81 
82  jtag_info = &arm920t->arm7_9_common.jtag_info;
83 
84  retval = arm_jtag_scann(jtag_info, 0xf, TAP_IDLE);
85  if (retval != ERROR_OK)
86  return retval;
87  retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
88  if (retval != ERROR_OK)
89  return retval;
90 
91  fields[0].num_bits = 1;
92  fields[0].out_value = &access_type_buf;
93  fields[0].in_value = NULL;
94 
95  fields[1].num_bits = 32;
96  fields[1].out_value = NULL;
97  fields[1].in_value = NULL;
98 
99  fields[2].num_bits = 6;
100  fields[2].out_value = &reg_addr_buf;
101  fields[2].in_value = NULL;
102 
103  fields[3].num_bits = 1;
104  fields[3].out_value = &nr_w_buf;
105  fields[3].in_value = NULL;
106 
107  jtag_add_dr_scan(jtag_info->tap, 4, fields, TAP_IDLE);
108 
109  fields[1].in_value = (uint8_t *)value;
110 
111  jtag_add_dr_scan(jtag_info->tap, 4, fields, TAP_IDLE);
112 
114 
115 #ifdef _DEBUG_INSTRUCTION_EXECUTION_
117  LOG_DEBUG("addr: 0x%x value: %8.8x", reg_addr, *value);
118 #endif
119 
120  return ERROR_OK;
121 }
122 
124  int reg_addr, uint32_t value)
125 {
126  struct arm920t_common *arm920t = target_to_arm920(target);
127  struct arm_jtag *jtag_info;
128  struct scan_field fields[4];
129  uint8_t access_type_buf = 1;
130  uint8_t reg_addr_buf = reg_addr & 0x3f;
131  uint8_t nr_w_buf = 1;
132  uint8_t value_buf[4];
133  int retval;
134 
135  jtag_info = &arm920t->arm7_9_common.jtag_info;
136 
137  buf_set_u32(value_buf, 0, 32, value);
138 
139  retval = arm_jtag_scann(jtag_info, 0xf, TAP_IDLE);
140  if (retval != ERROR_OK)
141  return retval;
142  retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
143  if (retval != ERROR_OK)
144  return retval;
145 
146  fields[0].num_bits = 1;
147  fields[0].out_value = &access_type_buf;
148  fields[0].in_value = NULL;
149 
150  fields[1].num_bits = 32;
151  fields[1].out_value = value_buf;
152  fields[1].in_value = NULL;
153 
154  fields[2].num_bits = 6;
155  fields[2].out_value = &reg_addr_buf;
156  fields[2].in_value = NULL;
157 
158  fields[3].num_bits = 1;
159  fields[3].out_value = &nr_w_buf;
160  fields[3].in_value = NULL;
161 
162  jtag_add_dr_scan(jtag_info->tap, 4, fields, TAP_IDLE);
163 
164 #ifdef _DEBUG_INSTRUCTION_EXECUTION_
165  LOG_DEBUG("addr: 0x%x value: %8.8x", reg_addr, value);
166 #endif
167 
168  return ERROR_OK;
169 }
170 
171 /* See table 9-10 for scan chain 15 format during interpreted access mode.
172  * If the TESTSTATE register is set for interpreted access, certain CP15
173  * MRC and MCR instructions may be executed through scan chain 15.
174  *
175  * Tables 9-11, 9-12, and 9-13 show which MRC and MCR instructions can be
176  * executed using scan chain 15 interpreted mode.
177  */
178 static int arm920t_execute_cp15(struct target *target, uint32_t cp15_opcode,
179  uint32_t arm_opcode)
180 {
181  int retval;
182  struct arm920t_common *arm920t = target_to_arm920(target);
183  struct arm_jtag *jtag_info;
184  struct scan_field fields[4];
185  uint8_t access_type_buf = 0; /* interpreted access */
186  uint8_t reg_addr_buf = 0x0;
187  uint8_t nr_w_buf = 0;
188  uint8_t cp15_opcode_buf[4];
189 
190  jtag_info = &arm920t->arm7_9_common.jtag_info;
191 
192  retval = arm_jtag_scann(jtag_info, 0xf, TAP_IDLE);
193  if (retval != ERROR_OK)
194  return retval;
195  retval = arm_jtag_set_instr(jtag_info->tap, jtag_info->intest_instr, NULL, TAP_IDLE);
196  if (retval != ERROR_OK)
197  return retval;
198 
199  buf_set_u32(cp15_opcode_buf, 0, 32, cp15_opcode);
200 
201  fields[0].num_bits = 1;
202  fields[0].out_value = &access_type_buf;
203  fields[0].in_value = NULL;
204 
205  fields[1].num_bits = 32;
206  fields[1].out_value = cp15_opcode_buf;
207  fields[1].in_value = NULL;
208 
209  fields[2].num_bits = 6;
210  fields[2].out_value = &reg_addr_buf;
211  fields[2].in_value = NULL;
212 
213  fields[3].num_bits = 1;
214  fields[3].out_value = &nr_w_buf;
215  fields[3].in_value = NULL;
216 
217  jtag_add_dr_scan(jtag_info->tap, 4, fields, TAP_IDLE);
218 
219  arm9tdmi_clock_out(jtag_info, arm_opcode, 0, NULL, 0);
220  arm9tdmi_clock_out(jtag_info, ARMV4_5_NOP, 0, NULL, 1);
222  if (retval != ERROR_OK)
223  return retval;
224 
225  retval = jtag_execute_queue();
226  if (retval != ERROR_OK) {
227  LOG_ERROR("failed executing JTAG queue");
228  return retval;
229  }
230 
231  return ERROR_OK;
232 }
233 
235  uint32_t cp15_opcode, uint32_t address, uint32_t *value)
236 {
237  struct arm *arm = target_to_arm(target);
238  uint32_t *regs_p[16];
239  uint32_t regs[16];
240  uint32_t cp15c15 = 0x0;
241  struct reg *r = arm->core_cache->reg_list;
242 
243  /* load address into R1 */
244  regs[1] = address;
246 
247  /* read-modify-write CP15 test state register
248  * to enable interpreted access mode */
251  cp15c15 |= 1; /* set interpret mode */
253 
254  /* execute CP15 instruction and ARM load (reading from coprocessor) */
255  arm920t_execute_cp15(target, cp15_opcode, ARMV4_5_LDR(0, 1));
256 
257  /* disable interpreted access mode */
258  cp15c15 &= ~1U; /* clear interpret mode */
260 
261  /* retrieve value from R0 */
262  regs_p[0] = value;
263  arm9tdmi_read_core_regs(target, 0x1, regs_p);
265 
266 #ifdef _DEBUG_INSTRUCTION_EXECUTION_
267  LOG_DEBUG("cp15_opcode: %8.8x, address: %8.8x, value: %8.8x",
268  cp15_opcode, address, *value);
269 #endif
270 
271  if (!is_arm_mode(arm->core_mode)) {
272  LOG_ERROR("not a valid arm core mode - communication failure?");
273  return ERROR_FAIL;
274  }
275 
276  r[0].dirty = true;
277  r[1].dirty = true;
278 
279  return ERROR_OK;
280 }
281 
282 static
284  uint32_t cp15_opcode, uint32_t value, uint32_t address)
285 {
286  uint32_t cp15c15 = 0x0;
287  struct arm *arm = target_to_arm(target);
288  uint32_t regs[16];
289  struct reg *r = arm->core_cache->reg_list;
290 
291  /* load value, address into R0, R1 */
292  regs[0] = value;
293  regs[1] = address;
295 
296  /* read-modify-write CP15 test state register
297  * to enable interpreted access mode */
300  cp15c15 |= 1; /* set interpret mode */
302 
303  /* execute CP15 instruction and ARM store (writing to coprocessor) */
304  arm920t_execute_cp15(target, cp15_opcode, ARMV4_5_STR(0, 1));
305 
306  /* disable interpreted access mode */
307  cp15c15 &= ~1U; /* set interpret mode */
309 
310 #ifdef _DEBUG_INSTRUCTION_EXECUTION_
311  LOG_DEBUG("cp15_opcode: %8.8x, value: %8.8x, address: %8.8x",
312  cp15_opcode, value, address);
313 #endif
314 
315  if (!is_arm_mode(arm->core_mode)) {
316  LOG_ERROR("not a valid arm core mode - communication failure?");
317  return ERROR_FAIL;
318  }
319 
320  r[0].dirty = true;
321  r[1].dirty = true;
322 
323  return ERROR_OK;
324 }
325 
326 /* EXPORTED to FA256 */
327 int arm920t_get_ttb(struct target *target, uint32_t *result)
328 {
329  int retval;
330  uint32_t ttb = 0x0;
331 
333  /* FIXME use opcode macro */
334  0xeebf0f51, 0x0, &ttb);
335  if (retval != ERROR_OK)
336  return retval;
337 
338  *result = ttb;
339  return ERROR_OK;
340 }
341 
342 /* EXPORTED to FA256 */
344  int d_u_cache, int i_cache)
345 {
346  uint32_t cp15_control;
347  int retval;
348 
349  /* read cp15 control register */
350  retval = arm920t_read_cp15_physical(target, CP15PHYS_CTRL, &cp15_control);
351  if (retval != ERROR_OK)
352  return retval;
353  retval = jtag_execute_queue();
354  if (retval != ERROR_OK)
355  return retval;
356 
357  if (mmu)
358  cp15_control &= ~0x1U;
359 
360  if (d_u_cache)
361  cp15_control &= ~0x4U;
362 
363  if (i_cache)
364  cp15_control &= ~0x1000U;
365 
366  retval = arm920t_write_cp15_physical(target, CP15PHYS_CTRL, cp15_control);
367  return retval;
368 }
369 
370 /* EXPORTED to FA256 */
372  int d_u_cache, int i_cache)
373 {
374  uint32_t cp15_control;
375  int retval;
376 
377  /* read cp15 control register */
378  retval = arm920t_read_cp15_physical(target, CP15PHYS_CTRL, &cp15_control);
379  if (retval != ERROR_OK)
380  return retval;
381  retval = jtag_execute_queue();
382  if (retval != ERROR_OK)
383  return retval;
384 
385  if (mmu)
386  cp15_control |= 0x1U;
387 
388  if (d_u_cache)
389  cp15_control |= 0x4U;
390 
391  if (i_cache)
392  cp15_control |= 0x1000U;
393 
394  retval = arm920t_write_cp15_physical(target, CP15PHYS_CTRL, cp15_control);
395  return retval;
396 }
397 
398 /* EXPORTED to FA256 */
400 {
401  uint32_t cp15c15;
402  struct arm920t_common *arm920t = target_to_arm920(target);
403  int retval;
404 
405  /* examine cp15 control reg */
407  CP15PHYS_CTRL, &arm920t->cp15_control_reg);
408  if (retval != ERROR_OK)
409  return retval;
410  retval = jtag_execute_queue();
411  if (retval != ERROR_OK)
412  return retval;
413  LOG_DEBUG("cp15_control_reg: %8.8" PRIx32, arm920t->cp15_control_reg);
414 
415  if (arm920t->armv4_5_mmu.armv4_5_cache.ctype == -1) {
416  uint32_t cache_type_reg;
417  /* identify caches */
419  CP15PHYS_CACHETYPE, &cache_type_reg);
420  if (retval != ERROR_OK)
421  return retval;
422  retval = jtag_execute_queue();
423  if (retval != ERROR_OK)
424  return retval;
425  armv4_5_identify_cache(cache_type_reg,
426  &arm920t->armv4_5_mmu.armv4_5_cache);
427  }
428 
429  arm920t->armv4_5_mmu.mmu_enabled = arm920t->cp15_control_reg & 0x1U;
431  arm920t->cp15_control_reg & 0x4U;
433  arm920t->cp15_control_reg & 0x1000U;
434 
435  /* save i/d fault status and address register
436  * FIXME use opcode macros */
437  retval = arm920t_read_cp15_interpreted(target, 0xee150f10, 0x0, &arm920t->d_fsr);
438  if (retval != ERROR_OK)
439  return retval;
440  retval = arm920t_read_cp15_interpreted(target, 0xee150f30, 0x0, &arm920t->i_fsr);
441  if (retval != ERROR_OK)
442  return retval;
443  retval = arm920t_read_cp15_interpreted(target, 0xee160f10, 0x0, &arm920t->d_far);
444  if (retval != ERROR_OK)
445  return retval;
446  retval = arm920t_read_cp15_interpreted(target, 0xee160f30, 0x0, &arm920t->i_far);
447  if (retval != ERROR_OK)
448  return retval;
449 
450  LOG_DEBUG("D FSR: 0x%8.8" PRIx32 ", D FAR: 0x%8.8" PRIx32
451  ", I FSR: 0x%8.8" PRIx32 ", I FAR: 0x%8.8" PRIx32,
452  arm920t->d_fsr, arm920t->d_far, arm920t->i_fsr, arm920t->i_far);
453 
454  if (arm920t->preserve_cache) {
455  /* read-modify-write CP15 test state register
456  * to disable I/D-cache linefills */
458  CP15PHYS_TESTSTATE, &cp15c15);
459  if (retval != ERROR_OK)
460  return retval;
461  retval = jtag_execute_queue();
462  if (retval != ERROR_OK)
463  return retval;
464  cp15c15 |= 0x600;
466  CP15PHYS_TESTSTATE, cp15c15);
467  if (retval != ERROR_OK)
468  return retval;
469  }
470  return ERROR_OK;
471 }
472 
473 /* EXPORTED to FA256 */
475 {
476  uint32_t cp15c15 = 0;
477  struct arm920t_common *arm920t = target_to_arm920(target);
478 
479  /* restore i/d fault status and address register */
480  arm920t_write_cp15_interpreted(target, 0xee050f10, arm920t->d_fsr, 0x0);
481  arm920t_write_cp15_interpreted(target, 0xee050f30, arm920t->i_fsr, 0x0);
482  arm920t_write_cp15_interpreted(target, 0xee060f10, arm920t->d_far, 0x0);
483  arm920t_write_cp15_interpreted(target, 0xee060f30, arm920t->i_far, 0x0);
484 
485  /* read-modify-write CP15 test state register
486  * to reenable I/D-cache linefills */
487  if (arm920t->preserve_cache) {
489  CP15PHYS_TESTSTATE, &cp15c15);
491  cp15c15 &= ~0x600U;
493  CP15PHYS_TESTSTATE, cp15c15);
494  }
495 }
496 
497 static const char arm920_not[] = "target is not an ARM920";
498 
500  struct arm920t_common *arm920t)
501 {
502  if (arm920t->common_magic != ARM920T_COMMON_MAGIC) {
504  return ERROR_TARGET_INVALID;
505  }
506 
507  return ERROR_OK;
508 }
509 
512 {
513  struct arm920t_common *arm920t = target_to_arm920(target);
514 
515  if (arm920t->common_magic != ARM920T_COMMON_MAGIC) {
516  LOG_ERROR("BUG: %s", arm920_not);
517  return ERROR_TARGET_INVALID;
518  }
519 
521  LOG_USER("MMU: %s, D-Cache: %s, I-Cache: %s",
525 
526  return ERROR_OK;
527 }
528 
529 static int arm920_mmu(struct target *target, bool *enabled)
530 {
531  if (target->state != TARGET_HALTED) {
532  LOG_TARGET_ERROR(target, "not halted");
534  }
535 
537  return ERROR_OK;
538 }
539 
540 static int arm920_virt2phys(struct target *target,
541  target_addr_t virt, target_addr_t *phys)
542 {
543  uint32_t cb;
544  struct arm920t_common *arm920t = target_to_arm920(target);
545 
546  uint32_t ret;
547  int retval = armv4_5_mmu_translate_va(target,
548  &arm920t->armv4_5_mmu, virt, &cb, &ret);
549  if (retval != ERROR_OK)
550  return retval;
551  *phys = ret;
552  return ERROR_OK;
553 }
554 
557  uint32_t size, uint32_t count, uint8_t *buffer)
558 {
559  int retval;
560 
562 
563  return retval;
564 }
565 
566 
568  target_addr_t address, uint32_t size,
569  uint32_t count, uint8_t *buffer)
570 {
571  struct arm920t_common *arm920t = target_to_arm920(target);
572 
573  return armv4_5_mmu_read_physical(target, &arm920t->armv4_5_mmu,
574  address, size, count, buffer);
575 }
576 
578  target_addr_t address, uint32_t size,
579  uint32_t count, const uint8_t *buffer)
580 {
581  struct arm920t_common *arm920t = target_to_arm920(target);
582 
584  address, size, count, buffer);
585 }
586 
589  uint32_t size, uint32_t count, const uint8_t *buffer)
590 {
591  int retval;
592  const uint32_t cache_mask = ~0x1f; /* cache line size : 32 byte */
593  struct arm920t_common *arm920t = target_to_arm920(target);
594 
595  /* FIX!!!! this should be cleaned up and made much more general. The
596  * plan is to write up and test on arm920t specifically and
597  * then generalize and clean up afterwards.
598  *
599  * Also it should be moved to the callbacks that handle breakpoints
600  * specifically and not the generic memory write fn's. See XScale code.
601  */
602  if (arm920t->armv4_5_mmu.mmu_enabled && (count == 1) &&
603  ((size == 2) || (size == 4))) {
604  /* special case the handling of single word writes to
605  * bypass MMU, to allow implementation of breakpoints
606  * in memory marked read only
607  * by MMU
608  */
609  uint32_t cb;
610  uint32_t pa;
611 
612  /*
613  * We need physical address and cb
614  */
615  retval = armv4_5_mmu_translate_va(target, &arm920t->armv4_5_mmu,
616  address, &cb, &pa);
617  if (retval != ERROR_OK)
618  return retval;
619 
621  if (cb & 0x1) {
622  LOG_DEBUG("D-Cache buffered, "
623  "drain write buffer");
624  /*
625  * Buffered ?
626  * Drain write buffer - MCR p15,0,Rd,c7,c10,4
627  */
628 
630  ARMV4_5_MCR(15, 0, 0, 7, 10, 4),
631  0x0, 0);
632  if (retval != ERROR_OK)
633  return retval;
634  }
635 
636  if (cb == 0x3) {
637  /*
638  * Write back memory ? -> clean cache
639  *
640  * There is no way to clean cache lines using
641  * cp15 scan chain, so copy the full cache
642  * line from cache to physical memory.
643  */
644  uint8_t data[32];
645 
646  LOG_DEBUG("D-Cache in 'write back' mode, "
647  "flush cache line");
648 
649  retval = target_read_memory(target,
650  address & cache_mask, 1,
651  sizeof(data), &data[0]);
652  if (retval != ERROR_OK)
653  return retval;
654 
656  &arm920t->armv4_5_mmu,
657  pa & cache_mask, 1,
658  sizeof(data), &data[0]);
659  if (retval != ERROR_OK)
660  return retval;
661  }
662 
663  /* Cached ? */
664  if (cb & 0x2) {
665  /*
666  * Cached ? -> Invalidate data cache using MVA
667  *
668  * MCR p15,0,Rd,c7,c6,1
669  */
670  LOG_DEBUG("D-Cache enabled, "
671  "invalidate cache line");
672 
674  ARMV4_5_MCR(15, 0, 0, 7, 6, 1), 0x0,
675  address & cache_mask);
676  if (retval != ERROR_OK)
677  return retval;
678  }
679  }
680 
681  /* write directly to physical memory,
682  * bypassing any read only MMU bits, etc.
683  */
685  &arm920t->armv4_5_mmu, pa, size,
686  count, buffer);
687  if (retval != ERROR_OK)
688  return retval;
689  } else {
691  if (retval != ERROR_OK)
692  return retval;
693  }
694 
695  /* If ICache is enabled, we have to invalidate affected ICache lines
696  * the DCache is forced to write-through,
697  * so we don't have to clean it here
698  */
700  if (count <= 1) {
701  /* invalidate ICache single entry with MVA
702  * mcr 15, 0, r0, cr7, cr5, {1}
703  */
704  LOG_DEBUG("I-Cache enabled, "
705  "invalidating affected I-Cache line");
707  ARMV4_5_MCR(15, 0, 0, 7, 5, 1),
708  0x0, address & cache_mask);
709  if (retval != ERROR_OK)
710  return retval;
711  } else {
712  /* invalidate ICache
713  * mcr 15, 0, r0, cr7, cr5, {0}
714  */
716  ARMV4_5_MCR(15, 0, 0, 7, 5, 0),
717  0x0, 0x0);
718  if (retval != ERROR_OK)
719  return retval;
720  }
721  }
722 
723  return ERROR_OK;
724 }
725 
726 /* EXPORTED to FA256 */
728 {
729  int retval = ERROR_OK;
730  struct arm920t_common *arm920t = target_to_arm920(target);
731  struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
732  struct arm *arm = &arm7_9->arm;
733  struct reg *dbg_stat = &arm7_9->eice_cache->reg_list[EICE_DBG_STAT];
734 
735  retval = target_halt(target);
736  if (retval != ERROR_OK)
737  return retval;
738 
739  int64_t then = timeval_ms();
740  bool timeout;
741  while (!(timeout = ((timeval_ms()-then) > 1000))) {
742  if (buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_DBGACK, 1) == 0) {
743  embeddedice_read_reg(dbg_stat);
744  retval = jtag_execute_queue();
745  if (retval != ERROR_OK)
746  return retval;
747  } else
748  break;
749  if (debug_level >= 3) {
750  /* do not eat all CPU, time out after 1 se*/
751  alive_sleep(100);
752  } else
753  keep_alive();
754  }
755  if (timeout) {
756  LOG_ERROR("Failed to halt CPU after 1 sec");
757  return ERROR_TARGET_TIMEOUT;
758  }
759 
761 
762  /* SVC, ARM state, IRQ and FIQ disabled */
763  uint32_t cpsr;
764 
765  cpsr = buf_get_u32(arm->cpsr->value, 0, 32);
766  cpsr &= ~0xff;
767  cpsr |= 0xd3;
768  arm_set_cpsr(arm, cpsr);
769  arm->cpsr->dirty = true;
770 
771  /* start fetching from 0x0 */
772  buf_set_u32(arm->pc->value, 0, 32, 0x0);
773  arm->pc->dirty = true;
774  arm->pc->valid = true;
775 
777  arm920t->armv4_5_mmu.mmu_enabled = false;
779  arm920t->armv4_5_mmu.armv4_5_cache.i_cache_enabled = false;
780 
782 }
783 
784 /* FIXME remove forward decls */
785 static int arm920t_mrc(struct target *target, int cpnum,
786  uint32_t op1, uint32_t op2,
787  uint32_t crn, uint32_t crm,
788  uint32_t *value);
789 static int arm920t_mcr(struct target *target, int cpnum,
790  uint32_t op1, uint32_t op2,
791  uint32_t crn, uint32_t crm,
792  uint32_t value);
793 
795  struct arm920t_common *arm920t, struct jtag_tap *tap)
796 {
797  struct arm7_9_common *arm7_9 = &arm920t->arm7_9_common;
798 
799  arm7_9->arm.mrc = arm920t_mrc;
800  arm7_9->arm.mcr = arm920t_mcr;
801 
802  /* initialize arm7/arm9 specific info (including armv4_5) */
803  arm9tdmi_init_arch_info(target, arm7_9, tap);
804 
806 
810 
811  arm920t->armv4_5_mmu.armv4_5_cache.ctype = -1;
817  arm920t->armv4_5_mmu.has_tiny_pages = 1;
818  arm920t->armv4_5_mmu.mmu_enabled = false;
819 
820  /* disabling linefills leads to lockups, so keep them enabled for now
821  * this doesn't affect correctness, but might affect timing issues, if
822  * important data is evicted from the cache during the debug session
823  * */
824  arm920t->preserve_cache = 0;
825 
826  /* override hw single-step capability from ARM9TDMI */
827  arm7_9->has_single_step = 1;
828 
829  return ERROR_OK;
830 }
831 
833 {
834  struct arm920t_common *arm920t;
835 
836  arm920t = calloc(1, sizeof(struct arm920t_common));
837  return arm920t_init_arch_info(target, arm920t, target->tap);
838 }
839 
840 static void arm920t_deinit_target(struct target *target)
841 {
842  struct arm *arm = target_to_arm(target);
843  struct arm920t_common *arm920t = target_to_arm920(target);
844 
847  free(arm920t);
848 }
849 
850 COMMAND_HANDLER(arm920t_handle_read_cache_command)
851 {
852  int retval = ERROR_OK;
854  struct arm920t_common *arm920t = target_to_arm920(target);
855  struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
856  struct arm *arm = &arm7_9->arm;
857  uint32_t cp15c15;
858  uint32_t cp15_ctrl, cp15_ctrl_saved;
859  uint32_t regs[16];
860  uint32_t *regs_p[16];
861  uint32_t c15_c_d_ind, c15_c_i_ind;
862  int i;
863  FILE *output;
864  int segment, index_t;
865  struct reg *r;
866 
867  retval = arm920t_verify_pointer(CMD, arm920t);
868  if (retval != ERROR_OK)
869  return retval;
870 
871  if (CMD_ARGC != 1)
873 
874  output = fopen(CMD_ARGV[0], "w");
875  if (!output) {
876  LOG_DEBUG("error opening cache content file");
877  return ERROR_OK;
878  }
879 
880  for (i = 0; i < 16; i++)
881  regs_p[i] = &regs[i];
882 
883  /* disable MMU and Caches */
885  retval = jtag_execute_queue();
886  if (retval != ERROR_OK)
887  return retval;
888  cp15_ctrl_saved = cp15_ctrl;
889  cp15_ctrl &= ~(ARMV4_5_MMU_ENABLED
892 
893  /* read CP15 test state register */
896 
897  /* read DCache content */
898  fprintf(output, "DCache:\n");
899 
900  /* go through segments 0 to nsets (8 on ARM920T, 4 on ARM922T) */
901  for (segment = 0;
902  segment < arm920t->armv4_5_mmu.armv4_5_cache.d_u_size.nsets;
903  segment++) {
904  fprintf(output, "\nsegment: %i\n----------", segment);
905 
906  /* Ra: r0 = SBZ(31:8):segment(7:5):SBZ(4:0) */
907  regs[0] = 0x0 | (segment << 5);
909 
910  /* set interpret mode */
911  cp15c15 |= 0x1;
913  CP15PHYS_TESTSTATE, cp15c15);
914 
915  /* D CAM Read, loads current victim into C15.C.D.Ind */
917  ARMV4_5_MCR(15, 2, 0, 15, 6, 2), ARMV4_5_LDR(1, 0));
918 
919  /* read current victim */
921  CP15PHYS_DCACHE_IDX, &c15_c_d_ind);
922 
923  /* clear interpret mode */
924  cp15c15 &= ~0x1;
926  CP15PHYS_TESTSTATE, cp15c15);
927 
928  for (index_t = 0; index_t < 64; index_t++) {
929  /* Ra:
930  * r0 = index(31:26):SBZ(25:8):segment(7:5):SBZ(4:0)
931  */
932  regs[0] = 0x0 | (segment << 5) | (index_t << 26);
934 
935  /* set interpret mode */
936  cp15c15 |= 0x1;
938  CP15PHYS_TESTSTATE, cp15c15);
939 
940  /* Write DCache victim */
942  ARMV4_5_MCR(15, 0, 0, 9, 1, 0), ARMV4_5_LDR(1, 0));
943 
944  /* Read D RAM */
946  ARMV4_5_MCR(15, 2, 0, 15, 10, 2),
947  ARMV4_5_LDMIA(0, 0x1fe, 0, 0));
948 
949  /* Read D CAM */
951  ARMV4_5_MCR(15, 2, 0, 15, 6, 2),
952  ARMV4_5_LDR(9, 0));
953 
954  /* clear interpret mode */
955  cp15c15 &= ~0x1;
957  CP15PHYS_TESTSTATE, cp15c15);
958 
959  /* read D RAM and CAM content */
960  arm9tdmi_read_core_regs(target, 0x3fe, regs_p);
961  retval = jtag_execute_queue();
962  if (retval != ERROR_OK)
963  return retval;
964 
965  /* mask LFSR[6] */
966  regs[9] &= 0xfffffffe;
967  fprintf(output, "\nsegment: %i, index: %i, CAM: 0x%8.8"
968  PRIx32 ", content (%s):\n",
969  segment, index_t, regs[9],
970  (regs[9] & 0x10) ? "valid" : "invalid");
971 
972  for (i = 1; i < 9; i++) {
973  fprintf(output, "%i: 0x%8.8" PRIx32 "\n",
974  i-1, regs[i]);
975  }
976 
977  }
978 
979  /* Ra: r0 = index(31:26):SBZ(25:8):segment(7:5):SBZ(4:0) */
980  regs[0] = 0x0 | (segment << 5) | (c15_c_d_ind << 26);
982 
983  /* set interpret mode */
984  cp15c15 |= 0x1;
986  CP15PHYS_TESTSTATE, cp15c15);
987 
988  /* Write DCache victim */
990  ARMV4_5_MCR(15, 0, 0, 9, 1, 0), ARMV4_5_LDR(1, 0));
991 
992  /* clear interpret mode */
993  cp15c15 &= ~0x1;
995  CP15PHYS_TESTSTATE, cp15c15);
996  }
997 
998  /* read ICache content */
999  fprintf(output, "ICache:\n");
1000 
1001  /* go through segments 0 to nsets (8 on ARM920T, 4 on ARM922T) */
1002  for (segment = 0;
1003  segment < arm920t->armv4_5_mmu.armv4_5_cache.d_u_size.nsets;
1004  segment++) {
1005  fprintf(output, "segment: %i\n----------", segment);
1006 
1007  /* Ra: r0 = SBZ(31:8):segment(7:5):SBZ(4:0) */
1008  regs[0] = 0x0 | (segment << 5);
1010 
1011  /* set interpret mode */
1012  cp15c15 |= 0x1;
1014  CP15PHYS_TESTSTATE, cp15c15);
1015 
1016  /* I CAM Read, loads current victim into C15.C.I.Ind */
1018  ARMV4_5_MCR(15, 2, 0, 15, 5, 2), ARMV4_5_LDR(1, 0));
1019 
1020  /* read current victim */
1022  &c15_c_i_ind);
1023 
1024  /* clear interpret mode */
1025  cp15c15 &= ~0x1;
1027  CP15PHYS_TESTSTATE, cp15c15);
1028 
1029  for (index_t = 0; index_t < 64; index_t++) {
1030  /* Ra:
1031  * r0 = index(31:26):SBZ(25:8):segment(7:5):SBZ(4:0)
1032  */
1033  regs[0] = 0x0 | (segment << 5) | (index_t << 26);
1035 
1036  /* set interpret mode */
1037  cp15c15 |= 0x1;
1039  CP15PHYS_TESTSTATE, cp15c15);
1040 
1041  /* Write ICache victim */
1043  ARMV4_5_MCR(15, 0, 0, 9, 1, 1), ARMV4_5_LDR(1, 0));
1044 
1045  /* Read I RAM */
1047  ARMV4_5_MCR(15, 2, 0, 15, 9, 2),
1048  ARMV4_5_LDMIA(0, 0x1fe, 0, 0));
1049 
1050  /* Read I CAM */
1052  ARMV4_5_MCR(15, 2, 0, 15, 5, 2),
1053  ARMV4_5_LDR(9, 0));
1054 
1055  /* clear interpret mode */
1056  cp15c15 &= ~0x1;
1058  CP15PHYS_TESTSTATE, cp15c15);
1059 
1060  /* read I RAM and CAM content */
1061  arm9tdmi_read_core_regs(target, 0x3fe, regs_p);
1062  retval = jtag_execute_queue();
1063  if (retval != ERROR_OK)
1064  return retval;
1065 
1066  /* mask LFSR[6] */
1067  regs[9] &= 0xfffffffe;
1068  fprintf(output, "\nsegment: %i, index: %i, "
1069  "CAM: 0x%8.8" PRIx32 ", content (%s):\n",
1070  segment, index_t, regs[9],
1071  (regs[9] & 0x10) ? "valid" : "invalid");
1072 
1073  for (i = 1; i < 9; i++) {
1074  fprintf(output, "%i: 0x%8.8" PRIx32 "\n",
1075  i-1, regs[i]);
1076  }
1077  }
1078 
1079  /* Ra: r0 = index(31:26):SBZ(25:8):segment(7:5):SBZ(4:0) */
1080  regs[0] = 0x0 | (segment << 5) | (c15_c_d_ind << 26);
1082 
1083  /* set interpret mode */
1084  cp15c15 |= 0x1;
1086  CP15PHYS_TESTSTATE, cp15c15);
1087 
1088  /* Write ICache victim */
1090  ARMV4_5_MCR(15, 0, 0, 9, 1, 1), ARMV4_5_LDR(1, 0));
1091 
1092  /* clear interpret mode */
1093  cp15c15 &= ~0x1;
1095  CP15PHYS_TESTSTATE, cp15c15);
1096  }
1097 
1098  /* restore CP15 MMU and Cache settings */
1100 
1101  command_print(CMD, "cache content successfully output to %s",
1102  CMD_ARGV[0]);
1103 
1104  fclose(output);
1105 
1106  if (!is_arm_mode(arm->core_mode)) {
1107  LOG_ERROR("not a valid arm core mode - communication failure?");
1108  return ERROR_FAIL;
1109  }
1110 
1111  /* force writeback of the valid data */
1112  r = arm->core_cache->reg_list;
1113  r[0].dirty = r[0].valid;
1114  r[1].dirty = r[1].valid;
1115  r[2].dirty = r[2].valid;
1116  r[3].dirty = r[3].valid;
1117  r[4].dirty = r[4].valid;
1118  r[5].dirty = r[5].valid;
1119  r[6].dirty = r[6].valid;
1120  r[7].dirty = r[7].valid;
1121 
1122  r = arm_reg_current(arm, 8);
1123  r->dirty = r->valid;
1124 
1125  r = arm_reg_current(arm, 9);
1126  r->dirty = r->valid;
1127 
1128  return ERROR_OK;
1129 }
1130 
1131 COMMAND_HANDLER(arm920t_handle_read_mmu_command)
1132 {
1133  int retval = ERROR_OK;
1135  struct arm920t_common *arm920t = target_to_arm920(target);
1136  struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
1137  struct arm *arm = &arm7_9->arm;
1138  uint32_t cp15c15;
1139  uint32_t cp15_ctrl, cp15_ctrl_saved;
1140  uint32_t regs[16];
1141  uint32_t *regs_p[16];
1142  int i;
1143  FILE *output;
1144  uint32_t d_lockdown, i_lockdown;
1145  struct arm920t_tlb_entry d_tlb[64], i_tlb[64];
1146  int victim;
1147  struct reg *r;
1148 
1149  retval = arm920t_verify_pointer(CMD, arm920t);
1150  if (retval != ERROR_OK)
1151  return retval;
1152 
1153  if (CMD_ARGC != 1)
1155 
1156  output = fopen(CMD_ARGV[0], "w");
1157  if (!output) {
1158  LOG_DEBUG("error opening mmu content file");
1159  return ERROR_OK;
1160  }
1161 
1162  for (i = 0; i < 16; i++)
1163  regs_p[i] = &regs[i];
1164 
1165  /* disable MMU and Caches */
1167  retval = jtag_execute_queue();
1168  if (retval != ERROR_OK)
1169  return retval;
1170  cp15_ctrl_saved = cp15_ctrl;
1171  cp15_ctrl &= ~(ARMV4_5_MMU_ENABLED
1174 
1175  /* read CP15 test state register */
1177  retval = jtag_execute_queue();
1178  if (retval != ERROR_OK)
1179  return retval;
1180 
1181  /* prepare reading D TLB content
1182  * */
1183 
1184  /* set interpret mode */
1185  cp15c15 |= 0x1;
1187 
1188  /* Read D TLB lockdown */
1190  ARMV4_5_MRC(15, 0, 0, 10, 0, 0), ARMV4_5_LDR(1, 0));
1191 
1192  /* clear interpret mode */
1193  cp15c15 &= ~0x1;
1195 
1196  /* read D TLB lockdown stored to r1 */
1197  arm9tdmi_read_core_regs(target, 0x2, regs_p);
1198  retval = jtag_execute_queue();
1199  if (retval != ERROR_OK)
1200  return retval;
1201  d_lockdown = regs[1];
1202 
1203  for (victim = 0; victim < 64; victim += 8) {
1204  /* new lockdown value: base[31:26]:victim[25:20]:SBZ[19:1]:p[0]
1205  * base remains unchanged, victim goes through entries 0 to 63
1206  */
1207  regs[1] = (d_lockdown & 0xfc000000) | (victim << 20);
1209 
1210  /* set interpret mode */
1211  cp15c15 |= 0x1;
1213  CP15PHYS_TESTSTATE, cp15c15);
1214 
1215  /* Write D TLB lockdown */
1217  ARMV4_5_MCR(15, 0, 0, 10, 0, 0),
1218  ARMV4_5_STR(1, 0));
1219 
1220  /* Read D TLB CAM */
1222  ARMV4_5_MCR(15, 4, 0, 15, 6, 4),
1223  ARMV4_5_LDMIA(0, 0x3fc, 0, 0));
1224 
1225  /* clear interpret mode */
1226  cp15c15 &= ~0x1;
1228  CP15PHYS_TESTSTATE, cp15c15);
1229 
1230  /* read D TLB CAM content stored to r2-r9 */
1231  arm9tdmi_read_core_regs(target, 0x3fc, regs_p);
1232  retval = jtag_execute_queue();
1233  if (retval != ERROR_OK)
1234  return retval;
1235 
1236  for (i = 0; i < 8; i++)
1237  d_tlb[victim + i].cam = regs[i + 2];
1238  }
1239 
1240  for (victim = 0; victim < 64; victim++) {
1241  /* new lockdown value: base[31:26]:victim[25:20]:SBZ[19:1]:p[0]
1242  * base remains unchanged, victim goes through entries 0 to 63
1243  */
1244  regs[1] = (d_lockdown & 0xfc000000) | (victim << 20);
1246 
1247  /* set interpret mode */
1248  cp15c15 |= 0x1;
1250  CP15PHYS_TESTSTATE, cp15c15);
1251 
1252  /* Write D TLB lockdown */
1254  ARMV4_5_MCR(15, 0, 0, 10, 0, 0), ARMV4_5_STR(1, 0));
1255 
1256  /* Read D TLB RAM1 */
1258  ARMV4_5_MCR(15, 4, 0, 15, 10, 4), ARMV4_5_LDR(2, 0));
1259 
1260  /* Read D TLB RAM2 */
1262  ARMV4_5_MCR(15, 4, 0, 15, 2, 5), ARMV4_5_LDR(3, 0));
1263 
1264  /* clear interpret mode */
1265  cp15c15 &= ~0x1;
1267  CP15PHYS_TESTSTATE, cp15c15);
1268 
1269  /* read D TLB RAM content stored to r2 and r3 */
1270  arm9tdmi_read_core_regs(target, 0xc, regs_p);
1271  retval = jtag_execute_queue();
1272  if (retval != ERROR_OK)
1273  return retval;
1274 
1275  d_tlb[victim].ram1 = regs[2];
1276  d_tlb[victim].ram2 = regs[3];
1277  }
1278 
1279  /* restore D TLB lockdown */
1280  regs[1] = d_lockdown;
1282 
1283  /* Write D TLB lockdown */
1285  ARMV4_5_MCR(15, 0, 0, 10, 0, 0), ARMV4_5_STR(1, 0));
1286 
1287  /* prepare reading I TLB content
1288  * */
1289 
1290  /* set interpret mode */
1291  cp15c15 |= 0x1;
1293 
1294  /* Read I TLB lockdown */
1296  ARMV4_5_MRC(15, 0, 0, 10, 0, 1), ARMV4_5_LDR(1, 0));
1297 
1298  /* clear interpret mode */
1299  cp15c15 &= ~0x1;
1301 
1302  /* read I TLB lockdown stored to r1 */
1303  arm9tdmi_read_core_regs(target, 0x2, regs_p);
1304  retval = jtag_execute_queue();
1305  if (retval != ERROR_OK)
1306  return retval;
1307  i_lockdown = regs[1];
1308 
1309  for (victim = 0; victim < 64; victim += 8) {
1310  /* new lockdown value: base[31:26]:victim[25:20]:SBZ[19:1]:p[0]
1311  * base remains unchanged, victim goes through entries 0 to 63
1312  */
1313  regs[1] = (i_lockdown & 0xfc000000) | (victim << 20);
1315 
1316  /* set interpret mode */
1317  cp15c15 |= 0x1;
1319  CP15PHYS_TESTSTATE, cp15c15);
1320 
1321  /* Write I TLB lockdown */
1323  ARMV4_5_MCR(15, 0, 0, 10, 0, 1),
1324  ARMV4_5_STR(1, 0));
1325 
1326  /* Read I TLB CAM */
1328  ARMV4_5_MCR(15, 4, 0, 15, 5, 4),
1329  ARMV4_5_LDMIA(0, 0x3fc, 0, 0));
1330 
1331  /* clear interpret mode */
1332  cp15c15 &= ~0x1;
1334  CP15PHYS_TESTSTATE, cp15c15);
1335 
1336  /* read I TLB CAM content stored to r2-r9 */
1337  arm9tdmi_read_core_regs(target, 0x3fc, regs_p);
1338  retval = jtag_execute_queue();
1339  if (retval != ERROR_OK)
1340  return retval;
1341 
1342  for (i = 0; i < 8; i++)
1343  i_tlb[i + victim].cam = regs[i + 2];
1344  }
1345 
1346  for (victim = 0; victim < 64; victim++) {
1347  /* new lockdown value: base[31:26]:victim[25:20]:SBZ[19:1]:p[0]
1348  * base remains unchanged, victim goes through entries 0 to 63
1349  */
1350  regs[1] = (d_lockdown & 0xfc000000) | (victim << 20);
1352 
1353  /* set interpret mode */
1354  cp15c15 |= 0x1;
1356  CP15PHYS_TESTSTATE, cp15c15);
1357 
1358  /* Write I TLB lockdown */
1360  ARMV4_5_MCR(15, 0, 0, 10, 0, 1), ARMV4_5_STR(1, 0));
1361 
1362  /* Read I TLB RAM1 */
1364  ARMV4_5_MCR(15, 4, 0, 15, 9, 4), ARMV4_5_LDR(2, 0));
1365 
1366  /* Read I TLB RAM2 */
1368  ARMV4_5_MCR(15, 4, 0, 15, 1, 5), ARMV4_5_LDR(3, 0));
1369 
1370  /* clear interpret mode */
1371  cp15c15 &= ~0x1;
1373  CP15PHYS_TESTSTATE, cp15c15);
1374 
1375  /* read I TLB RAM content stored to r2 and r3 */
1376  arm9tdmi_read_core_regs(target, 0xc, regs_p);
1377  retval = jtag_execute_queue();
1378  if (retval != ERROR_OK)
1379  return retval;
1380 
1381  i_tlb[victim].ram1 = regs[2];
1382  i_tlb[victim].ram2 = regs[3];
1383  }
1384 
1385  /* restore I TLB lockdown */
1386  regs[1] = i_lockdown;
1388 
1389  /* Write I TLB lockdown */
1391  ARMV4_5_MCR(15, 0, 0, 10, 0, 1), ARMV4_5_STR(1, 0));
1392 
1393  /* restore CP15 MMU and Cache settings */
1395 
1396  /* output data to file */
1397  fprintf(output, "D TLB content:\n");
1398  for (i = 0; i < 64; i++) {
1399  fprintf(output, "%i: 0x%8.8" PRIx32 " 0x%8.8" PRIx32
1400  " 0x%8.8" PRIx32 " %s\n",
1401  i, d_tlb[i].cam, d_tlb[i].ram1, d_tlb[i].ram2,
1402  (d_tlb[i].cam & 0x20) ? "(valid)" : "(invalid)");
1403  }
1404 
1405  fprintf(output, "\n\nI TLB content:\n");
1406  for (i = 0; i < 64; i++) {
1407  fprintf(output, "%i: 0x%8.8" PRIx32 " 0x%8.8" PRIx32
1408  " 0x%8.8" PRIx32 " %s\n",
1409  i, i_tlb[i].cam, i_tlb[i].ram1, i_tlb[i].ram2,
1410  (i_tlb[i].cam & 0x20) ? "(valid)" : "(invalid)");
1411  }
1412 
1413  command_print(CMD, "mmu content successfully output to %s",
1414  CMD_ARGV[0]);
1415 
1416  fclose(output);
1417 
1418  if (!is_arm_mode(arm->core_mode)) {
1419  LOG_ERROR("not a valid arm core mode - communication failure?");
1420  return ERROR_FAIL;
1421  }
1422 
1423  /* force writeback of the valid data */
1424  r = arm->core_cache->reg_list;
1425  r[0].dirty = r[0].valid;
1426  r[1].dirty = r[1].valid;
1427  r[2].dirty = r[2].valid;
1428  r[3].dirty = r[3].valid;
1429  r[4].dirty = r[4].valid;
1430  r[5].dirty = r[5].valid;
1431  r[6].dirty = r[6].valid;
1432  r[7].dirty = r[7].valid;
1433 
1434  r = arm_reg_current(arm, 8);
1435  r->dirty = r->valid;
1436 
1437  r = arm_reg_current(arm, 9);
1438  r->dirty = r->valid;
1439 
1440  return ERROR_OK;
1441 }
1442 
1443 COMMAND_HANDLER(arm920t_handle_cp15_command)
1444 {
1445  int retval;
1447  struct arm920t_common *arm920t = target_to_arm920(target);
1448 
1449  retval = arm920t_verify_pointer(CMD, arm920t);
1450  if (retval != ERROR_OK)
1451  return retval;
1452 
1453  if (target->state != TARGET_HALTED) {
1454  command_print(CMD, "Error: target must be stopped for "
1455  "\"%s\" command", CMD_NAME);
1456  return ERROR_TARGET_NOT_HALTED;
1457  }
1458 
1459  /* one argument, read a register.
1460  * two arguments, write it.
1461  */
1462  if (CMD_ARGC >= 1) {
1463  int address;
1465 
1466  if (CMD_ARGC == 1) {
1467  uint32_t value;
1468  retval = arm920t_read_cp15_physical(target, address, &value);
1469  if (retval != ERROR_OK) {
1471  "couldn't access reg %i", address);
1472  return ERROR_OK;
1473  }
1474  retval = jtag_execute_queue();
1475  if (retval != ERROR_OK)
1476  return retval;
1477 
1478  command_print(CMD, "%i: %8.8" PRIx32,
1479  address, value);
1480  } else if (CMD_ARGC == 2) {
1481  uint32_t value;
1482  COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value);
1484  address, value);
1485  if (retval != ERROR_OK) {
1487  "couldn't access reg %i", address);
1488  /* REVISIT why lie? "return retval"? */
1489  return ERROR_OK;
1490  }
1491  command_print(CMD, "%i: %8.8" PRIx32,
1492  address, value);
1493  }
1494  }
1495 
1496  return ERROR_OK;
1497 }
1498 
1499 COMMAND_HANDLER(arm920t_handle_cache_info_command)
1500 {
1501  int retval;
1503  struct arm920t_common *arm920t = target_to_arm920(target);
1504 
1505  retval = arm920t_verify_pointer(CMD, arm920t);
1506  if (retval != ERROR_OK)
1507  return retval;
1508 
1510  &arm920t->armv4_5_mmu.armv4_5_cache);
1511 }
1512 
1513 
1514 static int arm920t_mrc(struct target *target, int cpnum,
1515  uint32_t op1, uint32_t op2,
1516  uint32_t crn, uint32_t crm,
1517  uint32_t *value)
1518 {
1519  if (cpnum != 15) {
1520  LOG_ERROR("Only cp15 is supported");
1521  return ERROR_FAIL;
1522  }
1523 
1524  /* read "to" r0 */
1526  ARMV4_5_MRC(cpnum, op1, 0, crn, crm, op2),
1527  0, value);
1528 }
1529 
1530 static int arm920t_mcr(struct target *target, int cpnum,
1531  uint32_t op1, uint32_t op2,
1532  uint32_t crn, uint32_t crm,
1533  uint32_t value)
1534 {
1535  if (cpnum != 15) {
1536  LOG_ERROR("Only cp15 is supported");
1537  return ERROR_FAIL;
1538  }
1539 
1540  /* write "from" r0 */
1542  ARMV4_5_MCR(cpnum, op1, 0, crn, crm, op2),
1543  0, value);
1544 }
1545 
1546 static const struct command_registration arm920t_exec_command_handlers[] = {
1547  {
1548  .name = "cp15",
1549  .handler = arm920t_handle_cp15_command,
1550  .mode = COMMAND_EXEC,
1551  .help = "display/modify cp15 register",
1552  .usage = "regnum [value]",
1553  },
1554  {
1555  .name = "cache_info",
1556  .handler = arm920t_handle_cache_info_command,
1557  .mode = COMMAND_EXEC,
1558  .usage = "",
1559  .help = "display information about target caches",
1560  },
1561  {
1562  .name = "read_cache",
1563  .handler = arm920t_handle_read_cache_command,
1564  .mode = COMMAND_EXEC,
1565  .help = "dump I/D cache content to file",
1566  .usage = "filename",
1567  },
1568  {
1569  .name = "read_mmu",
1570  .handler = arm920t_handle_read_mmu_command,
1571  .mode = COMMAND_EXEC,
1572  .help = "dump I/D mmu content to file",
1573  .usage = "filename",
1574  },
1576 };
1578  {
1580  },
1581  {
1582  .name = "arm920t",
1583  .mode = COMMAND_ANY,
1584  .help = "arm920t command group",
1585  .usage = "",
1587  },
1589 };
1590 
1592 struct target_type arm920t_target = {
1593  .name = "arm920t",
1594 
1595  .poll = arm7_9_poll,
1596  .arch_state = arm920t_arch_state,
1597 
1598  .target_request_data = arm7_9_target_request_data,
1599 
1600  .halt = arm7_9_halt,
1601  .resume = arm7_9_resume,
1602  .step = arm7_9_step,
1603 
1604  .assert_reset = arm7_9_assert_reset,
1605  .deassert_reset = arm7_9_deassert_reset,
1606  .soft_reset_halt = arm920t_soft_reset_halt,
1607 
1608  .get_gdb_arch = arm_get_gdb_arch,
1609  .get_gdb_reg_list = arm_get_gdb_reg_list,
1610 
1611  .read_memory = arm920t_read_memory,
1612  .write_memory = arm7_9_write_memory_opt,
1613  .read_phys_memory = arm920t_read_phys_memory,
1614  .write_phys_memory = arm920t_write_phys_memory,
1615  .mmu = arm920_mmu,
1616  .virt2phys = arm920_virt2phys,
1617 
1618  .checksum_memory = arm_checksum_memory,
1619  .blank_check_memory = arm_blank_check_memory,
1620 
1621  .run_algorithm = armv4_5_run_algorithm,
1622 
1623  .add_breakpoint = arm7_9_add_breakpoint,
1624  .remove_breakpoint = arm7_9_remove_breakpoint,
1625  .add_watchpoint = arm7_9_add_watchpoint,
1626  .remove_watchpoint = arm7_9_remove_watchpoint,
1627 
1628  .commands = arm920t_command_handlers,
1629  .target_create = arm920t_target_create,
1630  .init_target = arm9tdmi_init_target,
1631  .deinit_target = arm920t_deinit_target,
1632  .examine = arm7_9_examine,
1633  .check_reset = arm7_9_check_reset,
1634 };
int arm7_9_write_memory_opt(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
int arm7_9_examine(struct target *target)
Perform per-target setup that requires JTAG access.
void arm7_9_deinit(struct target *target)
int arm7_9_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
int arm7_9_add_breakpoint(struct target *target, struct breakpoint *breakpoint)
Add a breakpoint to an ARM7/9 target.
int arm7_9_assert_reset(struct target *target)
Asserts the reset (SRST) on an ARM7/9 target.
int arm7_9_poll(struct target *target)
Polls an ARM7/9 target for its current status.
int arm7_9_execute_sys_speed(struct target *target)
Restarts the target by sending a RESTART instruction and moving the JTAG state to IDLE.
int arm7_9_halt(struct target *target)
Halt an ARM7/9 target.
int arm7_9_remove_breakpoint(struct target *target, struct breakpoint *breakpoint)
Removes a breakpoint from an ARM7/9 target.
int arm7_9_remove_watchpoint(struct target *target, struct watchpoint *watchpoint)
Remove a watchpoint from an ARM7/9 target.
int arm7_9_deassert_reset(struct target *target)
Deassert the reset (SRST) signal on an ARM7/9 target.
int arm7_9_write_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
int arm7_9_target_request_data(struct target *target, uint32_t size, uint8_t *buffer)
Get some data from the ARM7/9 target.
int arm7_9_step(struct target *target, bool current, target_addr_t address, bool handle_breakpoints)
int arm7_9_add_watchpoint(struct target *target, struct watchpoint *watchpoint)
Add a watchpoint to an ARM7/9 target.
int arm7_9_check_reset(struct target *target)
int arm7_9_resume(struct target *target, bool current, target_addr_t address, bool handle_breakpoints, bool debug_execution)
static struct arm7_9_common * target_to_arm7_9(struct target *target)
static const struct command_registration arm920t_exec_command_handlers[]
Definition: arm920t.c:1546
static int arm920t_write_cp15_physical(struct target *target, int reg_addr, uint32_t value)
Definition: arm920t.c:123
int arm920t_post_debug_entry(struct target *target)
Definition: arm920t.c:399
#define CP15PHYS_ICACHE_IDX
Definition: arm920t.c:60
const struct command_registration arm920t_command_handlers[]
Definition: arm920t.c:1577
int arm920t_write_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
Writes a buffer, in the specified word size, with current MMU settings.
Definition: arm920t.c:588
static const char arm920_not[]
Definition: arm920t.c:497
int arm920t_disable_mmu_caches(struct target *target, int mmu, int d_u_cache, int i_cache)
Definition: arm920t.c:343
int arm920t_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
Reads a buffer, in the specified word size, with current MMU settings.
Definition: arm920t.c:556
int arm920t_soft_reset_halt(struct target *target)
Definition: arm920t.c:727
static int arm920t_mcr(struct target *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t crn, uint32_t crm, uint32_t value)
Definition: arm920t.c:1530
static int arm920t_read_cp15_interpreted(struct target *target, uint32_t cp15_opcode, uint32_t address, uint32_t *value)
Definition: arm920t.c:234
static void arm920t_deinit_target(struct target *target)
Definition: arm920t.c:840
static int arm920t_verify_pointer(struct command_invocation *cmd, struct arm920t_common *arm920t)
Definition: arm920t.c:499
int arm920t_get_ttb(struct target *target, uint32_t *result)
Definition: arm920t.c:327
static int arm920t_init_arch_info(struct target *target, struct arm920t_common *arm920t, struct jtag_tap *tap)
Definition: arm920t.c:794
static int arm920t_target_create(struct target *target)
Definition: arm920t.c:832
COMMAND_HANDLER(arm920t_handle_read_cache_command)
Definition: arm920t.c:850
void arm920t_pre_restore_context(struct target *target)
Definition: arm920t.c:474
static int arm920t_write_phys_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
Definition: arm920t.c:577
static int arm920_mmu(struct target *target, bool *enabled)
Definition: arm920t.c:529
#define CP15PHYS_CACHETYPE
Definition: arm920t.c:59
#define CP15PHYS_TESTSTATE
Definition: arm920t.c:67
int arm920t_enable_mmu_caches(struct target *target, int mmu, int d_u_cache, int i_cache)
Definition: arm920t.c:371
int arm920t_arch_state(struct target *target)
Logs summary of ARM920 state for a halted target.
Definition: arm920t.c:511
static int arm920t_read_phys_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
Definition: arm920t.c:567
static int arm920t_write_cp15_interpreted(struct target *target, uint32_t cp15_opcode, uint32_t value, uint32_t address)
Definition: arm920t.c:283
struct target_type arm920t_target
Holds methods for ARM920 targets.
Definition: arm920t.c:1592
static int arm920t_mrc(struct target *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t crn, uint32_t crm, uint32_t *value)
Definition: arm920t.c:1514
static int arm920_virt2phys(struct target *target, target_addr_t virt, target_addr_t *phys)
Definition: arm920t.c:540
static int arm920t_execute_cp15(struct target *target, uint32_t cp15_opcode, uint32_t arm_opcode)
Definition: arm920t.c:178
static int arm920t_read_cp15_physical(struct target *target, int reg_addr, uint32_t *value)
Definition: arm920t.c:71
#define CP15PHYS_DCACHE_IDX
Definition: arm920t.c:61
#define CP15PHYS_CTRL
Definition: arm920t.c:65
#define ARM920T_COMMON_MAGIC
Definition: arm920t.h:14
static struct arm920t_common * target_to_arm920(struct target *target)
Definition: arm920t.h:29
int arm9tdmi_init_arch_info(struct target *target, struct arm7_9_common *arm7_9, struct jtag_tap *tap)
Definition: arm9tdmi.c:711
void arm9tdmi_read_core_regs(struct target *target, uint32_t mask, uint32_t *core_regs[16])
Definition: arm9tdmi.c:352
int arm9tdmi_init_target(struct command_context *cmd_ctx, struct target *target)
Definition: arm9tdmi.c:703
const struct command_registration arm9tdmi_command_handlers[]
Definition: arm9tdmi.c:873
void arm9tdmi_write_core_regs(struct target *target, uint32_t mask, uint32_t core_regs[16])
Definition: arm9tdmi.c:494
int arm9tdmi_clock_out(struct arm_jtag *jtag_info, uint32_t instr, uint32_t out, uint32_t *in, int sysspeed)
Definition: arm9tdmi.c:124
int arm_blank_check_memory(struct target *target, struct target_memory_check_block *blocks, int num_blocks, uint8_t erased_value)
Runs ARM code in the target to check whether a memory block holds all ones.
Definition: armv4_5.c:1686
struct reg * arm_reg_current(struct arm *arm, unsigned int regnum)
Returns handle to the register currently mapped to a given number.
Definition: armv4_5.c:516
int arm_arch_state(struct target *target)
Definition: armv4_5.c:796
bool is_arm_mode(unsigned int psr_mode)
Return true iff the parameter denotes a valid ARM processor mode.
Definition: armv4_5.c:182
int arm_checksum_memory(struct target *target, target_addr_t address, uint32_t count, uint32_t *checksum)
Runs ARM code in the target to calculate a CRC32 checksum.
Definition: armv4_5.c:1613
const char * arm_get_gdb_arch(const struct target *target)
Definition: armv4_5.c:1281
int arm_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
Definition: armv4_5.c:1286
void arm_free_reg_cache(struct arm *arm)
Definition: armv4_5.c:775
static struct arm * target_to_arm(const struct target *target)
Convert target handle to generic ARM target state handle.
Definition: arm.h:261
void arm_set_cpsr(struct arm *arm, uint32_t cpsr)
Configures host-side ARM records to reflect the specified CPSR.
Definition: armv4_5.c:452
int armv4_5_run_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, target_addr_t entry_point, target_addr_t exit_point, unsigned int timeout_ms, void *arch_info)
Definition: armv4_5.c:1587
static int arm_jtag_scann(struct arm_jtag *jtag_info, uint32_t new_scan_chain, enum tap_state end_state)
Definition: arm_jtag.h:43
static int arm_jtag_set_instr(struct jtag_tap *tap, uint32_t new_instr, void *no_verify_capture, enum tap_state end_state)
Definition: arm_jtag.h:31
static void arm_le_to_h_u32(jtag_callback_data_t arg)
Definition: arm_jtag.h:63
Macros used to generate various ARM or Thumb opcodes.
#define ARMV4_5_LDMIA(rn, list, s, w)
Definition: arm_opcodes.h:42
#define ARMV4_5_MRC(cp, op1, rd, crn, crm, op2)
Definition: arm_opcodes.h:186
#define ARMV4_5_LDR(rd, rn)
Definition: arm_opcodes.h:64
#define ARMV4_5_MCR(cp, op1, rd, crn, crm, op2)
Definition: arm_opcodes.h:209
#define ARMV4_5_STR(rd, rn)
Definition: arm_opcodes.h:58
#define ARMV4_5_NOP
Definition: arm_opcodes.h:46
int armv4_5_identify_cache(uint32_t cache_type_reg, struct armv4_5_cache_common *cache)
Definition: armv4_5_cache.c:15
int armv4_5_handle_cache_info_command(struct command_invocation *cmd, struct armv4_5_cache_common *armv4_5_cache)
Definition: armv4_5_cache.c:68
@ ARMV4_5_D_U_CACHE_ENABLED
Definition: armv4_5_cache.h:40
@ ARMV4_5_I_CACHE_ENABLED
Definition: armv4_5_cache.h:41
int armv4_5_mmu_read_physical(struct target *target, struct armv4_5_mmu_common *armv4_5_mmu, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer)
Definition: armv4_5_mmu.c:104
int armv4_5_mmu_write_physical(struct target *target, struct armv4_5_mmu_common *armv4_5_mmu, uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
Definition: armv4_5_mmu.c:134
int armv4_5_mmu_translate_va(struct target *target, struct armv4_5_mmu_common *armv4_5_mmu, uint32_t va, uint32_t *cb, uint32_t *val)
Definition: armv4_5_mmu.c:16
@ ARMV4_5_MMU_ENABLED
Definition: armv4_5_mmu.h:40
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
void command_print(struct command_invocation *cmd, const char *format,...)
Definition: command.c:375
#define CMD
Use this macro to access the command being handled, rather than accessing the variable directly.
Definition: command.h:141
#define CMD_NAME
Use this macro to access the name of the command being handled, rather than accessing the variable di...
Definition: command.h:166
#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 COMMAND_PARSE_NUMBER(type, in, out)
parses the string in into out as a type, or prints a command error and passes the error code to the c...
Definition: command.h:440
#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_ANY
Definition: command.h:42
@ COMMAND_EXEC
Definition: command.h:40
uint64_t buffer
Pointer to data buffer to send over SPI.
Definition: dw-spi-helper.h:0
uint32_t size
Size of dw_spi_transaction::buffer.
Definition: dw-spi-helper.h:4
uint32_t address
Starting address. Sector aligned.
Definition: dw-spi-helper.h:0
int embeddedice_read_reg(struct reg *reg)
Queue a read for an EmbeddedICE register into the register cache, not checking the value read.
Definition: embeddedice.c:464
@ EICE_DBG_STAT
Definition: embeddedice.h:21
@ EICE_DBG_STATUS_DBGACK
Definition: embeddedice.h:53
static uint16_t output
Definition: ftdi.c:119
int jtag_execute_queue(void)
For software FIFO implementations, the queued commands can be executed during this call or earlier.
Definition: jtag/core.c:1050
void jtag_add_dr_scan(struct jtag_tap *active, int in_num_fields, const struct scan_field *in_fields, enum tap_state state)
Generate a DR SCAN using the fields passed to the function.
Definition: jtag/core.c:457
void jtag_add_callback(jtag_callback1_t f, jtag_callback_data_t data0)
A simpler version of jtag_add_callback4().
@ TAP_IDLE
Definition: jtag.h:53
intptr_t jtag_callback_data_t
Defines the type of data passed to the jtag_callback_t interface.
Definition: jtag.h:336
static const struct @110 regs[]
int debug_level
Definition: log.c:47
void alive_sleep(uint64_t ms)
Definition: log.c:468
void keep_alive(void)
Definition: log.c:427
#define LOG_USER(expr ...)
Definition: log.h:136
#define ERROR_FAIL
Definition: log.h:174
#define LOG_TARGET_ERROR(target, fmt_str,...)
Definition: log.h:162
#define LOG_ERROR(expr ...)
Definition: log.h:133
#define LOG_DEBUG(expr ...)
Definition: log.h:110
#define ERROR_OK
Definition: log.h:168
static const char * str_enabled_disabled(bool value)
Structure for items that are common between both ARM7 and ARM9 targets.
Definition: arm7_9_common.h:28
struct arm arm
Definition: arm7_9_common.h:31
bool has_single_step
Definition: arm7_9_common.h:51
int(* write_memory)(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
Variant specific memory write function that does not dispatch to bulk_write_memory.
struct arm_jtag jtag_info
JTAG information for target.
Definition: arm7_9_common.h:33
struct reg_cache * eice_cache
Embedded ICE register cache.
Definition: arm7_9_common.h:34
int(* post_debug_entry)(struct target *target)
Callback function called after entering debug mode.
void(* pre_restore_context)(struct target *target)
Callback function called before restoring the processor context.
int preserve_cache
Definition: arm920t.h:26
uint32_t cp15_control_reg
Definition: arm920t.h:21
unsigned int common_magic
Definition: arm920t.h:17
uint32_t i_far
Definition: arm920t.h:25
uint32_t d_fsr
Definition: arm920t.h:22
uint32_t i_fsr
Definition: arm920t.h:23
struct arm7_9_common arm7_9_common
Definition: arm920t.h:19
uint32_t d_far
Definition: arm920t.h:24
struct armv4_5_mmu_common armv4_5_mmu
Definition: arm920t.h:20
Definition: arm920t.h:39
uint32_t ram2
Definition: arm920t.h:42
uint32_t ram1
Definition: arm920t.h:41
uint32_t intest_instr
Definition: arm_jtag.h:24
struct jtag_tap * tap
Definition: arm_jtag.h:18
Represents a generic ARM core, with standard application registers.
Definition: arm.h:175
int(* mrc)(struct target *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t crn, uint32_t crm, uint32_t *value)
Read coprocessor register.
Definition: arm.h:230
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
struct reg_cache * core_cache
Definition: arm.h:178
int(* mcr)(struct target *target, int cpnum, uint32_t op1, uint32_t op2, uint32_t crn, uint32_t crm, uint32_t value)
Write coprocessor register.
Definition: arm.h:241
struct armv4_5_cachesize d_u_size
Definition: armv4_5_cache.h:25
int(* write_memory)(struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
Definition: armv4_5_mmu.h:18
int(* read_memory)(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
Definition: armv4_5_mmu.h:17
int(* get_ttb)(struct target *target, uint32_t *result)
Definition: armv4_5_mmu.h:16
int(* enable_mmu_caches)(struct target *target, int mmu, int d_u_cache, int i_cache)
Definition: armv4_5_mmu.h:21
int(* disable_mmu_caches)(struct target *target, int mmu, int d_u_cache, int i_cache)
Definition: armv4_5_mmu.h:20
struct armv4_5_cache_common armv4_5_cache
Definition: armv4_5_mmu.h:22
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
const struct command_registration * chain
If non-NULL, the commands in chain will be registered in the same context and scope of this registrat...
Definition: command.h:247
Definition: jtag.h:101
struct reg * reg_list
Definition: register.h:147
Definition: register.h:111
bool valid
Definition: register.h:126
uint8_t * value
Definition: register.h:122
bool dirty
Definition: register.h:124
This structure defines a single scan field in the scan.
Definition: jtag.h:87
uint8_t * in_value
A pointer to a 32-bit memory location for data scanned out.
Definition: jtag.h:93
const uint8_t * out_value
A pointer to value to be scanned into the device.
Definition: jtag.h:91
unsigned int num_bits
The number of bits this field specifies.
Definition: jtag.h:89
This holds methods shared between all instances of a given target type.
Definition: target_type.h:26
const char * name
Name of this type of target.
Definition: target_type.h:31
Definition: target.h:119
struct jtag_tap * tap
Definition: target.h:122
enum target_state state
Definition: target.h:160
Definition: psoc6.c:83
int target_call_event_callbacks(struct target *target, enum target_event event)
Definition: target.c:1774
int target_halt(struct target *target)
Definition: target.c:516
int target_read_memory(struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
Read count items of size bytes from the memory of target at the address given.
Definition: target.c:1247
struct target * get_current_target(struct command_context *cmd_ctx)
Definition: target.c:467
#define ERROR_TARGET_NOT_HALTED
Definition: target.h:786
#define ERROR_TARGET_INVALID
Definition: target.h:783
@ TARGET_EVENT_HALTED
Definition: target.h:255
@ TARGET_HALTED
Definition: target.h:58
#define ERROR_TARGET_TIMEOUT
Definition: target.h:785
int64_t timeval_ms(void)
uint64_t target_addr_t
Definition: types.h:335
#define NULL
Definition: usb.h:16
uint8_t cmd
Definition: vdebug.c:1
uint8_t count[4]
Definition: vdebug.c:22