}
- switch (argc) {
+ switch (CMD_ARGC) {
default:
command_print(cmd_ctx,"Too many parameters\n");
return ERROR_COMMAND_SYNTAX_ERROR;
}
- switch (argc) {
+ switch (CMD_ARGC) {
case 0:
// show
break;
at91sam7_info->ext_freq = 0;
at91sam7_info->flash_autodetection = 0;
- if (argc < 13)
+ if (CMD_ARGC < 13)
{
at91sam7_info->flash_autodetection = 1;
return ERROR_OK;
COMMAND_PARSE_NUMBER(u16, args[11], page_size);
COMMAND_PARSE_NUMBER(u16, args[12], num_nvmbits);
- if (argc == 14) {
+ if (CMD_ARGC == 14) {
unsigned long freq;
COMMAND_PARSE_NUMBER(ulong, args[13], freq);
ext_freq = freq * 1000;
struct at91sam7_flash_bank *at91sam7_info;
int retval;
- if (argc != 2)
+ if (CMD_ARGC != 2)
{
command_print(cmd_ctx, "at91sam7 gpnvm <bit> <set | clear>");
return ERROR_OK;
{
struct avrf_flash_bank *avrf_info;
- if (argc < 6)
+ if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank avr configuration");
return ERROR_FLASH_BANK_INVALID;
{
int i;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "avr mass_erase <bank>");
return ERROR_OK;
{
struct cfi_flash_bank *cfi_info;
- if (argc < 6)
+ if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank cfi configuration");
return ERROR_FLASH_BANK_INVALID;
cfi_info->jedec_probe = 0;
cfi_info->not_cfi = 0;
- for (unsigned i = 6; i < argc; i++)
+ for (unsigned i = 6; i < CMD_ARGC; i++)
{
if (strcmp(args[i], "x16_as_x8") == 0)
{
* - aemif address
* Plus someday, optionally, ALE and CLE masks.
*/
- if (argc < 5) {
+ if (CMD_ARGC < 5) {
LOG_ERROR("parameters: %s target "
"chip_addr hwecc_mode aemif_addr",
args[0]);
{
struct ecosflash_flash_bank *info;
- if (argc < 7)
+ if (CMD_ARGC < 7)
{
LOG_WARNING("incomplete flash_bank ecosflash configuration");
return ERROR_FLASH_BANK_INVALID;
{
struct faux_flash_bank *info;
- if (argc < 6)
+ if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank faux configuration");
return ERROR_FLASH_BANK_INVALID;
int found = 0;
struct target *target;
- if (argc < 6)
+ if (CMD_ARGC < 6)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
int j = 0;
int retval;
- if (argc != 1)
+ if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
unsigned bank_nr;
{
int retval;
- if (argc != 1)
+ if (CMD_ARGC != 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
COMMAND_HANDLER(handle_flash_erase_check_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
struct target *target = get_current_target(cmd_ctx);
- if (argc != 2)
+ if (CMD_ARGC != 2)
return ERROR_COMMAND_SYNTAX_ERROR;
COMMAND_PARSE_NUMBER(int, args[0], address);
COMMAND_HANDLER(handle_flash_protect_check_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
struct flash_bank *p;
COMMAND_HANDLER(handle_flash_erase_command)
{
- if (argc != 2)
+ if (CMD_ARGC != 2)
return ERROR_COMMAND_SYNTAX_ERROR;
uint32_t bank_nr;
COMMAND_HANDLER(handle_flash_protect_command)
{
- if (argc != 3)
+ if (CMD_ARGC != 3)
return ERROR_COMMAND_SYNTAX_ERROR;
uint32_t bank_nr;
int retval;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
{
auto_erase = 1;
args++;
- argc--;
+ CMD_ARGC--;
command_print(cmd_ctx, "auto erase enabled");
} else if (strcmp(args[0], "unlock") == 0)
{
auto_unlock = true;
args++;
- argc--;
+ CMD_ARGC--;
command_print(cmd_ctx, "auto unlock enabled");
} else
{
}
}
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
struct duration bench;
duration_start(&bench);
- if (argc >= 2)
+ if (CMD_ARGC >= 2)
{
image.base_address_set = 1;
COMMAND_PARSE_NUMBER(int, args[1], image.base_address);
image.start_address_set = 0;
- retval = image_open(&image, args[0], (argc == 3) ? args[2] : NULL);
+ retval = image_open(&image, args[0], (CMD_ARGC == 3) ? args[2] : NULL);
if (retval != ERROR_OK)
{
return retval;
uint32_t i;
uint32_t wordsize;
- if (argc != 3)
+ if (CMD_ARGC != 3)
return ERROR_COMMAND_SYNTAX_ERROR;
COMMAND_PARSE_NUMBER(u32, args[0], address);
uint8_t *buffer;
struct fileio fileio;
- if (argc != 3)
+ if (CMD_ARGC != 3)
return ERROR_COMMAND_SYNTAX_ERROR;
struct duration bench;
*
* For example, args[4] = 16 bit flash, args[5] = 32bit bus.
*
- * If extra arguments are provided (@a argc > 6), they will
+ * If extra arguments are provided (@a CMD_ARGC > 6), they will
* start in @a args[6]. These can be used to implement
* driver-specific extensions.
*
{
struct lpc2000_flash_bank *lpc2000_info;
- if (argc < 8)
+ if (CMD_ARGC < 8)
{
LOG_WARNING("incomplete flash_bank lpc2000 configuration");
return ERROR_FLASH_BANK_INVALID;
lpc2000_info->calc_checksum = 0;
lpc2000_build_sector_list(bank);
- if (argc >= 9)
+ if (CMD_ARGC >= 9)
{
if (strcmp(args[8], "calc_checksum") == 0)
lpc2000_info->calc_checksum = 1;
uint32_t result_table[4];
int status_code;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
{
struct lpc288x_flash_bank *lpc288x_info;
- if (argc < 6)
+ if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank LPC288x configuration");
return ERROR_FLASH_BANK_INVALID;
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;
*/
COMMAND_HANDLER(lpc2900_handle_read_custom_command)
{
- if( argc < 2 )
+ if( CMD_ARGC < 2 )
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
*/
COMMAND_HANDLER(lpc2900_handle_password_command)
{
- if (argc < 2)
+ if (CMD_ARGC < 2)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
*/
COMMAND_HANDLER(lpc2900_handle_write_custom_command)
{
- if (argc < 2)
+ if (CMD_ARGC < 2)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
image.start_address_set = 0;
const char *filename = args[1];
- const char *type = (argc >= 3) ? args[2] : NULL;
+ const char *type = (CMD_ARGC >= 3) ? args[2] : NULL;
retval = image_open(&image, filename, type);
if (retval != ERROR_OK)
{
*/
COMMAND_HANDLER(lpc2900_handle_secure_sector_command)
{
- if (argc < 3)
+ if (CMD_ARGC < 3)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
*/
COMMAND_HANDLER(lpc2900_handle_secure_jtag_command)
{
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
{
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;
*/
NAND_DEVICE_COMMAND_HANDLER(lpc3180_nand_device_command)
{
- if (argc < 3)
+ if (CMD_ARGC < 3)
{
LOG_WARNING("incomplete 'lpc3180' nand flash configuration");
return ERROR_FLASH_BANK_INVALID;
"no", "mlc", "slc"
};
- if ((argc < 1) || (argc > 2))
+ if ((CMD_ARGC < 1) || (CMD_ARGC > 2))
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
lpc3180_info = nand->controller_priv;
- if (argc == 2)
+ if (CMD_ARGC == 2)
{
if (strcmp(args[1], "mlc") == 0)
{
struct fileio fileio;
int ret;
- if (argc != 3) {
+ if (CMD_ARGC != 3) {
return ERROR_COMMAND_SYNTAX_ERROR;
}
struct fileio fileio;
int ret;
- if (argc != 4) {
+ if (CMD_ARGC != 4) {
return ERROR_COMMAND_SYNTAX_ERROR;
}
if ((ret = mg_mflash_rst()) != ERROR_OK)
return ret;
- switch (argc) {
+ switch (CMD_ARGC) {
case 2:
if (!strcmp(args[1], "boot"))
return mg_boot_config();
struct target *target;
int i;
- if (argc < 4)
+ if (CMD_ARGC < 4)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
LOG_ERROR ("target '%s' not defined", args[1]);
return ERROR_FAIL;
}
- if (argc < 3)
+ if (CMD_ARGC < 3)
{
LOG_ERROR ("use \"nand device imx31 target noecc|hwecc\"");
return ERROR_FAIL;
int i;
int retval;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
LOG_WARNING("incomplete flash device nand configuration");
return ERROR_FLASH_BANK_INVALID;
if (ERROR_OK != retval)
return retval;
- switch (argc) {
+ switch (CMD_ARGC) {
default:
return ERROR_COMMAND_SYNTAX_ERROR;
case 1:
COMMAND_HANDLER(handle_nand_probe_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
COMMAND_HANDLER(handle_nand_erase_command)
{
- if (argc != 1 && argc != 3)
+ if (CMD_ARGC != 1 && CMD_ARGC != 3)
{
return ERROR_COMMAND_SYNTAX_ERROR;
unsigned long length;
/* erase specified part of the chip; or else everything */
- if (argc == 3) {
+ if (CMD_ARGC == 3) {
unsigned long size = p->erase_size * p->num_blocks;
COMMAND_PARSE_NUMBER(ulong, args[1], offset);
int first = -1;
int last = -1;
- if ((argc < 1) || (argc > 3) || (argc == 2))
+ if ((CMD_ARGC < 1) || (CMD_ARGC > 3) || (CMD_ARGC == 2))
{
return ERROR_COMMAND_SYNTAX_ERROR;
if (ERROR_OK != retval)
return retval;
- if (argc == 3)
+ if (CMD_ARGC == 3)
{
unsigned long offset;
unsigned long length;
nand_fileio_init(state);
unsigned minargs = need_size ? 4 : 3;
- if (argc < minargs)
+ if (CMD_ARGC < minargs)
return ERROR_COMMAND_SYNTAX_ERROR;
struct nand_device *nand;
}
}
- if (argc > minargs)
+ if (CMD_ARGC > minargs)
{
- for (unsigned i = minargs; i < argc; i++)
+ for (unsigned i = minargs; i < CMD_ARGC; i++)
{
if (!strcmp(args[i], "oob_raw"))
state->oob_format |= NAND_OOB_RAW;
COMMAND_HANDLER(handle_nand_raw_access_command)
{
- if ((argc < 1) || (argc > 2))
+ if ((CMD_ARGC < 1) || (CMD_ARGC > 2))
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
return ERROR_OK;
}
- if (argc == 2)
+ if (CMD_ARGC == 2)
{
if (strcmp("enable", args[1]) == 0)
p->use_raw = 1;
struct arm7_9_common *arm7_9;
struct ocl_priv *ocl;
- if (argc < 6)
+ if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank ocl configuration");
return ERROR_FLASH_BANK_INVALID;
uint32_t base;
uint8_t ale, cle;
- if (argc != 3) {
+ if (CMD_ARGC != 3) {
LOG_ERROR("arguments must be: <target_id> <NAND_address>\n");
return ERROR_NAND_DEVICE_INVALID;
}
{
struct pic32mx_flash_bank *pic32mx_info;
- if (argc < 6)
+ if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank pic32mx configuration");
return ERROR_FLASH_BANK_INVALID;
struct target *target = NULL;
struct pic32mx_flash_bank *pic32mx_info = NULL;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "pic32mx lock <bank>");
return ERROR_OK;
struct target *target = NULL;
struct pic32mx_flash_bank *pic32mx_info = NULL;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "pic32mx unlock <bank>");
return ERROR_OK;
#if 0
int i;
- if (argc != 0)
+ if (CMD_ARGC != 0)
{
command_print(cmd_ctx, "pic32mx chip_erase");
return ERROR_OK;
uint32_t address, value;
int status, res;
- if (argc != 3)
+ if (CMD_ARGC != 3)
{
command_print(cmd_ctx, "pic32mx pgm_word <addr> <value> <bank>");
return ERROR_OK;
{
struct stellaris_flash_bank *stellaris_info;
- if (argc < 6)
+ if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank stellaris configuration");
return ERROR_FLASH_BANK_INVALID;
{
int i;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "stellaris mass_erase <bank>");
return ERROR_OK;
{
struct stm32x_flash_bank *stm32x_info;
- if (argc < 6)
+ if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank stm32x configuration");
return ERROR_FLASH_BANK_INVALID;
struct target *target = NULL;
struct stm32x_flash_bank *stm32x_info = NULL;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "stm32x lock <bank>");
return ERROR_OK;
struct target *target = NULL;
struct stm32x_flash_bank *stm32x_info = NULL;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "stm32x unlock <bank>");
return ERROR_OK;
struct target *target = NULL;
struct stm32x_flash_bank *stm32x_info = NULL;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "stm32x options_read <bank>");
return ERROR_OK;
struct stm32x_flash_bank *stm32x_info = NULL;
uint16_t optionbyte = 0xF8;
- if (argc < 4)
+ if (CMD_ARGC < 4)
{
command_print(cmd_ctx, "stm32x options_write <bank> <SWWDG | HWWDG> <RSTSTNDBY | NORSTSTNDBY> <RSTSTOP | NORSTSTOP>");
return ERROR_OK;
{
int i;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "stm32x mass_erase <bank>");
return ERROR_OK;
{
struct str7x_flash_bank *str7x_info;
- if (argc < 7)
+ if (CMD_ARGC < 7)
{
LOG_WARNING("incomplete flash_bank str7x configuration");
return ERROR_FLASH_BANK_INVALID;
uint16_t ProtectionLevel = 0;
uint16_t ProtectionRegs;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "str7x disable_jtag <bank>");
return ERROR_OK;
{
struct str9x_flash_bank *str9x_info;
- if (argc < 6)
+ if (CMD_ARGC < 6)
{
LOG_WARNING("incomplete flash_bank str9x configuration");
return ERROR_FLASH_BANK_INVALID;
struct str9x_flash_bank *str9x_info;
struct target *target = NULL;
- if (argc < 5)
+ if (CMD_ARGC < 5)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
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;
uint32_t idcode;
struct str9xpec_flash_controller *str9xpec_info = NULL;
- if (argc < 1)
+ if (CMD_ARGC < 1)
return ERROR_COMMAND_SYNTAX_ERROR;
struct flash_bank *bank;
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>");
return ERROR_OK;
{
uint8_t status;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "str9xpec options_write <bank>");
return ERROR_OK;
{
struct str9xpec_flash_controller *str9xpec_info = NULL;
- if (argc < 2)
+ if (CMD_ARGC < 2)
{
command_print(cmd_ctx, "str9xpec options_cmap <bank> <bank0 | bank1>");
return ERROR_OK;
{
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>");
return ERROR_OK;
{
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>");
return ERROR_OK;
{
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>");
return ERROR_OK;
{
uint8_t status;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "str9xpec lock <bank>");
return ERROR_OK;
{
uint8_t status;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "str9xpec unlock <bank>");
return ERROR_OK;
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>");
return ERROR_OK;
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>");
return ERROR_OK;
COMMAND_HANDLER(tms470_handle_flash_keyset_command)
{
- if (argc > 4)
+ if (CMD_ARGC > 4)
{
command_print(cmd_ctx, "tms470 flash_keyset <key0> <key1> <key2> <key3>");
return ERROR_INVALID_ARGUMENTS;
}
- else if (argc == 4)
+ else if (CMD_ARGC == 4)
{
int i;
keysSet = 1;
}
- else if (argc != 0)
+ else if (CMD_ARGC != 0)
{
command_print(cmd_ctx, "tms470 flash_keyset <key0> <key1> <key2> <key3>");
return ERROR_INVALID_ARGUMENTS;
COMMAND_HANDLER(tms470_handle_osc_megahertz_command)
{
- if (argc > 1)
+ if (CMD_ARGC > 1)
{
command_print(cmd_ctx, "tms470 osc_megahertz <MHz>");
return ERROR_INVALID_ARGUMENTS;
}
- else if (argc == 1)
+ else if (CMD_ARGC == 1)
{
sscanf(args[0], "%d", &oscMHz);
}
COMMAND_HANDLER(tms470_handle_plldis_command)
{
- if (argc > 1)
+ if (CMD_ARGC > 1)
{
command_print(cmd_ctx, "tms470 plldis <0 | 1>");
return ERROR_INVALID_ARGUMENTS;
}
- else if (argc == 1)
+ else if (CMD_ARGC == 1)
{
sscanf(args[0], "%d", &plldis);
plldis = plldis ? 1 : 0;
static COMMAND_HELPER(handle_hello_args, const char **sep, const char **name)
{
- if (argc > 1)
+ if (CMD_ARGC > 1)
{
LOG_ERROR("%s: too many arguments", CMD_NAME);
return ERROR_COMMAND_SYNTAX_ERROR;
}
- if (1 == argc)
+ if (1 == CMD_ARGC)
{
*sep = " ";
*name = args[0];
COMMAND_HANDLER(handle_sleep_command)
{
bool busy = false;
- if (argc == 2)
+ if (CMD_ARGC == 2)
{
if (strcmp(args[1], "busy") == 0)
busy = true;
else
return ERROR_COMMAND_SYNTAX_ERROR;
}
- else if (argc < 1 || argc > 2)
+ else if (CMD_ARGC < 1 || CMD_ARGC > 2)
return ERROR_COMMAND_SYNTAX_ERROR;
unsigned long duration = 0;
COMMAND_HANDLER(handle_fast_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
fast_and_dangerous = strcmp("enable", args[0]) == 0;
COMMAND_HANDLER(handle_rm_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
{
command_print(cmd_ctx, "rm <filename>");
return ERROR_INVALID_ARGUMENTS;
COMMAND_HANDLER(handle_cat_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
{
command_print(cmd_ctx, "cat <filename>");
return ERROR_INVALID_ARGUMENTS;
COMMAND_HANDLER(handle_trunc_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
{
command_print(cmd_ctx, "trunc <filename>");
return ERROR_INVALID_ARGUMENTS;
static int prev = 0;
struct mallinfo info;
- if (argc != 0)
+ if (CMD_ARGC != 0)
{
command_print(cmd_ctx, "meminfo");
return ERROR_INVALID_ARGUMENTS;
COMMAND_HANDLER(handle_append_command)
{
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx,
"append <filename> [<string1>, [<string2>, ...]]");
fseek(config_file, 0, SEEK_END);
unsigned i;
- for (i = 1; i < argc; i++)
+ for (i = 1; i < CMD_ARGC; i++)
{
if (fwrite(args[i], 1, strlen(args[i]), config_file) != strlen(args[i]))
break;
- if (i != argc - 1)
+ if (i != CMD_ARGC - 1)
{
if (fwrite(" ", 1, 1, config_file) != 1)
break;
}
}
- if ((i == argc) && (fwrite("\n", 1, 1, config_file) == 1))
+ if ((i == CMD_ARGC) && (fwrite("\n", 1, 1, config_file) == 1))
{
retval = ERROR_OK;
}
COMMAND_HANDLER(handle_cp_command)
{
- if (argc != 2)
+ if (CMD_ARGC != 2)
{
return ERROR_INVALID_ARGUMENTS;
}
*/
COMMAND_HANDLER(handle_debug_level_command)
{
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
unsigned new_level;
COMMAND_PARSE_NUMBER(uint, args[0], new_level);
debug_level = MIN(new_level, LOG_LVL_DEBUG);
}
- else if (argc > 1)
+ else if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
if (debug_level >= LOG_LVL_DEBUG && server_use_pipes == 1)
COMMAND_HANDLER(handle_log_output_command)
{
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
FILE* file = fopen(args[0], "w");
COMMAND_HANDLER(amt_jtagaccel_handle_parport_port_command)
{
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
/* only if the port wasn't overwritten by cmdline */
if (amt_jtagaccel_port == 0)
COMMAND_HANDLER(amt_jtagaccel_handle_rtck_command)
{
- if (argc == 0)
+ if (CMD_ARGC == 0)
{
command_print(cmd_ctx, "amt_jtagaccel RTCK feature %s", (rtck_enabled) ? "enabled" : "disabled");
return ERROR_OK;
static int at91rm9200_handle_device_command(struct command_context *cmd_ctx, char *cmd, char **args, int argc)
{
- if (argc == 0)
+ if (CMD_ARGC == 0)
return ERROR_OK;
/* only if the device name wasn't overwritten by cmdline */
{
char *cp;
char buf[200];
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
ft2232_device_desc = strdup(args[0]);
cp = strchr(ft2232_device_desc, 0);
COMMAND_HANDLER(ft2232_handle_serial_command)
{
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
ft2232_serial = strdup(args[0]);
}
COMMAND_HANDLER(ft2232_handle_layout_command)
{
- if (argc == 0)
+ if (CMD_ARGC == 0)
return ERROR_OK;
ft2232_layout = malloc(strlen(args[0]) + 1);
COMMAND_HANDLER(ft2232_handle_vid_pid_command)
{
- if (argc > MAX_USB_IDS * 2)
+ if (CMD_ARGC > MAX_USB_IDS * 2)
{
LOG_WARNING("ignoring extra IDs in ft2232_vid_pid "
"(maximum is %d pairs)", MAX_USB_IDS);
- argc = MAX_USB_IDS * 2;
+ CMD_ARGC = MAX_USB_IDS * 2;
}
- if (argc < 2 || (argc & 1))
+ if (CMD_ARGC < 2 || (CMD_ARGC & 1))
{
LOG_WARNING("incomplete ft2232_vid_pid configuration directive");
- if (argc < 2)
+ if (CMD_ARGC < 2)
return ERROR_COMMAND_SYNTAX_ERROR;
/* remove the incomplete trailing id */
- argc -= 1;
+ CMD_ARGC -= 1;
}
unsigned i;
- for (i = 0; i < argc; i += 2)
+ for (i = 0; i < CMD_ARGC; i += 2)
{
COMMAND_PARSE_NUMBER(u16, args[i], ft2232_vid[i >> 1]);
COMMAND_PARSE_NUMBER(u16, args[i + 1], ft2232_pid[i >> 1]);
COMMAND_HANDLER(ft2232_handle_latency_command)
{
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
ft2232_latency = atoi(args[0]);
}
COMMAND_HANDLER(gw16012_handle_parport_port_command)
{
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
/* only if the port wasn't overwritten by cmdline */
if (gw16012_port == 0)
COMMAND_HANDLER(jlink_handle_jlink_hw_jtag_command)
{
- switch (argc) {
+ switch (CMD_ARGC) {
case 0:
command_print(cmd_ctx, "jlink hw jtag %i", jlink_hw_jtag_version);
break;
COMMAND_HANDLER(parport_handle_parport_port_command)
{
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
/* only if the port wasn't overwritten by cmdline */
if (parport_port == 0)
COMMAND_HANDLER(parport_handle_parport_cable_command)
{
- if (argc == 0)
+ if (CMD_ARGC == 0)
return ERROR_OK;
/* only if the cable name wasn't overwritten by cmdline */
COMMAND_HANDLER(parport_handle_write_on_exit_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
{
command_print(cmd_ctx, "usage: parport_write_on_exit <on | off>");
return ERROR_OK;
COMMAND_HANDLER(parport_handle_parport_toggling_time_command)
{
- if (argc == 1) {
+ if (CMD_ARGC == 1) {
uint32_t ns;
int retval = parse_u32(args[0], &ns);
COMMAND_HANDLER(presto_handle_serial_command)
{
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
if (presto_serial)
free(presto_serial);
COMMAND_HANDLER(handle_interface_list_command)
{
- if (strcmp(CMD_NAME, "interface_list") == 0 && argc > 0)
+ if (strcmp(CMD_NAME, "interface_list") == 0 && CMD_ARGC > 0)
return ERROR_COMMAND_SYNTAX_ERROR;
command_print(cmd_ctx, "The following JTAG interfaces are available:");
}
/* interface name is a mandatory argument */
- if (argc != 1 || args[0][0] == '\0')
+ if (CMD_ARGC != 1 || args[0][0] == '\0')
return ERROR_COMMAND_SYNTAX_ERROR;
for (unsigned i = 0; NULL != jtag_interfaces[i]; i++)
* Here we don't care about the order, and only change values
* which have been explicitly specified.
*/
- for (; argc; argc--, args++) {
+ for (; CMD_ARGC; CMD_ARGC--, args++) {
int tmp = 0;
int m;
COMMAND_HANDLER(handle_jtag_nsrst_delay_command)
{
- if (argc > 1)
+ if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
unsigned delay;
COMMAND_PARSE_NUMBER(uint, args[0], delay);
COMMAND_HANDLER(handle_jtag_ntrst_delay_command)
{
- if (argc > 1)
+ if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
unsigned delay;
COMMAND_PARSE_NUMBER(uint, args[0], delay);
COMMAND_HANDLER(handle_jtag_nsrst_assert_width_command)
{
- if (argc > 1)
+ if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
unsigned delay;
COMMAND_PARSE_NUMBER(uint, args[0], delay);
COMMAND_HANDLER(handle_jtag_ntrst_assert_width_command)
{
- if (argc > 1)
+ if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
unsigned delay;
COMMAND_PARSE_NUMBER(uint, args[0], delay);
COMMAND_HANDLER(handle_jtag_khz_command)
{
- if (argc > 1)
+ if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
int retval = ERROR_OK;
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
unsigned khz = 0;
COMMAND_PARSE_NUMBER(uint, args[0], khz);
COMMAND_HANDLER(handle_jtag_rclk_command)
{
- if (argc > 1)
+ if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
int retval = ERROR_OK;
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
unsigned khz = 0;
COMMAND_PARSE_NUMBER(uint, args[0], khz);
COMMAND_HANDLER(handle_jtag_reset_command)
{
- if (argc != 2)
+ if (CMD_ARGC != 2)
return ERROR_COMMAND_SYNTAX_ERROR;
int trst = -1;
COMMAND_HANDLER(handle_runtest_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
unsigned num_clocks;
struct jtag_tap *tap;
tap_state_t endstate;
- if ((argc < 2) || (argc % 2))
+ if ((CMD_ARGC < 2) || (CMD_ARGC % 2))
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
*/
endstate = TAP_IDLE;
- if (argc >= 4) {
+ if (CMD_ARGC >= 4) {
/* have at least one pair of numbers. */
/* is last pair the magic text? */
- if (strcmp("-endstate", args[argc - 2]) == 0) {
- endstate = tap_state_by_name(args[argc - 1]);
+ if (strcmp("-endstate", args[CMD_ARGC - 2]) == 0) {
+ endstate = tap_state_by_name(args[CMD_ARGC - 1]);
if (endstate == TAP_INVALID)
return ERROR_COMMAND_SYNTAX_ERROR;
if (!scan_is_safe(endstate))
LOG_WARNING("unstable irscan endstate \"%s\"",
- args[argc - 1]);
- argc -= 2;
+ args[CMD_ARGC - 1]);
+ CMD_ARGC -= 2;
}
}
- int num_fields = argc / 2;
+ int num_fields = CMD_ARGC / 2;
size_t fields_len = sizeof(struct scan_field) * num_fields;
fields = malloc(fields_len);
memset(fields, 0, fields_len);
COMMAND_HANDLER(handle_verify_ircapture_command)
{
- if (argc > 1)
+ if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
if (strcmp(args[0], "enable") == 0)
jtag_set_verify_capture_ir(true);
COMMAND_HANDLER(handle_verify_jtag_command)
{
- if (argc > 1)
+ if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
if (strcmp(args[0], "enable") == 0)
jtag_set_verify(true);
COMMAND_HANDLER(handle_tms_sequence_command)
{
- if (argc > 1)
+ if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
bool use_new_table;
if (strcmp(args[0], "short") == 0)
COMMAND_HANDLER(vsllink_handle_mode_command)
{
- if (argc != 1) {
+ if (CMD_ARGC != 1) {
LOG_ERROR("parameter error, should be one parameter for VID");
return ERROR_FAIL;
}
COMMAND_HANDLER(vsllink_handle_usb_vid_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
{
LOG_ERROR("parameter error, should be one parameter for VID");
return ERROR_OK;
COMMAND_HANDLER(vsllink_handle_usb_pid_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
{
LOG_ERROR("parameter error, should be one parameter for PID");
return ERROR_OK;
COMMAND_HANDLER(vsllink_handle_usb_bulkin_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
{
LOG_ERROR("parameter error, should be one parameter for BULKIN endpoint");
return ERROR_OK;
COMMAND_HANDLER(vsllink_handle_usb_bulkout_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
{
LOG_ERROR("parameter error, should be one parameter for BULKOUT endpoint");
return ERROR_OK;
COMMAND_HANDLER(vsllink_handle_usb_interface_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
{
LOG_ERROR("parameter error, should be one parameter for interface number");
return ERROR_OK;
/* Give TELNET a way to find out what version this is */
COMMAND_HANDLER(handle_version_command)
{
- if (argc != 0)
+ if (CMD_ARGC != 0)
return ERROR_COMMAND_SYNTAX_ERROR;
command_print(cmd_ctx, OPENOCD_VERSION);
COMMAND_HANDLER(handle_init_command)
{
- if (argc != 0)
+ if (CMD_ARGC != 0)
return ERROR_COMMAND_SYNTAX_ERROR;
int retval;
int i;
int found = 0;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
LOG_WARNING("incomplete 'pld device' command");
return ERROR_OK;
gettimeofday(&start, NULL);
- if (argc < 2)
+ if (CMD_ARGC < 2)
{
command_print(cmd_ctx, "usage: pld load <device#> <file>");
return ERROR_OK;
struct virtex2_pld_device *virtex2_info;
uint32_t status;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "usage: virtex2 read_stat <num>");
return ERROR_OK;
struct virtex2_pld_device *virtex2_info;
- if (argc < 2)
+ if (CMD_ARGC < 2)
{
LOG_WARNING("incomplete pld device 'virtex2' configuration");
return ERROR_PLD_DEVICE_INVALID;
COMMAND_HANDLER(handle_gdb_sync_command)
{
- if (argc != 0)
+ if (CMD_ARGC != 0)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
COMMAND_HANDLER(handle_gdb_memory_map_command)
{
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
if (strcmp(args[0], "enable") == 0)
{
COMMAND_HANDLER(handle_gdb_flash_program_command)
{
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
if (strcmp(args[0], "enable") == 0)
{
COMMAND_HANDLER(handle_gdb_report_data_abort_command)
{
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
if (strcmp(args[0], "enable") == 0)
{
/* gdb_breakpoint_override */
COMMAND_HANDLER(handle_gdb_breakpoint_override_command)
{
- if (argc == 0)
+ if (CMD_ARGC == 0)
{
- } else if (argc == 1)
+ } else if (CMD_ARGC == 1)
{
gdb_breakpoint_override = 1;
if (strcmp(args[0], "hard") == 0)
SERVER_PORT_COMMAND()
{
- switch (argc) {
+ switch (CMD_ARGC) {
case 0:
command_print(cmd_ctx, "%d", *out);
break;
int ret = ERROR_OK;
long long time_ago;
- if ((argc < 1) || (argc > (1 + SVF_NUM_OF_OPTIONS)))
+ if ((CMD_ARGC < 1) || (CMD_ARGC > (1 + SVF_NUM_OF_OPTIONS)))
{
command_print(cmd_ctx, "usage: svf <file> [quiet]");
return ERROR_FAIL;
// parse variant
svf_quiet = 0;
- for (unsigned i = 1; i < argc; i++)
+ for (unsigned i = 1; i < CMD_ARGC; i++)
{
if (!strcmp(args[i], "quiet"))
{
static COMMAND_HELPER(arm11_handle_bool, bool *var, char *name)
{
- if (argc == 0)
+ if (CMD_ARGC == 0)
{
LOG_INFO("%s is %s.", name, *var ? "enabled" : "disabled");
return ERROR_OK;
}
- if (argc != 1)
+ if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
switch (args[0][0])
COMMAND_HANDLER(arm11_handle_vcr)
{
- switch (argc) {
+ switch (CMD_ARGC) {
case 0:
break;
case 1:
}
/* one or more argument, access a single register (write if second argument is given */
- if (argc >= 1)
+ if (CMD_ARGC >= 1)
{
uint32_t opcode;
COMMAND_PARSE_NUMBER(u32, args[0], opcode);
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
uint32_t value;
if ((retval = arm720t_read_cp15(target, opcode, &value)) != ERROR_OK)
command_print(cmd_ctx, "0x%8.8" PRIx32 ": 0x%8.8" PRIx32 "", opcode, value);
}
- else if (argc == 2)
+ else if (CMD_ARGC == 2)
{
uint32_t value;
COMMAND_PARSE_NUMBER(u32, args[1], value);
return ERROR_FAIL;
}
- if (argc < 2)
+ if (CMD_ARGC < 2)
{
command_print(cmd_ctx, "usage: write_xpsr <value> <not cpsr | spsr>");
return ERROR_FAIL;
return ERROR_FAIL;
}
- if (argc < 3)
+ if (CMD_ARGC < 3)
{
command_print(cmd_ctx, "usage: write_xpsr_im8 <im8> <rotate> <not cpsr | spsr>");
return ERROR_FAIL;
return ERROR_FAIL;
}
- if (argc < 3)
+ if (CMD_ARGC < 3)
{
command_print(cmd_ctx, "usage: write_core_reg <num> <mode> <value>");
return ERROR_FAIL;
return ERROR_TARGET_INVALID;
}
- if (argc > 0)
+ if (CMD_ARGC > 0)
{
if (strcmp("enable", args[0]) == 0)
{
return ERROR_TARGET_INVALID;
}
- if (argc > 0)
+ if (CMD_ARGC > 0)
{
if (strcmp("enable", args[0]) == 0)
{
return ERROR_TARGET_INVALID;
}
- if (argc > 0)
+ if (CMD_ARGC > 0)
{
if (strcmp("enable", args[0]) == 0)
{
if (retval != ERROR_OK)
return retval;
- if (argc != 1)
+ if (CMD_ARGC != 1)
{
command_print(cmd_ctx, "usage: arm920t read_cache <filename>");
return ERROR_OK;
if (retval != ERROR_OK)
return retval;
- if (argc != 1)
+ if (CMD_ARGC != 1)
{
command_print(cmd_ctx, "usage: arm920t read_mmu <filename>");
return ERROR_OK;
}
/* one or more argument, access a single register (write if second argument is given */
- if (argc >= 1)
+ if (CMD_ARGC >= 1)
{
int address;
COMMAND_PARSE_NUMBER(int, args[0], address);
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
uint32_t value;
if ((retval = arm920t_read_cp15_physical(target, address, &value)) != ERROR_OK)
command_print(cmd_ctx, "%i: %8.8" PRIx32 "", address, value);
}
- else if (argc == 2)
+ else if (CMD_ARGC == 2)
{
uint32_t value;
COMMAND_PARSE_NUMBER(u32, args[1], value);
}
/* one or more argument, access a single register (write if second argument is given */
- if (argc >= 1)
+ if (CMD_ARGC >= 1)
{
uint32_t opcode;
COMMAND_PARSE_NUMBER(u32, args[0], opcode);
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
uint32_t value;
if ((retval = arm920t_read_cp15_interpreted(target, opcode, 0x0, &value)) != ERROR_OK)
command_print(cmd_ctx, "%8.8" PRIx32 ": %8.8" PRIx32 "", opcode, value);
}
- else if (argc == 2)
+ else if (CMD_ARGC == 2)
{
uint32_t value;
COMMAND_PARSE_NUMBER(u32, args[1], value);
}
command_print(cmd_ctx, "%8.8" PRIx32 ": %8.8" PRIx32 "", opcode, value);
}
- else if (argc == 3)
+ else if (CMD_ARGC == 3)
{
uint32_t value;
COMMAND_PARSE_NUMBER(u32, args[1], value);
int CRn;
int CRm;
- if ((argc < 4) || (argc > 5))
+ if ((CMD_ARGC < 4) || (CMD_ARGC > 5))
{
command_print(cmd_ctx, "usage: arm926ejs cp15 <opcode_1> <opcode_2> <CRn> <CRm> [value]");
return ERROR_OK;
return ERROR_OK;
}
- if (argc == 4)
+ if (CMD_ARGC == 4)
{
uint32_t value;
if ((retval = arm926ejs->read_cp15(target, opcode_1, opcode_2, CRn, CRm, &value)) != ERROR_OK)
}
/* one or more argument, access a single register (write if second argument is given */
- if (argc >= 1)
+ if (CMD_ARGC >= 1)
{
uint32_t address;
COMMAND_PARSE_NUMBER(u32, args[0], address);
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
uint32_t value;
if ((retval = arm966e_read_cp15(target, address, &value)) != ERROR_OK)
command_print(cmd_ctx, "%" PRIi32 ": %8.8" PRIx32,
address, value);
}
- else if (argc == 2)
+ else if (CMD_ARGC == 2)
{
uint32_t value;
COMMAND_PARSE_NUMBER(u32, args[1], value);
/* get the current setting */
vector_catch_value = buf_get_u32(vector_catch->value, 0, 8);
- if (argc > 0)
+ if (CMD_ARGC > 0)
{
vector_catch_value = 0x0;
if (strcmp(args[0], "all") == 0)
}
else
{
- for (unsigned i = 0; i < argc; i++)
+ for (unsigned i = 0; i < CMD_ARGC; i++)
{
/* go through list of vectors */
unsigned j;
int retval;
apselsave = swjdp->apsel;
- switch (argc) {
+ switch (CMD_ARGC) {
case 0:
apsel = swjdp->apsel;
break;
{
uint32_t memaccess_tck;
- switch (argc) {
+ switch (CMD_ARGC) {
case 0:
memaccess_tck = swjdp->memaccess_tck;
break;
uint32_t apsel, apid;
int retval;
- switch (argc) {
+ switch (CMD_ARGC) {
case 0:
apsel = 0;
break;
int retval;
apselsave = swjdp->apsel;
- switch (argc) {
+ switch (CMD_ARGC) {
case 0:
apsel = swjdp->apsel;
break;
return ERROR_FAIL;
}
- if (argc > 0)
+ if (CMD_ARGC > 0)
{
if (strcmp(args[0], "arm") == 0)
{
return ERROR_FAIL;
}
- switch (argc) {
+ switch (CMD_ARGC) {
case 3:
if (strcmp(args[2], "thumb") != 0)
goto usage;
struct swjdp_common *swjdp = &armv7a->swjdp_info;
uint32_t apsel;
- switch (argc) {
+ switch (CMD_ARGC) {
case 0:
apsel = swjdp->apsel;
break;
int retval;
apselsave = swjdp->apsel;
- switch (argc) {
+ switch (CMD_ARGC) {
case 0:
apsel = swjdp->apsel;
break;
struct swjdp_common *swjdp = &armv7m->swjdp_info;
uint32_t apsel;
- switch (argc) {
+ switch (CMD_ARGC) {
case 0:
apsel = swjdp->apsel;
break;
return retval;
errno = 0;
- switch (argc) {
+ switch (CMD_ARGC) {
case 2:
COMMAND_PARSE_NUMBER(ulong, args[1], count);
/* FALL THROUGH */
mem_ap_read_atomic_u32(swjdp, DCB_DEMCR, &demcr);
- if (argc > 0) {
+ if (CMD_ARGC > 0) {
unsigned catch = 0;
- if (argc == 1) {
+ if (CMD_ARGC == 1) {
if (strcmp(args[0], "all") == 0) {
catch = VC_HARDERR | VC_INTERR | VC_BUSERR
| VC_STATERR | VC_CHKERR | VC_NOCPERR
goto write;
}
}
- while (argc-- > 0) {
+ while (CMD_ARGC-- > 0) {
unsigned i;
for (i = 0; i < ARRAY_SIZE(vec_ids); i++) {
- if (strcmp(args[argc], vec_ids[i].name) != 0)
+ if (strcmp(args[CMD_ARGC], vec_ids[i].name) != 0)
continue;
catch |= vec_ids[i].mask;
break;
}
if (i == ARRAY_SIZE(vec_ids)) {
- LOG_ERROR("No CM3 vector '%s'", args[argc]);
+ LOG_ERROR("No CM3 vector '%s'", args[CMD_ARGC]);
return ERROR_INVALID_ARGUMENTS;
}
}
return ERROR_OK;
}
- if (argc > 0)
+ if (CMD_ARGC > 0)
{
if (!strcmp(args[0], "on"))
{
struct jtag_tap *tap;
struct arm *arm;
- if (argc != 2)
+ if (CMD_ARGC != 2)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
etmv1_tracemode_t tracemode = etm->tracemode;
- switch (argc)
+ switch (CMD_ARGC)
{
case 0:
break;
struct etm_context *etm_ctx;
int i;
- if (argc != 5)
+ if (CMD_ARGC != 5)
return ERROR_COMMAND_SYNTAX_ERROR;
target = get_target(args[0]);
struct arm *arm;
struct etm_context *etm_ctx;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "usage: etm image <file> [base address] [type]");
return ERROR_FAIL;
etm_ctx->image->start_address_set = 0;
/* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */
- if (argc >= 2)
+ if (CMD_ARGC >= 2)
{
etm_ctx->image->base_address_set = 1;
COMMAND_PARSE_NUMBER(int, args[1], etm_ctx->image->base_address);
etm_ctx->image->base_address_set = 0;
}
- if (image_open(etm_ctx->image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK)
+ if (image_open(etm_ctx->image, args[0], (CMD_ARGC >= 3) ? args[2] : NULL) != ERROR_OK)
{
free(etm_ctx->image);
etm_ctx->image = NULL;
struct etm_context *etm_ctx;
uint32_t i;
- if (argc != 1)
+ if (CMD_ARGC != 1)
{
command_print(cmd_ctx, "usage: etm dump <file>");
return ERROR_FAIL;
struct etm_context *etm_ctx;
uint32_t i;
- if (argc != 1)
+ if (CMD_ARGC != 1)
{
command_print(cmd_ctx, "usage: etm load <file>");
return ERROR_FAIL;
return ERROR_FAIL;
}
- if (argc > 0)
+ if (CMD_ARGC > 0)
{
uint32_t new_value;
COMMAND_PARSE_NUMBER(u32, args[0], new_value);
struct target *target;
struct arm *arm;
- if (argc != 2)
+ if (CMD_ARGC != 2)
{
LOG_ERROR("incomplete 'oocd_trace config <target> <tty>' command");
return ERROR_FAIL;
{
struct target *target = all_targets;
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
target = get_target(args[0]);
if (target == NULL) {
target = get_current_target(cmd_ctx);
/* list all available registers for the current target */
- if (argc == 0)
+ if (CMD_ARGC == 0)
{
struct reg_cache *cache = target->reg_cache;
}
/* display a register */
- if ((argc == 1) || ((argc == 2) && !((args[1][0] >= '0') && (args[1][0] <= '9'))))
+ if ((CMD_ARGC == 1) || ((CMD_ARGC == 2) && !((args[1][0] >= '0') && (args[1][0] <= '9'))))
{
- if ((argc == 2) && (strcmp(args[1], "force") == 0))
+ if ((CMD_ARGC == 2) && (strcmp(args[1], "force") == 0))
reg->valid = 0;
if (reg->valid == 0)
}
/* set register value */
- if (argc == 2)
+ if (CMD_ARGC == 2)
{
uint8_t *buf = malloc(DIV_ROUND_UP(reg->size, 8));
str_to_buf(args[1], strlen(args[1]), buf, reg->size, 0);
int retval = ERROR_OK;
struct target *target = get_current_target(cmd_ctx);
- if (argc == 0)
+ if (CMD_ARGC == 0)
{
command_print(cmd_ctx, "background polling: %s",
jtag_poll_get_enabled() ? "on" : "off");
return retval;
}
- else if (argc == 1)
+ else if (CMD_ARGC == 1)
{
if (strcmp(args[0], "on") == 0)
{
COMMAND_HANDLER(handle_wait_halt_command)
{
- if (argc > 1)
+ if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
unsigned ms = 5000;
- if (1 == argc)
+ if (1 == CMD_ARGC)
{
int retval = parse_uint(args[0], &ms);
if (ERROR_OK != retval)
if (ERROR_OK != retval)
return retval;
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
unsigned wait;
retval = parse_uint(args[0], &wait);
COMMAND_HANDLER(handle_reset_command)
{
- if (argc > 1)
+ if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
enum target_reset_mode reset_mode = RESET_RUN;
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
const Jim_Nvp *n;
n = Jim_Nvp_name2value_simple(nvp_reset_modes, args[0]);
COMMAND_HANDLER(handle_resume_command)
{
int current = 1;
- if (argc > 1)
+ if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
struct target *target = get_current_target(cmd_ctx);
* with one arguments, addr = args[0],
* handle breakpoints, not debugging */
uint32_t addr = 0;
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
COMMAND_PARSE_NUMBER(u32, args[0], addr);
current = 0;
COMMAND_HANDLER(handle_step_command)
{
- if (argc > 1)
+ if (CMD_ARGC > 1)
return ERROR_COMMAND_SYNTAX_ERROR;
LOG_DEBUG("-");
* handle breakpoints, debugging */
uint32_t addr = 0;
int current_pc = 1;
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
COMMAND_PARSE_NUMBER(u32, args[0], addr);
current_pc = 0;
COMMAND_HANDLER(handle_md_command)
{
- if (argc < 1)
+ if (CMD_ARGC < 1)
return ERROR_COMMAND_SYNTAX_ERROR;
unsigned size = 0;
uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer);
if (physical)
{
- argc--;
+ CMD_ARGC--;
args++;
fn=target_read_phys_memory;
} else
{
fn=target_read_memory;
}
- if ((argc < 1) || (argc > 2))
+ if ((CMD_ARGC < 1) || (CMD_ARGC > 2))
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
COMMAND_PARSE_NUMBER(u32, args[0], address);
unsigned count = 1;
- if (argc == 2)
+ if (CMD_ARGC == 2)
COMMAND_PARSE_NUMBER(uint, args[1], count);
uint8_t *buffer = calloc(count, size);
COMMAND_HANDLER(handle_mw_command)
{
- if (argc < 2)
+ if (CMD_ARGC < 2)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
const char *cmd_name = CMD_NAME;
if (physical)
{
- argc--;
+ CMD_ARGC--;
args++;
fn=target_write_phys_memory;
} else
{
fn=target_write_memory;
}
- if ((argc < 2) || (argc > 3))
+ if ((CMD_ARGC < 2) || (CMD_ARGC > 3))
return ERROR_COMMAND_SYNTAX_ERROR;
uint32_t address;
COMMAND_PARSE_NUMBER(u32, args[1], value);
unsigned count = 1;
- if (argc == 3)
+ if (CMD_ARGC == 3)
COMMAND_PARSE_NUMBER(uint, args[2], count);
struct target *target = get_current_target(cmd_ctx);
static COMMAND_HELPER(parse_load_image_command_args, struct image *image,
uint32_t *min_address, uint32_t *max_address)
{
- if (argc < 1 || argc > 5)
+ if (CMD_ARGC < 1 || CMD_ARGC > 5)
return ERROR_COMMAND_SYNTAX_ERROR;
/* a base address isn't always necessary,
* default to 0x0 (i.e. don't relocate) */
- if (argc >= 2)
+ if (CMD_ARGC >= 2)
{
uint32_t addr;
COMMAND_PARSE_NUMBER(u32, args[1], addr);
image->start_address_set = 0;
- if (argc >= 4)
+ if (CMD_ARGC >= 4)
{
COMMAND_PARSE_NUMBER(u32, args[3], *min_address);
}
- if (argc == 5)
+ if (CMD_ARGC == 5)
{
COMMAND_PARSE_NUMBER(u32, args[4], *max_address);
// use size (given) to find max (required)
struct duration bench;
duration_start(&bench);
- if (image_open(&image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK)
+ if (image_open(&image, args[0], (CMD_ARGC >= 3) ? args[2] : NULL) != ERROR_OK)
{
return ERROR_OK;
}
struct target *target = get_current_target(cmd_ctx);
- if (argc != 3)
+ if (CMD_ARGC != 3)
{
command_print(cmd_ctx, "usage: dump_image <filename> <address> <size>");
return ERROR_OK;
struct target *target = get_current_target(cmd_ctx);
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
struct duration bench;
duration_start(&bench);
- if (argc >= 2)
+ if (CMD_ARGC >= 2)
{
uint32_t addr;
COMMAND_PARSE_NUMBER(u32, args[1], addr);
image.start_address_set = 0;
- if ((retval = image_open(&image, args[0], (argc == 3) ? args[2] : NULL)) != ERROR_OK)
+ if ((retval = image_open(&image, args[0], (CMD_ARGC == 3) ? args[2] : NULL)) != ERROR_OK)
{
return retval;
}
COMMAND_HANDLER(handle_bp_command)
{
- if (argc == 0)
+ if (CMD_ARGC == 0)
return handle_bp_command_list(cmd_ctx);
- if (argc < 2 || argc > 3)
+ if (CMD_ARGC < 2 || CMD_ARGC > 3)
{
command_print(cmd_ctx, "usage: bp <address> <length> ['hw']");
return ERROR_COMMAND_SYNTAX_ERROR;
COMMAND_PARSE_NUMBER(u32, args[1], length);
int hw = BKPT_SOFT;
- if (argc == 3)
+ if (CMD_ARGC == 3)
{
if (strcmp(args[2], "hw") == 0)
hw = BKPT_HARD;
COMMAND_HANDLER(handle_rbp_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
uint32_t addr;
{
struct target *target = get_current_target(cmd_ctx);
- if (argc == 0)
+ if (CMD_ARGC == 0)
{
struct watchpoint *watchpoint = target->watchpoints;
uint32_t data_value = 0x0;
uint32_t data_mask = 0xffffffff;
- switch (argc)
+ switch (CMD_ARGC)
{
case 5:
COMMAND_PARSE_NUMBER(u32, args[4], data_mask);
COMMAND_HANDLER(handle_rwp_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
uint32_t addr;
*/
COMMAND_HANDLER(handle_virt2phys_command)
{
- if (argc != 1)
+ if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;
uint32_t va;
struct timeval timeout, now;
gettimeofday(&timeout, NULL);
- if (argc != 2)
+ if (CMD_ARGC != 2)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
struct duration bench;
duration_start(&bench);
- if (image_open(&image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK)
+ if (image_open(&image, args[0], (CMD_ARGC >= 3) ? args[2] : NULL) != ERROR_OK)
{
return ERROR_OK;
}
COMMAND_HANDLER(handle_fast_load_command)
{
- if (argc > 0)
+ if (CMD_ARGC > 0)
return ERROR_COMMAND_SYNTAX_ERROR;
if (fastload == NULL)
{
if (find_debug_msg_receiver(cmd_ctx, target) != NULL)
receiving = 1;
- if (argc > 0)
+ if (CMD_ARGC > 0)
{
if (!strcmp(args[0], "enable") || !strcmp(args[0], "charmsg"))
{
struct target *target = get_current_target(cmd_ctx);
struct trace *trace = target->trace_info;
- if (argc == 0)
+ if (CMD_ARGC == 0)
{
uint32_t i;
struct target *target = get_current_target(cmd_ctx);
struct trace *trace = target->trace_info;
- if (argc > 0)
+ if (CMD_ARGC > 0)
{
trace->trace_history_pos = 0;
trace->trace_history_overflowed = 0;
int retval;
uint32_t handler_address;
- if (argc < 2)
+ if (CMD_ARGC < 2)
{
LOG_ERROR("'xscale debug_handler <target#> <address>' command takes two required operands");
return ERROR_OK;
int retval;
uint32_t cache_clean_address;
- if (argc < 2)
+ if (CMD_ARGC < 2)
{
return ERROR_COMMAND_SYNTAX_ERROR;
}
return ERROR_OK;
}
- if (argc >= 1)
+ if (CMD_ARGC >= 1)
{
if (strcmp("enable", args[0]) == 0)
{
else if (strcmp(CMD_NAME, "dcache") == 0)
dcache = 1;
- if (argc >= 1)
+ if (CMD_ARGC >= 1)
{
if (strcmp("enable", args[0]) == 0)
{
if (retval != ERROR_OK)
return retval;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "usage: xscale vector_catch [mask]");
}
if (retval != ERROR_OK)
return retval;
- if (argc == 0) /* print current settings */
+ if (CMD_ARGC == 0) /* print current settings */
{
int idx;
return ERROR_OK;
}
- if (argc != 3)
+ if (CMD_ARGC != 3)
err = 1;
else
{
return ERROR_OK;
}
- if ((argc >= 1) && (strcmp("enable", args[0]) == 0))
+ if ((CMD_ARGC >= 1) && (strcmp("enable", args[0]) == 0))
{
struct xscale_trace_data *td, *next_td;
xscale->trace.buffer_enabled = 1;
}
xscale->trace.data = NULL;
}
- else if ((argc >= 1) && (strcmp("disable", args[0]) == 0))
+ else if ((CMD_ARGC >= 1) && (strcmp("disable", args[0]) == 0))
{
xscale->trace.buffer_enabled = 0;
}
- if ((argc >= 2) && (strcmp("fill", args[1]) == 0))
+ if ((CMD_ARGC >= 2) && (strcmp("fill", args[1]) == 0))
{
uint32_t fill = 1;
- if (argc >= 3)
+ if (CMD_ARGC >= 3)
COMMAND_PARSE_NUMBER(u32, args[2], fill);
xscale->trace.buffer_fill = fill;
}
- else if ((argc >= 2) && (strcmp("wrap", args[1]) == 0))
+ else if ((CMD_ARGC >= 2) && (strcmp("wrap", args[1]) == 0))
{
xscale->trace.buffer_fill = -1;
}
struct xscale_common *xscale = target_to_xscale(target);
int retval;
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "usage: xscale trace_image <file> [base address] [type]");
return ERROR_OK;
xscale->trace.image->start_address_set = 0;
/* a base address isn't always necessary, default to 0x0 (i.e. don't relocate) */
- if (argc >= 2)
+ if (CMD_ARGC >= 2)
{
xscale->trace.image->base_address_set = 1;
COMMAND_PARSE_NUMBER(int, args[1], xscale->trace.image->base_address);
xscale->trace.image->base_address_set = 0;
}
- if (image_open(xscale->trace.image, args[0], (argc >= 3) ? args[2] : NULL) != ERROR_OK)
+ if (image_open(xscale->trace.image, args[0], (CMD_ARGC >= 3) ? args[2] : NULL) != ERROR_OK)
{
free(xscale->trace.image);
xscale->trace.image = NULL;
return ERROR_OK;
}
- if (argc < 1)
+ if (CMD_ARGC < 1)
{
command_print(cmd_ctx, "usage: xscale dump_trace <file>");
return ERROR_OK;
}
uint32_t reg_no = 0;
struct reg *reg = NULL;
- if (argc > 0)
+ if (CMD_ARGC > 0)
{
COMMAND_PARSE_NUMBER(u32, args[0], reg_no);
/*translate from xscale cp15 register no to openocd register*/
reg = &xscale->reg_cache->reg_list[reg_no];
}
- if (argc == 1)
+ if (CMD_ARGC == 1)
{
uint32_t value;
value = buf_get_u32(reg->value, 0, 32);
command_print(cmd_ctx, "%s (/%i): 0x%" PRIx32 "", reg->name, (int)(reg->size), value);
}
- else if (argc == 2)
+ else if (CMD_ARGC == 2)
{
uint32_t value;
COMMAND_PARSE_NUMBER(u32, args[1], value);
*/
struct jtag_tap *tap = NULL;
- if (argc < 2)
+ if (CMD_ARGC < 2)
{
command_print(cmd_ctx, "usage: xsvf <device#|plain> <file> [<variant>] [quiet]");
return ERROR_FAIL;
}
/* if this argument is present, then interpret xruntest counts as TCK cycles rather than as usecs */
- if ((argc > 2) && (strcmp(args[2], "virt2") == 0))
+ if ((CMD_ARGC > 2) && (strcmp(args[2], "virt2") == 0))
{
runtest_requires_tck = 1;
- --argc;
+ --CMD_ARGC;
++args;
}
- if ((argc > 2) && (strcmp(args[2], "quiet") == 0))
+ if ((CMD_ARGC > 2) && (strcmp(args[2], "quiet") == 0))
{
verbose = 0;
}