X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fflash%2Focl.c;h=a2dac50a31b363a35e62c9903ff05d9711788062;hb=fb50efc6e712f413d109c3d77683d0358a557ed4;hp=e2099a1191a41d8fe780a0da960b13cedb7fb95c;hpb=fbcb57baf842a84898dcc1cbe9a8b56d2a0028e1;p=openocd diff --git a/src/flash/ocl.c b/src/flash/ocl.c index e2099a11..a2dac50a 100644 --- a/src/flash/ocl.c +++ b/src/flash/ocl.c @@ -30,7 +30,7 @@ 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, u8 *buffer, u32 offset, u32 count); +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); @@ -103,18 +103,18 @@ static int ocl_erase(struct flash_bank_s *bank, int first, int last) { ocl_priv_t *ocl = bank->driver_priv; int retval; - u32 dcc_buffer[3]; + uint32_t dcc_buffer[3]; /* check preconditions */ if (bank->num_sectors == 0) return ERROR_FLASH_BANK_NOT_PROBED; - + if (bank->target->state != TARGET_RUNNING) { LOG_ERROR("target has to be running to communicate with the loader"); return ERROR_TARGET_NOT_RUNNING; } - + if ((first == 0) && (last == bank->num_sectors - 1)) { dcc_buffer[0] = OCL_ERASE_ALL; @@ -139,15 +139,15 @@ static int ocl_erase(struct flash_bank_s *bank, int first, int last) } /* receive response */ - if ((retval = embeddedice_receive(ocl->jtag_info, dcc_buffer+1, 1) != ERROR_OK)) + if ((retval = embeddedice_receive(ocl->jtag_info, dcc_buffer + 1, 1) != ERROR_OK)) return retval; if (dcc_buffer[1] != OCL_CMD_DONE) { if (dcc_buffer[0] == OCL_ERASE_ALL) - LOG_ERROR("loader response to OCL_ERASE_ALL 0x%08X", dcc_buffer[1]); + LOG_ERROR("loader response to OCL_ERASE_ALL 0x%08" PRIx32 "", dcc_buffer[1]); else - LOG_ERROR("loader response to OCL_ERASE_BLOCK 0x%08X", dcc_buffer[1]); + LOG_ERROR("loader response to OCL_ERASE_BLOCK 0x%08" PRIx32 "", dcc_buffer[1]); return ERROR_FLASH_OPERATION_FAILED; } @@ -159,20 +159,20 @@ static int ocl_protect(struct flash_bank_s *bank, int set, int first, int last) return ERROR_OK; } -static int ocl_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count) +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; int retval; - u32 *dcc_buffer; - u32 *dcc_bufptr; + uint32_t *dcc_buffer; + uint32_t *dcc_bufptr; int byteofs; int runlen; - u32 chksum; - + uint32_t chksum; + int i; /* check preconditions */ - if (ocl->buflen == 0 || ocl->bufalign==0) + if (ocl->buflen == 0 || ocl->bufalign == 0) return ERROR_FLASH_BANK_NOT_PROBED; if (bank->target->state != TARGET_RUNNING) @@ -182,7 +182,7 @@ static int ocl_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 coun } /* allocate buffer for max. ocl buffer + overhead */ - dcc_buffer = malloc(sizeof(u32)*(ocl->buflen/4+3)); + dcc_buffer = malloc(sizeof(uint32_t)*(ocl->buflen/4 + 3)); while (count) { @@ -200,7 +200,7 @@ static int ocl_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 coun chksum = OCL_CHKS_INIT; /* copy data to DCC buffer in proper byte order and properly aligned */ - for (i=0; ijtag_info, dcc_buffer, dcc_bufptr-dcc_buffer)) != ERROR_OK) { @@ -253,7 +253,7 @@ static int ocl_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 coun if (dcc_buffer[0] != OCL_CMD_DONE) { - LOG_ERROR("loader response to OCL_FLASH_BLOCK 0x%08X", dcc_buffer[0]); + LOG_ERROR("loader response to OCL_FLASH_BLOCK 0x%08" PRIx32 "", dcc_buffer[0]); free(dcc_buffer); return ERROR_FLASH_OPERATION_FAILED; } @@ -270,7 +270,7 @@ static int ocl_probe(struct flash_bank_s *bank) { ocl_priv_t *ocl = bank->driver_priv; int retval; - u32 dcc_buffer[1]; + uint32_t dcc_buffer[1]; int sectsize; int i; @@ -292,10 +292,10 @@ static int ocl_probe(struct flash_bank_s *bank) /* receive response */ if ((retval = embeddedice_receive(ocl->jtag_info, dcc_buffer, 1) != ERROR_OK)) return retval; - + if (dcc_buffer[0] != OCL_CMD_DONE) { - LOG_ERROR("loader response to OCL_PROBE 0x%08X", dcc_buffer[0]); + LOG_ERROR("loader response to OCL_PROBE 0x%08" PRIx32 "", dcc_buffer[0]); return ERROR_FLASH_OPERATION_FAILED; } @@ -332,7 +332,7 @@ static int ocl_probe(struct flash_bank_s *bank) return ERROR_FLASH_BANK_INVALID; } sectsize = bank->size / bank->num_sectors; - for (i=0; inum_sectors; i++) + for (i = 0; i < bank->num_sectors; i++) { bank->sectors[i].offset = i * sectsize; bank->sectors[i].size = sectsize; @@ -373,7 +373,7 @@ static int ocl_auto_probe(struct flash_bank_s *bank) { ocl_priv_t *ocl = bank->driver_priv; - if (ocl->buflen == 0 || ocl->bufalign==0) + if (ocl->buflen == 0 || ocl->bufalign == 0) return ERROR_FLASH_BANK_NOT_PROBED; return ERROR_OK;