From: David B. <dbr...@us...> - 2009-11-23 00:51:32
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via b8b1353dd798d4aa811cdccc8eb2d6b41c1090d4 (commit) via fa9b0e2167c295c1f0de349563b893540fc73cb0 (commit) from af7f6891e98d538eabcf137d89f28bf3406a4999 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit b8b1353dd798d4aa811cdccc8eb2d6b41c1090d4 Author: David Brownell <dbr...@us...> Date: Sun Nov 22 15:51:16 2009 -0800 ARM11: remove unused state and exports For now there's no point in saving this stuff after examine() checks it out as OK. Ditto exporting symbols that aren't used outside of the module which defines them. In fact, those two things needlessly complicate the code... Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/arm11.c b/src/target/arm11.c index 0a54c52..cb1af7b 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -385,7 +385,7 @@ static int arm11_on_enter_debug_state(struct arm11_common *arm11) return ERROR_OK; } -void arm11_dump_reg_changes(struct arm11_common * arm11) +static void arm11_dump_reg_changes(struct arm11_common * arm11) { if (!(debug_level >= LOG_LVL_DEBUG)) @@ -1680,6 +1680,8 @@ static int arm11_examine(struct target *target) int retval; char *type; struct arm11_common *arm11 = target_to_arm11(target); + uint32_t didr, device_id; + uint8_t implementor; /* check IDCODE */ @@ -1687,7 +1689,7 @@ static int arm11_examine(struct target *target) struct scan_field idcode_field; - arm11_setup_field(arm11, 32, NULL, &arm11->device_id, &idcode_field); + arm11_setup_field(arm11, 32, NULL, &device_id, &idcode_field); arm11_add_dr_scan_vc(1, &idcode_field, TAP_DRPAUSE); @@ -1699,14 +1701,14 @@ static int arm11_examine(struct target *target) struct scan_field chain0_fields[2]; - arm11_setup_field(arm11, 32, NULL, &arm11->didr, chain0_fields + 0); - arm11_setup_field(arm11, 8, NULL, &arm11->implementor, chain0_fields + 1); + arm11_setup_field(arm11, 32, NULL, &didr, chain0_fields + 0); + arm11_setup_field(arm11, 8, NULL, &implementor, chain0_fields + 1); arm11_add_dr_scan_vc(ARRAY_SIZE(chain0_fields), chain0_fields, TAP_IDLE); CHECK_RETVAL(jtag_execute_queue()); - switch (arm11->device_id & 0x0FFFF000) + switch (device_id & 0x0FFFF000) { case 0x07B36000: type = "ARM1136"; @@ -1724,26 +1726,25 @@ static int arm11_examine(struct target *target) } LOG_INFO("found %s", type); - arm11->debug_version = (arm11->didr >> 16) & 0x0F; - - if (arm11->debug_version != ARM11_DEBUG_V6 && - arm11->debug_version != ARM11_DEBUG_V61) - { - LOG_ERROR("Only ARMv6 v6 and v6.1 architectures supported."); + /* unlikely this could ever fail, but ... */ + switch ((didr >> 16) & 0x0F) { + case ARM11_DEBUG_V6: + case ARM11_DEBUG_V61: /* supports security extensions */ + break; + default: + LOG_ERROR("Only ARM v6 and v6.1 debug supported."); return ERROR_FAIL; } - arm11->brp = ((arm11->didr >> 24) & 0x0F) + 1; - arm11->wrp = ((arm11->didr >> 28) & 0x0F) + 1; + arm11->brp = ((didr >> 24) & 0x0F) + 1; + arm11->wrp = ((didr >> 28) & 0x0F) + 1; /** \todo TODO: reserve one brp slot if we allow breakpoints during step */ arm11->free_brps = arm11->brp; arm11->free_wrps = arm11->wrp; - LOG_DEBUG("IDCODE %08" PRIx32 " IMPLEMENTOR %02x DIDR %08" PRIx32 "", - arm11->device_id, - (int)(arm11->implementor), - arm11->didr); + LOG_DEBUG("IDCODE %08" PRIx32 " IMPLEMENTOR %02x DIDR %08" PRIx32, + device_id, implementor, didr); /* as a side-effect this reads DSCR and thus * clears the ARM11_DSCR_STICKY_PRECISE_DATA_ABORT / Sticky Precise Data Abort Flag diff --git a/src/target/arm11.h b/src/target/arm11.h index 3d7841d..d40faa4 100644 --- a/src/target/arm11.h +++ b/src/target/arm11.h @@ -62,15 +62,9 @@ struct arm11_common /** \name Processor type detection */ /*@{*/ - uint32_t device_id; /**< IDCODE readout */ - uint32_t didr; /**< DIDR readout (debug capabilities) */ - uint8_t implementor; /**< DIDR Implementor readout */ - size_t brp; /**< Number of Breakpoint Register Pairs from DIDR */ size_t wrp; /**< Number of Watchpoint Register Pairs from DIDR */ - enum arm11_debug_version - debug_version; /**< ARM debug architecture from DIDR */ /*@}*/ uint32_t last_dscr; /**< Last retrieved DSCR value; diff --git a/src/target/arm11_dbgtap.c b/src/target/arm11_dbgtap.c index 26de4ce..c8d5902 100644 --- a/src/target/arm11_dbgtap.c +++ b/src/target/arm11_dbgtap.c @@ -48,7 +48,8 @@ static const tap_state_t arm11_move_pi_to_si_via_ci[] = }; -int arm11_add_ir_scan_vc(int num_fields, struct scan_field *fields, tap_state_t state) +static int arm11_add_ir_scan_vc(int num_fields, struct scan_field *fields, + tap_state_t state) { if (cmd_queue_cur_state == TAP_IRPAUSE) jtag_add_pathmove(ARRAY_SIZE(arm11_move_pi_to_si_via_ci), arm11_move_pi_to_si_via_ci); @@ -201,7 +202,8 @@ int arm11_add_debug_SCAN_N(struct arm11_common * arm11, uint8_t chain, tap_state * * \remarks This adds to the JTAG command queue but does \em not execute it. */ -void arm11_add_debug_INST(struct arm11_common * arm11, uint32_t inst, uint8_t * flag, tap_state_t state) +static void arm11_add_debug_INST(struct arm11_common * arm11, + uint32_t inst, uint8_t * flag, tap_state_t state) { JTAG_DEBUG("INST <= 0x%08x", inst); @@ -377,7 +379,9 @@ int arm11_run_instr_data_finish(struct arm11_common * arm11) * \param count Number of opcodes to execute * */ -int arm11_run_instr_no_data(struct arm11_common * arm11, uint32_t * opcode, size_t count) +static +int arm11_run_instr_no_data(struct arm11_common * arm11, + uint32_t * opcode, size_t count) { arm11_add_IR(arm11, ARM11_ITRSEL, ARM11_TAP_DEFAULT); diff --git a/src/target/arm11_dbgtap.h b/src/target/arm11_dbgtap.h index 87b66a5..b85a138 100644 --- a/src/target/arm11_dbgtap.h +++ b/src/target/arm11_dbgtap.h @@ -11,8 +11,6 @@ void arm11_add_IR(struct arm11_common *arm11, uint8_t instr, tap_state_t state); int arm11_add_debug_SCAN_N(struct arm11_common *arm11, uint8_t chain, tap_state_t state); -void arm11_add_debug_INST(struct arm11_common *arm11, - uint32_t inst, uint8_t *flag, tap_state_t state); int arm11_read_DSCR(struct arm11_common *arm11, uint32_t *dscr); int arm11_write_DSCR(struct arm11_common *arm11, uint32_t dscr); @@ -20,8 +18,6 @@ enum target_debug_reason arm11_get_DSCR_debug_reason(uint32_t dscr); int arm11_run_instr_data_prepare(struct arm11_common *arm11); int arm11_run_instr_data_finish(struct arm11_common *arm11); -int arm11_run_instr_no_data(struct arm11_common *arm11, - uint32_t *opcode, size_t count); int arm11_run_instr_no_data1(struct arm11_common *arm11, uint32_t opcode); int arm11_run_instr_data_to_core(struct arm11_common *arm11, uint32_t opcode, uint32_t *data, size_t count); @@ -38,8 +34,6 @@ int arm11_run_instr_data_to_core_via_r0(struct arm11_common *arm11, int arm11_add_dr_scan_vc(int num_fields, struct scan_field *fields, tap_state_t state); -int arm11_add_ir_scan_vc(int num_fields, struct scan_field *fields, - tap_state_t state); /** * Used with arm11_sc7_run to make a list of read/write commands for commit fa9b0e2167c295c1f0de349563b893540fc73cb0 Author: David Brownell <dbr...@us...> Date: Sun Nov 22 15:50:24 2009 -0800 ARM11: macro cleanup Make this code look more like the rest of the OpenOCD code. - Use calloc() directly, not NEW() ... and fix some potential memory leaks while we're at it. - Remove FNC_INFO ... it's a NOP that just clutters things, and it's trivial for developers to add tracing as needed. - Replace FNC_INFO_NOTIMPLEMENTED with LOG_WARNING calls; ditto. And stop having those call sites wrongly succeed! - Waste less space with the CHECK_RETVAL() macro. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/arm11.c b/src/target/arm11.c index 1a7b4e0..0a54c52 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -40,18 +40,6 @@ #define _DEBUG_INSTRUCTION_EXECUTION_ #endif -#if 0 -#define FNC_INFO LOG_DEBUG("-") -#else -#define FNC_INFO -#endif - -#if 1 -#define FNC_INFO_NOTIMPLEMENTED do { LOG_DEBUG("NOT IMPLEMENTED"); /*exit(-1);*/ } while (0) -#else -#define FNC_INFO_NOTIMPLEMENTED -#endif - static bool arm11_config_memwrite_burst = true; static bool arm11_config_memwrite_error_fatal = true; static uint32_t arm11_vcr = 0; @@ -180,8 +168,6 @@ static void arm11_dump_reg_changes(struct arm11_common * arm11); */ static int arm11_check_init(struct arm11_common *arm11, uint32_t *dscr) { - FNC_INFO; - uint32_t dscr_local_tmp_copy; if (!dscr) @@ -239,7 +225,6 @@ static int arm11_check_init(struct arm11_common *arm11, uint32_t *dscr) static int arm11_on_enter_debug_state(struct arm11_common *arm11) { int retval; - FNC_INFO; for (size_t i = 0; i < ARRAY_SIZE(arm11->reg_values); i++) { @@ -437,7 +422,6 @@ void arm11_dump_reg_changes(struct arm11_common * arm11) */ static int arm11_leave_debug_state(struct arm11_common *arm11) { - FNC_INFO; int retval; retval = arm11_run_instr_data_prepare(arm11); @@ -569,7 +553,6 @@ static void arm11_record_register_history(struct arm11_common *arm11) /* poll current target status */ static int arm11_poll(struct target *target) { - FNC_INFO; int retval; struct arm11_common *arm11 = target_to_arm11(target); uint32_t dscr; @@ -626,15 +609,14 @@ static int arm11_arch_state(struct target *target) static int arm11_target_request_data(struct target *target, uint32_t size, uint8_t *buffer) { - FNC_INFO_NOTIMPLEMENTED; + LOG_WARNING("Not implemented: %s", __func__); - return ERROR_OK; + return ERROR_FAIL; } /* target execution control */ static int arm11_halt(struct target *target) { - FNC_INFO; struct arm11_common *arm11 = target_to_arm11(target); LOG_DEBUG("target->state: %s", @@ -699,8 +681,6 @@ static int arm11_halt(struct target *target) static int arm11_resume(struct target *target, int current, uint32_t address, int handle_breakpoints, int debug_execution) { - FNC_INFO; - // LOG_DEBUG("current %d address %08x handle_breakpoints %d debug_execution %d", // current, address, handle_breakpoints, debug_execution); @@ -880,7 +860,7 @@ static void arm11_sim_set_state(struct arm_sim_interface *sim, // struct arm11_common * arm11 = (struct arm11_common *)sim->user_data; /* FIX!!!! we should implement thumb for arm11 */ - LOG_ERROR("Not implemetned!"); + LOG_ERROR("Not implemented: %s", __func__); } @@ -913,8 +893,6 @@ static int arm11_simulate_step(struct target *target, uint32_t *dry_run_pc) static int arm11_step(struct target *target, int current, uint32_t address, int handle_breakpoints) { - FNC_INFO; - LOG_DEBUG("target->state: %s", target_state_name(target)); @@ -1068,7 +1046,6 @@ static int arm11_step(struct target *target, int current, static int arm11_assert_reset(struct target *target) { - FNC_INFO; int retval; struct arm11_common *arm11 = target_to_arm11(target); @@ -1135,16 +1112,15 @@ static int arm11_deassert_reset(struct target *target) static int arm11_soft_reset_halt(struct target *target) { - FNC_INFO_NOTIMPLEMENTED; + LOG_WARNING("Not implemented: %s", __func__); - return ERROR_OK; + return ERROR_FAIL; } /* target register access for gdb */ static int arm11_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size) { - FNC_INFO; struct arm11_common *arm11 = target_to_arm11(target); *reg_list_size = ARM11_GDB_REGISTER_COUNT; @@ -1181,8 +1157,6 @@ static int arm11_read_memory_inner(struct target *target, /** \todo TODO: check if buffer cast to uint32_t* and uint16_t* might cause alignment problems */ int retval; - FNC_INFO; - if (target->state != TARGET_HALTED) { LOG_WARNING("target was not halted"); @@ -1277,7 +1251,6 @@ static int arm11_write_memory_inner(struct target *target, bool arm11_config_memrw_no_increment) { int retval; - FNC_INFO; if (target->state != TARGET_HALTED) { @@ -1421,8 +1394,6 @@ static int arm11_write_memory(struct target *target, static int arm11_bulk_write_memory(struct target *target, uint32_t address, uint32_t count, uint8_t *buffer) { - FNC_INFO; - if (target->state != TARGET_HALTED) { LOG_WARNING("target was not halted"); @@ -1438,7 +1409,6 @@ static int arm11_bulk_write_memory(struct target *target, static int arm11_add_breakpoint(struct target *target, struct breakpoint *breakpoint) { - FNC_INFO; struct arm11_common *arm11 = target_to_arm11(target); #if 0 @@ -1469,7 +1439,6 @@ static int arm11_add_breakpoint(struct target *target, static int arm11_remove_breakpoint(struct target *target, struct breakpoint *breakpoint) { - FNC_INFO; struct arm11_common *arm11 = target_to_arm11(target); arm11->free_brps++; @@ -1480,17 +1449,17 @@ static int arm11_remove_breakpoint(struct target *target, static int arm11_add_watchpoint(struct target *target, struct watchpoint *watchpoint) { - FNC_INFO_NOTIMPLEMENTED; + LOG_WARNING("Not implemented: %s", __func__); - return ERROR_OK; + return ERROR_FAIL; } static int arm11_remove_watchpoint(struct target *target, struct watchpoint *watchpoint) { - FNC_INFO_NOTIMPLEMENTED; + LOG_WARNING("Not implemented: %s", __func__); - return ERROR_OK; + return ERROR_FAIL; } // HACKHACKHACK - FIXME mode/state @@ -1665,11 +1634,7 @@ restore: static int arm11_target_create(struct target *target, Jim_Interp *interp) { - FNC_INFO; - - NEW(struct arm11_common, arm11, 1); - - arm11->target = target; + struct arm11_common *arm11; if (target->tap == NULL) return ERROR_FAIL; @@ -1680,8 +1645,14 @@ static int arm11_target_create(struct target *target, Jim_Interp *interp) return ERROR_COMMAND_SYNTAX_ERROR; } + arm11 = calloc(1, sizeof *arm11); + if (!arm11) + return ERROR_FAIL; + armv4_5_init_arch_info(target, &arm11->arm); + arm11->target = target; + arm11->jtag_info.tap = target->tap; arm11->jtag_info.scann_size = 5; arm11->jtag_info.scann_instr = ARM11_SCAN_N; @@ -1708,7 +1679,6 @@ static int arm11_examine(struct target *target) { int retval; char *type; - FNC_INFO; struct arm11_common *arm11 = target_to_arm11(target); /* check IDCODE */ @@ -1801,8 +1771,6 @@ static int arm11_examine(struct target *target) /** Load a register that is marked !valid in the register cache */ static int arm11_get_reg(struct reg *reg) { - FNC_INFO; - struct target * target = ((struct arm11_reg_state *)reg->arch_info)->target; if (target->state != TARGET_HALTED) @@ -1824,8 +1792,6 @@ static int arm11_get_reg(struct reg *reg) /** Change a value in the register cache */ static int arm11_set_reg(struct reg *reg, uint8_t *buf) { - FNC_INFO; - struct target *target = ((struct arm11_reg_state *)reg->arch_info)->target; struct arm11_common *arm11 = target_to_arm11(target); // const struct arm11_reg_defs *arm11_reg_info = arm11_reg_defs + ((struct arm11_reg_state *)reg->arch_info)->def_index; @@ -1845,10 +1811,20 @@ static const struct reg_arch_type arm11_reg_type = { static int arm11_build_reg_cache(struct target *target) { struct arm11_common *arm11 = target_to_arm11(target); - - NEW(struct reg_cache, cache, 1); - NEW(struct reg, reg_list, ARM11_REGCACHE_COUNT); - NEW(struct arm11_reg_state, arm11_reg_states, ARM11_REGCACHE_COUNT); + struct reg_cache *cache; + struct reg *reg_list; + struct arm11_reg_state *arm11_reg_states; + + cache = calloc(1, sizeof *cache); + reg_list = calloc(ARM11_REGCACHE_COUNT, sizeof *reg_list); + arm11_reg_states = calloc(ARM11_REGCACHE_COUNT, + sizeof *arm11_reg_states); + if (!cache || !reg_list || !arm11_reg_states) { + free(cache); + free(reg_list); + free(arm11_reg_states); + return ERROR_FAIL; + } arm11->reg_list = reg_list; @@ -1998,8 +1974,6 @@ static int arm11_mcr(struct target *target, int cpnum, static int arm11_register_commands(struct command_context *cmd_ctx) { - FNC_INFO; - struct command *top_cmd, *mw_cmd; armv4_5_register_commands(cmd_ctx); diff --git a/src/target/arm11.h b/src/target/arm11.h index 0b37929..3d7841d 100644 --- a/src/target/arm11.h +++ b/src/target/arm11.h @@ -25,27 +25,20 @@ #include "armv4_5.h" -#define NEW(type, variable, items) \ - type * variable = calloc(1, sizeof(type) * items) - /* TEMPORARY -- till we switch to the shared infrastructure */ #define ARM11_REGCACHE_COUNT 20 #define ARM11_TAP_DEFAULT TAP_INVALID - -#define CHECK_RETVAL(action) \ -do { \ - int __retval = (action); \ - \ - if (__retval != ERROR_OK) \ - { \ - LOG_DEBUG("error while calling \"" # action "\""); \ - return __retval; \ - } \ - \ -} while (0) - +#define CHECK_RETVAL(action) \ + do { \ + int __retval = (action); \ + if (__retval != ERROR_OK) { \ + LOG_DEBUG("error while calling \"%s\"", \ + # action ); \ + return __retval; \ + } \ + } while (0) struct arm11_register_history { ----------------------------------------------------------------------- Summary of changes: src/target/arm11.c | 121 ++++++++++++++++++--------------------------- src/target/arm11.h | 31 +++-------- src/target/arm11_dbgtap.c | 10 +++- src/target/arm11_dbgtap.h | 6 -- 4 files changed, 64 insertions(+), 104 deletions(-) hooks/post-receive -- Main OpenOCD repository |