rename flash and nand command helpers
[openocd.git] / src / flash / lpc2900.c
index 556a1512474ec7801ee6c17ac82f500f68f3d18f..465d77681529c7f3f18e2ee36523b73dc199ba5d 100644 (file)
@@ -27,6 +27,7 @@
 #include "flash.h"
 #include "binarybuffer.h"
 #include "armv4_5.h"
+#include "algorithm.h"
 
 
 /* 1024 bytes */
@@ -536,14 +537,14 @@ COMMAND_HANDLER(lpc2900_handle_signature_command)
        uint32_t signature[4];
 
 
-       if( argc < 1 )
+       if( CMD_ARGC < 1 )
        {
                LOG_WARNING( "Too few arguments. Call: lpc2900 signature <bank#>" );
                return ERROR_FLASH_BANK_INVALID;
        }
 
        struct flash_bank *bank;
-       int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -563,7 +564,7 @@ COMMAND_HANDLER(lpc2900_handle_signature_command)
                return status;
        }
 
-       command_print( cmd_ctx, "signature: 0x%8.8" PRIx32
+       command_print( CMD_CTX, "signature: 0x%8.8" PRIx32
                                          ":0x%8.8" PRIx32
                                          ":0x%8.8" PRIx32
                                          ":0x%8.8" PRIx32,
@@ -582,13 +583,13 @@ COMMAND_HANDLER(lpc2900_handle_signature_command)
  */
 COMMAND_HANDLER(lpc2900_handle_read_custom_command)
 {
-       if( argc < 2 )
+       if( CMD_ARGC < 2 )
        {
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        struct flash_bank *bank;
-       int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -622,7 +623,7 @@ COMMAND_HANDLER(lpc2900_handle_read_custom_command)
 
        /* Try and open the file */
        struct fileio fileio;
-       const char *filename = args[1];
+       const char *filename = CMD_ARGV[1];
        int ret = fileio_open( &fileio, filename, FILEIO_WRITE, FILEIO_BINARY );
        if( ret != ERROR_OK )
        {
@@ -630,7 +631,7 @@ COMMAND_HANDLER(lpc2900_handle_read_custom_command)
                return ret;
        }
 
-       uint32_t nwritten;
+       size_t nwritten;
        ret = fileio_write( &fileio, sizeof(customer),
                         (const uint8_t *)customer, &nwritten );
        if( ret != ERROR_OK )
@@ -653,13 +654,13 @@ COMMAND_HANDLER(lpc2900_handle_read_custom_command)
  */
 COMMAND_HANDLER(lpc2900_handle_password_command)
 {
-       if (argc < 2)
+       if (CMD_ARGC < 2)
        {
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        struct flash_bank *bank;
-       int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -667,15 +668,15 @@ COMMAND_HANDLER(lpc2900_handle_password_command)
 
 #define ISS_PASSWORD "I_know_what_I_am_doing"
 
-       lpc2900_info->risky = !strcmp( args[1], ISS_PASSWORD );
+       lpc2900_info->risky = !strcmp( CMD_ARGV[1], ISS_PASSWORD );
 
        if( !lpc2900_info->risky )
        {
-               command_print(cmd_ctx, "Wrong password (use '%s')", ISS_PASSWORD);
+               command_print(CMD_CTX, "Wrong password (use '%s')", ISS_PASSWORD);
                return ERROR_COMMAND_ARGUMENT_INVALID;
        }
 
-       command_print(cmd_ctx,
+       command_print(CMD_CTX,
                   "Potentially dangerous operation allowed in next command!");
 
        return ERROR_OK;
@@ -688,13 +689,13 @@ COMMAND_HANDLER(lpc2900_handle_password_command)
  */
 COMMAND_HANDLER(lpc2900_handle_write_custom_command)
 {
-       if (argc < 2)
+       if (CMD_ARGC < 2)
        {
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        struct flash_bank *bank;
-       int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -703,7 +704,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command)
        /* Check if command execution is allowed. */
        if( !lpc2900_info->risky )
        {
-               command_print( cmd_ctx, "Command execution not allowed!" );
+               command_print( CMD_CTX, "Command execution not allowed!" );
                return ERROR_COMMAND_ARGUMENT_INVALID;
        }
        lpc2900_info->risky = 0;
@@ -722,8 +723,8 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command)
        image.base_address = 0;
        image.start_address_set = 0;
 
-       const char *filename = args[1];
-       const char *type = (argc >= 3) ? args[2] : NULL;
+       const char *filename = CMD_ARGV[1];
+       const char *type = (CMD_ARGC >= 3) ? CMD_ARGV[2] : NULL;
        retval = image_open(&image, filename, type);
        if (retval != ERROR_OK)
        {
@@ -754,7 +755,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command)
        /* Page 4 */
        uint32_t offset = ISS_CUSTOMER_START1 % FLASH_PAGE_SIZE;
        memset( page, 0xff, FLASH_PAGE_SIZE );
-       uint32_t size_read;
+       size_t size_read;
        retval = image_read_section( &image, 0, 0,
                                     ISS_CUSTOMER_SIZE1, &page[offset], &size_read);
        if( retval != ERROR_OK )
@@ -798,14 +799,14 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command)
  */
 COMMAND_HANDLER(lpc2900_handle_secure_sector_command)
 {
-       if (argc < 3)
+       if (CMD_ARGC < 3)
        {
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        /* Get the bank descriptor */
        struct flash_bank *bank;
-       int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -814,7 +815,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command)
        /* Check if command execution is allowed. */
        if( !lpc2900_info->risky )
        {
-               command_print( cmd_ctx, "Command execution not allowed! "
+               command_print( CMD_CTX, "Command execution not allowed! "
                "(use 'password' command first)");
                return ERROR_COMMAND_ARGUMENT_INVALID;
        }
@@ -822,13 +823,13 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command)
 
        /* Read sector range, and do a sanity check. */
        int first, last;
-       COMMAND_PARSE_NUMBER(int, args[1], first);
-       COMMAND_PARSE_NUMBER(int, args[2], last);
+       COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], first);
+       COMMAND_PARSE_NUMBER(int, CMD_ARGV[2], last);
        if( (first >= bank->num_sectors) ||
            (last >= bank->num_sectors) ||
            (first > last) )
        {
-               command_print( cmd_ctx, "Illegal sector range" );
+               command_print( CMD_CTX, "Illegal sector range" );
                return ERROR_COMMAND_ARGUMENT_INVALID;
        }
 
@@ -877,7 +878,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command)
                }
        }
 
-       command_print( cmd_ctx,
+       command_print( CMD_CTX,
                "Sectors security will become effective after next power cycle");
 
        /* Update the sector security status */
@@ -897,14 +898,14 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command)
  */
 COMMAND_HANDLER(lpc2900_handle_secure_jtag_command)
 {
-       if (argc < 1)
+       if (CMD_ARGC < 1)
        {
                return ERROR_COMMAND_SYNTAX_ERROR;
        }
 
        /* Get the bank descriptor */
        struct flash_bank *bank;
-       int retval = flash_command_get_bank_by_num(cmd_ctx, args[0], &bank);
+       int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank);
        if (ERROR_OK != retval)
                return retval;
 
@@ -913,7 +914,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_jtag_command)
        /* Check if command execution is allowed. */
        if( !lpc2900_info->risky )
        {
-               command_print( cmd_ctx, "Command execution not allowed! "
+               command_print( CMD_CTX, "Command execution not allowed! "
                                        "(use 'password' command first)");
                return ERROR_COMMAND_ARGUMENT_INVALID;
        }
@@ -1019,7 +1020,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc2900_flash_bank_command)
 {
        struct lpc2900_flash_bank *lpc2900_info;
 
-       if (argc < 6)
+       if (CMD_ARGC < 6)
        {
                LOG_WARNING("incomplete flash_bank LPC2900 configuration");
                return ERROR_FLASH_BANK_INVALID;
@@ -1033,7 +1034,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc2900_flash_bank_command)
         * (if clock too slow), or for erase time (clock too fast).
         */
        uint32_t clk_sys_fmc;
-       COMMAND_PARSE_NUMBER(u32, args[6], clk_sys_fmc);
+       COMMAND_PARSE_NUMBER(u32, CMD_ARGV[6], clk_sys_fmc);
        lpc2900_info->clk_sys_fmc = clk_sys_fmc * 1000;
 
        uint32_t clock_limit;

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)