X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fflash%2Focl.c;h=0a2496dac6afedc67c17ce3e29d4b514ebf3b4cb;hb=af949b2531d2a8863d077025db40cbb170d13a63;hp=a2dac50a31b363a35e62c9903ff05d9711788062;hpb=6d1d58a1fc3dfd60e9cac89460b5a6e438d11efa;p=openocd diff --git a/src/flash/ocl.c b/src/flash/ocl.c index a2dac50a..0a2496da 100644 --- a/src/flash/ocl.c +++ b/src/flash/ocl.c @@ -26,43 +26,12 @@ #include "embeddedice.h" -static int ocl_register_commands(struct command_context_s *cmd_ctx); -static int ocl_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank); -static int ocl_erase(struct flash_bank_s *bank, int first, int last); -static int ocl_protect(struct flash_bank_s *bank, int set, int first, int last); -static int ocl_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset, uint32_t count); -static int ocl_probe(struct flash_bank_s *bank); -static int ocl_erase_check(struct flash_bank_s *bank); -static int ocl_protect_check(struct flash_bank_s *bank); -static int ocl_info(struct flash_bank_s *bank, char *buf, int buf_size); -static int ocl_auto_probe(struct flash_bank_s *bank); - -flash_driver_t ocl_flash = +struct ocl_priv { - .name = "ocl", - .register_commands = ocl_register_commands, - .flash_bank_command = ocl_flash_bank_command, - .erase = ocl_erase, - .protect = ocl_protect, - .write = ocl_write, - .probe = ocl_probe, - .erase_check = ocl_erase_check, - .protect_check = ocl_protect_check, - .info = ocl_info, - .auto_probe = ocl_auto_probe -}; - -typedef struct ocl_priv_s -{ - arm_jtag_t *jtag_info; + struct arm_jtag *jtag_info; unsigned int buflen; unsigned int bufalign; -} ocl_priv_t; - -static int ocl_register_commands(struct command_context_s *cmd_ctx) -{ - return ERROR_OK; -} +}; static int ocl_erase_check(struct flash_bank_s *bank) { @@ -75,12 +44,12 @@ static int ocl_protect_check(struct flash_bank_s *bank) } /* flash_bank ocl 0 0 0 0 */ -static int ocl_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank) +FLASH_BANK_COMMAND_HANDLER(ocl_flash_bank_command) { int retval; - armv4_5_common_t *armv4_5; - arm7_9_common_t *arm7_9; - ocl_priv_t *ocl; + struct arm *armv4_5; + struct arm7_9_common *arm7_9; + struct ocl_priv *ocl; if (argc < 6) { @@ -91,7 +60,7 @@ static int ocl_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, if ((retval = arm7_9_get_arch_pointers(bank->target, &armv4_5, &arm7_9)) != ERROR_OK) return retval; - ocl = bank->driver_priv = malloc(sizeof(ocl_priv_t)); + ocl = bank->driver_priv = malloc(sizeof(struct ocl_priv)); ocl->jtag_info = &arm7_9->jtag_info; ocl->buflen = 0; ocl->bufalign = 1; @@ -101,7 +70,7 @@ static int ocl_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, static int ocl_erase(struct flash_bank_s *bank, int first, int last) { - ocl_priv_t *ocl = bank->driver_priv; + struct ocl_priv *ocl = bank->driver_priv; int retval; uint32_t dcc_buffer[3]; @@ -161,7 +130,7 @@ static int ocl_protect(struct flash_bank_s *bank, int set, int first, int last) static int ocl_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset, uint32_t count) { - ocl_priv_t *ocl = bank->driver_priv; + struct ocl_priv *ocl = bank->driver_priv; int retval; uint32_t *dcc_buffer; uint32_t *dcc_bufptr; @@ -268,7 +237,7 @@ static int ocl_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset static int ocl_probe(struct flash_bank_s *bank) { - ocl_priv_t *ocl = bank->driver_priv; + struct ocl_priv *ocl = bank->driver_priv; int retval; uint32_t dcc_buffer[1]; int sectsize; @@ -321,7 +290,7 @@ static int ocl_probe(struct flash_bank_s *bank) ocl->buflen = dcc_buffer[0] & 0xffff; ocl->bufalign = dcc_buffer[0] >> 16; - bank->sectors = realloc(bank->sectors, sizeof(flash_sector_t)*bank->num_sectors); + bank->sectors = realloc(bank->sectors, sizeof(struct flash_sector)*bank->num_sectors); if (bank->num_sectors == 0) { LOG_ERROR("number of sectors shall be non zero value"); @@ -371,10 +340,23 @@ static int ocl_info(struct flash_bank_s *bank, char *buf, int buf_size) static int ocl_auto_probe(struct flash_bank_s *bank) { - ocl_priv_t *ocl = bank->driver_priv; + struct ocl_priv *ocl = bank->driver_priv; if (ocl->buflen == 0 || ocl->bufalign == 0) return ERROR_FLASH_BANK_NOT_PROBED; return ERROR_OK; } + +struct flash_driver ocl_flash = { + .name = "ocl", + .flash_bank_command = &ocl_flash_bank_command, + .erase = &ocl_erase, + .protect = &ocl_protect, + .write = &ocl_write, + .probe = &ocl_probe, + .erase_check = &ocl_erase_check, + .protect_check = &ocl_protect_check, + .info = &ocl_info, + .auto_probe = &ocl_auto_probe, + };