X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fflash%2Fflash.c;h=5374532cea8ff0f2286eb5c9fb4056d0e4b77785;hp=d3889b9bf42cbd223f594b10f4a8b218a724b552;hb=0f1163e823c6ca3c2a81fa296157f5dde0635fea;hpb=cfc4d5c6b7b6f8f82dc5bbf3ee661c179814666e diff --git a/src/flash/flash.c b/src/flash/flash.c index d3889b9bf4..5374532cea 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -31,30 +31,30 @@ #include "image.h" #include "time_support.h" -static int flash_write_unlock(target_t *target, image_t *image, uint32_t *written, int erase, bool unlock); +static int flash_write_unlock(struct target *target, struct image *image, uint32_t *written, int erase, bool unlock); /* flash drivers */ -extern flash_driver_t lpc2000_flash; -extern flash_driver_t lpc288x_flash; -extern flash_driver_t lpc2900_flash; -extern flash_driver_t cfi_flash; -extern flash_driver_t at91sam3_flash; -extern flash_driver_t at91sam7_flash; -extern flash_driver_t str7x_flash; -extern flash_driver_t str9x_flash; -extern flash_driver_t aduc702x_flash; -extern flash_driver_t stellaris_flash; -extern flash_driver_t str9xpec_flash; -extern flash_driver_t stm32x_flash; -extern flash_driver_t tms470_flash; -extern flash_driver_t ecosflash_flash; -extern flash_driver_t ocl_flash; -extern flash_driver_t pic32mx_flash; -extern flash_driver_t avr_flash; -extern flash_driver_t faux_flash; - -flash_driver_t *flash_drivers[] = { +extern struct flash_driver lpc2000_flash; +extern struct flash_driver lpc288x_flash; +extern struct flash_driver lpc2900_flash; +extern struct flash_driver cfi_flash; +extern struct flash_driver at91sam3_flash; +extern struct flash_driver at91sam7_flash; +extern struct flash_driver str7x_flash; +extern struct flash_driver str9x_flash; +extern struct flash_driver aduc702x_flash; +extern struct flash_driver stellaris_flash; +extern struct flash_driver str9xpec_flash; +extern struct flash_driver stm32x_flash; +extern struct flash_driver tms470_flash; +extern struct flash_driver ecosflash_flash; +extern struct flash_driver ocl_flash; +extern struct flash_driver pic32mx_flash; +extern struct flash_driver avr_flash; +extern struct flash_driver faux_flash; + +struct flash_driver *flash_drivers[] = { &lpc2000_flash, &lpc288x_flash, &lpc2900_flash, @@ -220,7 +220,7 @@ COMMAND_HANDLER(handle_flash_bank_command) int retval; int i; int found = 0; - target_t *target; + struct target *target; if (argc < 6) { @@ -259,7 +259,8 @@ COMMAND_HANDLER(handle_flash_bank_command) c->sectors = NULL; c->next = NULL; - if ((retval = flash_drivers[i]->flash_bank_command(cmd_ctx, cmd, args, argc, c)) != ERROR_OK) + retval = CALL_COMMAND_HANDLER(flash_drivers[i]->flash_bank_command, c); + if (ERROR_OK != retval) { LOG_ERROR("'%s' driver rejected flash bank at 0x%8.8" PRIx32 , args[0], c->base); free(c); @@ -447,7 +448,7 @@ COMMAND_HANDLER(handle_flash_erase_address_command) int address; int length; - target_t *target = get_current_target(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); if (argc != 2) return ERROR_COMMAND_SYNTAX_ERROR; @@ -614,9 +615,9 @@ COMMAND_HANDLER(handle_flash_protect_command) COMMAND_HANDLER(handle_flash_write_image_command) { - target_t *target = get_current_target(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); - image_t image; + struct image image; uint32_t written; int retval; @@ -713,7 +714,7 @@ COMMAND_HANDLER(handle_flash_fill_command) uint32_t wrote = 0; uint32_t cur_size = 0; uint32_t chunk_count; - target_t *target = get_current_target(cmd_ctx); + struct target *target = get_current_target(cmd_ctx); uint32_t i; uint32_t wordsize; @@ -727,7 +728,7 @@ COMMAND_HANDLER(handle_flash_fill_command) if (count == 0) return ERROR_OK; - switch (cmd[4]) + switch (CMD_NAME[4]) { case 'w': wordsize = 4; @@ -811,7 +812,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command) uint32_t offset; uint8_t *buffer; uint32_t buf_cnt; - fileio_t fileio; + struct fileio fileio; if (argc != 3) return ERROR_COMMAND_SYNTAX_ERROR; @@ -873,7 +874,7 @@ void flash_set_dirty(void) } /* lookup flash bank by address */ -flash_bank_t *get_flash_bank_by_addr(target_t *target, uint32_t addr) +struct flash_bank_s *get_flash_bank_by_addr(struct target *target, uint32_t addr) { flash_bank_t *c; @@ -897,7 +898,7 @@ flash_bank_t *get_flash_bank_by_addr(target_t *target, uint32_t addr) } /* erase given flash region, selects proper bank according to target and address */ -static int flash_iterate_address_range(target_t *target, uint32_t addr, uint32_t length, +static int flash_iterate_address_range(struct target *target, uint32_t addr, uint32_t length, int (*callback)(struct flash_bank_s *bank, int first, int last)) { flash_bank_t *c; @@ -948,7 +949,7 @@ static int flash_iterate_address_range(target_t *target, uint32_t addr, uint32_t -int flash_erase_address_range(target_t *target, uint32_t addr, uint32_t length) +int flash_erase_address_range(struct target *target, uint32_t addr, uint32_t length) { return flash_iterate_address_range(target, addr, length, &flash_driver_erase); } @@ -958,14 +959,14 @@ static int flash_driver_unprotect(struct flash_bank_s *bank, int first, int last return flash_driver_protect(bank, 0, first, last); } -static int flash_unlock_address_range(target_t *target, uint32_t addr, uint32_t length) +static int flash_unlock_address_range(struct target *target, uint32_t addr, uint32_t length) { return flash_iterate_address_range(target, addr, length, &flash_driver_unprotect); } /* write (optional verify) an image to flash memory of the given target */ -static int flash_write_unlock(target_t *target, image_t *image, uint32_t *written, int erase, bool unlock) +static int flash_write_unlock(struct target *target, struct image *image, uint32_t *written, int erase, bool unlock) { int retval = ERROR_OK; @@ -1124,14 +1125,14 @@ static int flash_write_unlock(target_t *target, image_t *image, uint32_t *writte return retval; } -int flash_write(target_t *target, image_t *image, uint32_t *written, int erase) +int flash_write(struct target *target, struct image *image, uint32_t *written, int erase) { return flash_write_unlock(target, image, written, erase, false); } int default_flash_mem_blank_check(struct flash_bank_s *bank) { - target_t *target = bank->target; + struct target *target = bank->target; uint8_t buffer[1024]; int buffer_size = sizeof(buffer); int i; @@ -1178,7 +1179,7 @@ int default_flash_mem_blank_check(struct flash_bank_s *bank) int default_flash_blank_check(struct flash_bank_s *bank) { - target_t *target = bank->target; + struct target *target = bank->target; int i; int retval; int fast_check = 0;