X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fflash%2Fnor%2Fstr7x.c;h=49aaa3d78be1a052a00a21ef1e4515f2b5af2227;hb=08d4411b59dd8bd0e7d8009003b71d23acbf6eee;hp=6cd5d69f8be8074fa1343c3369b5cd62bd70f72f;hpb=9f0cba528a163645c8ecace413731c23310f2c26;p=openocd.git diff --git a/src/flash/nor/str7x.c b/src/flash/nor/str7x.c index 6cd5d69f8b..49aaa3d78b 100644 --- a/src/flash/nor/str7x.c +++ b/src/flash/nor/str7x.c @@ -21,7 +21,7 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. * ***************************************************************************/ #ifdef HAVE_CONFIG_H @@ -90,7 +90,6 @@ struct str7x_flash_bank { uint32_t disable_bit; uint32_t busy_bits; uint32_t register_base; - struct working_area *write_algorithm; }; struct str7x_mem_layout { @@ -227,8 +226,6 @@ FLASH_BANK_COMMAND_HANDLER(str7x_flash_bank_command) str7x_build_block_list(bank); - str7x_info->write_algorithm = NULL; - return ERROR_OK; } @@ -451,10 +448,11 @@ static int str7x_write_block(struct flash_bank *bank, uint8_t *buffer, struct str7x_flash_bank *str7x_info = bank->driver_priv; struct target *target = bank->target; uint32_t buffer_size = 32768; + struct working_area *write_algorithm; struct working_area *source; uint32_t address = bank->base + offset; struct reg_param reg_params[6]; - struct arm_algorithm armv4_5_info; + struct arm_algorithm arm_algo; int retval = ERROR_OK; /* see contib/loaders/flash/str7x.s for src */ @@ -487,11 +485,11 @@ static int str7x_write_block(struct flash_bank *bank, uint8_t *buffer, /* flash write code */ if (target_alloc_working_area_try(target, sizeof(str7x_flash_write_code), - &str7x_info->write_algorithm) != ERROR_OK) { + &write_algorithm) != ERROR_OK) { return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; }; - target_write_buffer(target, str7x_info->write_algorithm->address, + target_write_buffer(target, write_algorithm->address, sizeof(str7x_flash_write_code), (uint8_t *)str7x_flash_write_code); @@ -499,19 +497,18 @@ static int str7x_write_block(struct flash_bank *bank, uint8_t *buffer, while (target_alloc_working_area_try(target, buffer_size, &source) != ERROR_OK) { buffer_size /= 2; if (buffer_size <= 256) { - /* if we already allocated the writing code, but failed to get a + /* we already allocated the writing code, but failed to get a * buffer, free the algorithm */ - if (str7x_info->write_algorithm) - target_free_working_area(target, str7x_info->write_algorithm); + target_free_working_area(target, write_algorithm); LOG_WARNING("no large enough working area available, can't do block memory writes"); return ERROR_TARGET_RESOURCE_NOT_AVAILABLE; } } - armv4_5_info.common_magic = ARM_COMMON_MAGIC; - armv4_5_info.core_mode = ARM_MODE_SVC; - armv4_5_info.core_state = ARM_STATE_ARM; + arm_algo.common_magic = ARM_COMMON_MAGIC; + arm_algo.core_mode = ARM_MODE_SVC; + arm_algo.core_state = ARM_STATE_ARM; init_reg_param(®_params[0], "r0", 32, PARAM_OUT); init_reg_param(®_params[1], "r1", 32, PARAM_OUT); @@ -532,9 +529,9 @@ static int str7x_write_block(struct flash_bank *bank, uint8_t *buffer, buf_set_u32(reg_params[5].value, 0, 32, str7x_info->busy_bits); retval = target_run_algorithm(target, 0, NULL, 6, reg_params, - str7x_info->write_algorithm->address, - str7x_info->write_algorithm->address + (sizeof(str7x_flash_write_code) - 4), - 10000, &armv4_5_info); + write_algorithm->address, + write_algorithm->address + (sizeof(str7x_flash_write_code) - 4), + 10000, &arm_algo); if (retval != ERROR_OK) break; @@ -549,7 +546,7 @@ static int str7x_write_block(struct flash_bank *bank, uint8_t *buffer, } target_free_working_area(target, source); - target_free_working_area(target, str7x_info->write_algorithm); + target_free_working_area(target, write_algorithm); destroy_reg_param(®_params[0]); destroy_reg_param(®_params[1]);