X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fflash%2Fat91sam7.c;h=e045f8457d15f7cd7b5066649bc64ec77c7fe601;hp=ebc934273b337b54922ce7700dae8a159d28a71b;hb=f876d5e9c769a288faa7fd14b7bf373363542aab;hpb=a88532bc6061ccc74ca08de161ec6fecf88a85b0 diff --git a/src/flash/at91sam7.c b/src/flash/at91sam7.c index ebc934273b..e045f8457d 100644 --- a/src/flash/at91sam7.c +++ b/src/flash/at91sam7.c @@ -39,25 +39,15 @@ #include "config.h" #endif -#include "replacements.h" - #include "at91sam7.h" - -#include "flash.h" -#include "target.h" -#include "log.h" #include "binarybuffer.h" -#include "types.h" -#include -#include -#include static int at91sam7_register_commands(struct command_context_s *cmd_ctx); static int at91sam7_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank); static int at91sam7_erase(struct flash_bank_s *bank, int first, int last); static int at91sam7_protect(struct flash_bank_s *bank, int set, int first, int last); -static int at91sam7_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count); +static int at91sam7_write(struct flash_bank_s *bank, uint8_t *buffer, u32 offset, u32 count); static int at91sam7_probe(struct flash_bank_s *bank); //static int at91sam7_auto_probe(struct flash_bank_s *bank); static int at91sam7_erase_check(struct flash_bank_s *bank); @@ -67,12 +57,12 @@ static int at91sam7_info(struct flash_bank_s *bank, char *buf, int buf_size); static u32 at91sam7_get_flash_status(target_t *target, int bank_number); static void at91sam7_set_flash_mode(flash_bank_t *bank, int mode); static u32 at91sam7_wait_status_busy(flash_bank_t *bank, u32 waitbits, int timeout); -static int at91sam7_flash_command(struct flash_bank_s *bank, u8 cmd, u16 pagen); +static int at91sam7_flash_command(struct flash_bank_s *bank, uint8_t cmd, uint16_t pagen); static int at91sam7_handle_gpnvm_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc); flash_driver_t at91sam7_flash = { - .name = "at91sam7_new", + .name = "at91sam7", .register_commands = at91sam7_register_commands, .flash_bank_command = at91sam7_flash_bank_command, .erase = at91sam7_erase, @@ -114,7 +104,7 @@ static long SRAMSIZ[16] = { static int at91sam7_register_commands(struct command_context_s *cmd_ctx) { - command_t *at91sam7_cmd = register_command(cmd_ctx, NULL, "at91sam7_new", NULL, COMMAND_ANY, NULL); + command_t *at91sam7_cmd = register_command(cmd_ctx, NULL, "at91sam7", NULL, COMMAND_ANY, NULL); register_command(cmd_ctx, at91sam7_cmd, "gpnvm", at91sam7_handle_gpnvm_command, COMMAND_EXEC, "at91sam7 gpnvm set|clear, set or clear one gpnvm bit"); @@ -284,7 +274,7 @@ static u32 at91sam7_wait_status_busy(flash_bank_t *bank, u32 waitbits, int timeo } /* Send one command to the AT91SAM flash controller */ -static int at91sam7_flash_command(struct flash_bank_s *bank, u8 cmd, u16 pagen) +static int at91sam7_flash_command(struct flash_bank_s *bank, uint8_t cmd, uint16_t pagen) { u32 fcr; at91sam7_flash_bank_t *at91sam7_info = bank->driver_priv; @@ -319,14 +309,14 @@ static int at91sam7_read_part_info(struct flash_bank_s *bank) at91sam7_flash_bank_t *at91sam7_info; target_t *target = t_bank->target; - u16 bnk, sec; - u16 arch; + uint16_t bnk, sec; + uint16_t arch; u32 cidr; - u8 banks_num; - u16 num_nvmbits; - u16 sectors_num; - u16 pages_per_sector; - u16 page_size; + uint8_t banks_num = 0; + uint16_t num_nvmbits = 0; + uint16_t sectors_num = 0; + uint16_t pages_per_sector = 0; + uint16_t page_size = 0; u32 ext_freq; u32 bank_size; u32 base_address = 0; @@ -631,12 +621,12 @@ static int at91sam7_read_part_info(struct flash_bank_s *bank) static int at91sam7_erase_check(struct flash_bank_s *bank) { target_t *target = bank->target; - u16 retval; + uint16_t retval; u32 blank; - u16 fast_check; - u8 *buffer; - u16 nSector; - u16 nByte; + uint16_t fast_check; + uint8_t *buffer; + uint16_t nSector; + uint16_t nByte; if (bank->target->state != TARGET_HALTED) { @@ -675,7 +665,7 @@ static int at91sam7_erase_check(struct flash_bank_s *bank) for (nSector=0; nSectornum_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; @@ -696,7 +686,7 @@ static int at91sam7_erase_check(struct flash_bank_s *bank) static int at91sam7_protect_check(struct flash_bank_s *bank) { - u8 lock_pos, gpnvm_pos; + uint8_t lock_pos, gpnvm_pos; u32 status; at91sam7_flash_bank_t *at91sam7_info = bank->driver_priv; @@ -769,9 +759,9 @@ static int at91sam7_flash_bank_command(struct command_context_s *cmd_ctx, char * int banks_num; int num_sectors; - u16 pages_per_sector; - u16 page_size; - u16 num_nvmbits; + uint16_t pages_per_sector; + uint16_t page_size; + uint16_t num_nvmbits; char *target_name; @@ -871,8 +861,8 @@ static int at91sam7_erase(struct flash_bank_s *bank, int first, int last) at91sam7_flash_bank_t *at91sam7_info = bank->driver_priv; int sec; u32 nbytes, pos; - u8 *buffer; - u8 erase_all; + uint8_t *buffer; + uint8_t erase_all; if (at91sam7_info->cidr == 0) { @@ -911,7 +901,7 @@ static int at91sam7_erase(struct flash_bank_s *bank, int first, int last) { /* allocate and clean buffer */ nbytes = (last - first + 1) * bank->sectors[first].size; - buffer = malloc(nbytes * sizeof(u8)); + buffer = malloc(nbytes * sizeof(uint8_t)); for (pos=0; posdriver_priv; @@ -1037,7 +1027,7 @@ static int at91sam7_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 /* 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; } @@ -1137,7 +1127,7 @@ static int at91sam7_handle_gpnvm_command(struct command_context_s *cmd_ctx, char { flash_bank_t *bank; int bit; - u8 flashcmd; + uint8_t flashcmd; u32 status; at91sam7_flash_bank_t *at91sam7_info; int retval;