-
-COMMAND_HANDLER(handle_arm7_9_write_xpsr_command)
-{
- uint32_t value;
- int spsr;
- int retval;
- struct target *target = get_current_target(CMD_CTX);
- struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
-
- if (!is_arm7_9(arm7_9))
- {
- command_print(CMD_CTX, "current target isn't an ARM7/ARM9 target");
- return ERROR_TARGET_INVALID;
- }
-
- if (target->state != TARGET_HALTED)
- {
- command_print(CMD_CTX, "can't write registers while running");
- return ERROR_FAIL;
- }
-
- if (CMD_ARGC < 2)
- {
- command_print(CMD_CTX, "usage: write_xpsr <value> <not cpsr | spsr>");
- return ERROR_FAIL;
- }
-
- COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], value);
- COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], spsr);
-
- /* if we're writing the CPSR, mask the T bit */
- if (!spsr)
- value &= ~0x20;
-
- arm7_9->write_xpsr(target, value, spsr);
- if ((retval = jtag_execute_queue()) != ERROR_OK)
- {
- LOG_ERROR("JTAG error while writing to xpsr");
- return retval;
- }
-
- return ERROR_OK;
-}
-
-COMMAND_HANDLER(handle_arm7_9_write_xpsr_im8_command)
-{
- uint32_t value;
- int rotate;
- int spsr;
- int retval;
- struct target *target = get_current_target(CMD_CTX);
- struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
-
- if (!is_arm7_9(arm7_9))
- {
- command_print(CMD_CTX, "current target isn't an ARM7/ARM9 target");
- return ERROR_TARGET_INVALID;
- }
-
- if (target->state != TARGET_HALTED)
- {
- command_print(CMD_CTX, "can't write registers while running");
- return ERROR_FAIL;
- }
-
- if (CMD_ARGC < 3)
- {
- command_print(CMD_CTX, "usage: write_xpsr_im8 <im8> <rotate> <not cpsr | spsr>");
- return ERROR_FAIL;
- }
-
- COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], value);
- COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], rotate);
- COMMAND_PARSE_NUMBER(int, CMD_ARGV[2], spsr);
-
- arm7_9->write_xpsr_im8(target, value, rotate, spsr);
- if ((retval = jtag_execute_queue()) != ERROR_OK)
- {
- LOG_ERROR("JTAG error while writing 8-bit immediate to xpsr");
- return retval;
- }
-
- return ERROR_OK;
-}
-
-COMMAND_HANDLER(handle_arm7_9_write_core_reg_command)
-{
- uint32_t value;
- uint32_t mode;
- int num;
- struct target *target = get_current_target(CMD_CTX);
- struct arm7_9_common *arm7_9 = target_to_arm7_9(target);
-
- if (!is_arm7_9(arm7_9))
- {
- command_print(CMD_CTX, "current target isn't an ARM7/ARM9 target");
- return ERROR_TARGET_INVALID;
- }
-
- if (target->state != TARGET_HALTED)
- {
- command_print(CMD_CTX, "can't write registers while running");
- return ERROR_FAIL;
- }
-
- if (CMD_ARGC < 3)
- {
- command_print(CMD_CTX, "usage: write_core_reg <num> <mode> <value>");
- return ERROR_FAIL;
- }
-
- COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], num);
- COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], mode);
- COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], value);
-
- return arm7_9_write_core_reg(target, num, mode, value);
-}
-