X-Git-Url: https://review.openocd.org/gitweb?a=blobdiff_plain;f=src%2Fflash%2Flpc2900.c;h=0d961e47f8bb81e2fbb5e8517638cf4667e4db3c;hb=1cbe3ec6f105e35e641293cd7e62e6fefac1b271;hp=67a510e09ea9e1a6f02d9d5fbc6e3e445e06021f;hpb=7bf1a86e473a12882bf6f71cb4d0d416394b69d4;p=openocd.git diff --git a/src/flash/lpc2900.c b/src/flash/lpc2900.c index 67a510e09e..0d961e47f8 100644 --- a/src/flash/lpc2900.c +++ b/src/flash/lpc2900.c @@ -544,7 +544,7 @@ COMMAND_HANDLER(lpc2900_handle_signature_command) } struct flash_bank *bank; - int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank); if (ERROR_OK != retval) return retval; @@ -564,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, @@ -589,7 +589,7 @@ COMMAND_HANDLER(lpc2900_handle_read_custom_command) } struct flash_bank *bank; - int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank); if (ERROR_OK != retval) return retval; @@ -623,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 ) { @@ -660,7 +660,7 @@ COMMAND_HANDLER(lpc2900_handle_password_command) } struct flash_bank *bank; - int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank); if (ERROR_OK != retval) return retval; @@ -668,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; @@ -695,7 +695,7 @@ COMMAND_HANDLER(lpc2900_handle_write_custom_command) } struct flash_bank *bank; - int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank); if (ERROR_OK != retval) return retval; @@ -704,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; @@ -723,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 = (CMD_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) { @@ -806,7 +806,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_sector_command) /* Get the bank descriptor */ struct flash_bank *bank; - int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank); if (ERROR_OK != retval) return retval; @@ -815,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; } @@ -823,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; } @@ -878,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 */ @@ -905,7 +905,7 @@ COMMAND_HANDLER(lpc2900_handle_secure_jtag_command) /* Get the bank descriptor */ struct flash_bank *bank; - int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 0, &bank); + int retval = CALL_COMMAND_HANDLER(flash_command_get_bank, 0, &bank); if (ERROR_OK != retval) return retval; @@ -914,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; } @@ -948,70 +948,67 @@ COMMAND_HANDLER(lpc2900_handle_secure_jtag_command) /*********************** Flash interface functions **************************/ +static const struct command_registration lpc2900_exec_command_handlers[] = { + { + .name = "signature", + .handler = &lpc2900_handle_signature_command, + .mode = COMMAND_EXEC, + .usage = "", + .help = "print device signature of flash bank", + }, + { + .name = "read_custom", + .handler = &lpc2900_handle_read_custom_command, + .mode = COMMAND_EXEC, + .usage = " ", + .help = "read customer information from index sector to file", + }, + { + .name = "password", + .handler = &lpc2900_handle_password_command, + .mode = COMMAND_EXEC, + .usage = " ", + .help = "enter password to enable 'dangerous' options", + }, + { + .name = "write_custom", + .handler = &lpc2900_handle_write_custom_command, + .mode = COMMAND_EXEC, + .usage = " []", + .help = "write customer info from file to index sector", + }, + { + .name = "secure_sector", + .handler = &lpc2900_handle_secure_sector_command, + .mode = COMMAND_EXEC, + .usage = " ", + .help = "activate sector security for a range of sectors", + }, + { + .name = "secure_jtag", + .handler = &lpc2900_handle_secure_jtag_command, + .mode = COMMAND_EXEC, + .usage = " ", + .help = "activate JTAG security", + }, + COMMAND_REGISTRATION_DONE +}; +static const struct command_registration lpc2900_command_handlers[] = { + { + .name = "lpc2900", + .mode = COMMAND_ANY, + .help = "LPC2900 flash command group", + .chain = lpc2900_exec_command_handlers, + }, + COMMAND_REGISTRATION_DONE +}; /** * Register private command handlers. */ static int lpc2900_register_commands(struct command_context *cmd_ctx) { - struct command *lpc2900_cmd = register_command(cmd_ctx, NULL, "lpc2900", - NULL, COMMAND_ANY, NULL); - - register_command( - cmd_ctx, - lpc2900_cmd, - "signature", - lpc2900_handle_signature_command, - COMMAND_EXEC, - " | " - "print device signature of flash bank"); - - register_command( - cmd_ctx, - lpc2900_cmd, - "read_custom", - lpc2900_handle_read_custom_command, - COMMAND_EXEC, - " | " - "read customer information from index sector to file"); - - register_command( - cmd_ctx, - lpc2900_cmd, - "password", - lpc2900_handle_password_command, - COMMAND_EXEC, - " | " - "enter password to enable 'dangerous' options"); - - register_command( - cmd_ctx, - lpc2900_cmd, - "write_custom", - lpc2900_handle_write_custom_command, - COMMAND_EXEC, - " [] | " - "write customer info from file to index sector"); - - register_command( - cmd_ctx, - lpc2900_cmd, - "secure_sector", - lpc2900_handle_secure_sector_command, - COMMAND_EXEC, - " | " - "activate sector security for a range of sectors"); - - register_command( - cmd_ctx, - lpc2900_cmd, - "secure_jtag", - lpc2900_handle_secure_jtag_command, - COMMAND_EXEC, - " | " - "activate JTAG security"); - - return ERROR_OK; + return register_commands(cmd_ctx, NULL, lpc2900_command_handlers); } @@ -1034,7 +1031,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;