X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fflash%2Fstr9xpec.c;h=a87d0fff46402e6891f2435b79a428b06c7c3f73;hp=ad51cf191eb555fa84362b216247bccd39673400;hb=23402315ce01071f30d7ec0c5ca7563ce41f1cc6;hpb=8012b3963fc49c7edf87f31a93bc0039095f5b59 diff --git a/src/flash/str9xpec.c b/src/flash/str9xpec.c index ad51cf191e..a87d0fff46 100644 --- a/src/flash/str9xpec.c +++ b/src/flash/str9xpec.c @@ -28,9 +28,9 @@ #include "arm7_9_common.h" -static int str9xpec_erase_area(struct flash_bank_s *bank, int first, int last); -static int str9xpec_set_address(struct flash_bank_s *bank, uint8_t sector); -static int str9xpec_write_options(struct flash_bank_s *bank); +static int str9xpec_erase_area(struct flash_bank *bank, int first, int last); +static int str9xpec_set_address(struct flash_bank *bank, uint8_t sector); +static int str9xpec_write_options(struct flash_bank *bank); int str9xpec_set_instr(struct jtag_tap *tap, uint32_t new_instr, tap_state_t end_state) { @@ -44,7 +44,7 @@ int str9xpec_set_instr(struct jtag_tap *tap, uint32_t new_instr, tap_state_t end field.tap = tap; field.num_bits = tap->ir_length; - field.out_value = calloc(CEIL(field.num_bits, 8), 1); + field.out_value = calloc(DIV_ROUND_UP(field.num_bits, 8), 1); buf_set_u32(field.out_value, 0, field.num_bits, new_instr); field.in_value = NULL; @@ -81,7 +81,7 @@ static uint8_t str9xpec_isc_status(struct jtag_tap *tap) return status; } -static int str9xpec_isc_enable(struct flash_bank_s *bank) +static int str9xpec_isc_enable(struct flash_bank *bank) { uint8_t status; struct jtag_tap *tap; @@ -108,7 +108,7 @@ static int str9xpec_isc_enable(struct flash_bank_s *bank) return ERROR_OK; } -static int str9xpec_isc_disable(struct flash_bank_s *bank) +static int str9xpec_isc_disable(struct flash_bank *bank) { uint8_t status; struct jtag_tap *tap; @@ -137,7 +137,7 @@ static int str9xpec_isc_disable(struct flash_bank_s *bank) return ERROR_OK; } -static int str9xpec_read_config(struct flash_bank_s *bank) +static int str9xpec_read_config(struct flash_bank *bank) { struct scan_field field; uint8_t status; @@ -166,7 +166,7 @@ static int str9xpec_read_config(struct flash_bank_s *bank) return status; } -static int str9xpec_build_block_list(struct flash_bank_s *bank) +static int str9xpec_build_block_list(struct flash_bank *bank) { struct str9xpec_flash_controller *str9xpec_info = bank->driver_priv; @@ -238,11 +238,11 @@ static int str9xpec_build_block_list(struct flash_bank_s *bank) FLASH_BANK_COMMAND_HANDLER(str9xpec_flash_bank_command) { struct str9xpec_flash_controller *str9xpec_info; - armv4_5_common_t *armv4_5 = NULL; + struct arm *armv4_5 = NULL; struct arm7_9_common *arm7_9 = NULL; - arm_jtag_t *jtag_info = NULL; + struct arm_jtag *jtag_info = NULL; - if (argc < 6) + if (CMD_ARGC < 6) { LOG_WARNING("incomplete flash_bank str9x configuration"); return ERROR_FLASH_BANK_INVALID; @@ -269,7 +269,7 @@ FLASH_BANK_COMMAND_HANDLER(str9xpec_flash_bank_command) return ERROR_OK; } -static int str9xpec_blank_check(struct flash_bank_s *bank, int first, int last) +static int str9xpec_blank_check(struct flash_bank *bank, int first, int last) { struct scan_field field; uint8_t status; @@ -289,7 +289,7 @@ static int str9xpec_blank_check(struct flash_bank_s *bank, int first, int last) return ERROR_FLASH_OPERATION_FAILED; } - buffer = calloc(CEIL(64, 8), 1); + buffer = calloc(DIV_ROUND_UP(64, 8), 1); LOG_DEBUG("blank check: first_bank: %i, last_bank: %i", first, last); @@ -336,7 +336,7 @@ static int str9xpec_blank_check(struct flash_bank_s *bank, int first, int last) return ERROR_OK; } -static int str9xpec_protect_check(struct flash_bank_s *bank) +static int str9xpec_protect_check(struct flash_bank *bank) { uint8_t status; int i; @@ -358,7 +358,7 @@ static int str9xpec_protect_check(struct flash_bank_s *bank) return ERROR_OK; } -static int str9xpec_erase_area(struct flash_bank_s *bank, int first, int last) +static int str9xpec_erase_area(struct flash_bank *bank, int first, int last) { struct scan_field field; uint8_t status; @@ -378,7 +378,7 @@ static int str9xpec_erase_area(struct flash_bank_s *bank, int first, int last) return ISC_STATUS_ERROR; } - buffer = calloc(CEIL(64, 8), 1); + buffer = calloc(DIV_ROUND_UP(64, 8), 1); LOG_DEBUG("erase: first_bank: %i, last_bank: %i", first, last); @@ -428,7 +428,7 @@ static int str9xpec_erase_area(struct flash_bank_s *bank, int first, int last) return status; } -static int str9xpec_erase(struct flash_bank_s *bank, int first, int last) +static int str9xpec_erase(struct flash_bank *bank, int first, int last) { int status; @@ -440,7 +440,7 @@ static int str9xpec_erase(struct flash_bank_s *bank, int first, int last) return ERROR_OK; } -static int str9xpec_lock_device(struct flash_bank_s *bank) +static int str9xpec_lock_device(struct flash_bank *bank) { struct scan_field field; uint8_t status; @@ -482,7 +482,7 @@ static int str9xpec_lock_device(struct flash_bank_s *bank) return status; } -static int str9xpec_unlock_device(struct flash_bank_s *bank) +static int str9xpec_unlock_device(struct flash_bank *bank) { uint8_t status; @@ -491,7 +491,7 @@ static int str9xpec_unlock_device(struct flash_bank_s *bank) return status; } -static int str9xpec_protect(struct flash_bank_s *bank, int set, int first, int last) +static int str9xpec_protect(struct flash_bank *bank, int set, int first, int last) { uint8_t status; int i; @@ -537,7 +537,7 @@ static int str9xpec_protect(struct flash_bank_s *bank, int set, int first, int l return ERROR_OK; } -static int str9xpec_set_address(struct flash_bank_s *bank, uint8_t sector) +static int str9xpec_set_address(struct flash_bank *bank, uint8_t sector) { struct jtag_tap *tap; struct scan_field field; @@ -558,7 +558,7 @@ static int str9xpec_set_address(struct flash_bank_s *bank, uint8_t sector) return ERROR_OK; } -static int str9xpec_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t offset, uint32_t count) +static int str9xpec_write(struct flash_bank *bank, uint8_t *buffer, uint32_t offset, uint32_t count) { struct str9xpec_flash_controller *str9xpec_info = bank->driver_priv; uint32_t dwords_remaining = (count / 8); @@ -618,7 +618,7 @@ static int str9xpec_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t o LOG_DEBUG("first_sector: %i, last_sector: %i", first_sector, last_sector); - scanbuf = calloc(CEIL(64, 8), 1); + scanbuf = calloc(DIV_ROUND_UP(64, 8), 1); LOG_DEBUG("ISC_PROGRAM"); @@ -721,7 +721,7 @@ static int str9xpec_write(struct flash_bank_s *bank, uint8_t *buffer, uint32_t o return ERROR_OK; } -static int str9xpec_probe(struct flash_bank_s *bank) +static int str9xpec_probe(struct flash_bank *bank) { return ERROR_OK; } @@ -734,18 +734,18 @@ COMMAND_HANDLER(str9xpec_handle_part_id_command) uint32_t idcode; struct str9xpec_flash_controller *str9xpec_info = NULL; - if (argc < 1) + if (CMD_ARGC < 1) return ERROR_COMMAND_SYNTAX_ERROR; - flash_bank_t *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + struct flash_bank *bank; + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; str9xpec_info = bank->driver_priv; tap = str9xpec_info->tap; - buffer = calloc(CEIL(32, 8), 1); + buffer = calloc(DIV_ROUND_UP(32, 8), 1); str9xpec_set_instr(tap, ISC_IDCODE, TAP_IRPAUSE); @@ -766,12 +766,12 @@ COMMAND_HANDLER(str9xpec_handle_part_id_command) return ERROR_OK; } -static int str9xpec_erase_check(struct flash_bank_s *bank) +static int str9xpec_erase_check(struct flash_bank *bank) { return str9xpec_blank_check(bank, 0, bank->num_sectors - 1); } -static int str9xpec_info(struct flash_bank_s *bank, char *buf, int buf_size) +static int str9xpec_info(struct flash_bank *bank, char *buf, int buf_size) { snprintf(buf, buf_size, "str9xpec flash driver info"); return ERROR_OK; @@ -782,14 +782,14 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_read_command) uint8_t status; struct str9xpec_flash_controller *str9xpec_info = NULL; - if (argc < 1) + if (CMD_ARGC < 1) { command_print(cmd_ctx, "str9xpec options_read "); return ERROR_OK; } - flash_bank_t *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + struct flash_bank *bank; + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -833,7 +833,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_read_command) return ERROR_OK; } -static int str9xpec_write_options(struct flash_bank_s *bank) +static int str9xpec_write_options(struct flash_bank *bank) { struct scan_field field; uint8_t status; @@ -898,14 +898,14 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_write_command) { uint8_t status; - if (argc < 1) + if (CMD_ARGC < 1) { command_print(cmd_ctx, "str9xpec options_write "); return ERROR_OK; } - flash_bank_t *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + struct flash_bank *bank; + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -921,20 +921,20 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_cmap_command) { struct str9xpec_flash_controller *str9xpec_info = NULL; - if (argc < 2) + if (CMD_ARGC < 2) { command_print(cmd_ctx, "str9xpec options_cmap "); return ERROR_OK; } - flash_bank_t *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + struct flash_bank *bank; + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; str9xpec_info = bank->driver_priv; - if (strcmp(args[1], "bank1") == 0) + if (strcmp(CMD_ARGV[1], "bank1") == 0) { buf_set_u32(str9xpec_info->options, STR9XPEC_OPT_CSMAPBIT, 1, 1); } @@ -950,20 +950,20 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdthd_command) { struct str9xpec_flash_controller *str9xpec_info = NULL; - if (argc < 2) + if (CMD_ARGC < 2) { command_print(cmd_ctx, "str9xpec options_lvdthd <2.4v | 2.7v>"); return ERROR_OK; } - flash_bank_t *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + struct flash_bank *bank; + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; str9xpec_info = bank->driver_priv; - if (strcmp(args[1], "2.7v") == 0) + if (strcmp(CMD_ARGV[1], "2.7v") == 0) { buf_set_u32(str9xpec_info->options, STR9XPEC_OPT_LVDTHRESBIT, 1, 1); } @@ -979,20 +979,20 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdsel_command) { struct str9xpec_flash_controller *str9xpec_info = NULL; - if (argc < 2) + if (CMD_ARGC < 2) { command_print(cmd_ctx, "str9xpec options_lvdsel "); return ERROR_OK; } - flash_bank_t *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + struct flash_bank *bank; + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; str9xpec_info = bank->driver_priv; - if (strcmp(args[1], "vdd_vddq") == 0) + if (strcmp(CMD_ARGV[1], "vdd_vddq") == 0) { buf_set_u32(str9xpec_info->options, STR9XPEC_OPT_LVDSELBIT, 1, 1); } @@ -1008,20 +1008,20 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdwarn_command) { struct str9xpec_flash_controller *str9xpec_info = NULL; - if (argc < 2) + if (CMD_ARGC < 2) { command_print(cmd_ctx, "str9xpec options_lvdwarn "); return ERROR_OK; } - flash_bank_t *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + struct flash_bank *bank; + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; str9xpec_info = bank->driver_priv; - if (strcmp(args[1], "vdd_vddq") == 0) + if (strcmp(CMD_ARGV[1], "vdd_vddq") == 0) { buf_set_u32(str9xpec_info->options, STR9XPEC_OPT_LVDWARNBIT, 1, 1); } @@ -1037,14 +1037,14 @@ COMMAND_HANDLER(str9xpec_handle_flash_lock_command) { uint8_t status; - if (argc < 1) + if (CMD_ARGC < 1) { command_print(cmd_ctx, "str9xpec lock "); return ERROR_OK; } - flash_bank_t *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + struct flash_bank *bank; + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -1060,14 +1060,14 @@ COMMAND_HANDLER(str9xpec_handle_flash_unlock_command) { uint8_t status; - if (argc < 1) + if (CMD_ARGC < 1) { command_print(cmd_ctx, "str9xpec unlock "); return ERROR_OK; } - flash_bank_t *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + struct flash_bank *bank; + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -1086,14 +1086,14 @@ COMMAND_HANDLER(str9xpec_handle_flash_enable_turbo_command) struct jtag_tap *tap2; struct str9xpec_flash_controller *str9xpec_info = NULL; - if (argc < 1) + if (CMD_ARGC < 1) { command_print(cmd_ctx, "str9xpec enable_turbo "); return ERROR_OK; } - flash_bank_t *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + struct flash_bank *bank; + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -1133,14 +1133,14 @@ COMMAND_HANDLER(str9xpec_handle_flash_disable_turbo_command) struct jtag_tap *tap; struct str9xpec_flash_controller *str9xpec_info = NULL; - if (argc < 1) + if (CMD_ARGC < 1) { command_print(cmd_ctx, "str9xpec disable_turbo "); return ERROR_OK; } - flash_bank_t *bank; - int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank); + struct flash_bank *bank; + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); if (ERROR_OK != retval) return retval; @@ -1163,9 +1163,9 @@ COMMAND_HANDLER(str9xpec_handle_flash_disable_turbo_command) return ERROR_OK; } -static int str9xpec_register_commands(struct command_context_s *cmd_ctx) +static int str9xpec_register_commands(struct command_context *cmd_ctx) { - command_t *str9xpec_cmd = register_command(cmd_ctx, NULL, "str9xpec", + struct command *str9xpec_cmd = register_command(cmd_ctx, NULL, "str9xpec", NULL, COMMAND_ANY, "str9xpec flash specific commands"); register_command(cmd_ctx, str9xpec_cmd, "enable_turbo",