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
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <zw...@ma...> - 2009-05-31 13:32:22
|
Author: zwelch Date: 2009-05-31 13:32:10 +0200 (Sun, 31 May 2009) New Revision: 1968 Modified: trunk/src/target/arm7_9_common.c trunk/src/target/target.c trunk/src/target/target.h Log: Add target_examine_one wrapper: - replaces all calls to target->type->examine. Modified: trunk/src/target/arm7_9_common.c =================================================================== --- trunk/src/target/arm7_9_common.c 2009-05-31 11:31:52 UTC (rev 1967) +++ trunk/src/target/arm7_9_common.c 2009-05-31 11:32:10 UTC (rev 1968) @@ -1051,7 +1051,7 @@ { LOG_WARNING("srst pulls trst - can not reset into halted mode. Issuing halt after reset."); /* set up embedded ice registers again */ - if ((retval=target->type->examine(target))!=ERROR_OK) + if ((retval = target_examine_one(target)) != ERROR_OK) return retval; if ((retval=target_poll(target))!=ERROR_OK) Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-05-31 11:31:52 UTC (rev 1967) +++ trunk/src/target/target.c 2009-05-31 11:32:10 UTC (rev 1968) @@ -467,6 +467,11 @@ return ERROR_OK; } +int target_examine_one(struct target_s *target) +{ + return target->type->examine(target); +} + /* Targets that correctly implement init+examine, i.e. * no communication with target during init: * @@ -478,7 +483,7 @@ target_t *target = all_targets; while (target) { - if ((retval = target->type->examine(target))!=ERROR_OK) + if ((retval = target_examine_one(target)) != ERROR_OK) return retval; target = target->next; } Modified: trunk/src/target/target.h =================================================================== --- trunk/src/target/target.h 2009-05-31 11:31:52 UTC (rev 1967) +++ trunk/src/target/target.h 2009-05-31 11:32:10 UTC (rev 1968) @@ -406,6 +406,12 @@ */ extern const char *target_get_name(struct target_s *target); +/** + * Examine the specified @a target. + * + * This routine is a wrapper for target->type->examine. + */ +extern int target_examine_one(struct target_s *target); /// @returns @c true if the target has been examined. extern bool target_was_examined(struct target_s *target); /// Sets the @c examined flag for the given target. |
From: <zw...@ma...> - 2009-05-31 13:32:01
|
Author: zwelch Date: 2009-05-31 13:31:52 +0200 (Sun, 31 May 2009) New Revision: 1967 Modified: trunk/src/target/breakpoints.c trunk/src/target/target.c trunk/src/target/target.h Log: Add target breakpoint and watchpoint wrapper: - replaces all calls to target->type->{add,remove}_{break,watch}point. Modified: trunk/src/target/breakpoints.c =================================================================== --- trunk/src/target/breakpoints.c 2009-05-31 11:31:27 UTC (rev 1966) +++ trunk/src/target/breakpoints.c 2009-05-31 11:31:52 UTC (rev 1967) @@ -61,7 +61,7 @@ (*breakpoint_p)->orig_instr = malloc(length); (*breakpoint_p)->next = NULL; - if ((retval = target->type->add_breakpoint(target, *breakpoint_p)) != ERROR_OK) + if ((retval = target_add_breakpoint(target, *breakpoint_p)) != ERROR_OK) { switch (retval) { @@ -108,7 +108,7 @@ if (breakpoint==NULL) return; - target->type->remove_breakpoint(target, breakpoint); + target_remove_breakpoint(target, breakpoint); (*breakpoint_p) = breakpoint->next; free(breakpoint->orig_instr); @@ -184,7 +184,7 @@ (*watchpoint_p)->set = 0; (*watchpoint_p)->next = NULL; - if ((retval = target->type->add_watchpoint(target, *watchpoint_p)) != ERROR_OK) + if ((retval = target_add_watchpoint(target, *watchpoint_p)) != ERROR_OK) { switch (retval) { @@ -229,7 +229,7 @@ if (watchpoint==NULL) return; - target->type->remove_watchpoint(target, watchpoint); + target_remove_watchpoint(target, watchpoint); (*watchpoint_p) = watchpoint->next; free(watchpoint); } Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-05-31 11:31:27 UTC (rev 1966) +++ trunk/src/target/target.c 2009-05-31 11:31:52 UTC (rev 1967) @@ -546,7 +546,28 @@ return target->type->bulk_write_memory(target, address, count, buffer); } +int target_add_breakpoint(struct target_s *target, + struct breakpoint_s *breakpoint) +{ + return target->type->add_breakpoint(target, breakpoint); +} +int target_remove_breakpoint(struct target_s *target, + struct breakpoint_s *breakpoint) +{ + return target->type->remove_breakpoint(target, breakpoint); +} +int target_add_watchpoint(struct target_s *target, + struct watchpoint_s *watchpoint) +{ + return target->type->add_watchpoint(target, watchpoint); +} +int target_remove_watchpoint(struct target_s *target, + struct watchpoint_s *watchpoint) +{ + return target->type->remove_watchpoint(target, watchpoint); +} + int target_get_gdb_reg_list(struct target_s *target, struct reg_s **reg_list[], int *reg_list_size) { Modified: trunk/src/target/target.h =================================================================== --- trunk/src/target/target.h 2009-05-31 11:31:27 UTC (rev 1966) +++ trunk/src/target/target.h 2009-05-31 11:31:52 UTC (rev 1967) @@ -413,7 +413,37 @@ /// Reset the @c examined flag for the given target. extern void target_reset_examined(struct target_s *target); + /** + * Add the @a breakpoint for @a target. + * + * This routine is a wrapper for target->type->add_breakpoint. + */ +extern int target_add_breakpoint(struct target_s *target, + struct breakpoint_s *breakpoint); +/** + * Remove the @a breakpoint for @a target. + * + * This routine is a wrapper for target->type->remove_breakpoint. + */ +extern int target_remove_breakpoint(struct target_s *target, + struct breakpoint_s *breakpoint); +/** + * Add the @a watchpoint for @a target. + * + * This routine is a wrapper for target->type->add_watchpoint. + */ +extern int target_add_watchpoint(struct target_s *target, + struct watchpoint_s *watchpoint); +/** + * Remove the @a watchpoint for @a target. + * + * This routine is a wrapper for target->type->remove_watchpoint. + */ +extern int target_remove_watchpoint(struct target_s *target, + struct watchpoint_s *watchpoint); + +/** * Obtain the registers for GDB. * * This routine is a wrapper for target->type->get_gdb_reg_list. |
From: <zw...@ma...> - 2009-05-31 13:31:36
|
Author: zwelch Date: 2009-05-31 13:31:27 +0200 (Sun, 31 May 2009) New Revision: 1966 Modified: trunk/src/server/gdb_server.c trunk/src/target/arm11.c trunk/src/target/embeddedice.c trunk/src/target/target.c trunk/src/target/target.h Log: Add target_get_name wrapper: - replaces all accesses to target->type->name. - add documentation in target_s to warn not to access field directly. Modified: trunk/src/server/gdb_server.c =================================================================== --- trunk/src/server/gdb_server.c 2009-05-31 11:31:11 UTC (rev 1965) +++ trunk/src/server/gdb_server.c 2009-05-31 11:31:27 UTC (rev 1966) @@ -2211,7 +2211,8 @@ add_service("gdb", CONNECTION_PIPE, 0, 1, gdb_new_connection, gdb_input, gdb_connection_closed, gdb_service); - LOG_DEBUG("gdb service for target %s using pipes", target->type->name); + LOG_DEBUG("gdb service for target %s using pipes", + target_get_name(target)); } else { @@ -2222,7 +2223,9 @@ add_service("gdb", CONNECTION_TCP, gdb_port + target->target_number, 1, gdb_new_connection, gdb_input, gdb_connection_closed, gdb_service); - LOG_DEBUG("gdb service for target %s at port %i", target->type->name, gdb_port + target->target_number); + LOG_DEBUG("gdb service for target %s at port %i", + target_get_name(target), + gdb_port + target->target_number); target = target->next; } } Modified: trunk/src/target/arm11.c =================================================================== --- trunk/src/target/arm11.c 2009-05-31 11:31:11 UTC (rev 1965) +++ trunk/src/target/arm11.c 2009-05-31 11:31:27 UTC (rev 1966) @@ -1847,7 +1847,7 @@ continue; /* if (t->type == arm11_target) */ - if (0 == strcmp(t->type->name, "arm11")) + if (0 == strcmp(target_get_name(t), "arm11")) return t->arch_info; } Modified: trunk/src/target/embeddedice.c =================================================================== --- trunk/src/target/embeddedice.c 2009-05-31 11:31:11 UTC (rev 1965) +++ trunk/src/target/embeddedice.c 2009-05-31 11:31:27 UTC (rev 1966) @@ -184,7 +184,7 @@ * in some unusual bits. Let feroceon.c validate it * and do the appropriate setup itself. */ - if (strcmp(target->type->name, "feroceon") == 0) + if (strcmp(target_get_name(target), "feroceon") == 0) break; LOG_ERROR("unknown EmbeddedICE version (comms ctrl: 0x%8.8x)", buf_get_u32(reg_list[EICE_COMMS_CTRL].value, 0, 32)); } Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-05-31 11:31:11 UTC (rev 1965) +++ trunk/src/target/target.c 2009-05-31 11:31:27 UTC (rev 1966) @@ -484,6 +484,10 @@ } return retval; } +const char *target_get_name(struct target_s *target) +{ + return target->type->name; +} static int target_write_memory_imp(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer) { @@ -598,7 +602,7 @@ if ((retval = target->type->init_target(cmd_ctx, target)) != ERROR_OK) { - LOG_ERROR("target '%s' init failed", target->type->name); + LOG_ERROR("target '%s' init failed", target_get_name(target)); return retval; } @@ -1451,7 +1455,7 @@ command_print(cmd_ctx, "%2d: %-10s %-10s %-10s %10d %14s %s", target->target_number, target->cmd_name, - target->type->name, + target_get_name(target), Jim_Nvp_value2name_simple( nvp_target_endian, target->endianness )->name, target->tap->abs_chain_position, target->tap->dotted_name, @@ -3131,7 +3135,7 @@ LOG_DEBUG( "target: (%d) %s (%s) event: %d (%s) action: %s\n", target->target_number, target->cmd_name, - target->type->name, + target_get_name(target), e, Jim_Nvp_value2name_simple( nvp_target_event, e )->name, Jim_GetString( teap->body, NULL ) ); @@ -3220,7 +3224,7 @@ return JIM_ERR; } } - Jim_SetResultString( goi->interp, target->type->name, -1 ); + Jim_SetResultString( goi->interp, target_get_name(target), -1 ); /* loop for more */ break; case TCFG_EVENT: Modified: trunk/src/target/target.h =================================================================== --- trunk/src/target/target.h 2009-05-31 11:31:11 UTC (rev 1965) +++ trunk/src/target/target.h 2009-05-31 11:31:27 UTC (rev 1966) @@ -107,6 +107,10 @@ typedef struct target_type_s { + /** + * Name of the target. Do @b not access this field directly, use + * target_get_name() instead. + */ char *name; /** @@ -395,6 +399,13 @@ extern int get_num_by_target(target_t *query_target); extern target_t *get_target(const char *id); +/** + * Get the target name. + * + * This routine is a wrapper for the target->type->name field. + */ +extern const char *target_get_name(struct target_s *target); + /// @returns @c true if the target has been examined. extern bool target_was_examined(struct target_s *target); /// Sets the @c examined flag for the given target. |
From: <zw...@ma...> - 2009-05-31 13:31:19
|
Author: zwelch Date: 2009-05-31 13:31:11 +0200 (Sun, 31 May 2009) New Revision: 1965 Modified: trunk/src/server/gdb_server.c trunk/src/target/target.c trunk/src/target/target.h Log: Add target_step wrapper: - replaces all calls to target->type->step. Modified: trunk/src/server/gdb_server.c =================================================================== --- trunk/src/server/gdb_server.c 2009-05-31 11:30:59 UTC (rev 1964) +++ trunk/src/server/gdb_server.c 2009-05-31 11:31:11 UTC (rev 1965) @@ -1366,7 +1366,8 @@ else if (packet[0] == 's') { LOG_DEBUG("step"); - retval=target->type->step(target, current, address, 0); /* step at current or address, don't handle breakpoints */ + /* step at current or address, don't handle breakpoints */ + retval = target_step(target, current, address, 0); } return retval; } Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-05-31 11:30:59 UTC (rev 1964) +++ trunk/src/target/target.c 2009-05-31 11:31:11 UTC (rev 1965) @@ -548,7 +548,13 @@ { return target->type->get_gdb_reg_list(target, reg_list, reg_list_size); } +int target_step(struct target_s *target, + int current, u32 address, int handle_breakpoints) +{ + return target->type->step(target, current, address, handle_breakpoints); +} + int target_run_algorithm(struct target_s *target, int num_mem_params, mem_param_t *mem_params, int num_reg_params, reg_param_t *reg_param, Modified: trunk/src/target/target.h =================================================================== --- trunk/src/target/target.h 2009-05-31 11:30:59 UTC (rev 1964) +++ trunk/src/target/target.h 2009-05-31 11:31:11 UTC (rev 1965) @@ -411,6 +411,13 @@ struct reg_s **reg_list[], int *reg_list_size); /** + * Step the target. + * + * This routine is a wrapper for target->type->step. + */ +int target_step(struct target_s *target, + int current, u32 address, int handle_breakpoints); +/** * Run an algorithm on the @a target given. * * This routine is a wrapper for target->type->run_algorithm. |
From: <zw...@ma...> - 2009-05-31 13:31:06
|
Author: zwelch Date: 2009-05-31 13:30:59 +0200 (Sun, 31 May 2009) New Revision: 1964 Modified: trunk/src/server/gdb_server.c trunk/src/target/target.c trunk/src/target/target.h Log: Add target_get_gdb_reg_list wrapper: - replaces all calls to target->type->get_gdb_reg_list. - add documentation in target_s to warn not to invoke callback directly. Modified: trunk/src/server/gdb_server.c =================================================================== --- trunk/src/server/gdb_server.c 2009-05-31 09:39:04 UTC (rev 1963) +++ trunk/src/server/gdb_server.c 2009-05-31 11:30:59 UTC (rev 1964) @@ -947,7 +947,7 @@ LOG_DEBUG("-"); #endif - if ((retval = target->type->get_gdb_reg_list(target, ®_list, ®_list_size)) != ERROR_OK) + if ((retval = target_get_gdb_reg_list(target, ®_list, ®_list_size)) != ERROR_OK) { return gdb_error(connection, retval); } @@ -1005,7 +1005,7 @@ return ERROR_SERVER_REMOTE_CLOSED; } - if ((retval = target->type->get_gdb_reg_list(target, ®_list, ®_list_size)) != ERROR_OK) + if ((retval = target_get_gdb_reg_list(target, ®_list, ®_list_size)) != ERROR_OK) { return gdb_error(connection, retval); } @@ -1057,7 +1057,7 @@ LOG_DEBUG("-"); #endif - if ((retval = target->type->get_gdb_reg_list(target, ®_list, ®_list_size)) != ERROR_OK) + if ((retval = target_get_gdb_reg_list(target, ®_list, ®_list_size)) != ERROR_OK) { return gdb_error(connection, retval); } @@ -1092,7 +1092,7 @@ LOG_DEBUG("-"); - if ((retval = target->type->get_gdb_reg_list(target, ®_list, ®_list_size)) != ERROR_OK) + if ((retval = target_get_gdb_reg_list(target, ®_list, ®_list_size)) != ERROR_OK) { return gdb_error(connection, retval); } Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-05-31 09:39:04 UTC (rev 1963) +++ trunk/src/target/target.c 2009-05-31 11:30:59 UTC (rev 1964) @@ -543,6 +543,12 @@ } +int target_get_gdb_reg_list(struct target_s *target, + struct reg_s **reg_list[], int *reg_list_size) +{ + return target->type->get_gdb_reg_list(target, reg_list, reg_list_size); +} + int target_run_algorithm(struct target_s *target, int num_mem_params, mem_param_t *mem_params, int num_reg_params, reg_param_t *reg_param, Modified: trunk/src/target/target.h =================================================================== --- trunk/src/target/target.h 2009-05-31 09:39:04 UTC (rev 1963) +++ trunk/src/target/target.h 2009-05-31 11:30:59 UTC (rev 1964) @@ -151,7 +151,9 @@ int (*soft_reset_halt_imp)(struct target_s *target); int (*soft_reset_halt)(struct target_s *target); - /* target register access for gdb. + /** + * Target register access for GDB. Do @b not call this function + * directly, use target_get_gdb_reg_list() instead. * * Danger! this function will succeed even if the target is running * and return a register list with dummy values. @@ -401,6 +403,14 @@ extern void target_reset_examined(struct target_s *target); /** + * Obtain the registers for GDB. + * + * This routine is a wrapper for target->type->get_gdb_reg_list. + */ +extern int target_get_gdb_reg_list(struct target_s *target, + struct reg_s **reg_list[], int *reg_list_size); + +/** * Run an algorithm on the @a target given. * * This routine is a wrapper for target->type->run_algorithm. |
From: <zw...@ma...> - 2009-05-31 11:39:09
|
Author: zwelch Date: 2009-05-31 11:39:04 +0200 (Sun, 31 May 2009) New Revision: 1963 Modified: trunk/src/flash/orion_nand.c trunk/src/target/target.c trunk/src/target/target.h Log: Add target_bulk_write_memory wrapper: - replaces all calls to target->type->bulk_write_memory. - add documentation in target_s to warn not to invoke callback directly. Modified: trunk/src/flash/orion_nand.c =================================================================== --- trunk/src/flash/orion_nand.c 2009-05-31 09:38:43 UTC (rev 1962) +++ trunk/src/flash/orion_nand.c 2009-05-31 09:39:04 UTC (rev 1963) @@ -140,8 +140,7 @@ /* copy data to target's memory */ target_buf = hw->copy_area->address + code_size; - retval = target->type->bulk_write_memory(target, target_buf, - size/4, data); + retval = target_bulk_write_memory(target, target_buf, size/4, data); if (retval == ERROR_OK && size & 3) { retval = target_write_memory(target, target_buf + (size & ~3), Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-05-31 09:38:43 UTC (rev 1962) +++ trunk/src/target/target.c 2009-05-31 09:39:04 UTC (rev 1963) @@ -536,7 +536,13 @@ { return target->type->write_memory(target, address, size, count, buffer); } +int target_bulk_write_memory(struct target_s *target, + u32 address, u32 count, u8 *buffer) +{ + return target->type->bulk_write_memory(target, address, count, buffer); +} + int target_run_algorithm(struct target_s *target, int num_mem_params, mem_param_t *mem_params, int num_reg_params, reg_param_t *reg_param, Modified: trunk/src/target/target.h =================================================================== --- trunk/src/target/target.h 2009-05-31 09:38:43 UTC (rev 1962) +++ trunk/src/target/target.h 2009-05-31 09:39:04 UTC (rev 1963) @@ -179,7 +179,11 @@ */ int (*write_memory)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); - /* write target memory in multiples of 4 byte, optimized for writing large quantities of data */ + /** + * Write target memory in multiples of 4 bytes, optimized for + * writing large quantities of data. Do @b not call this + * function directly, use target_bulk_write_memory() instead. + */ int (*bulk_write_memory)(struct target_s *target, u32 address, u32 count, u8 *buffer); int (*checksum_memory)(struct target_s *target, u32 address, u32 count, u32* checksum); @@ -424,6 +428,16 @@ extern int target_write_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); +/** + * Write @count items of 4 bytes to the memory of @a target at + * the @a address given. Because it operates only on whole words, + * this should be faster than target_write_memory(). + * + * This routine is wrapper for target->type->bulk_write_memory. + */ +extern int target_bulk_write_memory(struct target_s *target, + u32 address, u32 count, u8 *buffer); + extern int target_write_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer); extern int target_read_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer); extern int target_checksum_memory(struct target_s *target, u32 address, u32 size, u32* crc); |
From: <zw...@ma...> - 2009-05-31 11:38:53
|
Author: zwelch Date: 2009-05-31 11:38:43 +0200 (Sun, 31 May 2009) New Revision: 1962 Modified: trunk/src/target/arm11.c trunk/src/target/arm7_9_common.c trunk/src/target/arm7tdmi.c trunk/src/target/arm9tdmi.c trunk/src/target/cortex_a8.c trunk/src/target/cortex_m3.c trunk/src/target/mips32.c trunk/src/target/mips_m4k.c trunk/src/target/target.c trunk/src/target/target.h Log: Add wrappers for target->type->examined: - replace all checks of target->type->examined with target_was_examined(). - replace all setting of target->type->examined with target_set_examined(). - replace clearing of target->type->examined with target_reset_examined(). - add documentation in target_s to warn not to access field directly. Modified: trunk/src/target/arm11.c =================================================================== --- trunk/src/target/arm11.c 2009-05-31 09:38:20 UTC (rev 1961) +++ trunk/src/target/arm11.c 2009-05-31 09:38:43 UTC (rev 1962) @@ -1631,7 +1631,7 @@ arm11_check_init(arm11, NULL); - target->type->examined = 1; + target_set_examined(target); return ERROR_OK; } Modified: trunk/src/target/arm7_9_common.c =================================================================== --- trunk/src/target/arm7_9_common.c 2009-05-31 09:38:20 UTC (rev 1961) +++ trunk/src/target/arm7_9_common.c 2009-05-31 09:38:43 UTC (rev 1962) @@ -818,7 +818,7 @@ { int retval = ERROR_OK; target_t *target = priv; - if (!target->type->examined) + if (!target_was_examined(target)) return ERROR_OK; armv4_5_common_t *armv4_5 = target->arch_info; arm7_9_common_t *arm7_9 = armv4_5->arch_info; Modified: trunk/src/target/arm7tdmi.c =================================================================== --- trunk/src/target/arm7tdmi.c 2009-05-31 09:38:20 UTC (rev 1961) +++ trunk/src/target/arm7tdmi.c 2009-05-31 09:38:43 UTC (rev 1962) @@ -718,7 +718,7 @@ int retval; armv4_5_common_t *armv4_5 = target->arch_info; arm7_9_common_t *arm7_9 = armv4_5->arch_info; - if (!target->type->examined) + if (!target_was_examined(target)) { /* get pointers to arch-specific information */ reg_cache_t **cache_p = register_get_last_cache_p(&target->reg_cache); @@ -735,7 +735,7 @@ (*cache_p)->next = etm_build_reg_cache(target, jtag_info, arm7_9->etm_ctx); arm7_9->etm_ctx->reg_cache = (*cache_p)->next; } - target->type->examined = 1; + target_set_examined(target); } if ((retval=embeddedice_setup(target))!=ERROR_OK) return retval; Modified: trunk/src/target/arm9tdmi.c =================================================================== --- trunk/src/target/arm9tdmi.c 2009-05-31 09:38:20 UTC (rev 1961) +++ trunk/src/target/arm9tdmi.c 2009-05-31 09:38:43 UTC (rev 1962) @@ -810,7 +810,7 @@ int retval; armv4_5_common_t *armv4_5 = target->arch_info; arm7_9_common_t *arm7_9 = armv4_5->arch_info; - if (!target->type->examined) + if (!target_was_examined(target)) { reg_cache_t **cache_p = register_get_last_cache_p(&target->reg_cache); reg_cache_t *t; @@ -827,7 +827,7 @@ (*cache_p)->next = etm_build_reg_cache(target, jtag_info, arm7_9->etm_ctx); arm7_9->etm_ctx->reg_cache = (*cache_p)->next; } - target->type->examined = 1; + target_set_examined(target); } if ((retval=embeddedice_setup(target))!=ERROR_OK) return retval; Modified: trunk/src/target/cortex_a8.c =================================================================== --- trunk/src/target/cortex_a8.c 2009-05-31 09:38:20 UTC (rev 1961) +++ trunk/src/target/cortex_a8.c 2009-05-31 09:38:43 UTC (rev 1962) @@ -168,7 +168,7 @@ int cortex_a8_handle_target_request(void *priv) { target_t *target = priv; - if (!target->type->examined) + if (!target_was_examined(target)) return ERROR_OK; armv7m_common_t *armv7m = target->arch_info; swjdp_common_t *swjdp = &armv7m->swjdp_info; Modified: trunk/src/target/cortex_m3.c =================================================================== --- trunk/src/target/cortex_m3.c 2009-05-31 09:38:20 UTC (rev 1961) +++ trunk/src/target/cortex_m3.c 2009-05-31 09:38:43 UTC (rev 1962) @@ -1429,9 +1429,9 @@ if ((retval = ahbap_debugport_init(swjdp)) != ERROR_OK) return retval; - if (!target->type->examined) + if (!target_was_examined(target)) { - target->type->examined = 1; + target_set_examined(target); /* Read from Device Identification Registers */ if ((retval = target_read_u32(target, CPUID, &cpuid)) != ERROR_OK) @@ -1526,7 +1526,7 @@ int cortex_m3_handle_target_request(void *priv) { target_t *target = priv; - if (!target->type->examined) + if (!target_was_examined(target)) return ERROR_OK; armv7m_common_t *armv7m = target->arch_info; swjdp_common_t *swjdp = &armv7m->swjdp_info; Modified: trunk/src/target/mips32.c =================================================================== --- trunk/src/target/mips32.c 2009-05-31 09:38:20 UTC (rev 1961) +++ trunk/src/target/mips32.c 2009-05-31 09:38:43 UTC (rev 1962) @@ -346,9 +346,9 @@ { mips32_common_t *mips32 = target->arch_info; - if (!target->type->examined) + if (target_was_examined(target)) { - target->type->examined = 1; + target_set_examined(target); /* we will configure later */ mips32->bp_scanned = 0; Modified: trunk/src/target/mips_m4k.c =================================================================== --- trunk/src/target/mips_m4k.c 2009-05-31 09:38:20 UTC (rev 1961) +++ trunk/src/target/mips_m4k.c 2009-05-31 09:38:43 UTC (rev 1962) @@ -854,7 +854,7 @@ mips_ejtag_t *ejtag_info = &mips32->ejtag_info; u32 idcode = 0; - if (!target->type->examined) + if (!target_was_examined(target)) { mips_ejtag_get_idcode(ejtag_info, &idcode, NULL); ejtag_info->idcode = idcode; Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-05-31 09:38:20 UTC (rev 1961) +++ trunk/src/target/target.c 2009-05-31 09:38:43 UTC (rev 1962) @@ -384,7 +384,7 @@ int target_poll(struct target_s *target) { /* We can't poll until after examine */ - if (!target->type->examined) + if (!target_was_examined(target)) { /* Fail silently lest we pollute the log */ return ERROR_FAIL; @@ -395,7 +395,7 @@ int target_halt(struct target_s *target) { /* We can't poll until after examine */ - if (!target->type->examined) + if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; @@ -408,7 +408,7 @@ int retval; /* We can't poll until after examine */ - if (!target->type->examined) + if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; @@ -463,7 +463,7 @@ static int default_examine(struct target_s *target) { - target->type->examined = 1; + target_set_examined(target); return ERROR_OK; } @@ -487,7 +487,7 @@ static int target_write_memory_imp(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer) { - if (!target->type->examined) + if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; @@ -497,7 +497,7 @@ static int target_read_memory_imp(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer) { - if (!target->type->examined) + if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; @@ -507,7 +507,7 @@ static int target_soft_reset_halt_imp(struct target_s *target) { - if (!target->type->examined) + if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; @@ -517,7 +517,7 @@ static int target_run_algorithm_imp(struct target_s *target, int num_mem_params, mem_param_t *mem_params, int num_reg_params, reg_param_t *reg_param, u32 entry_point, u32 exit_point, int timeout_ms, void *arch_info) { - if (!target->type->examined) + if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; @@ -548,7 +548,23 @@ entry_point, exit_point, timeout_ms, arch_info); } +/// @returns @c true if the target has been examined. +bool target_was_examined(struct target_s *target) +{ + return target->type->examined; +} +/// Sets the @c examined flag for the given target. +void target_set_examined(struct target_s *target) +{ + target->type->examined = true; +} +// Reset the @c examined flag for the given target. +void target_reset_examined(struct target_s *target) +{ + target->type->examined = false; +} + int target_init(struct command_context_s *cmd_ctx) { target_t *target = all_targets; @@ -556,7 +572,7 @@ while (target) { - target->type->examined = 0; + target_reset_examined(target); if (target->type->examine == NULL) { target->type->examine = default_examine; @@ -1003,7 +1019,7 @@ int retval; LOG_DEBUG("writing buffer of %i byte at 0x%8.8x", size, address); - if (!target->type->examined) + if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; @@ -1082,7 +1098,7 @@ int retval; LOG_DEBUG("reading buffer of %i byte at 0x%8.8x", size, address); - if (!target->type->examined) + if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; @@ -1149,7 +1165,7 @@ int retval; u32 i; u32 checksum = 0; - if (!target->type->examined) + if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; @@ -1191,7 +1207,7 @@ int target_blank_check_memory(struct target_s *target, u32 address, u32 size, u32* blank) { int retval; - if (!target->type->examined) + if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; @@ -1208,7 +1224,7 @@ int target_read_u32(struct target_s *target, u32 address, u32 *value) { u8 value_buf[4]; - if (!target->type->examined) + if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; @@ -1233,7 +1249,7 @@ int target_read_u16(struct target_s *target, u32 address, u16 *value) { u8 value_buf[2]; - if (!target->type->examined) + if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; @@ -1258,7 +1274,7 @@ int target_read_u8(struct target_s *target, u32 address, u8 *value) { int retval = target_read_memory(target, address, 1, 1, value); - if (!target->type->examined) + if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; @@ -1281,7 +1297,7 @@ { int retval; u8 value_buf[4]; - if (!target->type->examined) + if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; @@ -1302,7 +1318,7 @@ { int retval; u8 value_buf[2]; - if (!target->type->examined) + if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; @@ -1322,7 +1338,7 @@ int target_write_u8(struct target_s *target, u32 address, u8 value) { int retval; - if (!target->type->examined) + if (!target_was_examined(target)) { LOG_ERROR("Target not examined yet"); return ERROR_FAIL; @@ -3682,7 +3698,7 @@ Jim_WrongNumArgs( goi.interp, 2, argv, "[no parameters]"); return JIM_ERR; } - if( !(target->type->examined) ){ + if( !(target_was_examined(target)) ){ e = ERROR_TARGET_NOT_EXAMINED; } else { e = target->type->poll( target ); Modified: trunk/src/target/target.h =================================================================== --- trunk/src/target/target.h 2009-05-31 09:38:20 UTC (rev 1961) +++ trunk/src/target/target.h 2009-05-31 09:38:43 UTC (rev 1962) @@ -109,6 +109,12 @@ { 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 */ @@ -383,6 +389,13 @@ extern int get_num_by_target(target_t *query_target); extern target_t *get_target(const char *id); +/// @returns @c true if the target has been examined. +extern bool target_was_examined(struct target_s *target); +/// Sets the @c examined flag for the given target. +extern void target_set_examined(struct target_s *target); +/// Reset the @c examined flag for the given target. +extern void target_reset_examined(struct target_s *target); + /** * Run an algorithm on the @a target given. * |
From: <zw...@ma...> - 2009-05-31 11:38:33
|
Author: zwelch Date: 2009-05-31 11:38:20 +0200 (Sun, 31 May 2009) New Revision: 1961 Modified: trunk/src/flash/aduc702x.c trunk/src/flash/cfi.c trunk/src/flash/ecos.c trunk/src/flash/lpc2000.c trunk/src/flash/orion_nand.c trunk/src/flash/pic32mx.c trunk/src/flash/stellaris.c trunk/src/flash/stm32x.c trunk/src/flash/str7x.c trunk/src/flash/str9x.c trunk/src/target/arm7_9_common.c trunk/src/target/armv7m.c trunk/src/target/target.c trunk/src/target/target.h Log: Add target_run_algorithm wrapper: - replaces all calls to target->type->run_algorithm. - add documentation in target_s to warn not to invoke callback directly. Modified: trunk/src/flash/aduc702x.c =================================================================== --- trunk/src/flash/aduc702x.c 2009-05-31 09:37:57 UTC (rev 1960) +++ trunk/src/flash/aduc702x.c 2009-05-31 09:38:20 UTC (rev 1961) @@ -288,7 +288,7 @@ buf_set_u32(reg_params[2].value, 0, 32, address); buf_set_u32(reg_params[4].value, 0, 32, 0xFFFFF800); - if ((retval = target->type->run_algorithm(target, 0, NULL, 5, + if ((retval = target_run_algorithm(target, 0, NULL, 5, reg_params, aduc702x_info->write_algorithm->address, aduc702x_info->write_algorithm->address + sizeof(aduc702x_flash_write_code) - 4, 10000, &armv4_5_info)) != ERROR_OK) Modified: trunk/src/flash/cfi.c =================================================================== --- trunk/src/flash/cfi.c 2009-05-31 09:37:57 UTC (rev 1960) +++ trunk/src/flash/cfi.c 2009-05-31 09:38:20 UTC (rev 1961) @@ -1227,7 +1227,7 @@ LOG_INFO("Write 0x%04x bytes to flash at 0x%08x", thisrun_count, address ); /* Execute algorithm, assume breakpoint for last instruction */ - retval = target->type->run_algorithm(target, 0, NULL, 7, reg_params, + retval = target_run_algorithm(target, 0, NULL, 7, reg_params, cfi_info->write_algorithm->address, cfi_info->write_algorithm->address + target_code_size - sizeof(u32), 10000, /* 10s should be enough for max. 32k of data */ @@ -1510,7 +1510,7 @@ buf_set_u32(reg_params[8].value, 0, 32, flash_address(bank, 0, pri_ext->_unlock2)); buf_set_u32(reg_params[9].value, 0, 32, 0x55555555); - retval = target->type->run_algorithm(target, 0, NULL, 10, reg_params, + retval = target_run_algorithm(target, 0, NULL, 10, reg_params, cfi_info->write_algorithm->address, cfi_info->write_algorithm->address + ((24 * 4) - 4), 10000, &armv4_5_info); Modified: trunk/src/flash/ecos.c =================================================================== --- trunk/src/flash/ecos.c 2009-05-31 09:37:57 UTC (rev 1960) +++ trunk/src/flash/ecos.c 2009-05-31 09:38:20 UTC (rev 1961) @@ -245,7 +245,7 @@ buf_set_u32(reg_params[2].value, 0, 32, r2); int retval; - if ((retval = target->type->run_algorithm(target, 0, NULL, 3, reg_params, + if ((retval = target_run_algorithm(target, 0, NULL, 3, reg_params, codeStart, codeStop, timeout, &armv4_5_info)) != ERROR_OK) Modified: trunk/src/flash/lpc2000.c =================================================================== --- trunk/src/flash/lpc2000.c 2009-05-31 09:37:57 UTC (rev 1960) +++ trunk/src/flash/lpc2000.c 2009-05-31 09:38:20 UTC (rev 1961) @@ -298,7 +298,7 @@ init_reg_param(®_params[4], "lr_svc", 32, PARAM_OUT); buf_set_u32(reg_params[4].value, 0, 32, lpc2000_info->iap_working_area->address + 0x4); - target->type->run_algorithm(target, 2, mem_params, 5, reg_params, lpc2000_info->iap_working_area->address, lpc2000_info->iap_working_area->address + 0x4, 10000, &armv4_5_info); + target_run_algorithm(target, 2, mem_params, 5, reg_params, lpc2000_info->iap_working_area->address, lpc2000_info->iap_working_area->address + 0x4, 10000, &armv4_5_info); status_code = buf_get_u32(mem_params[1].value, 0, 32); result_table[0] = target_buffer_get_u32(target, mem_params[1].value); Modified: trunk/src/flash/orion_nand.c =================================================================== --- trunk/src/flash/orion_nand.c 2009-05-31 09:37:57 UTC (rev 1960) +++ trunk/src/flash/orion_nand.c 2009-05-31 09:38:20 UTC (rev 1961) @@ -162,7 +162,7 @@ buf_set_u32(reg_params[1].value, 0, 32, target_buf); buf_set_u32(reg_params[2].value, 0, 32, size); - retval = target->type->run_algorithm(target, 0, NULL, 3, reg_params, + retval = target_run_algorithm(target, 0, NULL, 3, reg_params, hw->copy_area->address, hw->copy_area->address + code_size - 4, 1000, &algo); Modified: trunk/src/flash/pic32mx.c =================================================================== --- trunk/src/flash/pic32mx.c 2009-05-31 09:37:57 UTC (rev 1960) +++ trunk/src/flash/pic32mx.c 2009-05-31 09:38:20 UTC (rev 1961) @@ -419,7 +419,7 @@ buf_set_u32(reg_params[1].value, 0, 32, address); buf_set_u32(reg_params[2].value, 0, 32, buffer_size/4); - if ((retval = target->type->run_algorithm(target, 0, NULL, 4, reg_params, pic32mx_info->write_algorithm->address, \ + if ((retval = target_run_algorithm(target, 0, NULL, 4, reg_params, pic32mx_info->write_algorithm->address, \ pic32mx_info->write_algorithm->address + (sizeof(pic32mx_flash_write_code) - 10), 10000, &armv7m_info)) != ERROR_OK) { LOG_ERROR("error executing pic32mx flash write algorithm"); Modified: trunk/src/flash/stellaris.c =================================================================== --- trunk/src/flash/stellaris.c 2009-05-31 09:37:57 UTC (rev 1960) +++ trunk/src/flash/stellaris.c 2009-05-31 09:38:20 UTC (rev 1961) @@ -779,7 +779,7 @@ buf_set_u32(reg_params[2].value, 0, 32, 4*thisrun_count); LOG_INFO("Algorithm flash write %i words to 0x%x, %i remaining", thisrun_count, address, wcount); LOG_DEBUG("Algorithm flash write %i words to 0x%x, %i remaining", thisrun_count, address, wcount); - if ((retval = target->type->run_algorithm(target, 0, NULL, 3, reg_params, write_algorithm->address, write_algorithm->address + sizeof(stellaris_write_code)-10, 10000, &armv7m_info)) != ERROR_OK) + if ((retval = target_run_algorithm(target, 0, NULL, 3, reg_params, write_algorithm->address, write_algorithm->address + sizeof(stellaris_write_code)-10, 10000, &armv7m_info)) != ERROR_OK) { LOG_ERROR("error executing stellaris flash write algorithm"); retval = ERROR_FLASH_OPERATION_FAILED; Modified: trunk/src/flash/stm32x.c =================================================================== --- trunk/src/flash/stm32x.c 2009-05-31 09:37:57 UTC (rev 1960) +++ trunk/src/flash/stm32x.c 2009-05-31 09:38:20 UTC (rev 1961) @@ -554,7 +554,7 @@ buf_set_u32(reg_params[1].value, 0, 32, address); buf_set_u32(reg_params[2].value, 0, 32, thisrun_count); - if ((retval = target->type->run_algorithm(target, 0, NULL, 4, reg_params, stm32x_info->write_algorithm->address, \ + if ((retval = target_run_algorithm(target, 0, NULL, 4, reg_params, stm32x_info->write_algorithm->address, \ stm32x_info->write_algorithm->address + (sizeof(stm32x_flash_write_code) - 10), 10000, &armv7m_info)) != ERROR_OK) { LOG_ERROR("error executing stm32x flash write algorithm"); Modified: trunk/src/flash/str7x.c =================================================================== --- trunk/src/flash/str7x.c 2009-05-31 09:37:57 UTC (rev 1960) +++ trunk/src/flash/str7x.c 2009-05-31 09:38:20 UTC (rev 1961) @@ -429,7 +429,7 @@ buf_set_u32(reg_params[3].value, 0, 32, thisrun_count); buf_set_u32(reg_params[5].value, 0, 32, str7x_info->busy_bits); - if ((retval = target->type->run_algorithm(target, 0, NULL, 6, reg_params, str7x_info->write_algorithm->address, str7x_info->write_algorithm->address + (19 * 4), 10000, &armv4_5_info)) != ERROR_OK) + if ((retval = target_run_algorithm(target, 0, NULL, 6, reg_params, str7x_info->write_algorithm->address, str7x_info->write_algorithm->address + (19 * 4), 10000, &armv4_5_info)) != ERROR_OK) { LOG_ERROR("error executing str7x flash write algorithm"); retval = ERROR_FLASH_OPERATION_FAILED; Modified: trunk/src/flash/str9x.c =================================================================== --- trunk/src/flash/str9x.c 2009-05-31 09:37:57 UTC (rev 1960) +++ trunk/src/flash/str9x.c 2009-05-31 09:38:20 UTC (rev 1961) @@ -463,7 +463,7 @@ buf_set_u32(reg_params[1].value, 0, 32, address); buf_set_u32(reg_params[2].value, 0, 32, thisrun_count); - if ((retval = target->type->run_algorithm(target, 0, NULL, 4, reg_params, str9x_info->write_algorithm->address, str9x_info->write_algorithm->address + (18 * 4), 10000, &armv4_5_info)) != ERROR_OK) + if ((retval = target_run_algorithm(target, 0, NULL, 4, reg_params, str9x_info->write_algorithm->address, str9x_info->write_algorithm->address + (18 * 4), 10000, &armv4_5_info)) != ERROR_OK) { LOG_ERROR("error executing str9x flash write algorithm"); retval = ERROR_FLASH_OPERATION_FAILED; Modified: trunk/src/target/arm7_9_common.c =================================================================== --- trunk/src/target/arm7_9_common.c 2009-05-31 09:37:57 UTC (rev 1960) +++ trunk/src/target/arm7_9_common.c 2009-05-31 09:38:20 UTC (rev 1961) @@ -2747,7 +2747,7 @@ buf_set_u32(reg_params[0].value, 0, 32, address); buf_set_u32(reg_params[1].value, 0, 32, count); - if ((retval = target->type->run_algorithm(target, 0, NULL, 2, reg_params, + if ((retval = target_run_algorithm(target, 0, NULL, 2, reg_params, crc_algorithm->address, crc_algorithm->address + (sizeof(arm7_9_crc_code) - 8), 20000, &armv4_5_info)) != ERROR_OK) { LOG_ERROR("error executing arm7_9 crc algorithm"); @@ -2812,7 +2812,7 @@ init_reg_param(®_params[2], "r2", 32, PARAM_IN_OUT); buf_set_u32(reg_params[2].value, 0, 32, 0xff); - if ((retval = target->type->run_algorithm(target, 0, NULL, 3, reg_params, + 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]); Modified: trunk/src/target/armv7m.c =================================================================== --- trunk/src/target/armv7m.c 2009-05-31 09:37:57 UTC (rev 1960) +++ trunk/src/target/armv7m.c 2009-05-31 09:38:20 UTC (rev 1961) @@ -613,7 +613,7 @@ buf_set_u32(reg_params[0].value, 0, 32, address); buf_set_u32(reg_params[1].value, 0, 32, count); - if ((retval = target->type->run_algorithm(target, 0, NULL, 2, reg_params, + if ((retval = target_run_algorithm(target, 0, NULL, 2, reg_params, crc_algorithm->address, crc_algorithm->address + (sizeof(cortex_m3_crc_code)-6), 20000, &armv7m_info)) != ERROR_OK) { LOG_ERROR("error executing cortex_m3 crc algorithm"); @@ -674,7 +674,7 @@ init_reg_param(®_params[2], "r2", 32, PARAM_IN_OUT); buf_set_u32(reg_params[2].value, 0, 32, 0xff); - if ((retval = target->type->run_algorithm(target, 0, NULL, 3, reg_params, + if ((retval = target_run_algorithm(target, 0, NULL, 3, reg_params, erase_check_algorithm->address, erase_check_algorithm->address + (sizeof(erase_check_code)-2), 10000, &armv7m_info)) != ERROR_OK) { destroy_reg_param(®_params[0]); Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-05-31 09:37:57 UTC (rev 1960) +++ trunk/src/target/target.c 2009-05-31 09:38:20 UTC (rev 1961) @@ -537,7 +537,18 @@ return target->type->write_memory(target, address, size, count, buffer); } +int target_run_algorithm(struct target_s *target, + int num_mem_params, mem_param_t *mem_params, + int num_reg_params, reg_param_t *reg_param, + u32 entry_point, u32 exit_point, + int timeout_ms, void *arch_info) +{ + return target->type->run_algorithm(target, + num_mem_params, mem_params, num_reg_params, reg_param, + entry_point, exit_point, timeout_ms, arch_info); +} + int target_init(struct command_context_s *cmd_ctx) { target_t *target = all_targets; Modified: trunk/src/target/target.h =================================================================== --- trunk/src/target/target.h 2009-05-31 09:37:57 UTC (rev 1960) +++ trunk/src/target/target.h 2009-05-31 09:38:20 UTC (rev 1961) @@ -204,6 +204,10 @@ /* target algorithm support */ int (*run_algorithm_imp)(struct target_s *target, int num_mem_params, mem_param_t *mem_params, int num_reg_params, reg_param_t *reg_param, u32 entry_point, u32 exit_point, int timeout_ms, void *arch_info); + /** + * Target algorithm support. Do @b not call this method directly, + * use target_run_algorithm() instead. + */ int (*run_algorithm)(struct target_s *target, int num_mem_params, mem_param_t *mem_params, int num_reg_params, reg_param_t *reg_param, u32 entry_point, u32 exit_point, int timeout_ms, void *arch_info); int (*register_commands)(struct command_context_s *cmd_ctx); @@ -380,6 +384,17 @@ extern target_t *get_target(const char *id); /** + * Run an algorithm on the @a target given. + * + * This routine is a wrapper for target->type->run_algorithm. + */ +extern int target_run_algorithm(struct target_s *target, + int num_mem_params, mem_param_t *mem_params, + int num_reg_params, reg_param_t *reg_param, + u32 entry_point, u32 exit_point, + int timeout_ms, void *arch_info); + +/** * Read @count items of @a size bytes from the memory of @a target at * the @a address given. * |
From: <zw...@ma...> - 2009-05-31 11:38:13
|
Author: zwelch Date: 2009-05-31 11:37:57 +0200 (Sun, 31 May 2009) New Revision: 1960 Modified: trunk/src/flash/at91sam7.c trunk/src/flash/cfi.c trunk/src/flash/lpc2000.c trunk/src/flash/lpc288x.c trunk/src/flash/lpc3180_nand_controller.c trunk/src/flash/mflash.c trunk/src/flash/orion_nand.c trunk/src/flash/str7x.c trunk/src/flash/str9x.c trunk/src/target/arm7_9_common.c trunk/src/target/cortex_m3.c trunk/src/target/feroceon.c trunk/src/target/mips_m4k.c trunk/src/target/target.c trunk/src/target/target.h trunk/src/target/xscale.c Log: Add target_write_memory wrapper: - replaces all calls to target->type->write_memory. - add documentation in target_s to warn not to invoke callback directly. Modified: trunk/src/flash/at91sam7.c =================================================================== --- trunk/src/flash/at91sam7.c 2009-05-31 09:37:35 UTC (rev 1959) +++ trunk/src/flash/at91sam7.c 2009-05-31 09:37:57 UTC (rev 1960) @@ -1027,7 +1027,7 @@ /* Write one block to the PageWriteBuffer */ buffer_pos = (pagen-first_page)*dst_min_alignment; wcount = CEIL(count,4); - if((retval = target->type->write_memory(target, bank->base+pagen*dst_min_alignment, 4, wcount, buffer+buffer_pos)) != ERROR_OK) + if((retval = target_write_memory(target, bank->base+pagen*dst_min_alignment, 4, wcount, buffer+buffer_pos)) != ERROR_OK) { return retval; } Modified: trunk/src/flash/cfi.c =================================================================== --- trunk/src/flash/cfi.c 2009-05-31 09:37:35 UTC (rev 1959) +++ trunk/src/flash/cfi.c 2009-05-31 09:37:57 UTC (rev 1960) @@ -260,7 +260,7 @@ } cfi_command(bank, 0x50, command); - target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command); + target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command); } u8 cfi_intel_wait_status_busy(flash_bank_t *bank, int timeout) @@ -356,12 +356,12 @@ if ((pri_ext->pri[0] != 'P') || (pri_ext->pri[1] != 'R') || (pri_ext->pri[2] != 'I')) { cfi_command(bank, 0xf0, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0xff, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -419,7 +419,7 @@ if ((pri_ext->pri[0] != 'P') || (pri_ext->pri[1] != 'R') || (pri_ext->pri[2] != 'I')) { cfi_command(bank, 0xf0, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -492,7 +492,7 @@ if ((atmel_pri_ext.pri[0] != 'P') || (atmel_pri_ext.pri[1] != 'R') || (atmel_pri_ext.pri[2] != 'I')) { cfi_command(bank, 0xf0, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -688,13 +688,13 @@ for (i = first; i <= last; i++) { cfi_command(bank, 0x20, command); - if((retval = target->type->write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0xd0, command); - if((retval = target->type->write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -704,7 +704,7 @@ else { cfi_command(bank, 0xff, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -715,7 +715,7 @@ } cfi_command(bank, 0xff, command); - return target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command); + return target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command); } @@ -731,37 +731,37 @@ for (i = first; i <= last; i++) { cfi_command(bank, 0xaa, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0x55, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0x80, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0xaa, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0x55, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0x30, command); - if((retval = target->type->write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -771,7 +771,7 @@ else { cfi_command(bank, 0xf0, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -782,7 +782,7 @@ } cfi_command(bank, 0xf0, command); - return target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command); + return target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command); } static int cfi_erase(struct flash_bank_s *bank, int first, int last) @@ -842,7 +842,7 @@ { cfi_command(bank, 0x60, command); LOG_DEBUG("address: 0x%4.4x, command: 0x%4.4x", flash_address(bank, i, 0x0), target_buffer_get_u32(target, command)); - if((retval = target->type->write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -850,7 +850,7 @@ { cfi_command(bank, 0x01, command); LOG_DEBUG("address: 0x%4.4x, command: 0x%4.4x", flash_address(bank, i, 0x0), target_buffer_get_u32(target, command)); - if((retval = target->type->write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -860,7 +860,7 @@ { cfi_command(bank, 0xd0, command); LOG_DEBUG("address: 0x%4.4x, command: 0x%4.4x", flash_address(bank, i, 0x0), target_buffer_get_u32(target, command)); - if((retval = target->type->write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -878,7 +878,7 @@ u8 block_status; /* read block lock bit, to verify status */ cfi_command(bank, 0x90, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x55), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x55), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -888,7 +888,7 @@ { LOG_ERROR("couldn't change block lock status (set = %i, block_status = 0x%2.2x)", set, block_status); cfi_command(bank, 0x70, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x55), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x55), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -917,13 +917,13 @@ cfi_intel_clear_status_register(bank); cfi_command(bank, 0x60, command); - if((retval = target->type->write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0x01, command); - if((retval = target->type->write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -934,7 +934,7 @@ } cfi_command(bank, 0xff, command); - return target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command); + return target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command); } static int cfi_protect(struct flash_bank_s *bank, int set, int first, int last) @@ -1554,12 +1554,12 @@ cfi_intel_clear_status_register(bank); cfi_command(bank, 0x40, command); - if((retval = target->type->write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK) { return retval; } - if((retval = target->type->write_memory(target, address, bank->bus_width, 1, word)) != ERROR_OK) + if((retval = target_write_memory(target, address, bank->bus_width, 1, word)) != ERROR_OK) { return retval; } @@ -1567,7 +1567,7 @@ if (cfi_intel_wait_status_busy(bank, 1000 * (1 << cfi_info->word_write_timeout_max)) != 0x80) { cfi_command(bank, 0xff, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -1622,14 +1622,14 @@ /* Initiate buffer operation _*/ cfi_command(bank, 0xE8, command); - if((retval = target->type->write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK) { return retval; } if (cfi_intel_wait_status_busy(bank, 1000 * (1 << cfi_info->buf_write_timeout_max)) != 0x80) { cfi_command(bank, 0xff, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -1640,26 +1640,26 @@ /* Write buffer wordcount-1 and data words */ cfi_command(bank, bufferwsize-1, command); - if((retval = target->type->write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK) { return retval; } - if((retval = target->type->write_memory(target, address, bank->bus_width, bufferwsize, word)) != ERROR_OK) + if((retval = target_write_memory(target, address, bank->bus_width, bufferwsize, word)) != ERROR_OK) { return retval; } /* Commit write operation */ cfi_command(bank, 0xd0, command); - if((retval = target->type->write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK) { return retval; } if (cfi_intel_wait_status_busy(bank, 1000 * (1 << cfi_info->buf_write_timeout_max)) != 0x80) { cfi_command(bank, 0xff, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -1680,24 +1680,24 @@ u8 command[8]; cfi_command(bank, 0xaa, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0x55, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0xa0, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } - if((retval = target->type->write_memory(target, address, bank->bus_width, 1, word)) != ERROR_OK) + if((retval = target_write_memory(target, address, bank->bus_width, 1, word)) != ERROR_OK) { return retval; } @@ -1705,7 +1705,7 @@ if (cfi_spansion_wait_status_busy(bank, 1000 * (1 << cfi_info->word_write_timeout_max)) != ERROR_OK) { cfi_command(bank, 0xf0, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -1757,39 +1757,39 @@ // Unlock cfi_command(bank, 0xaa, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0x55, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } // Buffer load command cfi_command(bank, 0x25, command); - if((retval = target->type->write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK) { return retval; } /* Write buffer wordcount-1 and data words */ cfi_command(bank, bufferwsize-1, command); - if((retval = target->type->write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK) { return retval; } - if((retval = target->type->write_memory(target, address, bank->bus_width, bufferwsize, word)) != ERROR_OK) + if((retval = target_write_memory(target, address, bank->bus_width, bufferwsize, word)) != ERROR_OK) { return retval; } /* Commit write operation */ cfi_command(bank, 0x29, command); - if((retval = target->type->write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -1797,7 +1797,7 @@ if (cfi_spansion_wait_status_busy(bank, 1000 * (1 << cfi_info->word_write_timeout_max)) != ERROR_OK) { cfi_command(bank, 0xf0, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -2012,12 +2012,12 @@ /* return to read array mode, so we can read from flash again for padding */ cfi_command(bank, 0xf0, current_word); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, current_word)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, current_word)) != ERROR_OK) { return retval; } cfi_command(bank, 0xff, current_word); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, current_word)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, current_word)) != ERROR_OK) { return retval; } @@ -2052,12 +2052,12 @@ /* return to read array mode */ cfi_command(bank, 0xf0, current_word); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, current_word)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, current_word)) != ERROR_OK) { return retval; } cfi_command(bank, 0xff, current_word); - return target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, current_word); + return target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, current_word); } static void cfi_fixup_atmel_reversed_erase_regions(flash_bank_t *bank, void *param) @@ -2133,17 +2133,17 @@ /* switch to read identifier codes mode ("AUTOSELECT") */ cfi_command(bank, 0xaa, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, unlock1), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, unlock1), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0x55, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, unlock2), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, unlock2), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0x90, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, unlock1), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, unlock1), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -2177,12 +2177,12 @@ LOG_INFO("Flash Manufacturer/Device: 0x%04x 0x%04x", cfi_info->manufacturer, cfi_info->device_id); /* switch back to read array mode */ cfi_command(bank, 0xf0, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x00), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x00), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0xff, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x00), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x00), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -2203,7 +2203,7 @@ * SST flashes clearly violate this, and we will consider them incompatbile for now */ cfi_command(bank, 0x98, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x55), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x55), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -2217,12 +2217,12 @@ if ((cfi_info->qry[0] != 'Q') || (cfi_info->qry[1] != 'R') || (cfi_info->qry[2] != 'Y')) { cfi_command(bank, 0xf0, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0xff, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -2307,12 +2307,12 @@ * we use both reset commands, as some Intel flashes fail to recognize the 0xF0 command */ cfi_command(bank, 0xf0, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0xff, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -2410,7 +2410,7 @@ return ERROR_FLASH_OPERATION_FAILED; cfi_command(bank, 0x90, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, 0x55), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, 0x55), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -2426,7 +2426,7 @@ } cfi_command(bank, 0xff, command); - return target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command); + return target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command); } static int cfi_spansion_protect_check(struct flash_bank_s *bank) @@ -2439,19 +2439,19 @@ int i; cfi_command(bank, 0xaa, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0x55, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } cfi_command(bank, 0x90, command); - if((retval = target->type->write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK) + if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK) { return retval; } @@ -2467,7 +2467,7 @@ } cfi_command(bank, 0xf0, command); - return target->type->write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command); + return target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command); } static int cfi_protect_check(struct flash_bank_s *bank) Modified: trunk/src/flash/lpc2000.c =================================================================== --- trunk/src/flash/lpc2000.c 2009-05-31 09:37:35 UTC (rev 1959) +++ trunk/src/flash/lpc2000.c 2009-05-31 09:37:57 UTC (rev 1960) @@ -258,7 +258,7 @@ /* write IAP code to working area */ target_buffer_set_u32(target, jump_gate, ARMV4_5_BX(12)); target_buffer_set_u32(target, jump_gate + 4, ARMV4_5_B(0xfffffe, 0)); - if((retval = target->type->write_memory(target, lpc2000_info->iap_working_area->address, 4, 2, jump_gate)) != ERROR_OK) + if((retval = target_write_memory(target, lpc2000_info->iap_working_area->address, 4, 2, jump_gate)) != ERROR_OK) { return retval; } Modified: trunk/src/flash/lpc288x.c =================================================================== --- trunk/src/flash/lpc288x.c 2009-05-31 09:37:35 UTC (rev 1959) +++ trunk/src/flash/lpc288x.c 2009-05-31 09:37:57 UTC (rev 1960) @@ -406,7 +406,7 @@ * it seems not to be a LOT slower.... * bulk_write_memory() is no quicker :(*/ #if 1 - if (target->type->write_memory(target, offset + dest_offset, 4, 128, page_buffer) != ERROR_OK) + if (target_write_memory(target, offset + dest_offset, 4, 128, page_buffer) != ERROR_OK) { LOG_ERROR("Write failed s %x p %x", sector, page); return ERROR_FLASH_OPERATION_FAILED; Modified: trunk/src/flash/lpc3180_nand_controller.c =================================================================== --- trunk/src/flash/lpc3180_nand_controller.c 2009-05-31 09:37:35 UTC (rev 1959) +++ trunk/src/flash/lpc3180_nand_controller.c 2009-05-31 09:37:57 UTC (rev 1960) @@ -602,8 +602,8 @@ /* write MLC_ECC_ENC_REG to start encode cycle */ target_write_u32(target, 0x200b8008, 0x0); - target->type->write_memory(target, 0x200a8000, 4, 128, page_buffer + (quarter * 512)); - target->type->write_memory(target, 0x200a8000, 1, 6, oob_buffer + (quarter * 6)); + target_write_memory(target, 0x200a8000, 4, 128, page_buffer + (quarter * 512)); + target_write_memory(target, 0x200a8000, 1, 6, oob_buffer + (quarter * 6)); /* write MLC_ECC_AUTO_ENC_REG to start auto encode */ target_write_u32(target, 0x200b8010, 0x0); Modified: trunk/src/flash/mflash.c =================================================================== --- trunk/src/flash/mflash.c 2009-05-31 09:37:35 UTC (rev 1959) +++ trunk/src/flash/mflash.c 2009-05-31 09:37:57 UTC (rev 1960) @@ -494,7 +494,7 @@ if (ret != ERROR_OK) LOG_ERROR("mg_io_wait_drq time out"); - ret = target->type->write_memory(target, address, 2, MG_MFLASH_SECTOR_SIZE / 2, buff_ptr); + ret = target_write_memory(target, address, 2, MG_MFLASH_SECTOR_SIZE / 2, buff_ptr); if (ret != ERROR_OK) LOG_ERROR("mem write error"); buff_ptr += MG_MFLASH_SECTOR_SIZE; @@ -927,7 +927,7 @@ for (i = 0; i < MG_MFLASH_SECTOR_SIZE >> 1; i++) buff[i] = i; - target->type->write_memory(target, address, 2, + target_write_memory(target, address, 2, MG_MFLASH_SECTOR_SIZE / 2, (u8 *)buff); memset(buff, 0xff, MG_MFLASH_SECTOR_SIZE); Modified: trunk/src/flash/orion_nand.c =================================================================== --- trunk/src/flash/orion_nand.c 2009-05-31 09:37:35 UTC (rev 1959) +++ trunk/src/flash/orion_nand.c 2009-05-31 09:37:57 UTC (rev 1960) @@ -131,7 +131,7 @@ target_buffer_set_u32(target, code_buf + i*4, code[i]); /* write code to working area */ - retval = target->type->write_memory(target, + retval = target_write_memory(target, hw->copy_area->address, 4, code_size/4, code_buf); if (retval != ERROR_OK) @@ -143,7 +143,7 @@ retval = target->type->bulk_write_memory(target, target_buf, size/4, data); if (retval == ERROR_OK && size & 3) { - retval = target->type->write_memory(target, + retval = target_write_memory(target, target_buf + (size & ~3), 1, size & 3, data + (size & ~3)); } Modified: trunk/src/flash/str7x.c =================================================================== --- trunk/src/flash/str7x.c 2009-05-31 09:37:35 UTC (rev 1959) +++ trunk/src/flash/str7x.c 2009-05-31 09:37:57 UTC (rev 1960) @@ -546,11 +546,11 @@ target_write_u32(target, str7x_get_flash_adr(bank, FLASH_AR), address); /* data word 1 */ - target->type->write_memory(target, str7x_get_flash_adr(bank, FLASH_DR0), 4, 1, buffer + bytes_written); + target_write_memory(target, str7x_get_flash_adr(bank, FLASH_DR0), 4, 1, buffer + bytes_written); bytes_written += 4; /* data word 2 */ - target->type->write_memory(target, str7x_get_flash_adr(bank, FLASH_DR1), 4, 1, buffer + bytes_written); + target_write_memory(target, str7x_get_flash_adr(bank, FLASH_DR1), 4, 1, buffer + bytes_written); bytes_written += 4; /* start programming cycle */ @@ -593,11 +593,11 @@ target_write_u32(target, str7x_get_flash_adr(bank, FLASH_AR), address); /* data word 1 */ - target->type->write_memory(target, str7x_get_flash_adr(bank, FLASH_DR0), 4, 1, last_dword); + target_write_memory(target, str7x_get_flash_adr(bank, FLASH_DR0), 4, 1, last_dword); bytes_written += 4; /* data word 2 */ - target->type->write_memory(target, str7x_get_flash_adr(bank, FLASH_DR1), 4, 1, last_dword + 4); + target_write_memory(target, str7x_get_flash_adr(bank, FLASH_DR1), 4, 1, last_dword + 4); bytes_written += 4; /* start programming cycle */ Modified: trunk/src/flash/str9x.c =================================================================== --- trunk/src/flash/str9x.c 2009-05-31 09:37:35 UTC (rev 1959) +++ trunk/src/flash/str9x.c 2009-05-31 09:37:57 UTC (rev 1960) @@ -569,7 +569,7 @@ /* write data command */ target_write_u16(target, bank_adr, 0x40); - target->type->write_memory(target, address, 2, 1, buffer + bytes_written); + target_write_memory(target, address, 2, 1, buffer + bytes_written); /* get status command */ target_write_u16(target, bank_adr, 0x70); @@ -618,7 +618,7 @@ /* write data comamnd */ target_write_u16(target, bank_adr, 0x40); - target->type->write_memory(target, address, 2, 1, last_halfword); + target_write_memory(target, address, 2, 1, last_halfword); /* query status command */ target_write_u16(target, bank_adr, 0x70); Modified: trunk/src/target/arm7_9_common.c =================================================================== --- trunk/src/target/arm7_9_common.c 2009-05-31 09:37:35 UTC (rev 1959) +++ trunk/src/target/arm7_9_common.c 2009-05-31 09:37:57 UTC (rev 1960) @@ -378,7 +378,7 @@ return retval; } if (current_instr==arm7_9->arm_bkpt) - if ((retval = target->type->write_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK) + if ((retval = target_write_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK) { return retval; } @@ -392,7 +392,7 @@ return retval; } if (current_instr==arm7_9->thumb_bkpt) - if ((retval = target->type->write_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK) + if ((retval = target_write_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK) { return retval; } @@ -2628,7 +2628,7 @@ int i; if (!arm7_9->dcc_downloads) - return target->type->write_memory(target, address, 4, count, buffer); + return target_write_memory(target, address, 4, count, buffer); /* regrab previously allocated working_area, or allocate a new one */ if (!arm7_9->dcc_working_area) @@ -2639,7 +2639,7 @@ if (target_alloc_working_area(target, 24, &arm7_9->dcc_working_area) != ERROR_OK) { LOG_INFO("no working area available, falling back to memory writes"); - return target->type->write_memory(target, address, 4, count, buffer); + return target_write_memory(target, address, 4, count, buffer); } /* copy target instructions to target endianness */ @@ -2649,7 +2649,7 @@ } /* write DCC code to working area */ - if ((retval = target->type->write_memory(target, arm7_9->dcc_working_area->address, 4, 6, dcc_code_buf)) != ERROR_OK) + if ((retval = target_write_memory(target, arm7_9->dcc_working_area->address, 4, 6, dcc_code_buf)) != ERROR_OK) { return retval; } Modified: trunk/src/target/cortex_m3.c =================================================================== --- trunk/src/target/cortex_m3.c 2009-05-31 09:37:35 UTC (rev 1959) +++ trunk/src/target/cortex_m3.c 2009-05-31 09:37:57 UTC (rev 1960) @@ -934,7 +934,7 @@ { return retval; } - if((retval = target->type->write_memory(target, breakpoint->address & 0xFFFFFFFE, breakpoint->length, 1, code)) != ERROR_OK) + if((retval = target_write_memory(target, breakpoint->address & 0xFFFFFFFE, breakpoint->length, 1, code)) != ERROR_OK) { return retval; } @@ -975,14 +975,14 @@ /* restore original instruction (kept in target endianness) */ if (breakpoint->length == 4) { - if((retval = target->type->write_memory(target, breakpoint->address & 0xFFFFFFFE, 4, 1, breakpoint->orig_instr)) != ERROR_OK) + if((retval = target_write_memory(target, breakpoint->address & 0xFFFFFFFE, 4, 1, breakpoint->orig_instr)) != ERROR_OK) { return retval; } } else { - if((retval = target->type->write_memory(target, breakpoint->address & 0xFFFFFFFE, 2, 1, breakpoint->orig_instr)) != ERROR_OK) + if((retval = target_write_memory(target, breakpoint->address & 0xFFFFFFFE, 2, 1, breakpoint->orig_instr)) != ERROR_OK) { return retval; } Modified: trunk/src/target/feroceon.c =================================================================== --- trunk/src/target/feroceon.c 2009-05-31 09:37:35 UTC (rev 1959) +++ trunk/src/target/feroceon.c 2009-05-31 09:37:57 UTC (rev 1960) @@ -546,7 +546,7 @@ u32 dcc_size = sizeof(dcc_code); if (!arm7_9->dcc_downloads) - return target->type->write_memory(target, address, 4, count, buffer); + return target_write_memory(target, address, 4, count, buffer); /* regrab previously allocated working_area, or allocate a new one */ if (!arm7_9->dcc_working_area) @@ -557,7 +557,7 @@ if (target_alloc_working_area(target, dcc_size, &arm7_9->dcc_working_area) != ERROR_OK) { LOG_INFO("no working area available, falling back to memory writes"); - return target->type->write_memory(target, address, 4, count, buffer); + return target_write_memory(target, address, 4, count, buffer); } /* copy target instructions to target endianness */ @@ -565,7 +565,7 @@ target_buffer_set_u32(target, dcc_code_buf + i*4, dcc_code[i]); /* write DCC code to working area */ - if((retval = target->type->write_memory(target, arm7_9->dcc_working_area->address, 4, dcc_size/4, dcc_code_buf)) != ERROR_OK) + if((retval = target_write_memory(target, arm7_9->dcc_working_area->address, 4, dcc_size/4, dcc_code_buf)) != ERROR_OK) { return retval; } Modified: trunk/src/target/mips_m4k.c =================================================================== --- trunk/src/target/mips_m4k.c 2009-05-31 09:37:35 UTC (rev 1959) +++ trunk/src/target/mips_m4k.c 2009-05-31 09:37:57 UTC (rev 1960) @@ -617,7 +617,7 @@ } if (current_instr == MIPS32_SDBBP) { - if((retval = target->type->write_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK) + if((retval = target_write_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK) { return retval; } @@ -635,7 +635,7 @@ if (current_instr == MIPS16_SDBBP) { - if((retval = target->type->write_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK) + if((retval = target_write_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK) { return retval; } Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-05-31 09:37:35 UTC (rev 1959) +++ trunk/src/target/target.c 2009-05-31 09:37:57 UTC (rev 1960) @@ -531,6 +531,13 @@ return target->type->read_memory(target, address, size, count, buffer); } +int target_write_memory(struct target_s *target, + u32 address, u32 size, u32 count, u8 *buffer) +{ + return target->type->write_memory(target, address, size, count, buffer); +} + + int target_init(struct command_context_s *cmd_ctx) { target_t *target = all_targets; @@ -898,7 +905,7 @@ if (restore&&target->backup_working_area) { int retval; - if((retval = target->type->write_memory(target, area->address, 4, area->size / 4, area->backup)) != ERROR_OK) + if((retval = target_write_memory(target, area->address, 4, area->size / 4, area->backup)) != ERROR_OK) return retval; } @@ -1004,7 +1011,7 @@ if (((address % 2) == 0) && (size == 2)) { - return target->type->write_memory(target, address, 2, 1, buffer); + return target_write_memory(target, address, 2, 1, buffer); } /* handle unaligned head bytes */ @@ -1015,7 +1022,7 @@ if (unaligned > size) unaligned = size; - if ((retval = target->type->write_memory(target, address, 1, unaligned, buffer)) != ERROR_OK) + if ((retval = target_write_memory(target, address, 1, unaligned, buffer)) != ERROR_OK) return retval; buffer += unaligned; @@ -1036,7 +1043,7 @@ } else { - if ((retval = target->type->write_memory(target, address, 4, aligned / 4, buffer)) != ERROR_OK) + if ((retval = target_write_memory(target, address, 4, aligned / 4, buffer)) != ERROR_OK) return retval; } @@ -1048,7 +1055,7 @@ /* handle tail writes of less than 4 bytes */ if (size > 0) { - if ((retval = target->type->write_memory(target, address, 1, size, buffer)) != ERROR_OK) + if ((retval = target_write_memory(target, address, 1, size, buffer)) != ERROR_OK) return retval; } @@ -1272,7 +1279,7 @@ LOG_DEBUG("address: 0x%8.8x, value: 0x%8.8x", address, value); target_buffer_set_u32(target, value_buf, value); - if ((retval = target->type->write_memory(target, address, 4, 1, value_buf)) != ERROR_OK) + if ((retval = target_write_memory(target, address, 4, 1, value_buf)) != ERROR_OK) { LOG_DEBUG("failed: %i", retval); } @@ -1293,7 +1300,7 @@ LOG_DEBUG("address: 0x%8.8x, value: 0x%8.8x", address, value); target_buffer_set_u16(target, value_buf, value); - if ((retval = target->type->write_memory(target, address, 2, 1, value_buf)) != ERROR_OK) + if ((retval = target_write_memory(target, address, 2, 1, value_buf)) != ERROR_OK) { LOG_DEBUG("failed: %i", retval); } @@ -1312,7 +1319,7 @@ LOG_DEBUG("address: 0x%8.8x, value: 0x%2.2x", address, value); - if ((retval = target->type->write_memory(target, address, 1, 1, &value)) != ERROR_OK) + if ((retval = target_write_memory(target, address, 1, 1, &value)) != ERROR_OK) { LOG_DEBUG("failed: %i", retval); } @@ -1967,7 +1974,7 @@ } for (i=0; i<count; i++) { - int retval = target->type->write_memory(target, + int retval = target_write_memory(target, address + i * wordsize, wordsize, 1, value_buf); if (ERROR_OK != retval) return retval; @@ -3034,7 +3041,7 @@ } len -= count; - retval = target->type->write_memory(target, addr, width, count, buffer); + retval = target_write_memory(target, addr, width, count, buffer); if (retval != ERROR_OK) { /* BOO !*/ LOG_ERROR("array2mem: Write @ 0x%08x, w=%d, cnt=%d, failed", addr, width, count); @@ -3525,7 +3532,7 @@ break; } for( x = 0 ; x < c ; x++ ){ - e = target->type->write_memory( target, a, b, 1, target_buf ); + e = target_write_memory( target, a, b, 1, target_buf ); if( e != ERROR_OK ){ Jim_SetResult_sprintf( interp, "Error writing @ 0x%08x: %d\n", (int)(a), e ); return JIM_ERR; Modified: trunk/src/target/target.h =================================================================== --- trunk/src/target/target.h 2009-05-31 09:37:35 UTC (rev 1959) +++ trunk/src/target/target.h 2009-05-31 09:37:57 UTC (rev 1960) @@ -167,6 +167,10 @@ */ int (*read_memory)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); int (*write_memory_imp)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); + /** + * Target memory write callback. Do @b not call this function + * directly, use target_write_memory() instead. + */ int (*write_memory)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); /* write target memory in multiples of 4 byte, optimized for writing large quantities of data */ @@ -383,6 +387,14 @@ */ extern int target_read_memory(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); +/** + * Write @count items of @a size bytes to the memory of @a target at + * the @a address given. + * + * This routine is wrapper for target->type->write_memory. + */ +extern int target_write_memory(struct target_s *target, + u32 address, u32 size, u32 count, u8 *buffer); extern int target_write_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer); extern int target_read_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer); Modified: trunk/src/target/xscale.c =================================================================== --- trunk/src/target/xscale.c 2009-05-31 09:37:35 UTC (rev 1959) +++ trunk/src/target/xscale.c 2009-05-31 09:37:57 UTC (rev 1960) @@ -2284,14 +2284,14 @@ /* restore original instruction (kept in target endianness) */ if (breakpoint->length == 4) { - if((retval = target->type->write_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK) + if((retval = target_write_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK) { return retval; } } else { - if((retval = target->type->write_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK) + if((retval = target_write_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK) { return retval; } |
From: <zw...@ma...> - 2009-05-31 11:37:51
|
Author: zwelch Date: 2009-05-31 11:37:35 +0200 (Sun, 31 May 2009) New Revision: 1959 Modified: trunk/src/flash/at91sam7.c trunk/src/flash/cfi.c trunk/src/flash/flash.c trunk/src/flash/lpc3180_nand_controller.c trunk/src/flash/mflash.c trunk/src/target/arm7_9_common.c trunk/src/target/cortex_m3.c trunk/src/target/mips_m4k.c trunk/src/target/target.c trunk/src/target/target.h trunk/src/target/xscale.c Log: Add target_read_memory wrapper: - replaces all calls to target->type->read_memory. - add documentation in target_s to warn not to invoke callback directly. Modified: trunk/src/flash/at91sam7.c =================================================================== --- trunk/src/flash/at91sam7.c 2009-05-31 06:00:28 UTC (rev 1958) +++ trunk/src/flash/at91sam7.c 2009-05-31 09:37:35 UTC (rev 1959) @@ -665,7 +665,7 @@ for (nSector=0; nSector<bank->num_sectors; nSector++) { bank->sectors[nSector].is_erased = 1; - retval = target->type->read_memory(target, bank->base+bank->sectors[nSector].offset, 4, + retval = target_read_memory(target, bank->base+bank->sectors[nSector].offset, 4, bank->sectors[nSector].size/4, buffer); if (retval != ERROR_OK) return retval; Modified: trunk/src/flash/cfi.c =================================================================== --- trunk/src/flash/cfi.c 2009-05-31 06:00:28 UTC (rev 1958) +++ trunk/src/flash/cfi.c 2009-05-31 09:37:35 UTC (rev 1959) @@ -166,7 +166,7 @@ target_t *target = bank->target; u8 data[CFI_MAX_BUS_WIDTH]; - target->type->read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 1, data); + target_read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 1, data); if (bank->target->endianness == TARGET_LITTLE_ENDIAN) return data[0]; @@ -184,7 +184,7 @@ u8 data[CFI_MAX_BUS_WIDTH]; int i; - target->type->read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 1, data); + target_read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 1, data); if (bank->target->endianness == TARGET_LITTLE_ENDIAN) { @@ -213,11 +213,11 @@ { u8 i; for(i=0;i<2;i++) - target->type->read_memory(target, flash_address(bank, sector, offset+i), bank->bus_width, 1, + target_read_memory(target, flash_address(bank, sector, offset+i), bank->bus_width, 1, &data[i*bank->bus_width] ); } else - target->type->read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 2, data); + target_read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 2, data); if (bank->target->endianness == TARGET_LITTLE_ENDIAN) return data[0] | data[bank->bus_width] << 8; @@ -235,11 +235,11 @@ { u8 i; for(i=0;i<4;i++) - target->type->read_memory(target, flash_address(bank, sector, offset+i), bank->bus_width, 1, + target_read_memory(target, flash_address(bank, sector, offset+i), bank->bus_width, 1, &data[i*bank->bus_width] ); } else - target->type->read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 4, data); + target_read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 4, data); if (bank->target->endianness == TARGET_LITTLE_ENDIAN) return data[0] | data[bank->bus_width] << 8 | data[bank->bus_width * 2] << 16 | data[bank->bus_width * 3] << 24; @@ -1889,7 +1889,7 @@ for (i = 0; i < align; ++i, ++copy_p) { u8 byte; - if((retval = target->type->read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK) + if((retval = target_read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK) { return retval; } @@ -1908,7 +1908,7 @@ for (; (count == 0) && (i < bank->bus_width); ++i, ++copy_p) { u8 byte; - if((retval = target->type->read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK) + if((retval = target_read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK) { return retval; } @@ -2039,7 +2039,7 @@ for (; i < bank->bus_width; ++i, ++copy_p) { u8 byte; - if((retval = target->type->read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK) + if((retval = target_read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK) { return retval; } Modified: trunk/src/flash/flash.c =================================================================== --- trunk/src/flash/flash.c 2009-05-31 06:00:28 UTC (rev 1958) +++ trunk/src/flash/flash.c 2009-05-31 09:37:35 UTC (rev 1959) @@ -1157,7 +1157,7 @@ chunk = (j - bank->sectors[i].size); } - retval = target->type->read_memory(target, bank->base + bank->sectors[i].offset + j, 4, chunk/4, buffer); + retval = target_read_memory(target, bank->base + bank->sectors[i].offset + j, 4, chunk/4, buffer); if (retval != ERROR_OK) return retval; Modified: trunk/src/flash/lpc3180_nand_controller.c =================================================================== --- trunk/src/flash/lpc3180_nand_controller.c 2009-05-31 06:00:28 UTC (rev 1958) +++ trunk/src/flash/lpc3180_nand_controller.c 2009-05-31 09:37:35 UTC (rev 1959) @@ -759,12 +759,12 @@ if (data) { - target->type->read_memory(target, 0x200a8000, 4, 128, page_buffer + page_bytes_done); + target_read_memory(target, 0x200a8000, 4, 128, page_buffer + page_bytes_done); } if (oob) { - target->type->read_memory(target, 0x200a8000, 4, 4, oob_buffer + oob_bytes_done); + target_read_memory(target, 0x200a8000, 4, 4, oob_buffer + oob_bytes_done); } page_bytes_done += 512; Modified: trunk/src/flash/mflash.c =================================================================== --- trunk/src/flash/mflash.c 2009-05-31 06:00:28 UTC (rev 1958) +++ trunk/src/flash/mflash.c 2009-05-31 09:37:35 UTC (rev 1959) @@ -345,7 +345,7 @@ if (! mflash_bank->drv_info) mflash_bank->drv_info = malloc(sizeof(mg_drv_info_t)); - target->type->read_memory(target, mg_buff, 2, sizeof(mg_io_type_drv_info) >> 1, + target_read_memory(target, mg_buff, 2, sizeof(mg_io_type_drv_info) >> 1, (u8 *)&mflash_bank->drv_info->drv_id); mflash_bank->drv_info->tot_sects = (u32)(mflash_bank->drv_info->drv_id.total_user_addressable_sectors_hi << 16) @@ -428,7 +428,7 @@ for (i = 0; i < sect_cnt; i++) { mg_dsk_wait(mg_io_wait_drq, MG_OEM_DISK_WAIT_TIME_NORMAL); - target->type->read_memory(target, address, 2, MG_MFLASH_SECTOR_SIZE / 2, buff_ptr); + target_read_memory(target, address, 2, MG_MFLASH_SECTOR_SIZE / 2, buff_ptr); buff_ptr += MG_MFLASH_SECTOR_SIZE; target_write_u8(target, mflash_bank->base + MG_REG_OFFSET + MG_REG_COMMAND, mg_io_cmd_confirm_read); @@ -932,7 +932,7 @@ memset(buff, 0xff, MG_MFLASH_SECTOR_SIZE); - target->type->read_memory(target, address, 2, + target_read_memory(target, address, 2, MG_MFLASH_SECTOR_SIZE / 2, (u8 *)buff); for (i = 0; i < MG_MFLASH_SECTOR_SIZE >> 1; i++) { Modified: trunk/src/target/arm7_9_common.c =================================================================== --- trunk/src/target/arm7_9_common.c 2009-05-31 06:00:28 UTC (rev 1958) +++ trunk/src/target/arm7_9_common.c 2009-05-31 09:37:35 UTC (rev 1959) @@ -274,7 +274,7 @@ { u32 verify = 0xffffffff; /* keep the original instruction in target endianness */ - if ((retval = target->type->read_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK) + if ((retval = target_read_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK) { return retval; } @@ -298,7 +298,7 @@ { u16 verify = 0xffff; /* keep the original instruction in target endianness */ - if ((retval = target->type->read_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK) + if ((retval = target_read_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK) { return retval; } @@ -373,7 +373,7 @@ { u32 current_instr; /* check that user program as not modified breakpoint instruction */ - if ((retval = target->type->read_memory(target, breakpoint->address, 4, 1, (u8*)¤t_instr)) != ERROR_OK) + if ((retval = target_read_memory(target, breakpoint->address, 4, 1, (u8*)¤t_instr)) != ERROR_OK) { return retval; } @@ -387,7 +387,7 @@ { u16 current_instr; /* check that user program as not modified breakpoint instruction */ - if ((retval = target->type->read_memory(target, breakpoint->address, 2, 1, (u8*)¤t_instr)) != ERROR_OK) + if ((retval = target_read_memory(target, breakpoint->address, 2, 1, (u8*)¤t_instr)) != ERROR_OK) { return retval; } Modified: trunk/src/target/cortex_m3.c =================================================================== --- trunk/src/target/cortex_m3.c 2009-05-31 06:00:28 UTC (rev 1958) +++ trunk/src/target/cortex_m3.c 2009-05-31 09:37:35 UTC (rev 1959) @@ -930,7 +930,7 @@ { u8 code[4]; buf_set_u32(code, 0, 32, ARMV7M_T_BKPT(0x11)); - if((retval = target->type->read_memory(target, breakpoint->address & 0xFFFFFFFE, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK) + if((retval = target_read_memory(target, breakpoint->address & 0xFFFFFFFE, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK) { return retval; } Modified: trunk/src/target/mips_m4k.c =================================================================== --- trunk/src/target/mips_m4k.c 2009-05-31 06:00:28 UTC (rev 1958) +++ trunk/src/target/mips_m4k.c 2009-05-31 09:37:35 UTC (rev 1959) @@ -529,7 +529,7 @@ { u32 verify = 0xffffffff; - if((retval = target->type->read_memory(target, breakpoint->address, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK) + if((retval = target_read_memory(target, breakpoint->address, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK) { return retval; } @@ -552,7 +552,7 @@ { u16 verify = 0xffff; - if((retval = target->type->read_memory(target, breakpoint->address, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK) + if((retval = target_read_memory(target, breakpoint->address, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK) { return retval; } @@ -611,7 +611,7 @@ u32 current_instr; /* check that user program has not modified breakpoint instruction */ - if ((retval = target->type->read_memory(target, breakpoint->address, 4, 1, (u8*)¤t_instr)) != ERROR_OK) + if ((retval = target_read_memory(target, breakpoint->address, 4, 1, (u8*)¤t_instr)) != ERROR_OK) { return retval; } @@ -628,7 +628,7 @@ u16 current_instr; /* check that user program has not modified breakpoint instruction */ - if ((retval = target->type->read_memory(target, breakpoint->address, 2, 1, (u8*)¤t_instr)) != ERROR_OK) + if ((retval = target_read_memory(target, breakpoint->address, 2, 1, (u8*)¤t_instr)) != ERROR_OK) { return retval; } Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-05-31 06:00:28 UTC (rev 1958) +++ trunk/src/target/target.c 2009-05-31 09:37:35 UTC (rev 1959) @@ -525,6 +525,12 @@ return target->type->run_algorithm_imp(target, num_mem_params, mem_params, num_reg_params, reg_param, entry_point, exit_point, timeout_ms, arch_info); } +int target_read_memory(struct target_s *target, + u32 address, u32 size, u32 count, u8 *buffer) +{ + return target->type->read_memory(target, address, size, count, buffer); +} + int target_init(struct command_context_s *cmd_ctx) { target_t *target = all_targets; @@ -858,7 +864,7 @@ { int retval; new_wa->backup = malloc(new_wa->size); - if((retval = target->type->read_memory(target, new_wa->address, 4, new_wa->size / 4, new_wa->backup)) != ERROR_OK) + if((retval = target_read_memory(target, new_wa->address, 4, new_wa->size / 4, new_wa->backup)) != ERROR_OK) { free(new_wa->backup); free(new_wa); @@ -1077,7 +1083,7 @@ if (((address % 2) == 0) && (size == 2)) { - return target->type->read_memory(target, address, 2, 1, buffer); + return target_read_memory(target, address, 2, 1, buffer); } /* handle unaligned head bytes */ @@ -1088,7 +1094,7 @@ if (unaligned > size) unaligned = size; - if ((retval = target->type->read_memory(target, address, 1, unaligned, buffer)) != ERROR_OK) + if ((retval = target_read_memory(target, address, 1, unaligned, buffer)) != ERROR_OK) return retval; buffer += unaligned; @@ -1101,7 +1107,7 @@ { int aligned = size - (size % 4); - if ((retval = target->type->read_memory(target, address, 4, aligned / 4, buffer)) != ERROR_OK) + if ((retval = target_read_memory(target, address, 4, aligned / 4, buffer)) != ERROR_OK) return retval; buffer += aligned; @@ -1112,7 +1118,7 @@ /* handle tail writes of less than 4 bytes */ if (size > 0) { - if ((retval = target->type->read_memory(target, address, 1, size, buffer)) != ERROR_OK) + if ((retval = target_read_memory(target, address, 1, size, buffer)) != ERROR_OK) return retval; } @@ -1190,7 +1196,7 @@ return ERROR_FAIL; } - int retval = target->type->read_memory(target, address, 4, 1, value_buf); + int retval = target_read_memory(target, address, 4, 1, value_buf); if (retval == ERROR_OK) { @@ -1215,7 +1221,7 @@ return ERROR_FAIL; } - int retval = target->type->read_memory(target, address, 2, 1, value_buf); + int retval = target_read_memory(target, address, 2, 1, value_buf); if (retval == ERROR_OK) { @@ -1233,7 +1239,7 @@ int target_read_u8(struct target_s *target, u32 address, u8 *value) { - int retval = target->type->read_memory(target, address, 1, 1, value); + int retval = target_read_memory(target, address, 1, 1, value); if (!target->type->examined) { LOG_ERROR("Target not examined yet"); @@ -1914,7 +1920,7 @@ u8 *buffer = calloc(count, size); target_t *target = get_current_target(cmd_ctx); - int retval = target->type->read_memory(target, + int retval = target_read_memory(target, address, size, count, buffer); if (ERROR_OK == retval) handle_md_output(cmd_ctx, target, address, size, count, buffer); @@ -2256,7 +2262,7 @@ size *= 4; count /= 4; } - retval = target->type->read_memory(target, image.sections[i].base_address, size, count, data); + retval = target_read_memory(target, image.sections[i].base_address, size, count, data); if (retval == ERROR_OK) { u32 t; @@ -2829,7 +2835,7 @@ count = (sizeof(buffer)/width); } - retval = target->type->read_memory( target, addr, width, count, buffer ); + retval = target_read_memory( target, addr, width, count, buffer ); if (retval != ERROR_OK) { /* BOO !*/ LOG_ERROR("mem2array: Read @ 0x%08x, w=%d, cnt=%d, failed", addr, width, count); @@ -3575,7 +3581,7 @@ if( y > 16 ){ y = 16; } - e = target->type->read_memory( target, a, b, y / b, target_buf ); + e = target_read_memory( target, a, b, y / b, target_buf ); if( e != ERROR_OK ){ Jim_SetResult_sprintf( interp, "error reading target @ 0x%08lx", (int)(a) ); return JIM_ERR; Modified: trunk/src/target/target.h =================================================================== --- trunk/src/target/target.h 2009-05-31 06:00:28 UTC (rev 1958) +++ trunk/src/target/target.h 2009-05-31 09:37:35 UTC (rev 1959) @@ -161,6 +161,10 @@ * count: number of items of <size> */ int (*read_memory_imp)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); + /** + * Target memory read callback. Do @b not call this function + * directly, use target_read_memory() instead. + */ int (*read_memory)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); int (*write_memory_imp)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); int (*write_memory)(struct target_s *target, u32 address, u32 size, u32 count, u8 *buffer); @@ -371,6 +375,15 @@ extern int get_num_by_target(target_t *query_target); extern target_t *get_target(const char *id); +/** + * Read @count items of @a size bytes from the memory of @a target at + * the @a address given. + * + * This routine is a wrapper for target->type->read_memory. + */ +extern int target_read_memory(struct target_s *target, + u32 address, u32 size, u32 count, u8 *buffer); + extern int target_write_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer); extern int target_read_buffer(struct target_s *target, u32 address, u32 size, u8 *buffer); extern int target_checksum_memory(struct target_s *target, u32 address, u32 size, u32* crc); Modified: trunk/src/target/xscale.c =================================================================== --- trunk/src/target/xscale.c 2009-05-31 06:00:28 UTC (rev 1958) +++ trunk/src/target/xscale.c 2009-05-31 09:37:35 UTC (rev 1959) @@ -2187,7 +2187,7 @@ if (breakpoint->length == 4) { /* keep the original instruction in target endianness */ - if((retval = target->type->read_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK) + if((retval = target_read_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK) { return retval; } @@ -2200,7 +2200,7 @@ else { /* keep the original instruction in target endianness */ - if((retval = target->type->read_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK) + if((retval = target_read_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK) { return retval; } |
From: <zw...@ma...> - 2009-05-31 08:00:37
|
Author: zwelch Date: 2009-05-31 08:00:28 +0200 (Sun, 31 May 2009) New Revision: 1958 Modified: trunk/src/target/target.c Log: Simplify the handle_md_command routine in target.c: - fix buffer overrun in mdw; final '\0' would overflow the output buffer. - return ERROR_COMMAND_SYNTAX_ERROR instead of ERROR_OK if: - less than one argument is provided - the command is called with a name other than mdb, mdh, or mdw. - factor all command output into new handle_md_output function Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-05-31 04:58:51 UTC (rev 1957) +++ trunk/src/target/target.c 2009-05-31 06:00:28 UTC (rev 1958) @@ -1844,77 +1844,80 @@ return ERROR_OK; } -static int handle_md_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +static void handle_md_output(struct command_context_s *cmd_ctx, + struct target_s *target, u32 address, unsigned size, + unsigned count, const u8 *buffer) { - const int line_bytecnt = 32; - int count = 1; - int size = 4; - u32 address = 0; - int line_modulo; - int i; + const unsigned line_bytecnt = 32; + unsigned line_modulo = line_bytecnt / size; - char output[128]; - int output_len; + char output[line_bytecnt * 4 + 1]; + unsigned output_len = 0; - int retval; + const char *value_fmt; + switch (size) { + case 4: value_fmt = "%8.8x"; break; + case 2: value_fmt = "%4.2x"; break; + case 1: value_fmt = "%2.2x"; break; + default: + LOG_ERROR("invalid memory read size: %u", size); + exit(-1); + } - u8 *buffer; - target_t *target = get_current_target(cmd_ctx); + for (unsigned i = 0; i < count; i++) + { + if (i % line_modulo == 0) + { + output_len += snprintf(output + output_len, + sizeof(output) - output_len, + "0x%8.8x: ", address + (i*size)); + } - if (argc < 1) - return ERROR_OK; + u32 value; + const u8 *value_ptr = buffer + i * size; + switch (size) { + case 4: value = target_buffer_get_u32(target, value_ptr); break; + case 2: value = target_buffer_get_u16(target, value_ptr); break; + case 1: value = *value_ptr; + } + output_len += snprintf(output + output_len, + sizeof(output) - output_len, + value_fmt, value); - if (argc == 2) - count = strtoul(args[1], NULL, 0); + if ((i % line_modulo == line_modulo - 1) || (i == count - 1)) + { + command_print(cmd_ctx, "%s", output); + output_len = 0; + } + } +} - address = strtoul(args[0], NULL, 0); +static int handle_md_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) +{ + if (argc < 1) + return ERROR_COMMAND_SYNTAX_ERROR; - switch (cmd[2]) - { - case 'w': - size = 4; line_modulo = line_bytecnt / 4; - break; - case 'h': - size = 2; line_modulo = line_bytecnt / 2; - break; - case 'b': - size = 1; line_modulo = line_bytecnt / 1; - break; - default: - return ERROR_OK; + unsigned size = 0; + switch (cmd[2]) { + case 'w': size = 4; break; + case 'h': size = 2; break; + case 'b': size = 1; break; + default: return ERROR_COMMAND_SYNTAX_ERROR; } - buffer = calloc(count, size); - retval = target->type->read_memory(target, address, size, count, buffer); - if (retval == ERROR_OK) - { - output_len = 0; + u32 address = strtoul(args[0], NULL, 0); - for (i = 0; i < count; i++) - { - if (i%line_modulo == 0) - output_len += snprintf(output + output_len, 128 - output_len, "0x%8.8x: ", address + (i*size)); + unsigned count = 1; + if (argc == 2) + count = strtoul(args[1], NULL, 0); - switch (size) - { - case 4: - output_len += snprintf(output + output_len, 128 - output_len, "%8.8x ", target_buffer_get_u32(target, &buffer[i*4])); - break; - case 2: - output_len += snprintf(output + output_len, 128 - output_len, "%4.4x ", target_buffer_get_u16(target, &buffer[i*2])); - break; - case 1: - output_len += snprintf(output + output_len, 128 - output_len, "%2.2x ", buffer[i*1]); - break; - } + u8 *buffer = calloc(count, size); - if ((i%line_modulo == line_modulo-1) || (i == count - 1)) - { - command_print(cmd_ctx, "%s", output); - output_len = 0; - } - } - } + target_t *target = get_current_target(cmd_ctx); + int retval = target->type->read_memory(target, + address, size, count, buffer); + if (ERROR_OK == retval) + handle_md_output(cmd_ctx, target, address, size, count, buffer); free(buffer); |
From: <zw...@ma...> - 2009-05-31 06:58:59
|
Author: zwelch Date: 2009-05-31 06:58:51 +0200 (Sun, 31 May 2009) New Revision: 1957 Modified: trunk/src/target/target.c trunk/src/target/target.h Log: Make nvp_target_event static; remove its external declaration. Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-05-31 02:18:26 UTC (rev 1956) +++ trunk/src/target/target.c 2009-05-31 04:58:51 UTC (rev 1957) @@ -150,7 +150,7 @@ } } -const Jim_Nvp nvp_target_event[] = { +static const Jim_Nvp nvp_target_event[] = { { .value = TARGET_EVENT_OLD_gdb_program_config , .name = "old-gdb_program_config" }, { .value = TARGET_EVENT_OLD_pre_resume , .name = "old-pre_resume" }, Modified: trunk/src/target/target.h =================================================================== --- trunk/src/target/target.h 2009-05-31 02:18:26 UTC (rev 1956) +++ trunk/src/target/target.h 2009-05-31 04:58:51 UTC (rev 1957) @@ -318,8 +318,6 @@ TARGET_EVENT_GDB_FLASH_WRITE_END, }; -extern const Jim_Nvp nvp_target_event[]; - struct target_event_action_s { enum target_event event; Jim_Obj *body; |
From: <zw...@ma...> - 2009-05-31 04:18:33
|
Author: zwelch Date: 2009-05-31 04:18:26 +0200 (Sun, 31 May 2009) New Revision: 1956 Modified: trunk/src/target/target.c trunk/src/target/target.h Log: Make target_buffer_get_uXX interfaces work with constant buffers. Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-05-31 01:07:43 UTC (rev 1955) +++ trunk/src/target/target.c 2009-05-31 02:18:26 UTC (rev 1956) @@ -273,7 +273,7 @@ static int target_continous_poll = 1; /* read a u32 from a buffer in target memory endianness */ -u32 target_buffer_get_u32(target_t *target, u8 *buffer) +u32 target_buffer_get_u32(target_t *target, const u8 *buffer) { if (target->endianness == TARGET_LITTLE_ENDIAN) return le_to_h_u32(buffer); @@ -282,7 +282,7 @@ } /* read a u16 from a buffer in target memory endianness */ -u16 target_buffer_get_u16(target_t *target, u8 *buffer) +u16 target_buffer_get_u16(target_t *target, const u8 *buffer) { if (target->endianness == TARGET_LITTLE_ENDIAN) return le_to_h_u16(buffer); @@ -291,7 +291,7 @@ } /* read a u8 from a buffer in target memory endianness */ -u8 target_buffer_get_u8(target_t *target, u8 *buffer) +u8 target_buffer_get_u8(target_t *target, const u8 *buffer) { return *buffer & 0x0ff; } Modified: trunk/src/target/target.h =================================================================== --- trunk/src/target/target.h 2009-05-31 01:07:43 UTC (rev 1955) +++ trunk/src/target/target.h 2009-05-31 02:18:26 UTC (rev 1956) @@ -401,9 +401,9 @@ extern target_event_callback_t *target_event_callbacks; extern target_timer_callback_t *target_timer_callbacks; -extern u32 target_buffer_get_u32(target_t *target, u8 *buffer); -extern u16 target_buffer_get_u16(target_t *target, u8 *buffer); -extern u8 target_buffer_get_u8 (target_t *target, u8 *buffer); +extern u32 target_buffer_get_u32(target_t *target, const u8 *buffer); +extern u16 target_buffer_get_u16(target_t *target, const u8 *buffer); +extern u8 target_buffer_get_u8 (target_t *target, const u8 *buffer); extern void target_buffer_set_u32(target_t *target, u8 *buffer, u32 value); extern void target_buffer_set_u16(target_t *target, u8 *buffer, u16 value); extern void target_buffer_set_u8 (target_t *target, u8 *buffer, u8 value); |
From: <zw...@ma...> - 2009-05-31 03:07:48
|
Author: zwelch Date: 2009-05-31 03:07:43 +0200 (Sun, 31 May 2009) New Revision: 1955 Modified: trunk/src/jtag/jlink.c Log: Peter Denison <op...@ma...>: The debugging code in jlink_tap_execute() called when _DEBUG_USB_COMMS_ is defined was using the entire cached scan length to print the results buffers, and not the correct length of each individual buffer. Modified: trunk/src/jtag/jlink.c =================================================================== --- trunk/src/jtag/jlink.c 2009-05-31 00:49:03 UTC (rev 1954) +++ trunk/src/jtag/jlink.c 2009-05-31 01:07:43 UTC (rev 1955) @@ -809,7 +809,7 @@ DEBUG_JTAG_IO("pending scan result, length = %d", length); #ifdef _DEBUG_USB_COMMS_ - jlink_debug_buffer(buffer, byte_length); + jlink_debug_buffer(buffer, TAP_SCAN_BYTES(length)); #endif if (jtag_read_buffer(buffer, command) != ERROR_OK) |
From: <zw...@ma...> - 2009-05-31 02:49:40
|
Author: zwelch Date: 2009-05-31 02:49:03 +0200 (Sun, 31 May 2009) New Revision: 1954 Modified: trunk/doc/manual/primer/jtag.txt Log: Add new JTAG boundary scan primer, with links to BSDL information. Modified: trunk/doc/manual/primer/jtag.txt =================================================================== --- trunk/doc/manual/primer/jtag.txt 2009-05-30 23:57:30 UTC (rev 1953) +++ trunk/doc/manual/primer/jtag.txt 2009-05-31 00:49:03 UTC (rev 1954) @@ -11,12 +11,10 @@ Think of JTAG as I2C for testing. It doesn't define what it can do, just a logical interface that allows a uniform channel for communication. -See: - +See @par http://en.wikipedia.org/wiki/Joint_Test_Action_Group -and - +and @par http://www.inaccessnetworks.com/projects/ianjtag/jtag-intro/jtag-state-machine-large.png The first page (among other things) shows a logical representation @@ -107,4 +105,64 @@ registers do, so you can actually do something useful. That's where it gets interesting. But in and of itself, JTAG is actually very simple. +A separate primer contains information about @subpage primerjtagbs for +developers that want to extend OpenOCD for such purposes. + */ +/** @page primerjtagbs JTAG Boundary Scan Primer + +The following page provides an introduction on JTAG that focuses on its +boundary scan capabilities: @par +http://www.engr.udayton.edu/faculty/jloomis/ece446/notes/jtag/jtag1.html + +OpenOCD does not presently have clear means of using JTAG for boundary +scan testing purposes; however, some developers have explored the +possibilities. The page contains information that may be useful to +those wishing to implement boundary scan capabilities in OpenOCD. + +@section primerbsdl The BSDL Language + +For more information on the Boundary Scan Description Language (BSDL), +the following page provides a good introduction: @par +http://www.radio-electronics.com/info/t_and_m/boundaryscan/bsdl.php + +@section primerbsdlvendors Vendor BSDL Files + +NXP LPC: @par +http://www.standardics.nxp.com/support/models/lpc2000/ + +Freescale PowerPC: @par +http://www.freescale.com/webapp/sps/site/overview.jsp?code=DRPPCBSDLFLS + +Freescale i.MX1 (too old): @par +http://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=i.MX1&nodeId=0162468rH311432973ZrDR&fpsp=1&tab=Design_Tools_Tab + +Renesas R32C/117: @par +http://sg.renesas.com/fmwk.jsp?cnt=r32c116_7_8_root.jsp&fp=/products/mpumcu/m16c_family/r32c100_series/r32c116_7_8_group/ +- The device page does not come with BSDL file; you have to register to + download them. @par + http://www.corelis.com/support/BSDL.htm + +TI links theirs right off the generic page for each chip; +this may be the case for other vendors as well. For example: + +- DaVinci DM355 -- http://www.ti.com/litv/zip/sprm262b +- DaVinci DM6446 + - 2.1 silicon -- http://www.ti.com/litv/zip/sprm325a + - older silicon -- http://www.ti.com/litv/zip/sprm203 +- OMAP 3530 + - CBB package -- http://www.ti.com/litv/zip/sprm315b + - 515 ball s-PGBA, POP, 0.4mm pitch + - CUS package -- http://www.ti.com/litv/zip/sprm314a + - 515 ball s-PGBA, POP, 0.5mm pitch + - CBC package -- http://www.ti.com/litv/zip/sprm346 + - 423 ball s-PGBA, 0.65mm pitch + +Many other files are available in the "Semiconductor Manufacturer's BSDL +files" section of the following site: @par +http://www.freelabs.com/~whitis/electronics/jtag/ + + */ +/** @file +This file contains the @ref primerjtag and @ref bsdl page. + */ |
From: <zw...@ma...> - 2009-05-31 01:57:35
|
Author: zwelch Date: 2009-05-31 01:57:30 +0200 (Sun, 31 May 2009) New Revision: 1953 Modified: trunk/src/target/target.c Log: Eliminate duplicated code in the handle_mw_command memory write loop. - wordsize will always be 1, 2, or 4 due to preceeding switch statement. - move call to keep_alive after successful writes, not upon failures Modified: trunk/src/target/target.c =================================================================== --- trunk/src/target/target.c 2009-05-30 22:23:12 UTC (rev 1952) +++ trunk/src/target/target.c 2009-05-30 23:57:30 UTC (rev 1953) @@ -1958,27 +1958,11 @@ } for (i=0; i<count; i++) { - int retval; - switch (wordsize) - { - case 4: - retval = target->type->write_memory(target, address + i*wordsize, 4, 1, value_buf); - break; - case 2: - retval = target->type->write_memory(target, address + i*wordsize, 2, 1, value_buf); - break; - case 1: - retval = target->type->write_memory(target, address + i*wordsize, 1, 1, value_buf); - break; - default: - return ERROR_OK; - } - keep_alive(); - - if (retval!=ERROR_OK) - { + int retval = target->type->write_memory(target, + address + i * wordsize, wordsize, 1, value_buf); + if (ERROR_OK != retval) return retval; - } + keep_alive(); } return ERROR_OK; |
From: <zw...@ma...> - 2009-05-31 00:23:19
|
Author: zwelch Date: 2009-05-31 00:23:12 +0200 (Sun, 31 May 2009) New Revision: 1952 Modified: trunk/src/jtag/jtag.c trunk/src/jtag/jtag.h trunk/src/openocd.c Log: Encapsulate the global "jtag" jtag_interface pointer: - Add jtag_interface_quit, factored from exit_handler() in openocd.c. - Remove its extern declaration. - Add static keyword to its definition. Modified: trunk/src/jtag/jtag.c =================================================================== --- trunk/src/jtag/jtag.c 2009-05-30 21:53:10 UTC (rev 1951) +++ trunk/src/jtag/jtag.c 2009-05-30 22:23:12 UTC (rev 1952) @@ -227,7 +227,7 @@ NULL, }; -jtag_interface_t *jtag = NULL; +static jtag_interface_t *jtag = NULL; /* configuration */ static jtag_interface_t *jtag_interface = NULL; @@ -2407,6 +2407,20 @@ return ERROR_OK; } +int jtag_interface_quit(void) +{ + if (!jtag || !jtag->quit) + return ERROR_OK; + + // close the JTAG interface + int result = jtag->quit(); + if (ERROR_OK != result) + LOG_ERROR("failed: %d", result); + + return ERROR_OK; +} + + int jtag_init_reset(struct command_context_s *cmd_ctx) { int retval; Modified: trunk/src/jtag/jtag.h =================================================================== --- trunk/src/jtag/jtag.h 2009-05-30 21:53:10 UTC (rev 1951) +++ trunk/src/jtag/jtag.h 2009-05-30 22:23:12 UTC (rev 1952) @@ -512,8 +512,6 @@ extern jtag_event_callback_t* jtag_event_callbacks; -extern jtag_interface_t* jtag; /* global pointer to configured JTAG interface */ - extern int jtag_speed; extern int jtag_speed_post_reset; @@ -535,6 +533,9 @@ */ extern int jtag_interface_init(struct command_context_s* cmd_ctx); +/// Shutdown the JTAG interface upon program exit. +extern int jtag_interface_quit(void); + /* initialize JTAG chain using only a RESET reset. If init fails, * try reset + init. */ Modified: trunk/src/openocd.c =================================================================== --- trunk/src/openocd.c 2009-05-30 21:53:10 UTC (rev 1951) +++ trunk/src/openocd.c 2009-05-30 22:23:12 UTC (rev 1952) @@ -79,9 +79,7 @@ static void exit_handler(void) { - /* close JTAG interface */ - if (jtag && jtag->quit) - jtag->quit(); + jtag_interface_quit(); } static int log_target_callback_event_handler(struct target_s *target, enum target_event event, void *priv) |
From: <zw...@ma...> - 2009-05-30 23:53:16
|
Author: zwelch Date: 2009-05-30 23:53:10 +0200 (Sat, 30 May 2009) New Revision: 1951 Modified: trunk/src/jtag/jlink.c Log: Remove unused jlink_execute_end_state (unreferenced after r1949). Modified: trunk/src/jtag/jlink.c =================================================================== --- trunk/src/jtag/jlink.c 2009-05-30 11:55:14 UTC (rev 1950) +++ trunk/src/jtag/jlink.c 2009-05-30 21:53:10 UTC (rev 1951) @@ -150,14 +150,6 @@ .quit = jlink_quit }; -static void jlink_execute_end_state(jtag_command_t *cmd) -{ - DEBUG_JTAG_IO("end_state: %i", cmd->cmd.end_state->end_state); - - if (cmd->cmd.end_state->end_state != TAP_INVALID) - jlink_end_state(cmd->cmd.end_state->end_state); -} - static void jlink_execute_runtest(jtag_command_t *cmd) { DEBUG_JTAG_IO("runtest %i cycles, end in %i", |
From: <oh...@ma...> - 2009-05-30 13:55:16
|
Author: oharboe Date: 2009-05-30 13:55:14 +0200 (Sat, 30 May 2009) New Revision: 1950 Modified: trunk/src/jtag/ft2232.c trunk/src/jtag/jtag.h Log: remove unused JTAG_END_STATE part 2 Modified: trunk/src/jtag/ft2232.c =================================================================== --- trunk/src/jtag/ft2232.c 2009-05-30 11:37:21 UTC (rev 1949) +++ trunk/src/jtag/ft2232.c 2009-05-30 11:55:14 UTC (rev 1950) @@ -512,7 +512,6 @@ } } - static void ft2232_read_scan(enum scan_type type, u8* buffer, int scan_size) { int num_bytes = (scan_size + 7) / 8; @@ -1412,20 +1411,6 @@ LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction); } -static int ft2232_execute_end_state(jtag_command_t *cmd) -{ - int retval; - retval = ERROR_OK; - - DEBUG_JTAG_IO("execute_end_state: %s", tap_state_name(cmd->cmd.end_state->end_state) ); - - if (cmd->cmd.end_state->end_state != TAP_INVALID) - ft2232_end_state(cmd->cmd.end_state->end_state); - - return retval; -} - - static int ft2232_execute_runtest(jtag_command_t *cmd) { int retval; @@ -1682,7 +1667,6 @@ switch (cmd->type) { - case JTAG_END_STATE: retval = ft2232_execute_end_state(cmd); break; case JTAG_RESET: retval = ft2232_execute_reset(cmd); break; case JTAG_RUNTEST: retval = ft2232_execute_runtest(cmd); break; case JTAG_STATEMOVE: retval = ft2232_execute_statemove(cmd); break; Modified: trunk/src/jtag/jtag.h =================================================================== --- trunk/src/jtag/jtag.h 2009-05-30 11:37:21 UTC (rev 1949) +++ trunk/src/jtag/jtag.h 2009-05-30 11:55:14 UTC (rev 1950) @@ -348,7 +348,6 @@ JTAG_STATEMOVE = 2, JTAG_RUNTEST = 3, JTAG_RESET = 4, - JTAG_END_STATE = 5, JTAG_PATHMOVE = 6, JTAG_SLEEP = 7, JTAG_STABLECLOCKS = 8 |
From: <oh...@ma...> - 2009-05-30 13:37:27
|
Author: oharboe Date: 2009-05-30 13:37:21 +0200 (Sat, 30 May 2009) New Revision: 1949 Modified: trunk/src/jtag/amt_jtagaccel.c trunk/src/jtag/arm-jtag-ew.c trunk/src/jtag/bitbang.c trunk/src/jtag/bitq.c trunk/src/jtag/gw16012.c trunk/src/jtag/jlink.c trunk/src/jtag/rlink/rlink.c trunk/src/jtag/usbprog.c trunk/src/jtag/vsllink.c Log: remove unused JTAG_END_STATE Modified: trunk/src/jtag/amt_jtagaccel.c =================================================================== --- trunk/src/jtag/amt_jtagaccel.c 2009-05-30 07:56:14 UTC (rev 1948) +++ trunk/src/jtag/amt_jtagaccel.c 2009-05-30 11:37:21 UTC (rev 1949) @@ -332,13 +332,6 @@ { switch (cmd->type) { - case JTAG_END_STATE: -#ifdef _DEBUG_JTAG_IO_ - LOG_DEBUG("end_state: %i", cmd->cmd.end_state->end_state); -#endif - if (cmd->cmd.end_state->end_state != TAP_INVALID) - amt_jtagaccel_end_state(cmd->cmd.end_state->end_state); - break; case JTAG_RESET: #ifdef _DEBUG_JTAG_IO_ LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); Modified: trunk/src/jtag/arm-jtag-ew.c =================================================================== --- trunk/src/jtag/arm-jtag-ew.c 2009-05-30 07:56:14 UTC (rev 1948) +++ trunk/src/jtag/arm-jtag-ew.c 2009-05-30 11:37:21 UTC (rev 1949) @@ -133,15 +133,6 @@ { switch (cmd->type) { - case JTAG_END_STATE: - DEBUG_JTAG_IO("end_state: %i", cmd->cmd.end_state->end_state); - - if (cmd->cmd.end_state->end_state != TAP_INVALID) - { - armjtagew_end_state(cmd->cmd.end_state->end_state); - } - break; - case JTAG_RUNTEST: DEBUG_JTAG_IO( "runtest %i cycles, end in %i", cmd->cmd.runtest->num_cycles, \ cmd->cmd.runtest->end_state); Modified: trunk/src/jtag/bitbang.c =================================================================== --- trunk/src/jtag/bitbang.c 2009-05-30 07:56:14 UTC (rev 1948) +++ trunk/src/jtag/bitbang.c 2009-05-30 11:37:21 UTC (rev 1949) @@ -253,13 +253,6 @@ { switch (cmd->type) { - case JTAG_END_STATE: -#ifdef _DEBUG_JTAG_IO_ - LOG_DEBUG("end_state: %s", tap_state_name(cmd->cmd.end_state->end_state) ); -#endif - if (cmd->cmd.end_state->end_state != TAP_INVALID) - bitbang_end_state(cmd->cmd.end_state->end_state); - break; case JTAG_RESET: #ifdef _DEBUG_JTAG_IO_ LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); Modified: trunk/src/jtag/bitq.c =================================================================== --- trunk/src/jtag/bitq.c 2009-05-30 07:56:14 UTC (rev 1948) +++ trunk/src/jtag/bitq.c 2009-05-30 11:37:21 UTC (rev 1949) @@ -296,13 +296,6 @@ { switch (cmd->type) { - case JTAG_END_STATE: -#ifdef _DEBUG_JTAG_IO_ - LOG_DEBUG("end_state: %i", cmd->cmd.end_state->end_state); -#endif - bitq_end_state(cmd->cmd.end_state->end_state); - break; - case JTAG_RESET: #ifdef _DEBUG_JTAG_IO_ LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); Modified: trunk/src/jtag/gw16012.c =================================================================== --- trunk/src/jtag/gw16012.c 2009-05-30 07:56:14 UTC (rev 1948) +++ trunk/src/jtag/gw16012.c 2009-05-30 11:37:21 UTC (rev 1949) @@ -354,13 +354,6 @@ { switch (cmd->type) { - case JTAG_END_STATE: -#ifdef _DEBUG_JTAG_IO_ - LOG_DEBUG("end_state: %i", cmd->cmd.end_state->end_state); -#endif - if (cmd->cmd.end_state->end_state != TAP_INVALID) - gw16012_end_state(cmd->cmd.end_state->end_state); - break; case JTAG_RESET: #ifdef _DEBUG_JTAG_IO_ LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); Modified: trunk/src/jtag/jlink.c =================================================================== --- trunk/src/jtag/jlink.c 2009-05-30 07:56:14 UTC (rev 1948) +++ trunk/src/jtag/jlink.c 2009-05-30 11:37:21 UTC (rev 1949) @@ -234,7 +234,6 @@ { switch (cmd->type) { - case JTAG_END_STATE: jlink_execute_end_state(cmd); break; case JTAG_RUNTEST: jlink_execute_runtest(cmd); break; case JTAG_STATEMOVE: jlink_execute_statemove(cmd); break; case JTAG_PATHMOVE: jlink_execute_pathmove(cmd); break; Modified: trunk/src/jtag/rlink/rlink.c =================================================================== --- trunk/src/jtag/rlink/rlink.c 2009-05-30 07:56:14 UTC (rev 1948) +++ trunk/src/jtag/rlink/rlink.c 2009-05-30 11:37:21 UTC (rev 1949) @@ -1399,7 +1399,6 @@ { switch (cmd->type) { - case JTAG_END_STATE: case JTAG_RUNTEST: case JTAG_STATEMOVE: case JTAG_PATHMOVE: @@ -1415,13 +1414,6 @@ switch (cmd->type) { - case JTAG_END_STATE: -#ifdef _DEBUG_JTAG_IO_ - LOG_DEBUG("end_state: %i", cmd->cmd.end_state->end_state); -#endif - if (cmd->cmd.end_state->end_state != -1) - rlink_end_state(cmd->cmd.end_state->end_state); - break; case JTAG_RESET: #ifdef _DEBUG_JTAG_IO_ LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); Modified: trunk/src/jtag/usbprog.c =================================================================== --- trunk/src/jtag/usbprog.c 2009-05-30 07:56:14 UTC (rev 1948) +++ trunk/src/jtag/usbprog.c 2009-05-30 11:37:21 UTC (rev 1949) @@ -135,13 +135,6 @@ { switch (cmd->type) { - case JTAG_END_STATE: -#ifdef _DEBUG_JTAG_IO_ - LOG_DEBUG("end_state: %i", cmd->cmd.end_state->end_state); -#endif - if (cmd->cmd.end_state->end_state != TAP_INVALID) - usbprog_end_state(cmd->cmd.end_state->end_state); - break; case JTAG_RESET: #ifdef _DEBUG_JTAG_IO_ LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst); Modified: trunk/src/jtag/vsllink.c =================================================================== --- trunk/src/jtag/vsllink.c 2009-05-30 07:56:14 UTC (rev 1948) +++ trunk/src/jtag/vsllink.c 2009-05-30 11:37:21 UTC (rev 1949) @@ -296,15 +296,6 @@ { switch (cmd->type) { - case JTAG_END_STATE: - DEBUG_JTAG_IO("end_state: %s", tap_state_name(cmd->cmd.end_state->end_state)); - - if (cmd->cmd.end_state->end_state != TAP_INVALID) - { - vsllink_end_state(cmd->cmd.end_state->end_state); - } - break; - case JTAG_RUNTEST: DEBUG_JTAG_IO( "runtest %i cycles, end in %s", cmd->cmd.runtest->num_cycles, \ tap_state_name(cmd->cmd.runtest->end_state)); |
From: <oh...@ma...> - 2009-05-30 09:56:24
|
Author: oharboe Date: 2009-05-30 09:56:14 +0200 (Sat, 30 May 2009) New Revision: 1948 Modified: trunk/doc/openocd.texi Log: added some comments on meminfo command Modified: trunk/doc/openocd.texi =================================================================== --- trunk/doc/openocd.texi 2009-05-30 07:53:40 UTC (rev 1947) +++ trunk/doc/openocd.texi 2009-05-30 07:56:14 UTC (rev 1948) @@ -3488,7 +3488,9 @@ @section Memory access commands @anchor{Memory access} @subsection meminfo -display available RAM memory. +display available RAM memory on OpenOCD host. Used in OpenOCD regression testing scripts. Mainly +useful on embedded targets, PC type hosts have complimentary tools like Valgrind to address +resource tracking problems. @subsection Memory peek/poke type commands These commands allow accesses of a specific size to the memory system. Often these are used to configure the current target in some |
From: <oh...@ma...> - 2009-05-30 09:53:47
|
Author: oharboe Date: 2009-05-30 09:53:40 +0200 (Sat, 30 May 2009) New Revision: 1947 Modified: trunk/doc/openocd.texi Log: more reset_config texts Modified: trunk/doc/openocd.texi =================================================================== --- trunk/doc/openocd.texi 2009-05-30 01:44:22 UTC (rev 1946) +++ trunk/doc/openocd.texi 2009-05-30 07:53:40 UTC (rev 1947) @@ -1699,8 +1699,21 @@ @deffn {Command} reset_config mode_flag ... This command tells OpenOCD the reset configuration -of your combination of JTAG interface, board, and target. +of your combination of JTAG board and target in target +configuration scripts. +If you have an interface that does not support SRST and +TRST(unlikely), then you may be able to work around that +problem by using a reset_config command to override any +settings in the target configuration script. + +SRST and TRST has a fairly well understood definition and +behaviour in the JTAG specification, but vendors take +liberties to achieve various more or less clearly understood +goals. Sometimes documentation is available, other times it +is not. OpenOCD has the reset_config command to allow OpenOCD +to deal with the various common cases. + The @var{mode_flag} options can be specified in any order, but only one of each type -- @var{signals}, @var{combination}, @var{trst_type}, and @var{srst_type} -- may be specified at a time. |
From: <zw...@ma...> - 2009-05-30 03:44:25
|
Author: zwelch Date: 2009-05-30 03:44:22 +0200 (Sat, 30 May 2009) New Revision: 1946 Modified: trunk/src/target/oocd_trace.c Log: Remove trailing whitespace from oocd_trace source file. Modified: trunk/src/target/oocd_trace.c =================================================================== --- trunk/src/target/oocd_trace.c 2009-05-30 01:43:21 UTC (rev 1945) +++ trunk/src/target/oocd_trace.c 2009-05-30 01:44:22 UTC (rev 1946) @@ -48,7 +48,7 @@ } LOG_DEBUG("reg #%i: 0x%8.8x\n", reg, *value); - + return ERROR_OK; } @@ -92,7 +92,7 @@ else bytes_to_read -= bytes_read; } - + return ERROR_OK; } @@ -101,7 +101,7 @@ u8 trash[256]; oocd_trace_t *oocd_trace = etm_ctx->capture_driver_priv; size_t bytes_read; - + oocd_trace->tty_fd = open(oocd_trace->tty, O_RDWR | O_NOCTTY | O_NONBLOCK); if(oocd_trace->tty_fd < 0) @@ -114,32 +114,32 @@ tcflush(oocd_trace->tty_fd, TCOFLUSH); tcflush(oocd_trace->tty_fd, TCIFLUSH); fcntl(oocd_trace->tty_fd, F_SETFL, fcntl(oocd_trace->tty_fd, F_GETFL) & ~O_NONBLOCK); - + tcgetattr(oocd_trace->tty_fd, &oocd_trace->oldtio); /* save current port settings */ - + bzero(&oocd_trace->newtio, sizeof(oocd_trace->newtio)); oocd_trace->newtio.c_cflag = CS8 | CLOCAL | CREAD | B2500000; - + oocd_trace->newtio.c_iflag = IGNPAR | IGNBRK | IXON | IXOFF; oocd_trace->newtio.c_oflag = 0; - + /* set input mode (non-canonical, no echo,...) */ oocd_trace->newtio.c_lflag = 0; - + cfmakeraw(&oocd_trace->newtio); oocd_trace->newtio.c_cc[VTIME] = 1; /* inter-character timer used */ oocd_trace->newtio.c_cc[VMIN] = 0; /* blocking read until 0 chars received */ - + tcflush(oocd_trace->tty_fd, TCIFLUSH); tcsetattr(oocd_trace->tty_fd, TCSANOW, &oocd_trace->newtio); - + /* occasionally one bogus character is left in the input buffer * read up any leftover characters to ensure communication is in sync */ while ((bytes_read = read(oocd_trace->tty_fd, trash, sizeof(trash))) > 0) { LOG_DEBUG("%zi bytes read\n", bytes_read); }; - + return ERROR_OK; } @@ -147,9 +147,9 @@ { oocd_trace_t *oocd_trace = etm_ctx->capture_driver_priv; u32 status; - + oocd_trace_read_reg(oocd_trace, OOCD_TRACE_STATUS, &status); - + /* if tracing is currently idle, return this information */ if (etm_ctx->capture_status == TRACE_IDLE) { @@ -160,18 +160,18 @@ /* check Full bit to identify an overflow */ if (status & 0x4) etm_ctx->capture_status |= TRACE_OVERFLOWED; - + /* check Triggered bit to identify trigger condition */ if (status & 0x2) etm_ctx->capture_status |= TRACE_TRIGGERED; - + if (status & 0x1) { etm_ctx->capture_status &= ~TRACE_RUNNING; etm_ctx->capture_status |= TRACE_COMPLETED; } } - + return etm_ctx->capture_status; } @@ -196,7 +196,7 @@ else num_frames = address; - /* read data into temporary array for unpacking + /* read data into temporary array for unpacking * one frame from OpenOCD+trace corresponds to 16 trace cycles */ trace_data = malloc(sizeof(u8) * num_frames * 16); @@ -209,13 +209,13 @@ etm_ctx->trace_depth = num_frames * 16; etm_ctx->trace_data = malloc(sizeof(etmv1_trace_data_t) * etm_ctx->trace_depth); - + for (i = 0; i < num_frames * 16; i++) { etm_ctx->trace_data[i].pipestat = (trace_data[i] & 0x7); etm_ctx->trace_data[i].packet = (trace_data[i] & 0x78) >> 3; etm_ctx->trace_data[i].flags = 0; - + if ((trace_data[i] & 0x80) >> 7) { etm_ctx->trace_data[i].flags |= ETMV1_TRACESYNC_CYCLE; @@ -227,7 +227,7 @@ etm_ctx->trace_data[i].flags |= ETMV1_TRIGGER_CYCLE; } } - + free(trace_data); return ERROR_OK; @@ -238,19 +238,19 @@ oocd_trace_t *oocd_trace = etm_ctx->capture_driver_priv; u32 control = 0x1; /* 0x1: enabled */ u32 trigger_count; - + if (((etm_ctx->portmode & ETM_PORT_MODE_MASK) != ETM_PORT_NORMAL) || ((etm_ctx->portmode & ETM_PORT_WIDTH_MASK) != ETM_PORT_4BIT)) { LOG_DEBUG("OpenOCD+trace only supports normal 4-bit ETM mode"); return ERROR_ETM_PORTMODE_NOT_SUPPORTED; } - + if ((etm_ctx->portmode & ETM_PORT_CLOCK_MASK) == ETM_PORT_HALF_CLOCK) { control |= 0x2; /* half rate clock, capture at twice the clock rate */ } - + /* OpenOCD+trace holds up to 16 million samples, * but trigger counts is set in multiples of 16 */ trigger_count = (1048576 * etm_ctx->trigger_percent) / 100; @@ -259,22 +259,22 @@ oocd_trace_write_reg(oocd_trace, OOCD_TRACE_ADDRESS, 0x0); oocd_trace_write_reg(oocd_trace, OOCD_TRACE_TRIGGER_COUNTER, trigger_count); oocd_trace_write_reg(oocd_trace, OOCD_TRACE_CONTROL, control); - + /* we're starting a new trace, initialize capture status */ etm_ctx->capture_status = TRACE_RUNNING; - - return ERROR_OK; + + return ERROR_OK; } static int oocd_trace_stop_capture(etm_context_t *etm_ctx) { oocd_trace_t *oocd_trace = etm_ctx->capture_driver_priv; - /* trace stopped, just clear running flag, but preserve others */ + /* trace stopped, just clear running flag, but preserve others */ etm_ctx->capture_status &= ~TRACE_RUNNING; - + oocd_trace_write_reg(oocd_trace, OOCD_TRACE_CONTROL, 0x0); - + return ERROR_OK; } @@ -294,28 +294,28 @@ target_t *target; armv4_5_common_t *armv4_5; arm7_9_common_t *arm7_9; - + if (argc != 2) { LOG_ERROR("incomplete 'oocd_trace config <target> <tty>' command"); exit(-1); } - + target = get_current_target(cmd_ctx); - + if (arm7_9_get_arch_pointers(target, &armv4_5, &arm7_9) != ERROR_OK) { command_print(cmd_ctx, "current target isn't an ARM7/ARM9 target"); return ERROR_OK; } - + if (arm7_9->etm_ctx) { oocd_trace_t *oocd_trace = malloc(sizeof(oocd_trace_t)); - + arm7_9->etm_ctx->capture_driver_priv = oocd_trace; oocd_trace->etm_ctx = arm7_9->etm_ctx; - + /* copy name of TTY device used to communicate with OpenOCD+trace */ oocd_trace->tty = strndup(args[1], 256); } @@ -334,36 +334,36 @@ arm7_9_common_t *arm7_9; oocd_trace_t *oocd_trace; u32 status; - + target = get_current_target(cmd_ctx); - + if (arm7_9_get_arch_pointers(target, &armv4_5, &arm7_9) != ERROR_OK) { command_print(cmd_ctx, "current target isn't an ARM7/ARM9 target"); return ERROR_OK; } - + if (!arm7_9->etm_ctx) { command_print(cmd_ctx, "current target doesn't have an ETM configured"); return ERROR_OK; } - + if (strcmp(arm7_9->etm_ctx->capture_driver->name, "oocd_trace") != 0) { command_print(cmd_ctx, "current target's ETM capture driver isn't 'oocd_trace'"); return ERROR_OK; } - + oocd_trace = (oocd_trace_t*)arm7_9->etm_ctx->capture_driver_priv; - + oocd_trace_read_reg(oocd_trace, OOCD_TRACE_STATUS, &status); - + if (status & 0x8) command_print(cmd_ctx, "trace clock locked"); else command_print(cmd_ctx, "no trace clock"); - + return ERROR_OK; } @@ -375,33 +375,33 @@ oocd_trace_t *oocd_trace; size_t bytes_written; u8 cmd_array[1]; - + target = get_current_target(cmd_ctx); - + if (arm7_9_get_arch_pointers(target, &armv4_5, &arm7_9) != ERROR_OK) { command_print(cmd_ctx, "current target isn't an ARM7/ARM9 target"); return ERROR_OK; } - + if (!arm7_9->etm_ctx) { command_print(cmd_ctx, "current target doesn't have an ETM configured"); return ERROR_OK; } - + if (strcmp(arm7_9->etm_ctx->capture_driver->name, "oocd_trace") != 0) { command_print(cmd_ctx, "current target's ETM capture driver isn't 'oocd_trace'"); return ERROR_OK; } - + oocd_trace = (oocd_trace_t*)arm7_9->etm_ctx->capture_driver_priv; - + cmd_array[0] = 0xf0; bytes_written = write(oocd_trace->tty_fd, cmd_array, 1); - + command_print(cmd_ctx, "requesting traceclock resync"); LOG_DEBUG("resyncing traceclk pll"); @@ -411,9 +411,9 @@ int oocd_trace_register_commands(struct command_context_s *cmd_ctx) { command_t *oocd_trace_cmd; - + oocd_trace_cmd = register_command(cmd_ctx, NULL, "oocd_trace", NULL, COMMAND_ANY, "OpenOCD+trace"); - + register_command(cmd_ctx, oocd_trace_cmd, "config", handle_oocd_trace_config_command, COMMAND_CONFIG, NULL); register_command(cmd_ctx, oocd_trace_cmd, "status", handle_oocd_trace_status_command, COMMAND_EXEC, "display OpenOCD+trace status"); |
From: <zw...@ma...> - 2009-05-30 03:43:27
|
Author: zwelch Date: 2009-05-30 03:43:21 +0200 (Sat, 30 May 2009) New Revision: 1945 Modified: trunk/doc/openocd.texi trunk/src/target/etm.c trunk/src/target/oocd_trace.c Log: David Brownell <da...@pa...>: Provide basic documentation on the ARM ETM and ETB trace commands. Fix minor goofs in registration of the ETM commands; and whitespace issues in the proof-of-concept oocd_trace code. (Plus include a ref to Dominic's email saying that it's just proof-of-concept code.) Note that I'm still not sure whether the ETM support works. But documenting how it's expected to work should help sort out which behaviors are bugs, which will help get bugs patched. ZW: whitespace changes were split out of this patch but will follow. Modified: trunk/doc/openocd.texi =================================================================== --- trunk/doc/openocd.texi 2009-05-30 01:32:19 UTC (rev 1944) +++ trunk/doc/openocd.texi 2009-05-30 01:43:21 UTC (rev 1945) @@ -1094,17 +1094,11 @@ examination of the instruction and data bus activity. Trace activity is controlled through an ``Embedded Trace Module'' (ETM) on one of the core's scan chains. The ETM emits voluminous data -through a ``trace port''. The trace port is accessed in one -of two ways. When its signals are pinned out from the chip, -boards may provide a special high speed debugging connector; -software support for this is not configured by default, use -the ``--enable-oocd_trace'' option. Alternatively, trace data -may be stored an on-chip SRAM which is packaged as an ``Embedded -Trace Buffer'' (ETB). An ETB has its own TAP, usually right after -its associated ARM core. OpenOCD supports the ETM, and your -target configuration should set it up with the relevant trace -port: ``etb'' for chips which use that, else the board-specific -option will be either ``oocd_trace'' or ``dummy''. +through a ``trace port''. (@xref{ARM Tracing}.) +If you are using an external trace port, +configure it in your board config file. +If you are using an on-chip ``Embedded Trace Buffer'' (ETB), +configure it in your target config file. @example etm config $_TARGETNAME 16 normal full etb @@ -3586,6 +3580,181 @@ Some of those operations don't fit well in that framework, so they are exposed here using architecture or implementation specific commands. +@anchor{ARM Tracing} +@subsection ARM Tracing +@cindex ETM +@cindex ETB + +CPUs based on ARM cores may include standard tracing interfaces, +based on an ``Embedded Trace Module'' (ETM) which sends voluminous +address and data bus trace records to a ``Trace Port''. + +@itemize +@item +Development-oriented boards will sometimes provide a high speed +trace connector for collecting that data, when the particular CPU +supports such an interface. +(The standard connector is a 38-pin Mictor, with both JTAG +and trace port support.) +Those trace connectors are supported by higher end JTAG adapters +and some logic analyzer modules; frequently those modules can +buffer several megabytes of trace data. +Configuring an ETM coupled to such an external trace port belongs +in the board-specific configuration file. +@item +If the CPU doesn't provide an external interface, it probably +has an ``Embedded Trace Buffer'' (ETB) on the chip, which is a +dedicated SRAM. 4KBytes is one common ETB size. +Configuring an ETM coupled only to an ETB belongs in the CPU-specific +(target) configuration file, since it works the same on all boards. +@end itemize + +ETM support in OpenOCD doesn't seem to be widely used yet. + +@quotation Issues +ETM support may be buggy, and at least some @command{etm config} +parameters should be detected by asking the ETM for them. +It seems like a GDB hookup should be possible, +as well as triggering trace on specific events +(perhaps @emph{handling IRQ 23} or @emph{calls foo()}). +There should be GUI tools to manipulate saved trace data and help +analyse it in conjunction with the source code. +It's unclear how much of a common interface is shared +with the current XScale trace support, or should be +shared with eventual Nexus-style trace module support. +@end quotation + +@subsubsection ETM Configuration +ETM setup is coupled with the trace port driver configuration. + +@deffn {Config Command} {etm config} target width mode clocking driver +Declares the ETM associated with @var{target}, and associates it +with a given trace port @var{driver}. @xref{Trace Port Drivers}. + +Several of the parameters must reflect the trace port configuration. +The @var{width} must be either 4, 8, or 16. +The @var{mode} must be @option{normal}, @option{multiplexted}, +or @option{demultiplexted}. +The @var{clocking} must be @option{half} or @option{full}. + +@quotation Note +You can see the ETM registers using the @command{reg} command, although +not all of those possible registers are present in every ETM. +@end quotation +@end deffn + +@deffn Command {etm info} +Displays information about the current target's ETM. +@end deffn + +@deffn Command {etm status} +Displays status of the current target's ETM: +is the ETM idle, or is it collecting data? +Did trace data overflow? +Was it triggered? +@end deffn + +@deffn Command {etm tracemode} [type context_id_bits cycle_accurate branch_output] +Displays what data that ETM will collect. +If arguments are provided, first configures that data. +When the configuration changes, tracing is stopped +and any buffered trace data is invalidated. + +@itemize +@item @var{type} ... one of +@option{none} (save nothing), +@option{data} (save data), +@option{address} (save addresses), +@option{all} (save data and addresses) +@item @var{context_id_bits} ... 0, 8, 16, or 32 +@item @var{cycle_accurate} ... @option{enable} or @option{disable} +@item @var{branch_output} ... @option{enable} or @option{disable} +@end itemize +@end deffn + +@deffn Command {etm trigger_percent} percent +@emph{Buggy and effectively a NOP ... @var{percent} from 2..100} +@end deffn + +@subsubsection ETM Trace Operation + +After setting up the ETM, you can use it to collect data. +That data can be exported to files for later analysis. +It can also be parsed with OpenOCD, for basic sanity checking. + +@deffn Command {etm analyze} +Reads trace data into memory, if it wasn't already present. +Decodes and prints the data that was collected. +@end deffn + +@deffn Command {etm dump} filename +Stores the captured trace data in @file{filename}. +@end deffn + +@deffn Command {etm image} filename [base_address] [type] +Opens an image file. +@end deffn + +@deffn Command {etm load} filename +Loads captured trace data from @file{filename}. +@end deffn + +@deffn Command {etm start} +Starts trace data collection. +@end deffn + +@deffn Command {etm stop} +Stops trace data collection. +@end deffn + +@anchor{Trace Port Drivers} +@subsubsection Trace Port Drivers + +To use an ETM trace port it must be associated with a driver. + +@deffn {Trace Port Driver} etb +Use the @option{etb} driver if you are configuring an ETM +to use on-chip ETB memory. +@deffn {Config Command} {etb config} target etb_tap +Associates the ETM for @var{target} with the ETB at @var{etb_tap}. +You can see the ETB registers using the @command{reg} command. +@end deffn +@end deffn + +@deffn {Trace Port Driver} etm_dummy +Use the @option{etm_dummy} driver if you are configuring an ETM that's +not connected to anything (on-chip ETB or off-chip trace connector). +@emph{This driver lets OpenOCD talk to the ETM, but it does not expose +any trace data collection.} +@deffn {Config Command} {etm_dummy config} target +Associates the ETM for @var{target} with a dummy driver. +@end deffn +@end deffn + +@deffn {Trace Port Driver} oocd_trace +This driver isn't available unless OpenOCD was explicitly configured +with the @option{--enable-oocd_trace} option. You probably don't want +to configure it unless you've built the appropriate prototype hardware; +it's @emph{proof-of-concept} software. + +Use the @option{oocd_trace} driver if you are configuring an ETM that's +connected to an off-chip trace connector. + +@deffn {Config Command} {oocd_trace config} target tty +Associates the ETM for @var{target} with a trace driver which +collects data through the serial port @var{tty}. +@end deffn + +@deffn Command {oocd_trace resync} +Re-synchronizes with the capture clock. +@end deffn + +@deffn Command {oocd_trace status} +Reports whether the capture clock is locked or not. +@end deffn +@end deffn + + @subsection ARMv4 and ARMv5 Architecture @cindex ARMv4 specific commands @cindex ARMv5 specific commands Modified: trunk/src/target/etm.c =================================================================== --- trunk/src/target/etm.c 2009-05-30 01:32:19 UTC (rev 1944) +++ trunk/src/target/etm.c 2009-05-30 01:43:21 UTC (rev 1945) @@ -1815,7 +1815,8 @@ { etm_cmd = register_command(cmd_ctx, NULL, "etm", NULL, COMMAND_ANY, "Embedded Trace Macrocell"); - register_command(cmd_ctx, etm_cmd, "config", handle_etm_config_command, COMMAND_CONFIG, "etm config <target> <port_width> <port_mode> <clocking> <capture_driver>"); + register_command(cmd_ctx, etm_cmd, "config", handle_etm_config_command, + COMMAND_CONFIG, "etm config <target> <port_width> <port_mode> <clocking> <capture_driver>"); return ERROR_OK; } @@ -1823,12 +1824,13 @@ int etm_register_user_commands(struct command_context_s *cmd_ctx) { register_command(cmd_ctx, etm_cmd, "tracemode", handle_etm_tracemode_command, - COMMAND_EXEC, "configure trace mode <none|data|address|all> <context id bits> <cycle accurate> <branch output"); + COMMAND_EXEC, "configure trace mode <none|data|address|all> " + "<context_id_bits> <cycle_accurate> <branch_output>"); register_command(cmd_ctx, etm_cmd, "info", handle_etm_info_command, COMMAND_EXEC, "display info about the current target's ETM"); - register_command(cmd_ctx, etm_cmd, "trigger_percent <percent>", handle_etm_trigger_percent_command, + register_command(cmd_ctx, etm_cmd, "trigger_percent", handle_etm_trigger_percent_command, COMMAND_EXEC, "amount (<percent>) of trace buffer to be filled after the trigger occured"); register_command(cmd_ctx, etm_cmd, "status", handle_etm_status_command, COMMAND_EXEC, "display current target's ETM status"); Modified: trunk/src/target/oocd_trace.c =================================================================== --- trunk/src/target/oocd_trace.c 2009-05-30 01:32:19 UTC (rev 1944) +++ trunk/src/target/oocd_trace.c 2009-05-30 01:43:21 UTC (rev 1945) @@ -24,7 +24,12 @@ #include "oocd_trace.h" #include "arm7_9_common.h" +/* + * This is "proof of concept" code, for prototype hardware: + * https://lists.berlios.de/pipermail/openocd-development/2007-September/000336.html + */ + static int oocd_trace_register_commands(struct command_context_s *cmd_ctx); static int oocd_trace_read_reg(oocd_trace_t *oocd_trace, int reg, u32 *value) |
From: <zw...@ma...> - 2009-05-30 03:32:24
|
Author: zwelch Date: 2009-05-30 03:32:19 +0200 (Sat, 30 May 2009) New Revision: 1944 Modified: trunk/doc/openocd.texi trunk/src/jtag/jtag.c Log: David Brownell <da...@pa...>: Make it so the magic "reset_config" keywords can be provided in any order. This eliminates needless error paths, and makes it easier to define things at the right level (adapter, board, target). It also includes two other behavioral changes: (1) When "handle_reset_config" sees a parameter error, it exits without changing anything. This is best viewed as a bugfix. (Old behavior: restore defaults, even if they weren't previously active.) (2) Only the behaviors that were explicitly specified get changed. (Old behavior: everything else gets reset to the "default".) So for example you can now specify SRST drive requirements without saying anything about the three unrelated topics you previously had to specify. That second one might cause confusion for any configs that end up calling "reset_config" twice, so it will deserve to be called out in the release notes. (There were no such configurations in the current OpenOCD source tree.) Update docs accordingly. Note that at least some versions of the texi-to-html tools can't handle "@xref{with spaces}", but those work properly in PDF and in the info files. Modified: trunk/doc/openocd.texi =================================================================== --- trunk/doc/openocd.texi 2009-05-29 05:50:01 UTC (rev 1943) +++ trunk/doc/openocd.texi 2009-05-30 01:32:19 UTC (rev 1944) @@ -1574,9 +1574,13 @@ Every system configuration may require a different reset configuration. This can also be quite confusing. +Resets also interact with @var{reset-init} event handlers, +which do things like setting up clocks and DRAM, and +JTAG clock rates. (@xref{JTAG Speed}.) Please see the various board files for examples. -@b{Note} to maintainers and integrators: +@quotation Note +To maintainers and integrators: Reset configuration touches several things at once. Normally the board configuration file should define it and assume that the JTAG adapter supports @@ -1587,6 +1591,7 @@ And when the JTAG adapter doesn't support everything, the system configuration file will need to override parts of the reset configuration provided by other files. +@end quotation @section Types of Reset @@ -1671,12 +1676,19 @@ There can also be other issues. Some devices don't fully conform to the JTAG specifications. -Others have chip-specific extensions like extra steps needed -during TAP reset, or a requirement to use the normally-optional TRST -signal. Trivial system-specific differences are common, such as SRST and TRST using slightly different names. +There are also vendors who distribute key JTAG documentation for +their chips only to developers who have signed a Non-Disclosure +Agreement (NDA). +Sometimes there are chip-specific extensions like a requirement to use +the normally-optional TRST signal (precluding use of JTAG adapters which +don't pass TRST through), or needing extra steps to complete a TAP reset. + +In short, SRST and especially TRST handling may be very finicky, +needing to cope with both architecture and board specific constraints. + @section Commands for Handling Resets @deffn {Command} jtag_nsrst_delay milliseconds @@ -1691,31 +1703,58 @@ nTRST (active-low JTAG TAP reset) before starting new JTAG operations. @end deffn -@deffn {Command} reset_config signals [combination [trst_type [srst_type]]] +@deffn {Command} reset_config mode_flag ... This command tells OpenOCD the reset configuration of your combination of JTAG interface, board, and target. -If the JTAG interface provides SRST, but the board doesn't connect -that signal properly, then OpenOCD can't use it. @var{signals} can -be @option{none}, @option{trst_only}, @option{srst_only} or -@option{trst_and_srst}. +The @var{mode_flag} options can be specified in any order, but only one +of each type -- @var{signals}, @var{combination}, @var{trst_type}, +and @var{srst_type} -- may be specified at a time. +If you don't provide a new value for a given type, its previous +value (perhaps the default) is unchanged. +For example, this means that you don't need to say anything at all about +TRST just to declare that if the JTAG adapter should want to drive SRST, +it must explicitly be driven high (@option{srst_push_pull}). + +@var{signals} can specify which of the reset signals are connected. +For example, If the JTAG interface provides SRST, but the board doesn't +connect that signal properly, then OpenOCD can't use it. +Possible values are @option{none} (the default), @option{trst_only}, +@option{srst_only} and @option{trst_and_srst}. + +@quotation Tip +If your board provides SRST or TRST through the JTAG connector, +you must declare that or else those signals will not be used. +@end quotation + The @var{combination} is an optional value specifying broken reset -signal implementations. @option{srst_pulls_trst} states that the +signal implementations. +The default behaviour if no option given is @option{separate}, +indicating everything behaves normally. +@option{srst_pulls_trst} states that the test logic is reset together with the reset of the system (e.g. Philips LPC2000, "broken" board layout), @option{trst_pulls_srst} says that the system is reset together with the test logic (only hypothetical, I haven't seen hardware with such a bug, and can be worked around). @option{combined} implies both @option{srst_pulls_trst} and -@option{trst_pulls_srst}. The default behaviour if no option given is -@option{separate}. +@option{trst_pulls_srst}. The optional @var{trst_type} and @var{srst_type} parameters allow the -driver type of the reset lines to be specified. Possible values are -@option{trst_push_pull} (default) and @option{trst_open_drain} for the -test reset signal, and @option{srst_open_drain} (default) and -@option{srst_push_pull} for the system reset. These values only affect -JTAG interfaces with support for different drivers, like the Amontec -JTAGkey and JTAGAccelerator. +driver mode of each reset line to be specified. These values only affect +JTAG interfaces with support for different driver modes, like the Amontec +JTAGkey and JTAGAccelerator. Also, they are necessarily ignored if the +relevant signal (TRST or SRST) is not connected. + +Possible @var{trst_type} driver modes for the test reset signal (TRST) +are @option{trst_push_pull} (default) and @option{trst_open_drain}. +Most boards connect this signal to a pulldown, so the JTAG TAPs +never leave reset unless they are hooked up to a JTAG adapter. + +Possible @var{srst_type} driver modes for the system reset signal (SRST) +are the default @option{srst_open_drain}, and @option{srst_push_pull}. +Most boards connect this signal to a pullup, and allow the +signal to be pulled low by various events including system +powerup and pressing a reset button. @end deffn Modified: trunk/src/jtag/jtag.c =================================================================== --- trunk/src/jtag/jtag.c 2009-05-29 05:50:01 UTC (rev 1943) +++ trunk/src/jtag/jtag.c 2009-05-30 01:32:19 UTC (rev 1944) @@ -2651,77 +2651,111 @@ static int handle_reset_config_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc) { + int new_cfg = 0; + int mask = 0; + if (argc < 1) return ERROR_COMMAND_SYNTAX_ERROR; - if (argc >= 1) - { - if (strcmp(args[0], "none") == 0) - jtag_reset_config = RESET_NONE; - else if (strcmp(args[0], "trst_only") == 0) - jtag_reset_config = RESET_HAS_TRST; - else if (strcmp(args[0], "srst_only") == 0) - jtag_reset_config = RESET_HAS_SRST; - else if (strcmp(args[0], "trst_and_srst") == 0) - jtag_reset_config = RESET_TRST_AND_SRST; + /* Original versions cared about the order of these tokens: + * reset_config signals [combination [trst_type [srst_type]]] + * They also clobbered the previous configuration even on error. + * + * Here we don't care about the order, and only change values + * which have been explicitly specified. + */ + for (; argc; argc--, args++) { + int tmp = 0; + int m; + + /* signals */ + m = RESET_HAS_TRST | RESET_HAS_SRST; + if (strcmp(*args, "none") == 0) + tmp = RESET_NONE; + else if (strcmp(*args, "trst_only") == 0) + tmp = RESET_HAS_TRST; + else if (strcmp(*args, "srst_only") == 0) + tmp = RESET_HAS_SRST; + else if (strcmp(*args, "trst_and_srst") == 0) + tmp = RESET_HAS_TRST | RESET_HAS_SRST; else - { - LOG_ERROR("(1) invalid reset_config argument (%s), defaulting to none", args[0]); - jtag_reset_config = RESET_NONE; + m = 0; + if (mask & m) { + LOG_ERROR("extra reset_config %s spec (%s)", + "signal", *args); return ERROR_INVALID_ARGUMENTS; } - } + if (m) + goto next; - if (argc >= 2) - { - if (strcmp(args[1], "separate") == 0) - { - /* seperate reset lines - default */ - } else - { - if (strcmp(args[1], "srst_pulls_trst") == 0) - jtag_reset_config |= RESET_SRST_PULLS_TRST; - else if (strcmp(args[1], "trst_pulls_srst") == 0) - jtag_reset_config |= RESET_TRST_PULLS_SRST; - else if (strcmp(args[1], "combined") == 0) - jtag_reset_config |= RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST; - else - { - LOG_ERROR("(2) invalid reset_config argument (%s), defaulting to none", args[1]); - jtag_reset_config = RESET_NONE; - return ERROR_INVALID_ARGUMENTS; - } + /* combination (options for broken wiring) */ + m = RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST; + if (strcmp(*args, "separate") == 0) + /* separate reset lines - default */; + else if (strcmp(*args, "srst_pulls_trst") == 0) + tmp |= RESET_SRST_PULLS_TRST; + else if (strcmp(*args, "trst_pulls_srst") == 0) + tmp |= RESET_TRST_PULLS_SRST; + else if (strcmp(*args, "combined") == 0) + tmp |= RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST; + else + m = 0; + if (mask & m) { + LOG_ERROR("extra reset_config %s spec (%s)", + "combination", *args); + return ERROR_INVALID_ARGUMENTS; } - } + if (m) + goto next; - if (argc >= 3) - { - if (strcmp(args[2], "trst_open_drain") == 0) - jtag_reset_config |= RESET_TRST_OPEN_DRAIN; - else if (strcmp(args[2], "trst_push_pull") == 0) - jtag_reset_config &= ~RESET_TRST_OPEN_DRAIN; + /* trst_type (NOP without HAS_TRST) */ + m = RESET_TRST_OPEN_DRAIN; + if (strcmp(*args, "trst_open_drain") == 0) + tmp |= RESET_TRST_OPEN_DRAIN; + else if (strcmp(*args, "trst_push_pull") == 0) + /* push/pull from adapter - default */; else - { - LOG_ERROR("(3) invalid reset_config argument (%s) defaulting to none", args[2] ); - jtag_reset_config = RESET_NONE; + m = 0; + if (mask & m) { + LOG_ERROR("extra reset_config %s spec (%s)", + "trst_type", *args); return ERROR_INVALID_ARGUMENTS; } - } + if (m) + goto next; - if (argc >= 4) - { - if (strcmp(args[3], "srst_push_pull") == 0) - jtag_reset_config |= RESET_SRST_PUSH_PULL; - else if (strcmp(args[3], "srst_open_drain") == 0) - jtag_reset_config &= ~RESET_SRST_PUSH_PULL; + /* srst_type (NOP without HAS_SRST) */ + m |= RESET_SRST_PUSH_PULL; + if (strcmp(*args, "srst_push_pull") == 0) + tmp |= RESET_SRST_PUSH_PULL; + else if (strcmp(*args, "srst_open_drain") == 0) + /* open drain from adapter - default */; else - { - LOG_ERROR("(4) invalid reset_config argument (%s), defaulting to none", args[3]); - jtag_reset_config = RESET_NONE; + m = 0; + if (mask & m) { + LOG_ERROR("extra reset_config %s spec (%s)", + "srst_type", *args); return ERROR_INVALID_ARGUMENTS; } + if (m) + goto next; + + /* caller provided nonsense; fail */ + LOG_ERROR("unknown reset_config flag (%s)", *args); + return ERROR_INVALID_ARGUMENTS; + +next: + /* Remember the bits which were specified (mask) + * and their new values (new_cfg). + */ + mask |= m; + new_cfg |= tmp; } + /* clear previous values of those bits, save new values */ + jtag_reset_config &= ~mask; + jtag_reset_config |= new_cfg; + return ERROR_OK; } |