X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fflash%2Flpc2900.c;h=35f15070a78217e7fe4e74a28b5df27b0aaf2481;hb=51cd370b396d19555158c1eb913e7c8386d92a0f;hp=5255f56f5105334e7a9376391f05c2a93bd75911;hpb=b712a4e8b85f3b351f2af93d0988d9983e57d6fe;p=openocd.git diff --git a/src/flash/lpc2900.c b/src/flash/lpc2900.c index 5255f56f51..35f15070a7 100644 --- a/src/flash/lpc2900.c +++ b/src/flash/lpc2900.c @@ -24,10 +24,10 @@ #include "image.h" - -#include "lpc2900.h" +#include "flash.h" #include "binarybuffer.h" #include "armv4_5.h" +#include "algorithm.h" /* 1024 bytes */ @@ -171,14 +171,14 @@ struct lpc2900_flash_bank }; -static uint32_t lpc2900_wait_status(flash_bank_t *bank, uint32_t mask, int timeout); -static void lpc2900_setup(struct flash_bank_s *bank); -static uint32_t lpc2900_is_ready(struct flash_bank_s *bank); -static uint32_t lpc2900_read_security_status(struct flash_bank_s *bank); -static uint32_t lpc2900_run_bist128(struct flash_bank_s *bank, +static uint32_t lpc2900_wait_status(struct flash_bank *bank, uint32_t mask, int timeout); +static void lpc2900_setup(struct flash_bank *bank); +static uint32_t lpc2900_is_ready(struct flash_bank *bank); +static uint32_t lpc2900_read_security_status(struct flash_bank *bank); +static uint32_t lpc2900_run_bist128(struct flash_bank *bank, uint32_t addr_from, uint32_t addr_to, uint32_t (*signature)[4] ); -static uint32_t lpc2900_address2sector(struct flash_bank_s *bank, uint32_t offset); +static uint32_t lpc2900_address2sector(struct flash_bank *bank, uint32_t offset); static uint32_t lpc2900_calc_tr( uint32_t clock, uint32_t time ); @@ -194,12 +194,12 @@ static uint32_t lpc2900_calc_tr( uint32_t clock, uint32_t time ); * @param[in] mask Mask to be used for INT_STATUS * @param[in] timeout Timeout in ms */ -static uint32_t lpc2900_wait_status( flash_bank_t *bank, +static uint32_t lpc2900_wait_status( struct flash_bank *bank, uint32_t mask, int timeout ) { uint32_t int_status; - target_t *target = bank->target; + struct target *target = bank->target; do @@ -228,7 +228,7 @@ static uint32_t lpc2900_wait_status( flash_bank_t *bank, * * @param bank Pointer to the flash bank descriptor */ -static void lpc2900_setup( struct flash_bank_s *bank ) +static void lpc2900_setup( struct flash_bank *bank ) { uint32_t fcra; struct lpc2900_flash_bank *lpc2900_info = bank->driver_priv; @@ -251,7 +251,7 @@ static void lpc2900_setup( struct flash_bank_s *bank ) * Must have been successfully probed. * Must be halted. */ -static uint32_t lpc2900_is_ready( struct flash_bank_s *bank ) +static uint32_t lpc2900_is_ready( struct flash_bank *bank ) { struct lpc2900_flash_bank *lpc2900_info = bank->driver_priv; @@ -275,7 +275,7 @@ static uint32_t lpc2900_is_ready( struct flash_bank_s *bank ) * * @param bank Pointer to the flash bank descriptor */ -static uint32_t lpc2900_read_security_status( struct flash_bank_s *bank ) +static uint32_t lpc2900_read_security_status( struct flash_bank *bank ) { uint32_t status; if( (status = lpc2900_is_ready( bank )) != ERROR_OK ) @@ -283,7 +283,7 @@ static uint32_t lpc2900_read_security_status( struct flash_bank_s *bank ) return status; } - target_t *target = bank->target; + struct target *target = bank->target; /* Enable ISS access */ target_write_u32(target, FCTR, FCTR_FS_CS | FCTR_FS_WEB | FCTR_FS_ISS); @@ -356,12 +356,12 @@ static uint32_t lpc2900_read_security_status( struct flash_bank_s *bank ) * @param addr_to * @param signature */ -static uint32_t lpc2900_run_bist128(struct flash_bank_s *bank, +static uint32_t lpc2900_run_bist128(struct flash_bank *bank, uint32_t addr_from, uint32_t addr_to, uint32_t (*signature)[4] ) { - target_t *target = bank->target; + struct target *target = bank->target; /* Clear END_OF_MISR interrupt status */ target_write_u32( target, INT_CLR_STATUS, INTSRC_END_OF_MISR ); @@ -393,7 +393,7 @@ static uint32_t lpc2900_run_bist128(struct flash_bank_s *bank, * @param bank Pointer to the flash bank descriptor * @param offset Offset address relative to bank start */ -static uint32_t lpc2900_address2sector( struct flash_bank_s *bank, +static uint32_t lpc2900_address2sector( struct flash_bank *bank, uint32_t offset ) { uint32_t address = bank->base + offset; @@ -424,7 +424,7 @@ static uint32_t lpc2900_address2sector( struct flash_bank_s *bank, * @param pagenum Page number (0...7) * @param page Page array (FLASH_PAGE_SIZE bytes) */ -static int lpc2900_write_index_page( struct flash_bank_s *bank, +static int lpc2900_write_index_page( struct flash_bank *bank, int pagenum, uint8_t (*page)[FLASH_PAGE_SIZE] ) { @@ -436,7 +436,7 @@ static int lpc2900_write_index_page( struct flash_bank_s *bank, } /* Get target, and check if it's halted */ - target_t *target = bank->target; + struct target *target = bank->target; if( target->state != TARGET_HALTED ) { LOG_ERROR( "Target not halted" ); @@ -543,7 +543,7 @@ COMMAND_HANDLER(lpc2900_handle_signature_command) return ERROR_FLASH_BANK_INVALID; } - flash_bank_t *bank; + struct flash_bank *bank; int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); if (ERROR_OK != retval) return retval; @@ -588,7 +588,7 @@ COMMAND_HANDLER(lpc2900_handle_read_custom_command) return ERROR_COMMAND_SYNTAX_ERROR; } - flash_bank_t *bank; + struct flash_bank *bank; int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); if (ERROR_OK != retval) return retval; @@ -597,7 +597,7 @@ COMMAND_HANDLER(lpc2900_handle_read_custom_command) lpc2900_info->risky = 0; /* Get target, and check if it's halted */ - target_t *target = bank->target; + struct target *target = bank->target; if( target->state != TARGET_HALTED ) { LOG_ERROR( "Target not halted" ); @@ -659,7 +659,7 @@ COMMAND_HANDLER(lpc2900_handle_password_command) return ERROR_COMMAND_SYNTAX_ERROR; } - flash_bank_t *bank; + struct flash_bank *bank; int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); if (ERROR_OK != retval) return retval; @@ -694,7 +694,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command) return ERROR_COMMAND_SYNTAX_ERROR; } - flash_bank_t *bank; + struct flash_bank *bank; int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); if (ERROR_OK != retval) return retval; @@ -710,7 +710,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command) lpc2900_info->risky = 0; /* Get target, and check if it's halted */ - target_t *target = bank->target; + struct target *target = bank->target; if (target->state != TARGET_HALTED) { LOG_ERROR("Target not halted"); @@ -718,7 +718,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command) } /* The image will always start at offset 0 */ - image_t image; + struct image image; image.base_address_set = 1; image.base_address = 0; image.start_address_set = 0; @@ -805,7 +805,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command) } /* Get the bank descriptor */ - flash_bank_t *bank; + struct flash_bank *bank; int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); if (ERROR_OK != retval) return retval; @@ -904,7 +904,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_jtag_command) } /* Get the bank descriptor */ - flash_bank_t *bank; + struct flash_bank *bank; int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); if (ERROR_OK != retval) return retval; @@ -952,9 +952,9 @@ COMMAND_HANDLER(lpc2900_handle_secure_jtag_command) /** * Register private command handlers. */ -static int lpc2900_register_commands(struct command_context_s *cmd_ctx) +static int lpc2900_register_commands(struct command_context *cmd_ctx) { - command_t *lpc2900_cmd = register_command(cmd_ctx, NULL, "lpc2900", + struct command *lpc2900_cmd = register_command(cmd_ctx, NULL, "lpc2900", NULL, COMMAND_ANY, NULL); register_command( @@ -1070,12 +1070,12 @@ FLASH_BANK_COMMAND_HANDLER(lpc2900_flash_bank_command) * @param first First sector to be erased * @param last Last sector (including) to be erased */ -static int lpc2900_erase(struct flash_bank_s *bank, int first, int last) +static int lpc2900_erase(struct flash_bank *bank, int first, int last) { uint32_t status; int sector; int last_unsecured_sector; - target_t *target = bank->target; + struct target *target = bank->target; struct lpc2900_flash_bank *lpc2900_info = bank->driver_priv; @@ -1177,7 +1177,7 @@ static int lpc2900_erase(struct flash_bank_s *bank, int first, int last) -static int lpc2900_protect(struct flash_bank_s *bank, int set, int first, int last) +static int lpc2900_protect(struct flash_bank *bank, int set, int first, int last) { /* This command is not supported. * "Protection" in LPC2900 terms is handled transparently. Sectors will @@ -1199,13 +1199,13 @@ static int lpc2900_protect(struct flash_bank_s *bank, int set, int first, int la * @param offset Start address (relative to bank start) * @param count Number of bytes to be programmed */ -static int lpc2900_write(struct flash_bank_s *bank, uint8_t *buffer, +static int lpc2900_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count) { uint8_t page[FLASH_PAGE_SIZE]; uint32_t status; uint32_t num_bytes; - target_t *target = bank->target; + struct target *target = bank->target; struct lpc2900_flash_bank *lpc2900_info = bank->driver_priv; int sector; int retval; @@ -1294,7 +1294,7 @@ static int lpc2900_write(struct flash_bank_s *bank, uint8_t *buffer, /* Try working area allocation. Start with a large buffer, and try with reduced size if that fails. */ - working_area_t *warea; + struct working_area *warea; uint32_t buffer_size = lpc2900_info->max_ram_block - 1 * KiB; while( (retval = target_alloc_working_area(target, buffer_size + target_code_size, @@ -1313,8 +1313,8 @@ static int lpc2900_write(struct flash_bank_s *bank, uint8_t *buffer, if( warea ) { - reg_param_t reg_params[5]; - armv4_5_algorithm_t armv4_5_info; + struct reg_param reg_params[5]; + struct armv4_5_algorithm armv4_5_info; /* We can use target mode. Download the algorithm. */ retval = target_write_buffer( target, @@ -1548,10 +1548,10 @@ static int lpc2900_write(struct flash_bank_s *bank, uint8_t *buffer, * * @param bank Pointer to the flash bank descriptor */ -static int lpc2900_probe(struct flash_bank_s *bank) +static int lpc2900_probe(struct flash_bank *bank) { struct lpc2900_flash_bank *lpc2900_info = bank->driver_priv; - target_t *target = bank->target; + struct target *target = bank->target; int i = 0; uint32_t offset; @@ -1751,7 +1751,7 @@ static int lpc2900_probe(struct flash_bank_s *bank) * * @param bank Pointer to the flash bank descriptor */ -static int lpc2900_erase_check(struct flash_bank_s *bank) +static int lpc2900_erase_check(struct flash_bank *bank) { uint32_t status = lpc2900_is_ready(bank); if (status != ERROR_OK) @@ -1809,7 +1809,7 @@ static int lpc2900_erase_check(struct flash_bank_s *bank) * * @param bank Pointer to the flash bank descriptor */ -static int lpc2900_protect_check(struct flash_bank_s *bank) +static int lpc2900_protect_check(struct flash_bank *bank) { return lpc2900_read_security_status(bank); } @@ -1822,7 +1822,7 @@ static int lpc2900_protect_check(struct flash_bank_s *bank) * @param buf Buffer to take the string * @param buf_size Maximum number of characters that the buffer can take */ -static int lpc2900_info(struct flash_bank_s *bank, char *buf, int buf_size) +static int lpc2900_info(struct flash_bank *bank, char *buf, int buf_size) { snprintf(buf, buf_size, "lpc2900 flash driver");