1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
5 * Copyright (C) 2008 by Spencer Oliver *
6 * spen@spen-soft.co.uk *
8 * Copyright (C) 2008 by Oyvind Harboe *
9 * oyvind.harboe@zylin.com *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License for more details. *
21 * You should have received a copy of the GNU General Public License *
22 * along with this program; if not, write to the *
23 * Free Software Foundation, Inc., *
24 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 ***************************************************************************/
31 #include "arm_disassembler.h"
32 #include "binarybuffer.h"
35 struct bitfield_desc armv4_5_psr_bitfield_desc[] =
51 char* armv4_5_core_reg_list[] =
53 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13_usr", "lr_usr", "pc",
55 "r8_fiq", "r9_fiq", "r10_fiq", "r11_fiq", "r12_fiq", "r13_fiq", "lr_fiq",
65 "cpsr", "spsr_fiq", "spsr_irq", "spsr_svc", "spsr_abt", "spsr_und"
68 char * armv4_5_mode_strings_list[] =
70 "Illegal mode value", "User", "FIQ", "IRQ", "Supervisor", "Abort", "Undefined", "System"
73 /* Hack! Yuk! allow -1 index, which simplifies codepaths elsewhere in the code */
74 char** armv4_5_mode_strings = armv4_5_mode_strings_list + 1;
76 char* armv4_5_state_strings[] =
78 "ARM", "Thumb", "Jazelle"
81 int armv4_5_core_reg_arch_type = -1;
83 struct armv4_5_core_reg armv4_5_core_reg_list_arch_info[] =
85 {0, ARMV4_5_MODE_ANY, NULL, NULL},
86 {1, ARMV4_5_MODE_ANY, NULL, NULL},
87 {2, ARMV4_5_MODE_ANY, NULL, NULL},
88 {3, ARMV4_5_MODE_ANY, NULL, NULL},
89 {4, ARMV4_5_MODE_ANY, NULL, NULL},
90 {5, ARMV4_5_MODE_ANY, NULL, NULL},
91 {6, ARMV4_5_MODE_ANY, NULL, NULL},
92 {7, ARMV4_5_MODE_ANY, NULL, NULL},
93 {8, ARMV4_5_MODE_ANY, NULL, NULL},
94 {9, ARMV4_5_MODE_ANY, NULL, NULL},
95 {10, ARMV4_5_MODE_ANY, NULL, NULL},
96 {11, ARMV4_5_MODE_ANY, NULL, NULL},
97 {12, ARMV4_5_MODE_ANY, NULL, NULL},
98 {13, ARMV4_5_MODE_USR, NULL, NULL},
99 {14, ARMV4_5_MODE_USR, NULL, NULL},
100 {15, ARMV4_5_MODE_ANY, NULL, NULL},
102 {8, ARMV4_5_MODE_FIQ, NULL, NULL},
103 {9, ARMV4_5_MODE_FIQ, NULL, NULL},
104 {10, ARMV4_5_MODE_FIQ, NULL, NULL},
105 {11, ARMV4_5_MODE_FIQ, NULL, NULL},
106 {12, ARMV4_5_MODE_FIQ, NULL, NULL},
107 {13, ARMV4_5_MODE_FIQ, NULL, NULL},
108 {14, ARMV4_5_MODE_FIQ, NULL, NULL},
110 {13, ARMV4_5_MODE_IRQ, NULL, NULL},
111 {14, ARMV4_5_MODE_IRQ, NULL, NULL},
113 {13, ARMV4_5_MODE_SVC, NULL, NULL},
114 {14, ARMV4_5_MODE_SVC, NULL, NULL},
116 {13, ARMV4_5_MODE_ABT, NULL, NULL},
117 {14, ARMV4_5_MODE_ABT, NULL, NULL},
119 {13, ARMV4_5_MODE_UND, NULL, NULL},
120 {14, ARMV4_5_MODE_UND, NULL, NULL},
122 {16, ARMV4_5_MODE_ANY, NULL, NULL},
123 {16, ARMV4_5_MODE_FIQ, NULL, NULL},
124 {16, ARMV4_5_MODE_IRQ, NULL, NULL},
125 {16, ARMV4_5_MODE_SVC, NULL, NULL},
126 {16, ARMV4_5_MODE_ABT, NULL, NULL},
127 {16, ARMV4_5_MODE_UND, NULL, NULL}
130 /* map core mode (USR, FIQ, ...) and register number to indizes into the register cache */
131 int armv4_5_core_reg_map[7][17] =
134 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 31
137 0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, 20, 21, 22, 15, 32
140 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 23, 24, 15, 33
143 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 25, 26, 15, 34
146 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 27, 28, 15, 35
149 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 29, 30, 15, 36
152 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 31
156 uint8_t armv4_5_gdb_dummy_fp_value[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
158 reg_t armv4_5_gdb_dummy_fp_reg =
160 "GDB dummy floating-point register", armv4_5_gdb_dummy_fp_value, 0, 1, 96, NULL, 0, NULL, 0
163 uint8_t armv4_5_gdb_dummy_fps_value[] = {0, 0, 0, 0};
165 reg_t armv4_5_gdb_dummy_fps_reg =
167 "GDB dummy floating-point status register", armv4_5_gdb_dummy_fps_value, 0, 1, 32, NULL, 0, NULL, 0
170 int armv4_5_get_core_reg(reg_t *reg)
173 struct armv4_5_core_reg *armv4_5 = reg->arch_info;
174 target_t *target = armv4_5->target;
176 if (target->state != TARGET_HALTED)
178 LOG_ERROR("Target not halted");
179 return ERROR_TARGET_NOT_HALTED;
182 /* retval = armv4_5->armv4_5_common->full_context(target); */
183 retval = armv4_5->armv4_5_common->read_core_reg(target, armv4_5->num, armv4_5->mode);
188 int armv4_5_set_core_reg(reg_t *reg, uint8_t *buf)
190 struct armv4_5_core_reg *armv4_5 = reg->arch_info;
191 target_t *target = armv4_5->target;
192 struct armv4_5_common_s *armv4_5_target = target_to_armv4_5(target);
193 uint32_t value = buf_get_u32(buf, 0, 32);
195 if (target->state != TARGET_HALTED)
197 return ERROR_TARGET_NOT_HALTED;
200 if (reg == &armv4_5_target->core_cache->reg_list[ARMV4_5_CPSR])
204 /* T bit should be set */
205 if (armv4_5_target->core_state == ARMV4_5_STATE_ARM)
207 /* change state to Thumb */
208 LOG_DEBUG("changing to Thumb state");
209 armv4_5_target->core_state = ARMV4_5_STATE_THUMB;
214 /* T bit should be cleared */
215 if (armv4_5_target->core_state == ARMV4_5_STATE_THUMB)
217 /* change state to ARM */
218 LOG_DEBUG("changing to ARM state");
219 armv4_5_target->core_state = ARMV4_5_STATE_ARM;
223 if (armv4_5_target->core_mode != (enum armv4_5_mode)(value & 0x1f))
225 LOG_DEBUG("changing ARM core mode to '%s'", armv4_5_mode_strings[armv4_5_mode_to_number(value & 0x1f)]);
226 armv4_5_target->core_mode = value & 0x1f;
227 armv4_5_target->write_core_reg(target, 16, ARMV4_5_MODE_ANY, value);
231 buf_set_u32(reg->value, 0, 32, value);
238 int armv4_5_invalidate_core_regs(target_t *target)
240 struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target);
243 for (i = 0; i < 37; i++)
245 armv4_5->core_cache->reg_list[i].valid = 0;
246 armv4_5->core_cache->reg_list[i].dirty = 0;
252 struct reg_cache* armv4_5_build_reg_cache(target_t *target, struct arm *armv4_5_common)
255 struct reg_cache *cache = malloc(sizeof(struct reg_cache));
256 reg_t *reg_list = malloc(sizeof(reg_t) * num_regs);
257 struct armv4_5_core_reg *arch_info = malloc(sizeof(struct armv4_5_core_reg) * num_regs);
260 cache->name = "arm v4/5 registers";
262 cache->reg_list = reg_list;
263 cache->num_regs = num_regs;
265 if (armv4_5_core_reg_arch_type == -1)
266 armv4_5_core_reg_arch_type = register_reg_arch_type(armv4_5_get_core_reg, armv4_5_set_core_reg);
268 register_init_dummy(&armv4_5_gdb_dummy_fp_reg);
269 register_init_dummy(&armv4_5_gdb_dummy_fps_reg);
271 for (i = 0; i < 37; i++)
273 arch_info[i] = armv4_5_core_reg_list_arch_info[i];
274 arch_info[i].target = target;
275 arch_info[i].armv4_5_common = armv4_5_common;
276 reg_list[i].name = armv4_5_core_reg_list[i];
277 reg_list[i].size = 32;
278 reg_list[i].value = calloc(1, 4);
279 reg_list[i].dirty = 0;
280 reg_list[i].valid = 0;
281 reg_list[i].bitfield_desc = NULL;
282 reg_list[i].num_bitfields = 0;
283 reg_list[i].arch_type = armv4_5_core_reg_arch_type;
284 reg_list[i].arch_info = &arch_info[i];
290 int armv4_5_arch_state(struct target_s *target)
292 struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target);
294 if (armv4_5->common_magic != ARMV4_5_COMMON_MAGIC)
296 LOG_ERROR("BUG: called for a non-ARMv4/5 target");
300 LOG_USER("target halted in %s state due to %s, current mode: %s\ncpsr: 0x%8.8" PRIx32 " pc: 0x%8.8" PRIx32 "",
301 armv4_5_state_strings[armv4_5->core_state],
302 Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason)->name,
303 armv4_5_mode_strings[armv4_5_mode_to_number(armv4_5->core_mode)],
304 buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32),
305 buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32));
310 COMMAND_HANDLER(handle_armv4_5_reg_command)
315 target_t *target = get_current_target(cmd_ctx);
316 struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target);
318 if (armv4_5->common_magic != ARMV4_5_COMMON_MAGIC)
320 command_print(cmd_ctx, "current target isn't an ARMV4/5 target");
324 if (target->state != TARGET_HALTED)
326 command_print(cmd_ctx, "error: target must be halted for register accesses");
330 if (armv4_5_mode_to_number(armv4_5->core_mode)==-1)
333 for (num = 0; num <= 15; num++)
336 for (mode = 0; mode < 6; mode++)
338 if (!ARMV4_5_CORE_REG_MODENUM(armv4_5->core_cache, mode, num).valid)
340 armv4_5->full_context(target);
342 output_len += snprintf(output + output_len,
344 "%8s: %8.8" PRIx32 " ",
345 ARMV4_5_CORE_REG_MODENUM(armv4_5->core_cache, mode, num).name,
346 buf_get_u32(ARMV4_5_CORE_REG_MODENUM(armv4_5->core_cache, mode, num).value, 0, 32));
348 command_print(cmd_ctx, "%s", output);
350 command_print(cmd_ctx,
351 " cpsr: %8.8" PRIx32 " spsr_fiq: %8.8" PRIx32 " spsr_irq: %8.8" PRIx32 " spsr_svc: %8.8" PRIx32 " spsr_abt: %8.8" PRIx32 " spsr_und: %8.8" PRIx32 "",
352 buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32),
353 buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_SPSR_FIQ].value, 0, 32),
354 buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_SPSR_IRQ].value, 0, 32),
355 buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_SPSR_SVC].value, 0, 32),
356 buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_SPSR_ABT].value, 0, 32),
357 buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_SPSR_UND].value, 0, 32));
362 COMMAND_HANDLER(handle_armv4_5_core_state_command)
364 target_t *target = get_current_target(cmd_ctx);
365 struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target);
367 if (armv4_5->common_magic != ARMV4_5_COMMON_MAGIC)
369 command_print(cmd_ctx, "current target isn't an ARMV4/5 target");
375 if (strcmp(args[0], "arm") == 0)
377 armv4_5->core_state = ARMV4_5_STATE_ARM;
379 if (strcmp(args[0], "thumb") == 0)
381 armv4_5->core_state = ARMV4_5_STATE_THUMB;
385 command_print(cmd_ctx, "core state: %s", armv4_5_state_strings[armv4_5->core_state]);
390 COMMAND_HANDLER(handle_armv4_5_disassemble_command)
392 int retval = ERROR_OK;
393 target_t *target = get_current_target(cmd_ctx);
394 struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target);
398 struct arm_instruction cur_instruction;
400 uint16_t thumb_opcode;
403 if (armv4_5->common_magic != ARMV4_5_COMMON_MAGIC)
405 command_print(cmd_ctx, "current target isn't an ARMV4/5 target");
411 if (strcmp(args[2], "thumb") != 0)
416 COMMAND_PARSE_NUMBER(int, args[1], count);
419 COMMAND_PARSE_NUMBER(u32, args[0], address);
420 if (address & 0x01) {
422 command_print(cmd_ctx, "Disassemble as Thumb");
430 command_print(cmd_ctx,
431 "usage: armv4_5 disassemble <address> [<count> ['thumb']]");
435 for (i = 0; i < count; i++)
439 if ((retval = target_read_u16(target, address, &thumb_opcode)) != ERROR_OK)
443 if ((retval = thumb_evaluate_opcode(thumb_opcode, address, &cur_instruction)) != ERROR_OK)
449 if ((retval = target_read_u32(target, address, &opcode)) != ERROR_OK)
453 if ((retval = arm_evaluate_opcode(opcode, address, &cur_instruction)) != ERROR_OK)
458 command_print(cmd_ctx, "%s", cur_instruction.text);
459 address += (thumb) ? 2 : 4;
465 int armv4_5_register_commands(struct command_context_s *cmd_ctx)
467 command_t *armv4_5_cmd;
469 armv4_5_cmd = register_command(cmd_ctx, NULL, "armv4_5",
471 "armv4/5 specific commands");
473 register_command(cmd_ctx, armv4_5_cmd, "reg",
474 handle_armv4_5_reg_command, COMMAND_EXEC,
475 "display ARM core registers");
476 register_command(cmd_ctx, armv4_5_cmd, "core_state",
477 handle_armv4_5_core_state_command, COMMAND_EXEC,
478 "display/change ARM core state <arm | thumb>");
479 register_command(cmd_ctx, armv4_5_cmd, "disassemble",
480 handle_armv4_5_disassemble_command, COMMAND_EXEC,
481 "disassemble instructions <address> [<count> ['thumb']]");
486 int armv4_5_get_gdb_reg_list(target_t *target, reg_t **reg_list[], int *reg_list_size)
488 struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target);
491 if (armv4_5_mode_to_number(armv4_5->core_mode)==-1)
495 *reg_list = malloc(sizeof(reg_t*) * (*reg_list_size));
497 for (i = 0; i < 16; i++)
499 (*reg_list)[i] = &ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5->core_mode, i);
502 for (i = 16; i < 24; i++)
504 (*reg_list)[i] = &armv4_5_gdb_dummy_fp_reg;
507 (*reg_list)[24] = &armv4_5_gdb_dummy_fps_reg;
508 (*reg_list)[25] = &armv4_5->core_cache->reg_list[ARMV4_5_CPSR];
513 /* wait for execution to complete and check exit point */
514 static int armv4_5_run_algorithm_completion(struct target_s *target, uint32_t exit_point, int timeout_ms, void *arch_info)
517 struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target);
519 if ((retval = target_wait_state(target, TARGET_HALTED, timeout_ms)) != ERROR_OK)
523 if (target->state != TARGET_HALTED)
525 if ((retval = target_halt(target)) != ERROR_OK)
527 if ((retval = target_wait_state(target, TARGET_HALTED, 500)) != ERROR_OK)
531 return ERROR_TARGET_TIMEOUT;
534 /* fast exit: ARMv5+ code can use BKPT */
535 if (exit_point && buf_get_u32(armv4_5->core_cache->reg_list[15].value,
536 0, 32) != exit_point)
538 LOG_WARNING("target reentered debug state, but not at the desired exit point: 0x%4.4" PRIx32 "",
539 buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32));
540 return ERROR_TARGET_TIMEOUT;
546 int armv4_5_run_algorithm_inner(struct target_s *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, uint32_t entry_point, uint32_t exit_point, int timeout_ms, void *arch_info, int (*run_it)(struct target_s *target, uint32_t exit_point, int timeout_ms, void *arch_info))
548 struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target);
549 struct armv4_5_algorithm *armv4_5_algorithm_info = arch_info;
550 enum armv4_5_state core_state = armv4_5->core_state;
551 enum armv4_5_mode core_mode = armv4_5->core_mode;
552 uint32_t context[17];
554 int exit_breakpoint_size = 0;
556 int retval = ERROR_OK;
557 LOG_DEBUG("Running algorithm");
559 if (armv4_5_algorithm_info->common_magic != ARMV4_5_COMMON_MAGIC)
561 LOG_ERROR("current target isn't an ARMV4/5 target");
562 return ERROR_TARGET_INVALID;
565 if (target->state != TARGET_HALTED)
567 LOG_WARNING("target not halted");
568 return ERROR_TARGET_NOT_HALTED;
571 if (armv4_5_mode_to_number(armv4_5->core_mode)==-1)
574 /* armv5 and later can terminate with BKPT instruction; less overhead */
575 if (!exit_point && armv4_5->is_armv4)
577 LOG_ERROR("ARMv4 target needs HW breakpoint location");
581 for (i = 0; i <= 16; i++)
583 if (!ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5_algorithm_info->core_mode, i).valid)
584 armv4_5->read_core_reg(target, i, armv4_5_algorithm_info->core_mode);
585 context[i] = buf_get_u32(ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5_algorithm_info->core_mode, i).value, 0, 32);
587 cpsr = buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32);
589 for (i = 0; i < num_mem_params; i++)
591 if ((retval = target_write_buffer(target, mem_params[i].address, mem_params[i].size, mem_params[i].value)) != ERROR_OK)
597 for (i = 0; i < num_reg_params; i++)
599 reg_t *reg = register_get_by_name(armv4_5->core_cache, reg_params[i].reg_name, 0);
602 LOG_ERROR("BUG: register '%s' not found", reg_params[i].reg_name);
606 if (reg->size != reg_params[i].size)
608 LOG_ERROR("BUG: register '%s' size doesn't match reg_params[i].size", reg_params[i].reg_name);
612 if ((retval = armv4_5_set_core_reg(reg, reg_params[i].value)) != ERROR_OK)
618 armv4_5->core_state = armv4_5_algorithm_info->core_state;
619 if (armv4_5->core_state == ARMV4_5_STATE_ARM)
620 exit_breakpoint_size = 4;
621 else if (armv4_5->core_state == ARMV4_5_STATE_THUMB)
622 exit_breakpoint_size = 2;
625 LOG_ERROR("BUG: can't execute algorithms when not in ARM or Thumb state");
629 if (armv4_5_algorithm_info->core_mode != ARMV4_5_MODE_ANY)
631 LOG_DEBUG("setting core_mode: 0x%2.2x", armv4_5_algorithm_info->core_mode);
632 buf_set_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 5, armv4_5_algorithm_info->core_mode);
633 armv4_5->core_cache->reg_list[ARMV4_5_CPSR].dirty = 1;
634 armv4_5->core_cache->reg_list[ARMV4_5_CPSR].valid = 1;
637 /* terminate using a hardware or (ARMv5+) software breakpoint */
638 if (exit_point && (retval = breakpoint_add(target, exit_point,
639 exit_breakpoint_size, BKPT_HARD)) != ERROR_OK)
641 LOG_ERROR("can't add HW breakpoint to terminate algorithm");
642 return ERROR_TARGET_FAILURE;
645 if ((retval = target_resume(target, 0, entry_point, 1, 1)) != ERROR_OK)
650 retval = run_it(target, exit_point, timeout_ms, arch_info);
653 breakpoint_remove(target, exit_point);
655 if (retval != ERROR_OK)
658 for (i = 0; i < num_mem_params; i++)
660 if (mem_params[i].direction != PARAM_OUT)
661 if ((retvaltemp = target_read_buffer(target, mem_params[i].address, mem_params[i].size, mem_params[i].value)) != ERROR_OK)
667 for (i = 0; i < num_reg_params; i++)
669 if (reg_params[i].direction != PARAM_OUT)
672 reg_t *reg = register_get_by_name(armv4_5->core_cache, reg_params[i].reg_name, 0);
675 LOG_ERROR("BUG: register '%s' not found", reg_params[i].reg_name);
679 if (reg->size != reg_params[i].size)
681 LOG_ERROR("BUG: register '%s' size doesn't match reg_params[i].size", reg_params[i].reg_name);
685 buf_set_u32(reg_params[i].value, 0, 32, buf_get_u32(reg->value, 0, 32));
689 for (i = 0; i <= 16; i++)
692 regvalue = buf_get_u32(ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5_algorithm_info->core_mode, i).value, 0, 32);
693 if (regvalue != context[i])
695 LOG_DEBUG("restoring register %s with value 0x%8.8" PRIx32 "", ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5_algorithm_info->core_mode, i).name, context[i]);
696 buf_set_u32(ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5_algorithm_info->core_mode, i).value, 0, 32, context[i]);
697 ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5_algorithm_info->core_mode, i).valid = 1;
698 ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5_algorithm_info->core_mode, i).dirty = 1;
701 buf_set_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32, cpsr);
702 armv4_5->core_cache->reg_list[ARMV4_5_CPSR].valid = 1;
703 armv4_5->core_cache->reg_list[ARMV4_5_CPSR].dirty = 1;
705 armv4_5->core_state = core_state;
706 armv4_5->core_mode = core_mode;
711 int armv4_5_run_algorithm(struct target_s *target, int num_mem_params, struct mem_param *mem_params, int num_reg_params, struct reg_param *reg_params, uint32_t entry_point, uint32_t exit_point, int timeout_ms, void *arch_info)
713 return armv4_5_run_algorithm_inner(target, num_mem_params, mem_params, num_reg_params, reg_params, entry_point, exit_point, timeout_ms, arch_info, armv4_5_run_algorithm_completion);
716 int armv4_5_init_arch_info(target_t *target, struct arm *armv4_5)
718 target->arch_info = armv4_5;
720 armv4_5->common_magic = ARMV4_5_COMMON_MAGIC;
721 armv4_5->core_state = ARMV4_5_STATE_ARM;
722 armv4_5->core_mode = ARMV4_5_MODE_USR;