You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(75) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(70) |
Feb
(20) |
Mar
(52) |
Apr
(149) |
May
(387) |
Jun
(466) |
Jul
(133) |
Aug
(87) |
Sep
(122) |
Oct
(140) |
Nov
(185) |
Dec
(105) |
2010 |
Jan
(85) |
Feb
(45) |
Mar
(75) |
Apr
(17) |
May
(41) |
Jun
(52) |
Jul
(33) |
Aug
(29) |
Sep
(36) |
Oct
(15) |
Nov
(26) |
Dec
(34) |
2011 |
Jan
(26) |
Feb
(25) |
Mar
(26) |
Apr
(29) |
May
(20) |
Jun
(27) |
Jul
(15) |
Aug
(32) |
Sep
(13) |
Oct
(64) |
Nov
(60) |
Dec
(10) |
2012 |
Jan
(64) |
Feb
(63) |
Mar
(39) |
Apr
(43) |
May
(54) |
Jun
(11) |
Jul
(30) |
Aug
(45) |
Sep
(11) |
Oct
(70) |
Nov
(24) |
Dec
(23) |
2013 |
Jan
(17) |
Feb
(8) |
Mar
(35) |
Apr
(40) |
May
(20) |
Jun
(24) |
Jul
(36) |
Aug
(25) |
Sep
(42) |
Oct
(40) |
Nov
(9) |
Dec
(21) |
2014 |
Jan
(29) |
Feb
(24) |
Mar
(60) |
Apr
(22) |
May
(22) |
Jun
(46) |
Jul
(11) |
Aug
(23) |
Sep
(26) |
Oct
(10) |
Nov
(14) |
Dec
(2) |
2015 |
Jan
(28) |
Feb
(47) |
Mar
(33) |
Apr
(58) |
May
(5) |
Jun
(1) |
Jul
|
Aug
(8) |
Sep
(12) |
Oct
(25) |
Nov
(58) |
Dec
(21) |
2016 |
Jan
(12) |
Feb
(40) |
Mar
(2) |
Apr
(1) |
May
(67) |
Jun
(2) |
Jul
(5) |
Aug
(36) |
Sep
|
Oct
(24) |
Nov
(17) |
Dec
(50) |
2017 |
Jan
(14) |
Feb
(16) |
Mar
(2) |
Apr
(35) |
May
(14) |
Jun
(16) |
Jul
(3) |
Aug
(3) |
Sep
|
Oct
(19) |
Nov
|
Dec
(16) |
2018 |
Jan
(55) |
Feb
(11) |
Mar
(34) |
Apr
(14) |
May
(4) |
Jun
(20) |
Jul
(39) |
Aug
(16) |
Sep
(17) |
Oct
(16) |
Nov
(20) |
Dec
(30) |
2019 |
Jan
(29) |
Feb
(24) |
Mar
(37) |
Apr
(26) |
May
(19) |
Jun
(21) |
Jul
(2) |
Aug
(3) |
Sep
(9) |
Oct
(12) |
Nov
(12) |
Dec
(12) |
2020 |
Jan
(47) |
Feb
(36) |
Mar
(54) |
Apr
(44) |
May
(37) |
Jun
(19) |
Jul
(32) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(32) |
Dec
(11) |
2021 |
Jan
(14) |
Feb
(5) |
Mar
(40) |
Apr
(32) |
May
(42) |
Jun
(31) |
Jul
(29) |
Aug
(47) |
Sep
(38) |
Oct
(17) |
Nov
(74) |
Dec
(33) |
2022 |
Jan
(11) |
Feb
(15) |
Mar
(40) |
Apr
(21) |
May
(39) |
Jun
(44) |
Jul
(19) |
Aug
(46) |
Sep
(79) |
Oct
(35) |
Nov
(21) |
Dec
(15) |
2023 |
Jan
(56) |
Feb
(13) |
Mar
(43) |
Apr
(28) |
May
(60) |
Jun
(15) |
Jul
(29) |
Aug
(28) |
Sep
(32) |
Oct
(21) |
Nov
(42) |
Dec
(39) |
2024 |
Jan
(35) |
Feb
(17) |
Mar
(28) |
Apr
(7) |
May
(14) |
Jun
(35) |
Jul
(30) |
Aug
(35) |
Sep
(30) |
Oct
(28) |
Nov
(38) |
Dec
(18) |
2025 |
Jan
(21) |
Feb
(28) |
Mar
(36) |
Apr
(35) |
May
(34) |
Jun
(58) |
Jul
(9) |
Aug
(37) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Zach W. <zw...@us...> - 2009-11-18 12:39:17
|
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 59f32cbe53ccd8725e01968fcbc716cc5768a36b (commit) from 6e95f16d0a7d2b07caa1340b3bc3c2309ea12043 (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 59f32cbe53ccd8725e01968fcbc716cc5768a36b Author: Zachary T Welch <zw...@su...> Date: Wed Nov 18 03:34:52 2009 -0800 fix regression in md/mw commands The recent migration broke them, the fixes broken them in a new way, but this should restore them to working order. Eliminates the temporary variable, as the CMD_NAME macro can once again be use in routines that increment CMD_ARGV without nasty side-effects. diff --git a/src/target/target.c b/src/target/target.c index bf83da0..98e7a40 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2248,8 +2248,7 @@ COMMAND_HANDLER(handle_md_command) return ERROR_COMMAND_SYNTAX_ERROR; unsigned size = 0; - const char *cmd_name = CMD_NAME; - switch (cmd_name[6]) { + switch (CMD_NAME[2]) { case 'w': size = 4; break; case 'h': size = 2; break; case 'b': size = 1; break; @@ -2301,7 +2300,6 @@ COMMAND_HANDLER(handle_mw_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); - const char *cmd_name = CMD_NAME; if (physical) { CMD_ARGC--; @@ -2327,7 +2325,7 @@ COMMAND_HANDLER(handle_mw_command) struct target *target = get_current_target(CMD_CTX); unsigned wordsize; uint8_t value_buf[4]; - switch (cmd_name[6]) + switch (CMD_NAME[2]) { case 'w': wordsize = 4; ----------------------------------------------------------------------- Summary of changes: src/target/target.c | 6 ++---- 1 files changed, 2 insertions(+), 4 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2009-11-18 09:25:58
|
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 6e95f16d0a7d2b07caa1340b3bc3c2309ea12043 (commit) from 181d401d59419ec2f5a5d89e2600d9a6dbf8f9ed (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 6e95f16d0a7d2b07caa1340b3bc3c2309ea12043 Author: Ãyvind Harboe <oyv...@zy...> Date: Tue Nov 17 21:59:01 2009 +0100 jtag-api: get rid of unecessary buf_set_u23() that make code obtuse. Also, this is on the path to increasing the word size for bit vectors from 8 to something wider(32? natural host machine width?) Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/target/embeddedice.c b/src/target/embeddedice.c index e375475..3947e26 100644 --- a/src/target/embeddedice.c +++ b/src/target/embeddedice.c @@ -349,7 +349,7 @@ int embeddedice_read_reg_w_check(struct reg *reg, fields[1].tap = ice_reg->jtag_info->tap; fields[1].num_bits = 5; fields[1].out_value = field1_out; - buf_set_u32(fields[1].out_value, 0, 5, reg_addr); + fields[1].out_value[0] = reg_addr; fields[1].in_value = NULL; fields[1].check_value = NULL; fields[1].check_mask = NULL; @@ -358,7 +358,7 @@ int embeddedice_read_reg_w_check(struct reg *reg, fields[2].tap = ice_reg->jtag_info->tap; fields[2].num_bits = 1; fields[2].out_value = field2_out; - buf_set_u32(fields[2].out_value, 0, 1, 0); + fields[2].out_value[0] = 0; fields[2].in_value = NULL; fields[2].check_value = NULL; fields[2].check_mask = NULL; @@ -375,7 +375,7 @@ int embeddedice_read_reg_w_check(struct reg *reg, * EICE_COMMS_DATA would read the register twice * reading the control register is safe */ - buf_set_u32(fields[1].out_value, 0, 5, eice_regs[EICE_COMMS_CTRL].addr); + fields[1].out_value[0] = eice_regs[EICE_COMMS_CTRL].addr; /* traverse Update-DR, reading but with no other side effects */ jtag_add_dr_scan_check(3, fields, jtag_get_end_state()); @@ -409,13 +409,13 @@ int embeddedice_receive(struct arm_jtag *jtag_info, uint32_t *data, uint32_t siz fields[1].tap = jtag_info->tap; fields[1].num_bits = 5; fields[1].out_value = field1_out; - buf_set_u32(fields[1].out_value, 0, 5, eice_regs[EICE_COMMS_DATA].addr); + fields[1].out_value[0] = eice_regs[EICE_COMMS_DATA].addr; fields[1].in_value = NULL; fields[2].tap = jtag_info->tap; fields[2].num_bits = 1; fields[2].out_value = field2_out; - buf_set_u32(fields[2].out_value, 0, 1, 0); + fields[2].out_value[0] = 0; fields[2].in_value = NULL; jtag_add_dr_scan(3, fields, jtag_get_end_state()); @@ -426,8 +426,7 @@ int embeddedice_receive(struct arm_jtag *jtag_info, uint32_t *data, uint32_t siz * to avoid reading additional data from the DCC data reg */ if (size == 1) - buf_set_u32(fields[1].out_value, 0, 5, - eice_regs[EICE_COMMS_CTRL].addr); + fields[1].out_value[0] = eice_regs[EICE_COMMS_CTRL].addr; fields[0].in_value = (uint8_t *)data; jtag_add_dr_scan(3, fields, jtag_get_end_state()); @@ -531,13 +530,13 @@ int embeddedice_send(struct arm_jtag *jtag_info, uint32_t *data, uint32_t size) fields[1].tap = jtag_info->tap; fields[1].num_bits = 5; fields[1].out_value = field1_out; - buf_set_u32(fields[1].out_value, 0, 5, eice_regs[EICE_COMMS_DATA].addr); + fields[1].out_value[0] = eice_regs[EICE_COMMS_DATA].addr; fields[1].in_value = NULL; fields[2].tap = jtag_info->tap; fields[2].num_bits = 1; fields[2].out_value = field2_out; - buf_set_u32(fields[2].out_value, 0, 1, 1); + fields[2].out_value[0] = 1; fields[2].in_value = NULL; @@ -587,13 +586,13 @@ int embeddedice_handshake(struct arm_jtag *jtag_info, int hsbit, uint32_t timeou fields[1].tap = jtag_info->tap; fields[1].num_bits = 5; fields[1].out_value = field1_out; - buf_set_u32(fields[1].out_value, 0, 5, eice_regs[EICE_COMMS_DATA].addr); + fields[1].out_value[0] = eice_regs[EICE_COMMS_DATA].addr; fields[1].in_value = NULL; fields[2].tap = jtag_info->tap; fields[2].num_bits = 1; fields[2].out_value = field2_out; - buf_set_u32(fields[2].out_value, 0, 1, 0); + fields[2].out_value[0] = 0; fields[2].in_value = NULL; jtag_add_dr_scan(3, fields, jtag_get_end_state()); ----------------------------------------------------------------------- Summary of changes: src/target/embeddedice.c | 21 ++++++++++----------- 1 files changed, 10 insertions(+), 11 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: David B. <dbr...@us...> - 2009-11-18 08:50:45
|
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 181d401d59419ec2f5a5d89e2600d9a6dbf8f9ed (commit) via ec93209f51afc09e273a4742dc0b5f2cefc15e76 (commit) via d6c8945662e6027f6ba12d73bac2473088672db5 (commit) from 0091e59d2a18c293fd952a9d707e609afdd6b17f (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 181d401d59419ec2f5a5d89e2600d9a6dbf8f9ed Author: David Brownell <dbr...@us...> Date: Tue Nov 17 23:50:26 2009 -0800 ARM: add is_arm_mode() Add a new is_arm_mode() predicate, and use it to replace almost all calls to current armv4_5_mode_to_number(). Eventually those internal mode numbers should vanish... along with their siblings in the armv7a.c file. Remove a handful of superfluous checks ... e.g. the mode number was just initialized, or (debug entry methods) already validated. Move one of the macros using internal mode numbers into the only file which uses that macro. Make the tables manipulated with those numbers be read-only and, where possible, static so they're not confused with part of the generic ARM interface. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/arm11.c b/src/target/arm11.c index 5e73275..3a23585 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -1603,7 +1603,7 @@ static int arm11_run_algorithm(struct target *target, } // FIXME -// if (armv4_5_mode_to_number(arm11->core_mode)==-1) +// if (!is_arm_mode(arm11->core_mode)) // return ERROR_FAIL; // Save regs diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index ff95a0c..37aa066 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -1242,9 +1242,6 @@ int arm7_9_soft_reset_halt(struct target *target) armv4_5->core_mode = ARMV4_5_MODE_SVC; armv4_5->core_state = ARMV4_5_STATE_ARM; - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) - return ERROR_FAIL; - /* reset registers */ for (i = 0; i <= 14; i++) { @@ -1413,7 +1410,7 @@ static int arm7_9_debug_entry(struct target *target) armv4_5->core_mode = cpsr & 0x1f; - if (armv4_5_mode_to_number(armv4_5->core_mode) == -1) + if (!is_arm_mode(armv4_5->core_mode)) { target->state = TARGET_UNKNOWN; LOG_ERROR("cpsr contains invalid mode value - communication failure"); @@ -1439,9 +1436,6 @@ static int arm7_9_debug_entry(struct target *target) else context[15] -= arm7_9->dbgreq_adjust_pc * ((armv4_5->core_state == ARMV4_5_STATE_ARM) ? 4 : 2); - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) - return ERROR_FAIL; - for (i = 0; i <= 15; i++) { LOG_DEBUG("r%i: 0x%8.8" PRIx32 "", i, context[i]); @@ -1452,9 +1446,6 @@ static int arm7_9_debug_entry(struct target *target) LOG_DEBUG("entered debug state at PC 0x%" PRIx32 "", context[15]); - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) - return ERROR_FAIL; - /* exceptions other than USR & SYS have a saved program status register */ if ((armv4_5->core_mode != ARMV4_5_MODE_USR) && (armv4_5->core_mode != ARMV4_5_MODE_SYS)) { @@ -1506,7 +1497,7 @@ int arm7_9_full_context(struct target *target) return ERROR_TARGET_NOT_HALTED; } - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) + if (!is_arm_mode(armv4_5->core_mode)) return ERROR_FAIL; /* iterate through processor modes (User, FIQ, IRQ, SVC, ABT, UND) @@ -1606,7 +1597,7 @@ int arm7_9_restore_context(struct target *target) if (arm7_9->pre_restore_context) arm7_9->pre_restore_context(target); - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) + if (!is_arm_mode(armv4_5->core_mode)) return ERROR_FAIL; /* iterate through processor modes (User, FIQ, IRQ, SVC, ABT, UND) @@ -2104,7 +2095,7 @@ int arm7_9_read_core_reg(struct target *target, int num, enum armv4_5_mode mode) struct arm7_9_common *arm7_9 = target_to_arm7_9(target); struct armv4_5_common_s *armv4_5 = &arm7_9->armv4_5_common; - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) + if (!is_arm_mode(armv4_5->core_mode)) return ERROR_FAIL; enum armv4_5_mode reg_mode = ((struct armv4_5_core_reg*)ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, mode, num).arch_info)->mode; @@ -2168,7 +2159,7 @@ int arm7_9_write_core_reg(struct target *target, int num, enum armv4_5_mode mode struct arm7_9_common *arm7_9 = target_to_arm7_9(target); struct armv4_5_common_s *armv4_5 = &arm7_9->armv4_5_common; - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) + if (!is_arm_mode(armv4_5->core_mode)) return ERROR_FAIL; enum armv4_5_mode reg_mode = ((struct armv4_5_core_reg*)ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, mode, num).arch_info)->mode; @@ -2373,7 +2364,7 @@ int arm7_9_read_memory(struct target *target, uint32_t address, uint32_t size, u break; } - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) + if (!is_arm_mode(armv4_5->core_mode)) return ERROR_FAIL; for (i = 0; i <= last_reg; i++) @@ -2556,7 +2547,7 @@ int arm7_9_write_memory(struct target *target, uint32_t address, uint32_t size, buf_set_u32(dbg_ctrl->value, EICE_DBG_CONTROL_DBGACK, 1, 1); embeddedice_store_reg(dbg_ctrl); - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) + if (!is_arm_mode(armv4_5->core_mode)) return ERROR_FAIL; for (i = 0; i <= last_reg; i++) diff --git a/src/target/arm920t.c b/src/target/arm920t.c index e1dcea7..29f7917 100644 --- a/src/target/arm920t.c +++ b/src/target/arm920t.c @@ -244,7 +244,7 @@ static int arm920t_read_cp15_interpreted(struct target *target, LOG_DEBUG("cp15_opcode: %8.8x, address: %8.8x, value: %8.8x", cp15_opcode, address, *value); #endif - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) + if (!is_arm_mode(armv4_5->core_mode)) return ERROR_FAIL; ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5->core_mode, 0).dirty = 1; @@ -284,7 +284,7 @@ int arm920t_write_cp15_interpreted(struct target *target, LOG_DEBUG("cp15_opcode: %8.8x, value: %8.8x, address: %8.8x", cp15_opcode, value, address); #endif - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) + if (!is_arm_mode(armv4_5->core_mode)) return ERROR_FAIL; ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5->core_mode, 0).dirty = 1; @@ -889,7 +889,7 @@ COMMAND_HANDLER(arm920t_handle_read_cache_command) fclose(output); - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) + if (!is_arm_mode(armv4_5->core_mode)) return ERROR_FAIL; /* mark registers dirty. */ @@ -1172,7 +1172,7 @@ COMMAND_HANDLER(arm920t_handle_read_mmu_command) fclose(output); - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) + if (!is_arm_mode(armv4_5->core_mode)) return ERROR_FAIL; /* mark registers dirty */ diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 6864efb..d22e0f3 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -36,7 +36,7 @@ #include "register.h" -char* armv4_5_core_reg_list[] = +static const char *armv4_5_core_reg_list[] = { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13_usr", "lr_usr", "pc", @@ -101,9 +101,7 @@ static const struct { /** Map PSR mode bits to the name of an ARM processor operating mode. */ const char *arm_mode_name(unsigned psr_mode) { - unsigned i; - - for (i = 0; i < ARRAY_SIZE(arm_mode_data); i++) { + for (unsigned i = 0; i < ARRAY_SIZE(arm_mode_data); i++) { if (arm_mode_data[i].psr == psr_mode) return arm_mode_data[i].name; } @@ -111,7 +109,17 @@ const char *arm_mode_name(unsigned psr_mode) return "UNRECOGNIZED"; } -/** Map PSR mode bits to linear number */ +/** Return true iff the parameter denotes a valid ARM processor mode. */ +bool is_arm_mode(unsigned psr_mode) +{ + for (unsigned i = 0; i < ARRAY_SIZE(arm_mode_data); i++) { + if (arm_mode_data[i].psr == psr_mode) + return true; + } + return false; +} + +/** Map PSR mode bits to linear number indexing armv4_5_core_reg_map */ int armv4_5_mode_to_number(enum armv4_5_mode mode) { switch (mode) { @@ -137,7 +145,7 @@ int armv4_5_mode_to_number(enum armv4_5_mode mode) } } -/** Map linear number to PSR mode bits. */ +/** Map linear number indexing armv4_5_core_reg_map to PSR mode bits. */ enum armv4_5_mode armv4_5_number_to_mode(int number) { switch (number) { @@ -166,7 +174,7 @@ char* armv4_5_state_strings[] = "ARM", "Thumb", "Jazelle" }; -struct armv4_5_core_reg armv4_5_core_reg_list_arch_info[] = +static const struct armv4_5_core_reg armv4_5_core_reg_list_arch_info[] = { {0, ARMV4_5_MODE_ANY, NULL, NULL}, {1, ARMV4_5_MODE_ANY, NULL, NULL}, @@ -214,7 +222,7 @@ struct armv4_5_core_reg armv4_5_core_reg_list_arch_info[] = }; /* map core mode (USR, FIQ, ...) and register number to indizes into the register cache */ -int armv4_5_core_reg_map[7][17] = +const int armv4_5_core_reg_map[7][17] = { { /* USR */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 31 @@ -383,7 +391,7 @@ struct reg_cache* armv4_5_build_reg_cache(struct target *target, struct arm *arm arch_info[i] = armv4_5_core_reg_list_arch_info[i]; arch_info[i].target = target; arch_info[i].armv4_5_common = armv4_5_common; - reg_list[i].name = armv4_5_core_reg_list[i]; + reg_list[i].name = (char *) armv4_5_core_reg_list[i]; reg_list[i].size = 32; reg_list[i].value = calloc(1, 4); reg_list[i].dirty = 0; @@ -415,6 +423,9 @@ int armv4_5_arch_state(struct target *target) return ERROR_OK; } +#define ARMV4_5_CORE_REG_MODENUM(cache, mode, num) \ + cache->reg_list[armv4_5_core_reg_map[mode][num]] + COMMAND_HANDLER(handle_armv4_5_reg_command) { char output[128]; @@ -435,7 +446,7 @@ COMMAND_HANDLER(handle_armv4_5_reg_command) return ERROR_OK; } - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) + if (!is_arm_mode(armv4_5->core_mode)) return ERROR_FAIL; if (!armv4_5->full_context) { @@ -599,7 +610,7 @@ int armv4_5_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target); int i; - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) + if (!is_arm_mode(armv4_5->core_mode)) return ERROR_FAIL; *reg_list_size = 26; @@ -679,7 +690,7 @@ int armv4_5_run_algorithm_inner(struct target *target, int num_mem_params, struc return ERROR_TARGET_NOT_HALTED; } - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) + if (!is_arm_mode(armv4_5->core_mode)) return ERROR_FAIL; /* armv5 and later can terminate with BKPT instruction; less overhead */ diff --git a/src/target/armv4_5.h b/src/target/armv4_5.h index 5b7a522..81eac47 100644 --- a/src/target/armv4_5.h +++ b/src/target/armv4_5.h @@ -42,6 +42,8 @@ typedef enum armv4_5_mode } armv4_5_mode_t; const char *arm_mode_name(unsigned psr_mode); +bool is_arm_mode(unsigned psr_mode); + int armv4_5_mode_to_number(enum armv4_5_mode mode); enum armv4_5_mode armv4_5_number_to_mode(int number); @@ -54,12 +56,10 @@ typedef enum armv4_5_state extern char* armv4_5_state_strings[]; -extern int armv4_5_core_reg_map[7][17]; +extern const int armv4_5_core_reg_map[7][17]; #define ARMV4_5_CORE_REG_MODE(cache, mode, num) \ cache->reg_list[armv4_5_core_reg_map[armv4_5_mode_to_number(mode)][num]] -#define ARMV4_5_CORE_REG_MODENUM(cache, mode, num) \ - cache->reg_list[armv4_5_core_reg_map[mode][num]] /* offsets into armv4_5 core register cache */ enum diff --git a/src/target/xscale.c b/src/target/xscale.c index 38928f4..09e6825 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -954,7 +954,7 @@ static int xscale_debug_entry(struct target *target) LOG_DEBUG("cpsr: 0x%8.8" PRIx32 "", buffer[9]); armv4_5->core_mode = buffer[9] & 0x1f; - if (armv4_5_mode_to_number(armv4_5->core_mode) == -1) + if (!is_arm_mode(armv4_5->core_mode)) { target->state = TARGET_UNKNOWN; LOG_ERROR("cpsr contains invalid mode value - communication failure"); @@ -969,9 +969,6 @@ static int xscale_debug_entry(struct target *target) armv4_5->core_state = ARMV4_5_STATE_ARM; - if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) - return ERROR_FAIL; - /* get banked registers, r8 to r14, and spsr if not in USR/SYS mode */ if ((armv4_5->core_mode != ARMV4_5_MODE_USR) && (armv4_5->core_mode != ARMV4_5_MODE_SYS)) { commit ec93209f51afc09e273a4742dc0b5f2cefc15e76 Author: David Brownell <dbr...@us...> Date: Tue Nov 17 23:50:23 2009 -0800 ARM: add arm_mode_name() Add and use arm_mode_name() to map from PSR bits to user meaningful names. It uses a new table which, later, can be used to hold other mode-coupled data. Add definitions for the "Secure Monitor" mode, as seen on some ARM11 cores (like ARM1176) and on Cortex-A8. The previous mode name scheme didn't understand that mode. Remove the old mechanism ... there were two copies, caused by Cortex-A8 needing to add "Secure Monitor" mode support. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/arm720t.c b/src/target/arm720t.c index b51f969..a6c7cc7 100644 --- a/src/target/arm720t.c +++ b/src/target/arm720t.c @@ -239,7 +239,7 @@ static int arm720t_arch_state(struct target *target) "MMU: %s, Cache: %s", armv4_5_state_strings[armv4_5->core_state], Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason)->name , - armv4_5_mode_strings[armv4_5_mode_to_number(armv4_5->core_mode)], + arm_mode_name(armv4_5->core_mode), buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32), buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32), state[arm720t->armv4_5_mmu.mmu_enabled], diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index b29eb5c..ff95a0c 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -1420,7 +1420,8 @@ static int arm7_9_debug_entry(struct target *target) return ERROR_TARGET_FAILURE; } - LOG_DEBUG("target entered debug state in %s mode", armv4_5_mode_strings[armv4_5_mode_to_number(armv4_5->core_mode)]); + LOG_DEBUG("target entered debug state in %s mode", + arm_mode_name(armv4_5->core_mode)); if (armv4_5->core_state == ARMV4_5_STATE_THUMB) { @@ -1613,7 +1614,8 @@ int arm7_9_restore_context(struct target *target) */ for (i = 0; i < 6; i++) { - LOG_DEBUG("examining %s mode", armv4_5_mode_strings[i]); + LOG_DEBUG("examining %s mode", + arm_mode_name(armv4_5->core_mode)); dirty = 0; mode_change = 0; /* check if there are dirty registers in the current mode @@ -1675,7 +1677,10 @@ int arm7_9_restore_context(struct target *target) num_regs++; reg->dirty = 0; reg->valid = 1; - LOG_DEBUG("writing register %i of mode %s with value 0x%8.8" PRIx32 "", j, armv4_5_mode_strings[i], regs[j]); + LOG_DEBUG("writing register %i mode %s " + "with value 0x%8.8" PRIx32, j, + arm_mode_name(armv4_5->core_mode), + regs[j]); } } diff --git a/src/target/arm920t.c b/src/target/arm920t.c index 99b4bbd..e1dcea7 100644 --- a/src/target/arm920t.c +++ b/src/target/arm920t.c @@ -451,7 +451,7 @@ int arm920t_arch_state(struct target *target) "MMU: %s, D-Cache: %s, I-Cache: %s", armv4_5_state_strings[armv4_5->core_state], Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason)->name, - armv4_5_mode_strings[armv4_5_mode_to_number(armv4_5->core_mode)], + arm_mode_name(armv4_5->core_mode), buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32), buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32), state[arm920t->armv4_5_mmu.mmu_enabled], diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c index cc6318b..27eb752 100644 --- a/src/target/arm926ejs.c +++ b/src/target/arm926ejs.c @@ -509,7 +509,7 @@ int arm926ejs_arch_state(struct target *target) "MMU: %s, D-Cache: %s, I-Cache: %s", armv4_5_state_strings[armv4_5->core_state], Jim_Nvp_value2name_simple(nvp_target_debug_reason,target->debug_reason)->name, - armv4_5_mode_strings[armv4_5_mode_to_number(armv4_5->core_mode)], + arm_mode_name(armv4_5->core_mode), buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32), buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32), state[arm926ejs->armv4_5_mmu.mmu_enabled], diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index aba4431..6864efb 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -53,13 +53,63 @@ char* armv4_5_core_reg_list[] = "cpsr", "spsr_fiq", "spsr_irq", "spsr_svc", "spsr_abt", "spsr_und" }; -static const char *armv4_5_mode_strings_list[] = -{ - "Illegal mode value", "User", "FIQ", "IRQ", "Supervisor", "Abort", "Undefined", "System" +static const struct { + const char *name; + unsigned psr; +} arm_mode_data[] = { + /* Seven modes are standard from ARM7 on. "System" and "User" share + * the same registers; other modes shadow from 3 to 8 registers. + */ + { + .name = "User", + .psr = ARMV4_5_MODE_USR, + }, + { + .name = "FIQ", + .psr = ARMV4_5_MODE_FIQ, + }, + { + .name = "Supervisor", + .psr = ARMV4_5_MODE_SVC, + }, + { + .name = "Abort", + .psr = ARMV4_5_MODE_ABT, + }, + { + .name = "IRQ", + .psr = ARMV4_5_MODE_IRQ, + }, + { + .name = "Undefined" /* instruction */, + .psr = ARMV4_5_MODE_UND, + }, + { + .name = "System", + .psr = ARMV4_5_MODE_SYS, + }, + /* TrustZone "Security Extensions" add a secure monitor mode. + * This is distinct from a "debug monitor" which can support + * non-halting debug, in conjunction with some debuggers. + */ + { + .name = "Secure Monitor", + .psr = ARM_MODE_MON, + }, }; -/* Hack! Yuk! allow -1 index, which simplifies codepaths elsewhere in the code */ -const char **armv4_5_mode_strings = armv4_5_mode_strings_list + 1; +/** Map PSR mode bits to the name of an ARM processor operating mode. */ +const char *arm_mode_name(unsigned psr_mode) +{ + unsigned i; + + for (i = 0; i < ARRAY_SIZE(arm_mode_data); i++) { + if (arm_mode_data[i].psr == psr_mode) + return arm_mode_data[i].name; + } + LOG_ERROR("unrecognized psr mode: %#02x", psr_mode); + return "UNRECOGNIZED"; +} /** Map PSR mode bits to linear number */ int armv4_5_mode_to_number(enum armv4_5_mode mode) @@ -282,7 +332,8 @@ int armv4_5_set_core_reg(struct reg *reg, uint8_t *buf) if (armv4_5_target->core_mode != (enum armv4_5_mode)(value & 0x1f)) { - LOG_DEBUG("changing ARM core mode to '%s'", armv4_5_mode_strings[armv4_5_mode_to_number(value & 0x1f)]); + LOG_DEBUG("changing ARM core mode to '%s'", + arm_mode_name(value & 0x1f)); armv4_5_target->core_mode = value & 0x1f; armv4_5_target->write_core_reg(target, 16, ARMV4_5_MODE_ANY, value); } @@ -357,7 +408,7 @@ int armv4_5_arch_state(struct target *target) LOG_USER("target halted in %s state due to %s, current mode: %s\ncpsr: 0x%8.8" PRIx32 " pc: 0x%8.8" PRIx32 "", armv4_5_state_strings[armv4_5->core_state], Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason)->name, - armv4_5_mode_strings[armv4_5_mode_to_number(armv4_5->core_mode)], + arm_mode_name(armv4_5->core_mode), buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32), buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32)); diff --git a/src/target/armv4_5.h b/src/target/armv4_5.h index d126f96..5b7a522 100644 --- a/src/target/armv4_5.h +++ b/src/target/armv4_5.h @@ -35,16 +35,16 @@ typedef enum armv4_5_mode ARMV4_5_MODE_IRQ = 18, ARMV4_5_MODE_SVC = 19, ARMV4_5_MODE_ABT = 23, + ARM_MODE_MON = 26, ARMV4_5_MODE_UND = 27, ARMV4_5_MODE_SYS = 31, ARMV4_5_MODE_ANY = -1 } armv4_5_mode_t; +const char *arm_mode_name(unsigned psr_mode); int armv4_5_mode_to_number(enum armv4_5_mode mode); enum armv4_5_mode armv4_5_number_to_mode(int number); -extern const char **armv4_5_mode_strings; - typedef enum armv4_5_state { ARMV4_5_STATE_ARM, diff --git a/src/target/armv7a.c b/src/target/armv7a.c index 1518674..e13b33b 100644 --- a/src/target/armv7a.c +++ b/src/target/armv7a.c @@ -47,15 +47,6 @@ char* armv7a_core_reg_list[] = "r13_mon", "lr_mon", "spsr_mon" }; -char * armv7a_mode_strings_list[] = -{ - "Illegal mode value", "User", "FIQ", "IRQ", - "Supervisor", "Abort", "Undefined", "System", "Monitor" -}; - -/* Hack! Yuk! allow -1 index, which simplifies codepaths elsewhere in the code */ -char** armv7a_mode_strings = armv7a_mode_strings_list+1; - char* armv7a_state_strings[] = { "ARM", "Thumb", "Jazelle", "ThumbEE" @@ -183,8 +174,7 @@ int armv7a_arch_state(struct target *target) armv7a_state_strings[armv7a->core_state], Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason)->name, - armv7a_mode_strings[ - armv7a_mode_to_number(armv4_5->core_mode)], + arm_mode_name(armv4_5->core_mode), armv7a_core_reg_list[armv7a_core_reg_map[ armv7a_mode_to_number(armv4_5->core_mode)][16]], buf_get_u32(ARMV7A_CORE_REG_MODE(armv4_5->core_cache, diff --git a/src/target/armv7a.h b/src/target/armv7a.h index 4d29ef9..e781e72 100644 --- a/src/target/armv7a.h +++ b/src/target/armv7a.h @@ -37,8 +37,6 @@ typedef enum armv7a_mode ARMV7A_MODE_ANY = -1 } armv7a_t; -extern char **armv7a_mode_strings; - typedef enum armv7a_state { ARMV7A_STATE_ARM, diff --git a/src/target/xscale.c b/src/target/xscale.c index a4a8eab..38928f4 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -857,7 +857,7 @@ static int xscale_arch_state(struct target *target) "%s", armv4_5_state_strings[armv4_5->core_state], Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason)->name , - armv4_5_mode_strings[armv4_5_mode_to_number(armv4_5->core_mode)], + arm_mode_name(armv4_5->core_mode), buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32), buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32), state[xscale->armv4_5_mmu.mmu_enabled], @@ -960,7 +960,8 @@ static int xscale_debug_entry(struct target *target) LOG_ERROR("cpsr contains invalid mode value - communication failure"); return ERROR_TARGET_FAILURE; } - LOG_DEBUG("target entered debug state in %s mode", armv4_5_mode_strings[armv4_5_mode_to_number(armv4_5->core_mode)]); + LOG_DEBUG("target entered debug state in %s mode", + arm_mode_name(armv4_5->core_mode)); if (buffer[9] & 0x20) armv4_5->core_state = ARMV4_5_STATE_THUMB; commit d6c8945662e6027f6ba12d73bac2473088672db5 Author: David Brownell <dbr...@us...> Date: Tue Nov 17 23:50:17 2009 -0800 ARM: only use one set of dummy FPA registers All ARM cores need to provide obsolete FPA registers in their GDB register dumps. (Even though cores with floating point support now generally use some version of VFP...) Clean up that support a bit by sharing the same dummy registers, and removing the duplicate copies. Eventually we shouldn't need to export those dummies. (This makes the ARMv7-M support include the armv4_5 header, and cleans up related #includes, but doesn't yet use anything from there except those dummies.) Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/flash/lpc2000.c b/src/flash/lpc2000.c index 191eb4b..5442e71 100644 --- a/src/flash/lpc2000.c +++ b/src/flash/lpc2000.c @@ -26,7 +26,6 @@ #endif #include "lpc2000.h" -#include "armv4_5.h" #include "armv7m.h" #include "binarybuffer.h" #include "algorithm.h" diff --git a/src/target/arm11.c b/src/target/arm11.c index 65e0780..5e73275 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -246,36 +246,6 @@ enum arm11_regcache_ids #define ARM11_GDB_REGISTER_COUNT 26 -/* FIXME these are *identical* to the ARMv4_5 dummies ... except - * for their names, and being static vs global, and having different - * addresses. Ditto ARMv7a and ARMv7m dummies. - */ - -static uint8_t arm11_gdb_dummy_fp_value[12]; - -static struct reg arm11_gdb_dummy_fp_reg = -{ - .name = "GDB dummy floating-point register", - .value = arm11_gdb_dummy_fp_value, - .dirty = 0, - .valid = 1, - .size = 96, - .arch_info = NULL, -}; - -static uint8_t arm11_gdb_dummy_fps_value[4]; - -static struct reg arm11_gdb_dummy_fps_reg = -{ - .name = "GDB dummy floating-point status register", - .value = arm11_gdb_dummy_fps_value, - .dirty = 0, - .valid = 1, - .size = 32, - .arch_info = NULL, -}; - - static int arm11_on_enter_debug_state(struct arm11_common *arm11); static int arm11_step(struct target *target, int current, uint32_t address, int handle_breakpoints); @@ -1265,12 +1235,10 @@ static int arm11_get_gdb_reg_list(struct target *target, *reg_list_size = ARM11_GDB_REGISTER_COUNT; *reg_list = malloc(sizeof(struct reg*) * ARM11_GDB_REGISTER_COUNT); + /* nine unused legacy FPA registers are expected by GDB */ for (size_t i = 16; i < 24; i++) - { - (*reg_list)[i] = &arm11_gdb_dummy_fp_reg; - } - - (*reg_list)[24] = &arm11_gdb_dummy_fps_reg; + (*reg_list)[i] = &arm_gdb_dummy_fp_reg; + (*reg_list)[24] = &arm_gdb_dummy_fps_reg; for (size_t i = 0; i < ARM11_REGCACHE_COUNT; i++) { @@ -1954,9 +1922,6 @@ static int arm11_build_reg_cache(struct target *target) NEW(struct reg, reg_list, ARM11_REGCACHE_COUNT); NEW(struct arm11_reg_state, arm11_reg_states, ARM11_REGCACHE_COUNT); - register_init_dummy(&arm11_gdb_dummy_fp_reg); - register_init_dummy(&arm11_gdb_dummy_fps_reg); - arm11->reg_list = reg_list; /* Build the process context cache */ diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 6f8d14c..aba4431 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -189,30 +189,44 @@ int armv4_5_core_reg_map[7][17] = } }; -uint8_t armv4_5_gdb_dummy_fp_value[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +static const uint8_t arm_gdb_dummy_fp_value[12]; -struct reg armv4_5_gdb_dummy_fp_reg = +/** + * Dummy FPA registers are required to support GDB on ARM. + * Register packets require eight obsolete FPA register values. + * Modern ARM cores use Vector Floating Point (VFP), if they + * have any floating point support. VFP is not FPA-compatible. + */ +struct reg arm_gdb_dummy_fp_reg = { - .name = "GDB dummy floating-point register", - .value = armv4_5_gdb_dummy_fp_value, - .dirty = 0, + .name = "GDB dummy FPA register", + .value = (uint8_t *) arm_gdb_dummy_fp_value, .valid = 1, .size = 96, - .arch_info = NULL, }; -uint8_t armv4_5_gdb_dummy_fps_value[] = {0, 0, 0, 0}; +static const uint8_t arm_gdb_dummy_fps_value[4]; -struct reg armv4_5_gdb_dummy_fps_reg = +/** + * Dummy FPA status registers are required to support GDB on ARM. + * Register packets require an obsolete FPA status register. + */ +struct reg arm_gdb_dummy_fps_reg = { - .name = "GDB dummy floating-point status register", - .value = armv4_5_gdb_dummy_fps_value, - .dirty = 0, + .name = "GDB dummy FPA status register", + .value = (uint8_t *) arm_gdb_dummy_fps_value, .valid = 1, .size = 32, - .arch_info = NULL, }; +static void arm_gdb_dummy_init(void) __attribute__ ((constructor)); + +static void arm_gdb_dummy_init(void) +{ + register_init_dummy(&arm_gdb_dummy_fp_reg); + register_init_dummy(&arm_gdb_dummy_fps_reg); +} + int armv4_5_get_core_reg(struct reg *reg) { int retval; @@ -313,9 +327,6 @@ struct reg_cache* armv4_5_build_reg_cache(struct target *target, struct arm *arm cache->reg_list = reg_list; cache->num_regs = num_regs; - register_init_dummy(&armv4_5_gdb_dummy_fp_reg); - register_init_dummy(&armv4_5_gdb_dummy_fps_reg); - for (i = 0; i < 37; i++) { arch_info[i] = armv4_5_core_reg_list_arch_info[i]; @@ -550,10 +561,10 @@ int armv4_5_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int for (i = 16; i < 24; i++) { - (*reg_list)[i] = &armv4_5_gdb_dummy_fp_reg; + (*reg_list)[i] = &arm_gdb_dummy_fp_reg; } - (*reg_list)[24] = &armv4_5_gdb_dummy_fps_reg; + (*reg_list)[24] = &arm_gdb_dummy_fps_reg; (*reg_list)[25] = &armv4_5->core_cache->reg_list[ARMV4_5_CPSR]; return ERROR_OK; diff --git a/src/target/armv4_5.h b/src/target/armv4_5.h index 5fef094..d126f96 100644 --- a/src/target/armv4_5.h +++ b/src/target/armv4_5.h @@ -158,6 +158,8 @@ int arm_checksum_memory(struct target *target, int arm_blank_check_memory(struct target *target, uint32_t address, uint32_t count, uint32_t *blank); +extern struct reg arm_gdb_dummy_fp_reg; +extern struct reg arm_gdb_dummy_fps_reg; /* ARM mode instructions */ diff --git a/src/target/armv7a.c b/src/target/armv7a.c index 8f90dd3..1518674 100644 --- a/src/target/armv7a.c +++ b/src/target/armv7a.c @@ -144,21 +144,6 @@ int armv7a_core_reg_map[8][17] = } }; -/* FIXME this dummy is IDENTICAL to the armv4_5, arm11, and armv7m - * ones... except for naming/scoping - */ -uint8_t armv7a_gdb_dummy_fp_value[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - -struct reg armv7a_gdb_dummy_fp_reg = -{ - .name = "GDB dummy floating-point register", - .value = armv7a_gdb_dummy_fp_value, - .dirty = 0, - .valid = 1, - .size = 96, - .arch_info = NULL, -}; - void armv7a_show_fault_registers(struct target *target) { uint32_t dfsr, ifsr, dfar, ifar; diff --git a/src/target/armv7m.c b/src/target/armv7m.c index 862261d..56fbb05 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -35,7 +35,6 @@ #endif #include "breakpoints.h" -#include "target.h" #include "armv7m.h" #include "algorithm.h" #include "register.h" @@ -59,33 +58,6 @@ static char *armv7m_exception_strings[] = "DebugMonitor", "RESERVED", "PendSV", "SysTick" }; -/* FIXME these dummies are IDENTICAL to the armv4_5, arm11, and armv7a - * ones... except for naming/scoping - */ -static uint8_t armv7m_gdb_dummy_fp_value[12]; - -static struct reg armv7m_gdb_dummy_fp_reg = -{ - .name = "GDB dummy floating-point register", - .value = armv7m_gdb_dummy_fp_value, - .dirty = 0, - .valid = 1, - .size = 96, - .arch_info = NULL, -}; - -static uint8_t armv7m_gdb_dummy_fps_value[4]; - -static struct reg armv7m_gdb_dummy_fps_reg = -{ - .name = "GDB dummy floating-point status register", - .value = armv7m_gdb_dummy_fps_value, - .dirty = 0, - .valid = 1, - .size = 32, - .arch_info = NULL, -}; - #ifdef ARMV7_GDB_HACKS uint8_t armv7m_gdb_dummy_cpsr_value[] = {0, 0, 0, 0}; @@ -316,11 +288,8 @@ int armv7m_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int } for (i = 16; i < 24; i++) - { - (*reg_list)[i] = &armv7m_gdb_dummy_fp_reg; - } - - (*reg_list)[24] = &armv7m_gdb_dummy_fps_reg; + (*reg_list)[i] = &arm_gdb_dummy_fp_reg; + (*reg_list)[24] = &arm_gdb_dummy_fps_reg; #ifdef ARMV7_GDB_HACKS /* use dummy cpsr reg otherwise gdb may try and set the thumb bit */ @@ -553,11 +522,9 @@ struct reg_cache *armv7m_build_reg_cache(struct target *target) struct armv7m_core_reg *arch_info = calloc(num_regs, sizeof(struct armv7m_core_reg)); int i; - register_init_dummy(&armv7m_gdb_dummy_fps_reg); #ifdef ARMV7_GDB_HACKS register_init_dummy(&armv7m_gdb_dummy_cpsr_reg); #endif - register_init_dummy(&armv7m_gdb_dummy_fp_reg); /* Build the process context cache */ cache->name = "arm v7m registers"; diff --git a/src/target/armv7m.h b/src/target/armv7m.h index dba9a3b..9dd4ddb 100644 --- a/src/target/armv7m.h +++ b/src/target/armv7m.h @@ -27,6 +27,7 @@ #define ARMV7M_COMMON_H #include "arm_adi_v5.h" +#include "armv4_5.h" /* define for enabling armv7 gdb workarounds */ #if 1 diff --git a/src/target/cortex_m3.c b/src/target/cortex_m3.c index c9938c9..42f8ee0 100644 --- a/src/target/cortex_m3.c +++ b/src/target/cortex_m3.c @@ -334,6 +334,9 @@ static int cortex_m3_debug_entry(struct target *target) xPSR = buf_get_u32(armv7m->core_cache->reg_list[ARMV7M_xPSR].value, 0, 32); #ifdef ARMV7_GDB_HACKS + /* FIXME this breaks on scan chains with more than one Cortex-M3. + * Instead, each CM3 should have its own dummy value... + */ /* copy real xpsr reg for gdb, setting thumb bit */ buf_set_u32(armv7m_gdb_dummy_cpsr_value, 0, 32, xPSR); buf_set_u32(armv7m_gdb_dummy_cpsr_value, 5, 1, 1); diff --git a/src/target/cortex_m3.h b/src/target/cortex_m3.h index 759c2bc..7ce8901 100644 --- a/src/target/cortex_m3.h +++ b/src/target/cortex_m3.h @@ -26,7 +26,6 @@ #ifndef CORTEX_M3_H #define CORTEX_M3_H -#include "target.h" #include "armv7m.h" ----------------------------------------------------------------------- Summary of changes: src/flash/lpc2000.c | 1 - src/target/arm11.c | 43 +------------ src/target/arm720t.c | 2 +- src/target/arm7_9_common.c | 34 +++++------ src/target/arm920t.c | 10 ++-- src/target/arm926ejs.c | 2 +- src/target/armv4_5.c | 139 +++++++++++++++++++++++++++++++++---------- src/target/armv4_5.h | 12 ++-- src/target/armv7a.c | 27 +-------- src/target/armv7a.h | 2 - src/target/armv7m.c | 37 +----------- src/target/armv7m.h | 1 + src/target/cortex_m3.c | 3 + src/target/cortex_m3.h | 1 - src/target/xscale.c | 10 +-- 15 files changed, 150 insertions(+), 174 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Zach W. <zw...@us...> - 2009-11-17 21:11:14
|
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 0091e59d2a18c293fd952a9d707e609afdd6b17f (commit) via 94975c96d4f1f614e0877cac32ed5949cd0235f6 (commit) from 789d47c18097abb5ee6cc8544e0ba030000fd418 (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 0091e59d2a18c293fd952a9d707e609afdd6b17f Author: Zachary T Welch <zw...@su...> Date: Tue Nov 17 06:54:56 2009 -0800 allow documentation to be configured Add --disable-doxygen-html and --enable-doxygen-pdf options to the configure script, allowing user to change the defaults. These update the proess of munging the Doxygen configuration file to use the settings thusly provided. Add options in README. diff --git a/Doxyfile.in b/Doxyfile.in index 077db10..49630f2 100644 --- a/Doxyfile.in +++ b/Doxyfile.in @@ -764,7 +764,7 @@ IGNORE_PREFIX = # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. -GENERATE_HTML = YES +GENERATE_HTML = @doxygen_as_html@ # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be @@ -981,7 +981,7 @@ FORMULA_FONTSIZE = 10 # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. -GENERATE_LATEX = YES +GENERATE_LATEX = @doxygen_as_pdf@ # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be diff --git a/Makefile.am b/Makefile.am index be42c28..c067712 100644 --- a/Makefile.am +++ b/Makefile.am @@ -25,7 +25,9 @@ Doxyfile: $(srcdir)/Doxyfile.in @( \ echo "### @@@ -= DO NOT EDIT THIS FILE =- @@@ ###" && \ echo "### @@@ Make changes to Doxyfile.in @@@ ###" && \ - sed -e 's,@srcdir\@,$(srcdir),' $< \ + sed -e 's,@srcdir\@,$(srcdir),' \ + -e 's,@doxygen_as_html\@,$(doxygen_as_html),' \ + -e 's,@doxygen_as_pdf\@,$(doxygen_as_pdf),' $< \ ) > $@ THE_MANUAL = doxygen/latex/refman.pdf diff --git a/README b/README index 33258e8..0ba6f76 100644 --- a/README +++ b/README @@ -258,6 +258,9 @@ options may be available there: --enable-httpd Enable builtin httpd server - useful for standalone OpenOCD implementations + --disable-doxygen-html Disable building Doxygen manual as HTML. + --enable-doxygen-pdf Enable building Doxygen manual as PDF. + Miscellaneous Configure Options ------------------------------- diff --git a/configure.in b/configure.in index fa2a498..8ba8951 100644 --- a/configure.in +++ b/configure.in @@ -277,6 +277,24 @@ AC_ARG_WITH(ftd2xx-lib, with_ftd2xx_lib=static ]) + +AC_ARG_ENABLE(doxygen-html, + AS_HELP_STRING([--disable-doxygen-html], + [Disable building Doxygen manual as HTML.]), + [doxygen_as_html=$enableval], [doxygen_as_html=yes]) +AC_SUBST(doxygen_as_html) +AC_MSG_CHECKING([whether to build Doxygen as HTML]) +AC_MSG_RESULT($doxygen_as_html) + +AC_ARG_ENABLE(doxygen-pdf, + AS_HELP_STRING([--enable-doxygen-pdf], + [Enable building Doxygen manual as PDF.]), + [doxygen_as_pdf=$enableval], [doxygen_as_pdf=no]) +AC_SUBST(doxygen_as_pdf) +AC_MSG_CHECKING([whether to build Doxygen as PDF]) +AC_MSG_RESULT($doxygen_as_pdf) + + AC_ARG_ENABLE(gccwarnings, AS_HELP_STRING([--disable-gccwarnings], [Disable compiler warnings]), [gcc_warnings=$enableval], [gcc_warnings=yes]) commit 94975c96d4f1f614e0877cac32ed5949cd0235f6 Author: Zachary T Welch <zw...@su...> Date: Tue Nov 17 06:04:03 2009 -0800 update doxygen configuration to produce a PDF A single PDF file for the developer manual allows accessing a single index, browsing, and searching. It takes significantly more time to build this way, but this patch allows others to look at the results. Migration Tip: If you have previously built the HTML Doxygen documentatation, rename your 'doxygen' directory to 'doxygen/html' to prevent needlessly rebuilding those files. diff --git a/Doxyfile.in b/Doxyfile.in index 038f1e5..077db10 100644 --- a/Doxyfile.in +++ b/Doxyfile.in @@ -38,7 +38,7 @@ PROJECT_NUMBER = # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = +OUTPUT_DIRECTORY = doxygen # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output @@ -770,7 +770,7 @@ GENERATE_HTML = YES # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. -HTML_OUTPUT = doxygen +HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank @@ -981,7 +981,7 @@ FORMULA_FONTSIZE = 10 # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. -GENERATE_LATEX = NO +GENERATE_LATEX = YES # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be @@ -992,7 +992,7 @@ LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. -LATEX_CMD_NAME = latex +LATEX_CMD_NAME = pdflatex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the @@ -1004,7 +1004,7 @@ MAKEINDEX_CMD_NAME = makeindex # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. -COMPACT_LATEX = NO +COMPACT_LATEX = YES # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and @@ -1029,20 +1029,20 @@ LATEX_HEADER = # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. -PDF_HYPERLINKS = NO +PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. -USE_PDFLATEX = NO +USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. -LATEX_BATCHMODE = NO +LATEX_BATCHMODE = YES # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) diff --git a/Makefile.am b/Makefile.am index dc4166d..be42c28 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,9 +28,16 @@ Doxyfile: $(srcdir)/Doxyfile.in sed -e 's,@srcdir\@,$(srcdir),' $< \ ) > $@ +THE_MANUAL = doxygen/latex/refman.pdf + doxygen:: $(MAKE) Doxyfile doxygen Doxyfile 2>&1 | perl $(srcdir)/tools/logger.pl > doxygen.log + $(MAKE) $(THE_MANUAL) + +%.pdf: %.tex + -cd $$(dirname $*) && pdflatex $$(basename $*) + -cd $$(dirname $*) && pdflatex $$(basename $*) TCL_PATH = tcl # command to find paths of script files, relative to TCL_PATH ----------------------------------------------------------------------- Summary of changes: Doxyfile.in | 18 +++++++++--------- Makefile.am | 11 ++++++++++- README | 3 +++ configure.in | 18 ++++++++++++++++++ 4 files changed, 40 insertions(+), 10 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Zach W. <zw...@us...> - 2009-11-17 20:42:21
|
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 789d47c18097abb5ee6cc8544e0ba030000fd418 (commit) via cfaf7bdd0aedb23a4837078db808be450e5efc30 (commit) via cffc98ad8047b6dc8d38a6422136638f2df992d2 (commit) via be084414ba00a4ad641af04c3c6858312dd1b336 (commit) via 2861877b32a7a2f4022a1c3d9b66c9b4879878ac (commit) via 23402315ce01071f30d7ec0c5ca7563ce41f1cc6 (commit) via 7bf1a86e473a12882bf6f71cb4d0d416394b69d4 (commit) via 5b9899d6ea1e0cf763465c64c700f20eddd893f9 (commit) from f4788652e45662d1e43933dc0620561bc4cddae0 (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 789d47c18097abb5ee6cc8544e0ba030000fd418 Author: Zachary T Welch <zw...@su...> Date: Tue Nov 17 05:38:17 2009 -0800 update command_handler documentation Improve the developer manual and primer sections which talk about writing command handlers. Notably, it documents the new CMD_* macros. diff --git a/doc/manual/helper.txt b/doc/manual/helper.txt index 247d7b4..e7454b6 100644 --- a/doc/manual/helper.txt +++ b/doc/manual/helper.txt @@ -45,16 +45,16 @@ another layer of handlers. @subsection helpercmdhandlerdef Defining and Calling Command Handlers -These functions should be defined using the COMMAND_HANDLER macro. +These functions should be defined using the @c COMMAND_HANDLER macro. These methods must be defined as static, as their principle entry point should be the run_command dispatch mechanism. Command helper functions that require access to the full set of -parameters should be defined using the COMMAND_HELPER. These must be +parameters should be defined using the @c COMMAND_HELPER. These must be declared static by you, as sometimes you might want to share a helper -among several files (e.g. s3c24xx_nand.h). +among several files (e.g. @c s3c24xx_nand.h). -Both types of routines must be called using the CALL_COMMAND_HANDLER macro. +Both types of routines must be called using the @c CALL_COMMAND_HANDLER macro. Calls using this macro to normal handlers require the name of the command handler (which can a name or function pointer). Calls to helpers and derived handlers must pass those extra parameters specified by their @@ -67,22 +67,18 @@ will be able to use direct invocations. Thus, the following macros can be used to define and call command handlers or helpers: -- COMMAND_HANDLER - declare or define a command handler. -- COMMAND_HELPER - declare or define a derived command handler or helper. -- CALL_COMMAND_COMMAND - call a command handler/helper. - -@subsection helpercmdhandlerparam Command Handler Parameters - -The following parameters are defined in the scope of all command -handlers and helpers: -- <code>struct command_context *cmd_ctx</code> - the command's context -- <code>unsigned argc</code> - the number of command arguments -- <code>const char *args[]</code> - contains the command arguments +- @c COMMAND_HANDLER - declare or define a command handler. +- @c COMMAND_HELPER - declare or define a derived command handler or helper. +- @c CALL_COMMAND_COMMAND - call a command handler/helper. @subsection helpercmdhandlermacros Command Handler Macros -In addition, the following macro may be used: -- <code>COMMAND_NAME</code> - contains the command name +In addition, the following macros may be used in the context of +command handlers and helpers: +- @c CMD_CTX - the current @c command_context +- @c CMD_NAME - invoked command name +- @c CMD_ARGC - the number of command arguments +- @c CMD_ARGV - array of command argument strings @section helpercmdprimer Command Development Primer diff --git a/doc/manual/primer/commands.txt b/doc/manual/primer/commands.txt index 9efcca2..b15f669 100644 --- a/doc/manual/primer/commands.txt +++ b/doc/manual/primer/commands.txt @@ -16,7 +16,7 @@ COMMAND_HANDLER(handle_hello_command) const char *sep, *name; int retval = CALL_COMMAND_HANDLER(handle_hello_args); if (ERROR_OK == retval) - command_print(cmd_ctx, "Greetings%s%s!", sep, name); + command_print(CMD_CTX, "Greetings%s%s!", sep, name); return retval; } @endcode @@ -39,13 +39,13 @@ static COMMAND_HELPER(handle_hello_args, const char **sep, const char **name) { if (argc > 1) { - LOG_ERROR("%s: too many arguments", COMMAND_NAME); + LOG_ERROR("%s: too many arguments", CMD_NAME); return ERROR_COMMAND_SYNTAX_ERROR; } - if (1 == argc) + if (1 == CMD_ARGC) { *sep = ", "; - *name = args[0]; + *name = CMD_ARGV[0]; } else *sep = *name = ""; @@ -96,4 +96,9 @@ Greetings, John Doe! Error: ocd_hello: too many arguments @endcode +This difference between the registered and displayed command name comes from +the fact that the TCL scripts are provided with a stub that calls the munged +name. This stub wraps the internal <code>ocd_</code>-prefixed routine, +providing a measure of high-level error handling. + */ commit cfaf7bdd0aedb23a4837078db808be450e5efc30 Author: Zachary T Welch <zw...@su...> Date: Mon Nov 16 15:45:17 2009 -0800 remove unused variable from run_command diff --git a/src/helper/command.c b/src/helper/command.c index b9d0d08..ad09e3d 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -438,7 +438,6 @@ char *command_name(struct command *c, char delim) static int run_command(struct command_context *context, struct command *c, const char *words[], unsigned num_words) { - int start_word = 0; if (!((context->mode == COMMAND_CONFIG) || (c->mode == COMMAND_ANY) || (c->mode == context->mode))) { /* Config commands can not run after the config stage */ @@ -449,8 +448,8 @@ static int run_command(struct command_context *context, struct command_invocation cmd = { .ctx = context, .name = c->name, - .argc = num_words - start_word - 1, - .argv = words + start_word + 1, + .argc = num_words - 1, + .argv = words + 1, }; int retval = c->handler(&cmd); if (retval == ERROR_COMMAND_SYNTAX_ERROR) commit cffc98ad8047b6dc8d38a6422136638f2df992d2 Author: Zachary T Welch <zw...@su...> Date: Mon Nov 16 05:46:15 2009 -0800 add CMD_NAME variable in command_invocation Update CMD_NAME from its migratory home in CMD_ARGV[-1] to cmd->name. Allows CMD_ARGV++ idiom to be used safely in command handlers. diff --git a/src/helper/command.c b/src/helper/command.c index 96d23ab..b9d0d08 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -102,8 +102,7 @@ static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv) script_debug(interp, c->name, argc, argv); - words = malloc(sizeof(char *) * (argc + 1)); - words[0] = c->name; + words = malloc(argc * sizeof(char *)); for (i = 0; i < argc; i++) { int len; @@ -113,12 +112,12 @@ static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv) /* hit an end of line comment */ break; } - words[i + 1] = strdup(w); - if (words[i + 1] == NULL) + words[i] = strdup(w); + if (words[i] == NULL) { int j; for (j = 0; j < i; j++) - free(words[j + 1]); + free(words[j]); free(words); return JIM_ERR; } @@ -143,7 +142,7 @@ static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv) log_add_callback(tcl_output, tclOutput); // turn words[0] into CMD_ARGV[-1] with this cast - retval = run_command(context, c, (const char **)words + 1, nwords); + retval = run_command(context, c, (const char **)words, nwords); log_remove_callback(tcl_output, tclOutput); @@ -152,7 +151,7 @@ static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv) Jim_DecrRefCount(interp, tclOutput); for (i = 0; i < nwords; i++) - free(words[i + 1]); + free(words[i]); free(words); int *return_retval = Jim_GetAssocData(interp, "retval"); @@ -449,6 +448,7 @@ static int run_command(struct command_context *context, struct command_invocation cmd = { .ctx = context, + .name = c->name, .argc = num_words - start_word - 1, .argv = words + start_word + 1, }; diff --git a/src/helper/command.h b/src/helper/command.h index b8ea3a4..62231fc 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -87,6 +87,7 @@ struct command_context */ struct command_invocation { struct command_context *ctx; + const char *name; unsigned argc; const char **argv; }; @@ -149,7 +150,7 @@ struct command_invocation { * Use this macro to access the name of the command being handled, * rather than accessing the variable directly. It may be moved. */ -#define CMD_NAME CMD_ARGV[-1] +#define CMD_NAME cmd->name /// The type signature for commands' handler functions. commit be084414ba00a4ad641af04c3c6858312dd1b336 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 15 04:21:17 2009 -0800 add struct command_invocation for COMMAND_HANDLER Adds the command_invocation structure to encapsulate parameters for all COMMAND_HANDLER routines. Rather than passing several arguments to each successive subroutine, a single pointer may be passed around. Changes the CMD_* macros to reference the new fields. Updates run_command to create an instance and pass it to the handler. diff --git a/src/helper/command.c b/src/helper/command.c index fdb59f0..96d23ab 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -447,9 +447,12 @@ static int run_command(struct command_context *context, return ERROR_FAIL; } - unsigned argc = num_words - start_word - 1; - const char **args = words + start_word + 1; - int retval = c->handler(context, args, argc); + struct command_invocation cmd = { + .ctx = context, + .argc = num_words - start_word - 1, + .argv = words + start_word + 1, + }; + int retval = c->handler(&cmd); if (retval == ERROR_COMMAND_SYNTAX_ERROR) { /* Print help for command */ diff --git a/src/helper/command.h b/src/helper/command.h index 7484964..b8ea3a4 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -80,6 +80,16 @@ struct command_context void *output_handler_priv; }; +/** + * When run_command is called, a new instance will be created on the + * stack, filled with the proper values, and passed by reference to the + * required COMMAND_HANDLER routine. + */ +struct command_invocation { + struct command_context *ctx; + unsigned argc; + const char **argv; +}; /** * Command handlers may be defined with more parameters than the base @@ -87,8 +97,7 @@ struct command_context * defining all such derivative types using this macro. */ #define __COMMAND_HANDLER(name, extra...) \ - int name(struct command_context *cmd_ctx, \ - const char *args[], unsigned argc, ##extra) + int name(struct command_invocation *cmd, ##extra) /** * Use this to macro to call a command helper (or a nested handler). @@ -104,7 +113,7 @@ struct command_context * variables in intervening scope(s) by accident. */ #define CALL_COMMAND_HANDLER(name, extra...) \ - name(cmd_ctx, args, argc, ##extra) + name(cmd, ##extra) /** * Always use this macro to define new command handler functions. @@ -125,17 +134,17 @@ struct command_context * Use this macro to access the context of the command being handled, * rather than accessing the variable directly. It may be moved. */ -#define CMD_CTX cmd_ctx +#define CMD_CTX cmd->ctx /** * Use this macro to access the number of arguments for the command being * handled, rather than accessing the variable directly. It may be moved. */ -#define CMD_ARGC argc +#define CMD_ARGC cmd->argc /** * Use this macro to access the arguments for the command being handled, * rather than accessing the variable directly. It may be moved. */ -#define CMD_ARGV args +#define CMD_ARGV cmd->argv /** * Use this macro to access the name of the command being handled, * rather than accessing the variable directly. It may be moved. commit 2861877b32a7a2f4022a1c3d9b66c9b4879878ac Author: Zachary T Welch <zw...@su...> Date: Sun Nov 15 05:57:37 2009 -0800 command_handler: change 'cmd_ctx' to CMD_CTX Convert all command handler 'cmd_ctx' parameter usage with CMD_CTX. diff --git a/src/flash/at91sam3.c b/src/flash/at91sam3.c index 4cf4d20..195da91 100644 --- a/src/flash/at91sam3.c +++ b/src/flash/at91sam3.c @@ -2267,7 +2267,7 @@ COMMAND_HANDLER(sam3_handle_info_command) unsigned x; int r; - pChip = get_current_sam3(cmd_ctx); + pChip = get_current_sam3(CMD_CTX); if (!pChip) { return ERROR_OK; } @@ -2278,7 +2278,7 @@ COMMAND_HANDLER(sam3_handle_info_command) if (pChip->details.bank[0].pBank == NULL) { x = 0; need_define: - command_print(cmd_ctx, + command_print(CMD_CTX, "Please define bank %d via command: flash bank %s ... ", x, at91sam3_flash.name); @@ -2329,7 +2329,7 @@ COMMAND_HANDLER(sam3_handle_info_command) // print results cp = membuf_strtok(pChip->mbuf, "\n", &vp); while (cp) { - command_print(cmd_ctx,"%s", cp); + command_print(CMD_CTX,"%s", cp); cp = membuf_strtok(NULL, "\n", &vp); } return ERROR_OK; @@ -2341,7 +2341,7 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command) int r,who; struct sam3_chip *pChip; - pChip = get_current_sam3(cmd_ctx); + pChip = get_current_sam3(CMD_CTX); if (!pChip) { return ERROR_OK; } @@ -2353,7 +2353,7 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command) if (pChip->details.bank[0].pBank == NULL) { - command_print(cmd_ctx, "Bank0 must be defined first via: flash bank %s ...", + command_print(CMD_CTX, "Bank0 must be defined first via: flash bank %s ...", at91sam3_flash.name); return ERROR_FAIL; } @@ -2367,7 +2367,7 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command) switch (CMD_ARGC) { default: - command_print(cmd_ctx,"Too many parameters\n"); + command_print(CMD_CTX,"Too many parameters\n"); return ERROR_COMMAND_SYNTAX_ERROR; break; case 0: @@ -2397,22 +2397,22 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command) if (r != ERROR_OK) { break; } - command_print(cmd_ctx, "sam3-gpnvm%u: %u", x, v); + command_print(CMD_CTX, "sam3-gpnvm%u: %u", x, v); } return r; } if ((who >= 0) && (((unsigned)(who)) < pChip->details.n_gpnvms)) { r = FLASHD_GetGPNVM(&(pChip->details.bank[0]), who, &v); - command_print(cmd_ctx, "sam3-gpnvm%u: %u", who, v); + command_print(CMD_CTX, "sam3-gpnvm%u: %u", who, v); return r; } else { - command_print(cmd_ctx, "sam3-gpnvm invalid GPNVM: %u", who); + command_print(CMD_CTX, "sam3-gpnvm invalid GPNVM: %u", who); return ERROR_COMMAND_SYNTAX_ERROR; } } if (who == -1) { - command_print(cmd_ctx, "Missing GPNVM number"); + command_print(CMD_CTX, "Missing GPNVM number"); return ERROR_COMMAND_SYNTAX_ERROR; } @@ -2422,7 +2422,7 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command) (0 == strcmp("clear", CMD_ARGV[0]))) { // quietly accept both r = FLASHD_ClrGPNVM(&(pChip->details.bank[0]), who); } else { - command_print(cmd_ctx, "Unkown command: %s", CMD_ARGV[0]); + command_print(CMD_CTX, "Unkown command: %s", CMD_ARGV[0]); r = ERROR_COMMAND_SYNTAX_ERROR; } return r; @@ -2432,7 +2432,7 @@ COMMAND_HANDLER(sam3_handle_slowclk_command) { struct sam3_chip *pChip; - pChip = get_current_sam3(cmd_ctx); + pChip = get_current_sam3(CMD_CTX); if (!pChip) { return ERROR_OK; } @@ -2449,7 +2449,7 @@ COMMAND_HANDLER(sam3_handle_slowclk_command) COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], v); if (v > 200000) { // absurd slow clock of 200Khz? - command_print(cmd_ctx,"Absurd/illegal slow clock freq: %d\n", (int)(v)); + command_print(CMD_CTX,"Absurd/illegal slow clock freq: %d\n", (int)(v)); return ERROR_COMMAND_SYNTAX_ERROR; } pChip->cfg.slow_freq = v; @@ -2457,11 +2457,11 @@ COMMAND_HANDLER(sam3_handle_slowclk_command) } default: // error - command_print(cmd_ctx,"Too many parameters"); + command_print(CMD_CTX,"Too many parameters"); return ERROR_COMMAND_SYNTAX_ERROR; break; } - command_print(cmd_ctx, "Slowclk freq: %d.%03dkhz", + command_print(CMD_CTX, "Slowclk freq: %d.%03dkhz", (int)(pChip->cfg.slow_freq/ 1000), (int)(pChip->cfg.slow_freq% 1000)); return ERROR_OK; diff --git a/src/flash/at91sam7.c b/src/flash/at91sam7.c index d23d2b0..3e5dbdd 100644 --- a/src/flash/at91sam7.c +++ b/src/flash/at91sam7.c @@ -1109,7 +1109,7 @@ COMMAND_HANDLER(at91sam7_handle_gpnvm_command) if (CMD_ARGC != 2) { - command_print(cmd_ctx, "at91sam7 gpnvm <bit> <set | clear>"); + command_print(CMD_CTX, "at91sam7 gpnvm <bit> <set | clear>"); return ERROR_OK; } @@ -1120,7 +1120,7 @@ COMMAND_HANDLER(at91sam7_handle_gpnvm_command) } if (strcmp(bank->driver->name, "at91sam7")) { - command_print(cmd_ctx, "not an at91sam7 flash bank '%s'", CMD_ARGV[0]); + command_print(CMD_CTX, "not an at91sam7 flash bank '%s'", CMD_ARGV[0]); return ERROR_FLASH_BANK_INVALID; } if (bank->target->state != TARGET_HALTED) @@ -1155,7 +1155,7 @@ COMMAND_HANDLER(at91sam7_handle_gpnvm_command) COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], bit); if ((bit < 0) || (bit >= at91sam7_info->num_nvmbits)) { - command_print(cmd_ctx, "gpnvm bit '#%s' is out of bounds for target %s", CMD_ARGV[0], at91sam7_info->target_name); + command_print(CMD_CTX, "gpnvm bit '#%s' is out of bounds for target %s", CMD_ARGV[0], at91sam7_info->target_name); return ERROR_OK; } diff --git a/src/flash/avrf.c b/src/flash/avrf.c index f1db3c4..20c619d 100644 --- a/src/flash/avrf.c +++ b/src/flash/avrf.c @@ -421,7 +421,7 @@ COMMAND_HANDLER(avrf_handle_mass_erase_command) if (CMD_ARGC < 1) { - command_print(cmd_ctx, "avr mass_erase <bank>"); + command_print(CMD_CTX, "avr mass_erase <bank>"); return ERROR_OK; } @@ -438,11 +438,11 @@ COMMAND_HANDLER(avrf_handle_mass_erase_command) bank->sectors[i].is_erased = 1; } - command_print(cmd_ctx, "avr mass erase complete"); + command_print(CMD_CTX, "avr mass erase complete"); } else { - command_print(cmd_ctx, "avr mass erase failed"); + command_print(CMD_CTX, "avr mass erase failed"); } LOG_DEBUG("%s", __FUNCTION__); diff --git a/src/flash/flash.c b/src/flash/flash.c index 99e71d7..2c63b82 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -208,7 +208,7 @@ COMMAND_HELPER(flash_command_get_bank_by_num, *bank = get_flash_bank_by_num(bank_num); if (!*bank) { - command_print(cmd_ctx, "flash bank '%s' not found", name); + command_print(CMD_CTX, "flash bank '%s' not found", name); return ERROR_INVALID_ARGUMENTS; } return ERROR_OK; @@ -241,7 +241,7 @@ COMMAND_HANDLER(handle_flash_bank_command) struct flash_bank *p, *c; /* register flash specific commands */ - if (flash_drivers[i]->register_commands(cmd_ctx) != ERROR_OK) + if (flash_drivers[i]->register_commands(CMD_CTX) != ERROR_OK) { LOG_ERROR("couldn't register '%s' commands", CMD_ARGV[0]); return ERROR_FAIL; @@ -320,7 +320,7 @@ COMMAND_HANDLER(handle_flash_info_command) if ((retval = p->driver->auto_probe(p)) != ERROR_OK) return retval; - command_print(cmd_ctx, + command_print(CMD_CTX, "#%" PRIi32 " : %s at 0x%8.8" PRIx32 ", size 0x%8.8" PRIx32 ", buswidth %i, chipwidth %i", i, p->driver->name, @@ -339,7 +339,7 @@ COMMAND_HANDLER(handle_flash_info_command) else protect_state = "protection state unknown"; - command_print(cmd_ctx, + command_print(CMD_CTX, "\t#%3i: 0x%8.8" PRIx32 " (0x%" PRIx32 " %" PRIi32 "kB) %s", j, p->sectors[j].offset, @@ -350,7 +350,7 @@ COMMAND_HANDLER(handle_flash_info_command) *buf = '\0'; /* initialize buffer, otherwise it migh contain garbage if driver function fails */ retval = p->driver->info(p, buf, sizeof(buf)); - command_print(cmd_ctx, "%s", buf); + command_print(CMD_CTX, "%s", buf); if (retval != ERROR_OK) LOG_ERROR("error retrieving flash info (%d)", retval); } @@ -374,22 +374,22 @@ COMMAND_HANDLER(handle_flash_probe_command) { if ((retval = p->driver->probe(p)) == ERROR_OK) { - command_print(cmd_ctx, "flash '%s' found at 0x%8.8" PRIx32, p->driver->name, p->base); + command_print(CMD_CTX, "flash '%s' found at 0x%8.8" PRIx32, p->driver->name, p->base); } else if (retval == ERROR_FLASH_BANK_INVALID) { - command_print(cmd_ctx, "probing failed for flash bank '#%s' at 0x%8.8" PRIx32, + command_print(CMD_CTX, "probing failed for flash bank '#%s' at 0x%8.8" PRIx32, CMD_ARGV[0], p->base); } else { - command_print(cmd_ctx, "unknown error when probing flash bank '#%s' at 0x%8.8" PRIx32, + command_print(CMD_CTX, "unknown error when probing flash bank '#%s' at 0x%8.8" PRIx32, CMD_ARGV[0], p->base); } } else { - command_print(cmd_ctx, "flash bank '#%s' is out of bounds", CMD_ARGV[0]); + command_print(CMD_CTX, "flash bank '#%s' is out of bounds", CMD_ARGV[0]); } return ERROR_OK; @@ -410,11 +410,11 @@ COMMAND_HANDLER(handle_flash_erase_check_command) int j; if ((retval = p->driver->erase_check(p)) == ERROR_OK) { - command_print(cmd_ctx, "successfully checked erase state"); + command_print(CMD_CTX, "successfully checked erase state"); } else { - command_print(cmd_ctx, "unknown error when checking erase state of flash bank #%s at 0x%8.8" PRIx32, + command_print(CMD_CTX, "unknown error when checking erase state of flash bank #%s at 0x%8.8" PRIx32, CMD_ARGV[0], p->base); } @@ -429,7 +429,7 @@ COMMAND_HANDLER(handle_flash_erase_check_command) else erase_state = "erase state unknown"; - command_print(cmd_ctx, + command_print(CMD_CTX, "\t#%3i: 0x%8.8" PRIx32 " (0x%" PRIx32 " %" PRIi32 "kB) %s", j, p->sectors[j].offset, @@ -448,7 +448,7 @@ COMMAND_HANDLER(handle_flash_erase_address_command) int address; int length; - struct target *target = get_current_target(cmd_ctx); + struct target *target = get_current_target(CMD_CTX); if (CMD_ARGC != 2) return ERROR_COMMAND_SYNTAX_ERROR; @@ -457,7 +457,7 @@ COMMAND_HANDLER(handle_flash_erase_address_command) COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], length); if (length <= 0) { - command_print(cmd_ctx, "Length must be >0"); + command_print(CMD_CTX, "Length must be >0"); return ERROR_COMMAND_SYNTAX_ERROR; } @@ -477,7 +477,7 @@ COMMAND_HANDLER(handle_flash_erase_address_command) if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { - command_print(cmd_ctx, "erased address 0x%8.8x (length %i)" + command_print(CMD_CTX, "erased address 0x%8.8x (length %i)" " in %fs (%0.3f kb/s)", address, length, duration_elapsed(&bench), duration_kbps(&bench, length)); } @@ -497,15 +497,15 @@ COMMAND_HANDLER(handle_flash_protect_check_command) if ((retval = p->driver->protect_check(p)) == ERROR_OK) { - command_print(cmd_ctx, "successfully checked protect state"); + command_print(CMD_CTX, "successfully checked protect state"); } else if (retval == ERROR_FLASH_OPERATION_FAILED) { - command_print(cmd_ctx, "checking protection state failed (possibly unsupported) by flash #%s at 0x%8.8" PRIx32, CMD_ARGV[0], p->base); + command_print(CMD_CTX, "checking protection state failed (possibly unsupported) by flash #%s at 0x%8.8" PRIx32, CMD_ARGV[0], p->base); } else { - command_print(cmd_ctx, "unknown error when checking protection state of flash bank '#%s' at 0x%8.8" PRIx32, CMD_ARGV[0], p->base); + command_print(CMD_CTX, "unknown error when checking protection state of flash bank '#%s' at 0x%8.8" PRIx32, CMD_ARGV[0], p->base); } return ERROR_OK; @@ -550,7 +550,7 @@ COMMAND_HANDLER(handle_flash_erase_command) COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], last); int retval; - if ((retval = flash_check_sector_parameters(cmd_ctx, + if ((retval = flash_check_sector_parameters(CMD_CTX, first, last, p->num_sectors)) != ERROR_OK) return retval; @@ -561,7 +561,7 @@ COMMAND_HANDLER(handle_flash_erase_command) if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { - command_print(cmd_ctx, "erased sectors %" PRIu32 " " + command_print(CMD_CTX, "erased sectors %" PRIu32 " " "through %" PRIu32" on flash bank %" PRIu32 " " "in %fs", first, last, bank_nr, duration_elapsed(&bench)); } @@ -598,13 +598,13 @@ COMMAND_HANDLER(handle_flash_protect_command) return ERROR_COMMAND_SYNTAX_ERROR; int retval; - if ((retval = flash_check_sector_parameters(cmd_ctx, + if ((retval = flash_check_sector_parameters(CMD_CTX, first, last, p->num_sectors)) != ERROR_OK) return retval; retval = flash_driver_protect(p, set, first, last); if (retval == ERROR_OK) { - command_print(cmd_ctx, "%s protection for sectors %i " + command_print(CMD_CTX, "%s protection for sectors %i " "through %i on flash bank %i", (set) ? "set" : "cleared", (int) first, (int) last, (int) bank_nr); @@ -615,7 +615,7 @@ COMMAND_HANDLER(handle_flash_protect_command) COMMAND_HANDLER(handle_flash_write_image_command) { - struct target *target = get_current_target(cmd_ctx); + struct target *target = get_current_target(CMD_CTX); struct image image; uint32_t written; @@ -638,13 +638,13 @@ COMMAND_HANDLER(handle_flash_write_image_command) auto_erase = 1; CMD_ARGV++; CMD_ARGC--; - command_print(cmd_ctx, "auto erase enabled"); + command_print(CMD_CTX, "auto erase enabled"); } else if (strcmp(CMD_ARGV[0], "unlock") == 0) { auto_unlock = true; CMD_ARGV++; CMD_ARGC--; - command_print(cmd_ctx, "auto unlock enabled"); + command_print(CMD_CTX, "auto unlock enabled"); } else { break; @@ -693,7 +693,7 @@ COMMAND_HANDLER(handle_flash_write_image_command) if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { - command_print(cmd_ctx, "wrote %" PRIu32 " byte from file %s " + command_print(CMD_CTX, "wrote %" PRIu32 " byte from file %s " "in %fs (%0.3f kb/s)", written, CMD_ARGV[0], duration_elapsed(&bench), duration_kbps(&bench, written)); } @@ -714,7 +714,7 @@ COMMAND_HANDLER(handle_flash_fill_command) uint32_t wrote = 0; uint32_t cur_size = 0; uint32_t chunk_count; - struct target *target = get_current_target(cmd_ctx); + struct target *target = get_current_target(CMD_CTX); uint32_t i; uint32_t wordsize; @@ -800,7 +800,7 @@ COMMAND_HANDLER(handle_flash_fill_command) if (duration_measure(&bench) == ERROR_OK) { - command_print(cmd_ctx, "wrote %" PRIu32 " bytes to 0x%8.8" PRIx32 + command_print(CMD_CTX, "wrote %" PRIu32 " bytes to 0x%8.8" PRIx32 " in %fs (%0.3f kb/s)", wrote, address, duration_elapsed(&bench), duration_kbps(&bench, wrote)); } @@ -847,7 +847,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command) if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { - command_print(cmd_ctx, "wrote %zu byte from file %s to flash bank %u" + command_print(CMD_CTX, "wrote %zu byte from file %s to flash bank %u" " at offset 0x%8.8" PRIx32 " in %fs (%0.3f kb/s)", fileio.size, CMD_ARGV[1], p->bank_number, offset, duration_elapsed(&bench), duration_kbps(&bench, fileio.size)); diff --git a/src/flash/lpc2000.c b/src/flash/lpc2000.c index 6378130..191eb4b 100644 --- a/src/flash/lpc2000.c +++ b/src/flash/lpc2000.c @@ -764,14 +764,14 @@ COMMAND_HANDLER(lpc2000_handle_part_id_command) { if (status_code == ERROR_FLASH_OPERATION_FAILED) { - command_print(cmd_ctx, "no sufficient working area specified, can't access LPC2000 IAP interface"); + command_print(CMD_CTX, "no sufficient working area specified, can't access LPC2000 IAP interface"); return ERROR_OK; } - command_print(cmd_ctx, "lpc2000 IAP returned status code %i", status_code); + command_print(CMD_CTX, "lpc2000 IAP returned status code %i", status_code); } else { - command_print(cmd_ctx, "lpc2000 part id: 0x%8.8" PRIx32 , result_table[0]); + command_print(CMD_CTX, "lpc2000 part id: 0x%8.8" PRIx32 , result_table[0]); } return ERROR_OK; diff --git a/src/flash/lpc2900.c b/src/flash/lpc2900.c index 98b13bf..1d5abd9 100644 --- a/src/flash/lpc2900.c +++ b/src/flash/lpc2900.c @@ -564,7 +564,7 @@ COMMAND_HANDLER(lpc2900_handle_signature_command) return status; } - command_print( cmd_ctx, "signature: 0x%8.8" PRIx32 + command_print( CMD_CTX, "signature: 0x%8.8" PRIx32 ":0x%8.8" PRIx32 ":0x%8.8" PRIx32 ":0x%8.8" PRIx32, @@ -672,11 +672,11 @@ COMMAND_HANDLER(lpc2900_handle_password_command) if( !lpc2900_info->risky ) { - command_print(cmd_ctx, "Wrong password (use '%s')", ISS_PASSWORD); + command_print(CMD_CTX, "Wrong password (use '%s')", ISS_PASSWORD); return ERROR_COMMAND_ARGUMENT_INVALID; } - command_print(cmd_ctx, + command_print(CMD_CTX, "Potentially dangerous operation allowed in next command!"); return ERROR_OK; @@ -704,7 +704,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command) /* Check if command execution is allowed. */ if( !lpc2900_info->risky ) { - command_print( cmd_ctx, "Command execution not allowed!" ); + command_print( CMD_CTX, "Command execution not allowed!" ); return ERROR_COMMAND_ARGUMENT_INVALID; } lpc2900_info->risky = 0; @@ -815,7 +815,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command) /* Check if command execution is allowed. */ if( !lpc2900_info->risky ) { - command_print( cmd_ctx, "Command execution not allowed! " + command_print( CMD_CTX, "Command execution not allowed! " "(use 'password' command first)"); return ERROR_COMMAND_ARGUMENT_INVALID; } @@ -829,7 +829,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command) (last >= bank->num_sectors) || (first > last) ) { - command_print( cmd_ctx, "Illegal sector range" ); + command_print( CMD_CTX, "Illegal sector range" ); return ERROR_COMMAND_ARGUMENT_INVALID; } @@ -878,7 +878,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command) } } - command_print( cmd_ctx, + command_print( CMD_CTX, "Sectors security will become effective after next power cycle"); /* Update the sector security status */ @@ -914,7 +914,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_jtag_command) /* Check if command execution is allowed. */ if( !lpc2900_info->risky ) { - command_print( cmd_ctx, "Command execution not allowed! " + command_print( CMD_CTX, "Command execution not allowed! " "(use 'password' command first)"); return ERROR_COMMAND_ARGUMENT_INVALID; } diff --git a/src/flash/lpc3180_nand_controller.c b/src/flash/lpc3180_nand_controller.c index 1de48f4..61bef90 100644 --- a/src/flash/lpc3180_nand_controller.c +++ b/src/flash/lpc3180_nand_controller.c @@ -846,7 +846,7 @@ COMMAND_HANDLER(handle_lpc3180_select_command) struct nand_device *nand = get_nand_device_by_num(num); if (!nand) { - command_print(cmd_ctx, "nand device '#%s' is out of bounds", CMD_ARGV[0]); + command_print(CMD_CTX, "nand device '#%s' is out of bounds", CMD_ARGV[0]); return ERROR_OK; } @@ -868,7 +868,7 @@ COMMAND_HANDLER(handle_lpc3180_select_command) } } - command_print(cmd_ctx, "%s controller selected", selected[lpc3180_info->selected_controller]); + command_print(CMD_CTX, "%s controller selected", selected[lpc3180_info->selected_controller]); return ERROR_OK; } diff --git a/src/flash/mflash.c b/src/flash/mflash.c index 64f332e..2a1fbe5 100644 --- a/src/flash/mflash.c +++ b/src/flash/mflash.c @@ -416,7 +416,7 @@ COMMAND_HANDLER(mg_probe_cmd) ret = mg_mflash_probe(); if (ret == ERROR_OK) { - command_print(cmd_ctx, "mflash (total %" PRIu32 " sectors) found at 0x%8.8" PRIx32 "", + command_print(CMD_CTX, "mflash (total %" PRIu32 " sectors) found at 0x%8.8" PRIx32 "", mflash_bank->drv_info->tot_sects, mflash_bank->base); } @@ -751,7 +751,7 @@ COMMAND_HANDLER(mg_write_cmd) if (duration_measure(&bench) == ERROR_OK) { - command_print(cmd_ctx, "wrote %zu byte from file %s " + command_print(CMD_CTX, "wrote %zu byte from file %s " "in %fs (%0.3f kB/s)", fileio.size, CMD_ARGV[1], duration_elapsed(&bench), duration_kbps(&bench, fileio.size)); } @@ -817,7 +817,7 @@ COMMAND_HANDLER(mg_dump_cmd) if (duration_measure(&bench) == ERROR_OK) { - command_print(cmd_ctx, "dump image (address 0x%8.8" PRIx32 " " + command_print(CMD_CTX, "dump image (address 0x%8.8" PRIx32 " " "size %" PRIu32 ") to file %s in %fs (%0.3f kB/s)", address, size, CMD_ARGV[1], duration_elapsed(&bench), duration_kbps(&bench, size)); diff --git a/src/flash/nand.c b/src/flash/nand.c index ce713b9..c96354a 100644 --- a/src/flash/nand.c +++ b/src/flash/nand.c @@ -223,7 +223,7 @@ COMMAND_HANDLER(handle_nand_device_command) if (strcmp(CMD_ARGV[0], nand_flash_controllers[i]->name) == 0) { /* register flash specific commands */ - if ((retval = nand_flash_controllers[i]->register_commands(cmd_ctx)) != ERROR_OK) + if ((retval = nand_flash_controllers[i]->register_commands(CMD_CTX)) != ERROR_OK) { LOG_ERROR("couldn't register '%s' commands", CMD_ARGV[0]); return retval; @@ -312,7 +312,7 @@ COMMAND_HELPER(nand_command_get_device_by_num, unsigned name_index, COMMAND_PARSE_NUMBER(uint, str, num); *nand = get_nand_device_by_num(num); if (!*nand) { - command_print(cmd_ctx, "NAND flash device '#%s' is out of bounds", str); + command_print(CMD_CTX, "NAND flash device '#%s' is out of bounds", str); return ERROR_INVALID_ARGUMENTS; } return ERROR_OK; @@ -1050,21 +1050,21 @@ COMMAND_HANDLER(handle_nand_list_command) if (!nand_devices) { - command_print(cmd_ctx, "no NAND flash devices configured"); + command_print(CMD_CTX, "no NAND flash devices configured"); return ERROR_OK; } for (p = nand_devices, i = 0; p; p = p->next, i++) { if (p->device) - command_print(cmd_ctx, "#%i: %s (%s) " + command_print(CMD_CTX, "#%i: %s (%s) " "pagesize: %i, buswidth: %i,\n\t" "blocksize: %i, blocks: %i", i, p->device->name, p->manufacturer->name, p->page_size, p->bus_width, p->erase_size, p->num_blocks); else - command_print(cmd_ctx, "#%i: not probed", i); + command_print(CMD_CTX, "#%i: not probed", i); } return ERROR_OK; @@ -1102,7 +1102,7 @@ COMMAND_HANDLER(handle_nand_info_command) if (NULL == p->device) { - command_print(cmd_ctx, "#%s: not probed", CMD_ARGV[0]); + command_print(CMD_CTX, "#%s: not probed", CMD_ARGV[0]); return ERROR_OK; } @@ -1112,7 +1112,7 @@ COMMAND_HANDLER(handle_nand_info_command) if (last >= p->num_blocks) last = p->num_blocks - 1; - command_print(cmd_ctx, "#%i: %s (%s) pagesize: %i, buswidth: %i, erasesize: %i", + command_print(CMD_CTX, "#%i: %s (%s) pagesize: %i, buswidth: %i, erasesize: %i", i++, p->device->name, p->manufacturer->name, p->page_size, p->bus_width, p->erase_size); for (j = first; j <= last; j++) @@ -1133,7 +1133,7 @@ COMMAND_HANDLER(handle_nand_info_command) else bad_state = " (block condition unknown)"; - command_print(cmd_ctx, + command_print(CMD_CTX, "\t#%i: 0x%8.8" PRIx32 " (%" PRId32 "kB) %s%s", j, p->blocks[j].offset, @@ -1159,15 +1159,15 @@ COMMAND_HANDLER(handle_nand_probe_command) if ((retval = nand_probe(p)) == ERROR_OK) { - command_print(cmd_ctx, "NAND flash device '%s' found", p->device->name); + command_print(CMD_CTX, "NAND flash device '%s' found", p->device->name); } else if (retval == ERROR_NAND_OPERATION_FAILED) { - command_print(cmd_ctx, "probing failed for NAND flash device"); + command_print(CMD_CTX, "probing failed for NAND flash device"); } else { - command_print(cmd_ctx, "unknown error when probing NAND flash device"); + command_print(CMD_CTX, "unknown error when probing NAND flash device"); } return ERROR_OK; @@ -1212,18 +1212,18 @@ COMMAND_HANDLER(handle_nand_erase_command) retval = nand_erase(p, offset, offset + length - 1); if (retval == ERROR_OK) { - command_print(cmd_ctx, "erased blocks %lu to %lu " + command_print(CMD_CTX, "erased blocks %lu to %lu " "on NAND flash device #%s '%s'", offset, offset + length, CMD_ARGV[0], p->device->name); } else if (retval == ERROR_NAND_OPERATION_FAILED) { - command_print(cmd_ctx, "erase failed"); + command_print(CMD_CTX, "erase failed"); } else { - command_print(cmd_ctx, "unknown error when erasing NAND flash device"); + command_print(CMD_CTX, "unknown error when erasing NAND flash device"); } return ERROR_OK; @@ -1269,17 +1269,17 @@ COMMAND_HANDLER(handle_nand_check_bad_blocks_command) retval = nand_build_bbt(p, first, last); if (retval == ERROR_OK) { - command_print(cmd_ctx, "checked NAND flash device for bad blocks, " + command_print(CMD_CTX, "checked NAND flash device for bad blocks, " "use \"nand info\" command to list blocks"); } else if (retval == ERROR_NAND_OPERATION_FAILED) { - command_print(cmd_ctx, "error when checking for bad blocks on " + command_print(CMD_CTX, "error when checking for bad blocks on " "NAND flash device"); } else { - command_print(cmd_ctx, "unknown error when checking for bad " + command_print(CMD_CTX, "unknown error when checking for bad " "blocks on NAND flash device"); } @@ -1399,7 +1399,7 @@ static COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state, if (NULL == nand->device) { - command_print(cmd_ctx, "#%s: not probed", CMD_ARGV[0]); + command_print(CMD_CTX, "#%s: not probed", CMD_ARGV[0]); return ERROR_OK; } @@ -1409,7 +1409,7 @@ static COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state, COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], state->size); if (state->size % nand->page_size) { - command_print(cmd_ctx, "only page-aligned sizes are supported"); + command_print(CMD_CTX, "only page-aligned sizes are supported"); return ERROR_COMMAND_SYNTAX_ERROR; } } @@ -1428,13 +1428,13 @@ static COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state, state->oob_format |= NAND_OOB_SW_ECC_KW; else { - command_print(cmd_ctx, "unknown option: %s", CMD_ARGV[i]); + command_print(CMD_CTX, "unknown option: %s", CMD_ARGV[i]); return ERROR_COMMAND_SYNTAX_ERROR; } } } - retval = nand_fileio_start(cmd_ctx, nand, CMD_ARGV[1], filemode, state); + retval = nand_fileio_start(CMD_CTX, nand, CMD_ARGV[1], filemode, state); if (ERROR_OK != retval) return retval; @@ -1517,7 +1517,7 @@ COMMAND_HANDLER(handle_nand_write_command) int bytes_read = nand_fileio_read(nand, &s); if (bytes_read <= 0) { - command_print(cmd_ctx, "error while reading file"); + command_print(CMD_CTX, "error while reading file"); return nand_fileio_cleanup(&s); } s.size -= bytes_read; @@ -1526,7 +1526,7 @@ COMMAND_HANDLER(handle_nand_write_command) s.page, s.page_size, s.oob, s.oob_size); if (ERROR_OK != retval) { - command_print(cmd_ctx, "failed writing file %s " + command_print(CMD_CTX, "failed writing file %s " "to NAND flash %s at offset 0x%8.8" PRIx32, CMD_ARGV[1], CMD_ARGV[0], s.address); return nand_fileio_cleanup(&s); @@ -1536,7 +1536,7 @@ COMMAND_HANDLER(handle_nand_write_command) if (nand_fileio_finish(&s)) { - command_print(cmd_ctx, "wrote file %s to NAND flash %s up to " + command_print(CMD_CTX, "wrote file %s to NAND flash %s up to " "offset 0x%8.8" PRIx32 " in %fs (%0.3f kb/s)", CMD_ARGV[1], CMD_ARGV[0], s.address, duration_elapsed(&s.bench), duration_kbps(&s.bench, total_bytes)); @@ -1558,7 +1558,7 @@ COMMAND_HANDLER(handle_nand_verify_command) dev.address = file.address; dev.size = file.size; dev.oob_format = file.oob_format; - retval = nand_fileio_start(cmd_ctx, nand, NULL, FILEIO_NONE, &dev); + retval = nand_fileio_start(CMD_CTX, nand, NULL, FILEIO_NONE, &dev); if (ERROR_OK != retval) return retval; @@ -1568,7 +1568,7 @@ COMMAND_HANDLER(handle_nand_verify_command) dev.page, dev.page_size, dev.oob, dev.oob_size); if (ERROR_OK != retval) { - command_print(cmd_ctx, "reading NAND flash page failed"); + command_print(CMD_CTX, "reading NAND flash page failed"); nand_fileio_cleanup(&dev); return nand_fileio_cleanup(&file); } @@ -1576,7 +1576,7 @@ COMMAND_HANDLER(handle_nand_verify_command) int bytes_read = nand_fileio_read(nand, &file); if (bytes_read <= 0) { - command_print(cmd_ctx, "error while reading file"); + command_print(CMD_CTX, "error while reading file"); nand_fileio_cleanup(&dev); return nand_fileio_cleanup(&file); } @@ -1584,7 +1584,7 @@ COMMAND_HANDLER(handle_nand_verify_command) if ((dev.page && memcmp(dev.page, file.page, dev.page_size)) || (dev.oob && memcmp(dev.oob, file.oob, dev.oob_size)) ) { - command_print(cmd_ctx, "NAND flash contents differ " + command_print(CMD_CTX, "NAND flash contents differ " "at 0x%8.8" PRIx32, dev.address); nand_fileio_cleanup(&dev); return nand_fileio_cleanup(&file); @@ -1596,7 +1596,7 @@ COMMAND_HANDLER(handle_nand_verify_command) if (nand_fileio_finish(&file) == ERROR_OK) { - command_print(cmd_ctx, "verified file %s in NAND flash %s " + command_print(CMD_CTX, "verified file %s in NAND flash %s " "up to offset 0x%8.8" PRIx32 " in %fs (%0.3f kb/s)", CMD_ARGV[1], CMD_ARGV[0], dev.address, duration_elapsed(&file.bench), duration_kbps(&file.bench, dev.size)); @@ -1621,7 +1621,7 @@ COMMAND_HANDLER(handle_nand_dump_command) s.page, s.page_size, s.oob, s.oob_size); if (ERROR_OK != retval) { - command_print(cmd_ctx, "reading NAND flash page failed"); + command_print(CMD_CTX, "reading NAND flash page failed"); return nand_fileio_cleanup(&s); } @@ -1637,7 +1637,7 @@ COMMAND_HANDLER(handle_nand_dump_command) if (nand_fileio_finish(&s) == ERROR_OK) { - command_print(cmd_ctx, "dumped %zu bytes in %fs (%0.3f kb/s)", + command_print(CMD_CTX, "dumped %zu bytes in %fs (%0.3f kb/s)", s.fileio.size, duration_elapsed(&s.bench), duration_kbps(&s.bench, s.fileio.size)); } @@ -1658,7 +1658,7 @@ COMMAND_HANDLER(handle_nand_raw_access_command) if (NULL == p->device) { - command_print(cmd_ctx, "#%s: not probed", CMD_ARGV[0]); + command_print(CMD_CTX, "#%s: not probed", CMD_ARGV[0]); return ERROR_OK; } @@ -1673,7 +1673,7 @@ COMMAND_HANDLER(handle_nand_raw_access_command) } const char *msg = p->use_raw ? "enabled" : "disabled"; - command_print(cmd_ctx, "raw access is %s", msg); + command_print(CMD_CTX, "raw access is %s", msg); return ERROR_OK; } diff --git a/src/flash/pic32mx.c b/src/flash/pic32mx.c index 05e0474..4bfe91b 100644 --- a/src/flash/pic32mx.c +++ b/src/flash/pic32mx.c @@ -679,7 +679,7 @@ COMMAND_HANDLER(pic32mx_handle_lock_command) if (CMD_ARGC < 1) { - command_print(cmd_ctx, "pic32mx lock <bank>"); + command_print(CMD_CTX, "pic32mx lock <bank>"); return ERROR_OK; } @@ -700,7 +700,7 @@ COMMAND_HANDLER(pic32mx_handle_lock_command) if (pic32mx_erase_options(bank) != ERROR_OK) { - command_print(cmd_ctx, "pic32mx failed to erase options"); + command_print(CMD_CTX, "pic32mx failed to erase options"); return ERROR_OK; } @@ -709,11 +709,11 @@ COMMAND_HANDLER(pic32mx_handle_lock_command) if (pic32mx_write_options(bank) != ERROR_OK) { - command_print(cmd_ctx, "pic32mx failed to lock device"); + command_print(CMD_CTX, "pic32mx failed to lock device"); return ERROR_OK; } - command_print(cmd_ctx, "pic32mx locked"); + command_print(CMD_CTX, "pic32mx locked"); return ERROR_OK; } @@ -725,7 +725,7 @@ COMMAND_HANDLER(pic32mx_handle_unlock_command) if (CMD_ARGC < 1) { - command_print(cmd_ctx, "pic32mx unlock <bank>"); + command_print(CMD_CTX, "pic32mx unlock <bank>"); return ERROR_OK; } @@ -746,17 +746,17 @@ COMMAND_HANDLER(pic32mx_handle_unlock_command) if (pic32mx_erase_options(bank) != ERROR_OK) { - command_print(cmd_ctx, "pic32mx failed to unlock device"); + command_print(CMD_CTX, "pic32mx failed to unlock device"); return ERROR_OK; } if (pic32mx_write_options(bank) != ERROR_OK) { - command_print(cmd_ctx, "pic32mx failed to lock device"); + command_print(CMD_CTX, "pic32mx failed to lock device"); return ERROR_OK; } - command_print(cmd_ctx, "pic32mx unlocked"); + command_print(CMD_CTX, "pic32mx unlocked"); return ERROR_OK; } @@ -815,7 +815,7 @@ COMMAND_HANDLER(pic32mx_handle_chip_erase_command) if (CMD_ARGC != 0) { - command_print(cmd_ctx, "pic32mx chip_erase"); + command_print(CMD_CTX, "pic32mx chip_erase"); return ERROR_OK; } @@ -832,11 +832,11 @@ COMMAND_HANDLER(pic32mx_handle_chip_erase_command) bank->sectors[i].is_erased = 1; } - command_print(cmd_ctx, "pic32mx chip erase complete"); + command_print(CMD_CTX, "pic32mx chip erase complete"); } else { - command_print(cmd_ctx, "pic32mx chip erase failed"); + command_print(CMD_CTX, "pic32mx chip erase failed"); } #endif @@ -850,7 +850,7 @@ COMMAND_HANDLER(pic32mx_handle_pgm_word_command) if (CMD_ARGC != 3) { - command_print(cmd_ctx, "pic32mx pgm_word <addr> <value> <bank>"); + command_print(CMD_CTX, "pic32mx pgm_word <addr> <value> <bank>"); return ERROR_OK; } @@ -864,7 +864,7 @@ COMMAND_HANDLER(pic32mx_handle_pgm_word_command) if (address < bank->base || address >= (bank->base + bank->size)) { - command_print(cmd_ctx, "flash address '%s' is out of bounds", CMD_ARGV[0]); + command_print(CMD_CTX, "flash address '%s' is out of bounds", CMD_ARGV[0]); return ERROR_OK; } @@ -876,9 +876,9 @@ COMMAND_HANDLER(pic32mx_handle_pgm_word_command) res = ERROR_FLASH_OPERATION_FAILED; if (res == ERROR_OK) - command_print(cmd_ctx, "pic32mx pgm word complete"); + command_print(CMD_CTX, "pic32mx pgm word complete"); else - command_print(cmd_ctx, "pic32mx pgm word failed (status = 0x%x)", status); + command_print(CMD_CTX, "pic32mx pgm word failed (status = 0x%x)", status); return ERROR_OK; } diff --git a/src/flash/stellaris.c b/src/flash/stellaris.c index 4f28c09..a18c99b 100644 --- a/src/flash/stellaris.c +++ b/src/flash/stellaris.c @@ -1134,7 +1134,7 @@ COMMAND_HANDLER(stellaris_handle_mass_erase_command) if (CMD_ARGC < 1) { - command_print(cmd_ctx, "stellaris mass_erase <bank>"); + command_print(CMD_CTX, "stellaris mass_erase <bank>"); return ERROR_OK; } @@ -1151,11 +1151,11 @@ COMMAND_HANDLER(stellaris_handle_mass_erase_command) bank->sectors[i].is_erased = 1; } - command_print(cmd_ctx, "stellaris mass erase complete"); + command_print(CMD_CTX, "stellaris mass erase complete"); } else { - command_print(cmd_ctx, "stellaris mass erase failed"); + command_print(CMD_CTX, "stellaris mass erase failed"); } return ERROR_OK; diff --git a/src/flash/stm32x.c b/src/flash/stm32x.c index f59ed61..4db338d 100644 --- a/src/flash/stm32x.c +++ b/src/flash/stm32x.c @@ -900,7 +900,7 @@ COMMAND_HANDLER(stm32x_handle_lock_command) if (CMD_ARGC < 1) { - command_print(cmd_ctx, "stm32x lock <bank>"); + command_print(CMD_CTX, "stm32x lock <bank>"); return ERROR_OK; } @@ -921,7 +921,7 @@ COMMAND_HANDLER(stm32x_handle_lock_command) if (stm32x_erase_options(bank) != ERROR_OK) { - command_print(cmd_ctx, "stm32x failed to erase options"); + command_print(CMD_CTX, "stm32x failed to erase options"); return ERROR_OK; } @@ -930,11 +930,11 @@ COMMAND_HANDLER(stm32x_handle_lock_command) if (stm32x_write_options(bank) != ERROR_OK) { - command_print(cmd_ctx, "stm32x failed to lock device"); + command_print(CMD_CTX, "stm32x failed to lock device"); return ERROR_OK; } - command_print(cmd_ctx, "stm32x locked"); + command_print(CMD_CTX, "stm32x locked"); return ERROR_OK; } @@ -946,7 +946,7 @@ COMMAND_HANDLER(stm32x_handle_unlock_command) if (CMD_ARGC < 1) { - command_print(cmd_ctx, "stm32x unlock <bank>"); + command_print(CMD_CTX, "stm32x unlock <bank>"); return ERROR_OK; } @@ -967,17 +967,17 @@ COMMAND_HANDLER(stm32x_handle_unlock_command) if (stm32x_erase_options(bank) != ERROR_OK) { - command_print(cmd_ctx, "stm32x failed to unlock device"); + command_print(CMD_CTX, "stm32x failed to unlock device"); return ERROR_OK; } if (stm32x_write_options(bank) != ERROR_OK) { - command_print(cmd_ctx, "stm32x failed to lock device"); + command_print(CMD_CTX, "stm32x failed to lock device"); return ERROR_OK; } - command_print(cmd_ctx, "stm32x unlocked"); + command_print(CMD_CTX, "stm32x unlocked"); return ERROR_OK; } @@ -990,7 +990,7 @@ COMMAND_HANDLER(stm32x_handle_options_read_command) if (CMD_ARGC < 1) { - command_print(cmd_ctx, "stm32x options_read <bank>"); + command_print(CMD_CTX, "stm32x options_read <bank>"); return ERROR_OK; } @@ -1010,30 +1010,30 @@ COMMAND_HANDLER(stm32x_handle_options_read_command) } target_read_u32(target, STM32_FLASH_OBR, &optionbyte); - command_print(cmd_ctx, "Option Byte: 0x%" PRIx32 "", optionbyte); + command_print(CMD_CTX, "Option Byte: 0x%" PRIx32 "", optionbyte); if (buf_get_u32((uint8_t*)&optionbyte, OPT_ERROR, 1)) - command_print(cmd_ctx, "Option Byte Complement Error"); + command_print(CMD_CTX, "Option Byte Complement Error"); if (buf_get_u32((uint8_t*)&optionbyte, OPT_READOUT, 1)) - command_print(cmd_ctx, "Readout Protection On"); + command_print(CMD_CTX, "Readout Protection On"); else - command_print(cmd_ctx, "Readout Protection Off"); + command_print(CMD_CTX, "Readout Protection Off"); if (buf_get_u32((uint8_t*)&optionbyte, OPT_RDWDGSW, 1)) - command_print(cmd_ctx, "Software Watchdog"); + command_print(CMD_CTX, "Software Watchdog"); else - command_print(cmd_ctx, "Hardware Watchdog"); + command_print(CMD_CTX, "Hardware Watchdog"); if (buf_get_u32((uint8_t*)&optionbyte, OPT_RDRSTSTOP, 1)) - command_print(cmd_ctx, "Stop: No reset generated"); + command_print(CMD_CTX, "Stop: No reset generated"); else - command_print(cmd_ctx, "Stop: Reset generated"); + command_print(CMD_CTX, "Stop: Reset generated"); if (buf_get_u32((uint8_t*)&optionbyte, OPT_RDRSTSTDBY, 1)) - command_print(cmd_ctx, "Standby: No reset generated"); + command_print(CMD_CTX, "Standby: No reset generated"); else - command_print(cmd_ctx, "Standby: Reset generated"); + command_print(CMD_CTX, "Standby: Reset generated"); return ERROR_OK; } @@ -1046,7 +1046,7 @@ COMMAND_HANDLER(stm32x_handle_options_write_command) if (CMD_ARGC < 4) { - command_print(cmd_ctx, "stm32x options_write <bank> <SWWDG | HWWDG> <RSTSTNDBY | NORSTSTNDBY> <RSTSTOP | NORSTSTOP>"); + command_print(CMD_CTX, "stm32x options_write <bank> <SWWDG | HWWDG> <RSTSTNDBY | NORSTSTNDBY> <RSTSTOP | NORSTSTOP>"); return ERROR_OK; } @@ -1094,7 +1094,7 @@ COMMAND_HANDLER(stm32x_handle_options_write_command) if (stm32x_erase_options(bank) != ERROR_OK) { - command_print(cmd_ctx, "stm32x failed to erase options"); + command_print(CMD_CTX, "stm32x failed to erase options"); return ERROR_OK; } @@ -1102,11 +1102,11 @@ COMMAND_HANDLER(stm32x_handle_options_write_command) if (stm32x_write_options(bank) != ERROR_OK) { - command_print(cmd_ctx, "stm32x failed to write options"); + command_print(CMD_CTX, "stm32x failed to write options"); return ERROR_OK; } - command_print(cmd_ctx, "stm32x write options complete"); + command_print(CMD_CTX, "stm32x write options complete"); return ERROR_OK; } @@ -1155,7 +1155,7 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command) if (CMD_ARGC < 1) { - command_print(cmd_ctx, "stm32x mass_erase <bank>"); + command_print(CMD_CTX, "stm32x mass_erase <bank>"); return ERROR_OK; } @@ -1172,11 +1172,11 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command) bank->sectors[i].is_erased = 1; } - command_print(cmd_ctx, "stm32x mass erase complete"); + command_print(CMD_CTX, "stm32x mass erase complete"); } else { - command_print(cmd_ctx, "stm32x mass erase failed"); + command_print(CMD_CTX, "stm32x mass erase failed"); } return ERROR_OK; diff --git a/src/flash/str7x.c b/src/flash/str7x.c index 76b6467..da1899d 100644 --- a/src/flash/str7x.c +++ b/src/flash/str7x.c @@ -613,7 +613,7 @@ COMMAND_HANDLER(str7x_handle_disable_jtag_command) if (CMD_ARGC < 1) { - command_print(cmd_ctx, "str7x disable_jtag <bank>"); + command_print(CMD_CTX, "str7x disable_jtag <bank>"); return ERROR_OK; } diff --git a/src/flash/str9xpec.c b/src/flash/str9xpec.c index a87d0ff..de222fb 100644 --- a/src/flash/str9xpec.c +++ b/src/flash/str9xpec.c @@ -759,7 +759,7 @@ COMMAND_HANDLER(str9xpec_handle_part_id_command) idcode = buf_get_u32(buffer, 0, 32); - command_print(cmd_ctx, "str9xpec part id: 0x%8.8" PRIx32 "", idcode); + command_print(CMD_CTX, "str9xpec part id: 0x%8.8" PRIx32 "", idcode); free(buffer); @@ -784,7 +784,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_read_command) if (CMD_ARGC < 1) { - command_print(cmd_ctx, "str9xpec options_read <bank>"); + command_print(CMD_CTX, "str9xpec options_read <bank>"); return ERROR_OK; } @@ -802,33 +802,33 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_read_command) /* boot bank */ if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_CSMAPBIT, 1)) - command_print(cmd_ctx, "CS Map: bank1"); + command_print(CMD_CTX, "CS Map: bank1"); else - command_print(cmd_ctx, "CS Map: bank0"); + command_print(CMD_CTX, "CS Map: bank0"); /* OTP lock */ if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_OTPBIT, 1)) - command_print(cmd_ctx, "OTP Lock: OTP Locked"); + command_print(CMD_CTX, "OTP Lock: OTP Locked"); else - command_print(cmd_ctx, "OTP Lock: OTP Unlocked"); + command_print(CMD_CTX, "OTP Lock: OTP Unlocked"); /* LVD Threshold */ if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_LVDTHRESBIT, 1)) - command_print(cmd_ctx, "LVD Threshold: 2.7v"); + command_print(CMD_CTX, "LVD Threshold: 2.7v"); else - command_print(cmd_ctx, "LVD Threshold: 2.4v"); + command_print(CMD_CTX, "LVD Threshold: 2.4v"); /* LVD reset warning */ if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_LVDWARNBIT, 1)) - command_print(cmd_ctx, "LVD Reset Warning: VDD or VDDQ Inputs"); + command_print(CMD_CTX, "LVD Reset Warning: VDD or VDDQ Inputs"); else - command_print(cmd_ctx, "LVD Reset Warning: VDD Input Only"); + command_print(CMD_CTX, "LVD Reset Warning: VDD Input Only"); /* LVD reset select */ if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_LVDSELBIT, 1)) - command_print(cmd_ctx, "LVD Reset Selection: VDD or VDDQ Inputs"); + command_print(CMD_CTX, "LVD Reset Selection: VDD or VDDQ Inputs"); else - command_print(cmd_ctx, "LVD Reset Selection: VDD Input Only"); + command_print(CMD_CTX, "LVD Reset Selection: VDD Input Only"); return ERROR_OK; } @@ -900,7 +900,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_write_command) if (CMD_ARGC < 1) { - command_print(cmd_ctx, "str9xpec options_write <bank>"); + command_print(CMD_CTX, "str9xpec options_write <bank>"); return ERROR_OK; } @@ -923,7 +923,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_cmap_command) if (CMD_ARGC < 2) { - command_print(cmd_ctx, "str9xpec options_cmap <bank> <bank0 | bank1>"); + command_print(CMD_CTX, "str9xpec options_cmap <bank> <bank0 | bank1>"); return ERROR_OK; } @@ -952,7 +952,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdthd_command) if (CMD_ARGC < 2) { - command_print(cmd_ctx, "str9xpec options_lvdthd <bank> <2.4v | 2.7v>"); + command_print(CMD_CTX, "str9xpec options_lvdthd <bank> <2.4v | 2.7v>"); return ERROR_OK; } @@ -981,7 +981,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdsel_command) if (CMD_ARGC < 2) { - command_print(cmd_ctx, "str9xpec options_lvdsel <bank> <vdd | vdd_vddq>"); + command_print(CMD_CTX, "str9xpec options_lvdsel <bank> <vdd | vdd_vddq>"); return ERROR_OK; } @@ -1010,7 +1010,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdwarn_command) if (CMD_ARGC < 2) { - command_print(cmd_ctx, "str9xpec options_lvdwarn <bank> <vdd | vdd_vddq>"); + command_print(CMD_CTX, "str9xpec options_lvdwarn <bank> <vdd | vdd_vddq>"); return ERROR_OK; } @@ -1039,7 +1039,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_lock_command) if (CMD_ARGC < 1) { - command_print(cmd_ctx, "str9xpec lock <bank>"); + command_print(CMD_CTX, "str9xpec lock <bank>"); return ERROR_OK; } @@ -1062,7 +1062,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_unlock_command) if (CMD_ARGC < 1) { - command_print(cmd_ctx, "str9xpec unlock <bank>"); + command_print(CMD_CTX, "str9xpec unlock <bank>"); return ERROR_OK; } @@ -1088,7 +1088,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_enable_turbo_command) if (CMD_ARGC < 1) { - command_print(cmd_ctx, "str9xpec enable_turbo <bank>"); + command_print(CMD_CTX, "str9xpec enable_turbo <bank>"); return ERROR_OK; } @@ -1106,14 +1106,14 @@ COMMAND_HANDLER(str9xpec_handle_flash_enable_turbo_command) if (tap1 == NULL) { /* things are *WRONG* */ - command_print(cmd_ctx,"**STR9FLASH** (tap1) invalid chain?"); + command_print(CMD_CTX,"**STR9FLASH** (tap1) invalid chain?"); return ERROR_OK; } tap2 = tap1->next_tap; if (tap2 == NULL) { /* things are *WRONG* */ - command_print(cmd_ctx,"**STR9FLASH** (tap2) invalid chain?"); + command_print(CMD_CTX,"**STR9FLASH** (tap2) invalid chain?"); return ERROR_OK; } @@ -1135,7 +1135,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_disable_turbo_command) if (CMD_ARGC < 1) { - command_print(cmd_ctx, "str9xpec disable_turbo <bank>"); + command_print(CMD_CTX, "str9xpec disable_turbo <bank>"); return ERROR_OK; } diff --git a/src/flash/tms470.c b/src/flash/tms470.c index 890db73..f6f3900 100644 --- a/src/flash/tms470.c +++ b/src/flash/tms470.c @@ -293,7 +293,7 @@ COMMAND_HANDLER(tms470_handle_flash_keyset_command) { if (CMD_ARGC > 4) { - command_print(cmd_ctx, "tms470 flash_keyset <key0> <key1> <key2> <key3>"); + command_print(CMD_CTX, "tms470 flash_keyset <key0> <key1> <key2> <key3>"); return ERROR_INVALID_ARGUMENTS; } else if (CMD_ARGC == 4) @@ -306,7 +306,7 @@ COMMAND_HANDLER(tms470_handle_flash_keyset_command) if (1 != sscanf(&CMD_ARGV[i][start], "%" SCNx32 "", &flashKeys[i])) { - command_print(cmd_ctx, "could not process flash key %s", CMD_ARGV[i]); + command_print(CMD_CTX, "could not process flash key %s", CMD_ARGV[i]); LOG_ERROR("could not process flash key %s", CMD_ARGV[i]); return ERROR_INVALID_ARGUMENTS; } @@ -316,18 +316,18 @@ COMMAND_HANDLER(tms470_handle_flash_keyset_command) } else if (CMD_ARGC != 0) { - command_print(cmd_ctx, "tms470 flash_keyset <key0> <key1> <key2> <key3>"); + command_print(CMD_CTX, "tms470 flash_keyset <key0> <key1> <key2> <key3>"); return ERROR_INVALID_ARGUMENTS; } if (keysSet) { - command_print(cmd_ctx, "using flash keys 0x%08" PRIx32 ", 0x%08" PRIx32 ", 0x%08" PRIx32 ", 0x%08" PRIx32 "", + command_print(CMD_CTX, "using flash keys 0x%08" PRIx32 ", 0x%08" PRIx32 ", 0x%08" PRIx32 ", 0x%08" PRIx32 "", flashKeys[0], flashKeys[1], flashKeys[2], flashKeys[3]); } else { - command_print(cmd_ctx, "flash keys not set"); + command_print(CMD_CTX, "flash keys not set"); } return ERROR_OK; @@ -357,7 +357,7 @@ COMMAND_HANDLER(tms470_handle_osc_megahertz_command) { if (CMD_ARGC > 1) { - command_print(cmd_ctx, "tms470 osc_megahertz <MHz>"); + command_print(CMD_CTX, "tms470 osc_megahertz <MHz>"); return ERROR_INVALID_ARGUMENTS; } else if (CMD_ARGC == 1) @@ -368,12 +368,12 @@ COMMAND_HANDLER(tms470_handle_osc_megahertz_command) if (oscMHz <= 0) { LOG_ERROR("osc_megahertz must be positive and non-zero!"); - command_print(cmd_ctx, "osc_megahertz must be positive and non-zero!"); + command_print(CMD_CTX, "osc_megahertz must be positive and non-zero!"); oscMHz = 12; return ERROR_INVALID_ARGUMENTS; } - command_print(cmd_ctx, "osc_megahertz=%d", oscMHz); + command_print(CMD_CTX, "osc_megahertz=%d", oscMHz); return ERROR_OK; } @@ -386,7 +386,7 @@ COMMAND_HANDLER(tms470_handle_plldis_command) { if (CMD_ARGC > 1) { - command_print(cmd_ctx, "tms470 plldis <0 | 1>"); + command_print(CM... [truncated message content] |
From: David B. <dbr...@us...> - 2009-11-17 18:07:02
|
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 f4788652e45662d1e43933dc0620561bc4cddae0 (commit) from 959b373f8cdc2c1ad11c67c6916f88f48769438f (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 f4788652e45662d1e43933dc0620561bc4cddae0 Author: David Brownell <dbr...@us...> Date: Tue Nov 17 09:06:45 2009 -0800 target: simplify register get/set ops No need to indirect from registered integers to pointers. Just stash the pointers directly in the register struct, and don't even bother registering. This is a small code shrink, speeds register access just a smidgeon, and gets rid of another rude exit() path. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 55ec7d4..9581ea6 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -1004,14 +1004,10 @@ int gdb_set_registers_packet(struct connection *connection, struct target *targe LOG_ERROR("BUG: register packet is too small for registers"); } - struct reg_arch_type *arch_type; bin_buf = malloc(DIV_ROUND_UP(reg_list[i]->size, 8)); gdb_target_to_reg(target, packet_p, chars, bin_buf); - /* get register arch_type, and call set method */ - arch_type = register_get_arch_type(reg_list[i]->arch_type); - - arch_type->set(reg_list[i], bin_buf); + reg_list[i]->type->set(reg_list[i], bin_buf); /* advance packet pointer */ packet_p += chars; @@ -1071,7 +1067,6 @@ int gdb_set_register_packet(struct connection *connection, struct target *target struct reg **reg_list; int reg_list_size; int retval; - struct reg_arch_type *arch_type; LOG_DEBUG("-"); @@ -1100,9 +1095,7 @@ int gdb_set_register_packet(struct connection *connection, struct target *target gdb_target_to_reg(target, separator + 1, chars, bin_buf); - /* get register arch_type, and call set method */ - arch_type = register_get_arch_type(reg_list[reg_num]->arch_type); - arch_type->set(reg_list[reg_num], bin_buf); + reg_list[reg_num]->type->set(reg_list[reg_num], bin_buf); gdb_put_packet(connection, "OK", 2); diff --git a/src/target/arm11.c b/src/target/arm11.c index 31135e4..936edd8 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -58,8 +58,6 @@ static uint32_t arm11_vcr = 0; static bool arm11_config_step_irq_enable = false; static bool arm11_config_hardware_step = false; -static int arm11_regs_arch_type = -1; - enum arm11_regtype { ARM11_REGISTER_CORE, @@ -263,7 +261,6 @@ static struct reg arm11_gdb_dummy_fp_reg = .valid = 1, .size = 96, .arch_info = NULL, - .arch_type = 0, }; static uint8_t arm11_gdb_dummy_fps_value[4]; @@ -276,7 +273,6 @@ static struct reg arm11_gdb_dummy_fps_reg = .valid = 1, .size = 32, .arch_info = NULL, - .arch_type = 0, }; @@ -1945,6 +1941,11 @@ static int arm11_set_reg(struct reg *reg, uint8_t *buf) return ERROR_OK; } +static const struct reg_arch_type arm11_reg_type = { + .get = arm11_get_reg, + .set = arm11_set_reg, +}; + static int arm11_build_reg_cache(struct target *target) { struct arm11_common *arm11 = target_to_arm11(target); @@ -1953,9 +1954,6 @@ static int arm11_build_reg_cache(struct target *target) NEW(struct reg, reg_list, ARM11_REGCACHE_COUNT); NEW(struct arm11_reg_state, arm11_reg_states, ARM11_REGCACHE_COUNT); - if (arm11_regs_arch_type == -1) - arm11_regs_arch_type = register_reg_arch_type(arm11_get_reg, arm11_set_reg); - register_init_dummy(&arm11_gdb_dummy_fp_reg); register_init_dummy(&arm11_gdb_dummy_fps_reg); @@ -1995,7 +1993,7 @@ static int arm11_build_reg_cache(struct target *target) r->value = (uint8_t *)(arm11->reg_values + i); r->dirty = 0; r->valid = 0; - r->arch_type = arm11_regs_arch_type; + r->type = &arm11_reg_type; r->arch_info = rs; rs->def_index = i; diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 717c826..413061f 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -116,8 +116,6 @@ char* armv4_5_state_strings[] = "ARM", "Thumb", "Jazelle" }; -int armv4_5_core_reg_arch_type = -1; - struct armv4_5_core_reg armv4_5_core_reg_list_arch_info[] = { {0, ARMV4_5_MODE_ANY, NULL, NULL}, @@ -201,7 +199,6 @@ struct reg armv4_5_gdb_dummy_fp_reg = .valid = 1, .size = 96, .arch_info = NULL, - .arch_type = 0, }; uint8_t armv4_5_gdb_dummy_fps_value[] = {0, 0, 0, 0}; @@ -214,7 +211,6 @@ struct reg armv4_5_gdb_dummy_fps_reg = .valid = 1, .size = 32, .arch_info = NULL, - .arch_type = 0, }; int armv4_5_get_core_reg(struct reg *reg) @@ -285,6 +281,11 @@ int armv4_5_set_core_reg(struct reg *reg, uint8_t *buf) return ERROR_OK; } +static const struct reg_arch_type arm_reg_type = { + .get = armv4_5_get_core_reg, + .set = armv4_5_set_core_reg, +}; + int armv4_5_invalidate_core_regs(struct target *target) { struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target); @@ -312,9 +313,6 @@ struct reg_cache* armv4_5_build_reg_cache(struct target *target, struct arm *arm cache->reg_list = reg_list; cache->num_regs = num_regs; - if (armv4_5_core_reg_arch_type == -1) - armv4_5_core_reg_arch_type = register_reg_arch_type(armv4_5_get_core_reg, armv4_5_set_core_reg); - register_init_dummy(&armv4_5_gdb_dummy_fp_reg); register_init_dummy(&armv4_5_gdb_dummy_fps_reg); @@ -328,7 +326,7 @@ struct reg_cache* armv4_5_build_reg_cache(struct target *target, struct arm *arm reg_list[i].value = calloc(1, 4); reg_list[i].dirty = 0; reg_list[i].valid = 0; - reg_list[i].arch_type = armv4_5_core_reg_arch_type; + reg_list[i].type = &arm_reg_type; reg_list[i].arch_info = &arch_info[i]; } diff --git a/src/target/armv7a.c b/src/target/armv7a.c index fdaca31..5193b2a 100644 --- a/src/target/armv7a.c +++ b/src/target/armv7a.c @@ -157,7 +157,6 @@ struct reg armv7a_gdb_dummy_fp_reg = .valid = 1, .size = 96, .arch_info = NULL, - .arch_type = 0, }; void armv7a_show_fault_registers(struct target *target) diff --git a/src/target/armv7m.c b/src/target/armv7m.c index 3b01fa9..8c1de32 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -72,7 +72,6 @@ static struct reg armv7m_gdb_dummy_fp_reg = .valid = 1, .size = 96, .arch_info = NULL, - .arch_type = 0, }; static uint8_t armv7m_gdb_dummy_fps_value[4]; @@ -85,7 +84,6 @@ static struct reg armv7m_gdb_dummy_fps_reg = .valid = 1, .size = 32, .arch_info = NULL, - .arch_type = 0, }; #ifdef ARMV7_GDB_HACKS @@ -99,7 +97,6 @@ struct reg armv7m_gdb_dummy_cpsr_reg = .valid = 1, .size = 32, .arch_info = NULL, - .arch_type = 0, }; #endif @@ -148,8 +145,6 @@ static const struct { #define ARMV7M_NUM_REGS ARRAY_SIZE(armv7m_regs) -static int armv7m_core_reg_arch_type = -1; - /** * Restores target context using the cache of core registers set up * by armv7m_build_reg_cache(), calling optional core-specific hooks. @@ -542,6 +537,10 @@ int armv7m_arch_state(struct target *target) return ERROR_OK; } +static const struct reg_arch_type armv7m_reg_type = { + .get = armv7m_get_core_reg, + .set = armv7m_set_core_reg, +}; /** Builds cache of architecturally defined registers. */ struct reg_cache *armv7m_build_reg_cache(struct target *target) @@ -554,11 +553,6 @@ struct reg_cache *armv7m_build_reg_cache(struct target *target) struct armv7m_core_reg *arch_info = calloc(num_regs, sizeof(struct armv7m_core_reg)); int i; - if (armv7m_core_reg_arch_type == -1) - { - armv7m_core_reg_arch_type = register_reg_arch_type(armv7m_get_core_reg, armv7m_set_core_reg); - } - register_init_dummy(&armv7m_gdb_dummy_fps_reg); #ifdef ARMV7_GDB_HACKS register_init_dummy(&armv7m_gdb_dummy_cpsr_reg); @@ -583,7 +577,7 @@ struct reg_cache *armv7m_build_reg_cache(struct target *target) reg_list[i].value = calloc(1, 4); reg_list[i].dirty = 0; reg_list[i].valid = 0; - reg_list[i].arch_type = armv7m_core_reg_arch_type; + reg_list[i].type = &armv7m_reg_type; reg_list[i].arch_info = &arch_info[i]; } diff --git a/src/target/cortex_m3.c b/src/target/cortex_m3.c index 7e48dae..c7b978b 100644 --- a/src/target/cortex_m3.c +++ b/src/target/cortex_m3.c @@ -1478,7 +1478,10 @@ static struct dwt_reg dwt_comp[] = { #undef DWT_COMPARATOR }; -static int dwt_reg_type = -1; +static const struct reg_arch_type dwt_reg_type = { + .get = cortex_m3_dwt_get_reg, + .set = cortex_m3_dwt_set_reg, +}; static void cortex_m3_dwt_addreg(struct target *t, struct reg *r, struct dwt_reg *d) @@ -1495,7 +1498,7 @@ cortex_m3_dwt_addreg(struct target *t, struct reg *r, struct dwt_reg *d) r->size = d->size; r->value = &state->value; r->arch_info = state; - r->arch_type = dwt_reg_type; + r->type = &dwt_reg_type; } static void @@ -1512,10 +1515,6 @@ cortex_m3_dwt_setup(struct cortex_m3_common *cm3, struct target *target) return; } - if (dwt_reg_type < 0) - dwt_reg_type = register_reg_arch_type(cortex_m3_dwt_get_reg, - cortex_m3_dwt_set_reg); - cm3->dwt_num_comp = (dwtcr >> 28) & 0xF; cm3->dwt_comp_available = cm3->dwt_num_comp; cm3->dwt_comparator_list = calloc(cm3->dwt_num_comp, diff --git a/src/target/embeddedice.c b/src/target/embeddedice.c index 2e9f1c0..e375475 100644 --- a/src/target/embeddedice.c +++ b/src/target/embeddedice.c @@ -143,8 +143,6 @@ static const struct { }; -static int embeddedice_reg_arch_type = -1; - static int embeddedice_get_reg(struct reg *reg) { int retval; @@ -157,6 +155,11 @@ static int embeddedice_get_reg(struct reg *reg) return retval; } +static const struct reg_arch_type eice_reg_type = { + .get = embeddedice_get_reg, + .set = embeddedice_set_reg_w_exec, +}; + /** * Probe EmbeddedICE module and set up local records of its registers. * Different versions of the modules have different capabilities, such as @@ -174,11 +177,6 @@ embeddedice_build_reg_cache(struct target *target, struct arm7_9_common *arm7_9) int i; int eice_version = 0; - /* register arch-type for EmbeddedICE registers only once */ - if (embeddedice_reg_arch_type == -1) - embeddedice_reg_arch_type = register_reg_arch_type( - embeddedice_get_reg, embeddedice_set_reg_w_exec); - /* vector_catch isn't always present */ if (!arm7_9->has_vector_catch) num_regs--; @@ -202,7 +200,7 @@ embeddedice_build_reg_cache(struct target *target, struct arm7_9_common *arm7_9) reg_list[i].valid = 0; reg_list[i].value = calloc(1, 4); reg_list[i].arch_info = &arch_info[i]; - reg_list[i].arch_type = embeddedice_reg_arch_type; + reg_list[i].type = &eice_reg_type; arch_info[i].addr = eice_regs[i].addr; arch_info[i].jtag_info = jtag_info; } diff --git a/src/target/etb.c b/src/target/etb.c index 196df6c..859ebaf 100644 --- a/src/target/etb.c +++ b/src/target/etb.c @@ -40,8 +40,6 @@ static char* etb_reg_list[] = "ETB_control", }; -static int etb_reg_arch_type = -1; - static int etb_get_reg(struct reg *reg); static int etb_set_instr(struct etb *etb, uint32_t new_instr) @@ -123,6 +121,11 @@ static int etb_get_reg(struct reg *reg) return ERROR_OK; } +static const struct reg_arch_type etb_reg_type = { + .get = etb_get_reg, + .set = etb_set_reg_w_exec, +}; + struct reg_cache* etb_build_reg_cache(struct etb *etb) { struct reg_cache *reg_cache = malloc(sizeof(struct reg_cache)); @@ -131,10 +134,6 @@ struct reg_cache* etb_build_reg_cache(struct etb *etb) int num_regs = 9; int i; - /* register a register arch-type for etm registers only once */ - if (etb_reg_arch_type == -1) - etb_reg_arch_type = register_reg_arch_type(etb_get_reg, etb_set_reg_w_exec); - /* the actual registers are kept in two arrays */ reg_list = calloc(num_regs, sizeof(struct reg)); arch_info = calloc(num_regs, sizeof(struct etb_reg)); @@ -154,7 +153,7 @@ struct reg_cache* etb_build_reg_cache(struct etb *etb) reg_list[i].valid = 0; reg_list[i].value = calloc(1, 4); reg_list[i].arch_info = &arch_info[i]; - reg_list[i].arch_type = etb_reg_arch_type; + reg_list[i].type = &etb_reg_type; reg_list[i].size = 32; arch_info[i].addr = i; arch_info[i].etb = etb; diff --git a/src/target/etm.c b/src/target/etm.c index fa7a71b..31b8bb2 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -214,8 +214,6 @@ static const struct etm_reg_info etm_outputs[] = { { 0x6f, 32, RO, 0x20, "ETM_contextid_comparator_mask", } #endif -static int etm_reg_arch_type = -1; - static int etm_get_reg(struct reg *reg); static int etm_read_reg_w_check(struct reg *reg, uint8_t* check_value, uint8_t* check_mask); @@ -225,6 +223,10 @@ static int etm_write_reg(struct reg *reg, uint32_t value); static struct command *etm_cmd; +static const struct reg_arch_type etm_scan6_type = { + .get = etm_get_reg, + .set = etm_set_reg_w_exec, +}; /* Look up register by ID ... most ETM instances only * support a subset of the possible registers. @@ -269,7 +271,7 @@ static void etm_reg_add(unsigned bcd_vers, struct arm_jtag *jtag_info, reg->size = r->size; reg->value = &ereg->value; reg->arch_info = ereg; - reg->arch_type = etm_reg_arch_type; + reg->type = &etm_scan6_type; reg++; cache->num_regs++; @@ -287,11 +289,6 @@ struct reg_cache *etm_build_reg_cache(struct target *target, struct etm_reg *arch_info = NULL; unsigned bcd_vers, config; - /* register a register arch-type for etm registers only once */ - if (etm_reg_arch_type == -1) - etm_reg_arch_type = register_reg_arch_type(etm_get_reg, - etm_set_reg_w_exec); - /* the actual registers are kept in two arrays */ reg_list = calloc(128, sizeof(struct reg)); arch_info = calloc(128, sizeof(struct etm_reg)); diff --git a/src/target/mips32.c b/src/target/mips32.c index 1315744..f986079 100644 --- a/src/target/mips32.c +++ b/src/target/mips32.c @@ -97,11 +97,8 @@ struct reg mips32_gdb_dummy_fp_reg = .valid = 1, .size = 32, .arch_info = NULL, - .arch_type = 0, }; -int mips32_core_reg_arch_type = -1; - int mips32_get_core_reg(struct reg *reg) { int retval; @@ -278,6 +275,11 @@ int mips32_arch_state(struct target *target) return ERROR_OK; } +static const struct reg_arch_type mips32_reg_type = { + .get = mips32_get_core_reg, + .set = mips32_set_core_reg, +}; + struct reg_cache *mips32_build_reg_cache(struct target *target) { /* get pointers to arch-specific information */ @@ -290,9 +292,6 @@ struct reg_cache *mips32_build_reg_cache(struct target *target) struct mips32_core_reg *arch_info = malloc(sizeof(struct mips32_core_reg) * num_regs); int i; - if (mips32_core_reg_arch_type == -1) - mips32_core_reg_arch_type = register_reg_arch_type(mips32_get_core_reg, mips32_set_core_reg); - register_init_dummy(&mips32_gdb_dummy_fp_reg); /* Build the process context cache */ @@ -313,7 +312,7 @@ struct reg_cache *mips32_build_reg_cache(struct target *target) reg_list[i].value = calloc(1, 4); reg_list[i].dirty = 0; reg_list[i].valid = 0; - reg_list[i].arch_type = mips32_core_reg_arch_type; + reg_list[i].type = &mips32_reg_type; reg_list[i].arch_info = &arch_info[i]; } diff --git a/src/target/register.c b/src/target/register.c index bb046a1..d9ef53e 100644 --- a/src/target/register.c +++ b/src/target/register.c @@ -29,8 +29,6 @@ #include "log.h" -struct reg_arch_type *reg_arch_types = NULL; - struct reg* register_get_by_name(struct reg_cache *first, const char *name, bool search_all) { @@ -67,44 +65,6 @@ struct reg_cache** register_get_last_cache_p(struct reg_cache **first) return cache_p; } -int register_reg_arch_type(int (*get)(struct reg *reg), int (*set)(struct reg *reg, uint8_t *buf)) -{ - struct reg_arch_type** arch_type_p = ®_arch_types; - int id = 0; - - if (*arch_type_p) - { - while (*arch_type_p) - { - id = (*arch_type_p)->id; - arch_type_p = &((*arch_type_p)->next); - } - } - - (*arch_type_p) = malloc(sizeof(struct reg_arch_type)); - (*arch_type_p)->id = id + 1; - (*arch_type_p)->set = set; - (*arch_type_p)->get = get; - (*arch_type_p)->next = NULL; - - return id + 1; -} - -struct reg_arch_type* register_get_arch_type(int id) -{ - struct reg_arch_type *arch_type = reg_arch_types; - - while (arch_type) - { - if (arch_type->id == id) - return arch_type; - arch_type = arch_type->next; - } - LOG_ERROR("BUG: encountered unregistered arch type 0x%08x", id); - exit(-1); - return NULL; -} - static int register_get_dummy_core_reg(struct reg *reg) { return ERROR_OK; @@ -118,11 +78,12 @@ static int register_set_dummy_core_reg(struct reg *reg, uint8_t *buf) return ERROR_OK; } +static const struct reg_arch_type dummy_type = { + .get = register_get_dummy_core_reg, + .set = register_set_dummy_core_reg, +}; + void register_init_dummy(struct reg *reg) { - static int dummy_arch_type = -1; - if (dummy_arch_type == -1) - dummy_arch_type = register_reg_arch_type(register_get_dummy_core_reg, register_set_dummy_core_reg); - - reg->arch_type = dummy_arch_type; + reg->type = &dummy_type; } diff --git a/src/target/register.h b/src/target/register.h index 84d2aaa..c14dfd4 100644 --- a/src/target/register.h +++ b/src/target/register.h @@ -33,7 +33,7 @@ struct reg int valid; uint32_t size; void *arch_info; - int arch_type; + const struct reg_arch_type *type; }; struct reg_cache @@ -46,20 +46,14 @@ struct reg_cache struct reg_arch_type { - int id; int (*get)(struct reg *reg); int (*set)(struct reg *reg, uint8_t *buf); - struct reg_arch_type *next; }; struct reg* register_get_by_name(struct reg_cache *first, const char *name, bool search_all); struct reg_cache** register_get_last_cache_p(struct reg_cache **first); -int register_reg_arch_type(int (*get)(struct reg *reg), - int (*set)(struct reg *reg, uint8_t *buf)); -struct reg_arch_type* register_get_arch_type(int id); - void register_init_dummy(struct reg *reg); #endif /* REGISTER_H */ diff --git a/src/target/target.c b/src/target/target.c index c00c2ed..0b2438c 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -1955,8 +1955,7 @@ COMMAND_HANDLER(handle_reg_command) if (reg->valid == 0) { - struct reg_arch_type *arch_type = register_get_arch_type(reg->arch_type); - arch_type->get(reg); + reg->type->get(reg); } value = buf_to_str(reg->value, reg->size, 16); command_print(cmd_ctx, "%s (/%i): 0x%s", reg->name, (int)(reg->size), value); @@ -1970,8 +1969,7 @@ COMMAND_HANDLER(handle_reg_command) uint8_t *buf = malloc(DIV_ROUND_UP(reg->size, 8)); str_to_buf(args[1], strlen(args[1]), buf, reg->size, 0); - struct reg_arch_type *arch_type = register_get_arch_type(reg->arch_type); - arch_type->set(reg, buf); + reg->type->set(reg, buf); value = buf_to_str(reg->value, reg->size, 16); command_print(cmd_ctx, "%s (/%i): 0x%s", reg->name, (int)(reg->size), value); diff --git a/src/target/xscale.c b/src/target/xscale.c index 742dd25..4c3945c 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -134,8 +134,6 @@ static const struct xscale_reg xscale_reg_arch_info[] = {-1, NULL}, /* TXRXCTRL implicit access via JTAG */ }; -static int xscale_reg_arch_type = -1; - /* convenience wrapper to access XScale specific registers */ static int xscale_set_reg_u32(struct reg *reg, uint32_t value) { @@ -2819,6 +2817,11 @@ static int xscale_analyze_trace(struct target *target, struct command_context *c return ERROR_OK; } +static const struct reg_arch_type xscale_reg_type = { + .get = xscale_get_reg, + .set = xscale_set_reg, +}; + static void xscale_build_reg_cache(struct target *target) { struct xscale_common *xscale = target_to_xscale(target); @@ -2831,10 +2834,6 @@ static void xscale_build_reg_cache(struct target *target) (*cache_p) = armv4_5_build_reg_cache(target, armv4_5); armv4_5->core_cache = (*cache_p); - /* register a register arch-type for XScale dbg registers only once */ - if (xscale_reg_arch_type == -1) - xscale_reg_arch_type = register_reg_arch_type(xscale_get_reg, xscale_set_reg); - (*cache_p)->next = malloc(sizeof(struct reg_cache)); cache_p = &(*cache_p)->next; @@ -2852,7 +2851,7 @@ static void xscale_build_reg_cache(struct target *target) (*cache_p)->reg_list[i].valid = 0; (*cache_p)->reg_list[i].size = 32; (*cache_p)->reg_list[i].arch_info = &arch_info[i]; - (*cache_p)->reg_list[i].arch_type = xscale_reg_arch_type; + (*cache_p)->reg_list[i].type = &xscale_reg_type; arch_info[i] = xscale_reg_arch_info[i]; arch_info[i].target = target; } ----------------------------------------------------------------------- Summary of changes: src/server/gdb_server.c | 11 +-------- src/target/arm11.c | 14 +++++------- src/target/armv4_5.c | 14 +++++------- src/target/armv7a.c | 1 - src/target/armv7m.c | 16 ++++---------- src/target/cortex_m3.c | 11 ++++----- src/target/embeddedice.c | 14 +++++------- src/target/etb.c | 13 +++++------ src/target/etm.c | 13 ++++------- src/target/mips32.c | 13 +++++------ src/target/register.c | 51 +++++---------------------------------------- src/target/register.h | 8 +------ src/target/target.c | 6 +--- src/target/xscale.c | 13 +++++------ 14 files changed, 62 insertions(+), 136 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2009-11-17 15:59:45
|
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 959b373f8cdc2c1ad11c67c6916f88f48769438f (commit) via 741cd3c3ab172e6231fc5ed2d099993d59315f74 (commit) via ca32f25638408df8a9c18522da43f6e8adcdb5cb (commit) via 83104648e6a1834244eb1b1bb6324f729532906c (commit) from b888b63fe9bee26e567a645f6ceb10d66bfff785 (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 959b373f8cdc2c1ad11c67c6916f88f48769438f Author: Ãyvind Harboe <oyv...@zy...> Date: Tue Nov 17 11:03:55 2009 +0100 jtag_registers: Avalon bridge flushing tweaks The code is now much more explicit. It flushes every N writes. For now flush every time, but tinkering with the bridge FIFO size and how often we flush clearly points in the direction of the Avalon write FIFO full being the culprit. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/jtag/zy1000/jtag_minidriver.h b/src/jtag/zy1000/jtag_minidriver.h index 3fe16ef..afbea13 100644 --- a/src/jtag/zy1000/jtag_minidriver.h +++ b/src/jtag/zy1000/jtag_minidriver.h @@ -30,8 +30,19 @@ int diag_printf(const char *fmt, ...); #define ZY1000_POKE(a, b) HAL_WRITE_UINT32(a, b); diag_printf("poke 0x%08x,0x%08x\n", a, b) #define ZY1000_PEEK(a, b) HAL_READ_UINT32(a, b); diag_printf("peek 0x%08x = 0x%08x\n", a, b) #else -#define ZY1000_POKE(a, b) HAL_WRITE_UINT32(a, b) #define ZY1000_PEEK(a, b) HAL_READ_UINT32(a, b) +#define ZY1000_POKE(a, b) HAL_WRITE_UINT32(a, b);\ + {/* This will flush the bridge FIFO. Overflowed bridge FIFO fails. We must \ + flush every "often". No precise system has been found, but 4 seems solid. \ + */ \ + static int overflow_counter = 0; \ + if (++overflow_counter >= 1) \ + { \ + /* clear FIFO */ \ + cyg_uint32 empty; ZY1000_PEEK(ZY1000_JTAG_BASE + 0x10, empty); \ + overflow_counter = 0; \ + } \ + } #endif // FIFO empty? commit 741cd3c3ab172e6231fc5ed2d099993d59315f74 Author: Ãyvind Harboe <oyv...@zy...> Date: Tue Nov 17 11:00:02 2009 +0100 zy1000: revC UART forwarding Name of serial device differs between revB/C. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/ecosboard.c b/src/ecosboard.c index 0cbba3e..120b3f9 100644 --- a/src/ecosboard.c +++ b/src/ecosboard.c @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2008 by Ãyvind Harboe * + * Copyright (C) 2007-2009 by Ãyvind Harboe * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -81,6 +81,14 @@ #include <stdio.h> +#ifdef CYGPKG_HAL_NIOS2 +#define ZY1000_SER_DEV "/dev/uart_0" +#else +#define ZY1000_SER_DEV "/dev/ser0" + +#endif + + #define MAX_IFS 64 #if defined(CYGPKG_NET_FREEBSD_STACK) #include <tftp_support.h> @@ -684,7 +692,7 @@ static void zylinjtag_uart(cyg_addrword_t data) int oldopts = fcntl(session, F_GETFL, 0); fcntl(session, F_SETFL, oldopts | O_NONBLOCK); // - int serHandle = open("/dev/ser0", O_RDWR | O_NONBLOCK); + int serHandle = open(ZY1000_SER_DEV, O_RDWR | O_NONBLOCK); if (serHandle < 0) { close(session); @@ -886,10 +894,10 @@ int handle_uart_command(struct command_context *cmd_ctx, char *cmd, int err; cyg_io_handle_t serial_handle; - err = cyg_io_lookup("/dev/ser0", &serial_handle); + err = cyg_io_lookup(ZY1000_SER_DEV, &serial_handle); if (err != ENOERR) { - LOG_ERROR("/dev/ser0 not found\n"); + LOG_ERROR("Could not open serial port\n"); return ERROR_FAIL; } commit ca32f25638408df8a9c18522da43f6e8adcdb5cb Author: Ãyvind Harboe <oyv...@zy...> Date: Fri Nov 13 13:54:20 2009 +0100 zy1000: add version command to print FPGA version and timestamps Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/jtag/zy1000/zy1000.c b/src/jtag/zy1000/zy1000.c index f2a5aa9..a509aee 100644 --- a/src/jtag/zy1000/zy1000.c +++ b/src/jtag/zy1000/zy1000.c @@ -28,6 +28,8 @@ #include <cyg/hal/hal_io.h> // low level i/o #include <cyg/hal/hal_diag.h> +#include <time.h> + #define ZYLIN_VERSION GIT_ZY1000_VERSION #define ZYLIN_DATE __DATE__ #define ZYLIN_TIME __TIME__ @@ -257,9 +259,8 @@ int handle_power_command(struct command_context *cmd_ctx, char *cmd, char **args /* Give TELNET a way to find out what version this is */ static int jim_zy1000_version(Jim_Interp *interp, int argc, Jim_Obj *const *argv) { - if ((argc < 1) || (argc > 2)) + if ((argc < 1) || (argc > 3)) return JIM_ERR; - char buff[128]; const char *version_str = NULL; if (argc == 1) @@ -268,6 +269,9 @@ static int jim_zy1000_version(Jim_Interp *interp, int argc, Jim_Obj *const *argv } else { const char *str = Jim_GetString(argv[1], NULL); + const char *str2 = NULL; + if (argc > 2) + str2 = Jim_GetString(argv[2], NULL); if (strcmp("openocd", str) == 0) { version_str = ZYLIN_OPENOCD; @@ -292,6 +296,29 @@ static int jim_zy1000_version(Jim_Interp *interp, int argc, Jim_Obj *const *argv version_str="b"; #endif } +#ifdef CYGPKG_HAL_NIOS2 + else if (strcmp("fpga", str) == 0) + { + + /* return a list of 32 bit integers to describe the expected + * and actual FPGA + */ + static char *fpga_id = "0x12345678 0x12345678 0x12345678 0x12345678"; + cyg_uint32 id, timestamp; + HAL_READ_UINT32(SYSID_BASE, id); + HAL_READ_UINT32(SYSID_BASE+4, timestamp); + sprintf(fpga_id, "0x%08x 0x%08x 0x%08x 0x%08x", id, timestamp, SYSID_ID, SYSID_TIMESTAMP); + version_str = fpga_id; + if ((argc>2) && (strcmp("time", str2) == 0)) + { + time_t last_mod = timestamp; + char * t = ctime (&last_mod) ; + t[strlen(t)-1] = 0; + version_str = t; + } + } +#endif + else { return JIM_ERR; commit 83104648e6a1834244eb1b1bb6324f729532906c Author: Ãyvind Harboe <oyv...@zy...> Date: Thu Nov 12 10:10:11 2009 +0100 zy1000: fix bug when running on non-arm CPU Shifting by more than 32 is undefined for 32 bit integers according to the C standard. Robust solution is conditional code. Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/jtag/zy1000/zy1000.c b/src/jtag/zy1000/zy1000.c index 9a5d2e7..f2a5aa9 100644 --- a/src/jtag/zy1000/zy1000.c +++ b/src/jtag/zy1000/zy1000.c @@ -509,7 +509,14 @@ static __inline void scanFields(int num_fields, const struct scan_field *fields, } } /* mask away unused bits for easier debugging */ - value&=~(((uint32_t)0xffffffff) << k); + if (k < 32) + { + value&=~(((uint32_t)0xffffffff) << k); + } else + { + /* Shifting by >= 32 is not defined by the C standard + * and will in fact shift by &0x1f bits on nios */ + } shiftValueInner(shiftState, pause_state, k, value); ----------------------------------------------------------------------- Summary of changes: src/ecosboard.c | 16 +++++++++++--- src/jtag/zy1000/jtag_minidriver.h | 13 +++++++++++- src/jtag/zy1000/zy1000.c | 40 ++++++++++++++++++++++++++++++++++-- 3 files changed, 61 insertions(+), 8 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Øyvind H. <go...@us...> - 2009-11-17 15:03:04
|
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 b888b63fe9bee26e567a645f6ceb10d66bfff785 (commit) from 0181296f61f11e4390e5a381906021db4ddd4bcd (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 b888b63fe9bee26e567a645f6ceb10d66bfff785 Author: Ãyvind Harboe <oyv...@zy...> Date: Tue Nov 17 14:51:09 2009 +0100 zy1000: fix trivial syntax error introduced by latest refactorings Signed-off-by: Ãyvind Harboe <oyv...@zy...> diff --git a/src/jtag/zy1000/jtag_minidriver.h b/src/jtag/zy1000/jtag_minidriver.h index 9d093ca..3fe16ef 100644 --- a/src/jtag/zy1000/jtag_minidriver.h +++ b/src/jtag/zy1000/jtag_minidriver.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2008 by Ãyvind Harboe * + * Copyright (C) 2007-2009 by Ãyvind Harboe * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -148,7 +148,7 @@ static __inline__ void shiftValueInner(const enum tap_state state, const enum ta -static __inline__ void interface_jtag_add_dr_out_core(struct jtag_tap *struct targetap, +static __inline__ void interface_jtag_add_dr_out_core(struct jtag_tap *target_tap, int num_fields, const int *num_bits, const uint32_t *value, @@ -164,7 +164,7 @@ static __inline__ void interface_jtag_add_dr_out_core(struct jtag_tap *struct ta { pause_state = end_state; } - if (tap == struct targetap) + if (tap == target_tap) { int j; for (j = 0; j < (num_fields-1); j++) @@ -180,7 +180,7 @@ static __inline__ void interface_jtag_add_dr_out_core(struct jtag_tap *struct ta } } -static __inline__ void interface_jtag_add_dr_out(struct jtag_tap *struct targetap, +static __inline__ void interface_jtag_add_dr_out(struct jtag_tap *target_tap, int num_fields, const int *num_bits, const uint32_t *value, @@ -201,7 +201,7 @@ static __inline__ void interface_jtag_add_dr_out(struct jtag_tap *struct targeta shiftValueInner(TAP_DRSHIFT, end_state, num_bits[1], value[1]); } else { - interface_jtag_add_dr_out_core(struct targetap, num_fields, num_bits, value, end_state); + interface_jtag_add_dr_out_core(target_tap, num_fields, num_bits, value, end_state); } } ----------------------------------------------------------------------- Summary of changes: src/jtag/zy1000/jtag_minidriver.h | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: David B. <dbr...@us...> - 2009-11-17 10:10:26
|
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 0181296f61f11e4390e5a381906021db4ddd4bcd (commit) via 812ab89f58f43979a402ecf4bef7f09f84695cc6 (commit) via a2df544fd9cb758163b049f389c5cc07e97e029f (commit) from e722396890bdb07553959258c585853edfbb291c (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 0181296f61f11e4390e5a381906021db4ddd4bcd Author: David Brownell <dbr...@us...> Date: Tue Nov 17 01:09:50 2009 -0800 ARM9TDMI: remove now-needless "struct arm9tdmi" And move the rest of the vector_catch stuff into the C file; it's not part of the module interface. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/arm920t.c b/src/target/arm920t.c index fca3743..62dd3a1 100644 --- a/src/target/arm920t.c +++ b/src/target/arm920t.c @@ -62,7 +62,7 @@ static int arm920t_read_cp15_physical(struct target *target, uint8_t reg_addr_buf = reg_addr & 0x3f; uint8_t nr_w_buf = 0; - jtag_info = &arm920t->arm9tdmi_common.arm7_9_common.jtag_info; + jtag_info = &arm920t->arm7_9_common.jtag_info; jtag_set_end_state(TAP_IDLE); arm_jtag_scann(jtag_info, 0xf); @@ -115,7 +115,7 @@ static int arm920t_write_cp15_physical(struct target *target, uint8_t nr_w_buf = 1; uint8_t value_buf[4]; - jtag_info = &arm920t->arm9tdmi_common.arm7_9_common.jtag_info; + jtag_info = &arm920t->arm7_9_common.jtag_info; buf_set_u32(value_buf, 0, 32, value); @@ -164,7 +164,7 @@ static int arm920t_execute_cp15(struct target *target, uint32_t cp15_opcode, uint8_t nr_w_buf = 0; uint8_t cp15_opcode_buf[4]; - jtag_info = &arm920t->arm9tdmi_common.arm7_9_common.jtag_info; + jtag_info = &arm920t->arm7_9_common.jtag_info; jtag_set_end_state(TAP_IDLE); arm_jtag_scann(jtag_info, 0xf); @@ -444,7 +444,7 @@ int arm920t_arch_state(struct target *target) return ERROR_TARGET_INVALID; } - armv4_5 = &arm920t->arm9tdmi_common.arm7_9_common.armv4_5_common; + armv4_5 = &arm920t->arm7_9_common.armv4_5_common; LOG_USER("target halted in %s state due to %s, current mode: %s\n" "cpsr: 0x%8.8" PRIx32 " pc: 0x%8.8" PRIx32 "\n" @@ -623,12 +623,10 @@ int arm920t_soft_reset_halt(struct target *target) int arm920t_init_arch_info(struct target *target, struct arm920t_common *arm920t, struct jtag_tap *tap) { - struct arm9tdmi_common *arm9tdmi = &arm920t->arm9tdmi_common; - struct arm7_9_common *arm7_9 = &arm9tdmi->arm7_9_common; + struct arm7_9_common *arm7_9 = &arm920t->arm7_9_common; - /* initialize arm9tdmi specific info (including arm7_9 and armv4_5) - */ - arm9tdmi_init_arch_info(target, arm9tdmi, tap); + /* initialize arm7/arm9 specific info (including armv4_5) */ + arm9tdmi_init_arch_info(target, arm7_9, tap); arm920t->common_magic = ARM920T_COMMON_MAGIC; diff --git a/src/target/arm920t.h b/src/target/arm920t.h index 567c8de..ca6be7e 100644 --- a/src/target/arm920t.h +++ b/src/target/arm920t.h @@ -27,7 +27,7 @@ struct arm920t_common { - struct arm9tdmi_common arm9tdmi_common; + struct arm7_9_common arm7_9_common; uint32_t common_magic; struct armv4_5_mmu_common armv4_5_mmu; uint32_t cp15_control_reg; @@ -42,7 +42,7 @@ static inline struct arm920t_common * target_to_arm920(struct target *target) { return container_of(target->arch_info, struct arm920t_common, - arm9tdmi_common.arm7_9_common.armv4_5_common); + arm7_9_common.armv4_5_common); } struct arm920t_cache_line diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c index f305390..e38e7df 100644 --- a/src/target/arm926ejs.c +++ b/src/target/arm926ejs.c @@ -502,7 +502,7 @@ int arm926ejs_arch_state(struct target *target) return ERROR_TARGET_INVALID; } - armv4_5 = &arm926ejs->arm9tdmi_common.arm7_9_common.armv4_5_common; + armv4_5 = &arm926ejs->arm7_9_common.armv4_5_common; LOG_USER("target halted in %s state due to %s, current mode: %s\n" "cpsr: 0x%8.8" PRIx32 " pc: 0x%8.8" PRIx32 "\n" @@ -670,12 +670,10 @@ static int arm926ejs_read_phys_memory(struct target *target, int arm926ejs_init_arch_info(struct target *target, struct arm926ejs_common *arm926ejs, struct jtag_tap *tap) { - struct arm9tdmi_common *arm9tdmi = &arm926ejs->arm9tdmi_common; - struct arm7_9_common *arm7_9 = &arm9tdmi->arm7_9_common; + struct arm7_9_common *arm7_9 = &arm926ejs->arm7_9_common; - /* initialize arm9tdmi specific info (including arm7_9 and armv4_5) - */ - arm9tdmi_init_arch_info(target, arm9tdmi, tap); + /* initialize arm7/arm9 specific info (including armv4_5) */ + arm9tdmi_init_arch_info(target, arm7_9, tap); arm926ejs->common_magic = ARM926EJS_COMMON_MAGIC; diff --git a/src/target/arm926ejs.h b/src/target/arm926ejs.h index 22081f4..514f054 100644 --- a/src/target/arm926ejs.h +++ b/src/target/arm926ejs.h @@ -27,7 +27,7 @@ struct arm926ejs_common { - struct arm9tdmi_common arm9tdmi_common; + struct arm7_9_common arm7_9_common; uint32_t common_magic; struct armv4_5_mmu_common armv4_5_mmu; int (*read_cp15)(struct target *target, uint32_t op1, uint32_t op2, uint32_t CRn, uint32_t CRm, uint32_t *value); @@ -42,7 +42,7 @@ static inline struct arm926ejs_common * target_to_arm926(struct target *target) { return container_of(target->arch_info, struct arm926ejs_common, - arm9tdmi_common.arm7_9_common.armv4_5_common); + arm7_9_common.armv4_5_common); } diff --git a/src/target/arm966e.c b/src/target/arm966e.c index 3b85a5c..fc50acb 100644 --- a/src/target/arm966e.c +++ b/src/target/arm966e.c @@ -34,10 +34,10 @@ int arm966e_init_arch_info(struct target *target, struct arm966e_common *arm966e, struct jtag_tap *tap) { - struct arm9tdmi_common *arm9tdmi = &arm966e->arm9tdmi_common; - struct arm7_9_common *arm7_9 = &arm9tdmi->arm7_9_common; + struct arm7_9_common *arm7_9 = &arm966e->arm7_9_common; - arm9tdmi_init_arch_info(target, arm9tdmi, tap); + /* initialize arm7/arm9 specific info (including armv4_5) */ + arm9tdmi_init_arch_info(target, arm7_9, tap); arm966e->common_magic = ARM966E_COMMON_MAGIC; diff --git a/src/target/arm966e.h b/src/target/arm966e.h index b58f3a2..45aeb4e 100644 --- a/src/target/arm966e.h +++ b/src/target/arm966e.h @@ -29,7 +29,7 @@ struct arm966e_common { - struct arm9tdmi_common arm9tdmi_common; + struct arm7_9_common arm7_9_common; int common_magic; uint32_t cp15_control_reg; }; @@ -38,7 +38,7 @@ static inline struct arm966e_common * target_to_arm966(struct target *target) { return container_of(target->arch_info, struct arm966e_common, - arm9tdmi_common.arm7_9_common.armv4_5_common); + arm7_9_common.armv4_5_common); } int arm966e_init_arch_info(struct target *target, diff --git a/src/target/arm9tdmi.c b/src/target/arm9tdmi.c index 8e8f4d6..3492c2a 100644 --- a/src/target/arm9tdmi.c +++ b/src/target/arm9tdmi.c @@ -46,8 +46,22 @@ #define _DEBUG_INSTRUCTION_EXECUTION_ #endif -static const struct arm9tdmi_vector arm9tdmi_vectors[] = +enum arm9tdmi_vector_bit { + ARM9TDMI_RESET_VECTOR = 0x01, + ARM9TDMI_UNDEF_VECTOR = 0x02, + ARM9TDMI_SWI_VECTOR = 0x04, + ARM9TDMI_PABT_VECTOR = 0x08, + ARM9TDMI_DABT_VECTOR = 0x10, + /* BIT(5) reserved -- must be zero */ + ARM9TDMI_IRQ_VECTOR = 0x40, + ARM9TDMI_FIQ_VECTOR = 0x80, +}; + +static const struct arm9tdmi_vector { + char *name; + uint32_t value; +} arm9tdmi_vectors[] = { {"reset", ARM9TDMI_RESET_VECTOR}, {"undef", ARM9TDMI_UNDEF_VECTOR}, {"swi", ARM9TDMI_SWI_VECTOR}, @@ -750,14 +764,9 @@ int arm9tdmi_init_target(struct command_context *cmd_ctx, return ERROR_OK; } -int arm9tdmi_init_arch_info(struct target *target, struct arm9tdmi_common *arm9tdmi, struct jtag_tap *tap) +int arm9tdmi_init_arch_info(struct target *target, + struct arm7_9_common *arm7_9, struct jtag_tap *tap) { - struct arm *armv4_5; - struct arm7_9_common *arm7_9; - - arm7_9 = &arm9tdmi->arm7_9_common; - armv4_5 = &arm7_9->armv4_5_common; - /* prepare JTAG information for the new target */ arm7_9->jtag_info.tap = tap; arm7_9->jtag_info.scann_size = 5; @@ -812,10 +821,10 @@ int arm9tdmi_init_arch_info(struct target *target, struct arm9tdmi_common *arm9t static int arm9tdmi_target_create(struct target *target, Jim_Interp *interp) { - struct arm9tdmi_common *arm9tdmi = calloc(1,sizeof(struct arm9tdmi_common)); + struct arm7_9_common *arm7_9 = calloc(1,sizeof(struct arm7_9_common)); - arm9tdmi_init_arch_info(target, arm9tdmi, target->tap); - arm9tdmi->arm7_9_common.armv4_5_common.is_armv4 = true; + arm9tdmi_init_arch_info(target, arm7_9, target->tap); + arm7_9->armv4_5_common.is_armv4 = true; return ERROR_OK; } diff --git a/src/target/arm9tdmi.h b/src/target/arm9tdmi.h index 496e4c5..351b00a 100644 --- a/src/target/arm9tdmi.h +++ b/src/target/arm9tdmi.h @@ -25,36 +25,10 @@ #include "embeddedice.h" -/* FIXME we don't really need a separate arm9tdmi struct any more... - * remove it, the arm7/arm9 common struct suffices. - */ -struct arm9tdmi_common -{ - struct arm7_9_common arm7_9_common; -}; - -struct arm9tdmi_vector -{ - char *name; - uint32_t value; -}; - -enum arm9tdmi_vector_bit -{ - ARM9TDMI_RESET_VECTOR = 0x01, - ARM9TDMI_UNDEF_VECTOR = 0x02, - ARM9TDMI_SWI_VECTOR = 0x04, - ARM9TDMI_PABT_VECTOR = 0x08, - ARM9TDMI_DABT_VECTOR = 0x10, - /* BIT(5) reserved -- must be zero */ - ARM9TDMI_IRQ_VECTOR = 0x40, - ARM9TDMI_FIQ_VECTOR = 0x80, -}; - int arm9tdmi_init_target(struct command_context *cmd_ctx, struct target *target); int arm9tdmi_init_arch_info(struct target *target, - struct arm9tdmi_common *arm9tdmi, struct jtag_tap *tap); + struct arm7_9_common *arm7_9, struct jtag_tap *tap); int arm9tdmi_register_commands(struct command_context *cmd_ctx); int arm9tdmi_clock_out(struct arm_jtag *jtag_info, diff --git a/src/target/fa526.c b/src/target/fa526.c index e7c1a2e..9c22a75 100644 --- a/src/target/fa526.c +++ b/src/target/fa526.c @@ -256,12 +256,8 @@ static void fa526_branch_resume_thumb(struct target *target) } static int fa526_init_arch_info_2(struct target *target, - struct arm9tdmi_common *arm9tdmi, struct jtag_tap *tap) + struct arm7_9_common *arm7_9, struct jtag_tap *tap) { - struct arm7_9_common *arm7_9; - - arm7_9 = &arm9tdmi->arm7_9_common; - /* prepare JTAG information for the new target */ arm7_9->jtag_info.tap = tap; arm7_9->jtag_info.scann_size = 5; @@ -317,12 +313,10 @@ static int fa526_init_arch_info_2(struct target *target, static int fa526_init_arch_info(struct target *target, struct arm920t_common *arm920t, struct jtag_tap *tap) { - struct arm9tdmi_common *arm9tdmi = &arm920t->arm9tdmi_common; - struct arm7_9_common *arm7_9 = &arm9tdmi->arm7_9_common; + struct arm7_9_common *arm7_9 = &arm920t->arm7_9_common; - /* initialize arm9tdmi specific info (including arm7_9 and armv4_5) - */ - fa526_init_arch_info_2(target, arm9tdmi, tap); + /* initialize arm7/arm9 specific info (including armv4_5) */ + fa526_init_arch_info_2(target, arm7_9, tap); arm920t->common_magic = ARM920T_COMMON_MAGIC; commit 812ab89f58f43979a402ecf4bef7f09f84695cc6 Author: David Brownell <dbr...@us...> Date: Tue Nov 17 01:09:06 2009 -0800 ARM7TDMI: remove now-needless "struct arm7tdmi" Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/arm720t.c b/src/target/arm720t.c index 5d83517..3bac0be 100644 --- a/src/target/arm720t.c +++ b/src/target/arm720t.c @@ -49,7 +49,7 @@ static int arm720t_scan_cp15(struct target *target, uint8_t out_buf[4]; uint8_t instruction_buf = instruction; - jtag_info = &arm720t->arm7tdmi_common.arm7_9_common.jtag_info; + jtag_info = &arm720t->arm7_9_common.jtag_info; buf_set_u32(out_buf, 0, 32, flip_u32(out, 32)); @@ -232,7 +232,7 @@ static int arm720t_arch_state(struct target *target) "disabled", "enabled" }; - armv4_5 = &arm720t->arm7tdmi_common.arm7_9_common.armv4_5_common; + armv4_5 = &arm720t->arm7_9_common.armv4_5_common; LOG_USER("target halted in %s state due to %s, current mode: %s\n" "cpsr: 0x%8.8" PRIx32 " pc: 0x%8.8" PRIx32 "\n" @@ -305,10 +305,10 @@ static int arm720t_soft_reset_halt(struct target *target) { int retval = ERROR_OK; struct arm720t_common *arm720t = target_to_arm720(target); - struct reg *dbg_stat = &arm720t->arm7tdmi_common.arm7_9_common + struct reg *dbg_stat = &arm720t->arm7_9_common .eice_cache->reg_list[EICE_DBG_STAT]; - struct armv4_5_common_s *armv4_5 = &arm720t->arm7tdmi_common - .arm7_9_common.armv4_5_common; + struct armv4_5_common_s *armv4_5 = &arm720t->arm7_9_common + .armv4_5_common; if ((retval = target_halt(target)) != ERROR_OK) { @@ -380,10 +380,9 @@ static int arm720t_init_target(struct command_context *cmd_ctx, struct target *t static int arm720t_init_arch_info(struct target *target, struct arm720t_common *arm720t, struct jtag_tap *tap) { - struct arm7tdmi_common *arm7tdmi = &arm720t->arm7tdmi_common; - struct arm7_9_common *arm7_9 = &arm7tdmi->arm7_9_common; + struct arm7_9_common *arm7_9 = &arm720t->arm7_9_common; - arm7tdmi_init_arch_info(target, arm7tdmi, tap); + arm7tdmi_init_arch_info(target, arm7_9, tap); arm720t->common_magic = ARM720T_COMMON_MAGIC; @@ -406,7 +405,7 @@ static int arm720t_target_create(struct target *target, Jim_Interp *interp) { struct arm720t_common *arm720t = calloc(1, sizeof(*arm720t)); - arm720t->arm7tdmi_common.arm7_9_common.armv4_5_common.is_armv4 = true; + arm720t->arm7_9_common.armv4_5_common.is_armv4 = true; return arm720t_init_arch_info(target, arm720t, target->tap); } @@ -421,7 +420,7 @@ COMMAND_HANDLER(arm720t_handle_cp15_command) if (retval != ERROR_OK) return retval; - jtag_info = &arm720t->arm7tdmi_common.arm7_9_common.jtag_info; + jtag_info = &arm720t->arm7_9_common.jtag_info; if (target->state != TARGET_HALTED) { diff --git a/src/target/arm720t.h b/src/target/arm720t.h index 6bbac24..f0ab444 100644 --- a/src/target/arm720t.h +++ b/src/target/arm720t.h @@ -27,7 +27,7 @@ struct arm720t_common { - struct arm7tdmi_common arm7tdmi_common; + struct arm7_9_common arm7_9_common; uint32_t common_magic; struct armv4_5_mmu_common armv4_5_mmu; uint32_t cp15_control_reg; @@ -39,7 +39,7 @@ static inline struct arm720t_common * target_to_arm720(struct target *target) { return container_of(target->arch_info, struct arm720t_common, - arm7tdmi_common.arm7_9_common.armv4_5_common); + arm7_9_common.armv4_5_common); } #endif /* ARM720T_H */ diff --git a/src/target/arm7tdmi.c b/src/target/arm7tdmi.c index ba993ee..3bd5236 100644 --- a/src/target/arm7tdmi.c +++ b/src/target/arm7tdmi.c @@ -654,10 +654,9 @@ int arm7tdmi_init_target(struct command_context *cmd_ctx, struct target *target) return ERROR_OK; } -int arm7tdmi_init_arch_info(struct target *target, struct arm7tdmi_common *arm7tdmi, struct jtag_tap *tap) +int arm7tdmi_init_arch_info(struct target *target, + struct arm7_9_common *arm7_9, struct jtag_tap *tap) { - struct arm7_9_common *arm7_9 = &arm7tdmi->arm7_9_common; - /* prepare JTAG information for the new target */ arm7_9->jtag_info.tap = tap; arm7_9->jtag_info.scann_size = 4; @@ -706,11 +705,11 @@ int arm7tdmi_init_arch_info(struct target *target, struct arm7tdmi_common *arm7t static int arm7tdmi_target_create(struct target *target, Jim_Interp *interp) { - struct arm7tdmi_common *arm7tdmi; + struct arm7_9_common *arm7_9; - arm7tdmi = calloc(1,sizeof(struct arm7tdmi_common)); - arm7tdmi_init_arch_info(target, arm7tdmi, target->tap); - arm7tdmi->arm7_9_common.armv4_5_common.is_armv4 = true; + arm7_9 = calloc(1,sizeof(struct arm7_9_common)); + arm7tdmi_init_arch_info(target, arm7_9, target->tap); + arm7_9->armv4_5_common.is_armv4 = true; return ERROR_OK; } diff --git a/src/target/arm7tdmi.h b/src/target/arm7tdmi.h index 4ed6f3e..b6bbe59 100644 --- a/src/target/arm7tdmi.h +++ b/src/target/arm7tdmi.h @@ -25,15 +25,9 @@ #include "embeddedice.h" -/* FIXME we don't really need a separate arm7tdmi struct any more... - * remove it, the arm7/arm9 common struct suffices. - */ -struct arm7tdmi_common -{ - struct arm7_9_common arm7_9_common; -}; - -int arm7tdmi_init_arch_info(struct target *target, struct arm7tdmi_common *arm7tdmi, struct jtag_tap *tap); -int arm7tdmi_init_target(struct command_context *cmd_ctx, struct target *target); +int arm7tdmi_init_arch_info(struct target *target, + struct arm7_9_common *arm7_9, struct jtag_tap *tap); +int arm7tdmi_init_target(struct command_context *cmd_ctx, + struct target *target); #endif /* ARM7TDMI_H */ commit a2df544fd9cb758163b049f389c5cc07e97e029f Author: David Brownell <dbr...@us...> Date: Tue Nov 17 01:06:16 2009 -0800 target: remove some more duplicate includes Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/arm11.c b/src/target/arm11.c index f0ed85f..31135e4 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -27,7 +27,6 @@ #endif #include "etm.h" -#include "arm11.h" #include "breakpoints.h" #include "arm11_dbgtap.h" #include "arm_simulator.h" diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index 27a9b8d..923c8cd 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -33,7 +33,6 @@ #include "breakpoints.h" #include "embeddedice.h" #include "target_request.h" -#include "arm7_9_common.h" #include "etm.h" #include "time_support.h" #include "arm_simulator.h" diff --git a/src/target/cortex_a8.c b/src/target/cortex_a8.c index f4b5550..4cd6c0a 100644 --- a/src/target/cortex_a8.c +++ b/src/target/cortex_a8.c @@ -35,7 +35,6 @@ #include "breakpoints.h" #include "cortex_a8.h" -#include "armv4_5.h" #include "register.h" #include "target_request.h" #include "target_type.h" diff --git a/src/target/xscale.c b/src/target/xscale.c index e97e082..742dd25 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -30,7 +30,7 @@ #include "breakpoints.h" #include "xscale.h" #include "target_type.h" -#include "arm7_9_common.h" +#include "arm_jtag.h" #include "arm_simulator.h" #include "arm_disassembler.h" #include "time_support.h" ----------------------------------------------------------------------- Summary of changes: src/target/arm11.c | 1 - src/target/arm720t.c | 19 +++++++++---------- src/target/arm720t.h | 4 ++-- src/target/arm7_9_common.c | 1 - src/target/arm7tdmi.c | 13 ++++++------- src/target/arm7tdmi.h | 14 ++++---------- src/target/arm920t.c | 16 +++++++--------- src/target/arm920t.h | 4 ++-- src/target/arm926ejs.c | 10 ++++------ src/target/arm926ejs.h | 4 ++-- src/target/arm966e.c | 6 +++--- src/target/arm966e.h | 4 ++-- src/target/arm9tdmi.c | 31 ++++++++++++++++++++----------- src/target/arm9tdmi.h | 28 +--------------------------- src/target/cortex_a8.c | 1 - src/target/fa526.c | 14 ++++---------- src/target/xscale.c | 2 +- 17 files changed, 67 insertions(+), 105 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: David B. <dbr...@us...> - 2009-11-17 02:59:29
|
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 e722396890bdb07553959258c585853edfbb291c (commit) via 36a538c6d76c6a7483e6925c12669cd91807d918 (commit) via c5e00268365045a57354b53c63673990329e6d59 (commit) via 1d4a09c2ef22dc10ec8a40183b8dd1b1102af20d (commit) via 1f3e067b860927f18f88c5dbb11c7aefe22252a5 (commit) via 9d57f4d5a1bad5c5bd42df56f402413be828d915 (commit) via 6030f2ca03abcb934ce5b75be898ef74a0e89be0 (commit) from 47f2305229486f14eed948025c21c6ab73471d4e (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 e722396890bdb07553959258c585853edfbb291c Author: David Brownell <dbr...@us...> Date: Mon Nov 16 17:58:58 2009 -0800 ARMv7-A: no exit() calls Also, switch integrity check over to the correct magic number, and remove duplicate v4/v5 #define. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/armv7a.c b/src/target/armv7a.c index 8b16336..fdaca31 100644 --- a/src/target/armv7a.c +++ b/src/target/armv7a.c @@ -187,10 +187,10 @@ int armv7a_arch_state(struct target *target) struct armv7a_common *armv7a = target_to_armv7a(target); struct armv4_5_common_s *armv4_5 = &armv7a->armv4_5_common; - if (armv4_5->common_magic != ARMV4_5_COMMON_MAGIC) + if (armv7a->common_magic != ARMV7_COMMON_MAGIC) { - LOG_ERROR("BUG: called for a non-ARMv4/5 target"); - exit(-1); + LOG_ERROR("BUG: called for a non-ARMv7A target"); + return ERROR_INVALID_ARGUMENTS; } LOG_USER("target halted in %s state due to %s, current mode: %s\n" diff --git a/src/target/armv7a.h b/src/target/armv7a.h index a4be9e2..4d29ef9 100644 --- a/src/target/armv7a.h +++ b/src/target/armv7a.h @@ -73,7 +73,6 @@ enum ARMV7A_SPSR_UND = 36 }; -#define ARMV4_5_COMMON_MAGIC 0x0A450A45 #define ARMV7_COMMON_MAGIC 0x0A450999 /* VA to PA translation operations opc2 values*/ commit 36a538c6d76c6a7483e6925c12669cd91807d918 Author: David Brownell <dbr...@us...> Date: Mon Nov 16 17:57:12 2009 -0800 Cortex-A8: no exit() calls, add missing v7-A init Eventually there should be a v7a init routine, but for now all that is inlined here. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/cortex_a8.c b/src/target/cortex_a8.c index f099be9..f4b5550 100644 --- a/src/target/cortex_a8.c +++ b/src/target/cortex_a8.c @@ -984,7 +984,7 @@ static int cortex_a8_set_breakpoint(struct target *target, if (brp_i >= cortex_a8->brp_num) { LOG_ERROR("ERROR Can not find free Breakpoint Register Pair"); - exit(-1); + return ERROR_FAIL; } breakpoint->set = brp_i + 1; if (breakpoint->length == 2) @@ -1180,19 +1180,14 @@ static int cortex_a8_read_memory(struct target *target, uint32_t address, { struct armv7a_common *armv7a = target_to_armv7a(target); struct swjdp_common *swjdp = &armv7a->swjdp_info; - - int retval = ERROR_OK; - - /* sanitize arguments */ - if (((size != 4) && (size != 2) && (size != 1)) || (count == 0) || !(buffer)) - return ERROR_INVALID_ARGUMENTS; + int retval = ERROR_INVALID_ARGUMENTS; /* cortex_a8 handles unaligned memory access */ // ??? dap_ap_select(swjdp, swjdp_memoryap); - switch (size) - { + if (count && buffer) { + switch (size) { case 4: retval = mem_ap_read_buf_u32(swjdp, buffer, 4 * count, address); break; @@ -1202,9 +1197,7 @@ static int cortex_a8_read_memory(struct target *target, uint32_t address, case 1: retval = mem_ap_read_buf_u8(swjdp, buffer, count, address); break; - default: - LOG_ERROR("BUG: we shouldn't get here"); - exit(-1); + } } return retval; @@ -1215,17 +1208,12 @@ int cortex_a8_write_memory(struct target *target, uint32_t address, { struct armv7a_common *armv7a = target_to_armv7a(target); struct swjdp_common *swjdp = &armv7a->swjdp_info; - - int retval; - - /* sanitize arguments */ - if (((size != 4) && (size != 2) && (size != 1)) || (count == 0) || !(buffer)) - return ERROR_INVALID_ARGUMENTS; + int retval = ERROR_INVALID_ARGUMENTS; // ??? dap_ap_select(swjdp, swjdp_memoryap); - switch (size) - { + if (count && buffer) { + switch (size) { case 4: retval = mem_ap_write_buf_u32(swjdp, buffer, 4 * count, address); break; @@ -1235,12 +1223,10 @@ int cortex_a8_write_memory(struct target *target, uint32_t address, case 1: retval = mem_ap_write_buf_u8(swjdp, buffer, count, address); break; - default: - LOG_ERROR("BUG: we shouldn't get here"); - exit(-1); + } } - if (target->state == TARGET_HALTED) + if (retval == ERROR_OK && target->state == TARGET_HALTED) { /* The Cache handling will NOT work with MMU active, the wrong addresses will be invalidated */ /* invalidate I-Cache */ @@ -1453,19 +1439,18 @@ static int cortex_a8_init_target(struct command_context *cmd_ctx, int cortex_a8_init_arch_info(struct target *target, struct cortex_a8_common *cortex_a8, struct jtag_tap *tap) { - struct arm *armv4_5; - struct armv7a_common *armv7a; - - armv7a = &cortex_a8->armv7a_common; - armv4_5 = &armv7a->armv4_5_common; + struct armv7a_common *armv7a = &cortex_a8->armv7a_common; + struct arm *armv4_5 = &armv7a->armv4_5_common; struct swjdp_common *swjdp = &armv7a->swjdp_info; + /* REVISIT v7a setup should be in a v7a-specific routine */ + armv4_5_init_arch_info(target, armv4_5); + armv7a->common_magic = ARMV7_COMMON_MAGIC; + /* Setup struct cortex_a8_common */ cortex_a8->common_magic = CORTEX_A8_COMMON_MAGIC; armv4_5->arch_info = armv7a; - armv4_5_init_arch_info(target, armv4_5); - /* prepare JTAG information for the new target */ cortex_a8->jtag_info.tap = tap; cortex_a8->jtag_info.scann_size = 4; commit c5e00268365045a57354b53c63673990329e6d59 Author: David Brownell <dbr...@us...> Date: Mon Nov 16 17:55:49 2009 -0800 XScale: fewere exit() calls Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/xscale.c b/src/target/xscale.c index 9e93c02..e97e082 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -585,7 +585,7 @@ static int xscale_send(struct target *target, uint8_t *buffer, int count, int si break; default: LOG_ERROR("BUG: size neither 4, 2 nor 1"); - exit(-1); + return ERROR_INVALID_ARGUMENTS; } jtag_add_dr_out(target->tap, 3, @@ -850,7 +850,7 @@ static int xscale_arch_state(struct target *target) if (armv4_5->common_magic != ARMV4_5_COMMON_MAGIC) { LOG_ERROR("BUG: called for a non-ARMv4/5 target"); - exit(-1); + return ERROR_INVALID_ARGUMENTS; } LOG_USER("target halted in %s state due to %s, current mode: %s\n" @@ -1865,8 +1865,8 @@ static int xscale_read_memory(struct target *target, uint32_t address, *buffer++ = buf32[i] & 0xff; break; default: - LOG_ERROR("should never get here"); - exit(-1); + LOG_ERROR("invalid read size"); + return ERROR_INVALID_ARGUMENTS; } } commit 1d4a09c2ef22dc10ec8a40183b8dd1b1102af20d Author: David Brownell <dbr...@us...> Date: Mon Nov 16 17:55:30 2009 -0800 MIPS: no exit() calls Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/mips32.c b/src/target/mips32.c index 6ba433c..1315744 100644 --- a/src/target/mips32.c +++ b/src/target/mips32.c @@ -268,7 +268,7 @@ int mips32_arch_state(struct target *target) if (mips32->common_magic != MIPS32_COMMON_MAGIC) { LOG_ERROR("BUG: called for a non-MIPS32 target"); - exit(-1); + return ERROR_FAIL; } LOG_USER("target halted due to %s, pc: 0x%8.8" PRIx32 "", diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c index d1d3481..864ede0 100644 --- a/src/target/mips_m4k.c +++ b/src/target/mips_m4k.c @@ -513,10 +513,9 @@ int mips_m4k_set_breakpoint(struct target *target, struct breakpoint *breakpoint bp_num++; if (bp_num >= mips32->num_inst_bpoints) { - LOG_DEBUG("ERROR Can not find free FP Comparator(bpid: %d)", + LOG_ERROR("Can not find free FP Comparator(bpid: %d)", breakpoint->unique_id ); - LOG_WARNING("ERROR Can not find free FP Comparator"); - exit(-1); + return ERROR_FAIL; } breakpoint->set = bp_num + 1; comparator_list[bp_num].used = 1; @@ -724,9 +723,8 @@ int mips_m4k_set_watchpoint(struct target *target, struct watchpoint *watchpoint wp_num++; if (wp_num >= mips32->num_data_bpoints) { - LOG_DEBUG("ERROR Can not find free FP Comparator"); - LOG_WARNING("ERROR Can not find free FP Comparator"); - exit(-1); + LOG_ERROR("Can not find free FP Comparator"); + return ERROR_FAIL; } if (watchpoint->length != 4) commit 1f3e067b860927f18f88c5dbb11c7aefe22252a5 Author: David Brownell <dbr...@us...> Date: Mon Nov 16 17:54:51 2009 -0800 ARMv7-M: no exit() calls Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/armv7m.c b/src/target/armv7m.c index 132b786..3b01fa9 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -424,13 +424,13 @@ int armv7m_run_algorithm(struct target *target, if (!reg) { LOG_ERROR("BUG: register '%s' not found", reg_params[i].reg_name); - exit(-1); + return ERROR_INVALID_ARGUMENTS; } if (reg->size != reg_params[i].size) { LOG_ERROR("BUG: register '%s' size doesn't match reg_params[i].size", reg_params[i].reg_name); - exit(-1); + return ERROR_INVALID_ARGUMENTS; } // regvalue = buf_get_u32(reg_params[i].value, 0, 32); @@ -487,13 +487,13 @@ int armv7m_run_algorithm(struct target *target, if (!reg) { LOG_ERROR("BUG: register '%s' not found", reg_params[i].reg_name); - exit(-1); + return ERROR_INVALID_ARGUMENTS; } if (reg->size != reg_params[i].size) { LOG_ERROR("BUG: register '%s' size doesn't match reg_params[i].size", reg_params[i].reg_name); - exit(-1); + return ERROR_INVALID_ARGUMENTS; } buf_set_u32(reg_params[i].value, 0, 32, buf_get_u32(reg->value, 0, 32)); commit 9d57f4d5a1bad5c5bd42df56f402413be828d915 Author: David Brownell <dbr...@us...> Date: Mon Nov 16 17:52:50 2009 -0800 ARMv4/ARMv5: no exit() calls Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index b60b8b2..717c826 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -342,7 +342,7 @@ int armv4_5_arch_state(struct target *target) if (armv4_5->common_magic != ARMV4_5_COMMON_MAGIC) { LOG_ERROR("BUG: called for a non-ARMv4/5 target"); - exit(-1); + 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 "", @@ -651,13 +651,13 @@ int armv4_5_run_algorithm_inner(struct target *target, int num_mem_params, struc if (!reg) { LOG_ERROR("BUG: register '%s' not found", reg_params[i].reg_name); - exit(-1); + return ERROR_INVALID_ARGUMENTS; } if (reg->size != reg_params[i].size) { LOG_ERROR("BUG: register '%s' size doesn't match reg_params[i].size", reg_params[i].reg_name); - exit(-1); + return ERROR_INVALID_ARGUMENTS; } if ((retval = armv4_5_set_core_reg(reg, reg_params[i].value)) != ERROR_OK) @@ -674,7 +674,7 @@ int armv4_5_run_algorithm_inner(struct target *target, int num_mem_params, struc else { LOG_ERROR("BUG: can't execute algorithms when not in ARM or Thumb state"); - exit(-1); + return ERROR_INVALID_ARGUMENTS; } if (armv4_5_algorithm_info->core_mode != ARMV4_5_MODE_ANY) @@ -724,13 +724,15 @@ int armv4_5_run_algorithm_inner(struct target *target, int num_mem_params, struc if (!reg) { LOG_ERROR("BUG: register '%s' not found", reg_params[i].reg_name); - exit(-1); + retval = ERROR_INVALID_ARGUMENTS; + continue; } if (reg->size != reg_params[i].size) { LOG_ERROR("BUG: register '%s' size doesn't match reg_params[i].size", reg_params[i].reg_name); - exit(-1); + retval = ERROR_INVALID_ARGUMENTS; + continue; } buf_set_u32(reg_params[i].value, 0, 32, buf_get_u32(reg->value, 0, 32)); commit 6030f2ca03abcb934ce5b75be898ef74a0e89be0 Author: David Brownell <dbr...@us...> Date: Mon Nov 16 17:51:55 2009 -0800 ARM11: fewer exit() calls Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/arm11.c b/src/target/arm11.c index 4d9016f..f0ed85f 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -1665,13 +1665,13 @@ static int arm11_run_algorithm(struct target *target, if (!reg) { LOG_ERROR("BUG: register '%s' not found", reg_params[i].reg_name); - exit(-1); + return ERROR_INVALID_ARGUMENTS; } if (reg->size != reg_params[i].size) { LOG_ERROR("BUG: register '%s' size doesn't match reg_params[i].size", reg_params[i].reg_name); - exit(-1); + return ERROR_INVALID_ARGUMENTS; } arm11_set_reg(reg,reg_params[i].value); // printf("%i: Set %s =%08x\n", i, reg_params[i].reg_name,val); @@ -1750,13 +1750,15 @@ static int arm11_run_algorithm(struct target *target, if (!reg) { LOG_ERROR("BUG: register '%s' not found", reg_params[i].reg_name); - exit(-1); + retval = ERROR_INVALID_ARGUMENTS; + goto del_breakpoint; } if (reg->size != reg_params[i].size) { LOG_ERROR("BUG: register '%s' size doesn't match reg_params[i].size", reg_params[i].reg_name); - exit(-1); + retval = ERROR_INVALID_ARGUMENTS; + goto del_breakpoint; } buf_set_u32(reg_params[i].value, 0, 32, buf_get_u32(reg->value, 0, 32)); ----------------------------------------------------------------------- Summary of changes: src/target/arm11.c | 10 ++++++---- src/target/armv4_5.c | 14 ++++++++------ src/target/armv7a.c | 6 +++--- src/target/armv7a.h | 1 - src/target/armv7m.c | 8 ++++---- src/target/cortex_a8.c | 47 ++++++++++++++++------------------------------- src/target/mips32.c | 2 +- src/target/mips_m4k.c | 10 ++++------ src/target/xscale.c | 8 ++++---- 9 files changed, 46 insertions(+), 60 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: David B. <dbr...@us...> - 2009-11-17 01:43:07
|
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 47f2305229486f14eed948025c21c6ab73471d4e (commit) from 56adbaffd0a0fab320a64097cd6aa6e74473f840 (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 47f2305229486f14eed948025c21c6ab73471d4e Author: David Brownell <dbr...@us...> Date: Mon Nov 16 16:42:51 2009 -0800 Cortex-M3: don't exit() Get rid of undesirable and needless exit() calls from the Cortex-M3 support. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/cortex_m3.c b/src/target/cortex_m3.c index e99e99c..7e48dae 100644 --- a/src/target/cortex_m3.c +++ b/src/target/cortex_m3.c @@ -858,9 +858,8 @@ cortex_m3_set_breakpoint(struct target *target, struct breakpoint *breakpoint) fp_num++; if (fp_num >= cortex_m3->fp_num_code) { - LOG_DEBUG("ERROR Can not find free FP Comparator"); - LOG_WARNING("ERROR Can not find free FP Comparator"); - exit(-1); + LOG_ERROR("Can not find free FPB Comparator!"); + return ERROR_FAIL; } breakpoint->set = fp_num + 1; hilo = (breakpoint->address & 0x2) ? FPCR_REPLACE_BKPT_HIGH : FPCR_REPLACE_BKPT_LOW; @@ -1372,16 +1371,11 @@ static int cortex_m3_read_memory(struct target *target, uint32_t address, { struct armv7m_common *armv7m = target_to_armv7m(target); struct swjdp_common *swjdp = &armv7m->swjdp_info; - int retval; - - /* sanitize arguments */ - if (((size != 4) && (size != 2) && (size != 1)) || (count == 0) || !(buffer)) - return ERROR_INVALID_ARGUMENTS; + int retval = ERROR_INVALID_ARGUMENTS; /* cortex_m3 handles unaligned memory access */ - - switch (size) - { + if (count && buffer) { + switch (size) { case 4: retval = mem_ap_read_buf_u32(swjdp, buffer, 4 * count, address); break; @@ -1391,9 +1385,7 @@ static int cortex_m3_read_memory(struct target *target, uint32_t address, case 1: retval = mem_ap_read_buf_u8(swjdp, buffer, count, address); break; - default: - LOG_ERROR("BUG: we shouldn't get here"); - exit(-1); + } } return retval; @@ -1404,14 +1396,10 @@ static int cortex_m3_write_memory(struct target *target, uint32_t address, { struct armv7m_common *armv7m = target_to_armv7m(target); struct swjdp_common *swjdp = &armv7m->swjdp_info; - int retval; - - /* sanitize arguments */ - if (((size != 4) && (size != 2) && (size != 1)) || (count == 0) || !(buffer)) - return ERROR_INVALID_ARGUMENTS; + int retval = ERROR_INVALID_ARGUMENTS; - switch (size) - { + if (count && buffer) { + switch (size) { case 4: retval = mem_ap_write_buf_u32(swjdp, buffer, 4 * count, address); break; @@ -1421,9 +1409,7 @@ static int cortex_m3_write_memory(struct target *target, uint32_t address, case 1: retval = mem_ap_write_buf_u8(swjdp, buffer, count, address); break; - default: - LOG_ERROR("BUG: we shouldn't get here"); - exit(-1); + } } return retval; ----------------------------------------------------------------------- Summary of changes: src/target/cortex_m3.c | 34 ++++++++++------------------------ 1 files changed, 10 insertions(+), 24 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: David B. <dbr...@us...> - 2009-11-17 01:37:27
|
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 56adbaffd0a0fab320a64097cd6aa6e74473f840 (commit) via d7d857a1896005df53956565644b138a76a1f0ec (commit) via f86137066a6b42c46c457c9837a8015990bf71e6 (commit) via 7c393679c0cd8f7609a0d6b2329a1877de0f3d31 (commit) from 51862bb98c26e9b3f03d46ae0f8ceb434f0743d0 (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 56adbaffd0a0fab320a64097cd6aa6e74473f840 Author: David Brownell <dbr...@us...> Date: Mon Nov 16 16:36:21 2009 -0800 ARMv7A: use standard disassembler We no longer need v7A-specific code for this. Signed-off-by: David Brownell <dbr...@us...> diff --git a/doc/openocd.texi b/doc/openocd.texi index 092de7d..2767d78 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -5535,10 +5535,17 @@ that is not currently supported in OpenOCD.) Disassembles @var{count} instructions starting at @var{address}. If @var{count} is not specified, a single instruction is disassembled. If @option{thumb} is specified, or the low bit of the address is set, -Thumb (16-bit) instructions are used; +Thumb2 (mixed 16/32-bit) instructions are used; else ARM (32-bit) instructions are used. (Processors may also support the Jazelle state, but those instructions are not currently understood by OpenOCD.) + +Note that all Thumb instructions are Thumb2 instructions, +so older processors (without Thumb2 support) will still +see correct disassembly of Thumb code. +Also, ThumbEE opcodes are the same as Thumb2, +with a handful of exceptions. +ThumbEE disassembly currently has no explicit support. @end deffn @deffn Command {arm reg} @@ -5941,23 +5948,6 @@ Displays the number of extra tck for mem-ap memory bus access [0-255]. If @var{value} is defined, first assigns that. @end deffn -@subsection ARMv7-A specific commands -@cindex ARMv7-A - -@deffn Command {armv7a disassemble} address [count [@option{thumb}]] -@cindex disassemble -Disassembles @var{count} instructions starting at @var{address}. -If @var{count} is not specified, a single instruction is disassembled. -If @option{thumb} is specified, or the low bit of the address is set, -Thumb2 (mixed 16/32-bit) instructions are used; -else ARM (32-bit) instructions are used. -With a handful of exceptions, ThumbEE instructions are the same as Thumb2; -ThumbEE disassembly currently has no explicit support. -(Processors may also support the Jazelle state, but -those instructions are not currently understood by OpenOCD.) -@end deffn - - @subsection Cortex-M3 specific commands @cindex Cortex-M3 diff --git a/src/target/armv7a.c b/src/target/armv7a.c index 7f2c387..8b16336 100644 --- a/src/target/armv7a.c +++ b/src/target/armv7a.c @@ -274,84 +274,9 @@ COMMAND_HANDLER(handle_dap_info_command) return dap_info_command(cmd_ctx, swjdp, apsel); } -COMMAND_HANDLER(handle_armv7a_disassemble_command) -{ - struct target *target = get_current_target(cmd_ctx); - struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target); - int thumb = 0; - int count = 1; - uint32_t address; - int i; - - if (armv4_5->common_magic != ARMV4_5_COMMON_MAGIC) { - command_print(cmd_ctx, "current target isn't an ARM target"); - return ERROR_OK; - } - - /* REVISIT: eventually support ThumbEE disassembly too; - * some opcodes work differently. - */ - - switch (argc) { - case 3: - if (strcmp(args[2], "thumb") != 0) - goto usage; - thumb = 1; - /* FALL THROUGH */ - case 2: - COMMAND_PARSE_NUMBER(int, args[1], count); - /* FALL THROUGH */ - case 1: - COMMAND_PARSE_NUMBER(u32, args[0], address); - if (address & 0x01) { - if (!thumb) { - command_print(cmd_ctx, "Disassemble as Thumb"); - thumb = 1; - } - address &= ~1; - } - break; - default: -usage: - command_print(cmd_ctx, - "usage: armv7a disassemble <address> [<count> ['thumb']]"); - return ERROR_OK; - } - - for (i = 0; i < count; i++) { - struct arm_instruction cur_instruction; - int retval; - - if (thumb) { - retval = thumb2_opcode(target, address, &cur_instruction); - if (retval != ERROR_OK) - return retval; - - address += cur_instruction.instruction_size; - } else { - uint32_t opcode; - - retval = target_read_u32(target, address, &opcode); - if (retval != ERROR_OK) - return retval; - - retval = arm_evaluate_opcode(opcode, address, - &cur_instruction); - if (retval != ERROR_OK) - return retval; - - address += 4; - } - command_print(cmd_ctx, "%s", cur_instruction.text); - } - - return ERROR_OK; -} - int armv7a_register_commands(struct command_context *cmd_ctx) { struct command *arm_adi_v5_dap_cmd; - struct command *armv7a_cmd; arm_adi_v5_dap_cmd = register_command(cmd_ctx, NULL, "dap", NULL, COMMAND_ANY, @@ -377,13 +302,5 @@ int armv7a_register_commands(struct command_context *cmd_ctx) "set/get number of extra tck for mem-ap memory " "bus access [0-255]"); - armv7a_cmd = register_command(cmd_ctx, NULL, "armv7a", - NULL, COMMAND_ANY, - "ARMv7-A specific commands"); - - register_command(cmd_ctx, armv7a_cmd, "disassemble", - handle_armv7a_disassemble_command, COMMAND_EXEC, - "disassemble instructions <address> [<count> ['thumb']]"); - return ERROR_OK; } commit d7d857a1896005df53956565644b138a76a1f0ec Author: David Brownell <dbr...@us...> Date: Mon Nov 16 16:36:12 2009 -0800 ARM11: register (most) standard ARM commands Have ARM11 register the "standard" ARM commands. For now, only disassembly really works. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/arm11.c b/src/target/arm11.c index 750c1f5..4d9016f 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -2138,6 +2138,8 @@ static int arm11_register_commands(struct command_context *cmd_ctx) struct command *top_cmd, *mw_cmd; + armv4_5_register_commands(cmd_ctx); + top_cmd = register_command(cmd_ctx, NULL, "arm11", NULL, COMMAND_ANY, NULL); diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 7c4861f..b60b8b2 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -378,6 +378,12 @@ COMMAND_HANDLER(handle_armv4_5_reg_command) if (armv4_5_mode_to_number(armv4_5->core_mode)==-1) return ERROR_FAIL; + if (!armv4_5->full_context) { + command_print(cmd_ctx, "error: target doesn't support %s", + CMD_NAME); + return ERROR_FAIL; + } + for (num = 0; num <= 15; num++) { output_len = 0; @@ -522,7 +528,8 @@ int armv4_5_register_commands(struct command_context *cmd_ctx) "display/change ARM core state <arm | thumb>"); register_command(cmd_ctx, armv4_5_cmd, "disassemble", handle_armv4_5_disassemble_command, COMMAND_EXEC, - "disassemble instructions <address> [<count> ['thumb']]"); + "disassemble instructions " + "<address> [<count> ['thumb']]"); return ERROR_OK; } commit f86137066a6b42c46c457c9837a8015990bf71e6 Author: David Brownell <dbr...@us...> Date: Mon Nov 16 16:36:09 2009 -0800 ARM: "armv4_5" command prefix becomes "arm" Rename the "armv4_5" command prefix to straight "arm" so it makes more sense for newer cores. Add a simple compatibility script. Make sure all the commands give the same "not an ARM" diagnostic message (and fail properly) when called against non-ARM targets. Signed-off-by: David Brownell <dbr...@us...> diff --git a/NEWS b/NEWS index 7387d70..1a024e4 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,8 @@ JTAG Layer: Boundary Scan: Target Layer: + ARM + - renamed "armv4_5" command prefix as "arm" ARM11 - Preliminary ETM and ETB hookup - accelerated "flash erase_check" diff --git a/doc/openocd.texi b/doc/openocd.texi index 81409ac..092de7d 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -5515,16 +5515,14 @@ Reports whether the capture clock is locked or not. @end deffn -@section ARMv4 and ARMv5 Architecture -@cindex ARMv4 -@cindex ARMv5 +@section Generic ARM +@cindex ARM -These commands are specific to ARM architecture v4 and v5, -including all ARM7 or ARM9 systems and Intel XScale. +These commands should be available on all ARM processors. They are available in addition to other core-specific commands that may be available. -@deffn Command {armv4_5 core_state} [@option{arm}|@option{thumb}] +@deffn Command {arm core_state} [@option{arm}|@option{thumb}] Displays the core_state, optionally changing it to process either @option{arm} or @option{thumb} instructions. The target may later be resumed in the currently set core_state. @@ -5532,7 +5530,7 @@ The target may later be resumed in the currently set core_state. that is not currently supported in OpenOCD.) @end deffn -@deffn Command {armv4_5 disassemble} address [count [@option{thumb}]] +@deffn Command {arm disassemble} address [count [@option{thumb}]] @cindex disassemble Disassembles @var{count} instructions starting at @var{address}. If @var{count} is not specified, a single instruction is disassembled. @@ -5543,7 +5541,7 @@ else ARM (32-bit) instructions are used. those instructions are not currently understood by OpenOCD.) @end deffn -@deffn Command {armv4_5 reg} +@deffn Command {arm reg} Display a table of all banked core registers, fetching the current value from every core mode if necessary. OpenOCD versions before rev. 60 didn't fetch the current register value. diff --git a/src/helper/startup.tcl b/src/helper/startup.tcl index 73c4cf1..096f03a 100644 --- a/src/helper/startup.tcl +++ b/src/helper/startup.tcl @@ -142,6 +142,15 @@ proc ocd_gdb_restart {target_id} { reset halt } +######### + +# Temporary migration aid. May be removed starting in January 2011. +proc armv4_5 params { + echo "DEPRECATED! use 'arm $params' not 'armv4_5 $params'" + arm $params +} + +######### # This reset logic may be overridden by board/target/... scripts as needed # to provide a reset that, if possible, is close to a power-up reset. diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index e112e7b..7c4861f 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -363,10 +363,10 @@ COMMAND_HANDLER(handle_armv4_5_reg_command) struct target *target = get_current_target(cmd_ctx); struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target); - if (armv4_5->common_magic != ARMV4_5_COMMON_MAGIC) + if (!is_arm(armv4_5)) { - command_print(cmd_ctx, "current target isn't an ARMV4/5 target"); - return ERROR_OK; + command_print(cmd_ctx, "current target isn't an ARM"); + return ERROR_FAIL; } if (target->state != TARGET_HALTED) @@ -412,10 +412,10 @@ COMMAND_HANDLER(handle_armv4_5_core_state_command) struct target *target = get_current_target(cmd_ctx); struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target); - if (armv4_5->common_magic != ARMV4_5_COMMON_MAGIC) + if (!is_arm(armv4_5)) { - command_print(cmd_ctx, "current target isn't an ARMV4/5 target"); - return ERROR_OK; + command_print(cmd_ctx, "current target isn't an ARM"); + return ERROR_FAIL; } if (argc > 0) @@ -471,7 +471,7 @@ COMMAND_HANDLER(handle_armv4_5_disassemble_command) default: usage: command_print(cmd_ctx, - "usage: armv4_5 disassemble <address> [<count> ['thumb']]"); + "usage: arm disassemble <address> [<count> ['thumb']]"); count = 0; retval = ERROR_FAIL; } @@ -510,9 +510,9 @@ int armv4_5_register_commands(struct command_context *cmd_ctx) { struct command *armv4_5_cmd; - armv4_5_cmd = register_command(cmd_ctx, NULL, "armv4_5", + armv4_5_cmd = register_command(cmd_ctx, NULL, "arm", NULL, COMMAND_ANY, - "armv4/5 specific commands"); + "generic ARM commands"); register_command(cmd_ctx, armv4_5_cmd, "reg", handle_armv4_5_reg_command, COMMAND_EXEC, diff --git a/tcl/board/mini2440.cfg b/tcl/board/mini2440.cfg index d17b107..0f7ebf8 100644 --- a/tcl/board/mini2440.cfg +++ b/tcl/board/mini2440.cfg @@ -292,7 +292,7 @@ proc load_uboot { } { proc s {} { step reg - armv4_5 disassemble 0x33F80068 0x10 + arm disassemble 0x33F80068 0x10 } proc help_2440 {} { diff --git a/tcl/target/lpc1768.cfg b/tcl/target/lpc1768.cfg index 9f6bcff..0b07d51 100644 --- a/tcl/target/lpc1768.cfg +++ b/tcl/target/lpc1768.cfg @@ -35,7 +35,7 @@ $_TARGETNAME configure -work-area-phys 0x10000000 -work-area-size 0x8000 -work-a $_TARGETNAME configure -event reset-init { # Force target into ARM state - armv4_5 core_state arm + arm core_state arm #do not remap 0x0000-0x0020 to anything but the flash # mwb 0xE01FC040 0x01 mwb 0xE000ED08 0x00 diff --git a/tcl/target/lpc2148.cfg b/tcl/target/lpc2148.cfg index ce672c8..1f833e7 100644 --- a/tcl/target/lpc2148.cfg +++ b/tcl/target/lpc2148.cfg @@ -39,7 +39,7 @@ $_TARGETNAME configure -work-area-phys 0x40000000 -work-area-size 0x4000 -work-a $_TARGETNAME configure -event reset-init { # Force target into ARM state - armv4_5 core_state arm + arm core_state arm # Do not remap 0x0000-0x0020 to anything but the flash (i.e. select # "User Flash Mode" where interrupt vectors are _not_ remapped, diff --git a/tcl/target/lpc2378.cfg b/tcl/target/lpc2378.cfg index 7f716f3..aa3fad2 100644 --- a/tcl/target/lpc2378.cfg +++ b/tcl/target/lpc2378.cfg @@ -35,7 +35,7 @@ $_TARGETNAME configure -work-area-phys 0x40000000 -work-area-size 0x8000 -work-a $_TARGETNAME configure -event reset-init { # Force target into ARM state - armv4_5 core_state arm + arm core_state arm #do not remap 0x0000-0x0020 to anything but the flash mwb 0xE01FC040 0x01 } diff --git a/tcl/target/lpc2478.cfg b/tcl/target/lpc2478.cfg index e78afa1..b0af4c0 100644 --- a/tcl/target/lpc2478.cfg +++ b/tcl/target/lpc2478.cfg @@ -35,7 +35,7 @@ $_TARGETNAME configure -work-area-phys 0x40000000 -work-area-size 0x10000 -work- $_TARGETNAME configure -event reset-init { # Force target into ARM state - armv4_5 core_state arm + arm core_state arm # Do not remap 0x0000-0x0020 to anything but the Flash mwb 0xE01FC040 0x01 } commit 7c393679c0cd8f7609a0d6b2329a1877de0f3d31 Author: David Brownell <dbr...@us...> Date: Mon Nov 16 16:36:03 2009 -0800 JTAG: fix autoprobe failure. Fix bug noted by Ãyvind: terminate the IR length autoscan when the IR is too long, or otherwise broken. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/jtag/core.c b/src/jtag/core.c index da745d0..211b9d5 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -1224,7 +1224,14 @@ static int jtag_validate_ircapture(void) /* If we're autoprobing, guess IR lengths. They must be at * least two bits. Guessing will fail if (a) any TAP does * not conform to the JTAG spec; or (b) when the upper bits - * captured from some conforming TAP are nonzero. + * captured from some conforming TAP are nonzero. Or if + * (c) an IR length is longer than 32 bits -- which is only + * an implementation limit, which could someday be raised. + * + * REVISIT optimization: if there's a *single* TAP we can + * lift restrictions (a) and (b) by scanning a recognizable + * pattern before the all-ones BYPASS. Check for where the + * pattern starts in the result, instead of an 0...01 value. * * REVISIT alternative approach: escape to some tcl code * which could provide more knowledge, based on IDCODE; and @@ -1233,7 +1240,8 @@ static int jtag_validate_ircapture(void) if (tap->ir_length == 0) { tap->ir_length = 2; while ((val = buf_get_u32(ir_test, chain_pos, - tap->ir_length + 1)) == 1) { + tap->ir_length + 1)) == 1 + && tap->ir_length <= 32) { tap->ir_length++; } LOG_WARNING("AUTO %s - use \"... -irlen %d\"", ----------------------------------------------------------------------- Summary of changes: NEWS | 2 + doc/openocd.texi | 40 ++++++++--------------- src/helper/startup.tcl | 9 +++++ src/jtag/core.c | 12 ++++++- src/target/arm11.c | 2 + src/target/armv4_5.c | 27 ++++++++++------ src/target/armv7a.c | 83 ------------------------------------------------ tcl/board/mini2440.cfg | 2 +- tcl/target/lpc1768.cfg | 2 +- tcl/target/lpc2148.cfg | 2 +- tcl/target/lpc2378.cfg | 2 +- tcl/target/lpc2478.cfg | 2 +- 12 files changed, 59 insertions(+), 126 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Zach W. <zw...@us...> - 2009-11-17 00:54:38
|
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 51862bb98c26e9b3f03d46ae0f8ceb434f0743d0 (commit) via 69df712d1d06b2c698bed3de086b9f734de73b7e (commit) via 9763aef76a42fdaedcec9825fdf502f8cb7dd628 (commit) via df9b12695f4ede8144491d257ea236cdbca0a15c (commit) via 0a9daddc2e20d9ff5053a9faf3e1ec11fd600c73 (commit) via ccf59123b72b01149063d5864ef61077786c033e (commit) from 91ac164d95e1101120b938c684b78934d23dd51c (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 51862bb98c26e9b3f03d46ae0f8ceb434f0743d0 Author: Zachary T Welch <zw...@su...> Date: Fri Nov 13 14:44:53 2009 -0800 fileio: improve API types Use size_t instead of uint32_t when specifying file sizes. Update all consumers up through the layers to use size_t when required. These changes should be safe, but the higher-levels will need to be updated further to receive the intended benefits (i.e. large file support). Add error checking for fileio_read and file_write. Previously, all errors were being silently ignored, so this change might cause some problems for some people in some cases. However, it gives us the chance to handle any errors that do occur at higher-levels, rather than burying our heads in the sand. diff --git a/src/flash/ecos.c b/src/flash/ecos.c index c12ed9d..b2ffadf 100644 --- a/src/flash/ecos.c +++ b/src/flash/ecos.c @@ -152,8 +152,8 @@ FLASH_BANK_COMMAND_HANDLER(ecosflash_flash_bank_command) static int loadDriver(struct ecosflash_flash_bank *info) { - uint32_t buf_cnt; - uint32_t image_size; + size_t buf_cnt; + size_t image_size; struct image image; image.base_address_set = 0; @@ -182,7 +182,8 @@ static int loadDriver(struct ecosflash_flash_bank *info) } target_write_buffer(target, image.sections[i].base_address, buf_cnt, buffer); image_size += buf_cnt; - LOG_DEBUG("%" PRIu32 " byte written at address 0x%8.8" PRIx32 "", buf_cnt, image.sections[i].base_address); + LOG_DEBUG("%zu bytes written at address 0x%8.8" PRIx32 "", + buf_cnt, image.sections[i].base_address); free(buffer); } diff --git a/src/flash/flash.c b/src/flash/flash.c index 03d4547..adc1411 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -811,7 +811,6 @@ COMMAND_HANDLER(handle_flash_write_bank_command) { uint32_t offset; uint8_t *buffer; - uint32_t buf_cnt; struct fileio fileio; if (argc != 3) @@ -833,6 +832,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command) } buffer = malloc(fileio.size); + size_t buf_cnt; if (fileio_read(&fileio, fileio.size, buffer, &buf_cnt) != ERROR_OK) { free(buffer); @@ -1059,7 +1059,7 @@ static int flash_write_unlock(struct target *target, struct image *image, uint32 /* read sections to the buffer */ while (buffer_size < run_size) { - uint32_t size_read; + size_t size_read; size_read = run_size - buffer_size; if (size_read > image->sections[section].size - section_offset) diff --git a/src/flash/lpc2900.c b/src/flash/lpc2900.c index b80079d..dc91668 100644 --- a/src/flash/lpc2900.c +++ b/src/flash/lpc2900.c @@ -631,7 +631,7 @@ COMMAND_HANDLER(lpc2900_handle_read_custom_command) return ret; } - uint32_t nwritten; + size_t nwritten; ret = fileio_write( &fileio, sizeof(customer), (const uint8_t *)customer, &nwritten ); if( ret != ERROR_OK ) @@ -755,7 +755,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command) /* Page 4 */ uint32_t offset = ISS_CUSTOMER_START1 % FLASH_PAGE_SIZE; memset( page, 0xff, FLASH_PAGE_SIZE ); - uint32_t size_read; + size_t size_read; retval = image_read_section( &image, 0, 0, ISS_CUSTOMER_SIZE1, &page[offset], &size_read); if( retval != ERROR_OK ) diff --git a/src/flash/mflash.c b/src/flash/mflash.c index 4356f27..0620642 100644 --- a/src/flash/mflash.c +++ b/src/flash/mflash.c @@ -705,7 +705,7 @@ static int mg_mflash_write(uint32_t addr, uint8_t *buff, uint32_t len) COMMAND_HANDLER(mg_write_cmd) { - uint32_t address, buf_cnt, cnt, res, i; + uint32_t address, cnt, res, i; uint8_t *buffer; struct fileio fileio; int ret; @@ -732,6 +732,7 @@ COMMAND_HANDLER(mg_write_cmd) struct duration bench; duration_start(&bench); + size_t buf_cnt; for (i = 0; i < cnt; i++) { if ((ret = fileio_read(&fileio, MG_FILEIO_CHUNK, buffer, &buf_cnt)) != ERROR_OK) @@ -769,7 +770,7 @@ mg_write_cmd_err: COMMAND_HANDLER(mg_dump_cmd) { - uint32_t address, size_written, size, cnt, res, i; + uint32_t address, size, cnt, res, i; uint8_t *buffer; struct fileio fileio; int ret; @@ -797,6 +798,7 @@ COMMAND_HANDLER(mg_dump_cmd) struct duration bench; duration_start(&bench); + size_t size_written; for (i = 0; i < cnt; i++) { if ((ret = mg_mflash_read(address, buffer, MG_FILEIO_CHUNK)) != ERROR_OK) goto mg_dump_cmd_err; diff --git a/src/flash/nand.c b/src/flash/nand.c index 9d997fa..71a67c4 100644 --- a/src/flash/nand.c +++ b/src/flash/nand.c @@ -1453,8 +1453,8 @@ static COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state, static int nand_fileio_read(struct nand_device *nand, struct nand_fileio_state *s) { - uint32_t total_read = 0; - uint32_t one_read; + size_t total_read = 0; + size_t one_read; if (NULL != s->page) { @@ -1616,7 +1616,7 @@ COMMAND_HANDLER(handle_nand_dump_command) while (s.size > 0) { - uint32_t size_written; + size_t size_written; int retval = nand_read_page(nand, s.address / nand->page_size, s.page, s.page_size, s.oob, s.oob_size); if (ERROR_OK != retval) diff --git a/src/helper/fileio.c b/src/helper/fileio.c index 84d46bd..8f2ce22 100644 --- a/src/helper/fileio.c +++ b/src/helper/fileio.c @@ -143,7 +143,7 @@ int fileio_close(struct fileio *fileio) return retval; } -int fileio_seek(struct fileio *fileio, uint32_t position) +int fileio_seek(struct fileio *fileio, size_t position) { int retval; if ((retval = fseek(fileio->file, position, SEEK_SET)) != 0) @@ -155,14 +155,16 @@ int fileio_seek(struct fileio *fileio, uint32_t position) return ERROR_OK; } -static inline int fileio_local_read(struct fileio *fileio, uint32_t size, uint8_t *buffer, uint32_t *size_read) +static int fileio_local_read(struct fileio *fileio, + size_t size, void *buffer, size_t *size_read) { - *size_read = fread(buffer, 1, size, fileio->file); - - return ERROR_OK; + ssize_t retval = fread(buffer, 1, size, fileio->file); + *size_read = (retval >= 0) ? retval : 0; + return (retval < 0) ? retval : ERROR_OK; } -int fileio_read(struct fileio *fileio, uint32_t size, uint8_t *buffer, uint32_t *size_read) +int fileio_read(struct fileio *fileio, size_t size, void *buffer, + size_t *size_read) { return fileio_local_read(fileio, size, buffer, size_read); } @@ -170,17 +172,17 @@ int fileio_read(struct fileio *fileio, uint32_t size, uint8_t *buffer, uint32_t int fileio_read_u32(struct fileio *fileio, uint32_t *data) { uint8_t buf[4]; - uint32_t size_read; - int retval; - - if ((retval = fileio_local_read(fileio, 4, buf, &size_read)) != ERROR_OK) - return retval; - *data = be_to_h_u32(buf); - - return ERROR_OK; + size_t size_read; + int retval = fileio_local_read(fileio, sizeof(uint32_t), buf, &size_read); + if (ERROR_OK == retval && sizeof(uint32_t) != size_read) + retval = -EIO; + if (ERROR_OK == retval) + *data = be_to_h_u32(buf); + return retval; } -static inline int fileio_local_fgets(struct fileio *fileio, uint32_t size, char *buffer) +static int fileio_local_fgets(struct fileio *fileio, + size_t size, void *buffer) { if (fgets(buffer, size, fileio->file) == NULL) return ERROR_FILEIO_OPERATION_FAILED; @@ -188,40 +190,37 @@ static inline int fileio_local_fgets(struct fileio *fileio, uint32_t size, char return ERROR_OK; } -int fileio_fgets(struct fileio *fileio, uint32_t size, char *buffer) +int fileio_fgets(struct fileio *fileio, size_t size, void *buffer) { return fileio_local_fgets(fileio, size, buffer); } -static inline int fileio_local_write(struct fileio *fileio, uint32_t size, const uint8_t *buffer, uint32_t *size_written) +static int fileio_local_write(struct fileio *fileio, + size_t size, const void *buffer, size_t *size_written) { - *size_written = fwrite(buffer, 1, size, fileio->file); - - return ERROR_OK; + ssize_t retval = fwrite(buffer, 1, size, fileio->file); + *size_written = (retval >= 0) ? retval : 0; + return (retval < 0) ? retval : ERROR_OK; } -int fileio_write(struct fileio *fileio, uint32_t size, const uint8_t *buffer, uint32_t *size_written) +int fileio_write(struct fileio *fileio, + size_t size, const void *buffer, size_t *size_written) { - int retval; - - retval = fileio_local_write(fileio, size, buffer, size_written); - + int retval = fileio_local_write(fileio, size, buffer, size_written); if (retval == ERROR_OK) fileio->size += *size_written; - - return retval;; + return retval; } int fileio_write_u32(struct fileio *fileio, uint32_t data) { uint8_t buf[4]; - uint32_t size_written; - int retval; - h_u32_to_be(buf, data); - if ((retval = fileio_local_write(fileio, 4, buf, &size_written)) != ERROR_OK) - return retval; + size_t size_written; + int retval = fileio_write(fileio, 4, buf, &size_written); + if (ERROR_OK == retval && size_written != sizeof(uint32_t)) + retval = -EIO; - return ERROR_OK; + return retval; } diff --git a/src/helper/fileio.h b/src/helper/fileio.h index 6ed6fe4..325b441 100644 --- a/src/helper/fileio.h +++ b/src/helper/fileio.h @@ -58,13 +58,13 @@ int fileio_open(struct fileio *fileio, const char *url, enum fileio_access access, enum fileio_type type); int fileio_close(struct fileio *fileio); -int fileio_seek(struct fileio *fileio, uint32_t position); -int fileio_fgets(struct fileio *fileio, uint32_t size, char *buffer); +int fileio_seek(struct fileio *fileio, size_t position); +int fileio_fgets(struct fileio *fileio, size_t size, void *buffer); int fileio_read(struct fileio *fileio, - uint32_t size, uint8_t *buffer, uint32_t *size_read); + size_t size, void *buffer, size_t *size_read); int fileio_write(struct fileio *fileio, - uint32_t size, const uint8_t *buffer, uint32_t *size_written); + size_t size, const void *buffer, size_t *size_written); int fileio_read_u32(struct fileio *fileio, uint32_t *data); int fileio_write_u32(struct fileio *fileio, uint32_t data); diff --git a/src/target/etm.c b/src/target/etm.c index 5a0ffed..fa7a71b 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -640,7 +640,7 @@ static int etm_read_instruction(struct etm_context *ctx, struct arm_instruction { int i; int section = -1; - uint32_t size_read; + size_t size_read; uint32_t opcode; int retval; diff --git a/src/target/image.c b/src/target/image.c index bba4675..8774c25 100644 --- a/src/target/image.c +++ b/src/target/image.c @@ -48,7 +48,7 @@ static int autodetect_image_type(struct image *image, const char *url) { int retval; struct fileio fileio; - uint32_t read_bytes; + size_t read_bytes; uint8_t buffer[9]; /* read the first 4 bytes of image */ @@ -175,7 +175,7 @@ static int image_ihex_buffer_complete(struct image *image) uint32_t record_type; uint32_t checksum; uint8_t cal_checksum = 0; - uint32_t bytes_read = 0; + size_t bytes_read = 0; if (sscanf(&lpszLine[bytes_read], ":%2" SCNx32 "%4" SCNx32 "%2" SCNx32 , &count, &address, &record_type) != 3) { @@ -360,7 +360,7 @@ static int image_ihex_buffer_complete(struct image *image) static int image_elf_read_headers(struct image *image) { struct image_elf *elf = image->type_private; - uint32_t read_bytes; + size_t read_bytes; uint32_t i,j; int retval; @@ -458,11 +458,11 @@ static int image_elf_read_headers(struct image *image) return ERROR_OK; } -static int image_elf_read_section(struct image *image, int section, uint32_t offset, uint32_t size, uint8_t *buffer, uint32_t *size_read) +static int image_elf_read_section(struct image *image, int section, uint32_t offset, uint32_t size, uint8_t *buffer, size_t *size_read) { struct image_elf *elf = image->type_private; Elf32_Phdr *segment = (Elf32_Phdr *)image->sections[section].private; - uint32_t read_size,really_read; + size_t read_size,really_read; int retval; *size_read = 0; @@ -474,7 +474,7 @@ static int image_elf_read_section(struct image *image, int section, uint32_t off { /* maximal size present in file for the current segment */ read_size = MIN(size, field32(elf,segment->p_filesz)-offset); - LOG_DEBUG("read elf: size = 0x%" PRIx32 " at 0x%" PRIx32 "",read_size, + LOG_DEBUG("read elf: size = 0x%zu at 0x%" PRIx32 "", read_size, field32(elf,segment->p_offset) + offset); /* read initialized area of the segment */ if ((retval = fileio_seek(&elf->fileio, field32(elf,segment->p_offset) + offset)) != ERROR_OK) @@ -797,7 +797,7 @@ int image_open(struct image *image, const char *url, const char *type_string) return retval; }; -int image_read_section(struct image *image, int section, uint32_t offset, uint32_t size, uint8_t *buffer, uint32_t *size_read) +int image_read_section(struct image *image, int section, uint32_t offset, uint32_t size, uint8_t *buffer, size_t *size_read) { int retval; diff --git a/src/target/image.h b/src/target/image.h index 06d47bf..0dac5ba 100644 --- a/src/target/image.h +++ b/src/target/image.h @@ -102,7 +102,7 @@ struct image_mot int image_open(struct image *image, const char *url, const char *type_string); int image_read_section(struct image *image, int section, uint32_t offset, - uint32_t size, uint8_t *buffer, uint32_t *size_read); + uint32_t size, uint8_t *buffer, size_t *size_read); void image_close(struct image *image); int image_add_section(struct image *image, uint32_t base, uint32_t size, diff --git a/src/target/target.c b/src/target/target.c index f141e93..c00c2ed 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2399,7 +2399,7 @@ static COMMAND_HELPER(parse_load_image_command_args, struct image *image, COMMAND_HANDLER(handle_load_image_command) { uint8_t *buffer; - uint32_t buf_cnt; + size_t buf_cnt; uint32_t image_size; uint32_t min_address = 0; uint32_t max_address = 0xffffffff; @@ -2519,7 +2519,7 @@ COMMAND_HANDLER(handle_dump_image_command) int retval = ERROR_OK; while (size > 0) { - uint32_t size_written; + size_t size_written; uint32_t this_run_size = (size > 560) ? 560 : size; retval = target_read_buffer(target, address, this_run_size, buffer); if (retval != ERROR_OK) @@ -2553,7 +2553,7 @@ COMMAND_HANDLER(handle_dump_image_command) static COMMAND_HELPER(handle_verify_image_command_internal, int verify) { uint8_t *buffer; - uint32_t buf_cnt; + size_t buf_cnt; uint32_t image_size; int i; int retval; @@ -2674,7 +2674,7 @@ static COMMAND_HELPER(handle_verify_image_command_internal, int verify) } } else { - command_print(cmd_ctx, "address 0x%08" PRIx32 " length 0x%08" PRIx32 "", + command_print(cmd_ctx, "address 0x%08" PRIx32 " length 0x%08zx", image.sections[i].base_address, buf_cnt); } @@ -4537,7 +4537,7 @@ static void free_fastload(void) COMMAND_HANDLER(handle_fast_load_image_command) { uint8_t *buffer; - uint32_t buf_cnt; + size_t buf_cnt; uint32_t image_size; uint32_t min_address = 0; uint32_t max_address = 0xffffffff; diff --git a/src/target/xscale.c b/src/target/xscale.c index 30ca3bf..9e93c02 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -2557,7 +2557,7 @@ static int xscale_read_instruction(struct target *target, struct xscale_common *xscale = target_to_xscale(target); int i; int section = -1; - uint32_t size_read; + size_t size_read; uint32_t opcode; int retval; commit 69df712d1d06b2c698bed3de086b9f734de73b7e Author: Zachary T Welch <zw...@su...> Date: Fri Nov 13 14:22:21 2009 -0800 struct fileio: improve member types Add const keyword to file url and cast to free(). Make size an ssize_t and chase all format strings that use it. diff --git a/src/flash/flash.c b/src/flash/flash.c index bdee53b..03d4547 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -847,7 +847,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command) if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { - command_print(cmd_ctx, "wrote %lld byte from file %s to flash bank %u" + command_print(cmd_ctx, "wrote %zu byte from file %s to flash bank %u" " at offset 0x%8.8" PRIx32 " in %fs (%0.3f kb/s)", fileio.size, args[1], p->bank_number, offset, duration_elapsed(&bench), duration_kbps(&bench, fileio.size)); diff --git a/src/flash/mflash.c b/src/flash/mflash.c index 49dc432..4356f27 100644 --- a/src/flash/mflash.c +++ b/src/flash/mflash.c @@ -750,7 +750,7 @@ COMMAND_HANDLER(mg_write_cmd) if (duration_measure(&bench) == ERROR_OK) { - command_print(cmd_ctx, "wrote %lli byte from file %s " + command_print(cmd_ctx, "wrote %zu byte from file %s " "in %fs (%0.3f kB/s)", fileio.size, args[1], duration_elapsed(&bench), duration_kbps(&bench, fileio.size)); } diff --git a/src/flash/nand.c b/src/flash/nand.c index fba8104..9d997fa 100644 --- a/src/flash/nand.c +++ b/src/flash/nand.c @@ -1637,7 +1637,7 @@ COMMAND_HANDLER(handle_nand_dump_command) if (nand_fileio_finish(&s) == ERROR_OK) { - command_print(cmd_ctx, "dumped %lld byte in %fs (%0.3f kb/s)", + command_print(cmd_ctx, "dumped %zu bytes in %fs (%0.3f kb/s)", s.fileio.size, duration_elapsed(&s.bench), duration_kbps(&s.bench, s.fileio.size)); } diff --git a/src/helper/fileio.c b/src/helper/fileio.c index 71cae75..84d46bd 100644 --- a/src/helper/fileio.c +++ b/src/helper/fileio.c @@ -137,7 +137,7 @@ int fileio_close(struct fileio *fileio) retval = fileio_close_local(fileio); - free(fileio->url); + free((void*)fileio->url); fileio->url = NULL; return retval; diff --git a/src/helper/fileio.h b/src/helper/fileio.h index 8cba926..6ed6fe4 100644 --- a/src/helper/fileio.h +++ b/src/helper/fileio.h @@ -47,8 +47,8 @@ enum fileio_access }; struct fileio { - char *url; - long long size; + const char *url; + ssize_t size; enum fileio_type type; enum fileio_access access; FILE *file; diff --git a/src/target/target.c b/src/target/target.c index c24085f..f141e93 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -2543,7 +2543,7 @@ COMMAND_HANDLER(handle_dump_image_command) if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { command_print(cmd_ctx, - "dumped %lld bytes in %fs (%0.3f kb/s)", fileio.size, + "dumped %zu bytes in %fs (%0.3f kb/s)", fileio.size, duration_elapsed(&bench), duration_kbps(&bench, fileio.size)); } commit 9763aef76a42fdaedcec9825fdf502f8cb7dd628 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 15 03:42:45 2009 -0800 helper/log: improve API parameter types Uses unsigned type to pass line numbers. Use uint64_t to pass sleep routines their milliseconds. Updates sleep routines to use this type and improve whitespace. diff --git a/src/helper/log.c b/src/helper/log.c index 5a65c87..9396ffe 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -77,7 +77,7 @@ struct store_log_forward }; /* either forward the log to the listeners or store it for possible forwarding later */ -static void log_forward(const char *file, int line, const char *function, const char *string) +static void log_forward(const char *file, unsigned line, const char *function, const char *string) { if (log_forward_count==0) { @@ -224,7 +224,7 @@ static void log_puts(enum log_levels level, const char *file, int line, const ch } -void log_printf(enum log_levels level, const char *file, int line, const char *function, const char *format, ...) +void log_printf(enum log_levels level, const char *file, unsigned line, const char *function, const char *format, ...) { char *string; va_list ap; @@ -245,7 +245,7 @@ void log_printf(enum log_levels level, const char *file, int line, const char *f va_end(ap); } -void log_printf_lf(enum log_levels level, const char *file, int line, const char *function, const char *format, ...) +void log_printf_lf(enum log_levels level, const char *file, unsigned line, const char *function, const char *format, ...) { char *string; va_list ap; @@ -504,27 +504,24 @@ void kept_alive() } /* if we sleep for extended periods of time, we must invoke keep_alive() intermittantly */ -void alive_sleep(int ms) +void alive_sleep(uint64_t ms) { - int i; - int napTime = 10; - for (i = 0; i < ms; i += napTime) + uint64_t napTime = 10; + for (uint64_t i = 0; i < ms; i += napTime) { - int sleep_a_bit = ms-i; + uint64_t sleep_a_bit = ms - i; if (sleep_a_bit > napTime) - { sleep_a_bit = napTime; - } - usleep(sleep_a_bit*1000); + + usleep(sleep_a_bit * 1000); keep_alive(); } } -void busy_sleep(int ms) +void busy_sleep(uint64_t ms) { - long long then; - then = timeval_ms(); - while ((timeval_ms()-then) < ms) + uint64_t then = timeval_ms(); + while (timeval_ms() - then < ms) { /* busy wait */ } diff --git a/src/helper/log.h b/src/helper/log.h index 3bf9840..6f7c24a 100644 --- a/src/helper/log.h +++ b/src/helper/log.h @@ -59,10 +59,10 @@ enum log_levels LOG_LVL_DEBUG = 3 }; -void log_printf(enum log_levels level, const char *file, int line, +void log_printf(enum log_levels level, const char *file, unsigned line, const char *function, const char *format, ...) __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6))); -void log_printf_lf(enum log_levels level, const char *file, int line, +void log_printf_lf(enum log_levels level, const char *file, unsigned line, const char *function, const char *format, ...) __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 5, 6))); @@ -74,8 +74,8 @@ int log_register_commands(struct command_context *cmd_ctx); void keep_alive(void); void kept_alive(void); -void alive_sleep(int ms); -void busy_sleep(int ms); +void alive_sleep(uint64_t ms); +void busy_sleep(uint64_t ms); /* log entries can be paused and replayed roughly according to the try/catch/rethrow * concepts in C++ commit df9b12695f4ede8144491d257ea236cdbca0a15c Author: Zachary T Welch <zw...@su...> Date: Sun Nov 15 04:05:33 2009 -0800 use Jim_CmdProc in jim_register The jim_register command just needed to use the type defined by jim.h. diff --git a/src/helper/command.c b/src/helper/command.c index 41af035..7edd585 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -869,7 +869,8 @@ void process_jim_events(void) #endif } -void register_jim(struct command_context *cmd_ctx, const char *name, int (*cmd)(Jim_Interp *interp, int argc, Jim_Obj *const *argv), const char *help) +void register_jim(struct command_context *cmd_ctx, const char *name, + Jim_CmdProc cmd, const char *help) { Jim_CreateCommand(interp, name, cmd, NULL, NULL); diff --git a/src/helper/command.h b/src/helper/command.h index 94d9816..79e57f5 100644 --- a/src/helper/command.h +++ b/src/helper/command.h @@ -190,7 +190,8 @@ extern int fast_and_dangerous; extern Jim_Interp *interp; -void register_jim(struct command_context *context, const char *name, int (*cmd)(Jim_Interp *interp, int argc, Jim_Obj *const *argv), const char *help); +void register_jim(struct command_context *context, const char *name, + Jim_CmdProc cmd, const char *help); long jim_global_long(const char *variable); commit 0a9daddc2e20d9ff5053a9faf3e1ec11fd600c73 Author: Zachary T Welch <zw...@su...> Date: Fri Nov 13 14:21:56 2009 -0800 improve constness of open_file_from_path diff --git a/src/helper/configuration.c b/src/helper/configuration.c index 1f7240d..74bcc9b 100644 --- a/src/helper/configuration.c +++ b/src/helper/configuration.c @@ -86,7 +86,7 @@ char *find_file(const char *file) return NULL; } -FILE *open_file_from_path (char *file, char *mode) +FILE *open_file_from_path(const char *file, const char *mode) { if (mode[0]!='r') { diff --git a/src/helper/configuration.h b/src/helper/configuration.h index 9b77a25..ce9159c 100644 --- a/src/helper/configuration.h +++ b/src/helper/configuration.h @@ -36,7 +36,7 @@ void add_script_search_dir(const char *dir); int configuration_output_handler(struct command_context *cmd_ctx, const char *line); -FILE *open_file_from_path(char *file, char *mode); +FILE *open_file_from_path(const char *file, const char *mode); char *find_file(const char *name); commit ccf59123b72b01149063d5864ef61077786c033e Author: Zachary T Welch <zw...@su...> Date: Sun Nov 15 03:53:19 2009 -0800 make command line options const The getopt_long call allows a const struct option, so mark ours const too. diff --git a/src/helper/options.c b/src/helper/options.c index e26782f..874196e 100644 --- a/src/helper/options.c +++ b/src/helper/options.c @@ -32,7 +32,7 @@ static int help_flag, version_flag; -static struct option long_options[] = +static const struct option long_options[] = { {"help", no_argument, &help_flag, 1}, {"version", no_argument, &version_flag, 1}, ----------------------------------------------------------------------- Summary of changes: src/flash/ecos.c | 7 ++-- src/flash/flash.c | 6 ++-- src/flash/lpc2900.c | 4 +- src/flash/mflash.c | 8 +++-- src/flash/nand.c | 8 ++-- src/helper/command.c | 3 +- src/helper/command.h | 3 +- src/helper/configuration.c | 2 +- src/helper/configuration.h | 2 +- src/helper/fileio.c | 67 +++++++++++++++++++++---------------------- src/helper/fileio.h | 12 ++++---- src/helper/log.c | 27 ++++++++---------- src/helper/log.h | 8 ++-- src/helper/options.c | 2 +- src/target/etm.c | 2 +- src/target/image.c | 14 ++++---- src/target/image.h | 2 +- src/target/target.c | 12 ++++---- src/target/xscale.c | 2 +- 19 files changed, 96 insertions(+), 95 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: David B. <dbr...@us...> - 2009-11-17 00:30:26
|
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 91ac164d95e1101120b938c684b78934d23dd51c (commit) via bf972374011359a1d160b0359e59c4350e78aefe (commit) via 2fb58116a58f7928af75839e65c07f7d55c81500 (commit) via a7c04a0e49bf436e7930d798732c0827c38135b8 (commit) from b6e0f2e1c32930b10403d26d39e71225573bcba9 (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 91ac164d95e1101120b938c684b78934d23dd51c Author: David Brownell <dbr...@us...> Date: Mon Nov 16 15:29:14 2009 -0800 ARM: standard disassembler uses Thumb2 entry Tweak "standard" ARM disassembler diagnostics to fail if the target is not "an ARM" (vs. not "an ARMV4/5"), so it makes more sense for cores inheriting this as the "generic" disassembler. Also, to use the Thumb2 entry instead of the original Thumb entry. This makes it work better for both newer cores (which support those added instructions) and for BL and BLX instructions on older cores. (Those instructions are 32-bits, which requires curious state-aware code to go through a 16-bit decode interface...) Plus minor cleanups, notably to have fewer exit paths and to make sure they all return failure codes. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/arm_disassembler.c b/src/target/arm_disassembler.c index 35c3520..b93df64 100644 --- a/src/target/arm_disassembler.c +++ b/src/target/arm_disassembler.c @@ -1784,8 +1784,12 @@ static int evaluate_b_bl_blx_thumb(uint16_t opcode, } /* TODO: deal correctly with dual opcode (prefixed) BL/BLX; - * these are effectively 32-bit instructions even in Thumb1. - * Might be simplest to always use the Thumb2 decoder. + * these are effectively 32-bit instructions even in Thumb1. For + * disassembly, it's simplest to always use the Thumb2 decoder. + * + * But some cores will evidently handle them as two instructions, + * where exceptions may occur between the two. The ETMv3.2+ ID + * register has a bit which exposes this behavior. */ snprintf(instruction->text, 128, diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 334f834..e112e7b 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -439,19 +439,14 @@ COMMAND_HANDLER(handle_armv4_5_disassemble_command) { int retval = ERROR_OK; struct target *target = get_current_target(cmd_ctx); - struct armv4_5_common_s *armv4_5 = target_to_armv4_5(target); + struct arm *arm = target ? target_to_arm(target) : NULL; uint32_t address; int count = 1; - int i; - struct arm_instruction cur_instruction; - uint32_t opcode; - uint16_t thumb_opcode; int thumb = 0; - if (armv4_5->common_magic != ARMV4_5_COMMON_MAGIC) - { - command_print(cmd_ctx, "current target isn't an ARMV4/5 target"); - return ERROR_OK; + if (!is_arm(arm)) { + command_print(cmd_ctx, "current target isn't an ARM"); + return ERROR_FAIL; } switch (argc) { @@ -477,37 +472,38 @@ COMMAND_HANDLER(handle_armv4_5_disassemble_command) usage: command_print(cmd_ctx, "usage: armv4_5 disassemble <address> [<count> ['thumb']]"); - return ERROR_OK; - } - - for (i = 0; i < count; i++) - { - if (thumb) - { - if ((retval = target_read_u16(target, address, &thumb_opcode)) != ERROR_OK) - { - return retval; - } - if ((retval = thumb_evaluate_opcode(thumb_opcode, address, &cur_instruction)) != ERROR_OK) - { - return retval; - } - } - else { - if ((retval = target_read_u32(target, address, &opcode)) != ERROR_OK) - { - return retval; - } - if ((retval = arm_evaluate_opcode(opcode, address, &cur_instruction)) != ERROR_OK) - { - return retval; - } + count = 0; + retval = ERROR_FAIL; + } + + while (count-- > 0) { + struct arm_instruction cur_instruction; + + if (thumb) { + /* Always use Thumb2 disassembly for best handling + * of 32-bit BL/BLX, and to work with newer cores + * (some ARMv6, all ARMv7) that use Thumb2. + */ + retval = thumb2_opcode(target, address, + &cur_instruction); + if (retval != ERROR_OK) + break; + } else { + uint32_t opcode; + + retval = target_read_u32(target, address, &opcode); + if (retval != ERROR_OK) + break; + retval = arm_evaluate_opcode(opcode, address, + &cur_instruction) != ERROR_OK; + if (retval != ERROR_OK) + break; } command_print(cmd_ctx, "%s", cur_instruction.text); - address += (thumb) ? 2 : 4; + address += cur_instruction.instruction_size; } - return ERROR_OK; + return retval; } int armv4_5_register_commands(struct command_context *cmd_ctx) commit bf972374011359a1d160b0359e59c4350e78aefe Author: David Brownell <dbr...@us...> Date: Mon Nov 16 15:27:40 2009 -0800 target: don't include "log.h" from "armv4_5.h" No point in multiple includes, and that file doesn't use its functions any more. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/arm_simulator.c b/src/target/arm_simulator.c index a353c13..31163b4 100644 --- a/src/target/arm_simulator.c +++ b/src/target/arm_simulator.c @@ -29,6 +29,7 @@ #include "arm_simulator.h" #include "binarybuffer.h" #include "register.h" +#include "log.h" static uint32_t arm_shift(uint8_t shift, uint32_t Rm, diff --git a/src/target/armv4_5.h b/src/target/armv4_5.h index 1e3ee42..5fef094 100644 --- a/src/target/armv4_5.h +++ b/src/target/armv4_5.h @@ -27,7 +27,6 @@ #define ARMV4_5_H #include "target.h" -#include "log.h" typedef enum armv4_5_mode { commit 2fb58116a58f7928af75839e65c07f7d55c81500 Author: David Brownell <dbr...@us...> Date: Mon Nov 16 15:27:36 2009 -0800 ARM: move mode functions out of header They're really too big to inline, at least for code that's not in any performance-critical loops. Also move the associated string table to the rodata section. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 0d890b8..334f834 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -53,13 +53,63 @@ char* armv4_5_core_reg_list[] = "cpsr", "spsr_fiq", "spsr_irq", "spsr_svc", "spsr_abt", "spsr_und" }; -char * armv4_5_mode_strings_list[] = +static const char *armv4_5_mode_strings_list[] = { "Illegal mode value", "User", "FIQ", "IRQ", "Supervisor", "Abort", "Undefined", "System" }; /* Hack! Yuk! allow -1 index, which simplifies codepaths elsewhere in the code */ -char** armv4_5_mode_strings = armv4_5_mode_strings_list + 1; +const char **armv4_5_mode_strings = armv4_5_mode_strings_list + 1; + +/** Map PSR mode bits to linear number */ +int armv4_5_mode_to_number(enum armv4_5_mode mode) +{ + switch (mode) { + case ARMV4_5_MODE_ANY: + /* map MODE_ANY to user mode */ + case ARMV4_5_MODE_USR: + return 0; + case ARMV4_5_MODE_FIQ: + return 1; + case ARMV4_5_MODE_IRQ: + return 2; + case ARMV4_5_MODE_SVC: + return 3; + case ARMV4_5_MODE_ABT: + return 4; + case ARMV4_5_MODE_UND: + return 5; + case ARMV4_5_MODE_SYS: + return 6; + default: + LOG_ERROR("invalid mode value encountered %d", mode); + return -1; + } +} + +/** Map linear number to PSR mode bits. */ +enum armv4_5_mode armv4_5_number_to_mode(int number) +{ + switch (number) { + case 0: + return ARMV4_5_MODE_USR; + case 1: + return ARMV4_5_MODE_FIQ; + case 2: + return ARMV4_5_MODE_IRQ; + case 3: + return ARMV4_5_MODE_SVC; + case 4: + return ARMV4_5_MODE_ABT; + case 5: + return ARMV4_5_MODE_UND; + case 6: + return ARMV4_5_MODE_SYS; + default: + LOG_ERROR("mode index out of bounds %d", number); + return ARMV4_5_MODE_ANY; + } +} char* armv4_5_state_strings[] = { diff --git a/src/target/armv4_5.h b/src/target/armv4_5.h index ffcd7c0..1e3ee42 100644 --- a/src/target/armv4_5.h +++ b/src/target/armv4_5.h @@ -41,7 +41,10 @@ typedef enum armv4_5_mode ARMV4_5_MODE_ANY = -1 } armv4_5_mode_t; -extern char** armv4_5_mode_strings; +int armv4_5_mode_to_number(enum armv4_5_mode mode); +enum armv4_5_mode armv4_5_number_to_mode(int number); + +extern const char **armv4_5_mode_strings; typedef enum armv4_5_state { @@ -136,43 +139,6 @@ struct armv4_5_core_reg struct reg_cache* armv4_5_build_reg_cache(struct target *target, struct arm *armv4_5_common); -/* map psr mode bits to linear number */ -static __inline int armv4_5_mode_to_number(enum armv4_5_mode mode) -{ - switch (mode) - { - case ARMV4_5_MODE_USR: return 0; break; - case ARMV4_5_MODE_FIQ: return 1; break; - case ARMV4_5_MODE_IRQ: return 2; break; - case ARMV4_5_MODE_SVC: return 3; break; - case ARMV4_5_MODE_ABT: return 4; break; - case ARMV4_5_MODE_UND: return 5; break; - case ARMV4_5_MODE_SYS: return 6; break; - case ARMV4_5_MODE_ANY: return 0; break; /* map MODE_ANY to user mode */ - default: - LOG_ERROR("invalid mode value encountered %d", mode); - return -1; - } -} - -/* map linear number to mode bits */ -static __inline enum armv4_5_mode armv4_5_number_to_mode(int number) -{ - switch (number) - { - case 0: return ARMV4_5_MODE_USR; break; - case 1: return ARMV4_5_MODE_FIQ; break; - case 2: return ARMV4_5_MODE_IRQ; break; - case 3: return ARMV4_5_MODE_SVC; break; - case 4: return ARMV4_5_MODE_ABT; break; - case 5: return ARMV4_5_MODE_UND; break; - case 6: return ARMV4_5_MODE_SYS; break; - default: - LOG_ERROR("mode index out of bounds %d", number); - return ARMV4_5_MODE_ANY; - } -}; - int armv4_5_arch_state(struct target *target); int armv4_5_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size); commit a7c04a0e49bf436e7930d798732c0827c38135b8 Author: David Brownell <dbr...@us...> Date: Mon Nov 16 15:18:55 2009 -0800 JTAG: no LOG_WARNING() for taps without IDCODE Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/jtag/core.c b/src/jtag/core.c index ea723eb..da745d0 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -1064,7 +1064,7 @@ static int jtag_examine_chain(void) if ((idcode & 1) == 0) { /* Zero for LSB indicates a device in bypass */ - LOG_WARNING("TAP %s does not have IDCODE", + LOG_INFO("TAP %s does not have IDCODE", tap->dotted_name); idcode = 0; tap->hasidcode = false; ----------------------------------------------------------------------- Summary of changes: src/jtag/core.c | 2 +- src/target/arm_disassembler.c | 8 ++- src/target/arm_simulator.c | 1 + src/target/armv4_5.c | 118 ++++++++++++++++++++++++++++------------ src/target/armv4_5.h | 43 ++------------- 5 files changed, 94 insertions(+), 78 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: David B. <dbr...@us...> - 2009-11-16 23:51:25
|
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 b6e0f2e1c32930b10403d26d39e71225573bcba9 (commit) from 66300d59661c94bd54a5ff5eff83f20c3217d99d (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 b6e0f2e1c32930b10403d26d39e71225573bcba9 Author: David Brownell <dbr...@us...> Date: Mon Nov 16 14:50:07 2009 -0800 binarybuffer: regression fix The "improve inline binarybuffer helpers" mis-handled bytes with the high bit set; treat them as unsigned, not signed. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index 460d017..6275eaf 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -41,7 +41,8 @@ static inline void buf_set_u32(void *_buffer, unsigned first, unsigned num, uint32_t value) { - char *buffer = (char *)_buffer; + uint8_t *buffer = (uint8_t *)_buffer; + if ((num == 32) && (first == 0)) { buffer[3] = (value >> 24) & 0xff; buffer[2] = (value >> 16) & 0xff; @@ -69,7 +70,8 @@ static inline void buf_set_u32(void *_buffer, static inline uint32_t buf_get_u32(const void *_buffer, unsigned first, unsigned num) { - char *buffer = (char *)_buffer; + uint8_t *buffer = (uint8_t *)_buffer; + if ((num == 32) && (first == 0)) { return (((uint32_t)buffer[3]) << 24) | (((uint32_t)buffer[2]) << 16) | ----------------------------------------------------------------------- Summary of changes: src/helper/binarybuffer.h | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: David B. <dbr...@us...> - 2009-11-16 19:42:43
|
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 66300d59661c94bd54a5ff5eff83f20c3217d99d (commit) from 9a98e83b49fe3541cb0d79924b13c2d86484aee2 (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 66300d59661c94bd54a5ff5eff83f20c3217d99d Author: David Brownell <dbr...@us...> Date: Mon Nov 16 10:42:01 2009 -0800 "types.h" doxygen fix Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/helper/types.h b/src/helper/types.h index 96a923b..03ab5f0 100644 --- a/src/helper/types.h +++ b/src/helper/types.h @@ -85,8 +85,8 @@ typedef bool _Bool; /** * Rounds @c m up to the nearest multiple of @c n using division. - * @params m The value to round up to @c n. - * @params n Round @c m up to a multiple of this number. + * @param m The value to round up to @c n. + * @param n Round @c m up to a multiple of this number. * @returns The rounded integer value. */ #define DIV_ROUND_UP(m, n) (((m) + (n) - 1) / (n)) ----------------------------------------------------------------------- Summary of changes: src/helper/types.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: David B. <dbr...@us...> - 2009-11-16 19:19:48
|
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 9a98e83b49fe3541cb0d79924b13c2d86484aee2 (commit) from dc1685ca25567fe75c8d50c825fb0303fbb66fac (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 9a98e83b49fe3541cb0d79924b13c2d86484aee2 Author: David Brownell <dbr...@us...> Date: Mon Nov 16 10:19:33 2009 -0800 target: less implicit inclusion of "etm.h" Don't include it in more headers than necessary; just use it in the few files that actually need it. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/arm11.c b/src/target/arm11.c index e4d2693..750c1f5 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -26,10 +26,10 @@ #include "config.h" #endif +#include "etm.h" #include "arm11.h" #include "breakpoints.h" #include "arm11_dbgtap.h" -#include "armv4_5.h" #include "arm_simulator.h" #include "time_support.h" #include "target_type.h" diff --git a/src/target/arm11_dbgtap.c b/src/target/arm11_dbgtap.c index 7010eab..bdbcc8f 100644 --- a/src/target/arm11_dbgtap.c +++ b/src/target/arm11_dbgtap.c @@ -24,6 +24,7 @@ #include "config.h" #endif +#include "arm_jtag.h" #include "arm11_dbgtap.h" #include "time_support.h" diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index 780ccf9..27a9b8d 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -34,6 +34,7 @@ #include "embeddedice.h" #include "target_request.h" #include "arm7_9_common.h" +#include "etm.h" #include "time_support.h" #include "arm_simulator.h" #include "algorithm.h" diff --git a/src/target/arm7_9_common.h b/src/target/arm7_9_common.h index e5a2bb7..266bf80 100644 --- a/src/target/arm7_9_common.h +++ b/src/target/arm7_9_common.h @@ -30,6 +30,7 @@ #define ARM7_9_COMMON_H #include "armv4_5.h" +#include "arm_jtag.h" #define ARM7_9_COMMON_MAGIC 0x0a790a79 /**< */ diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 9fa1ac0..0d890b8 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -28,6 +28,7 @@ #endif #include "armv4_5.h" +#include "arm_jtag.h" #include "breakpoints.h" #include "arm_disassembler.h" #include "binarybuffer.h" diff --git a/src/target/armv4_5.h b/src/target/armv4_5.h index ea46488..ffcd7c0 100644 --- a/src/target/armv4_5.h +++ b/src/target/armv4_5.h @@ -27,7 +27,7 @@ #define ARMV4_5_H #include "target.h" -#include "etm.h" +#include "log.h" typedef enum armv4_5_mode { diff --git a/src/target/etb.c b/src/target/etb.c index 21c375c..196df6c 100644 --- a/src/target/etb.c +++ b/src/target/etb.c @@ -22,6 +22,7 @@ #endif #include "armv4_5.h" +#include "etm.h" #include "etb.h" #include "register.h" diff --git a/src/target/etm.c b/src/target/etm.c index 936c9e6..5a0ffed 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -22,6 +22,7 @@ #endif #include "armv4_5.h" +#include "etm.h" #include "etb.h" #include "image.h" #include "arm_disassembler.h" diff --git a/src/target/trace.h b/src/target/trace.h index d6fd63e..c554c73 100644 --- a/src/target/trace.h +++ b/src/target/trace.h @@ -42,6 +42,11 @@ struct trace int trace_history_overflowed; }; +/** + * \todo This enum is one of the few things in this file related + * to *hardware* tracing ... split such "real" tracing out from + * the contrib/libdcc support. + */ typedef enum trace_status { TRACE_IDLE = 0x0, ----------------------------------------------------------------------- Summary of changes: src/target/arm11.c | 2 +- src/target/arm11_dbgtap.c | 1 + src/target/arm7_9_common.c | 1 + src/target/arm7_9_common.h | 1 + src/target/armv4_5.c | 1 + src/target/armv4_5.h | 2 +- src/target/etb.c | 1 + src/target/etm.c | 1 + src/target/trace.h | 5 +++++ 9 files changed, 13 insertions(+), 2 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Zach W. <zw...@us...> - 2009-11-16 18:59:39
|
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 dc1685ca25567fe75c8d50c825fb0303fbb66fac (commit) via 10cce4a5fe85bfd680bc338c900b0033d7174b6a (commit) via 0535a9245632e2cf12d8eaae8c4a9b1cc0bc66c6 (commit) via a94748ec6da9bdc6e25a7f73bbea723b8b55fa33 (commit) via f0ce88b3af9a6090ac986160950d66317de5087e (commit) from cbc05783727122f0052fe6f3be40635eb73ec5bc (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 dc1685ca25567fe75c8d50c825fb0303fbb66fac Author: Zachary T Welch <zw...@su...> Date: Mon Nov 16 03:29:30 2009 -0800 move ARRAY_SIZE macro to types.h The ARRAY_SIZE macro was defined in several target files, so move it to types.h. This patch also removes two other identical macros: DIM (from jtag.h) and asizeof (from arm11.h). diff --git a/src/helper/types.h b/src/helper/types.h index 8f6283b..96a923b 100644 --- a/src/helper/types.h +++ b/src/helper/types.h @@ -61,6 +61,16 @@ typedef bool _Bool; /** + * Compute the number of elements of a variable length array. + * <code> + * const char *strs[] = { "a", "b", "c" }; + * unsigned num_strs = ARRAY_SIZE(strs); + * </code> + */ +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) + + +/** * Cast a member of a structure out to the containing structure. * @param ptr The pointer to the member. * @param type The type of the container struct this is embedded in. diff --git a/src/jtag/core.c b/src/jtag/core.c index c8a76e8..ea723eb 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -586,7 +586,7 @@ int jtag_add_statemove(tap_state_t goal_state) unsigned tms_bits = tap_get_tms_path(cur_state, goal_state); unsigned tms_count = tap_get_tms_path_len(cur_state, goal_state); tap_state_t moves[8]; - assert(tms_count < DIM(moves)); + assert(tms_count < ARRAY_SIZE(moves)); for (unsigned i = 0; i < tms_count; i++, tms_bits >>= 1) { diff --git a/src/jtag/interface.c b/src/jtag/interface.c index f062414..1ed4512 100644 --- a/src/jtag/interface.c +++ b/src/jtag/interface.c @@ -363,7 +363,7 @@ const char *tap_state_name(tap_state_t state) { unsigned i; - for (i = 0; i < DIM(tap_name_mapping); i++) { + for (i = 0; i < ARRAY_SIZE(tap_name_mapping); i++) { if (tap_name_mapping[i].symbol == state) return tap_name_mapping[i].name; } @@ -374,7 +374,7 @@ tap_state_t tap_state_by_name(const char *name) { unsigned i; - for (i = 0; i < DIM(tap_name_mapping); i++) { + for (i = 0; i < ARRAY_SIZE(tap_name_mapping); i++) { /* be nice to the human */ if (strcasecmp(name, tap_name_mapping[i].name) == 0) return tap_name_mapping[i].symbol; diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h index ee3ca32..d4fafa3 100644 --- a/src/jtag/jtag.h +++ b/src/jtag/jtag.h @@ -38,14 +38,6 @@ #define DEBUG_JTAG_IOZ 64 #endif -/*-----<Macros>--------------------------------------------------*/ - -/** - * When given an array, compute its DIMension; in other words, the - * number of elements in the array - */ -#define DIM(x) (sizeof(x)/sizeof((x)[0])) - /*-----</Macros>-------------------------------------------------*/ /** diff --git a/src/svf/svf.c b/src/svf/svf.c index 814f3f2..fb5e1b0 100644 --- a/src/svf/svf.c +++ b/src/svf/svf.c @@ -282,7 +282,7 @@ int svf_add_statemove(tap_state_t state_to) return ERROR_OK; } - for (index = 0; index < DIM(svf_statemoves); index++) + for (index = 0; index < ARRAY_SIZE(svf_statemoves); index++) { if ((svf_statemoves[index].from == state_from) && (svf_statemoves[index].to == state_to)) @@ -783,7 +783,7 @@ static int svf_run_command(struct command_context *cmd_ctx, char *cmd_str) */ command = svf_find_string_in_array(argus[0], - (char **)svf_command_name, DIM(svf_command_name)); + (char **)svf_command_name, ARRAY_SIZE(svf_command_name)); switch (command) { case ENDDR: @@ -1391,7 +1391,7 @@ static int svf_run_command(struct command_context *cmd_ctx, char *cmd_str) } i_tmp = svf_find_string_in_array(argus[1], (char **)svf_trst_mode_name, - DIM(svf_trst_mode_name)); + ARRAY_SIZE(svf_trst_mode_name)); switch (i_tmp) { case TRST_ON: diff --git a/src/target/arm11.c b/src/target/arm11.c index 46f332e..e4d2693 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -363,7 +363,7 @@ static int arm11_on_enter_debug_state(struct arm11_common *arm11) int retval; FNC_INFO; - for (size_t i = 0; i < asizeof(arm11->reg_values); i++) + for (size_t i = 0; i < ARRAY_SIZE(arm11->reg_values); i++) { arm11->reg_list[i].valid = 1; arm11->reg_list[i].dirty = 0; @@ -386,7 +386,7 @@ static int arm11_on_enter_debug_state(struct arm11_common *arm11) arm11_setup_field(arm11, 1, NULL, NULL, chain5_fields + 1); arm11_setup_field(arm11, 1, NULL, NULL, chain5_fields + 2); - arm11_add_dr_scan_vc(asizeof(chain5_fields), chain5_fields, TAP_DRPAUSE); + arm11_add_dr_scan_vc(ARRAY_SIZE(chain5_fields), chain5_fields, TAP_DRPAUSE); } else { @@ -666,7 +666,7 @@ static int arm11_leave_debug_state(struct arm11_common *arm11) arm11_setup_field(arm11, 1, &Ready, NULL, chain5_fields + 1); arm11_setup_field(arm11, 1, &Valid, NULL, chain5_fields + 2); - arm11_add_dr_scan_vc(asizeof(chain5_fields), chain5_fields, TAP_DRPAUSE); + arm11_add_dr_scan_vc(ARRAY_SIZE(chain5_fields), chain5_fields, TAP_DRPAUSE); } arm11_record_register_history(arm11); @@ -877,7 +877,7 @@ static int arm11_resume(struct target *target, int current, brp[1].address = ARM11_SC7_BCR0 + brp_num; brp[1].value = 0x1 | (3 << 1) | (0x0F << 5) | (0 << 14) | (0 << 16) | (0 << 20) | (0 << 21); - arm11_sc7_run(arm11, brp, asizeof(brp)); + arm11_sc7_run(arm11, brp, ARRAY_SIZE(brp)); LOG_DEBUG("Add BP " ZU " at %08" PRIx32 "", brp_num, bp->address); @@ -1120,7 +1120,7 @@ static int arm11_step(struct target *target, int current, brp[1].value = 0x1 | (3 << 1) | (0x0F << 5) | (0 << 14) | (0 << 16) | (0 << 20) | (0 << 21); } - CHECK_RETVAL(arm11_sc7_run(arm11, brp, asizeof(brp))); + CHECK_RETVAL(arm11_sc7_run(arm11, brp, ARRAY_SIZE(brp))); /* resume */ @@ -1847,7 +1847,7 @@ static int arm11_examine(struct target *target) arm11_setup_field(arm11, 32, NULL, &arm11->didr, chain0_fields + 0); arm11_setup_field(arm11, 8, NULL, &arm11->implementor, chain0_fields + 1); - arm11_add_dr_scan_vc(asizeof(chain0_fields), chain0_fields, TAP_IDLE); + arm11_add_dr_scan_vc(ARRAY_SIZE(chain0_fields), chain0_fields, TAP_IDLE); CHECK_RETVAL(jtag_execute_queue()); @@ -1975,11 +1975,11 @@ static int arm11_build_reg_cache(struct target *target) size_t i; /* Not very elegant assertion */ - if (ARM11_REGCACHE_COUNT != asizeof(arm11->reg_values) || - ARM11_REGCACHE_COUNT != asizeof(arm11_reg_defs) || + if (ARM11_REGCACHE_COUNT != ARRAY_SIZE(arm11->reg_values) || + ARM11_REGCACHE_COUNT != ARRAY_SIZE(arm11_reg_defs) || ARM11_REGCACHE_COUNT != ARM11_RC_MAX) { - LOG_ERROR("BUG: arm11->reg_values inconsistent (%d " ZU " " ZU " %d)", ARM11_REGCACHE_COUNT, asizeof(arm11->reg_values), asizeof(arm11_reg_defs), ARM11_RC_MAX); + LOG_ERROR("BUG: arm11->reg_values inconsistent (%d " ZU " " ZU " %d)", ARM11_REGCACHE_COUNT, ARRAY_SIZE(arm11->reg_values), ARRAY_SIZE(arm11_reg_defs), ARM11_RC_MAX); exit(-1); } diff --git a/src/target/arm11.h b/src/target/arm11.h index 9bc6eb4..809c23f 100644 --- a/src/target/arm11.h +++ b/src/target/arm11.h @@ -25,8 +25,6 @@ #include "armv4_5.h" -#define asizeof(x) (sizeof(x) / sizeof((x)[0])) - #define NEW(type, variable, items) \ type * variable = calloc(1, sizeof(type) * items) diff --git a/src/target/arm11_dbgtap.c b/src/target/arm11_dbgtap.c index a95dcdd..7010eab 100644 --- a/src/target/arm11_dbgtap.c +++ b/src/target/arm11_dbgtap.c @@ -50,7 +50,7 @@ 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) { if (cmd_queue_cur_state == TAP_IRPAUSE) - jtag_add_pathmove(asizeof(arm11_move_pi_to_si_via_ci), arm11_move_pi_to_si_via_ci); + jtag_add_pathmove(ARRAY_SIZE(arm11_move_pi_to_si_via_ci), arm11_move_pi_to_si_via_ci); jtag_add_ir_scan(num_fields, fields, state); return ERROR_OK; @@ -64,7 +64,7 @@ static const tap_state_t arm11_move_pd_to_sd_via_cd[] = int arm11_add_dr_scan_vc(int num_fields, struct scan_field *fields, tap_state_t state) { if (cmd_queue_cur_state == TAP_DRPAUSE) - jtag_add_pathmove(asizeof(arm11_move_pd_to_sd_via_cd), arm11_move_pd_to_sd_via_cd); + jtag_add_pathmove(ARRAY_SIZE(arm11_move_pd_to_sd_via_cd), arm11_move_pd_to_sd_via_cd); jtag_add_dr_scan(num_fields, fields, state); return ERROR_OK; @@ -209,7 +209,7 @@ void arm11_add_debug_INST(struct arm11_common * arm11, uint32_t inst, uint8_t * arm11_setup_field(arm11, 32, &inst, NULL, itr + 0); arm11_setup_field(arm11, 1, NULL, flag, itr + 1); - arm11_add_dr_scan_vc(asizeof(itr), itr, state == ARM11_TAP_DEFAULT ? TAP_IDLE : state); + arm11_add_dr_scan_vc(ARRAY_SIZE(itr), itr, state == ARM11_TAP_DEFAULT ? TAP_IDLE : state); } /** Read the Debug Status and Control Register (DSCR) @@ -470,7 +470,7 @@ int arm11_run_instr_data_to_core(struct arm11_common * arm11, uint32_t opcode, u { Data = *data; - arm11_add_dr_scan_vc(asizeof(chain5_fields), chain5_fields, jtag_set_end_state(TAP_IDLE)); + arm11_add_dr_scan_vc(ARRAY_SIZE(chain5_fields), chain5_fields, jtag_set_end_state(TAP_IDLE)); CHECK_RETVAL(jtag_execute_queue()); @@ -505,7 +505,7 @@ int arm11_run_instr_data_to_core(struct arm11_common * arm11, uint32_t opcode, u { Data = 0; - arm11_add_dr_scan_vc(asizeof(chain5_fields), chain5_fields, TAP_DRPAUSE); + arm11_add_dr_scan_vc(ARRAY_SIZE(chain5_fields), chain5_fields, TAP_DRPAUSE); CHECK_RETVAL(jtag_execute_queue()); @@ -605,13 +605,13 @@ int arm11_run_instr_data_to_core_noack(struct arm11_common * arm11, uint32_t opc if (count) { - jtag_add_dr_scan(asizeof(chain5_fields), chain5_fields, jtag_set_end_state(TAP_DRPAUSE)); - jtag_add_pathmove(asizeof(arm11_MOVE_DRPAUSE_IDLE_DRPAUSE_with_delay), + jtag_add_dr_scan(ARRAY_SIZE(chain5_fields), chain5_fields, jtag_set_end_state(TAP_DRPAUSE)); + jtag_add_pathmove(ARRAY_SIZE(arm11_MOVE_DRPAUSE_IDLE_DRPAUSE_with_delay), arm11_MOVE_DRPAUSE_IDLE_DRPAUSE_with_delay); } else { - jtag_add_dr_scan(asizeof(chain5_fields), chain5_fields, jtag_set_end_state(TAP_IDLE)); + jtag_add_dr_scan(ARRAY_SIZE(chain5_fields), chain5_fields, jtag_set_end_state(TAP_IDLE)); } } @@ -620,7 +620,7 @@ int arm11_run_instr_data_to_core_noack(struct arm11_common * arm11, uint32_t opc chain5_fields[0].out_value = 0; chain5_fields[1].in_value = ReadyPos++; - arm11_add_dr_scan_vc(asizeof(chain5_fields), chain5_fields, TAP_DRPAUSE); + arm11_add_dr_scan_vc(ARRAY_SIZE(chain5_fields), chain5_fields, TAP_DRPAUSE); int retval = jtag_execute_queue(); if (retval == ERROR_OK) @@ -699,7 +699,7 @@ int arm11_run_instr_data_from_core(struct arm11_common * arm11, uint32_t opcode, int i = 0; do { - arm11_add_dr_scan_vc(asizeof(chain5_fields), chain5_fields, count ? TAP_IDLE : TAP_DRPAUSE); + arm11_add_dr_scan_vc(ARRAY_SIZE(chain5_fields), chain5_fields, count ? TAP_IDLE : TAP_DRPAUSE); CHECK_RETVAL(jtag_execute_queue()); @@ -833,7 +833,7 @@ int arm11_sc7_run(struct arm11_common * arm11, struct arm11_sc7_action * actions { JTAG_DEBUG("SC7 <= Address %02x Data %08x nRW %d", AddressOut, DataOut, nRW); - arm11_add_dr_scan_vc(asizeof(chain7_fields), chain7_fields, TAP_DRPAUSE); + arm11_add_dr_scan_vc(ARRAY_SIZE(chain7_fields), chain7_fields, TAP_DRPAUSE); CHECK_RETVAL(jtag_execute_queue()); @@ -880,7 +880,7 @@ void arm11_sc7_clear_vbw(struct arm11_common * arm11) struct arm11_sc7_action clear_bw[arm11->brp + arm11->wrp + 1]; struct arm11_sc7_action * pos = clear_bw; - for (size_t i = 0; i < asizeof(clear_bw); i++) + for (size_t i = 0; i < ARRAY_SIZE(clear_bw); i++) { clear_bw[i].write = true; clear_bw[i].value = 0; @@ -896,7 +896,7 @@ void arm11_sc7_clear_vbw(struct arm11_common * arm11) (pos++)->address = ARM11_SC7_VCR; - arm11_sc7_run(arm11, clear_bw, asizeof(clear_bw)); + arm11_sc7_run(arm11, clear_bw, ARRAY_SIZE(clear_bw)); } /** Write VCR register diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 884f8f6..9fa1ac0 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -759,7 +759,7 @@ int arm_checksum_memory(struct target *target, return retval; /* convert code into a buffer in target endianness */ - for (i = 0; i < DIM(arm_crc_code); i++) { + for (i = 0; i < ARRAY_SIZE(arm_crc_code); i++) { retval = target_write_u32(target, crc_algorithm->address + i * sizeof(uint32_t), arm_crc_code[i]); @@ -835,7 +835,7 @@ int arm_blank_check_memory(struct target *target, return retval; /* convert code into a buffer in target endianness */ - for (i = 0; i < DIM(check_code); i++) { + for (i = 0; i < ARRAY_SIZE(check_code); i++) { retval = target_write_u32(target, check_algorithm->address + i * sizeof(uint32_t), diff --git a/src/target/armv7m.c b/src/target/armv7m.c index f6127e8..132b786 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -40,8 +40,6 @@ #include "algorithm.h" #include "register.h" -#define ARRAY_SIZE(x) ((int)(sizeof(x)/sizeof((x)[0]))) - #if 0 #define _DEBUG_INSTRUCTION_EXECUTION_ @@ -389,7 +387,6 @@ int armv7m_run_algorithm(struct target *target, struct armv7m_algorithm *armv7m_algorithm_info = arch_info; enum armv7m_mode core_mode = armv7m->core_mode; int retval = ERROR_OK; - int i; uint32_t context[ARMV7M_NUM_REGS]; if (armv7m_algorithm_info->common_magic != ARMV7M_COMMON_MAGIC) @@ -406,20 +403,20 @@ int armv7m_run_algorithm(struct target *target, /* refresh core register cache */ /* Not needed if core register cache is always consistent with target process state */ - for (i = 0; i < ARMV7M_NUM_REGS; i++) + for (unsigned i = 0; i < ARMV7M_NUM_REGS; i++) { if (!armv7m->core_cache->reg_list[i].valid) armv7m->read_core_reg(target, i); context[i] = buf_get_u32(armv7m->core_cache->reg_list[i].value, 0, 32); } - for (i = 0; i < num_mem_params; i++) + for (int i = 0; i < num_mem_params; i++) { if ((retval = target_write_buffer(target, mem_params[i].address, mem_params[i].size, mem_params[i].value)) != ERROR_OK) return retval; } - for (i = 0; i < num_reg_params; i++) + for (int i = 0; i < num_reg_params; i++) { struct reg *reg = register_get_by_name(armv7m->core_cache, reg_params[i].reg_name, 0); // uint32_t regvalue; @@ -471,7 +468,7 @@ int armv7m_run_algorithm(struct target *target, } /* Read memory values to mem_params[] */ - for (i = 0; i < num_mem_params; i++) + for (int i = 0; i < num_mem_params; i++) { if (mem_params[i].direction != PARAM_OUT) if ((retval = target_read_buffer(target, mem_params[i].address, mem_params[i].size, mem_params[i].value)) != ERROR_OK) @@ -481,7 +478,7 @@ int armv7m_run_algorithm(struct target *target, } /* Copy core register values to reg_params[] */ - for (i = 0; i < num_reg_params; i++) + for (int i = 0; i < num_reg_params; i++) { if (reg_params[i].direction != PARAM_OUT) { @@ -503,7 +500,7 @@ int armv7m_run_algorithm(struct target *target, } } - for (i = ARMV7M_NUM_REGS - 1; i >= 0; i--) + for (int i = ARMV7M_NUM_REGS - 1; i >= 0; i--) { uint32_t regvalue; regvalue = buf_get_u32(armv7m->core_cache->reg_list[i].value, 0, 32); diff --git a/src/target/cortex_m3.c b/src/target/cortex_m3.c index e4949d2..e99e99c 100644 --- a/src/target/cortex_m3.c +++ b/src/target/cortex_m3.c @@ -43,8 +43,6 @@ * Cortex-M0 cores too, although they're ARMv6-M not ARMv7-M. */ -#define ARRAY_SIZE(x) ((int)(sizeof(x)/sizeof((x)[0]))) - /* forward declarations */ static int cortex_m3_set_breakpoint(struct target *target, struct breakpoint *breakpoint); @@ -1843,8 +1841,6 @@ COMMAND_HANDLER(handle_cortex_m3_vector_catch_command) struct swjdp_common *swjdp = &armv7m->swjdp_info; uint32_t demcr = 0; int retval; - int i; - retval = cortex_m3_verify_pointer(cmd_ctx, cortex_m3); if (retval != ERROR_OK) return retval; @@ -1865,6 +1861,7 @@ COMMAND_HANDLER(handle_cortex_m3_vector_catch_command) } } while (argc-- > 0) { + unsigned i; for (i = 0; i < ARRAY_SIZE(vec_ids); i++) { if (strcmp(args[argc], vec_ids[i].name) != 0) continue; @@ -1885,7 +1882,7 @@ write: mem_ap_read_atomic_u32(swjdp, DCB_DEMCR, &demcr); } - for (i = 0; i < ARRAY_SIZE(vec_ids); i++) + for (unsigned i = 0; i < ARRAY_SIZE(vec_ids); i++) command_print(cmd_ctx, "%9s: %s", vec_ids[i].name, (demcr & vec_ids[i].mask) ? "catch" : "ignore"); diff --git a/src/target/embeddedice.c b/src/target/embeddedice.c index 4a7cf12..2e9f1c0 100644 --- a/src/target/embeddedice.c +++ b/src/target/embeddedice.c @@ -30,8 +30,6 @@ #include "embeddedice.h" #include "register.h" -#define ARRAY_SIZE(x) ((int)(sizeof(x)/sizeof((x)[0]))) - /** * @file * diff --git a/src/target/etm.c b/src/target/etm.c index e70df10..936c9e6 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -50,8 +50,6 @@ * ARM IHI 0014O ... Embedded Trace Macrocell, Architecture Specification */ -#define ARRAY_SIZE(x) ((int)(sizeof(x)/sizeof((x)[0]))) - enum { RO, /* read/only */ WO, /* write/only */ diff --git a/src/xsvf/xsvf.c b/src/xsvf/xsvf.c index 2e78447..01a9411 100644 --- a/src/xsvf/xsvf.c +++ b/src/xsvf/xsvf.c @@ -470,7 +470,7 @@ COMMAND_HANDLER(handle_xsvf_command) TAP_IDLE, }; - jtag_add_pathmove(DIM(exception_path), exception_path); + jtag_add_pathmove(ARRAY_SIZE(exception_path), exception_path); if (verbose) LOG_USER("%s mismatch, xsdrsize=%d retry=%d", op_name, xsdrsize, attempt); commit 10cce4a5fe85bfd680bc338c900b0033d7174b6a Author: Zachary T Welch <zw...@su...> Date: Mon Nov 16 03:33:22 2009 -0800 armv7m: make core reg read/write use unsigned Eliminate redundant check that gets covered by using unsigned type. Created to eliminate noise from subsequent patches, but this kind of conversion will be beneficial in similar ways throughout the tree. diff --git a/src/target/armv7m.c b/src/target/armv7m.c index d8718f9..f6127e8 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -236,14 +236,14 @@ static int armv7m_set_core_reg(struct reg *reg, uint8_t *buf) return ERROR_OK; } -static int armv7m_read_core_reg(struct target *target, int num) +static int armv7m_read_core_reg(struct target *target, unsigned num) { uint32_t reg_value; int retval; struct armv7m_core_reg * armv7m_core_reg; struct armv7m_common *armv7m = target_to_armv7m(target); - if ((num < 0) || (num >= ARMV7M_NUM_REGS)) + if (num >= ARMV7M_NUM_REGS) return ERROR_INVALID_ARGUMENTS; armv7m_core_reg = armv7m->core_cache->reg_list[num].arch_info; @@ -255,14 +255,14 @@ static int armv7m_read_core_reg(struct target *target, int num) return retval; } -static int armv7m_write_core_reg(struct target *target, int num) +static int armv7m_write_core_reg(struct target *target, unsigned num) { int retval; uint32_t reg_value; struct armv7m_core_reg *armv7m_core_reg; struct armv7m_common *armv7m = target_to_armv7m(target); - if ((num < 0) || (num >= ARMV7M_NUM_REGS)) + if (num >= ARMV7M_NUM_REGS) return ERROR_INVALID_ARGUMENTS; reg_value = buf_get_u32(armv7m->core_cache->reg_list[num].value, 0, 32); diff --git a/src/target/armv7m.h b/src/target/armv7m.h index 7f8190b..dba9a3b 100644 --- a/src/target/armv7m.h +++ b/src/target/armv7m.h @@ -103,8 +103,8 @@ struct armv7m_common int (*load_core_reg_u32)(struct target *target, enum armv7m_regtype type, uint32_t num, uint32_t *value); int (*store_core_reg_u32)(struct target *target, enum armv7m_regtype type, uint32_t num, uint32_t value); /* register cache to processor synchronization */ - int (*read_core_reg)(struct target *target, int num); - int (*write_core_reg)(struct target *target, int num); + int (*read_core_reg)(struct target *target, unsigned num); + int (*write_core_reg)(struct target *target, unsigned num); int (*examine_debug_reason)(struct target *target); void (*post_debug_entry)(struct target *target); commit 0535a9245632e2cf12d8eaae8c4a9b1cc0bc66c6 Author: Zachary T Welch <zw...@su...> Date: Mon Nov 16 03:12:45 2009 -0800 remove TAP_SCAN_BYTES macro Use DIV_ROUND_UP(n, 8) instead of TAP_SCAN_BYTES macro. diff --git a/src/jtag/interface.c b/src/jtag/interface.c index e475b48..f062414 100644 --- a/src/jtag/interface.c +++ b/src/jtag/interface.c @@ -413,7 +413,7 @@ tap_state_t jtag_debug_state_machine(const void *tms_buf, const void *tdi_buf, tms_buffer = (const uint8_t *)tms_buf; tdi_buffer = (const uint8_t *)tdi_buf; - tap_bytes = TAP_SCAN_BYTES(tap_bits); + tap_bytes = DIV_ROUND_UP(tap_bits, 8); DEBUG_JTAG_IO("TAP/SM: TMS bits: %u (bytes: %u)", tap_bits, tap_bytes); tap_out_bits = 0; diff --git a/src/jtag/jlink.c b/src/jtag/jlink.c index 2422135..23ebc62 100644 --- a/src/jtag/jlink.c +++ b/src/jtag/jlink.c @@ -763,15 +763,16 @@ static int jlink_tap_execute(void) if (!tap_length) return ERROR_OK; - /* JLink returns an extra NULL in packet when size of in message is a multiple of 64, creates problems with usb comms */ - /* WARNING This will interfere with tap state counting */ - while ((TAP_SCAN_BYTES(tap_length)%64) == 0) + /* JLink returns an extra NULL in packet when size of incoming + * message is a multiple of 64, creates problems with USB comms. + * WARNING: This will interfere with tap state counting. */ + while ((DIV_ROUND_UP(tap_length, 8) % 64) == 0) { jlink_tap_append_step((tap_get_state() == TAP_RESET)?1:0, 0); } // number of full bytes (plus one if some would be left over) - byte_length = TAP_SCAN_BYTES(tap_length); + byte_length = DIV_ROUND_UP(tap_length, 8); bool use_jtag3 = jlink_hw_jtag_version >= 3; usb_out_buffer[0] = use_jtag3 ? EMU_CMD_HW_JTAG3 : EMU_CMD_HW_JTAG2; @@ -808,7 +809,7 @@ static int jlink_tap_execute(void) DEBUG_JTAG_IO("pending scan result, length = %d", length); #ifdef _DEBUG_USB_COMMS_ - jlink_debug_buffer(buffer, TAP_SCAN_BYTES(length)); + jlink_debug_buffer(buffer, DIV_ROUND_UP(length, 8)); #endif if (jtag_read_buffer(buffer, command) != ERROR_OK) diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h index 5328ff8..ee3ca32 100644 --- a/src/jtag/jtag.h +++ b/src/jtag/jtag.h @@ -46,9 +46,6 @@ */ #define DIM(x) (sizeof(x)/sizeof((x)[0])) -/** Calculate the number of bytes required to hold @a n TAP scan bits */ -#define TAP_SCAN_BYTES(n) DIV_ROUND_UP(n, 8) - /*-----</Macros>-------------------------------------------------*/ /** diff --git a/src/jtag/minidriver.h b/src/jtag/minidriver.h index 49931b7..392a190 100644 --- a/src/jtag/minidriver.h +++ b/src/jtag/minidriver.h @@ -58,7 +58,7 @@ static inline void interface_jtag_add_scan_check_alloc(struct scan_field *field) /* We're executing this synchronously, so try to use local storage. */ if (field->num_bits > 32) { - unsigned num_bytes = TAP_SCAN_BYTES(field->num_bits); + unsigned num_bytes = DIV_ROUND_UP(field->num_bits, 8); field->in_value = (uint8_t *)malloc(num_bytes); field->allocated = 1; } @@ -77,7 +77,7 @@ static inline void interface_jtag_alloc_in_value32(struct scan_field *field) static inline void interface_jtag_add_scan_check_alloc(struct scan_field *field) { - unsigned num_bytes = TAP_SCAN_BYTES(field->num_bits); + unsigned num_bytes = DIV_ROUND_UP(field->num_bits, 8); field->in_value = (uint8_t *)cmd_queue_alloc(num_bytes); } commit a94748ec6da9bdc6e25a7f73bbea723b8b55fa33 Author: Zachary T Welch <zw...@su...> Date: Mon Nov 16 02:53:57 2009 -0800 rename CEIL as DIV_ROUND_UP Improves the name of this macro, moves it to types.h, and adds a block of Doxygen comments to describe what it does. diff --git a/src/flash/at91sam7.c b/src/flash/at91sam7.c index e0b83d5..9d05d7b 100644 --- a/src/flash/at91sam7.c +++ b/src/flash/at91sam7.c @@ -979,7 +979,7 @@ static int at91sam7_write(struct flash_bank *bank, uint8_t *buffer, uint32_t off return ERROR_FLASH_BANK_NOT_PROBED; first_page = offset/dst_min_alignment; - last_page = CEIL(offset + count, dst_min_alignment); + last_page = DIV_ROUND_UP(offset + count, dst_min_alignment); LOG_DEBUG("first_page: %i, last_page: %i, count %i", (int)first_page, (int)last_page, (int)count); @@ -997,7 +997,7 @@ static int at91sam7_write(struct flash_bank *bank, uint8_t *buffer, uint32_t off /* Write one block to the PageWriteBuffer */ buffer_pos = (pagen-first_page)*dst_min_alignment; - wcount = CEIL(count,4); + wcount = DIV_ROUND_UP(count,4); if ((retval = target_write_memory(target, bank->base + pagen*dst_min_alignment, 4, wcount, buffer + buffer_pos)) != ERROR_OK) { return retval; diff --git a/src/flash/lpc2000.c b/src/flash/lpc2000.c index 79f5804..a3f9718 100644 --- a/src/flash/lpc2000.c +++ b/src/flash/lpc2000.c @@ -573,7 +573,7 @@ static int lpc2000_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offs { if (offset >= bank->sectors[i].offset) first_sector = i; - if (offset + CEIL(count, dst_min_alignment) * dst_min_alignment > bank->sectors[i].offset) + if (offset + DIV_ROUND_UP(count, dst_min_alignment) * dst_min_alignment > bank->sectors[i].offset) last_sector = i; } diff --git a/src/flash/str9xpec.c b/src/flash/str9xpec.c index 4bf5bca..7f6d8be 100644 --- a/src/flash/str9xpec.c +++ b/src/flash/str9xpec.c @@ -44,7 +44,7 @@ int str9xpec_set_instr(struct jtag_tap *tap, uint32_t new_instr, tap_state_t end field.tap = tap; field.num_bits = tap->ir_length; - field.out_value = calloc(CEIL(field.num_bits, 8), 1); + field.out_value = calloc(DIV_ROUND_UP(field.num_bits, 8), 1); buf_set_u32(field.out_value, 0, field.num_bits, new_instr); field.in_value = NULL; @@ -289,7 +289,7 @@ static int str9xpec_blank_check(struct flash_bank *bank, int first, int last) return ERROR_FLASH_OPERATION_FAILED; } - buffer = calloc(CEIL(64, 8), 1); + buffer = calloc(DIV_ROUND_UP(64, 8), 1); LOG_DEBUG("blank check: first_bank: %i, last_bank: %i", first, last); @@ -378,7 +378,7 @@ static int str9xpec_erase_area(struct flash_bank *bank, int first, int last) return ISC_STATUS_ERROR; } - buffer = calloc(CEIL(64, 8), 1); + buffer = calloc(DIV_ROUND_UP(64, 8), 1); LOG_DEBUG("erase: first_bank: %i, last_bank: %i", first, last); @@ -618,7 +618,7 @@ static int str9xpec_write(struct flash_bank *bank, uint8_t *buffer, uint32_t off LOG_DEBUG("first_sector: %i, last_sector: %i", first_sector, last_sector); - scanbuf = calloc(CEIL(64, 8), 1); + scanbuf = calloc(DIV_ROUND_UP(64, 8), 1); LOG_DEBUG("ISC_PROGRAM"); @@ -745,7 +745,7 @@ COMMAND_HANDLER(str9xpec_handle_part_id_command) str9xpec_info = bank->driver_priv; tap = str9xpec_info->tap; - buffer = calloc(CEIL(32, 8), 1); + buffer = calloc(DIV_ROUND_UP(32, 8), 1); str9xpec_set_instr(tap, ISC_IDCODE, TAP_IRPAUSE); diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c index 53ad4d3..081cc03 100644 --- a/src/helper/binarybuffer.c +++ b/src/helper/binarybuffer.c @@ -54,7 +54,7 @@ void* buf_cpy(const void *from, void *_to, unsigned size) return NULL; // copy entire buffer - memcpy(_to, from, CEIL(size, 8)); + memcpy(_to, from, DIV_ROUND_UP(size, 8)); /* mask out bits that don't belong to the buffer */ unsigned trailing_bits = size % 8; @@ -191,11 +191,11 @@ char* buf_to_str(const void *_buf, unsigned buf_len, unsigned radix) return NULL; } - unsigned str_len = ceil_f_to_u32(CEIL(buf_len, 8) * factor); + unsigned str_len = ceil_f_to_u32(DIV_ROUND_UP(buf_len, 8) * factor); char *str = calloc(str_len + 1, 1); const uint8_t *buf = _buf; - int b256_len = CEIL(buf_len, 8); + int b256_len = DIV_ROUND_UP(buf_len, 8); for (int i = b256_len - 1; i >= 0; i--) { uint32_t tmp = buf[i]; @@ -300,7 +300,7 @@ int str_to_buf(const char *str, unsigned str_len, } uint8_t *buf = _buf; - for (unsigned j = 0; j < CEIL(buf_len, 8); j++) + for (unsigned j = 0; j < DIV_ROUND_UP(buf_len, 8); j++) { if (j < b256_len) buf[j] = b256_buf[j]; diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index 9e0cc9b..460d017 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -124,8 +124,6 @@ int str_to_buf(const char *str, unsigned len, void *bin_buf, unsigned buf_size, unsigned radix); char* buf_to_str(const void *buf, unsigned size, unsigned radix); -#define CEIL(m, n) (((m) + (n) - 1) / (n)) - /* read a uint32_t from a buffer in target memory endianness */ static inline uint32_t fast_target_buffer_get_u32(const void *p, bool le) { diff --git a/src/helper/types.h b/src/helper/types.h index a8753c5..8f6283b 100644 --- a/src/helper/types.h +++ b/src/helper/types.h @@ -73,6 +73,15 @@ typedef bool _Bool; (type *)( (char *)__mptr - offsetof(type,member) );}) +/** + * Rounds @c m up to the nearest multiple of @c n using division. + * @params m The value to round up to @c n. + * @params n Round @c m up to a multiple of this number. + * @returns The rounded integer value. + */ +#define DIV_ROUND_UP(m, n) (((m) + (n) - 1) / (n)) + + /* DANGER!!!! here be dragons! * * Leave these fn's as byte accesses because it is safe diff --git a/src/jtag/commands.c b/src/jtag/commands.c index ccd6d0f..4e8ce40 100644 --- a/src/jtag/commands.c +++ b/src/jtag/commands.c @@ -179,7 +179,7 @@ int jtag_build_buffer(const struct scan_command *cmd, uint8_t **buffer) int i; bit_count = jtag_scan_size(cmd); - *buffer = calloc(1,CEIL(bit_count, 8)); + *buffer = calloc(1,DIV_ROUND_UP(bit_count, 8)); bit_count = 0; @@ -235,7 +235,7 @@ int jtag_read_buffer(uint8_t *buffer, const struct scan_command *cmd) if (cmd->fields[i].in_value) { int num_bits = cmd->fields[i].num_bits; - uint8_t *captured = buf_set_buf(buffer, bit_count, malloc(CEIL(num_bits, 8)), 0, num_bits); + uint8_t *captured = buf_set_buf(buffer, bit_count, malloc(DIV_ROUND_UP(num_bits, 8)), 0, num_bits); #ifdef _DEBUG_JTAG_IO_ char *char_buf = buf_to_str(captured, diff --git a/src/jtag/core.c b/src/jtag/core.c index 1841dde..c8a76e8 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -1193,7 +1193,7 @@ static int jtag_validate_ircapture(void) /* increase length to add 2 bit sentinel after scan */ total_ir_length += 2; - ir_test = malloc(CEIL(total_ir_length, 8)); + ir_test = malloc(DIV_ROUND_UP(total_ir_length, 8)); if (ir_test == NULL) return ERROR_FAIL; @@ -1293,7 +1293,7 @@ void jtag_tap_init(struct jtag_tap *tap) /* if we're autoprobing, cope with potentially huge ir_length */ ir_len_bits = tap->ir_length ? : JTAG_IRLEN_MAX; - ir_len_bytes = CEIL(ir_len_bits, 8); + ir_len_bytes = DIV_ROUND_UP(ir_len_bits, 8); tap->expected = calloc(1, ir_len_bytes); tap->expected_mask = calloc(1, ir_len_bytes); diff --git a/src/jtag/driver.c b/src/jtag/driver.c index 6469358..cadd88e 100644 --- a/src/jtag/driver.c +++ b/src/jtag/driver.c @@ -64,7 +64,7 @@ static void cmd_queue_scan_field_clone(struct scan_field * dst, const struct sca { dst->tap = src->tap; dst->num_bits = src->num_bits; - dst->out_value = buf_cpy(src->out_value, cmd_queue_alloc(CEIL(src->num_bits, 8)), src->num_bits); + dst->out_value = buf_cpy(src->out_value, cmd_queue_alloc(DIV_ROUND_UP(src->num_bits, 8)), src->num_bits); dst->in_value = src->in_value; } @@ -128,7 +128,7 @@ int interface_jtag_add_ir_scan(int in_num_fields, const struct scan_field *in_fi field->tap = tap; field->num_bits = tap->ir_length; - field->out_value = buf_set_ones(cmd_queue_alloc(CEIL(tap->ir_length, 8)), tap->ir_length); + field->out_value = buf_set_ones(cmd_queue_alloc(DIV_ROUND_UP(tap->ir_length, 8)), tap->ir_length); field->in_value = NULL; /* do not collect input for tap's in bypass */ } @@ -317,7 +317,7 @@ void interface_jtag_add_dr_out(struct jtag_tap *target_tap, field->tap = tap; field->num_bits = scan_size; - field->out_value = buf_cpy(out_value, cmd_queue_alloc(CEIL(scan_size, 8)), scan_size); + field->out_value = buf_cpy(out_value, cmd_queue_alloc(DIV_ROUND_UP(scan_size, 8)), scan_size); field->in_value = NULL; field++; diff --git a/src/jtag/ft2232.c b/src/jtag/ft2232.c index cee55e0..7acdf1a 100644 --- a/src/jtag/ft2232.c +++ b/src/jtag/ft2232.c @@ -721,7 +721,7 @@ static int ft2232_send_and_recv(struct jtag_command* first, struct jtag_command* if (type != SCAN_OUT) { scan_size = jtag_scan_size(cmd->cmd.scan); - buffer = calloc(CEIL(scan_size, 8), 1); + buffer = calloc(DIV_ROUND_UP(scan_size, 8), 1); ft2232_read_scan(type, buffer, scan_size); if (jtag_read_buffer(buffer, cmd->cmd.scan) != ERROR_OK) retval = ERROR_JTAG_QUEUE_FAILED; @@ -962,7 +962,7 @@ static int ft2232_large_scan(struct scan_command* cmd, enum scan_type type, uint int bits_left = scan_size; int cur_byte = 0; int last_bit; - uint8_t* receive_buffer = malloc(CEIL(scan_size, 8)); + uint8_t* receive_buffer = malloc(DIV_ROUND_UP(scan_size, 8)); uint8_t* receive_pointer = receive_buffer; uint32_t bytes_written; uint32_t bytes_read; @@ -1182,7 +1182,7 @@ static int ft2232_predict_scan_out(int scan_size, enum scan_type type) if (type == SCAN_IN) /* only from device to host */ { /* complete bytes */ - predicted_size += CEIL(num_bytes, 65536) * 3; + predicted_size += DIV_ROUND_UP(num_bytes, 65536) * 3; /* remaining bits - 1 (up to 7) */ predicted_size += ((scan_size - 1) % 8) ? 2 : 0; @@ -1190,7 +1190,7 @@ static int ft2232_predict_scan_out(int scan_size, enum scan_type type) else /* host to device, or bidirectional */ { /* complete bytes */ - predicted_size += num_bytes + CEIL(num_bytes, 65536) * 3; + predicted_size += num_bytes + DIV_ROUND_UP(num_bytes, 65536) * 3; /* remaining bits -1 (up to 7) */ predicted_size += ((scan_size - 1) % 8) ? 3 : 0; @@ -1206,7 +1206,7 @@ static int ft2232_predict_scan_in(int scan_size, enum scan_type type) if (type != SCAN_OUT) { /* complete bytes */ - predicted_size += (CEIL(scan_size, 8) > 1) ? (CEIL(scan_size, 8) - 1) : 0; + predicted_size += (DIV_ROUND_UP(scan_size, 8) > 1) ? (DIV_ROUND_UP(scan_size, 8) - 1) : 0; /* remaining bits - 1 */ predicted_size += ((scan_size - 1) % 8) ? 1 : 0; @@ -1506,7 +1506,7 @@ static int ft2232_execute_runtest(struct jtag_command *cmd) predicted_size = 0; if (tap_get_state() != TAP_IDLE) predicted_size += 3; - predicted_size += 3 * CEIL(cmd->cmd.runtest->num_cycles, 7); + predicted_size += 3 * DIV_ROUND_UP(cmd->cmd.runtest->num_cycles, 7); if (cmd->cmd.runtest->end_state != TAP_IDLE) predicted_size += 3; if (tap_get_end_state() != TAP_IDLE) @@ -1605,7 +1605,7 @@ static int ft2232_execute_pathmove(struct jtag_command *cmd) tap_state_name(path[num_states-1])); /* only send the maximum buffer size that FT2232C can handle */ - predicted_size = 3 * CEIL(num_states, 7); + predicted_size = 3 * DIV_ROUND_UP(num_states, 7); if (ft2232_buffer_size + predicted_size + 1 > FT2232_BUFFER_SIZE) { if (ft2232_send_and_recv(first_unsent, cmd) != ERROR_OK) diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h index 30d62fd..5328ff8 100644 --- a/src/jtag/jtag.h +++ b/src/jtag/jtag.h @@ -47,7 +47,7 @@ #define DIM(x) (sizeof(x)/sizeof((x)[0])) /** Calculate the number of bytes required to hold @a n TAP scan bits */ -#define TAP_SCAN_BYTES(n) CEIL(n, 8) +#define TAP_SCAN_BYTES(n) DIV_ROUND_UP(n, 8) /*-----</Macros>-------------------------------------------------*/ diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index 75732ef..71e7bd5 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -1129,7 +1129,7 @@ COMMAND_HANDLER(handle_irscan_command) int field_size = tap->ir_length; fields[i].tap = tap; fields[i].num_bits = field_size; - fields[i].out_value = malloc(CEIL(field_size, 8)); + fields[i].out_value = malloc(DIV_ROUND_UP(field_size, 8)); uint32_t value; retval = parse_u32(args[i * 2 + 1], &value); @@ -1257,7 +1257,7 @@ static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args fields[field_count].tap = tap; fields[field_count].num_bits = bits; - fields[field_count].out_value = malloc(CEIL(bits, 8)); + fields[field_count].out_value = malloc(DIV_ROUND_UP(bits, 8)); str_to_buf(str, len, fields[field_count].out_value, bits, 0); fields[field_count].in_value = fields[field_count].out_value; field_count++; diff --git a/src/pld/virtex2.c b/src/pld/virtex2.c index ea9ee0c..c07931e 100644 --- a/src/pld/virtex2.c +++ b/src/pld/virtex2.c @@ -37,7 +37,7 @@ static int virtex2_set_instr(struct jtag_tap *tap, uint32_t new_instr) field.tap = tap; field.num_bits = tap->ir_length; - field.out_value = calloc(CEIL(field.num_bits, 8), 1); + field.out_value = calloc(DIV_ROUND_UP(field.num_bits, 8), 1); buf_set_u32(field.out_value, 0, field.num_bits, new_instr); field.in_value = NULL; diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index f6b44cd..55ec7d4 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -871,7 +871,7 @@ void gdb_str_to_target(struct target *target, char *tstr, struct reg *reg) uint8_t *buf; int buf_len; buf = reg->value; - buf_len = CEIL(reg->size, 8); + buf_len = DIV_ROUND_UP(reg->size, 8); for (i = 0; i < buf_len; i++) { @@ -940,25 +940,25 @@ int gdb_get_registers_packet(struct connection *connection, struct target *targe reg_packet_size += reg_list[i]->size; } - reg_packet = malloc(CEIL(reg_packet_size, 8) * 2); + reg_packet = malloc(DIV_ROUND_UP(reg_packet_size, 8) * 2); reg_packet_p = reg_packet; for (i = 0; i < reg_list_size; i++) { gdb_str_to_target(target, reg_packet_p, reg_list[i]); - reg_packet_p += CEIL(reg_list[i]->size, 8) * 2; + reg_packet_p += DIV_ROUND_UP(reg_list[i]->size, 8) * 2; } #ifdef _DEBUG_GDB_IO_ { char *reg_packet_p; - reg_packet_p = strndup(reg_packet, CEIL(reg_packet_size, 8) * 2); + reg_packet_p = strndup(reg_packet, DIV_ROUND_UP(reg_packet_size, 8) * 2); LOG_DEBUG("reg_packet: %s", reg_packet_p); free(reg_packet_p); } #endif - gdb_put_packet(connection, reg_packet, CEIL(reg_packet_size, 8) * 2); + gdb_put_packet(connection, reg_packet, DIV_ROUND_UP(reg_packet_size, 8) * 2); free(reg_packet); free(reg_list); @@ -997,7 +997,7 @@ int gdb_set_registers_packet(struct connection *connection, struct target *targe for (i = 0; i < reg_list_size; i++) { uint8_t *bin_buf; - int chars = (CEIL(reg_list[i]->size, 8) * 2); + int chars = (DIV_ROUND_UP(reg_list[i]->size, 8) * 2); if (packet_p + chars > packet + packet_size) { @@ -1005,7 +1005,7 @@ int gdb_set_registers_packet(struct connection *connection, struct target *targe } struct reg_arch_type *arch_type; - bin_buf = malloc(CEIL(reg_list[i]->size, 8)); + bin_buf = malloc(DIV_ROUND_UP(reg_list[i]->size, 8)); gdb_target_to_reg(target, packet_p, chars, bin_buf); /* get register arch_type, and call set method */ @@ -1051,11 +1051,11 @@ int gdb_get_register_packet(struct connection *connection, struct target *target exit(-1); } - reg_packet = malloc(CEIL(reg_list[reg_num]->size, 8) * 2); + reg_packet = malloc(DIV_ROUND_UP(reg_list[reg_num]->size, 8) * 2); gdb_str_to_target(target, reg_packet, reg_list[reg_num]); - gdb_put_packet(connection, reg_packet, CEIL(reg_list[reg_num]->size, 8) * 2); + gdb_put_packet(connection, reg_packet, DIV_ROUND_UP(reg_list[reg_num]->size, 8) * 2); free(reg_list); free(reg_packet); @@ -1093,8 +1093,8 @@ int gdb_set_register_packet(struct connection *connection, struct target *target } /* convert from GDB-string (target-endian) to hex-string (big-endian) */ - bin_buf = malloc(CEIL(reg_list[reg_num]->size, 8)); - int chars = (CEIL(reg_list[reg_num]->size, 8) * 2); + bin_buf = malloc(DIV_ROUND_UP(reg_list[reg_num]->size, 8)); + int chars = (DIV_ROUND_UP(reg_list[reg_num]->size, 8) * 2); /* fix!!! add some sanity checks on packet size here */ diff --git a/src/target/algorithm.c b/src/target/algorithm.c index 7643e3c..76cf48b 100644 --- a/src/target/algorithm.c +++ b/src/target/algorithm.c @@ -43,7 +43,7 @@ void init_reg_param(struct reg_param *param, char *reg_name, uint32_t size, enum { param->reg_name = reg_name; param->size = size; - param->value = malloc(CEIL(size, 8)); + param->value = malloc(DIV_ROUND_UP(size, 8)); param->direction = direction; } diff --git a/src/target/etb.c b/src/target/etb.c index 72474cd..21c375c 100644 --- a/src/target/etb.c +++ b/src/target/etb.c @@ -57,7 +57,7 @@ static int etb_set_instr(struct etb *etb, uint32_t new_instr) field.tap = tap; field.num_bits = tap->ir_length; - field.out_value = calloc(CEIL(field.num_bits, 8), 1); + field.out_value = calloc(DIV_ROUND_UP(field.num_bits, 8), 1); buf_set_u32(field.out_value, 0, field.num_bits, new_instr); field.in_value = NULL; @@ -78,7 +78,7 @@ static int etb_scann(struct etb *etb, uint32_t new_scan_chain) field.tap = etb->tap; field.num_bits = 5; - field.out_value = calloc(CEIL(field.num_bits, 8), 1); + field.out_value = calloc(DIV_ROUND_UP(field.num_bits, 8), 1); buf_set_u32(field.out_value, 0, field.num_bits, new_scan_chain); field.in_value = NULL; diff --git a/src/target/target.c b/src/target/target.c index f5a092a..c24085f 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -1967,7 +1967,7 @@ COMMAND_HANDLER(handle_reg_command) /* set register value */ if (argc == 2) { - uint8_t *buf = malloc(CEIL(reg->size, 8)); + uint8_t *buf = malloc(DIV_ROUND_UP(reg->size, 8)); str_to_buf(args[1], strlen(args[1]), buf, reg->size, 0); struct reg_arch_type *arch_type = register_get_arch_type(reg->arch_type); diff --git a/src/target/target_request.c b/src/target/target_request.c index 7215155..be176ca 100644 --- a/src/target/target_request.c +++ b/src/target/target_request.c @@ -40,10 +40,10 @@ static int charmsg_mode = 0; static int target_asciimsg(struct target *target, uint32_t length) { - char *msg = malloc(CEIL(length + 1, 4) * 4); + char *msg = malloc(DIV_ROUND_UP(length + 1, 4) * 4); struct debug_msg_receiver *c = target->dbgmsg; - target->type->target_request_data(target, CEIL(length, 4), (uint8_t*)msg); + target->type->target_request_data(target, DIV_ROUND_UP(length, 4), (uint8_t*)msg); msg[length] = 0; LOG_DEBUG("%s", msg); @@ -66,7 +66,7 @@ static int target_charmsg(struct target *target, uint8_t msg) static int target_hexmsg(struct target *target, int size, uint32_t length) { - uint8_t *data = malloc(CEIL(length * size, 4) * 4); + uint8_t *data = malloc(DIV_ROUND_UP(length * size, 4) * 4); char line[128]; int line_len; struct debug_msg_receiver *c = target->dbgmsg; @@ -74,7 +74,7 @@ static int target_hexmsg(struct target *target, int size, uint32_t length) LOG_DEBUG("size: %i, length: %i", (int)size, (int)length); - target->type->target_request_data(target, CEIL(length * size, 4), (uint8_t*)data); + target->type->target_request_data(target, DIV_ROUND_UP(length * size, 4), (uint8_t*)data); line_len = 0; for (i = 0; i < length; i++) diff --git a/src/xsvf/xsvf.c b/src/xsvf/xsvf.c index 3fe2c0f..2e78447 100644 --- a/src/xsvf/xsvf.c +++ b/src/xsvf/xsvf.c @@ -479,7 +479,7 @@ COMMAND_HANDLER(handle_xsvf_command) field.tap = tap; field.num_bits = xsdrsize; field.out_value = dr_out_buf; - field.in_value = calloc(CEIL(field.num_bits, 8), 1); + field.in_value = calloc(DIV_ROUND_UP(field.num_bits, 8), 1); if (tap == NULL) jtag_add_plain_dr_scan(1, &field, jtag_set_end_state(TAP_DRPAUSE)); @@ -933,7 +933,7 @@ COMMAND_HANDLER(handle_xsvf_command) field.tap = tap; field.num_bits = xsdrsize; field.out_value = dr_out_buf; - field.in_value = calloc(CEIL(field.num_bits, 8), 1); + field.in_value = calloc(DIV_ROUND_UP(field.num_bits, 8), 1); if (attempt > 0 && verbose) LOG_USER("LSDR retry %d", attempt); commit f0ce88b3af9a6090ac986160950d66317de5087e Author: Zachary T Welch <zw...@su...> Date: Mon Nov 16 02:29:09 2009 -0800 move container_of to types.h The container_of macro is useful as a general solution. It belongs in types.h, rather than target.h where it was introduced. Requires the offsetof macro, which comes from <stddef.h> (moved as well). diff --git a/src/helper/types.h b/src/helper/types.h index 79eac13..a8753c5 100644 --- a/src/helper/types.h +++ b/src/helper/types.h @@ -23,6 +23,7 @@ #ifndef TYPES_H #define TYPES_H +#include <stddef.h> #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> #endif @@ -58,6 +59,20 @@ typedef bool _Bool; #define stringify(s) __stringify(s) #define __stringify(s) #s + +/** + * Cast a member of a structure out to the containing structure. + * @param ptr The pointer to the member. + * @param type The type of the container struct this is embedded in. + * @param member The name of the member within the struct. + * + * This is a mechanism which is used throughout the Linux kernel. + */ +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + + /* DANGER!!!! here be dragons! * * Leave these fn's as byte accesses because it is safe diff --git a/src/target/target.h b/src/target/target.h index 51fb299..ee40209 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -26,7 +26,6 @@ #ifndef TARGET_H #define TARGET_H -#include <stddef.h> #include "types.h" #include "jim.h" @@ -39,18 +38,6 @@ struct mem_param; struct reg_param; -/** - * Cast a member of a structure out to the containing structure. - * @param ptr The pointer to the member. - * @param type The type of the container struct this is embedded in. - * @param member The name of the member within the struct. - * - * This is a mechanism which is used throughout the Linux kernel. - */ -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) - /* * TARGET_UNKNOWN = 0: we don't know anything about the target yet * TARGET_RUNNING = 1: the target is executing user code ----------------------------------------------------------------------- Summary of changes: src/flash/at91sam7.c | 4 ++-- src/flash/lpc2000.c | 2 +- src/flash/str9xpec.c | 10 +++++----- src/helper/binarybuffer.c | 8 ++++---- src/helper/binarybuffer.h | 2 -- src/helper/types.h | 34 ++++++++++++++++++++++++++++++++++ src/jtag/commands.c | 4 ++-- src/jtag/core.c | 6 +++--- src/jtag/driver.c | 6 +++--- src/jtag/ft2232.c | 14 +++++++------- src/jtag/interface.c | 6 +++--- src/jtag/jlink.c | 11 ++++++----- src/jtag/jtag.h | 11 ----------- src/jtag/minidriver.h | 4 ++-- src/jtag/tcl.c | 4 ++-- src/pld/virtex2.c | 2 +- src/server/gdb_server.c | 22 +++++++++++----------- src/svf/svf.c | 6 +++--- src/target/algorithm.c | 2 +- src/target/arm11.c | 18 +++++++++--------- src/target/arm11.h | 2 -- src/target/arm11_dbgtap.c | 26 +++++++++++++------------- src/target/armv4_5.c | 4 ++-- src/target/armv7m.c | 23 ++++++++++------------- src/target/armv7m.h | 4 ++-- src/target/cortex_m3.c | 7 ++----- src/target/embeddedice.c | 2 -- src/target/etb.c | 4 ++-- src/target/etm.c | 2 -- src/target/target.c | 2 +- src/target/target.h | 13 ------------- src/target/target_request.c | 8 ++++---- src/xsvf/xsvf.c | 6 +++--- 33 files changed, 138 insertions(+), 141 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Zach W. <zw...@us...> - 2009-11-16 18:05:25
|
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 cbc05783727122f0052fe6f3be40635eb73ec5bc (commit) via e84849f5ed7416c758914bea88a31827259c4f5b (commit) from d7a0dfa4dc28c60c3137b9f9acf3fcc046730f0f (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 cbc05783727122f0052fe6f3be40635eb73ec5bc Author: Zachary T Welch <zw...@su...> Date: Sun Nov 15 07:20:19 2009 -0800 nand_command_get_device_by_num: make COMMAND_HELPER Use COMMAND_HELPER macro to define nand_command_get_device_by_num. Use CALL_COMMAND_HANDLER to invoke it. diff --git a/src/flash/nand.c b/src/flash/nand.c index 46ac728..fba8104 100644 --- a/src/flash/nand.c +++ b/src/flash/nand.c @@ -304,9 +304,10 @@ struct nand_device *get_nand_device_by_num(int num) return NULL; } -int nand_command_get_device_by_num(struct command_context *cmd_ctx, - const char *str, struct nand_device **nand) +COMMAND_HELPER(nand_command_get_device_by_num, unsigned name_index, + struct nand_device **nand) { + const char *str = args[name_index]; unsigned num; COMMAND_PARSE_NUMBER(uint, str, num); *nand = get_nand_device_by_num(num); @@ -1077,7 +1078,7 @@ COMMAND_HANDLER(handle_nand_info_command) int last = -1; struct nand_device *p; - int retval = nand_command_get_device_by_num(cmd_ctx, args[0], &p); + int retval = CALL_COMMAND_HANDLER(nand_command_get_device_by_num, 0, &p); if (ERROR_OK != retval) return retval; @@ -1152,7 +1153,7 @@ COMMAND_HANDLER(handle_nand_probe_command) } struct nand_device *p; - int retval = nand_command_get_device_by_num(cmd_ctx, args[0], &p); + int retval = CALL_COMMAND_HANDLER(nand_command_get_device_by_num, 0, &p); if (ERROR_OK != retval) return retval; @@ -1181,7 +1182,7 @@ COMMAND_HANDLER(handle_nand_erase_command) } struct nand_device *p; - int retval = nand_command_get_device_by_num(cmd_ctx, args[0], &p); + int retval = CALL_COMMAND_HANDLER(nand_command_get_device_by_num, 0, &p); if (ERROR_OK != retval) return retval; @@ -1240,7 +1241,7 @@ COMMAND_HANDLER(handle_nand_check_bad_blocks_command) } struct nand_device *p; - int retval = nand_command_get_device_by_num(cmd_ctx, args[0], &p); + int retval = CALL_COMMAND_HANDLER(nand_command_get_device_by_num, 0, &p); if (ERROR_OK != retval) return retval; @@ -1392,7 +1393,7 @@ static COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state, return ERROR_COMMAND_SYNTAX_ERROR; struct nand_device *nand; - int retval = nand_command_get_device_by_num(cmd_ctx, args[0], &nand); + int retval = CALL_COMMAND_HANDLER(nand_command_get_device_by_num, 0, &nand); if (ERROR_OK != retval) return retval; @@ -1651,7 +1652,7 @@ COMMAND_HANDLER(handle_nand_raw_access_command) } struct nand_device *p; - int retval = nand_command_get_device_by_num(cmd_ctx, args[0], &p); + int retval = CALL_COMMAND_HANDLER(nand_command_get_device_by_num, 0, &p); if (ERROR_OK != retval) return retval; diff --git a/src/flash/nand.h b/src/flash/nand.h index afec9a7..ddc4520 100644 --- a/src/flash/nand.h +++ b/src/flash/nand.h @@ -230,8 +230,8 @@ int nand_register_commands(struct command_context *cmd_ctx); int nand_init(struct command_context *cmd_ctx); /// helper for parsing a nand device command argument string -int nand_command_get_device_by_num(struct command_context *cmd_ctx, - const char *str, struct nand_device **nand); +COMMAND_HELPER(nand_command_get_device_by_num, unsigned name_index, + struct nand_device **nand); #define ERROR_NAND_DEVICE_INVALID (-1100) commit e84849f5ed7416c758914bea88a31827259c4f5b Author: Zachary T Welch <zw...@su...> Date: Sun Nov 15 06:48:20 2009 -0800 flash_command_get_bank_by_num: make COMMAND_HELPER Use COMMAND_HELPER macro to declare flash_command_get_bank_by_num. This is required for COMMAND_PARSE_NUMBER macro. diff --git a/src/flash/avrf.c b/src/flash/avrf.c index e41093d..5d3c033 100644 --- a/src/flash/avrf.c +++ b/src/flash/avrf.c @@ -426,7 +426,7 @@ COMMAND_HANDLER(avrf_handle_mass_erase_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; diff --git a/src/flash/flash.c b/src/flash/flash.c index 20efa50..bdee53b 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -198,11 +198,11 @@ struct flash_bank *get_flash_bank_by_num(int num) return p; } -int flash_command_get_bank_by_num( - struct command_context *cmd_ctx, const char *str, struct flash_bank **bank) +COMMAND_HELPER(flash_command_get_bank_by_num, + unsigned name_index, struct flash_bank **bank) { unsigned bank_num; - COMMAND_PARSE_NUMBER(uint, str, bank_num); + COMMAND_PARSE_NUMBER(uint, args[name_index], bank_num); *bank = get_flash_bank_by_num(bank_num); if (!*bank) @@ -403,7 +403,7 @@ COMMAND_HANDLER(handle_flash_erase_check_command) } struct flash_bank *p; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &p); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &p); if (ERROR_OK != retval) return retval; @@ -491,7 +491,7 @@ COMMAND_HANDLER(handle_flash_protect_check_command) return ERROR_COMMAND_SYNTAX_ERROR; struct flash_bank *p; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &p); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &p); if (ERROR_OK != retval) return retval; @@ -821,7 +821,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command) duration_start(&bench); struct flash_bank *p; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &p); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &p); if (ERROR_OK != retval) return retval; diff --git a/src/flash/flash.h b/src/flash/flash.h index 4651fc3..96a4120 100644 --- a/src/flash/flash.h +++ b/src/flash/flash.h @@ -318,13 +318,13 @@ struct flash_bank *get_flash_bank_by_num(int num); /** * Retreives @a bank from a command argument, reporting errors parsing * the bank identifier or retreiving the specified bank. - * @param cmd_ctx The command context for reporting errors. - * @param str The string containing the bank identifier. + * @param name_index The index to the string in args containing the + * bank identifier. * @param bank On output, contians a pointer to the bank or NULL. * @returns ERROR_OK on success, or an error indicating the problem. */ -int flash_command_get_bank_by_num(struct command_context *cmd_ctx, - const char *str, struct flash_bank **bank); +COMMAND_HELPER(flash_command_get_bank_by_num, unsigned name_index, + struct flash_bank **bank); /** * Returns the flash bank like get_flash_bank_by_num(), without probing. * @param num The flash bank number. diff --git a/src/flash/lpc2000.c b/src/flash/lpc2000.c index 09bb13f..79f5804 100644 --- a/src/flash/lpc2000.c +++ b/src/flash/lpc2000.c @@ -750,7 +750,7 @@ COMMAND_HANDLER(lpc2000_handle_part_id_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; diff --git a/src/flash/lpc2900.c b/src/flash/lpc2900.c index 35f1507..b80079d 100644 --- a/src/flash/lpc2900.c +++ b/src/flash/lpc2900.c @@ -544,7 +544,7 @@ COMMAND_HANDLER(lpc2900_handle_signature_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -589,7 +589,7 @@ COMMAND_HANDLER(lpc2900_handle_read_custom_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -660,7 +660,7 @@ COMMAND_HANDLER(lpc2900_handle_password_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -695,7 +695,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -806,7 +806,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command) /* Get the bank descriptor */ struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -905,7 +905,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_jtag_command) /* Get the bank descriptor */ struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; diff --git a/src/flash/pic32mx.c b/src/flash/pic32mx.c index b6c4c44..51c42b5 100644 --- a/src/flash/pic32mx.c +++ b/src/flash/pic32mx.c @@ -684,7 +684,7 @@ COMMAND_HANDLER(pic32mx_handle_lock_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -730,7 +730,7 @@ COMMAND_HANDLER(pic32mx_handle_unlock_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -820,7 +820,7 @@ COMMAND_HANDLER(pic32mx_handle_chip_erase_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -858,7 +858,7 @@ COMMAND_HANDLER(pic32mx_handle_pgm_word_command) COMMAND_PARSE_NUMBER(u32, args[1], value); struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[2], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 2, &bank); if (ERROR_OK != retval) return retval; diff --git a/src/flash/stellaris.c b/src/flash/stellaris.c index 7b94675..bbe4aef 100644 --- a/src/flash/stellaris.c +++ b/src/flash/stellaris.c @@ -1139,7 +1139,7 @@ COMMAND_HANDLER(stellaris_handle_mass_erase_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; diff --git a/src/flash/stm32x.c b/src/flash/stm32x.c index 7072715..ab9831b 100644 --- a/src/flash/stm32x.c +++ b/src/flash/stm32x.c @@ -905,7 +905,7 @@ COMMAND_HANDLER(stm32x_handle_lock_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -951,7 +951,7 @@ COMMAND_HANDLER(stm32x_handle_unlock_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -995,7 +995,7 @@ COMMAND_HANDLER(stm32x_handle_options_read_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -1051,7 +1051,7 @@ COMMAND_HANDLER(stm32x_handle_options_write_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -1160,7 +1160,7 @@ COMMAND_HANDLER(stm32x_handle_mass_erase_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; diff --git a/src/flash/str7x.c b/src/flash/str7x.c index 19ee160..d851051 100644 --- a/src/flash/str7x.c +++ b/src/flash/str7x.c @@ -618,7 +618,7 @@ COMMAND_HANDLER(str7x_handle_disable_jtag_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; diff --git a/src/flash/str9x.c b/src/flash/str9x.c index 870871c..4c4d8ae 100644 --- a/src/flash/str9x.c +++ b/src/flash/str9x.c @@ -642,7 +642,7 @@ COMMAND_HANDLER(str9x_handle_flash_config_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; diff --git a/src/flash/str9xpec.c b/src/flash/str9xpec.c index d1b02c5..4bf5bca 100644 --- a/src/flash/str9xpec.c +++ b/src/flash/str9xpec.c @@ -738,7 +738,7 @@ COMMAND_HANDLER(str9xpec_handle_part_id_command) return ERROR_COMMAND_SYNTAX_ERROR; struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -789,7 +789,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_read_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -905,7 +905,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_write_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -928,7 +928,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_cmap_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -957,7 +957,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdthd_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -986,7 +986,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdsel_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -1015,7 +1015,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdwarn_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -1044,7 +1044,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_lock_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -1067,7 +1067,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_unlock_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -1093,7 +1093,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_enable_turbo_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -1140,7 +1140,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_disable_turbo_command) } struct flash_bank *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; ----------------------------------------------------------------------- Summary of changes: src/flash/avrf.c | 2 +- src/flash/flash.c | 12 ++++++------ src/flash/flash.h | 8 ++++---- src/flash/lpc2000.c | 2 +- src/flash/lpc2900.c | 12 ++++++------ src/flash/nand.c | 17 +++++++++-------- src/flash/nand.h | 4 ++-- src/flash/pic32mx.c | 8 ++++---- src/flash/stellaris.c | 2 +- src/flash/stm32x.c | 10 +++++----- src/flash/str7x.c | 2 +- src/flash/str9x.c | 2 +- src/flash/str9xpec.c | 22 +++++++++++----------- 13 files changed, 52 insertions(+), 51 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Zach W. <zw...@us...> - 2009-11-16 14:31:48
|
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 d7a0dfa4dc28c60c3137b9f9acf3fcc046730f0f (commit) from 555757175eb344d11f3c0123f2f83460ef6ca67b (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 d7a0dfa4dc28c60c3137b9f9acf3fcc046730f0f Author: Zachary T Welch <zw...@su...> Date: Mon Nov 16 04:29:45 2009 -0800 cleanup jtag minidrivers Remove two vestigial externs from our JTAG minidriver source files. Also, removes many extra blank lines from the minidummy driver. diff --git a/src/jtag/minidummy/minidummy.c b/src/jtag/minidummy/minidummy.c index 67919e4..1bee74e 100644 --- a/src/jtag/minidummy/minidummy.c +++ b/src/jtag/minidummy/minidummy.c @@ -24,9 +24,6 @@ #include "minidriver.h" #include "interface.h" - - - struct jtag_interface minidummy_interface = { .name = "minidummy", @@ -41,11 +38,6 @@ struct jtag_interface minidummy_interface = .srst_asserted = NULL, }; - - - - - int interface_jtag_execute_queue(void) { /* synchronously do the operation here */ @@ -53,12 +45,6 @@ int interface_jtag_execute_queue(void) return ERROR_OK; } - - - - -extern int jtag_check_value(uint8_t *captured, void *priv); - int interface_jtag_add_ir_scan(int num_fields, const struct scan_field *fields, tap_state_t state) { /* synchronously do the operation here */ @@ -67,10 +53,6 @@ int interface_jtag_add_ir_scan(int num_fields, const struct scan_field *fields, } - - - - int interface_jtag_add_plain_ir_scan(int num_fields, const struct scan_field *fields, tap_state_t state) { /* synchronously do the operation here */ @@ -78,8 +60,6 @@ int interface_jtag_add_plain_ir_scan(int num_fields, const struct scan_field *fi return ERROR_OK; } -/*extern jtag_struct command **jtag_get_last_command_p(void);*/ - int interface_jtag_add_dr_scan(int num_fields, const struct scan_field *fields, tap_state_t state) { /* synchronously do the operation here */ @@ -94,7 +74,6 @@ int interface_jtag_add_plain_dr_scan(int num_fields, const struct scan_field *fi return ERROR_OK; } - int interface_jtag_add_tlr() { /* synchronously do the operation here */ @@ -102,8 +81,6 @@ int interface_jtag_add_tlr() return ERROR_OK; } - - int interface_jtag_add_reset(int req_trst, int req_srst) { /* synchronously do the operation here */ @@ -111,7 +88,6 @@ int interface_jtag_add_reset(int req_trst, int req_srst) return ERROR_OK; } - int interface_jtag_add_runtest(int num_cycles, tap_state_t state) { /* synchronously do the operation here */ @@ -170,8 +146,6 @@ int interface_jtag_add_pathmove(int num_states, const tap_state_t *path) return ERROR_OK; } - - void embeddedice_write_dcc(struct jtag_tap *tap, int reg_addr, uint8_t *buffer, int little, int count) { int i; @@ -181,4 +155,3 @@ void embeddedice_write_dcc(struct jtag_tap *tap, int reg_addr, uint8_t *buffer, buffer += 4; } } - diff --git a/src/jtag/zy1000/zy1000.c b/src/jtag/zy1000/zy1000.c index 526914a..9a5d2e7 100644 --- a/src/jtag/zy1000/zy1000.c +++ b/src/jtag/zy1000/zy1000.c @@ -455,8 +455,6 @@ static void shiftValueInnerFlip(const tap_state_t state, const tap_state_t endSt } #endif -extern int jtag_check_value(uint8_t *captured, void *priv); - static void gotoEndState(tap_state_t end_state) { setCurrentState(end_state); @@ -595,8 +593,6 @@ int interface_jtag_add_plain_ir_scan(int num_fields, const struct scan_field *fi return ERROR_OK; } -/*extern jtag_struct command **jtag_get_last_command_p(void);*/ - int interface_jtag_add_dr_scan(int num_fields, const struct scan_field *fields, tap_state_t state) { ----------------------------------------------------------------------- Summary of changes: src/jtag/minidummy/minidummy.c | 27 --------------------------- src/jtag/zy1000/zy1000.c | 4 ---- 2 files changed, 0 insertions(+), 31 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Zach W. <zw...@us...> - 2009-11-16 13:09:57
|
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 555757175eb344d11f3c0123f2f83460ef6ca67b (commit) via da4cb3c029e7f271ee4fa7165ceefbef04d45e49 (commit) via 51cd370b396d19555158c1eb913e7c8386d92a0f (commit) via 23cc85b307de80be089dcb0048dbb6168e59651a (commit) from 45527ee82c9e7c93b29b79f01f52d663960649c2 (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 555757175eb344d11f3c0123f2f83460ef6ca67b Author: Zachary T Welch <zw...@su...> Date: Sat Nov 7 21:20:45 2009 -0800 Add 'nand verify' command Add the 'nand verify' command to perform a dump and fake-write simultaneously, checking the read bits against those generated by the write process. Appropriate user documentation for this command has been added to the user guide as well. The algorithm presently makes a relatively naive comparison. Some chips that use ECC may not verify correctly using this implementation, but the new documentation provides details about this limitation. diff --git a/doc/openocd.texi b/doc/openocd.texi index bb96a2e..81409ac 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -4620,6 +4620,32 @@ the underlying driver from applying hardware ECC. @end itemize @end deffn +@deffn Command {nand verify} num filename offset [option...] +@cindex NAND verification +@cindex NAND programming +Verify the binary data in the file has been programmed to the +specified NAND device, starting at the specified offset. +The @var{num} parameter is the value shown by @command{nand list}. + +Use a complete path name for @var{filename}, so you don't depend +on the directory used to start the OpenOCD server. + +The @var{offset} must be an exact multiple of the device's page size. +All data in the file will be read and compared to the contents of the +flash, assuming it doesn't run past the end of the device. +As with @command{nand write}, only full pages are verified, so any extra +space in the last page will be filled with 0xff bytes. + +The same @var{options} accepted by @command{nand write}, +and the file will be processed similarly to produce the buffers that +can be compared against the contents produced from @command{nand dump}. + +@b{NOTE:} This will not work when the underlying NAND controller +driver's @code{write_page} routine must update the OOB with a +hardward-computed ECC before the data is written. This limitation may +be removed in a future release. +@end deffn + @section Other NAND commands @cindex NAND other commands diff --git a/src/flash/nand.c b/src/flash/nand.c index da561f6..46ac728 100644 --- a/src/flash/nand.c +++ b/src/flash/nand.c @@ -1543,6 +1543,67 @@ COMMAND_HANDLER(handle_nand_write_command) return ERROR_OK; } +COMMAND_HANDLER(handle_nand_verify_command) +{ + struct nand_device *nand = NULL; + struct nand_fileio_state file; + int retval = CALL_COMMAND_HANDLER(nand_fileio_parse_args, + &file, &nand, FILEIO_READ, false, true); + if (ERROR_OK != retval) + return retval; + + struct nand_fileio_state dev; + nand_fileio_init(&dev); + dev.address = file.address; + dev.size = file.size; + dev.oob_format = file.oob_format; + retval = nand_fileio_start(cmd_ctx, nand, NULL, FILEIO_NONE, &dev); + if (ERROR_OK != retval) + return retval; + + while (file.size > 0) + { + int retval = nand_read_page(nand, dev.address / dev.page_size, + dev.page, dev.page_size, dev.oob, dev.oob_size); + if (ERROR_OK != retval) + { + command_print(cmd_ctx, "reading NAND flash page failed"); + nand_fileio_cleanup(&dev); + return nand_fileio_cleanup(&file); + } + + int bytes_read = nand_fileio_read(nand, &file); + if (bytes_read <= 0) + { + command_print(cmd_ctx, "error while reading file"); + nand_fileio_cleanup(&dev); + return nand_fileio_cleanup(&file); + } + + if ((dev.page && memcmp(dev.page, file.page, dev.page_size)) || + (dev.oob && memcmp(dev.oob, file.oob, dev.oob_size)) ) + { + command_print(cmd_ctx, "NAND flash contents differ " + "at 0x%8.8" PRIx32, dev.address); + nand_fileio_cleanup(&dev); + return nand_fileio_cleanup(&file); + } + + file.size -= bytes_read; + file.address += nand->page_size; + } + + if (nand_fileio_finish(&file) == ERROR_OK) + { + command_print(cmd_ctx, "verified file %s in NAND flash %s " + "up to offset 0x%8.8" PRIx32 " in %fs (%0.3f kb/s)", + args[1], args[0], dev.address, duration_elapsed(&file.bench), + duration_kbps(&file.bench, dev.size)); + } + + return nand_fileio_cleanup(&dev); +} + COMMAND_HANDLER(handle_nand_dump_command) { struct nand_device *nand = NULL; @@ -1641,6 +1702,10 @@ int nand_init(struct command_context *cmd_ctx) handle_nand_dump_command, COMMAND_EXEC, "dump from NAND flash device <num> <filename> " "<offset> <length> [oob_raw | oob_only]"); + register_command(cmd_ctx, nand_cmd, "verify", + &handle_nand_verify_command, COMMAND_EXEC, + "verify NAND flash device <num> <filename> <offset> " + "[oob_raw | oob_only | oob_softecc | oob_softecc_kw]"); register_command(cmd_ctx, nand_cmd, "write", handle_nand_write_command, COMMAND_EXEC, "write to NAND flash device <num> <filename> <offset> " commit da4cb3c029e7f271ee4fa7165ceefbef04d45e49 Author: Zachary T Welch <zw...@su...> Date: Sat Nov 7 22:37:39 2009 -0800 Add FILEIO_NONE access mode. In some cases, the FILEIO_NONE access mode may be useful as a parameter to indicate that file access should be disabled. High-level routines can use it to skip file access calls, as 'fileio_open' will fail presently if called to open a file using this mode. diff --git a/src/helper/fileio.h b/src/helper/fileio.h index 024ad08..8cba926 100644 --- a/src/helper/fileio.h +++ b/src/helper/fileio.h @@ -38,6 +38,7 @@ enum fileio_type enum fileio_access { + FILEIO_NONE, /* open without any access (invalid mode) */ FILEIO_READ, /* open for reading, position at beginning */ FILEIO_WRITE, /* open for writing, position at beginning */ FILEIO_READWRITE, /* open for writing, position at beginning, allow reading */ commit 51cd370b396d19555158c1eb913e7c8386d92a0f Author: Zachary T Welch <zw...@su...> Date: Thu Nov 5 19:45:24 2009 -0800 Use nand_fileio_* in write/dump commands. This patch eliminates duplicated code in the the NAND 'dump' and 'write' by using the new static helper functions. These changes also fix a possible memory leak in nand dump command, in the case that the dump file failed to open. Overall, the changes should be functionally equivalent, but the resulting code will be easier to improve and extend further. diff --git a/src/flash/nand.c b/src/flash/nand.c index 9cc0802..da561f6 100644 --- a/src/flash/nand.c +++ b/src/flash/nand.c @@ -1375,13 +1375,13 @@ static int nand_fileio_cleanup(struct nand_fileio_state *state) } return ERROR_OK; } -int nand_fileio_finish(struct nand_fileio_state *state) +static int nand_fileio_finish(struct nand_fileio_state *state) { nand_fileio_cleanup(state); return duration_measure(&state->bench); } -COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state, +static COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state, struct nand_device **dev, enum fileio_access filemode, bool need_size, bool sw_ecc) { @@ -1449,7 +1449,7 @@ COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state, * @returns If no error occurred, returns number of bytes consumed; * otherwise, returns a negative error code.) */ -int nand_fileio_read(struct nand_device *nand, +static int nand_fileio_read(struct nand_device *nand, struct nand_fileio_state *s) { uint32_t total_read = 0; @@ -1503,284 +1503,82 @@ int nand_fileio_read(struct nand_device *nand, COMMAND_HANDLER(handle_nand_write_command) { - uint32_t offset; - uint32_t binary_size; - uint32_t buf_cnt; - enum oob_formats oob_format = NAND_OOB_NONE; - - struct fileio fileio; - - - if (argc < 3) - { - return ERROR_COMMAND_SYNTAX_ERROR; - } - - struct nand_device *p; - int retval = nand_command_get_device_by_num(cmd_ctx, args[0], &p); + struct nand_device *nand = NULL; + struct nand_fileio_state s; + int retval = CALL_COMMAND_HANDLER(nand_fileio_parse_args, + &s, &nand, FILEIO_READ, false, true); if (ERROR_OK != retval) return retval; - uint8_t *page = NULL; - uint32_t page_size = 0; - uint8_t *oob = NULL; - uint32_t oob_size = 0; - const int *eccpos = NULL; - - COMMAND_PARSE_NUMBER(u32, args[2], offset); - - if (argc > 3) - { - for (unsigned i = 3; i < argc; i++) - { - if (!strcmp(args[i], "oob_raw")) - oob_format |= NAND_OOB_RAW; - else if (!strcmp(args[i], "oob_only")) - oob_format |= NAND_OOB_RAW | NAND_OOB_ONLY; - else if (!strcmp(args[i], "oob_softecc")) - oob_format |= NAND_OOB_SW_ECC; - else if (!strcmp(args[i], "oob_softecc_kw")) - oob_format |= NAND_OOB_SW_ECC_KW; - else - { - command_print(cmd_ctx, "unknown option: %s", args[i]); - return ERROR_COMMAND_SYNTAX_ERROR; - } - } - } - - struct duration bench; - duration_start(&bench); - - if (fileio_open(&fileio, args[1], FILEIO_READ, FILEIO_BINARY) != ERROR_OK) - { - return ERROR_OK; - } - - buf_cnt = binary_size = fileio.size; - - if (!(oob_format & NAND_OOB_ONLY)) - { - page_size = p->page_size; - page = malloc(p->page_size); - } - - if (oob_format & (NAND_OOB_RAW | NAND_OOB_SW_ECC | NAND_OOB_SW_ECC_KW)) - { - if (p->page_size == 512) { - oob_size = 16; - eccpos = nand_oob_16.eccpos; - } else if (p->page_size == 2048) { - oob_size = 64; - eccpos = nand_oob_64.eccpos; - } - oob = malloc(oob_size); - } - - if (offset % p->page_size) - { - command_print(cmd_ctx, "only page size aligned offsets and sizes are supported"); - fileio_close(&fileio); - free(oob); - free(page); - return ERROR_OK; - } - - while (buf_cnt > 0) + uint32_t total_bytes = s.size; + while (s.size > 0) { - uint32_t size_read; - - if (NULL != page) + int bytes_read = nand_fileio_read(nand, &s); + if (bytes_read <= 0) { - fileio_read(&fileio, page_size, page, &size_read); - buf_cnt -= size_read; - if (size_read < page_size) - { - memset(page + size_read, 0xff, page_size - size_read); - } + command_print(cmd_ctx, "error while reading file"); + return nand_fileio_cleanup(&s); } + s.size -= bytes_read; - if (oob_format & NAND_OOB_SW_ECC) - { - uint32_t i, j; - uint8_t ecc[3]; - memset(oob, 0xff, oob_size); - for (i = 0, j = 0; i < page_size; i += 256) { - nand_calculate_ecc(p, page + i, ecc); - oob[eccpos[j++]] = ecc[0]; - oob[eccpos[j++]] = ecc[1]; - oob[eccpos[j++]] = ecc[2]; - } - } else if (oob_format & NAND_OOB_SW_ECC_KW) - { - /* - * In this case eccpos is not used as - * the ECC data is always stored contigously - * at the end of the OOB area. It consists - * of 10 bytes per 512-byte data block. - */ - uint32_t i; - uint8_t *ecc = oob + oob_size - page_size/512 * 10; - memset(oob, 0xff, oob_size); - for (i = 0; i < page_size; i += 512) { - nand_calculate_ecc_kw(p, page + i, ecc); - ecc += 10; - } - } - else if (NULL != oob) + retval = nand_write_page(nand, s.address / nand->page_size, + s.page, s.page_size, s.oob, s.oob_size); + if (ERROR_OK != retval) { - fileio_read(&fileio, oob_size, oob, &size_read); - buf_cnt -= size_read; - if (size_read < oob_size) - { - memset(oob + size_read, 0xff, oob_size - size_read); - } + command_print(cmd_ctx, "failed writing file %s " + "to NAND flash %s at offset 0x%8.8" PRIx32, + args[1], args[0], s.address); + return nand_fileio_cleanup(&s); } - - if (nand_write_page(p, offset / p->page_size, page, page_size, oob, oob_size) != ERROR_OK) - { - command_print(cmd_ctx, "failed writing file %s to NAND flash %s at offset 0x%8.8" PRIx32 "", - args[1], args[0], offset); - - fileio_close(&fileio); - free(oob); - free(page); - - return ERROR_OK; - } - offset += page_size; + s.address += s.page_size; } - fileio_close(&fileio); - free(oob); - free(page); - oob = NULL; - page = NULL; - if (duration_measure(&bench) == ERROR_OK) + if (nand_fileio_finish(&s)) { - command_print(cmd_ctx, "wrote file %s to NAND flash %s " - "up to offset 0x%8.8" PRIx32 " in %fs (%0.3f kb/s)", - args[1], args[0], offset, duration_elapsed(&bench), - duration_kbps(&bench, fileio.size)); + command_print(cmd_ctx, "wrote file %s to NAND flash %s up to " + "offset 0x%8.8" PRIx32 " in %fs (%0.3f kb/s)", + args[1], args[0], s.address, duration_elapsed(&s.bench), + duration_kbps(&s.bench, total_bytes)); } - return ERROR_OK; } COMMAND_HANDLER(handle_nand_dump_command) { - if (argc < 4) - { - return ERROR_COMMAND_SYNTAX_ERROR; - } - - struct nand_device *p; - int retval = nand_command_get_device_by_num(cmd_ctx, args[0], &p); + struct nand_device *nand = NULL; + struct nand_fileio_state s; + int retval = CALL_COMMAND_HANDLER(nand_fileio_parse_args, + &s, &nand, FILEIO_WRITE, true, false); if (ERROR_OK != retval) return retval; - if (NULL == p->device) - { - command_print(cmd_ctx, "#%s: not probed", args[0]); - return ERROR_OK; - } - - struct fileio fileio; - - uint8_t *page = NULL; - uint32_t page_size = 0; - uint8_t *oob = NULL; - uint32_t oob_size = 0; - uint32_t address; - COMMAND_PARSE_NUMBER(u32, args[2], address); - uint32_t size; - COMMAND_PARSE_NUMBER(u32, args[3], size); - uint32_t bytes_done = 0; - enum oob_formats oob_format = NAND_OOB_NONE; - - if (argc > 4) - { - for (unsigned i = 4; i < argc; i++) - { - if (!strcmp(args[i], "oob_raw")) - oob_format |= NAND_OOB_RAW; - else if (!strcmp(args[i], "oob_only")) - oob_format |= NAND_OOB_RAW | NAND_OOB_ONLY; - else - command_print(cmd_ctx, "unknown option: '%s'", args[i]); - } - } - - if ((address % p->page_size) || (size % p->page_size)) - { - command_print(cmd_ctx, "only page size aligned addresses and sizes are supported"); - return ERROR_OK; - } - - if (!(oob_format & NAND_OOB_ONLY)) - { - page_size = p->page_size; - page = malloc(p->page_size); - } - - if (oob_format & NAND_OOB_RAW) - { - if (p->page_size == 512) - oob_size = 16; - else if (p->page_size == 2048) - oob_size = 64; - oob = malloc(oob_size); - } - - if (fileio_open(&fileio, args[1], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK) - { - return ERROR_OK; - } - - struct duration bench; - duration_start(&bench); - - while (size > 0) + while (s.size > 0) { uint32_t size_written; - if ((retval = nand_read_page(p, address / p->page_size, page, page_size, oob, oob_size)) != ERROR_OK) + int retval = nand_read_page(nand, s.address / nand->page_size, + s.page, s.page_size, s.oob, s.oob_size); + if (ERROR_OK != retval) { command_print(cmd_ctx, "reading NAND flash page failed"); - free(page); - free(oob); - fileio_close(&fileio); - return ERROR_OK; + return nand_fileio_cleanup(&s); } - if (NULL != page) - { - fileio_write(&fileio, page_size, page, &size_written); - bytes_done += page_size; - } + if (NULL != s.page) + fileio_write(&s.fileio, s.page_size, s.page, &size_written); - if (NULL != oob) - { - fileio_write(&fileio, oob_size, oob, &size_written); - bytes_done += oob_size; - } + if (NULL != s.oob) + fileio_write(&s.fileio, s.oob_size, s.oob, &size_written); - size -= p->page_size; - address += p->page_size; + s.size -= nand->page_size; + s.address += nand->page_size; } - free(page); - page = NULL; - free(oob); - oob = NULL; - fileio_close(&fileio); - - if (duration_measure(&bench) == ERROR_OK) + if (nand_fileio_finish(&s) == ERROR_OK) { - command_print(cmd_ctx, "dumped %lld byte in %fs (%0.3f kb/s)", - fileio.size, duration_elapsed(&bench), - duration_kbps(&bench, fileio.size)); + command_print(cmd_ctx, "dumped %lld byte in %fs (%0.3f kb/s)", + s.fileio.size, duration_elapsed(&s.bench), + duration_kbps(&s.bench, s.fileio.size)); } - return ERROR_OK; } commit 23cc85b307de80be089dcb0048dbb6168e59651a Author: Zachary T Welch <zw...@su...> Date: Sun Nov 8 02:06:34 2009 -0800 Add nand_fileio_* helper APIs. This patch provides helpers APIs that will eliminate duplicated code in the the NAND 'dump' and 'write' commands by factoring their common code into static helper functions. These helpers may be useful for creating new commands, as shown in the final patch to 'verify' flash from a file. Several previously unreported error conditions now generate messages and propogate the return codes, such as when the file fails to open and bad arguments are given. These changes will fix a possible memory leak in nand dump command, in the case that the dump file failed to open. Overall, the changes should be functionally equivalent, but the resulting code will be easier to improve and extend consistently. diff --git a/src/flash/nand.c b/src/flash/nand.c index be3a669..9cc0802 100644 --- a/src/flash/nand.c +++ b/src/flash/nand.c @@ -1285,6 +1285,222 @@ COMMAND_HANDLER(handle_nand_check_bad_blocks_command) return ERROR_OK; } +struct nand_fileio_state { + uint32_t address; + uint32_t size; + + uint8_t *page; + uint32_t page_size; + + enum oob_formats oob_format; + uint8_t *oob; + uint32_t oob_size; + + const int *eccpos; + + bool file_opened; + struct fileio fileio; + + struct duration bench; +}; + +static void nand_fileio_init(struct nand_fileio_state *state) +{ + memset(state, 0, sizeof(*state)); + state->oob_format = NAND_OOB_NONE; +} + +static int nand_fileio_start(struct command_context *cmd_ctx, + struct nand_device *nand, const char *filename, int filemode, + struct nand_fileio_state *state) +{ + if (state->address % nand->page_size) + { + command_print(cmd_ctx, "only page-aligned addresses are supported"); + return ERROR_COMMAND_SYNTAX_ERROR; + } + + duration_start(&state->bench); + + if (NULL != filename) + { + int retval = fileio_open(&state->fileio, filename, filemode, FILEIO_BINARY); + if (ERROR_OK != retval) + { + const char *msg = (FILEIO_READ == filemode) ? "read" : "write"; + command_print(cmd_ctx, "failed to open '%s' for %s access", + filename, msg); + return retval; + } + state->file_opened = true; + } + + if (!(state->oob_format & NAND_OOB_ONLY)) + { + state->page_size = nand->page_size; + state->page = malloc(nand->page_size); + } + + if (state->oob_format & (NAND_OOB_RAW | NAND_OOB_SW_ECC | NAND_OOB_SW_ECC_KW)) + { + if (nand->page_size == 512) + { + state->oob_size = 16; + state->eccpos = nand_oob_16.eccpos; + } + else if (nand->page_size == 2048) + { + state->oob_size = 64; + state->eccpos = nand_oob_64.eccpos; + } + state->oob = malloc(state->oob_size); + } + + return ERROR_OK; +} +static int nand_fileio_cleanup(struct nand_fileio_state *state) +{ + if (state->file_opened) + fileio_close(&state->fileio); + + if (state->oob) + { + free(state->oob); + state->oob = NULL; + } + if (state->page) + { + free(state->page); + state->page = NULL; + } + return ERROR_OK; +} +int nand_fileio_finish(struct nand_fileio_state *state) +{ + nand_fileio_cleanup(state); + return duration_measure(&state->bench); +} + +COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state, + struct nand_device **dev, enum fileio_access filemode, + bool need_size, bool sw_ecc) +{ + nand_fileio_init(state); + + unsigned minargs = need_size ? 4 : 3; + if (argc < minargs) + return ERROR_COMMAND_SYNTAX_ERROR; + + struct nand_device *nand; + int retval = nand_command_get_device_by_num(cmd_ctx, args[0], &nand); + if (ERROR_OK != retval) + return retval; + + if (NULL == nand->device) + { + command_print(cmd_ctx, "#%s: not probed", args[0]); + return ERROR_OK; + } + + COMMAND_PARSE_NUMBER(u32, args[2], state->address); + if (need_size) + { + COMMAND_PARSE_NUMBER(u32, args[2], state->size); + if (state->size % nand->page_size) + { + command_print(cmd_ctx, "only page-aligned sizes are supported"); + return ERROR_COMMAND_SYNTAX_ERROR; + } + } + + if (argc > minargs) + { + for (unsigned i = minargs; i < argc; i++) + { + if (!strcmp(args[i], "oob_raw")) + state->oob_format |= NAND_OOB_RAW; + else if (!strcmp(args[i], "oob_only")) + state->oob_format |= NAND_OOB_RAW | NAND_OOB_ONLY; + else if (sw_ecc && !strcmp(args[i], "oob_softecc")) + state->oob_format |= NAND_OOB_SW_ECC; + else if (sw_ecc && !strcmp(args[i], "oob_softecc_kw")) + state->oob_format |= NAND_OOB_SW_ECC_KW; + else + { + command_print(cmd_ctx, "unknown option: %s", args[i]); + return ERROR_COMMAND_SYNTAX_ERROR; + } + } + } + + retval = nand_fileio_start(cmd_ctx, nand, args[1], filemode, state); + if (ERROR_OK != retval) + return retval; + + if (!need_size) + state->size = state->fileio.size; + + *dev = nand; + + return ERROR_OK; +} + +/** + * @returns If no error occurred, returns number of bytes consumed; + * otherwise, returns a negative error code.) + */ +int nand_fileio_read(struct nand_device *nand, + struct nand_fileio_state *s) +{ + uint32_t total_read = 0; + uint32_t one_read; + + if (NULL != s->page) + { + fileio_read(&s->fileio, s->page_size, s->page, &one_read); + if (one_read < s->page_size) + memset(s->page + one_read, 0xff, s->page_size - one_read); + total_read += one_read; + } + + if (s->oob_format & NAND_OOB_SW_ECC) + { + uint8_t ecc[3]; + memset(s->oob, 0xff, s->oob_size); + for (uint32_t i = 0, j = 0; i < s->page_size; i += 256) + { + nand_calculate_ecc(nand, s->page + i, ecc); + s->oob[s->eccpos[j++]] = ecc[0]; + s->oob[s->eccpos[j++]] = ecc[1]; + s->oob[s->eccpos[j++]] = ecc[2]; + } + } + else if (s->oob_format & NAND_OOB_SW_ECC_KW) + { + /* + * In this case eccpos is not used as + * the ECC data is always stored contigously + * at the end of the OOB area. It consists + * of 10 bytes per 512-byte data block. + */ + uint8_t *ecc = s->oob + s->oob_size - s->page_size / 512 * 10; + memset(s->oob, 0xff, s->oob_size); + for (uint32_t i = 0; i < s->page_size; i += 512) + { + nand_calculate_ecc_kw(nand, s->page + i, ecc); + ecc += 10; + } + } + else if (NULL != s->oob) + { + fileio_read(&s->fileio, s->oob_size, s->oob, &one_read); + if (one_read < s->oob_size) + memset(s->oob + one_read, 0xff, s->oob_size - one_read); + total_read += one_read; + } + return total_read; +} + COMMAND_HANDLER(handle_nand_write_command) { uint32_t offset; ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 26 +++ src/flash/nand.c | 477 ++++++++++++++++++++++++++++++--------------------- src/helper/fileio.h | 1 + 3 files changed, 305 insertions(+), 199 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Zach W. <zw...@us...> - 2009-11-16 10:27:38
|
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 45527ee82c9e7c93b29b79f01f52d663960649c2 (commit) via d6348d4316ea71b9ad232fd63a0a39ed84d8e8b7 (commit) via 21b452cf675bd3bb307c0d58c6cc45a028d7df3a (commit) via d8d8c5d8c3e47a38059952c3407bb819c5c33d05 (commit) via d09e308130619f8667b6f08399cfc7d16dddab36 (commit) via e4ee891759b08d3edb258b34f00b4ae8e3298d06 (commit) via d50caa97d17187ed96746cc1527e5dbf57d4a81a (commit) via 5a43bd2e185bf469561a8370dcd543cc4813c33f (commit) via 82fc2f9628e0f1dbd9010e0146ff63832e4a77a1 (commit) from b695cb75220100cd9bbfaec5bd1740958454130d (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 45527ee82c9e7c93b29b79f01f52d663960649c2 Author: Zachary T Welch <zw...@su...> Date: Mon Nov 16 01:10:46 2009 -0800 binarybuffer: add API documentation Adds Doxygen documentation for a number of the binarybuffer APIs, including "unexpected" behavior exposed during review on the list. diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index e8931ab..9e0cc9b 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -29,6 +29,15 @@ * Support functions to access arbitrary bits in a byte array */ +/** + * Sets @c num bits in @c _buffer, starting at the @c first bit, + * using the bits in @c value. This routine fast-paths writes + * of little-endian, byte-aligned, 32-bit words. + * @param _buffer The buffer whose bits will be set. + * @param first The bit offset in @c _buffer to start writing (0-31). + * @param num The number of bits from @c value to copy (1-32). + * @param value Up to 32 bits that will be copied to _buffer. + */ static inline void buf_set_u32(void *_buffer, unsigned first, unsigned num, uint32_t value) { @@ -48,6 +57,15 @@ static inline void buf_set_u32(void *_buffer, } } } +/** + * Retrieves @c num bits from @c _buffer, starting at the @c first bit, + * returning the bits in a 32-bit word. This routine fast-paths reads + * of little-endian, byte-aligned, 32-bit words. + * @param _buffer The buffer whose bits will be read. + * @param first The bit offset in @c _buffer to start reading (0-31). + * @param num The number of bits from @c _buffer to read (1-32). + * @returns Up to 32-bits that were read from @c _buffer. + */ static inline uint32_t buf_get_u32(const void *_buffer, unsigned first, unsigned num) { @@ -68,16 +86,36 @@ static inline uint32_t buf_get_u32(const void *_buffer, } } -/// flip_u32 inverts the bit order inside a 32-bit word (31..0 -> 0..31) -uint32_t flip_u32(uint32_t value, unsigned num); +/** + * Inverts the ordering of bits inside a 32-bit word (e.g. 31..0 -> 0..31). + * This routine can be used to flip smaller data types by using smaller + * values for @c width. + * @param value The word to flip. + * @param width The number of bits in value (2-32). + * @returns A 32-bit word with @c value in reversed bit-order. + */ +uint32_t flip_u32(uint32_t value, unsigned width); bool buf_cmp(const void *buf1, const void *buf2, unsigned size); bool buf_cmp_mask(const void *buf1, const void *buf2, const void *mask, unsigned size); +/** + * Copies @c size bits out of @c from and into @c to. Any extra + * bits in the final byte will be set to zero. + * @param from The buffer to copy into @c to. + * @param to The buffer that will receive the copy of @c from. + * @param size The number of bits to copy. + */ void* buf_cpy(const void *from, void *to, unsigned size); -void* buf_set_ones(void *buf, unsigned count); +/** + * Set the contents of @c buf with @c count bits, all set to 1. + * @param buf The buffer to fill with ones. + * @param size The number of bits. + * @returns The original buffer (@c buf). + */ +void* buf_set_ones(void *buf, unsigned size); void* buf_set_buf(const void *src, unsigned src_start, void *dst, unsigned dst_start, unsigned len); commit d6348d4316ea71b9ad232fd63a0a39ed84d8e8b7 Author: Zachary T Welch <zw...@su...> Date: Sat Nov 14 06:26:55 2009 -0800 improve inline binarybuffer helpers Use void*, unsigned, and bool types with inline helpers. diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index 9397fcf..e8931ab 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -29,10 +29,10 @@ * Support functions to access arbitrary bits in a byte array */ -/* inlining this will help show what fn that is taking time during profiling. */ -static inline void buf_set_u32(uint8_t* buffer, - unsigned int first, unsigned int num, uint32_t value) +static inline void buf_set_u32(void *_buffer, + unsigned first, unsigned num, uint32_t value) { + char *buffer = (char *)_buffer; if ((num == 32) && (first == 0)) { buffer[3] = (value >> 24) & 0xff; buffer[2] = (value >> 16) & 0xff; @@ -48,9 +48,10 @@ static inline void buf_set_u32(uint8_t* buffer, } } } -static inline uint32_t buf_get_u32(const uint8_t* buffer, - unsigned int first, unsigned int num) +static inline uint32_t buf_get_u32(const void *_buffer, + unsigned first, unsigned num) { + char *buffer = (char *)_buffer; if ((num == 32) && (first == 0)) { return (((uint32_t)buffer[3]) << 24) | (((uint32_t)buffer[2]) << 16) | @@ -68,7 +69,7 @@ static inline uint32_t buf_get_u32(const uint8_t* buffer, } /// flip_u32 inverts the bit order inside a 32-bit word (31..0 -> 0..31) -uint32_t flip_u32(uint32_t value, unsigned int num); +uint32_t flip_u32(uint32_t value, unsigned num); bool buf_cmp(const void *buf1, const void *buf2, unsigned size); bool buf_cmp_mask(const void *buf1, const void *buf2, @@ -88,7 +89,7 @@ char* buf_to_str(const void *buf, unsigned size, unsigned radix); #define CEIL(m, n) (((m) + (n) - 1) / (n)) /* read a uint32_t from a buffer in target memory endianness */ -static inline uint32_t fast_target_buffer_get_u32(const uint8_t *p, int le) +static inline uint32_t fast_target_buffer_get_u32(const void *p, bool le) { return le ? le_to_h_u32(p) : be_to_h_u32(p); } commit 21b452cf675bd3bb307c0d58c6cc45a028d7df3a Author: Zachary T Welch <zw...@su...> Date: Sat Nov 14 10:44:37 2009 -0800 improve buf_set_buf helper Use void * and unsigned types for buffer and their sizes. Allows it to be used with more than uint8_t * without casts. diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c index 8275d12..53ad4d3 100644 --- a/src/helper/binarybuffer.c +++ b/src/helper/binarybuffer.c @@ -128,11 +128,14 @@ void* buf_set_ones(void *_buf, unsigned size) return buf; } -uint8_t* buf_set_buf(const uint8_t *src, int src_start, uint8_t *dst, int dst_start, int len) +void* buf_set_buf(const void *_src, unsigned src_start, + void *_dst, unsigned dst_start, unsigned len) { - int src_idx = src_start, dst_idx = dst_start; + const uint8_t *src = _src; + uint8_t *dst = _dst; - for (int i = 0; i < len; i++) + unsigned src_idx = src_start, dst_idx = dst_start; + for (unsigned i = 0; i < len; i++) { if (((src[src_idx / 8] >> (src_idx % 8)) & 1) == 1) dst[dst_idx / 8] |= 1 << (dst_idx % 8); diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index b988e40..9397fcf 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -78,8 +78,8 @@ void* buf_cpy(const void *from, void *to, unsigned size); void* buf_set_ones(void *buf, unsigned count); -uint8_t* buf_set_buf(const uint8_t *src, int src_start, - uint8_t *dst, int dst_start, int len); +void* buf_set_buf(const void *src, unsigned src_start, + void *dst, unsigned dst_start, unsigned len); int str_to_buf(const char *str, unsigned len, void *bin_buf, unsigned buf_size, unsigned radix); commit d8d8c5d8c3e47a38059952c3407bb819c5c33d05 Author: Zachary T Welch <zw...@su...> Date: Sat Nov 14 10:41:35 2009 -0800 improve buf_set_ones Use memset instead of loop. Improve types, using void * and unsigned. diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c index e5f9854..8275d12 100644 --- a/src/helper/binarybuffer.c +++ b/src/helper/binarybuffer.c @@ -113,17 +113,17 @@ bool buf_cmp_mask(const void *_buf1, const void *_buf2, } -uint8_t* buf_set_ones(uint8_t *buf, int count) +void* buf_set_ones(void *_buf, unsigned size) { - for (unsigned i = 0, num_bytes = CEIL(count, 8); i < num_bytes; i++) - { - if (count >= 8) - buf[i] = 0xff; - else - buf[i] = (1 << count) - 1; + uint8_t *buf = _buf; + if (!buf) + return NULL; - count -= 8; - } + memset(buf, 0xff, size / 8); + + unsigned trailing_bits = size % 8; + if (trailing_bits) + buf[size / 8] = (1 << trailing_bits) - 1; return buf; } diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index 07a5862..b988e40 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -76,7 +76,8 @@ bool buf_cmp_mask(const void *buf1, const void *buf2, void* buf_cpy(const void *from, void *to, unsigned size); -uint8_t* buf_set_ones(uint8_t *buf, int count); +void* buf_set_ones(void *buf, unsigned count); + uint8_t* buf_set_buf(const uint8_t *src, int src_start, uint8_t *dst, int dst_start, int len); commit d09e308130619f8667b6f08399cfc7d16dddab36 Author: Zachary T Welch <zw...@su...> Date: Sat Nov 14 10:36:57 2009 -0800 improve buf_cpy helper Use memcpy for bulk of copy, improve final byte handling. Improve types by using void * for buffers and unsigned for size. diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c index 865d3a3..e5f9854 100644 --- a/src/helper/binarybuffer.c +++ b/src/helper/binarybuffer.c @@ -48,21 +48,22 @@ const unsigned char bit_reverse_table256[] = }; -uint8_t* buf_cpy(const uint8_t *from, uint8_t *to, int size) +void* buf_cpy(const void *from, void *_to, unsigned size) { - if (from == NULL) + if (NULL == from || NULL == _to) return NULL; - for (unsigned i = 0, num_bytes = CEIL(size, 8); i < num_bytes; i++) - to[i] = from[i]; + // copy entire buffer + memcpy(_to, from, CEIL(size, 8)); /* mask out bits that don't belong to the buffer */ - if (size % 8) + unsigned trailing_bits = size % 8; + if (trailing_bits) { - to[size / 8] &= (0xff >> (8 - (size % 8))); + uint8_t *to = _to; + to[size / 8] &= (1 << trailing_bits) - 1; } - - return to; + return _to; } static bool buf_cmp_masked(uint8_t a, uint8_t b, uint8_t m) diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index a51c2e5..07a5862 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -73,7 +73,8 @@ uint32_t flip_u32(uint32_t value, unsigned int num); bool buf_cmp(const void *buf1, const void *buf2, unsigned size); bool buf_cmp_mask(const void *buf1, const void *buf2, const void *mask, unsigned size); -uint8_t* buf_cpy(const uint8_t *from, uint8_t *to, int size); + +void* buf_cpy(const void *from, void *to, unsigned size); uint8_t* buf_set_ones(uint8_t *buf, int count); uint8_t* buf_set_buf(const uint8_t *src, int src_start, commit e4ee891759b08d3edb258b34f00b4ae8e3298d06 Author: Zachary T Welch <zw...@su...> Date: Sat Nov 14 10:27:34 2009 -0800 improve buf_cmp and buf_cmp_mask helpers Rewrite buf_cmp to use memcpy for bulk of comparison. Add static helper to perform comparison of trailing byte, which uses another static helper to perform a maksed comparison. The masked comparison helper is used by the buf_cmp_mask to simplify its loop. Improve types to use void *, unsigned, and return bool. diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c index 0def948..865d3a3 100644 --- a/src/helper/binarybuffer.c +++ b/src/helper/binarybuffer.c @@ -65,52 +65,53 @@ uint8_t* buf_cpy(const uint8_t *from, uint8_t *to, int size) return to; } -int buf_cmp(const uint8_t *buf1, const uint8_t *buf2, int size) +static bool buf_cmp_masked(uint8_t a, uint8_t b, uint8_t m) { - if (!buf1 || !buf2) - return 1; + return (a & m) != (b & m); +} +static bool buf_cmp_trailing(uint8_t a, uint8_t b, uint8_t m, unsigned trailing) +{ + uint8_t mask = (1 << trailing) - 1; + return buf_cmp_masked(a, b, mask & m); +} - for (unsigned i = 0, num_bytes = CEIL(size, 8); i < num_bytes; i++) - { - /* last byte */ - /* mask out bits that don't really belong to the buffer if size isn't a multiple of 8 bits */ - if ((size % 8) && (i == num_bytes -1)) - { - if ((buf1[i] & ((1 << (size % 8)) - 1)) != (buf2[i] & ((1 << (size % 8)) - 1))) - return 1; - } - else - { - if (buf1[i] != buf2[i]) - return 1; - } - } +bool buf_cmp(const void *_buf1, const void *_buf2, unsigned size) +{ + if (!_buf1 || !_buf2) + return _buf1 != _buf2; - return 0; + unsigned last = size / 8; + if (memcmp(_buf1, _buf2, last) != 0) + return false; + + unsigned trailing = size % 8; + if (!trailing) + return false; + + const uint8_t *buf1 = _buf1, *buf2 = _buf2; + return buf_cmp_trailing(buf1[last], buf2[last], 0xff, trailing); } -int buf_cmp_mask(const uint8_t *buf1, const uint8_t *buf2, const uint8_t *mask, int size) +bool buf_cmp_mask(const void *_buf1, const void *_buf2, + const void *_mask, unsigned size) { - for (unsigned i = 0, num_bytes = CEIL(size, 8); i < num_bytes; i++) + if (!_buf1 || !_buf2) + return _buf1 != _buf2 || _buf1 != _mask; + + const uint8_t *buf1 = _buf1, *buf2 = _buf2, *mask = _mask; + unsigned last = size / 8; + for (unsigned i = 0; i < last; i++) { - /* last byte */ - /* mask out bits that don't really belong to the buffer if size isn't a multiple of 8 bits */ - if ((size % 8) && (i == num_bytes -1)) - { - if ((buf1[i] & ((1 << (size % 8)) - 1) & mask[i]) != - (buf2[i] & ((1 << (size % 8)) - 1) & mask[i])) - return 1; - } - else - { - if ((buf1[i] & mask[i]) != (buf2[i] & mask[i])) - return 1; - } + if (buf_cmp_masked(buf1[i], buf2[i], mask[i])) + return true; } - - return 0; + unsigned trailing = size % 8; + if (!trailing) + return false; + return buf_cmp_trailing(buf1[last], buf2[last], mask[last], trailing); } + uint8_t* buf_set_ones(uint8_t *buf, int count) { for (unsigned i = 0, num_bytes = CEIL(count, 8); i < num_bytes; i++) diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index 4905007..a51c2e5 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -70,9 +70,9 @@ static inline uint32_t buf_get_u32(const uint8_t* buffer, /// flip_u32 inverts the bit order inside a 32-bit word (31..0 -> 0..31) uint32_t flip_u32(uint32_t value, unsigned int num); -int buf_cmp(const uint8_t *buf1, const uint8_t *buf2, int size); -int buf_cmp_mask(const uint8_t *buf1, const uint8_t *buf2, - const uint8_t *mask, int size); +bool buf_cmp(const void *buf1, const void *buf2, unsigned size); +bool buf_cmp_mask(const void *buf1, const void *buf2, + const void *mask, unsigned size); uint8_t* buf_cpy(const uint8_t *from, uint8_t *to, int size); uint8_t* buf_set_ones(uint8_t *buf, int count); commit d50caa97d17187ed96746cc1527e5dbf57d4a81a Author: Zachary T Welch <zw...@su...> Date: Sat Nov 14 10:14:04 2009 -0800 improve str_to_buf and buf_to_str helpers Improve types: use void * and unsigned. Move all variables to point of first use. Move radix guessing logic to new str_radix_guess helper. diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c index 95e084e..0def948 100644 --- a/src/helper/binarybuffer.c +++ b/src/helper/binarybuffer.c @@ -169,43 +169,36 @@ int ceil_f_to_u32(float x) return y; } -char* buf_to_str(const uint8_t *buf, int buf_len, int radix) +char* buf_to_str(const void *_buf, unsigned buf_len, unsigned radix) { - const char *DIGITS = "0123456789ABCDEF"; float factor; - char *str; - int str_len; - int b256_len = CEIL(buf_len, 8); - uint32_t tmp; - - int j; /* base-256 digits */ - int i; /* output digits (radix) */ - - if (radix == 16) - { + switch (radix) { + case 16: factor = 2.0; /* log(256) / log(16) = 2.0 */ - } - else if (radix == 10) - { + break; + case 10: factor = 2.40824; /* log(256) / log(10) = 2.40824 */ - } - else if (radix == 8) - { + break; + case 8: factor = 2.66667; /* log(256) / log(8) = 2.66667 */ - } - else + break; + default: return NULL; + } - str_len = ceil_f_to_u32(CEIL(buf_len, 8) * factor); - str = calloc(str_len + 1, 1); + unsigned str_len = ceil_f_to_u32(CEIL(buf_len, 8) * factor); + char *str = calloc(str_len + 1, 1); - for (i = b256_len - 1; i >= 0; i--) + const uint8_t *buf = _buf; + int b256_len = CEIL(buf_len, 8); + for (int i = b256_len - 1; i >= 0; i--) { - tmp = buf[i]; - if ((i == (buf_len / 8)) && (buf_len % 8)) + uint32_t tmp = buf[i]; + if (((unsigned)i == (buf_len / 8)) && (buf_len % 8)) tmp &= (0xff >> (8 - (buf_len % 8))); - for (j = str_len; j > 0; j--) + /* base-256 digits */ + for (unsigned j = str_len; j > 0; j--) { tmp += (uint32_t)str[j-1] * 256; str[j-1] = (uint8_t)(tmp % radix); @@ -213,44 +206,49 @@ char* buf_to_str(const uint8_t *buf, int buf_len, int radix) } } - for (j = 0; j < str_len; j++) + const char *DIGITS = "0123456789ABCDEF"; + for (unsigned j = 0; j < str_len; j++) str[j] = DIGITS[(int)str[j]]; return str; } -int str_to_buf(const char *str, int str_len, uint8_t *buf, int buf_len, int radix) +/// identify radix, and skip radix-prefix (0, 0x or 0X) +static void str_radix_guess(const char **_str, unsigned *_str_len, + unsigned *_radix) { - char *charbuf; - uint32_t tmp; - float factor; - uint8_t *b256_buf; - int b256_len; - - int j; /* base-256 digits */ - int i; /* input digits (ASCII) */ - - if (radix == 0) + unsigned radix = *_radix; + if (0 != radix) + return; + const char *str = *_str; + unsigned str_len = *_str_len; + if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) { - /* identify radix, and skip radix-prefix (0, 0x or 0X) */ - if ((str[0] == '0') && (str[1] && ((str[1] == 'x') || (str[1] == 'X')))) - { - radix = 16; - str += 2; - str_len -= 2; - } - else if ((str[0] == '0') && (str_len != 1)) - { - radix = 8; - str += 1; - str_len -= 1; - } - else - { - radix = 10; - } + radix = 16; + str += 2; + str_len -= 2; } + else if ((str[0] == '0') && (str_len != 1)) + { + radix = 8; + str += 1; + str_len -= 1; + } + else + { + radix = 10; + } + *_str = str; + *_str_len = str_len; + *_radix = radix; +} + +int str_to_buf(const char *str, unsigned str_len, + void *_buf, unsigned buf_len, unsigned radix) +{ + str_radix_guess(&str, &str_len, &radix); + float factor; if (radix == 16) factor = 0.5; /* log(16) / log(256) = 0.5 */ else if (radix == 10) @@ -261,18 +259,20 @@ int str_to_buf(const char *str, int str_len, uint8_t *buf, int buf_len, int radi return 0; /* copy to zero-terminated buffer */ - charbuf = malloc(str_len + 1); + char *charbuf = malloc(str_len + 1); memcpy(charbuf, str, str_len); charbuf[str_len] = '\0'; /* number of digits in base-256 notation */ - b256_len = ceil_f_to_u32(str_len * factor); - b256_buf = calloc(b256_len, 1); + unsigned b256_len = ceil_f_to_u32(str_len * factor); + uint8_t *b256_buf = calloc(b256_len, 1); /* go through zero terminated buffer */ + /* input digits (ASCII) */ + unsigned i; for (i = 0; charbuf[i]; i++) { - tmp = charbuf[i]; + uint32_t tmp = charbuf[i]; if ((tmp >= '0') && (tmp <= '9')) tmp = (tmp - '0'); else if ((tmp >= 'a') && (tmp <= 'f')) @@ -281,10 +281,11 @@ int str_to_buf(const char *str, int str_len, uint8_t *buf, int buf_len, int radi tmp = (tmp - 'A' + 10); else continue; /* skip characters other than [0-9,a-f,A-F] */ - if (tmp >= (uint32_t)radix) + if (tmp >= radix) continue; /* skip digits invalid for the current radix */ - for (j = 0; j < b256_len; j++) + /* base-256 digits */ + for (unsigned j = 0; j < b256_len; j++) { tmp += (uint32_t)b256_buf[j] * radix; b256_buf[j] = (uint8_t)(tmp & 0xFF); @@ -293,7 +294,8 @@ int str_to_buf(const char *str, int str_len, uint8_t *buf, int buf_len, int radi } - for (j = 0; j < CEIL(buf_len, 8); j++) + uint8_t *buf = _buf; + for (unsigned j = 0; j < CEIL(buf_len, 8); j++) { if (j < b256_len) buf[j] = b256_buf[j]; diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index 400cbbe..4905007 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -79,9 +79,9 @@ uint8_t* buf_set_ones(uint8_t *buf, int count); uint8_t* buf_set_buf(const uint8_t *src, int src_start, uint8_t *dst, int dst_start, int len); -int str_to_buf(const char *str, int len, - uint8_t *bin_buf, int buf_size, int radix); -char* buf_to_str(const uint8_t *buf, int size, int radix); +int str_to_buf(const char *str, unsigned len, + void *bin_buf, unsigned buf_size, unsigned radix); +char* buf_to_str(const void *buf, unsigned size, unsigned radix); #define CEIL(m, n) (((m) + (n) - 1) / (n)) commit 5a43bd2e185bf469561a8370dcd543cc4813c33f Author: Zachary T Welch <zw...@su...> Date: Sat Nov 14 08:19:24 2009 -0800 binarybuffer: move variables to point of first use Reduce some noise from subsequent patches. diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c index d813ecf..95e084e 100644 --- a/src/helper/binarybuffer.c +++ b/src/helper/binarybuffer.c @@ -50,13 +50,10 @@ const unsigned char bit_reverse_table256[] = uint8_t* buf_cpy(const uint8_t *from, uint8_t *to, int size) { - unsigned int num_bytes = CEIL(size, 8); - unsigned int i; - if (from == NULL) return NULL; - for (i = 0; i < num_bytes; i++) + for (unsigned i = 0, num_bytes = CEIL(size, 8); i < num_bytes; i++) to[i] = from[i]; /* mask out bits that don't belong to the buffer */ @@ -70,13 +67,10 @@ uint8_t* buf_cpy(const uint8_t *from, uint8_t *to, int size) int buf_cmp(const uint8_t *buf1, const uint8_t *buf2, int size) { - int num_bytes = CEIL(size, 8); - int i; - if (!buf1 || !buf2) return 1; - for (i = 0; i < num_bytes; i++) + for (unsigned i = 0, num_bytes = CEIL(size, 8); i < num_bytes; i++) { /* last byte */ /* mask out bits that don't really belong to the buffer if size isn't a multiple of 8 bits */ @@ -97,10 +91,7 @@ int buf_cmp(const uint8_t *buf1, const uint8_t *buf2, int size) int buf_cmp_mask(const uint8_t *buf1, const uint8_t *buf2, const uint8_t *mask, int size) { - int num_bytes = CEIL(size, 8); - int i; - - for (i = 0; i < num_bytes; i++) + for (unsigned i = 0, num_bytes = CEIL(size, 8); i < num_bytes; i++) { /* last byte */ /* mask out bits that don't really belong to the buffer if size isn't a multiple of 8 bits */ @@ -122,10 +113,7 @@ int buf_cmp_mask(const uint8_t *buf1, const uint8_t *buf2, const uint8_t *mask, uint8_t* buf_set_ones(uint8_t *buf, int count) { - int num_bytes = CEIL(count, 8); - int i; - - for (i = 0; i < num_bytes; i++) + for (unsigned i = 0, num_bytes = CEIL(count, 8); i < num_bytes; i++) { if (count >= 8) buf[i] = 0xff; @@ -141,9 +129,8 @@ uint8_t* buf_set_ones(uint8_t *buf, int count) uint8_t* buf_set_buf(const uint8_t *src, int src_start, uint8_t *dst, int dst_start, int len) { int src_idx = src_start, dst_idx = dst_start; - int i; - for (i = 0; i < len; i++) + for (int i = 0; i < len; i++) { if (((src[src_idx / 8] >> (src_idx % 8)) & 1) == 1) dst[dst_idx / 8] |= 1 << (dst_idx % 8); @@ -158,9 +145,7 @@ uint8_t* buf_set_buf(const uint8_t *src, int src_start, uint8_t *dst, int dst_st uint32_t flip_u32(uint32_t value, unsigned int num) { - uint32_t c; - - c = (bit_reverse_table256[value & 0xff] << 24) | + uint32_t c = (bit_reverse_table256[value & 0xff] << 24) | (bit_reverse_table256[(value >> 8) & 0xff] << 16) | (bit_reverse_table256[(value >> 16) & 0xff] << 8) | (bit_reverse_table256[(value >> 24) & 0xff]); @@ -173,12 +158,10 @@ uint32_t flip_u32(uint32_t value, unsigned int num) int ceil_f_to_u32(float x) { - uint32_t y; - if (x < 0) /* return zero for negative numbers */ return 0; - y = x; /* cut off fraction */ + uint32_t y = x; /* cut off fraction */ if ((x - y) > 0.0) /* if there was a fractional part, increase by one */ y++; diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index 60077b3..400cbbe 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -39,8 +39,7 @@ static inline void buf_set_u32(uint8_t* buffer, buffer[1] = (value >> 8) & 0xff; buffer[0] = (value >> 0) & 0xff; } else { - unsigned int i; - for (i = first; i < first + num; i++) + for (unsigned i = first; i < first + num; i++) { if (((value >> (i - first)) & 1) == 1) buffer[i / 8] |= 1 << (i % 8); @@ -59,8 +58,7 @@ static inline uint32_t buf_get_u32(const uint8_t* buffer, (((uint32_t)buffer[0]) << 0); } else { uint32_t result = 0; - unsigned int i; - for (i = first; i < first + num; i++) + for (unsigned i = first; i < first + num; i++) { if (((buffer[i / 8] >> (i % 8)) & 1) == 1) result |= 1 << (i - first); commit 82fc2f9628e0f1dbd9010e0146ff63832e4a77a1 Author: Zachary T Welch <zw...@su...> Date: Sat Nov 14 08:10:22 2009 -0800 binarybuffer: fix whitespace related issues Add inter-operator whitespace. Improve existing documentation. diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c index fdfcf71..d813ecf 100644 --- a/src/helper/binarybuffer.c +++ b/src/helper/binarybuffer.c @@ -145,10 +145,10 @@ uint8_t* buf_set_buf(const uint8_t *src, int src_start, uint8_t *dst, int dst_st for (i = 0; i < len; i++) { - if (((src[src_idx/8] >> (src_idx % 8)) & 1) == 1) - dst[dst_idx/8] |= 1 << (dst_idx%8); + if (((src[src_idx / 8] >> (src_idx % 8)) & 1) == 1) + dst[dst_idx / 8] |= 1 << (dst_idx % 8); else - dst[dst_idx/8] &= ~(1 << (dst_idx%8)); + dst[dst_idx / 8] &= ~(1 << (dst_idx % 8)); dst_idx++; src_idx++; } diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h index 2399a6e..60077b3 100644 --- a/src/helper/binarybuffer.h +++ b/src/helper/binarybuffer.h @@ -25,38 +25,34 @@ #include "types.h" -/* support functions to access arbitrary bits in a byte array - * flip_u32 inverses the bit order inside a 32-bit word (31..0 -> 0..31) +/** @file + * Support functions to access arbitrary bits in a byte array */ /* inlining this will help show what fn that is taking time during profiling. */ static inline void buf_set_u32(uint8_t* buffer, unsigned int first, unsigned int num, uint32_t value) { - if ((num == 32) && (first == 0)) - { - buffer[3]=(value >> 24)&0xff; - buffer[2]=(value >> 16)&0xff; - buffer[1]=(value >> 8)&0xff; - buffer[0]=(value >> 0)&0xff; - } else - { + if ((num == 32) && (first == 0)) { + buffer[3] = (value >> 24) & 0xff; + buffer[2] = (value >> 16) & 0xff; + buffer[1] = (value >> 8) & 0xff; + buffer[0] = (value >> 0) & 0xff; + } else { unsigned int i; - for (i = first; i < first + num; i++) { - if (((value >> (i-first))&1) == 1) - buffer[i/8] |= 1 << (i%8); + if (((value >> (i - first)) & 1) == 1) + buffer[i / 8] |= 1 << (i % 8); else - buffer[i/8] &= ~(1 << (i%8)); + buffer[i / 8] &= ~(1 << (i % 8)); } } } static inline uint32_t buf_get_u32(const uint8_t* buffer, unsigned int first, unsigned int num) { - if ((num == 32) && (first == 0)) - { + if ((num == 32) && (first == 0)) { return (((uint32_t)buffer[3]) << 24) | (((uint32_t)buffer[2]) << 16) | (((uint32_t)buffer[1]) << 8) | @@ -64,17 +60,16 @@ static inline uint32_t buf_get_u32(const uint8_t* buffer, } else { uint32_t result = 0; unsigned int i; - for (i = first; i < first + num; i++) { - if (((buffer[i/8]>>(i%8))&1) == 1) - result |= 1 << (i-first); + if (((buffer[i / 8] >> (i % 8)) & 1) == 1) + result |= 1 << (i - first); } - return result; } } +/// flip_u32 inverts the bit order inside a 32-bit word (31..0 -> 0..31) uint32_t flip_u32(uint32_t value, unsigned int num); int buf_cmp(const uint8_t *buf1, const uint8_t *buf2, int size); ----------------------------------------------------------------------- Summary of changes: src/helper/binarybuffer.c | 262 ++++++++++++++++++++++----------------------- src/helper/binarybuffer.h | 116 +++++++++++++------- 2 files changed, 201 insertions(+), 177 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: David B. <dbr...@us...> - 2009-11-16 09:35:50
|
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 b695cb75220100cd9bbfaec5bd1740958454130d (commit) via 8193f17c3aeb948ca8f70ed3361e8b2bccefffed (commit) via 1186f7efa72a86a7000dce60b090bd4f822cdceb (commit) via db094c2e60176b3c63ce788159b04a7024ad1010 (commit) via aa7c449600d6f6d634f587de6091421a1a877af5 (commit) from 5d1a9033ab89b017c95e79590d76abbfa61f7512 (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 b695cb75220100cd9bbfaec5bd1740958454130d Author: David Brownell <dbr...@us...> Date: Mon Nov 16 00:35:24 2009 -0800 #include "target.h" less wildly Don't include "target.h" from more headers than necessary. This avoids needless interdependencies and duplicated include paths. Don't needlessly include it in source files, either. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/ecosboard.c b/src/ecosboard.c index 95d41cb..0cbba3e 100644 --- a/src/ecosboard.c +++ b/src/ecosboard.c @@ -26,7 +26,6 @@ #include "configuration.h" #include "xsvf.h" #include "svf.h" -#include "target.h" #include "nand.h" #include "pld.h" diff --git a/src/flash/at91sam3.c b/src/flash/at91sam3.c index 0f2be3c..4507888 100644 --- a/src/flash/at91sam3.c +++ b/src/flash/at91sam3.c @@ -62,7 +62,6 @@ #include <stddef.h> #include "types.h" #include "flash.h" -#include "target.h" #include "membuf.h" #include "at91sam3.h" #include "time_support.h" diff --git a/src/flash/lpc3180_nand_controller.h b/src/flash/lpc3180_nand_controller.h index b965be9..0891ced 100644 --- a/src/flash/lpc3180_nand_controller.h +++ b/src/flash/lpc3180_nand_controller.h @@ -20,8 +20,6 @@ #ifndef LPC3180_NAND_CONTROLLER_H #define LPC3180_NAND_CONTROLLER_H -#include "target.h" - enum lpc3180_selected_controller { LPC3180_NO_CONTROLLER, diff --git a/src/flash/mflash.c b/src/flash/mflash.c index c2d04ca..49dc432 100644 --- a/src/flash/mflash.c +++ b/src/flash/mflash.c @@ -22,6 +22,7 @@ #endif #include "mflash.h" +#include "target.h" #include "time_support.h" #include "fileio.h" #include "log.h" diff --git a/src/flash/mflash.h b/src/flash/mflash.h index ed4a2cd..358d253 100644 --- a/src/flash/mflash.h +++ b/src/flash/mflash.h @@ -20,7 +20,7 @@ #ifndef _MFLASH_H #define _MFLASH_H -#include "target.h" +struct command_context; typedef unsigned long mg_io_uint32; typedef unsigned short mg_io_uint16; diff --git a/src/openocd.c b/src/openocd.c index e35a0ae..4c07511 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -32,7 +32,6 @@ #include "configuration.h" #include "xsvf.h" #include "svf.h" -#include "target.h" #include "nand.h" #include "pld.h" #include "mflash.h" diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 21db296..f6b44cd 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -27,12 +27,12 @@ #include "config.h" #endif -#include "gdb_server.h" #include "breakpoints.h" #include "target_request.h" #include "register.h" #include "server.h" #include "flash.h" +#include "gdb_server.h" #include "image.h" #include "jtag.h" diff --git a/src/server/gdb_server.h b/src/server/gdb_server.h index 4513e8a..a8e8dad 100644 --- a/src/server/gdb_server.h +++ b/src/server/gdb_server.h @@ -26,8 +26,6 @@ #ifndef GDB_SERVER_H #define GDB_SERVER_H -#include "target.h" - struct image; #define GDB_BUFFER_SIZE 16384 diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h index 9aac806..a78193c 100644 --- a/src/target/arm_adi_v5.h +++ b/src/target/arm_adi_v5.h @@ -23,7 +23,6 @@ #ifndef ARM_ADI_V5_H #define ARM_ADI_V5_H -#include "target.h" #include "arm_jtag.h" #define DAP_IR_DPACC 0xA diff --git a/src/target/armv4_5_mmu.c b/src/target/armv4_5_mmu.c index d84da48..4651960 100644 --- a/src/target/armv4_5_mmu.c +++ b/src/target/armv4_5_mmu.c @@ -22,6 +22,7 @@ #endif #include "log.h" +#include "target.h" #include "armv4_5_mmu.h" diff --git a/src/target/armv4_5_mmu.h b/src/target/armv4_5_mmu.h index bbe50c6..6b9ed34 100644 --- a/src/target/armv4_5_mmu.h +++ b/src/target/armv4_5_mmu.h @@ -21,7 +21,8 @@ #define ARMV4_5_MMU_H #include "armv4_5_cache.h" -#include "target.h" + +struct target; struct armv4_5_mmu_common { diff --git a/src/target/armv7a.c b/src/target/armv7a.c index 7b33053..7f2c387 100644 --- a/src/target/armv7a.c +++ b/src/target/armv7a.c @@ -25,7 +25,6 @@ #include "armv7a.h" #include "arm_disassembler.h" -#include "target.h" #include "register.h" #include "binarybuffer.h" #include "command.h" diff --git a/src/target/armv7a.h b/src/target/armv7a.h index facd150..a4be9e2 100644 --- a/src/target/armv7a.h +++ b/src/target/armv7a.h @@ -19,7 +19,6 @@ #ifndef ARMV7A_H #define ARMV7A_H -#include "target.h" #include "arm_adi_v5.h" #include "armv4_5.h" #include "armv4_5_mmu.h" diff --git a/src/target/armv7m.c b/src/target/armv7m.c index 7ccdf54..d8718f9 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -35,6 +35,7 @@ #endif #include "breakpoints.h" +#include "target.h" #include "armv7m.h" #include "algorithm.h" #include "register.h" diff --git a/src/target/cortex_a8.h b/src/target/cortex_a8.h index 230008a..393a310 100644 --- a/src/target/cortex_a8.h +++ b/src/target/cortex_a8.h @@ -29,7 +29,6 @@ #ifndef CORTEX_A8_H #define CORTEX_A8_H -#include "target.h" #include "armv7a.h" extern char* cortex_a8_state_strings[]; diff --git a/src/target/target_request.c b/src/target/target_request.c index 283ce55..7215155 100644 --- a/src/target/target_request.c +++ b/src/target/target_request.c @@ -27,6 +27,7 @@ #include "config.h" #endif +#include "target.h" #include "target_request.h" #include "target_type.h" #include "binarybuffer.h" diff --git a/src/target/target_request.h b/src/target/target_request.h index cc9f3b9..e50c425 100644 --- a/src/target/target_request.h +++ b/src/target/target_request.h @@ -26,7 +26,8 @@ #ifndef TARGET_REQUEST_H #define TARGET_REQUEST_H -#include "target.h" +struct target; +struct command_context; typedef enum target_req_cmd { commit 8193f17c3aeb948ca8f70ed3361e8b2bccefffed Author: David Brownell <dbr...@us...> Date: Mon Nov 16 00:35:14 2009 -0800 target: no implicit #includes of "register.h" Same deal: "register.h" got needlessly included all over the place because of being in a few widely included headers. So take it out of the header files which included it, and put it in files which use it ... reduce needless interdependencies. Also, don't need that extra "types.h" inclusion. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/arm11.c b/src/target/arm11.c index cdeb420..46f332e 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -34,6 +34,7 @@ #include "time_support.h" #include "target_type.h" #include "algorithm.h" +#include "register.h" #if 0 diff --git a/src/target/arm720t.c b/src/target/arm720t.c index 7bfb97d..5d83517 100644 --- a/src/target/arm720t.c +++ b/src/target/arm720t.c @@ -27,6 +27,7 @@ #include "arm720t.h" #include "time_support.h" #include "target_type.h" +#include "register.h" /* diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index 76c79c3..780ccf9 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -37,6 +37,7 @@ #include "time_support.h" #include "arm_simulator.h" #include "algorithm.h" +#include "register.h" /** diff --git a/src/target/arm7tdmi.c b/src/target/arm7tdmi.c index 51fbddf..ba993ee 100644 --- a/src/target/arm7tdmi.c +++ b/src/target/arm7tdmi.c @@ -29,6 +29,7 @@ #include "arm7tdmi.h" #include "target_type.h" +#include "register.h" /* diff --git a/src/target/arm920t.c b/src/target/arm920t.c index fd61020..fca3743 100644 --- a/src/target/arm920t.c +++ b/src/target/arm920t.c @@ -24,6 +24,7 @@ #include "arm920t.h" #include "time_support.h" #include "target_type.h" +#include "register.h" /* diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c index 00b7865..f305390 100644 --- a/src/target/arm926ejs.c +++ b/src/target/arm926ejs.c @@ -27,6 +27,7 @@ #include "arm926ejs.h" #include "time_support.h" #include "target_type.h" +#include "register.h" /* diff --git a/src/target/arm9tdmi.c b/src/target/arm9tdmi.c index 1b7b645..8e8f4d6 100644 --- a/src/target/arm9tdmi.c +++ b/src/target/arm9tdmi.c @@ -29,6 +29,7 @@ #include "arm9tdmi.h" #include "target_type.h" +#include "register.h" /* diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h index 56b6206..9aac806 100644 --- a/src/target/arm_adi_v5.h +++ b/src/target/arm_adi_v5.h @@ -24,7 +24,6 @@ #define ARM_ADI_V5_H #include "target.h" -#include "register.h" #include "arm_jtag.h" #define DAP_IR_DPACC 0xA diff --git a/src/target/arm_simulator.c b/src/target/arm_simulator.c index 120d5b9..a353c13 100644 --- a/src/target/arm_simulator.c +++ b/src/target/arm_simulator.c @@ -28,6 +28,7 @@ #include "arm_disassembler.h" #include "arm_simulator.h" #include "binarybuffer.h" +#include "register.h" static uint32_t arm_shift(uint8_t shift, uint32_t Rm, diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index e6e0bd7..884f8f6 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -32,6 +32,7 @@ #include "arm_disassembler.h" #include "binarybuffer.h" #include "algorithm.h" +#include "register.h" char* armv4_5_core_reg_list[] = diff --git a/src/target/armv4_5.h b/src/target/armv4_5.h index 6c0b881..ea46488 100644 --- a/src/target/armv4_5.h +++ b/src/target/armv4_5.h @@ -26,7 +26,6 @@ #ifndef ARMV4_5_H #define ARMV4_5_H -#include "register.h" #include "target.h" #include "etm.h" diff --git a/src/target/armv7a.h b/src/target/armv7a.h index 625c3a9..facd150 100644 --- a/src/target/armv7a.h +++ b/src/target/armv7a.h @@ -19,7 +19,6 @@ #ifndef ARMV7A_H #define ARMV7A_H -#include "register.h" #include "target.h" #include "arm_adi_v5.h" #include "armv4_5.h" diff --git a/src/target/armv7m.c b/src/target/armv7m.c index 3f9e7f5..7ccdf54 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -37,6 +37,7 @@ #include "breakpoints.h" #include "armv7m.h" #include "algorithm.h" +#include "register.h" #define ARRAY_SIZE(x) ((int)(sizeof(x)/sizeof((x)[0]))) diff --git a/src/target/cortex_a8.c b/src/target/cortex_a8.c index 832efe9..f099be9 100644 --- a/src/target/cortex_a8.c +++ b/src/target/cortex_a8.c @@ -35,9 +35,8 @@ #include "breakpoints.h" #include "cortex_a8.h" -#include "armv7a.h" #include "armv4_5.h" - +#include "register.h" #include "target_request.h" #include "target_type.h" diff --git a/src/target/cortex_a8.h b/src/target/cortex_a8.h index f11d9dd..230008a 100644 --- a/src/target/cortex_a8.h +++ b/src/target/cortex_a8.h @@ -29,7 +29,6 @@ #ifndef CORTEX_A8_H #define CORTEX_A8_H -#include "register.h" #include "target.h" #include "armv7a.h" diff --git a/src/target/cortex_m3.c b/src/target/cortex_m3.c index 35ca5a5..e4949d2 100644 --- a/src/target/cortex_m3.c +++ b/src/target/cortex_m3.c @@ -36,6 +36,7 @@ #include "target_request.h" #include "target_type.h" #include "arm_disassembler.h" +#include "register.h" /* NOTE: most of this should work fine for the Cortex-M1 and diff --git a/src/target/cortex_m3.h b/src/target/cortex_m3.h index ed08323..759c2bc 100644 --- a/src/target/cortex_m3.h +++ b/src/target/cortex_m3.h @@ -26,7 +26,6 @@ #ifndef CORTEX_M3_H #define CORTEX_M3_H -#include "register.h" #include "target.h" #include "armv7m.h" diff --git a/src/target/embeddedice.c b/src/target/embeddedice.c index 292504b..4a7cf12 100644 --- a/src/target/embeddedice.c +++ b/src/target/embeddedice.c @@ -28,6 +28,7 @@ #endif #include "embeddedice.h" +#include "register.h" #define ARRAY_SIZE(x) ((int)(sizeof(x)/sizeof((x)[0]))) diff --git a/src/target/etb.c b/src/target/etb.c index e65cd5a..72474cd 100644 --- a/src/target/etb.c +++ b/src/target/etb.c @@ -23,6 +23,7 @@ #include "armv4_5.h" #include "etb.h" +#include "register.h" static char* etb_reg_list[] = diff --git a/src/target/etm.c b/src/target/etm.c index 4c94e6b..e70df10 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -25,6 +25,7 @@ #include "etb.h" #include "image.h" #include "arm_disassembler.h" +#include "register.h" /* diff --git a/src/target/feroceon.c b/src/target/feroceon.c index 03a5afc..8c05276 100644 --- a/src/target/feroceon.c +++ b/src/target/feroceon.c @@ -55,6 +55,8 @@ #include "arm926ejs.h" #include "arm966e.h" #include "target_type.h" +#include "register.h" + int feroceon_assert_reset(struct target *target) { diff --git a/src/target/mips32.c b/src/target/mips32.c index 6432a90..6ba433c 100644 --- a/src/target/mips32.c +++ b/src/target/mips32.c @@ -27,6 +27,7 @@ #endif #include "mips32.h" +#include "register.h" char* mips32_core_reg_list[] = diff --git a/src/target/mips32.h b/src/target/mips32.h index 7a4ba57..1ac682b 100644 --- a/src/target/mips32.h +++ b/src/target/mips32.h @@ -24,7 +24,6 @@ #define MIPS32_H #include "target.h" -#include "register.h" #include "mips32_pracc.h" diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c index fff401c..d1d3481 100644 --- a/src/target/mips_m4k.c +++ b/src/target/mips_m4k.c @@ -28,6 +28,7 @@ #include "mips_m4k.h" #include "mips32_dmaacc.h" #include "target_type.h" +#include "register.h" /* cli handling */ diff --git a/src/target/register.c b/src/target/register.c index f26835b..bb046a1 100644 --- a/src/target/register.c +++ b/src/target/register.c @@ -24,6 +24,7 @@ #include "config.h" #endif +#include "types.h" #include "register.h" #include "log.h" diff --git a/src/target/register.h b/src/target/register.h index c21edf6..84d2aaa 100644 --- a/src/target/register.h +++ b/src/target/register.h @@ -23,8 +23,6 @@ #ifndef REGISTER_H #define REGISTER_H -#include "types.h" - struct target; struct reg diff --git a/src/target/xscale.c b/src/target/xscale.c index d8977e2..30ca3bf 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -34,6 +34,7 @@ #include "arm_simulator.h" #include "arm_disassembler.h" #include "time_support.h" +#include "register.h" #include "image.h" commit 1186f7efa72a86a7000dce60b090bd4f822cdceb Author: David Brownell <dbr...@us...> Date: Mon Nov 16 00:35:11 2009 -0800 target: less implicit inclusion of "command.h" Lots of files still include it, often through needless duplicate inclusion of "log.h"; sigh. This cleans up the inclusion graph a bunch, so there are fewer inclusion paths, but it doesn't change much otherwise. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/ecosboard.c b/src/ecosboard.c index e38316c..95d41cb 100644 --- a/src/ecosboard.c +++ b/src/ecosboard.c @@ -21,18 +21,15 @@ #include "config.h" #endif -#include "log.h" #include "types.h" #include "jtag.h" #include "configuration.h" #include "xsvf.h" #include "svf.h" #include "target.h" -#include "flash.h" #include "nand.h" #include "pld.h" -#include "command.h" #include "server.h" #include "telnet_server.h" #include "gdb_server.h" diff --git a/src/flash/at91sam3.c b/src/flash/at91sam3.c index ad45bd5..0f2be3c 100644 --- a/src/flash/at91sam3.c +++ b/src/flash/at91sam3.c @@ -60,7 +60,6 @@ #include <stdio.h> #include <string.h> #include <stddef.h> -#include "log.h" #include "types.h" #include "flash.h" #include "target.h" diff --git a/src/helper/log.c b/src/helper/log.c index c690654..5a65c87 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -27,7 +27,6 @@ #include "config.h" #endif -#include "log.h" #include "time_support.h" // @todo the inclusion of server.h here is a layering violation #include "server.h" diff --git a/src/helper/options.c b/src/helper/options.c index 3ffc673..e26782f 100644 --- a/src/helper/options.c +++ b/src/helper/options.c @@ -25,7 +25,6 @@ #endif #include "configuration.h" -#include "log.h" // @todo the inclusion of server.h here is a layering violation #include "server.h" diff --git a/src/openocd.c b/src/openocd.c index 234b01c..e35a0ae 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -33,7 +33,6 @@ #include "xsvf.h" #include "svf.h" #include "target.h" -#include "flash.h" #include "nand.h" #include "pld.h" #include "mflash.h" diff --git a/src/target/arm_simulator.c b/src/target/arm_simulator.c index 46cd558..120d5b9 100644 --- a/src/target/arm_simulator.c +++ b/src/target/arm_simulator.c @@ -27,7 +27,6 @@ #include "armv4_5.h" #include "arm_disassembler.h" #include "arm_simulator.h" -#include "log.h" #include "binarybuffer.h" diff --git a/src/target/armv4_5.h b/src/target/armv4_5.h index 83b38b6..6c0b881 100644 --- a/src/target/armv4_5.h +++ b/src/target/armv4_5.h @@ -28,7 +28,6 @@ #include "register.h" #include "target.h" -#include "log.h" #include "etm.h" typedef enum armv4_5_mode diff --git a/src/target/armv7a.c b/src/target/armv7a.c index c94d3b0..7b33053 100644 --- a/src/target/armv7a.c +++ b/src/target/armv7a.c @@ -27,7 +27,6 @@ #include "target.h" #include "register.h" -#include "log.h" #include "binarybuffer.h" #include "command.h" diff --git a/src/target/armv7a.h b/src/target/armv7a.h index 5cdffd8..625c3a9 100644 --- a/src/target/armv7a.h +++ b/src/target/armv7a.h @@ -21,7 +21,6 @@ #include "register.h" #include "target.h" -#include "log.h" #include "arm_adi_v5.h" #include "armv4_5.h" #include "armv4_5_mmu.h" diff --git a/src/target/target.h b/src/target/target.h index 75bc4f0..51fb299 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -27,8 +27,8 @@ #define TARGET_H #include <stddef.h> - -#include "command.h" +#include "types.h" +#include "jim.h" struct reg; struct trace; @@ -230,7 +230,7 @@ enum target_event struct target_event_action { enum target_event event; - Jim_Obj *body; + struct Jim_Obj *body; int has_percent; struct target_event_action *next; }; commit db094c2e60176b3c63ce788159b04a7024ad1010 Author: David Brownell <dbr...@us...> Date: Mon Nov 16 00:35:05 2009 -0800 target: don't implicitly include "algorithm.h" Most files in the tree seem to have ended up including this, and *quite* needlessly ... only code implementing or using downloadable algorithms actually needs these declarations. So take it out of the header files which included it, and put it in files which use it ... reduce needless interdependencies. Also: "algorithm.h" doesn't need to include "types.h" again; it already comes from a different header. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/flash/aduc702x.c b/src/flash/aduc702x.c index c2a1884..643705c 100644 --- a/src/flash/aduc702x.c +++ b/src/flash/aduc702x.c @@ -27,6 +27,7 @@ #include "armv4_5.h" #include "binarybuffer.h" #include "time_support.h" +#include "algorithm.h" static int aduc702x_build_sector_list(struct flash_bank *bank); diff --git a/src/flash/arm_nandio.c b/src/flash/arm_nandio.c index 63eb041..81697fa 100644 --- a/src/flash/arm_nandio.c +++ b/src/flash/arm_nandio.c @@ -26,6 +26,7 @@ #include "arm_nandio.h" #include "armv4_5.h" +#include "algorithm.h" /* @@ -43,8 +44,8 @@ int arm_nandwrite(struct arm_nand_data *nand, uint8_t *data, int size) { struct target *target = nand->target; struct armv4_5_algorithm algo; - struct arm *armv4_5 = target->arch_info; - struct reg_param reg_params[3]; + struct arm *armv4_5 = target->arch_info; + struct reg_param reg_params[3]; uint32_t target_buf; uint32_t exit = 0; int retval; diff --git a/src/flash/cfi.c b/src/flash/cfi.c index 17f5c32..c0ad50d 100644 --- a/src/flash/cfi.c +++ b/src/flash/cfi.c @@ -27,6 +27,7 @@ #include "non_cfi.h" #include "armv4_5.h" #include "binarybuffer.h" +#include "algorithm.h" #define CFI_MAX_BUS_WIDTH 4 diff --git a/src/flash/ecos.c b/src/flash/ecos.c index 0525fbe..c12ed9d 100644 --- a/src/flash/ecos.c +++ b/src/flash/ecos.c @@ -24,6 +24,7 @@ #include "flash.h" #include "embeddedice.h" #include "image.h" +#include "algorithm.h" #if 0 diff --git a/src/flash/lpc2000.c b/src/flash/lpc2000.c index df1f082..09bb13f 100644 --- a/src/flash/lpc2000.c +++ b/src/flash/lpc2000.c @@ -29,6 +29,7 @@ #include "armv4_5.h" #include "armv7m.h" #include "binarybuffer.h" +#include "algorithm.h" /* flash programming support for NXP LPC17xx and LPC2xxx devices diff --git a/src/flash/lpc2900.c b/src/flash/lpc2900.c index 556a151..35f1507 100644 --- a/src/flash/lpc2900.c +++ b/src/flash/lpc2900.c @@ -27,6 +27,7 @@ #include "flash.h" #include "binarybuffer.h" #include "armv4_5.h" +#include "algorithm.h" /* 1024 bytes */ diff --git a/src/flash/stellaris.c b/src/flash/stellaris.c index 56762d1..7b94675 100644 --- a/src/flash/stellaris.c +++ b/src/flash/stellaris.c @@ -31,6 +31,7 @@ #include "stellaris.h" #include "armv7m.h" #include "binarybuffer.h" +#include "algorithm.h" #define DID0_VER(did0) ((did0 >> 28)&0x07) diff --git a/src/flash/stm32x.c b/src/flash/stm32x.c index 7ac06a6..7072715 100644 --- a/src/flash/stm32x.c +++ b/src/flash/stm32x.c @@ -27,6 +27,7 @@ #include "stm32x.h" #include "armv7m.h" #include "binarybuffer.h" +#include "algorithm.h" static int stm32x_mass_erase(struct flash_bank *bank); diff --git a/src/flash/str7x.c b/src/flash/str7x.c index 71709bb..19ee160 100644 --- a/src/flash/str7x.c +++ b/src/flash/str7x.c @@ -27,6 +27,7 @@ #include "str7x.h" #include "armv4_5.h" #include "binarybuffer.h" +#include "algorithm.h" struct str7x_mem_layout mem_layout_str7bank0[] = { diff --git a/src/flash/str9x.c b/src/flash/str9x.c index 1506cb5..870871c 100644 --- a/src/flash/str9x.c +++ b/src/flash/str9x.c @@ -29,6 +29,7 @@ #include "str9x.h" #include "arm966e.h" +#include "algorithm.h" static uint32_t bank1start = 0x00080000; diff --git a/src/target/algorithm.h b/src/target/algorithm.h index 80f081d..abb8ecf 100644 --- a/src/target/algorithm.h +++ b/src/target/algorithm.h @@ -20,8 +20,6 @@ #ifndef ALGORITHM_H #define ALGORITHM_H -#include "types.h" - enum param_direction { PARAM_IN, diff --git a/src/target/arm11.c b/src/target/arm11.c index f4e2c0d..cdeb420 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -33,6 +33,7 @@ #include "arm_simulator.h" #include "time_support.h" #include "target_type.h" +#include "algorithm.h" #if 0 diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index b07111e..76c79c3 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -36,6 +36,7 @@ #include "arm7_9_common.h" #include "time_support.h" #include "arm_simulator.h" +#include "algorithm.h" /** diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 47b32ad..e6e0bd7 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -31,6 +31,7 @@ #include "breakpoints.h" #include "arm_disassembler.h" #include "binarybuffer.h" +#include "algorithm.h" char* armv4_5_core_reg_list[] = diff --git a/src/target/armv7m.c b/src/target/armv7m.c index 6c6a9ec..3f9e7f5 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -36,6 +36,7 @@ #include "breakpoints.h" #include "armv7m.h" +#include "algorithm.h" #define ARRAY_SIZE(x) ((int)(sizeof(x)/sizeof((x)[0]))) diff --git a/src/target/target.h b/src/target/target.h index 06105ee..75bc4f0 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -28,7 +28,6 @@ #include <stddef.h> -#include "algorithm.h" #include "command.h" struct reg; @@ -36,6 +35,8 @@ struct trace; struct command_context; struct breakpoint; struct watchpoint; +struct mem_param; +struct reg_param; /** commit aa7c449600d6f6d634f587de6091421a1a877af5 Author: David Brownell <dbr...@us...> Date: Mon Nov 16 00:34:57 2009 -0800 target: don't implicitly include "breakpoint.h" Most files in the tree seem to have ended up including this, and *quite* needlessly ... only code implementing or using breakpoints actually needs these declarations. So take it out of the header files which included it, and put it in files which use it ... reduce needless interdependencies. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 4151ec7..21db296 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -28,6 +28,7 @@ #endif #include "gdb_server.h" +#include "breakpoints.h" #include "target_request.h" #include "register.h" #include "server.h" diff --git a/src/target/arm11.c b/src/target/arm11.c index 348dd87..f4e2c0d 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -27,6 +27,7 @@ #endif #include "arm11.h" +#include "breakpoints.h" #include "arm11_dbgtap.h" #include "armv4_5.h" #include "arm_simulator.h" diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index c35c825..b07111e 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -30,6 +30,7 @@ #include "config.h" #endif +#include "breakpoints.h" #include "embeddedice.h" #include "target_request.h" #include "arm7_9_common.h" diff --git a/src/target/arm7_9_common.h b/src/target/arm7_9_common.h index d70bae2..e5a2bb7 100644 --- a/src/target/arm7_9_common.h +++ b/src/target/arm7_9_common.h @@ -29,7 +29,6 @@ #ifndef ARM7_9_COMMON_H #define ARM7_9_COMMON_H -#include "breakpoints.h" #include "armv4_5.h" #define ARM7_9_COMMON_MAGIC 0x0a790a79 /**< */ diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index f9b22b9..47b32ad 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -28,6 +28,7 @@ #endif #include "armv4_5.h" +#include "breakpoints.h" #include "arm_disassembler.h" #include "binarybuffer.h" diff --git a/src/target/armv7m.c b/src/target/armv7m.c index ff97a4c..6c6a9ec 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -34,6 +34,7 @@ #include "config.h" #endif +#include "breakpoints.h" #include "armv7m.h" #define ARRAY_SIZE(x) ((int)(sizeof(x)/sizeof((x)[0]))) diff --git a/src/target/cortex_a8.c b/src/target/cortex_a8.c index 0d00b3a..832efe9 100644 --- a/src/target/cortex_a8.c +++ b/src/target/cortex_a8.c @@ -33,6 +33,7 @@ #include "config.h" #endif +#include "breakpoints.h" #include "cortex_a8.h" #include "armv7a.h" #include "armv4_5.h" diff --git a/src/target/cortex_m3.c b/src/target/cortex_m3.c index e236df2..35ca5a5 100644 --- a/src/target/cortex_m3.c +++ b/src/target/cortex_m3.c @@ -31,6 +31,7 @@ #include "config.h" #endif +#include "breakpoints.h" #include "cortex_m3.h" #include "target_request.h" #include "target_type.h" diff --git a/src/target/mips_m4k.c b/src/target/mips_m4k.c index 6dd00ad..fff401c 100644 --- a/src/target/mips_m4k.c +++ b/src/target/mips_m4k.c @@ -23,6 +23,7 @@ #include "config.h" #endif +#include "breakpoints.h" #include "mips32.h" #include "mips_m4k.h" #include "mips32_dmaacc.h" diff --git a/src/target/target.c b/src/target/target.c index f7e2ad6..f5a092a 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -36,6 +36,7 @@ #include "target.h" #include "target_type.h" #include "target_request.h" +#include "breakpoints.h" #include "time_support.h" #include "register.h" #include "trace.h" diff --git a/src/target/target.h b/src/target/target.h index e4de2c7..06105ee 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -28,13 +28,14 @@ #include <stddef.h> -#include "breakpoints.h" #include "algorithm.h" #include "command.h" struct reg; struct trace; struct command_context; +struct breakpoint; +struct watchpoint; /** diff --git a/src/target/xscale.c b/src/target/xscale.c index 0b5b26b..d8977e2 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -27,6 +27,7 @@ #include "config.h" #endif +#include "breakpoints.h" #include "xscale.h" #include "target_type.h" #include "arm7_9_common.h" ----------------------------------------------------------------------- Summary of changes: src/ecosboard.c | 4 ---- src/flash/aduc702x.c | 1 + src/flash/arm_nandio.c | 5 +++-- src/flash/at91sam3.c | 2 -- src/flash/cfi.c | 1 + src/flash/ecos.c | 1 + src/flash/lpc2000.c | 1 + src/flash/lpc2900.c | 1 + src/flash/lpc3180_nand_controller.h | 2 -- src/flash/mflash.c | 1 + src/flash/mflash.h | 2 +- src/flash/stellaris.c | 1 + src/flash/stm32x.c | 1 + src/flash/str7x.c | 1 + src/flash/str9x.c | 1 + src/helper/log.c | 1 - src/helper/options.c | 1 - src/openocd.c | 2 -- src/server/gdb_server.c | 3 ++- src/server/gdb_server.h | 2 -- src/target/algorithm.h | 2 -- src/target/arm11.c | 3 +++ src/target/arm720t.c | 1 + src/target/arm7_9_common.c | 3 +++ src/target/arm7_9_common.h | 1 - src/target/arm7tdmi.c | 1 + src/target/arm920t.c | 1 + src/target/arm926ejs.c | 1 + src/target/arm9tdmi.c | 1 + src/target/arm_adi_v5.h | 2 -- src/target/arm_simulator.c | 2 +- src/target/armv4_5.c | 3 +++ src/target/armv4_5.h | 2 -- src/target/armv4_5_mmu.c | 1 + src/target/armv4_5_mmu.h | 3 ++- src/target/armv7a.c | 2 -- src/target/armv7a.h | 3 --- src/target/armv7m.c | 4 ++++ src/target/cortex_a8.c | 4 ++-- src/target/cortex_a8.h | 2 -- src/target/cortex_m3.c | 2 ++ src/target/cortex_m3.h | 1 - src/target/embeddedice.c | 1 + src/target/etb.c | 1 + src/target/etm.c | 1 + src/target/feroceon.c | 2 ++ src/target/mips32.c | 1 + src/target/mips32.h | 1 - src/target/mips_m4k.c | 2 ++ src/target/register.c | 1 + src/target/register.h | 2 -- src/target/target.c | 1 + src/target/target.h | 12 +++++++----- src/target/target_request.c | 1 + src/target/target_request.h | 3 ++- src/target/xscale.c | 2 ++ 56 files changed, 64 insertions(+), 46 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: David B. <dbr...@us...> - 2009-11-15 19:38:22
|
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 5d1a9033ab89b017c95e79590d76abbfa61f7512 (commit) via 2280ddeea5fd82554696f1caa97f7a485a035da4 (commit) via 269040bbad7f18066f5ec5707447c33de6290ef5 (commit) via 9ac7cdec82c19481b79f2effcefb7106dd7ade41 (commit) from f30136603e4cc8b2db0112a32f26959d5201e58c (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 5d1a9033ab89b017c95e79590d76abbfa61f7512 Author: David Brownell <dbr...@us...> Date: Sun Nov 15 10:35:47 2009 -0800 ARM11: use now-generic memory utils Now the ARM11 cores can use the renamed arm_checksum_memory() and arm_blank_check_memory() routines ... do so. Sanity checked with "flash erase_check" of both NOR banks on an OMAP2420 ... the algorithm code dumped four lines of of "poll" status after each of almost 520 blocks (yes, *very* annoying) but gave plausible results after producing that spam. Signed-off-by: David Brownell <dbr...@us...> diff --git a/NEWS b/NEWS index 813ecda..7387d70 100644 --- a/NEWS +++ b/NEWS @@ -8,8 +8,16 @@ JTAG Layer: Boundary Scan: Target Layer: + ARM11 + - Preliminary ETM and ETB hookup + - accelerated "flash erase_check" + - accelerated GDB memory checksum + Flash Layer: Board, Target, and Interface Configuration Scripts: + ARM9 + - ETM and ETB hookup for iMX2* targets + Documentation: Build and Release: diff --git a/src/target/arm11.c b/src/target/arm11.c index 0b2fa2c..348dd87 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -1551,16 +1551,6 @@ static int arm11_bulk_write_memory(struct target *target, return arm11_write_memory(target, address, 4, count, buffer); } -/* here we have nothing target specific to contribute, so we fail and then the - * fallback code will read data from the target and calculate the CRC on the - * host. - */ -static int arm11_checksum_memory(struct target *target, - uint32_t address, uint32_t count, uint32_t* checksum) -{ - return ERROR_FAIL; -} - /* target break-/watchpoint control * rw: 0 = write, 1 = read, 2 = access */ @@ -2203,7 +2193,8 @@ struct target_type arm11_target = { .bulk_write_memory = arm11_bulk_write_memory, - .checksum_memory = arm11_checksum_memory, + .checksum_memory = arm_checksum_memory, + .blank_check_memory = arm_blank_check_memory, .add_breakpoint = arm11_add_breakpoint, .remove_breakpoint = arm11_remove_breakpoint, commit 2280ddeea5fd82554696f1caa97f7a485a035da4 Author: David Brownell <dbr...@us...> Date: Sun Nov 15 10:35:41 2009 -0800 ARM11: fixup method table Three changes: remove ARM11_HANDLER() in favor of normal structure initialization syntax; fix goofy indentation in that structure; and don't needlessly export arm11_register_commands(), it's only called through that method table. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/arm11.c b/src/target/arm11.c index a88d597..0b2fa2c 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -2139,51 +2139,7 @@ static int arm11_mcr(struct target *target, int cpnum, return arm11_mrc_inner(target, cpnum, op1, op2, CRn, CRm, &value, false); } -#define ARM11_HANDLER(x) .x = arm11_##x - -struct target_type arm11_target = { - .name = "arm11", - - ARM11_HANDLER(poll), - ARM11_HANDLER(arch_state), - - ARM11_HANDLER(target_request_data), - - ARM11_HANDLER(halt), - ARM11_HANDLER(resume), - ARM11_HANDLER(step), - - ARM11_HANDLER(assert_reset), - ARM11_HANDLER(deassert_reset), - ARM11_HANDLER(soft_reset_halt), - - ARM11_HANDLER(get_gdb_reg_list), - - ARM11_HANDLER(read_memory), - ARM11_HANDLER(write_memory), - - ARM11_HANDLER(bulk_write_memory), - - ARM11_HANDLER(checksum_memory), - - ARM11_HANDLER(add_breakpoint), - ARM11_HANDLER(remove_breakpoint), - ARM11_HANDLER(add_watchpoint), - ARM11_HANDLER(remove_watchpoint), - - ARM11_HANDLER(run_algorithm), - - ARM11_HANDLER(register_commands), - ARM11_HANDLER(target_create), - ARM11_HANDLER(init_target), - ARM11_HANDLER(examine), - - ARM11_HANDLER(mrc), - ARM11_HANDLER(mcr), - }; - - -int arm11_register_commands(struct command_context *cmd_ctx) +static int arm11_register_commands(struct command_context *cmd_ctx) { FNC_INFO; @@ -2222,3 +2178,45 @@ int arm11_register_commands(struct command_context *cmd_ctx) return etm_register_commands(cmd_ctx); } + +/** Holds methods for ARM11xx targets. */ +struct target_type arm11_target = { + .name = "arm11", + + .poll = arm11_poll, + .arch_state = arm11_arch_state, + + .target_request_data = arm11_target_request_data, + + .halt = arm11_halt, + .resume = arm11_resume, + .step = arm11_step, + + .assert_reset = arm11_assert_reset, + .deassert_reset = arm11_deassert_reset, + .soft_reset_halt = arm11_soft_reset_halt, + + .get_gdb_reg_list = arm11_get_gdb_reg_list, + + .read_memory = arm11_read_memory, + .write_memory = arm11_write_memory, + + .bulk_write_memory = arm11_bulk_write_memory, + + .checksum_memory = arm11_checksum_memory, + + .add_breakpoint = arm11_add_breakpoint, + .remove_breakpoint = arm11_remove_breakpoint, + .add_watchpoint = arm11_add_watchpoint, + .remove_watchpoint = arm11_remove_watchpoint, + + .run_algorithm = arm11_run_algorithm, + + .register_commands = arm11_register_commands, + .target_create = arm11_target_create, + .init_target = arm11_init_target, + .examine = arm11_examine, + + .mrc = arm11_mrc, + .mcr = arm11_mcr, +}; diff --git a/src/target/arm11.h b/src/target/arm11.h index e48758f..9bc6eb4 100644 --- a/src/target/arm11.h +++ b/src/target/arm11.h @@ -188,6 +188,4 @@ struct arm11_reg_state struct target * target; }; -int arm11_register_commands(struct command_context *cmd_ctx); - #endif /* ARM11_H */ commit 269040bbad7f18066f5ec5707447c33de6290ef5 Author: David Brownell <dbr...@us...> Date: Sun Nov 15 10:35:34 2009 -0800 ARM: memory utils aren't ARM7/ARM9 dependent The arm7_9_checksum_memory() and arm7_9_blank_check_memory() routines are not actually specific to the ARM7 and ARM9 core generations ... they can work for any core which can run algorithms using basic ARM (not Thumb) instructions. Rename them; move the declarations to a more generic site; likewise move the code (and tidy it a bit in the process). NOTE: the blank_check() method falsely returned a success status (0) on one error path, when the algorithm failed. Fixed this bug. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/arm720t.c b/src/target/arm720t.c index eb66b12..7bfb97d 100644 --- a/src/target/arm720t.c +++ b/src/target/arm720t.c @@ -535,8 +535,9 @@ struct target_type arm720t_target = .virt2phys = arm720_virt2phys, .bulk_write_memory = arm7_9_bulk_write_memory, - .checksum_memory = arm7_9_checksum_memory, - .blank_check_memory = arm7_9_blank_check_memory, + + .checksum_memory = arm_checksum_memory, + .blank_check_memory = arm_blank_check_memory, .run_algorithm = armv4_5_run_algorithm, diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index 115a1d6..c35c825 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -2706,156 +2706,6 @@ int arm7_9_bulk_write_memory(struct target *target, uint32_t address, uint32_t c return retval; } -int arm7_9_checksum_memory(struct target *target, uint32_t address, uint32_t count, uint32_t* checksum) -{ - struct working_area *crc_algorithm; - struct armv4_5_algorithm armv4_5_info; - struct reg_param reg_params[2]; - int retval; - - static const uint32_t arm7_9_crc_code[] = { - 0xE1A02000, /* mov r2, r0 */ - 0xE3E00000, /* mov r0, #0xffffffff */ - 0xE1A03001, /* mov r3, r1 */ - 0xE3A04000, /* mov r4, #0 */ - 0xEA00000B, /* b ncomp */ - /* nbyte: */ - 0xE7D21004, /* ldrb r1, [r2, r4] */ - 0xE59F7030, /* ldr r7, CRC32XOR */ - 0xE0200C01, /* eor r0, r0, r1, asl 24 */ - 0xE3A05000, /* mov r5, #0 */ - /* loop: */ - 0xE3500000, /* cmp r0, #0 */ - 0xE1A06080, /* mov r6, r0, asl #1 */ - 0xE2855001, /* add r5, r5, #1 */ - 0xE1A00006, /* mov r0, r6 */ - 0xB0260007, /* eorlt r0, r6, r7 */ - 0xE3550008, /* cmp r5, #8 */ - 0x1AFFFFF8, /* bne loop */ - 0xE2844001, /* add r4, r4, #1 */ - /* ncomp: */ - 0xE1540003, /* cmp r4, r3 */ - 0x1AFFFFF1, /* bne nbyte */ - /* end: */ - 0xEAFFFFFE, /* b end */ - 0x04C11DB7 /* CRC32XOR: .word 0x04C11DB7 */ - }; - - uint32_t i; - - if (target_alloc_working_area(target, sizeof(arm7_9_crc_code), &crc_algorithm) != ERROR_OK) - { - return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; - } - - /* convert flash writing code into a buffer in target endianness */ - for (i = 0; i < (sizeof(arm7_9_crc_code)/sizeof(uint32_t)); i++) - { - if ((retval = target_write_u32(target, crc_algorithm->address + i*sizeof(uint32_t), arm7_9_crc_code[i])) != ERROR_OK) - { - return retval; - } - } - - armv4_5_info.common_magic = ARMV4_5_COMMON_MAGIC; - armv4_5_info.core_mode = ARMV4_5_MODE_SVC; - armv4_5_info.core_state = ARMV4_5_STATE_ARM; - - init_reg_param(®_params[0], "r0", 32, PARAM_IN_OUT); - init_reg_param(®_params[1], "r1", 32, PARAM_OUT); - - buf_set_u32(reg_params[0].value, 0, 32, address); - buf_set_u32(reg_params[1].value, 0, 32, count); - - /* 20 second timeout/megabyte */ - int timeout = 20000 * (1 + (count / (1024*1024))); - - if ((retval = target_run_algorithm(target, 0, NULL, 2, reg_params, - crc_algorithm->address, crc_algorithm->address + (sizeof(arm7_9_crc_code) - 8), timeout, &armv4_5_info)) != ERROR_OK) - { - LOG_ERROR("error executing arm7_9 crc algorithm"); - destroy_reg_param(®_params[0]); - destroy_reg_param(®_params[1]); - target_free_working_area(target, crc_algorithm); - return retval; - } - - *checksum = buf_get_u32(reg_params[0].value, 0, 32); - - destroy_reg_param(®_params[0]); - destroy_reg_param(®_params[1]); - - target_free_working_area(target, crc_algorithm); - - return ERROR_OK; -} - -int arm7_9_blank_check_memory(struct target *target, uint32_t address, uint32_t count, uint32_t* blank) -{ - struct working_area *erase_check_algorithm; - struct reg_param reg_params[3]; - struct armv4_5_algorithm armv4_5_info; - int retval; - uint32_t i; - - static const uint32_t erase_check_code[] = - { - /* loop: */ - 0xe4d03001, /* ldrb r3, [r0], #1 */ - 0xe0022003, /* and r2, r2, r3 */ - 0xe2511001, /* subs r1, r1, #1 */ - 0x1afffffb, /* bne loop */ - /* end: */ - 0xeafffffe /* b end */ - }; - - /* make sure we have a working area */ - if (target_alloc_working_area(target, sizeof(erase_check_code), &erase_check_algorithm) != ERROR_OK) - { - return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; - } - - /* convert flash writing code into a buffer in target endianness */ - for (i = 0; i < (sizeof(erase_check_code)/sizeof(uint32_t)); i++) - if ((retval = target_write_u32(target, erase_check_algorithm->address + i*sizeof(uint32_t), erase_check_code[i])) != ERROR_OK) - { - return retval; - } - - armv4_5_info.common_magic = ARMV4_5_COMMON_MAGIC; - armv4_5_info.core_mode = ARMV4_5_MODE_SVC; - armv4_5_info.core_state = ARMV4_5_STATE_ARM; - - init_reg_param(®_params[0], "r0", 32, PARAM_OUT); - buf_set_u32(reg_params[0].value, 0, 32, address); - - init_reg_param(®_params[1], "r1", 32, PARAM_OUT); - buf_set_u32(reg_params[1].value, 0, 32, count); - - init_reg_param(®_params[2], "r2", 32, PARAM_IN_OUT); - buf_set_u32(reg_params[2].value, 0, 32, 0xff); - - if ((retval = target_run_algorithm(target, 0, NULL, 3, reg_params, - erase_check_algorithm->address, erase_check_algorithm->address + (sizeof(erase_check_code) - 4), 10000, &armv4_5_info)) != ERROR_OK) - { - destroy_reg_param(®_params[0]); - destroy_reg_param(®_params[1]); - destroy_reg_param(®_params[2]); - target_free_working_area(target, erase_check_algorithm); - return 0; - } - - *blank = buf_get_u32(reg_params[2].value, 0, 32); - - destroy_reg_param(®_params[0]); - destroy_reg_param(®_params[1]); - destroy_reg_param(®_params[2]); - - target_free_working_area(target, erase_check_algorithm); - - return ERROR_OK; -} - /** * Perform per-target setup that requires JTAG access. */ diff --git a/src/target/arm7_9_common.h b/src/target/arm7_9_common.h index bbe95ca..d70bae2 100644 --- a/src/target/arm7_9_common.h +++ b/src/target/arm7_9_common.h @@ -143,8 +143,6 @@ int arm7_9_read_core_reg(struct target *target, int num, enum armv4_5_mode mode) int arm7_9_read_memory(struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer); int arm7_9_write_memory(struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer); int arm7_9_bulk_write_memory(struct target *target, uint32_t address, uint32_t count, uint8_t *buffer); -int arm7_9_checksum_memory(struct target *target, uint32_t address, uint32_t count, uint32_t* checksum); -int arm7_9_blank_check_memory(struct target *target, uint32_t address, uint32_t count, uint32_t* blank); int arm7_9_run_algorithm(struct target *target, int num_mem_params, struct mem_param *mem_params, int num_reg_prams, struct reg_param *reg_param, uint32_t entry_point, void *arch_info); diff --git a/src/target/arm7tdmi.c b/src/target/arm7tdmi.c index 8be8a12..51fbddf 100644 --- a/src/target/arm7tdmi.c +++ b/src/target/arm7tdmi.c @@ -737,8 +737,9 @@ struct target_type arm7tdmi_target = .read_memory = arm7_9_read_memory, .write_memory = arm7_9_write_memory, .bulk_write_memory = arm7_9_bulk_write_memory, - .checksum_memory = arm7_9_checksum_memory, - .blank_check_memory = arm7_9_blank_check_memory, + + .checksum_memory = arm_checksum_memory, + .blank_check_memory = arm_blank_check_memory, .run_algorithm = armv4_5_run_algorithm, diff --git a/src/target/arm920t.c b/src/target/arm920t.c index 9aa165c..fd61020 100644 --- a/src/target/arm920t.c +++ b/src/target/arm920t.c @@ -1407,8 +1407,9 @@ struct target_type arm920t_target = .virt2phys = arm920_virt2phys, .bulk_write_memory = arm7_9_bulk_write_memory, - .checksum_memory = arm7_9_checksum_memory, - .blank_check_memory = arm7_9_blank_check_memory, + + .checksum_memory = arm_checksum_memory, + .blank_check_memory = arm_blank_check_memory, .run_algorithm = armv4_5_run_algorithm, diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c index 51b241a..00b7865 100644 --- a/src/target/arm926ejs.c +++ b/src/target/arm926ejs.c @@ -864,8 +864,9 @@ struct target_type arm926ejs_target = .read_memory = arm7_9_read_memory, .write_memory = arm926ejs_write_memory, .bulk_write_memory = arm7_9_bulk_write_memory, - .checksum_memory = arm7_9_checksum_memory, - .blank_check_memory = arm7_9_blank_check_memory, + + .checksum_memory = arm_checksum_memory, + .blank_check_memory = arm_blank_check_memory, .run_algorithm = armv4_5_run_algorithm, diff --git a/src/target/arm966e.c b/src/target/arm966e.c index b3d8e15..3b85a5c 100644 --- a/src/target/arm966e.c +++ b/src/target/arm966e.c @@ -261,8 +261,9 @@ struct target_type arm966e_target = .read_memory = arm7_9_read_memory, .write_memory = arm7_9_write_memory, .bulk_write_memory = arm7_9_bulk_write_memory, - .checksum_memory = arm7_9_checksum_memory, - .blank_check_memory = arm7_9_blank_check_memory, + + .checksum_memory = arm_checksum_memory, + .blank_check_memory = arm_blank_check_memory, .run_algorithm = armv4_5_run_algorithm, diff --git a/src/target/arm9tdmi.c b/src/target/arm9tdmi.c index 44a978a..1b7b645 100644 --- a/src/target/arm9tdmi.c +++ b/src/target/arm9tdmi.c @@ -938,8 +938,9 @@ struct target_type arm9tdmi_target = .read_memory = arm7_9_read_memory, .write_memory = arm7_9_write_memory, .bulk_write_memory = arm7_9_bulk_write_memory, - .checksum_memory = arm7_9_checksum_memory, - .blank_check_memory = arm7_9_blank_check_memory, + + .checksum_memory = arm_checksum_memory, + .blank_check_memory = arm_blank_check_memory, .run_algorithm = armv4_5_run_algorithm, diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index aa05e83..f9b22b9 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -707,6 +707,176 @@ int armv4_5_run_algorithm(struct target *target, int num_mem_params, struct mem_ 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); } +/** + * Runs ARM code in the target to calculate a CRC32 checksum. + * + * \todo On ARMv5+, rely on BKPT termination for reduced overhead. + */ +int arm_checksum_memory(struct target *target, + uint32_t address, uint32_t count, uint32_t *checksum) +{ + struct working_area *crc_algorithm; + struct armv4_5_algorithm armv4_5_info; + struct reg_param reg_params[2]; + int retval; + uint32_t i; + + static const uint32_t arm_crc_code[] = { + 0xE1A02000, /* mov r2, r0 */ + 0xE3E00000, /* mov r0, #0xffffffff */ + 0xE1A03001, /* mov r3, r1 */ + 0xE3A04000, /* mov r4, #0 */ + 0xEA00000B, /* b ncomp */ + /* nbyte: */ + 0xE7D21004, /* ldrb r1, [r2, r4] */ + 0xE59F7030, /* ldr r7, CRC32XOR */ + 0xE0200C01, /* eor r0, r0, r1, asl 24 */ + 0xE3A05000, /* mov r5, #0 */ + /* loop: */ + 0xE3500000, /* cmp r0, #0 */ + 0xE1A06080, /* mov r6, r0, asl #1 */ + 0xE2855001, /* add r5, r5, #1 */ + 0xE1A00006, /* mov r0, r6 */ + 0xB0260007, /* eorlt r0, r6, r7 */ + 0xE3550008, /* cmp r5, #8 */ + 0x1AFFFFF8, /* bne loop */ + 0xE2844001, /* add r4, r4, #1 */ + /* ncomp: */ + 0xE1540003, /* cmp r4, r3 */ + 0x1AFFFFF1, /* bne nbyte */ + /* end: */ + 0xEAFFFFFE, /* b end */ + /* CRC32XOR: */ + 0x04C11DB7 /* .word 0x04C11DB7 */ + }; + + retval = target_alloc_working_area(target, + sizeof(arm_crc_code), &crc_algorithm); + if (retval != ERROR_OK) + return retval; + + /* convert code into a buffer in target endianness */ + for (i = 0; i < DIM(arm_crc_code); i++) { + retval = target_write_u32(target, + crc_algorithm->address + i * sizeof(uint32_t), + arm_crc_code[i]); + if (retval != ERROR_OK) + return retval; + } + + armv4_5_info.common_magic = ARMV4_5_COMMON_MAGIC; + armv4_5_info.core_mode = ARMV4_5_MODE_SVC; + armv4_5_info.core_state = ARMV4_5_STATE_ARM; + + init_reg_param(®_params[0], "r0", 32, PARAM_IN_OUT); + init_reg_param(®_params[1], "r1", 32, PARAM_OUT); + + buf_set_u32(reg_params[0].value, 0, 32, address); + buf_set_u32(reg_params[1].value, 0, 32, count); + + /* 20 second timeout/megabyte */ + int timeout = 20000 * (1 + (count / (1024 * 1024))); + + retval = target_run_algorithm(target, 0, NULL, 2, reg_params, + crc_algorithm->address, + crc_algorithm->address + sizeof(arm_crc_code) - 8, + timeout, &armv4_5_info); + if (retval != ERROR_OK) { + LOG_ERROR("error executing ARM crc algorithm"); + destroy_reg_param(®_params[0]); + destroy_reg_param(®_params[1]); + target_free_working_area(target, crc_algorithm); + return retval; + } + + *checksum = buf_get_u32(reg_params[0].value, 0, 32); + + destroy_reg_param(®_params[0]); + destroy_reg_param(®_params[1]); + + target_free_working_area(target, crc_algorithm); + + return ERROR_OK; +} + +/** + * Runs ARM code in the target to check whether a memory block holds + * all ones. NOR flash which has been erased, and thus may be written, + * holds all ones. + * + * \todo On ARMv5+, rely on BKPT termination for reduced overhead. + */ +int arm_blank_check_memory(struct target *target, + uint32_t address, uint32_t count, uint32_t *blank) +{ + struct working_area *check_algorithm; + struct reg_param reg_params[3]; + struct armv4_5_algorithm armv4_5_info; + int retval; + uint32_t i; + + static const uint32_t check_code[] = { + /* loop: */ + 0xe4d03001, /* ldrb r3, [r0], #1 */ + 0xe0022003, /* and r2, r2, r3 */ + 0xe2511001, /* subs r1, r1, #1 */ + 0x1afffffb, /* bne loop */ + /* end: */ + 0xeafffffe /* b end */ + }; + + /* make sure we have a working area */ + retval = target_alloc_working_area(target, + sizeof(check_code), &check_algorithm); + if (retval != ERROR_OK) + return retval; + + /* convert code into a buffer in target endianness */ + for (i = 0; i < DIM(check_code); i++) { + retval = target_write_u32(target, + check_algorithm->address + + i * sizeof(uint32_t), + check_code[i]); + if (retval != ERROR_OK) + return retval; + } + + armv4_5_info.common_magic = ARMV4_5_COMMON_MAGIC; + armv4_5_info.core_mode = ARMV4_5_MODE_SVC; + armv4_5_info.core_state = ARMV4_5_STATE_ARM; + + init_reg_param(®_params[0], "r0", 32, PARAM_OUT); + buf_set_u32(reg_params[0].value, 0, 32, address); + + init_reg_param(®_params[1], "r1", 32, PARAM_OUT); + buf_set_u32(reg_params[1].value, 0, 32, count); + + init_reg_param(®_params[2], "r2", 32, PARAM_IN_OUT); + buf_set_u32(reg_params[2].value, 0, 32, 0xff); + + retval = target_run_algorithm(target, 0, NULL, 3, reg_params, + check_algorithm->address, + check_algorithm->address + sizeof(check_code) - 4, + 10000, &armv4_5_info); + if (retval != ERROR_OK) { + destroy_reg_param(®_params[0]); + destroy_reg_param(®_params[1]); + destroy_reg_param(®_params[2]); + target_free_working_area(target, check_algorithm); + return retval; + } + + *blank = buf_get_u32(reg_params[2].value, 0, 32); + + destroy_reg_param(®_params[0]); + destroy_reg_param(®_params[1]); + destroy_reg_param(®_params[2]); + + target_free_working_area(target, check_algorithm); + + return ERROR_OK; +} + int armv4_5_init_arch_info(struct target *target, struct arm *armv4_5) { target->arch_info = armv4_5; diff --git a/src/target/armv4_5.h b/src/target/armv4_5.h index 14dfa99..83b38b6 100644 --- a/src/target/armv4_5.h +++ b/src/target/armv4_5.h @@ -190,6 +190,12 @@ int armv4_5_run_algorithm(struct target *target, int armv4_5_invalidate_core_regs(struct target *target); +int arm_checksum_memory(struct target *target, + uint32_t address, uint32_t count, uint32_t *checksum); +int arm_blank_check_memory(struct target *target, + uint32_t address, uint32_t count, uint32_t *blank); + + /* ARM mode instructions */ @@ -369,7 +375,4 @@ static inline uint32_t mrc_opcode(int cpnum, uint32_t op1, uint32_t op2, uint32_ return t; } - - - #endif /* ARMV4_5_H */ diff --git a/src/target/cortex_a8.c b/src/target/cortex_a8.c index da5e84b..0d00b3a 100644 --- a/src/target/cortex_a8.c +++ b/src/target/cortex_a8.c @@ -1590,8 +1590,9 @@ struct target_type cortexa8_target = { .read_memory = cortex_a8_read_memory, .write_memory = cortex_a8_write_memory, .bulk_write_memory = cortex_a8_bulk_write_memory, - .checksum_memory = arm7_9_checksum_memory, - .blank_check_memory = arm7_9_blank_check_memory, + + .checksum_memory = arm_checksum_memory, + .blank_check_memory = arm_blank_check_memory, .run_algorithm = armv4_5_run_algorithm, diff --git a/src/target/cortex_a8.h b/src/target/cortex_a8.h index e7ea6c7..f11d9dd 100644 --- a/src/target/cortex_a8.h +++ b/src/target/cortex_a8.h @@ -32,7 +32,6 @@ #include "register.h" #include "target.h" #include "armv7a.h" -#include "arm7_9_common.h" extern char* cortex_a8_state_strings[]; diff --git a/src/target/fa526.c b/src/target/fa526.c index 9e7b00d..e7c1a2e 100644 --- a/src/target/fa526.c +++ b/src/target/fa526.c @@ -380,8 +380,9 @@ struct target_type fa526_target = .read_memory = arm920t_read_memory, .write_memory = arm920t_write_memory, .bulk_write_memory = arm7_9_bulk_write_memory, - .checksum_memory = arm7_9_checksum_memory, - .blank_check_memory = arm7_9_blank_check_memory, + + .checksum_memory = arm_checksum_memory, + .blank_check_memory = arm_blank_check_memory, .run_algorithm = armv4_5_run_algorithm, diff --git a/src/target/feroceon.c b/src/target/feroceon.c index c029e44..03a5afc 100644 --- a/src/target/feroceon.c +++ b/src/target/feroceon.c @@ -696,8 +696,9 @@ struct target_type feroceon_target = .read_memory = arm7_9_read_memory, .write_memory = arm926ejs_write_memory, .bulk_write_memory = feroceon_bulk_write_memory, - .checksum_memory = arm7_9_checksum_memory, - .blank_check_memory = arm7_9_blank_check_memory, + + .checksum_memory = arm_checksum_memory, + .blank_check_memory = arm_blank_check_memory, .run_algorithm = armv4_5_run_algorithm, @@ -734,8 +735,9 @@ struct target_type dragonite_target = .read_memory = arm7_9_read_memory, .write_memory = arm7_9_write_memory, .bulk_write_memory = feroceon_bulk_write_memory, - .checksum_memory = arm7_9_checksum_memory, - .blank_check_memory = arm7_9_blank_check_memory, + + .checksum_memory = arm_checksum_memory, + .blank_check_memory = arm_blank_check_memory, .run_algorithm = armv4_5_run_algorithm, diff --git a/src/target/xscale.c b/src/target/xscale.c index 10ccf5d..0b5b26b 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -3626,8 +3626,9 @@ struct target_type xscale_target = .read_memory = xscale_read_memory, .write_memory = xscale_write_memory, .bulk_write_memory = xscale_bulk_write_memory, - .checksum_memory = arm7_9_checksum_memory, - .blank_check_memory = arm7_9_blank_check_memory, + + .checksum_memory = arm_checksum_memory, + .blank_check_memory = arm_blank_check_memory, .run_algorithm = armv4_5_run_algorithm, commit 9ac7cdec82c19481b79f2effcefb7106dd7ade41 Author: David Brownell <dbr...@us...> Date: Sun Nov 15 10:35:25 2009 -0800 target: make "examined" flag be per-target Previously this flag was stored in "target_type", so that for example if there were two ARM7TDMI targets in a scan chain, both would claim to have been examined although only the first one actually had its examine() method called. Move this state to where it should have been in the first place, and hide a method that didn't need exposure ... the flag is write-once. Provide some doxygen. The examine() method is confusing, since it isn't separating one-time setup from the after-each-reset stuff. And the ARM7/ARM9 version is, somewhat undesirably, not leaving the debug state alone after reset ... probably more of an issue for trace setup than for watchpoints and breakpoints. Signed-off-by: David Brownell <dbr...@us...> diff --git a/src/target/arm11.c b/src/target/arm11.c index 7a30bc7..a88d597 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -1906,12 +1906,6 @@ static int arm11_examine(struct target *target) retval = etm_setup(target); } - /* FIXME this sets a flag in the (shared) arm11_target structure, - * not in the (per-cpu) "target" structure ... so it's clearly - * wrong in the case of e.g. two different ARM11 chips on the - * same board. (Maybe ARM11 MPCore works though.) Whoever calls - * the examine() method should set a target-specific flag... - */ target_set_examined(target); return ERROR_OK; diff --git a/src/target/cortex_a8.c b/src/target/cortex_a8.c index 730cd33..da5e84b 100644 --- a/src/target/cortex_a8.c +++ b/src/target/cortex_a8.c @@ -1297,11 +1297,11 @@ static int cortex_a8_dcc_read(struct swjdp_common *swjdp, uint8_t *value, uint8_ static int cortex_a8_handle_target_request(void *priv) { struct target *target = priv; - if (!target->type->examined) - return ERROR_OK; struct armv7a_common *armv7a = target_to_armv7a(target); struct swjdp_common *swjdp = &armv7a->swjdp_info; + if (!target_was_examined(target)) + return ERROR_OK; if (!target->dbg_msg_enabled) return ERROR_OK; @@ -1424,7 +1424,7 @@ static int cortex_a8_examine(struct target *target) /* Configure core debug access */ cortex_a8_init_debug_access(target); - target->type->examined = 1; + target_set_examined(target); return retval; } diff --git a/src/target/target.c b/src/target/target.c index 2385d0f..f7e2ad6 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -644,20 +644,13 @@ int target_run_algorithm(struct target *target, entry_point, exit_point, timeout_ms, arch_info); } -/// @returns @c true if the target has been examined. -bool target_was_examined(struct target *target) -{ - return target->type->examined; -} -/// Sets the @c examined flag for the given target. -void target_set_examined(struct target *target) -{ - target->type->examined = true; -} -// Reset the @c examined flag for the given target. -void target_reset_examined(struct target *target) +/** + * Reset the @c examined flag for the given target. + * Pure paranoia -- targets are zeroed on allocation. + */ +static void target_reset_examined(struct target *target) { - target->type->examined = false; + target->examined = false; } diff --git a/src/target/target.h b/src/target/target.h index 914d62f..e4de2c7 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -129,7 +129,16 @@ struct target const char *cmd_name; /* tcl Name of target */ int target_number; /* DO NOT USE! field to be removed in 2010 */ struct jtag_tap *tap; /* where on the jtag chain is this */ - const char *variant; /* what varient of this chip is it? */ + const char *variant; /* what variant of this chip is it? */ + + /** + * Indicates whether this target has been examined. + * + * Do @b not access this field directly, use target_was_examined() + * or target_set_examined(). + */ + bool examined; + struct target_event_action *event_action; int reset_halt; /* attempt resetting the CPU into the halted mode? */ @@ -289,18 +298,25 @@ struct target *get_target(const char *id); const char *target_get_name(struct target *target); /** - * Examine the specified @a target. + * Examine the specified @a target, letting it perform any + * initialization that requires JTAG access. * * This routine is a wrapper for target->type->examine. */ int target_examine_one(struct target *target); -/// @returns @c true if the target has been examined. -bool target_was_examined(struct target *target); -/// Sets the @c examined flag for the given target. -void target_set_examined(struct target *target); -/// Reset the @c examined flag for the given target. -void target_reset_examined(struct target *target); +/// @returns @c true if target_set_examined() has been called. +static inline bool target_was_examined(struct target *target) +{ + return target->examined; +} + +/// Sets the @c examined flag for the given target. +/// Use in target->type->examine() after one-time setup is done. +static inline void target_set_examined(struct target *target) +{ + target->examined = true; +} /** * Add the @a breakpoint for @a target. diff --git a/src/target/target_type.h b/src/target/target_type.h index f601b19..aa87a74 100644 --- a/src/target/target_type.h +++ b/src/target/target_type.h @@ -30,22 +30,19 @@ struct target; +/** + * This holds methods shared between all instances of a given target + * type. For example, all Cortex-M3 targets on a scan chain share + * the same method table. + */ struct target_type { /** - * Name of the target. Do @b not access this field directly, use - * target_get_name() instead. + * Name of this type of target. Do @b not access this + * field directly, use target_get_name() instead. */ char *name; - /** - * Indicates whether this target has been examined. - * - * Do @b not access this field directly, use target_was_examined() - * target_set_examined(), and target_reset_examined(). - */ - int examined; - /* poll current target status */ int (*poll)(struct target *target); /* Invoked only from target_arch_state(). @@ -165,13 +162,22 @@ struct target_type /* returns JIM_OK, or JIM_ERR, or JIM_CONTINUE - if option not understood */ int (*target_jim_commands)(struct target *target, Jim_GetOptInfo *goi); - /* invoked after JTAG chain has been examined & validated. During - * this stage the target is examined and any additional setup is - * performed. + /** + * This method is used to perform target setup that requires + * JTAG access. + * + * This may be called multiple times. It is called after the + * scan chain is initially validated, or later after the target + * is enabled by a JRC. It may also be called during some + * parts of the reset sequence. * - * invoked every time after the jtag chain has been validated/examined + * For one-time initialization tasks, use target_was_examined() + * and target_set_examined(). For example, probe the hardware + * before setting up chip-specific state, and then set that + * flag so you don't do that again. */ int (*examine)(struct target *target); + /* Set up structures for target. * * It is illegal to talk to the target at this stage as this fn is invoked ----------------------------------------------------------------------- Summary of changes: NEWS | 8 ++ src/target/arm11.c | 105 +++++++++++---------------- src/target/arm11.h | 2 - src/target/arm720t.c | 5 +- src/target/arm7_9_common.c | 150 -------------------------------------- src/target/arm7_9_common.h | 2 - src/target/arm7tdmi.c | 5 +- src/target/arm920t.c | 5 +- src/target/arm926ejs.c | 5 +- src/target/arm966e.c | 5 +- src/target/arm9tdmi.c | 5 +- src/target/armv4_5.c | 170 ++++++++++++++++++++++++++++++++++++++++++++ src/target/armv4_5.h | 9 ++- src/target/cortex_a8.c | 11 ++-- src/target/cortex_a8.h | 1 - src/target/fa526.c | 5 +- src/target/feroceon.c | 10 ++- src/target/target.c | 19 ++---- src/target/target.h | 32 ++++++-- src/target/target_type.h | 34 +++++---- src/target/xscale.c | 5 +- 21 files changed, 314 insertions(+), 279 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: Zach W. <zw...@us...> - 2009-11-15 18:22:27
|
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 f30136603e4cc8b2db0112a32f26959d5201e58c (commit) via 673196887325188af843a9cc153c3cde86b25321 (commit) from a502676df7e6e99c29f207003ec02a128012d325 (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 f30136603e4cc8b2db0112a32f26959d5201e58c Author: Zachary T Welch <zw...@su...> Date: Sun Nov 15 09:12:44 2009 -0800 arm-jtag-ew,jlink: switch to COMMAND_HANDLER These drivers were overlooked during the recent upgrade. Convert them, moving their registration routines to eliminate their declarations. diff --git a/src/jtag/arm-jtag-ew.c b/src/jtag/arm-jtag-ew.c index 0568d1c..18b353a 100644 --- a/src/jtag/arm-jtag-ew.c +++ b/src/jtag/arm-jtag-ew.c @@ -63,9 +63,6 @@ static int armjtagew_register_commands(struct command_context *cmd_ctx); static int armjtagew_init(void); static int armjtagew_quit(void); -/* CLI command handler functions */ -static int armjtagew_handle_armjtagew_info_command(struct command_context *cmd_ctx, char *cmd, char **args, int argc); - /* Queue command functions */ static void armjtagew_end_state(tap_state_t state); static void armjtagew_state_move(void); @@ -240,13 +237,6 @@ static int armjtagew_khz(int khz, int *jtag_speed) return ERROR_OK; } -static int armjtagew_register_commands(struct command_context *cmd_ctx) -{ - register_command(cmd_ctx, NULL, "armjtagew_info", armjtagew_handle_armjtagew_info_command, COMMAND_EXEC, - "query armjtagew info"); - return ERROR_OK; -} - static int armjtagew_init(void) { int check_cnt; @@ -520,7 +510,7 @@ static int armjtagew_get_version_info(void) return ERROR_OK; } -static int armjtagew_handle_armjtagew_info_command(struct command_context *cmd_ctx, char *cmd, char **args, int argc) +COMMAND_HANDLER(armjtagew_handle_armjtagew_info_command) { if (armjtagew_get_version_info() == ERROR_OK) { @@ -531,6 +521,14 @@ static int armjtagew_handle_armjtagew_info_command(struct command_context *cmd_c return ERROR_OK; } +static int armjtagew_register_commands(struct command_context *cmd_ctx) +{ + register_command(cmd_ctx, NULL, "armjtagew_info", + &armjtagew_handle_armjtagew_info_command, COMMAND_EXEC, + "query armjtagew info"); + return ERROR_OK; +} + /***************************************************************************/ /* ARM-JTAG-EW tap functions */ diff --git a/src/jtag/jlink.c b/src/jtag/jlink.c index 27d400d..2422135 100644 --- a/src/jtag/jlink.c +++ b/src/jtag/jlink.c @@ -91,10 +91,6 @@ static int jlink_register_commands(struct command_context *cmd_ctx); static int jlink_init(void); static int jlink_quit(void); -/* CLI command handler functions */ -static int jlink_handle_jlink_info_command(struct command_context *cmd_ctx, char *cmd, char **args, int argc); -static int jlink_handle_jlink_hw_jtag_command(struct command_context *cmd_ctx, char *cmd, char **args, int argc); - /* Queue command functions */ static void jlink_end_state(tap_state_t state); static void jlink_state_move(void); @@ -290,18 +286,6 @@ static int jlink_khz(int khz, int *jtag_speed) return ERROR_OK; } -static int jlink_register_commands(struct command_context *cmd_ctx) -{ - - register_command(cmd_ctx, NULL, "jlink_info", - &jlink_handle_jlink_info_command, COMMAND_EXEC, - "query jlink info"); - register_command(cmd_ctx, NULL, "jlink_hw_jtag", - &jlink_handle_jlink_hw_jtag_command, COMMAND_EXEC, - "set/get jlink hw jtag command version [2 | 3]"); - return ERROR_OK; -} - static int jlink_init(void) { int i; @@ -630,7 +614,7 @@ static int jlink_get_version_info(void) return ERROR_OK; } -static int jlink_handle_jlink_info_command(struct command_context *cmd_ctx, char *cmd, char **args, int argc) +COMMAND_HANDLER(jlink_handle_jlink_info_command) { if (jlink_get_version_info() == ERROR_OK) { @@ -641,7 +625,7 @@ static int jlink_handle_jlink_info_command(struct command_context *cmd_ctx, char return ERROR_OK; } -static int jlink_handle_jlink_hw_jtag_command(struct command_context *cmd_ctx, char *cmd, char **args, int argc) +COMMAND_HANDLER(jlink_handle_jlink_hw_jtag_command) { switch (argc) { case 0: @@ -665,6 +649,18 @@ static int jlink_handle_jlink_hw_jtag_command(struct command_context *cmd_ctx, c return ERROR_OK; } +static int jlink_register_commands(struct command_context *cmd_ctx) +{ + + register_command(cmd_ctx, NULL, "jlink_info", + &jlink_handle_jlink_info_command, COMMAND_EXEC, + "query jlink info"); + register_command(cmd_ctx, NULL, "jlink_hw_jtag", + &jlink_handle_jlink_hw_jtag_command, COMMAND_EXEC, + "set/get jlink hw jtag command version [2 | 3]"); + return ERROR_OK; +} + /***************************************************************************/ /* J-Link tap functions */ commit 673196887325188af843a9cc153c3cde86b25321 Author: Zachary T Welch <zw...@su...> Date: Sun Nov 15 09:11:29 2009 -0800 rlink: fix overzealous sed Fix an instance where my cleanup when awry. diff --git a/src/jtag/rlink/rlink.c b/src/jtag/rlink/rlink.c index 8aa0342..c88067c 100644 --- a/src/jtag/rlink/rlink.c +++ b/src/jtag/rlink/rlink.c @@ -577,8 +577,8 @@ dtc_run_download( */ struct dtc_reply_queue_entry { - struct dtc_reply_queue_entry_s *next; - jtag_struct command *cmd; /* the command that resulted in this entry */ + struct dtc_reply_queue_entry *next; + struct jtag_command *cmd; /* the command that resulted in this entry */ struct { uint8_t *buffer; /* the scan buffer */ @@ -637,7 +637,7 @@ dtc_queue_enqueue_reply( int size, int offset, int length, - jtag_struct command *cmd + struct jtag_command *cmd ) { struct dtc_reply_queue_entry *rq_entry; @@ -1090,7 +1090,7 @@ void rlink_reset(int trst, int srst) static int rlink_scan( - jtag_struct command *cmd, + struct jtag_command *cmd, enum scan_type type, uint8_t *buffer, int scan_size @@ -1378,7 +1378,7 @@ rlink_scan( static int rlink_execute_queue(void) { - jtag_struct command *cmd = jtag_command_queue; /* currently processed command */ + struct jtag_command *cmd = jtag_command_queue; /* currently processed command */ int scan_size; enum scan_type type; uint8_t *buffer; ----------------------------------------------------------------------- Summary of changes: src/jtag/arm-jtag-ew.c | 20 +++++++++----------- src/jtag/jlink.c | 32 ++++++++++++++------------------ src/jtag/rlink/rlink.c | 10 +++++----- 3 files changed, 28 insertions(+), 34 deletions(-) hooks/post-receive -- Main OpenOCD repository |