rename flash and nand command helpers
[openocd.git] / src / flash / str9xpec.c
index ec5d031646ffa58e941ad3c6d2abf29798051bf9..f7c705e85bce6b07dfd03d86e37e7532df427539 100644 (file)
@@ -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;
 
@@ -242,7 +242,7 @@ FLASH_BANK_COMMAND_HANDLER(str9xpec_flash_bank_command)
        struct arm7_9_common *arm7_9 = 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, 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);
 
@@ -759,19 +759,19 @@ COMMAND_HANDLER(str9xpec_handle_part_id_command)
 
        idcode = buf_get_u32(buffer, 0, 32);
 
-       command_print(cmd_ctx, "str9xpec part id: 0x%8.8" PRIx32 "", idcode);
+       command_print(CMD_CTX, "str9xpec part id: 0x%8.8" PRIx32 "", idcode);
 
        free(buffer);
 
        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 <bank>");
+               command_print(CMD_CTX, "str9xpec options_read <bank>");
                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, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -802,38 +802,38 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_read_command)
 
        /* boot bank */
        if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_CSMAPBIT, 1))
-               command_print(cmd_ctx, "CS Map: bank1");
+               command_print(CMD_CTX, "CS Map: bank1");
        else
-               command_print(cmd_ctx, "CS Map: bank0");
+               command_print(CMD_CTX, "CS Map: bank0");
 
        /* OTP lock */
        if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_OTPBIT, 1))
-               command_print(cmd_ctx, "OTP Lock: OTP Locked");
+               command_print(CMD_CTX, "OTP Lock: OTP Locked");
        else
-               command_print(cmd_ctx, "OTP Lock: OTP Unlocked");
+               command_print(CMD_CTX, "OTP Lock: OTP Unlocked");
 
        /* LVD Threshold */
        if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_LVDTHRESBIT, 1))
-               command_print(cmd_ctx, "LVD Threshold: 2.7v");
+               command_print(CMD_CTX, "LVD Threshold: 2.7v");
        else
-               command_print(cmd_ctx, "LVD Threshold: 2.4v");
+               command_print(CMD_CTX, "LVD Threshold: 2.4v");
 
        /* LVD reset warning */
        if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_LVDWARNBIT, 1))
-               command_print(cmd_ctx, "LVD Reset Warning: VDD or VDDQ Inputs");
+               command_print(CMD_CTX, "LVD Reset Warning: VDD or VDDQ Inputs");
        else
-               command_print(cmd_ctx, "LVD Reset Warning: VDD Input Only");
+               command_print(CMD_CTX, "LVD Reset Warning: VDD Input Only");
 
        /* LVD reset select */
        if (buf_get_u32(str9xpec_info->options, STR9XPEC_OPT_LVDSELBIT, 1))
-               command_print(cmd_ctx, "LVD Reset Selection: VDD or VDDQ Inputs");
+               command_print(CMD_CTX, "LVD Reset Selection: VDD or VDDQ Inputs");
        else
-               command_print(cmd_ctx, "LVD Reset Selection: VDD Input Only");
+               command_print(CMD_CTX, "LVD Reset Selection: VDD Input Only");
 
        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 <bank>");
+               command_print(CMD_CTX, "str9xpec options_write <bank>");
                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, 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 <bank> <bank0 | bank1>");
+               command_print(CMD_CTX, "str9xpec options_cmap <bank> <bank0 | bank1>");
                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, 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 <bank> <2.4v | 2.7v>");
+               command_print(CMD_CTX, "str9xpec options_lvdthd <bank> <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, 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 <bank> <vdd | vdd_vddq>");
+               command_print(CMD_CTX, "str9xpec options_lvdsel <bank> <vdd | vdd_vddq>");
                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, 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 <bank> <vdd | vdd_vddq>");
+               command_print(CMD_CTX, "str9xpec options_lvdwarn <bank> <vdd | vdd_vddq>");
                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, 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 <bank>");
+               command_print(CMD_CTX, "str9xpec lock <bank>");
                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, 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 <bank>");
+               command_print(CMD_CTX, "str9xpec unlock <bank>");
                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, 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 <bank>");
+               command_print(CMD_CTX, "str9xpec enable_turbo <bank>");
                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, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -1106,14 +1106,14 @@ COMMAND_HANDLER(str9xpec_handle_flash_enable_turbo_command)
        if (tap1 == NULL)
        {
                /* things are *WRONG* */
-               command_print(cmd_ctx,"**STR9FLASH** (tap1) invalid chain?");
+               command_print(CMD_CTX,"**STR9FLASH** (tap1) invalid chain?");
                return ERROR_OK;
        }
        tap2 = tap1->next_tap;
        if (tap2 == NULL)
        {
                /* things are *WRONG* */
-               command_print(cmd_ctx,"**STR9FLASH** (tap2) invalid chain?");
+               command_print(CMD_CTX,"**STR9FLASH** (tap2) invalid chain?");
                return ERROR_OK;
        }
 
@@ -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 <bank>");
+               command_print(CMD_CTX, "str9xpec disable_turbo <bank>");
                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, 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",

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)