X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Ftarget%2Ftarget.c;h=3a6c6bb42129d5c0f9b9bce86403347cb4f5f74b;hb=b0bdc4e2f2b4fd31ae3b0ebf47765e88c4c37556;hp=5cff9d081ad27cecb6c0069780553ab8fbeb80b9;hpb=778b789c8ed44faadfb572c9a0eebb4e4a76a3aa;p=openocd.git diff --git a/src/target/target.c b/src/target/target.c index 5cff9d081a..3a6c6bb421 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -66,6 +66,7 @@ extern struct target_type dragonite_target; extern struct target_type xscale_target; extern struct target_type cortexm3_target; extern struct target_type cortexa8_target; +extern struct target_type cortexa9_target; extern struct target_type arm11_target; extern struct target_type mips_m4k_target; extern struct target_type avr_target; @@ -88,6 +89,7 @@ static struct target_type *target_types[] = &xscale_target, &cortexm3_target, &cortexa8_target, + &cortexa9_target, &arm11_target, &mips_m4k_target, &avr_target, @@ -278,6 +280,15 @@ uint32_t target_buffer_get_u32(struct target *target, const uint8_t *buffer) return be_to_h_u32(buffer); } +/* read a uint24_t from a buffer in target memory endianness */ +uint32_t target_buffer_get_u24(struct target *target, const uint8_t *buffer) +{ + if (target->endianness == TARGET_LITTLE_ENDIAN) + return le_to_h_u24(buffer); + else + return be_to_h_u24(buffer); +} + /* read a uint16_t from a buffer in target memory endianness */ uint16_t target_buffer_get_u16(struct target *target, const uint8_t *buffer) { @@ -302,6 +313,15 @@ void target_buffer_set_u32(struct target *target, uint8_t *buffer, uint32_t valu h_u32_to_be(buffer, value); } +/* write a uint24_t to a buffer in target memory endianness */ +void target_buffer_set_u24(struct target *target, uint8_t *buffer, uint32_t value) +{ + if (target->endianness == TARGET_LITTLE_ENDIAN) + h_u24_to_le(buffer, value); + else + h_u24_to_be(buffer, value); +} + /* write a uint16_t to a buffer in target memory endianness */ void target_buffer_set_u16(struct target *target, uint8_t *buffer, uint16_t value) { @@ -1213,7 +1233,7 @@ int target_alloc_working_area_try(struct target *target, uint32_t size, struct w } /* mark as used, and return the new (reused) area */ - new_wa->free = 0; + new_wa->free = false; *area = new_wa; /* user pointer */ @@ -1247,7 +1267,7 @@ static int target_free_working_area_restore(struct target *target, struct workin return retval; } - area->free = 1; + area->free = true; /* mark user pointer invalid */ *area->user = NULL; @@ -2314,7 +2334,7 @@ COMMAND_HANDLER(handle_md_command) bool physical=strcmp(CMD_ARGV[0], "phys")==0; int (*fn)(struct target *target, - uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer); + uint32_t address, uint32_t size_value, uint32_t count, uint8_t *buffer); if (physical) { CMD_ARGC--; @@ -3660,6 +3680,7 @@ enum target_cfg_param { TCFG_WORK_AREA_BACKUP, TCFG_ENDIAN, TCFG_VARIANT, + TCFG_COREID, TCFG_CHAIN_POSITION, }; @@ -3672,6 +3693,7 @@ static Jim_Nvp nvp_config_opts[] = { { .name = "-work-area-backup", .value = TCFG_WORK_AREA_BACKUP }, { .name = "-endian" , .value = TCFG_ENDIAN }, { .name = "-variant", .value = TCFG_VARIANT }, + { .name = "-coreid", .value = TCFG_COREID }, { .name = "-chain-position", .value = TCFG_CHAIN_POSITION }, { .name = NULL, .value = -1 } @@ -3924,6 +3946,23 @@ static int target_configure(Jim_GetOptInfo *goi, struct target *target) Jim_SetResultString(goi->interp, target->variant,-1); /* loop for more */ break; + + case TCFG_COREID: + if (goi->isconfigure) { + e = Jim_GetOpt_Wide(goi, &w); + if (e != JIM_OK) { + return e; + } + target->coreid = (int)w; + } else { + if (goi->argc != 0) { + goto no_params; + } + } + Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, target->working_area_size)); + /* loop for more */ + break; + case TCFG_CHAIN_POSITION: if (goi->isconfigure) { Jim_Obj *o_t; @@ -4221,9 +4260,6 @@ static int jim_target_examine(Jim_Interp *interp, int argc, Jim_Obj *const *argv int e = target->type->examine(target); if (e != ERROR_OK) { - Jim_Obj *eObj = Jim_NewIntObj(interp, e); - Jim_SetResultFormatted(interp, "examine-fails: %#s", eObj); - Jim_FreeNewObj(interp, eObj); return JIM_ERR; } return JIM_OK; @@ -4263,9 +4299,6 @@ static int jim_target_poll(Jim_Interp *interp, int argc, Jim_Obj *const *argv) } if (e != ERROR_OK) { - Jim_Obj *eObj = Jim_NewIntObj(interp, e); - Jim_SetResultFormatted(interp, "poll-fails: %#s", eObj); - Jim_FreeNewObj(interp, eObj); return JIM_ERR; } return JIM_OK; @@ -4640,6 +4673,9 @@ static int target_create(Jim_GetOptInfo *goi) /* will be set by "-endian" */ target->endianness = TARGET_ENDIAN_UNKNOWN; + /* default to first core, override with -coreid */ + target->coreid = 0; + target->working_area = 0x0; target->working_area_size = 0x0; target->working_areas = NULL;