if (CMD_ARGC > 0)
{
- COMMAND_PARSE_ENABLE(CMD_ARGV[0], semihosting_active);
+ int semihosting;
+
+ COMMAND_PARSE_ENABLE(CMD_ARGV[0], semihosting);
/* TODO: support other methods if vector catch is unavailable */
if (arm7_9->has_vector_catch) {
- struct reg *vector_catch = &arm7_9->eice_cache->reg_list[EICE_VEC_CATCH];
+ struct reg *vector_catch = &arm7_9->eice_cache
+ ->reg_list[EICE_VEC_CATCH];
+
if (!vector_catch->valid)
embeddedice_read_reg(vector_catch);
- buf_set_u32(vector_catch->value, 2, 1, semihosting_active);
+ buf_set_u32(vector_catch->value, 2, 1, semihosting);
embeddedice_store_reg(vector_catch);
- } else if (semihosting_active) {
+
+ /* FIXME never let that "catch" be dropped! */
+
+ arm7_9->armv4_5_common.is_semihosting = semihosting;
+
+ } else if (semihosting) {
command_print(CMD_CTX, "vector catch unavailable");
- semihosting_active = 0;
}
}
- command_print(CMD_CTX, "semihosting is %s", (semihosting_active) ? "enabled" : "disabled");
+ command_print(CMD_CTX, "semihosting is %s",
+ arm7_9->armv4_5_common.is_semihosting
+ ? "enabled" : "disabled");
return ERROR_OK;
}
#include <helper/binarybuffer.h>
#include <helper/log.h>
-/* TODO: this needs to be per target */
-int semihosting_active;
-int semihosting_errno;
static int do_semihosting(struct target *target)
{
result = dup(1);
} else
result = open((char *)fn, mode);
- semihosting_errno = errno;
+ armv4_5->semihosting_errno = errno;
} else {
result = -1;
- semihosting_errno = EINVAL;
+ armv4_5->semihosting_errno = EINVAL;
}
}
break;
else {
int fd = target_buffer_get_u32(target, params+0);
result = close(fd);
- semihosting_errno = errno;
+ armv4_5->semihosting_errno = errno;
}
break;
uint8_t *buf = malloc(l);
if (!buf) {
result = -1;
- semihosting_errno = ENOMEM;
+ armv4_5->semihosting_errno = ENOMEM;
} else {
retval = target_read_buffer(target, a, l, buf);
if (retval != ERROR_OK) {
return retval;
}
result = write(fd, buf, l);
- semihosting_errno = errno;
+ armv4_5->semihosting_errno = errno;
if (result >= 0)
result = l - result;
free(buf);
uint8_t *buf = malloc(l);
if (!buf) {
result = -1;
- semihosting_errno = ENOMEM;
+ armv4_5->semihosting_errno = ENOMEM;
} else {
result = read(fd, buf, l);
- semihosting_errno = errno;
+ armv4_5->semihosting_errno = errno;
if (result > 0) {
retval = target_write_buffer(target, a, result, buf);
if (retval != ERROR_OK) {
int fd = target_buffer_get_u32(target, params+0);
off_t pos = target_buffer_get_u32(target, params+4);
result = lseek(fd, pos, SEEK_SET);
- semihosting_errno = errno;
+ armv4_5->semihosting_errno = errno;
if (result == pos)
result = 0;
}
int fd = target_buffer_get_u32(target, params+0);
off_t cur = lseek(fd, 0, SEEK_CUR);
if (cur == (off_t)-1) {
- semihosting_errno = errno;
+ armv4_5->semihosting_errno = errno;
result = -1;
break;
}
result = lseek(fd, 0, SEEK_END);
- semihosting_errno = errno;
+ armv4_5->semihosting_errno = errno;
if (lseek(fd, cur, SEEK_SET) == (off_t)-1) {
- semihosting_errno = errno;
+ armv4_5->semihosting_errno = errno;
result = -1;
}
}
return retval;
fn[l] = 0;
result = remove((char *)fn);
- semihosting_errno = errno;
+ armv4_5->semihosting_errno = errno;
} else {
result = -1;
- semihosting_errno = EINVAL;
+ armv4_5->semihosting_errno = EINVAL;
}
}
break;
fn1[l1] = 0;
fn2[l2] = 0;
result = rename((char *)fn1, (char *)fn2);
- semihosting_errno = errno;
+ armv4_5->semihosting_errno = errno;
} else {
result = -1;
- semihosting_errno = EINVAL;
+ armv4_5->semihosting_errno = EINVAL;
}
}
break;
break;
case 0x13: /* SYS_ERRNO */
- result = semihosting_errno;
+ result = armv4_5->semihosting_errno;
break;
case 0x15: /* SYS_GET_CMDLINE */
fprintf(stderr, "semihosting: unsupported call %#x\n",
(unsigned) r0);
result = -1;
- semihosting_errno = ENOTSUP;
+ armv4_5->semihosting_errno = ENOTSUP;
}
/* resume execution to the original mode */
struct arm *armv4_5 = target_to_armv4_5(target);
uint32_t lr, spsr;
- if (!semihosting_active ||
+ if (!armv4_5->is_semihosting ||
armv4_5->core_mode != ARMV4_5_MODE_SVC ||
buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32) != 0x08)
return 0;
if (armv4_5->common_magic != ARMV4_5_COMMON_MAGIC)
{
- LOG_ERROR("BUG: called for a non-ARMv4/5 target");
+ LOG_ERROR("BUG: called for a non-ARM target");
return ERROR_FAIL;
}
- LOG_USER("target halted in %s state due to %s, current mode: %s\ncpsr: 0x%8.8" PRIx32 " pc: 0x%8.8" PRIx32 "",
+ LOG_USER("target halted in %s state due to %s, current mode: %s\n"
+ "cpsr: 0x%8.8" PRIx32 " pc: 0x%8.8" PRIx32 "%s",
armv4_5_state_strings[armv4_5->core_state],
- Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason)->name,
+ Jim_Nvp_value2name_simple(nvp_target_debug_reason,
+ target->debug_reason)->name,
arm_mode_name(armv4_5->core_mode),
buf_get_u32(armv4_5->cpsr->value, 0, 32),
- buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32));
+ buf_get_u32(armv4_5->core_cache->reg_list[15].value,
+ 0, 32),
+ armv4_5->is_semihosting ? ", semihosting" : "");
return ERROR_OK;
}