X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fflash%2Fmflash.c;h=1ad7290fa5850095b889823a5e51c03d8aec6c4c;hp=3d927c4549375349ccb3423a43c7093d4d8de724;hb=b61e454869c988e7fafc1c16982ccfec04415b51;hpb=1e9f8836a1af5b35b5950a24b8f19b38318df532 diff --git a/src/flash/mflash.c b/src/flash/mflash.c index 3d927c4549..1ad7290fa5 100644 --- a/src/flash/mflash.c +++ b/src/flash/mflash.c @@ -12,9 +12,7 @@ * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * along with this program. If not, see . * ***************************************************************************/ #ifdef HAVE_CONFIG_H @@ -261,11 +259,11 @@ static int mg_dsk_wait(mg_io_type_wait wait_local, uint32_t time_var) case mg_io_wait_rdy: if (status & mg_io_rbit_status_ready) return ERROR_OK; - + /* fallthrough */ case mg_io_wait_drq: if (status & mg_io_rbit_status_data_req) return ERROR_OK; - + /* fallthrough */ default: break; } @@ -510,7 +508,7 @@ static int mg_mflash_read_sects(void *buff, uint32_t sect_num, uint32_t sect_cnt } static int mg_mflash_do_write_sects(void *buff, uint32_t sect_num, uint32_t sect_cnt, - mg_io_type_cmd cmd) + uint8_t cmd) { uint32_t i, address; int ret; @@ -749,7 +747,7 @@ COMMAND_HANDLER(mg_write_cmd) { uint32_t address, cnt, res, i; uint8_t *buffer; - struct fileio fileio; + struct fileio *fileio; int ret; if (CMD_ARGC != 3) @@ -761,15 +759,16 @@ COMMAND_HANDLER(mg_write_cmd) if (ret != ERROR_OK) return ret; - int filesize; + size_t filesize; buffer = malloc(MG_FILEIO_CHUNK); if (!buffer) { - fileio_close(&fileio); + fileio_close(fileio); return ERROR_FAIL; } - int retval = fileio_size(&fileio, &filesize); + int retval = fileio_size(fileio, &filesize); if (retval != ERROR_OK) { - fileio_close(&fileio); + fileio_close(fileio); + free(buffer); return retval; } @@ -781,7 +780,7 @@ COMMAND_HANDLER(mg_write_cmd) size_t buf_cnt; for (i = 0; i < cnt; i++) { - ret = fileio_read(&fileio, MG_FILEIO_CHUNK, buffer, &buf_cnt); + ret = fileio_read(fileio, MG_FILEIO_CHUNK, buffer, &buf_cnt); if (ret != ERROR_OK) goto mg_write_cmd_err; ret = mg_mflash_write(address, buffer, MG_FILEIO_CHUNK); @@ -791,7 +790,7 @@ COMMAND_HANDLER(mg_write_cmd) } if (res) { - ret = fileio_read(&fileio, res, buffer, &buf_cnt); + ret = fileio_read(fileio, res, buffer, &buf_cnt); if (ret != ERROR_OK) goto mg_write_cmd_err; ret = mg_mflash_write(address, buffer, res); @@ -800,19 +799,19 @@ COMMAND_HANDLER(mg_write_cmd) } if (duration_measure(&bench) == ERROR_OK) { - command_print(CMD_CTX, "wrote %ld bytes from file %s " - "in %fs (%0.3f kB/s)", (long)filesize, CMD_ARGV[1], + command_print(CMD_CTX, "wrote %zu bytes from file %s " + "in %fs (%0.3f kB/s)", filesize, CMD_ARGV[1], duration_elapsed(&bench), duration_kbps(&bench, filesize)); } free(buffer); - fileio_close(&fileio); + fileio_close(fileio); return ERROR_OK; mg_write_cmd_err: free(buffer); - fileio_close(&fileio); + fileio_close(fileio); return ret; } @@ -821,7 +820,7 @@ COMMAND_HANDLER(mg_dump_cmd) { uint32_t address, size, cnt, res, i; uint8_t *buffer; - struct fileio fileio; + struct fileio *fileio; int ret; if (CMD_ARGC != 4) @@ -836,7 +835,7 @@ COMMAND_HANDLER(mg_dump_cmd) buffer = malloc(MG_FILEIO_CHUNK); if (!buffer) { - fileio_close(&fileio); + fileio_close(fileio); return ERROR_FAIL; } @@ -851,7 +850,7 @@ COMMAND_HANDLER(mg_dump_cmd) ret = mg_mflash_read(address, buffer, MG_FILEIO_CHUNK); if (ret != ERROR_OK) goto mg_dump_cmd_err; - ret = fileio_write(&fileio, MG_FILEIO_CHUNK, buffer, &size_written); + ret = fileio_write(fileio, MG_FILEIO_CHUNK, buffer, &size_written); if (ret != ERROR_OK) goto mg_dump_cmd_err; address += MG_FILEIO_CHUNK; @@ -861,7 +860,7 @@ COMMAND_HANDLER(mg_dump_cmd) ret = mg_mflash_read(address, buffer, res); if (ret != ERROR_OK) goto mg_dump_cmd_err; - ret = fileio_write(&fileio, res, buffer, &size_written); + ret = fileio_write(fileio, res, buffer, &size_written); if (ret != ERROR_OK) goto mg_dump_cmd_err; } @@ -874,13 +873,13 @@ COMMAND_HANDLER(mg_dump_cmd) } free(buffer); - fileio_close(&fileio); + fileio_close(fileio); return ERROR_OK; mg_dump_cmd_err: free(buffer); - fileio_close(&fileio); + fileio_close(fileio); return ret; } @@ -1072,16 +1071,16 @@ static void mg_gen_ataid(mg_io_type_drv_info *pSegIdDrvInfo) pSegIdDrvInfo->vendor_unique1[1] = 0x7570; pSegIdDrvInfo->vendor_unique1[2] = 0x8888; - memcpy(pSegIdDrvInfo->serial_number, (void *)g_strSEG_SerialNum, 20); + memcpy(pSegIdDrvInfo->serial_number, g_strSEG_SerialNum, 20); /* 0x2 : dual buffer */ pSegIdDrvInfo->buffer_type = 0x2; /* buffer size : 2KB */ pSegIdDrvInfo->buffer_sector_size = 0x800; pSegIdDrvInfo->number_of_ecc_bytes = 0; - memcpy(pSegIdDrvInfo->firmware_revision, (void *)g_strSEG_FWRev, 8); + memcpy(pSegIdDrvInfo->firmware_revision, g_strSEG_FWRev, 8); - memcpy(pSegIdDrvInfo->model_number, (void *)g_strSEG_ModelNum, 40); + memcpy(pSegIdDrvInfo->model_number, g_strSEG_ModelNum, 40); pSegIdDrvInfo->maximum_block_transfer = 0x4; pSegIdDrvInfo->vendor_unique2 = 0x0; @@ -1130,7 +1129,7 @@ static void mg_gen_ataid(mg_io_type_drv_info *pSegIdDrvInfo) pSegIdDrvInfo->recommend_dma_cyc = 0x1E0; pSegIdDrvInfo->min_pio_cyc_no_iordy = 0x1E0; pSegIdDrvInfo->min_pio_cyc_with_iordy = 0x1E0; - memset((void *)pSegIdDrvInfo->reserved3, 0x00, 22); + memset(pSegIdDrvInfo->reserved3, 0x00, 22); /* b7 : ATA/ATAPI-7 ,b6 : ATA/ATAPI-6 ,b5 : ATA/ATAPI-5,b4 : ATA/ATAPI-4 */ pSegIdDrvInfo->major_ver_num = 0x7E; /* 0x1C : ATA/ATAPI-6 T13 1532D revision1 */ @@ -1154,13 +1153,13 @@ static void mg_gen_ataid(mg_io_type_drv_info *pSegIdDrvInfo) /* Advanced power management level 1 */ pSegIdDrvInfo->adv_pwr_mgm_lvl_val = 0x0; pSegIdDrvInfo->reserved5 = 0x0; - memset((void *)pSegIdDrvInfo->reserved6, 0x00, 68); + memset(pSegIdDrvInfo->reserved6, 0x00, 68); /* Security mode feature is disabled */ pSegIdDrvInfo->security_stas = 0x0; - memset((void *)pSegIdDrvInfo->vendor_uniq_bytes, 0x00, 62); + memset(pSegIdDrvInfo->vendor_uniq_bytes, 0x00, 62); /* CFA power mode 1 support in maximum 200mA */ pSegIdDrvInfo->cfa_pwr_mode = 0x0100; - memset((void *)pSegIdDrvInfo->reserved7, 0x00, 190); + memset(pSegIdDrvInfo->reserved7, 0x00, 190); } static int mg_storage_config(void) @@ -1328,6 +1327,7 @@ static const struct command_registration mflash_exec_command_handlers[] = { .handler = mg_probe_cmd, .mode = COMMAND_EXEC, .help = "Detect bank configuration information", + .usage = "", }, { .name = "write", @@ -1395,7 +1395,7 @@ COMMAND_HANDLER(mg_bank_cmd) mflash_bank = calloc(sizeof(struct mflash_bank), 1); COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], mflash_bank->base); - /* / @todo Verify how this parsing should work, then document it. */ + /** @todo Verify how this parsing should work, then document it. */ char *str; mflash_bank->rst_pin.num = strtoul(CMD_ARGV[2], &str, 0); if (*str)