From: Zachary T Welch Date: Sun, 15 Nov 2009 16:15:59 +0000 (-0800) Subject: command_handler: change 'args' to CMD_ARGV X-Git-Tag: v0.4.0-rc1~529 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=23402315ce01071f30d7ec0c5ca7563ce41f1cc6;p=openocd command_handler: change 'args' to CMD_ARGV This patch converts all instances of 'args' in COMMAND_HANDLER routines to use CMD_ARGV macro. --- diff --git a/src/flash/at91sam3.c b/src/flash/at91sam3.c index 54e60bff..4cf4d209 100644 --- a/src/flash/at91sam3.c +++ b/src/flash/at91sam3.c @@ -2378,17 +2378,17 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command) who = -1; break; case 2: - if ((0 == strcmp(args[0], "show")) && (0 == strcmp(args[1], "all"))) { + if ((0 == strcmp(CMD_ARGV[0], "show")) && (0 == strcmp(CMD_ARGV[1], "all"))) { who = -1; } else { uint32_t v32; - COMMAND_PARSE_NUMBER(u32, args[1], v32); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], v32); who = v32; } break; } - if (0 == strcmp("show", args[0])) { + if (0 == strcmp("show", CMD_ARGV[0])) { if (who == -1) { showall: r = ERROR_OK; @@ -2416,13 +2416,13 @@ COMMAND_HANDLER(sam3_handle_gpnvm_command) return ERROR_COMMAND_SYNTAX_ERROR; } - if (0 == strcmp("set", args[0])) { + if (0 == strcmp("set", CMD_ARGV[0])) { r = FLASHD_SetGPNVM(&(pChip->details.bank[0]), who); - } else if ((0 == strcmp("clr", args[0])) || - (0 == strcmp("clear", args[0]))) { // quietly accept both + } else if ((0 == strcmp("clr", CMD_ARGV[0])) || + (0 == strcmp("clear", CMD_ARGV[0]))) { // quietly accept both r = FLASHD_ClrGPNVM(&(pChip->details.bank[0]), who); } else { - command_print(cmd_ctx, "Unkown command: %s", args[0]); + command_print(cmd_ctx, "Unkown command: %s", CMD_ARGV[0]); r = ERROR_COMMAND_SYNTAX_ERROR; } return r; @@ -2446,7 +2446,7 @@ COMMAND_HANDLER(sam3_handle_slowclk_command) { // set uint32_t v; - COMMAND_PARSE_NUMBER(u32, args[0], v); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], v); if (v > 200000) { // absurd slow clock of 200Khz? command_print(cmd_ctx,"Absurd/illegal slow clock freq: %d\n", (int)(v)); diff --git a/src/flash/at91sam7.c b/src/flash/at91sam7.c index 193bfd35..d23d2b02 100644 --- a/src/flash/at91sam7.c +++ b/src/flash/at91sam7.c @@ -749,20 +749,20 @@ FLASH_BANK_COMMAND_HANDLER(at91sam7_flash_bank_command) return ERROR_OK; } - COMMAND_PARSE_NUMBER(u32, args[1], base_address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], base_address); - COMMAND_PARSE_NUMBER(int, args[3], chip_width); - COMMAND_PARSE_NUMBER(int, args[4], bus_width); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[3], chip_width); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[4], bus_width); - COMMAND_PARSE_NUMBER(int, args[8], banks_num); - COMMAND_PARSE_NUMBER(int, args[9], num_sectors); - COMMAND_PARSE_NUMBER(u16, args[10], pages_per_sector); - COMMAND_PARSE_NUMBER(u16, args[11], page_size); - COMMAND_PARSE_NUMBER(u16, args[12], num_nvmbits); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[8], banks_num); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[9], num_sectors); + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[10], pages_per_sector); + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[11], page_size); + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[12], num_nvmbits); if (CMD_ARGC == 14) { unsigned long freq; - COMMAND_PARSE_NUMBER(ulong, args[13], freq); + COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[13], freq); ext_freq = freq * 1000; at91sam7_info->ext_freq = ext_freq; } @@ -774,8 +774,8 @@ FLASH_BANK_COMMAND_HANDLER(at91sam7_flash_bank_command) return ERROR_OK; } - target_name = calloc(strlen(args[7]) + 1, sizeof(char)); - strcpy(target_name, args[7]); + target_name = calloc(strlen(CMD_ARGV[7]) + 1, sizeof(char)); + strcpy(target_name, CMD_ARGV[7]); /* calculate bank size */ bank_size = num_sectors * pages_per_sector * page_size; @@ -1120,7 +1120,7 @@ COMMAND_HANDLER(at91sam7_handle_gpnvm_command) } if (strcmp(bank->driver->name, "at91sam7")) { - command_print(cmd_ctx, "not an at91sam7 flash bank '%s'", args[0]); + command_print(cmd_ctx, "not an at91sam7 flash bank '%s'", CMD_ARGV[0]); return ERROR_FLASH_BANK_INVALID; } if (bank->target->state != TARGET_HALTED) @@ -1129,11 +1129,11 @@ COMMAND_HANDLER(at91sam7_handle_gpnvm_command) return ERROR_TARGET_NOT_HALTED; } - if (strcmp(args[1], "set") == 0) + if (strcmp(CMD_ARGV[1], "set") == 0) { flashcmd = SGPB; } - else if (strcmp(args[1], "clear") == 0) + else if (strcmp(CMD_ARGV[1], "clear") == 0) { flashcmd = CGPB; } @@ -1152,10 +1152,10 @@ COMMAND_HANDLER(at91sam7_handle_gpnvm_command) } } - COMMAND_PARSE_NUMBER(int, args[0], bit); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], bit); if ((bit < 0) || (bit >= at91sam7_info->num_nvmbits)) { - command_print(cmd_ctx, "gpnvm bit '#%s' is out of bounds for target %s", args[0], at91sam7_info->target_name); + command_print(cmd_ctx, "gpnvm bit '#%s' is out of bounds for target %s", CMD_ARGV[0], at91sam7_info->target_name); return ERROR_OK; } diff --git a/src/flash/cfi.c b/src/flash/cfi.c index c68fb738..59c9c6c9 100644 --- a/src/flash/cfi.c +++ b/src/flash/cfi.c @@ -613,8 +613,8 @@ FLASH_BANK_COMMAND_HANDLER(cfi_flash_bank_command) } uint16_t chip_width, bus_width; - COMMAND_PARSE_NUMBER(u16, args[3], bus_width); - COMMAND_PARSE_NUMBER(u16, args[4], chip_width); + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[3], bus_width); + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[4], chip_width); if ((chip_width > CFI_MAX_CHIP_WIDTH) || (bus_width > CFI_MAX_BUS_WIDTH)) @@ -635,11 +635,11 @@ FLASH_BANK_COMMAND_HANDLER(cfi_flash_bank_command) for (unsigned i = 6; i < CMD_ARGC; i++) { - if (strcmp(args[i], "x16_as_x8") == 0) + if (strcmp(CMD_ARGV[i], "x16_as_x8") == 0) { cfi_info->x16_as_x8 = 1; } - else if (strcmp(args[i], "jedec_probe") == 0) + else if (strcmp(CMD_ARGV[i], "jedec_probe") == 0) { cfi_info->jedec_probe = 1; } diff --git a/src/flash/davinci_nand.c b/src/flash/davinci_nand.c index 7c68be70..ebd9ba8d 100644 --- a/src/flash/davinci_nand.c +++ b/src/flash/davinci_nand.c @@ -648,36 +648,36 @@ NAND_DEVICE_COMMAND_HANDLER(davinci_nand_device_command) if (CMD_ARGC < 5) { LOG_ERROR("parameters: %s target " "chip_addr hwecc_mode aemif_addr", - args[0]); + CMD_ARGV[0]); goto fail; } - target = get_target(args[1]); + target = get_target(CMD_ARGV[1]); if (!target) { - LOG_ERROR("invalid target %s", args[1]); + LOG_ERROR("invalid target %s", CMD_ARGV[1]); goto fail; } - COMMAND_PARSE_NUMBER(ulong, args[2], chip); + COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[2], chip); if (chip == 0) { - LOG_ERROR("Invalid NAND chip address %s", args[2]); + LOG_ERROR("Invalid NAND chip address %s", CMD_ARGV[2]); goto fail; } - if (strcmp(args[3], "hwecc1") == 0) + if (strcmp(CMD_ARGV[3], "hwecc1") == 0) eccmode = HWECC1; - else if (strcmp(args[3], "hwecc4") == 0) + else if (strcmp(CMD_ARGV[3], "hwecc4") == 0) eccmode = HWECC4; - else if (strcmp(args[3], "hwecc4_infix") == 0) + else if (strcmp(CMD_ARGV[3], "hwecc4_infix") == 0) eccmode = HWECC4_INFIX; else { - LOG_ERROR("Invalid ecc mode %s", args[3]); + LOG_ERROR("Invalid ecc mode %s", CMD_ARGV[3]); goto fail; } - COMMAND_PARSE_NUMBER(ulong, args[4], aemif); + COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[4], aemif); if (aemif == 0) { - LOG_ERROR("Invalid AEMIF controller address %s", args[4]); + LOG_ERROR("Invalid AEMIF controller address %s", CMD_ARGV[4]); goto fail; } diff --git a/src/flash/ecos.c b/src/flash/ecos.c index 8d2d3eec..863c12b2 100644 --- a/src/flash/ecos.c +++ b/src/flash/ecos.c @@ -122,7 +122,7 @@ FLASH_BANK_COMMAND_HANDLER(ecosflash_flash_bank_command) exit(-1); } bank->driver_priv = info; - info->driverPath = strdup(args[6]); + info->driverPath = strdup(CMD_ARGV[6]); /* eCos flash sector sizes are not exposed to OpenOCD, use 0x10000 as * a way to improve impedance match between OpenOCD and eCos flash @@ -141,10 +141,10 @@ FLASH_BANK_COMMAND_HANDLER(ecosflash_flash_bank_command) bank->sectors[i].is_protected = 0; } - info->target = get_target(args[5]); + info->target = get_target(CMD_ARGV[5]); if (info->target == NULL) { - LOG_ERROR("target '%s' not defined", args[5]); + LOG_ERROR("target '%s' not defined", CMD_ARGV[5]); return ERROR_FAIL; } return ERROR_OK; diff --git a/src/flash/faux.c b/src/flash/faux.c index 54acf754..558d7b07 100644 --- a/src/flash/faux.c +++ b/src/flash/faux.c @@ -76,10 +76,10 @@ FLASH_BANK_COMMAND_HANDLER(faux_flash_bank_command) bank->sectors[i].is_protected = 0; } - info->target = get_target(args[5]); + info->target = get_target(CMD_ARGV[5]); if (info->target == NULL) { - LOG_ERROR("target '%s' not defined", args[5]); + LOG_ERROR("target '%s' not defined", CMD_ARGV[5]); free(info->memory); free(info); return ERROR_FAIL; diff --git a/src/flash/flash.c b/src/flash/flash.c index 7402772c..99e71d7a 100644 --- a/src/flash/flash.c +++ b/src/flash/flash.c @@ -201,14 +201,14 @@ struct flash_bank *get_flash_bank_by_num(int num) COMMAND_HELPER(flash_command_get_bank_by_num, unsigned name_index, struct flash_bank **bank) { + const char *name = CMD_ARGV[name_index]; unsigned bank_num; - COMMAND_PARSE_NUMBER(uint, args[name_index], bank_num); + COMMAND_PARSE_NUMBER(uint, name, bank_num); *bank = get_flash_bank_by_num(bank_num); if (!*bank) { - command_print(cmd_ctx, - "flash bank '#%u' not found", bank_num); + command_print(cmd_ctx, "flash bank '%s' not found", name); return ERROR_INVALID_ARGUMENTS; } return ERROR_OK; @@ -227,15 +227,15 @@ COMMAND_HANDLER(handle_flash_bank_command) return ERROR_COMMAND_SYNTAX_ERROR; } - if ((target = get_target(args[5])) == NULL) + if ((target = get_target(CMD_ARGV[5])) == NULL) { - LOG_ERROR("target '%s' not defined", args[5]); + LOG_ERROR("target '%s' not defined", CMD_ARGV[5]); return ERROR_FAIL; } for (i = 0; flash_drivers[i]; i++) { - if (strcmp(args[0], flash_drivers[i]->name) != 0) + if (strcmp(CMD_ARGV[0], flash_drivers[i]->name) != 0) continue; struct flash_bank *p, *c; @@ -243,7 +243,7 @@ COMMAND_HANDLER(handle_flash_bank_command) /* register flash specific commands */ if (flash_drivers[i]->register_commands(cmd_ctx) != ERROR_OK) { - LOG_ERROR("couldn't register '%s' commands", args[0]); + LOG_ERROR("couldn't register '%s' commands", CMD_ARGV[0]); return ERROR_FAIL; } @@ -251,10 +251,10 @@ COMMAND_HANDLER(handle_flash_bank_command) c->target = target; c->driver = flash_drivers[i]; c->driver_priv = NULL; - COMMAND_PARSE_NUMBER(u32, args[1], c->base); - COMMAND_PARSE_NUMBER(u32, args[2], c->size); - COMMAND_PARSE_NUMBER(int, args[3], c->chip_width); - COMMAND_PARSE_NUMBER(int, args[4], c->bus_width); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], c->base); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], c->size); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[3], c->chip_width); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[4], c->bus_width); c->num_sectors = 0; c->sectors = NULL; c->next = NULL; @@ -262,7 +262,7 @@ COMMAND_HANDLER(handle_flash_bank_command) retval = CALL_COMMAND_HANDLER(flash_drivers[i]->flash_bank_command, c); if (ERROR_OK != retval) { - LOG_ERROR("'%s' driver rejected flash bank at 0x%8.8" PRIx32 , args[0], c->base); + LOG_ERROR("'%s' driver rejected flash bank at 0x%8.8" PRIx32 , CMD_ARGV[0], c->base); free(c); return retval; } @@ -289,7 +289,7 @@ COMMAND_HANDLER(handle_flash_bank_command) /* no matching flash driver found */ if (!found) { - LOG_ERROR("flash driver '%s' not found", args[0]); + LOG_ERROR("flash driver '%s' not found", CMD_ARGV[0]); return ERROR_FAIL; } @@ -307,7 +307,7 @@ COMMAND_HANDLER(handle_flash_info_command) return ERROR_COMMAND_SYNTAX_ERROR; unsigned bank_nr; - COMMAND_PARSE_NUMBER(uint, args[0], bank_nr); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], bank_nr); for (p = flash_banks; p; p = p->next, i++) { @@ -368,7 +368,7 @@ COMMAND_HANDLER(handle_flash_probe_command) } unsigned bank_nr; - COMMAND_PARSE_NUMBER(uint, args[0], bank_nr); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], bank_nr); struct flash_bank *p = get_flash_bank_by_num_noprobe(bank_nr); if (p) { @@ -379,17 +379,17 @@ COMMAND_HANDLER(handle_flash_probe_command) else if (retval == ERROR_FLASH_BANK_INVALID) { command_print(cmd_ctx, "probing failed for flash bank '#%s' at 0x%8.8" PRIx32, - args[0], p->base); + CMD_ARGV[0], p->base); } else { command_print(cmd_ctx, "unknown error when probing flash bank '#%s' at 0x%8.8" PRIx32, - args[0], p->base); + CMD_ARGV[0], p->base); } } else { - command_print(cmd_ctx, "flash bank '#%s' is out of bounds", args[0]); + command_print(cmd_ctx, "flash bank '#%s' is out of bounds", CMD_ARGV[0]); } return ERROR_OK; @@ -415,7 +415,7 @@ COMMAND_HANDLER(handle_flash_erase_check_command) else { command_print(cmd_ctx, "unknown error when checking erase state of flash bank #%s at 0x%8.8" PRIx32, - args[0], p->base); + CMD_ARGV[0], p->base); } for (j = 0; j < p->num_sectors; j++) @@ -453,8 +453,8 @@ COMMAND_HANDLER(handle_flash_erase_address_command) if (CMD_ARGC != 2) return ERROR_COMMAND_SYNTAX_ERROR; - COMMAND_PARSE_NUMBER(int, args[0], address); - COMMAND_PARSE_NUMBER(int, args[1], length); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], address); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], length); if (length <= 0) { command_print(cmd_ctx, "Length must be >0"); @@ -501,11 +501,11 @@ COMMAND_HANDLER(handle_flash_protect_check_command) } else if (retval == ERROR_FLASH_OPERATION_FAILED) { - command_print(cmd_ctx, "checking protection state failed (possibly unsupported) by flash #%s at 0x%8.8" PRIx32, args[0], p->base); + command_print(cmd_ctx, "checking protection state failed (possibly unsupported) by flash #%s at 0x%8.8" PRIx32, CMD_ARGV[0], p->base); } else { - command_print(cmd_ctx, "unknown error when checking protection state of flash bank '#%s' at 0x%8.8" PRIx32, args[0], p->base); + command_print(cmd_ctx, "unknown error when checking protection state of flash bank '#%s' at 0x%8.8" PRIx32, CMD_ARGV[0], p->base); } return ERROR_OK; @@ -538,16 +538,16 @@ COMMAND_HANDLER(handle_flash_erase_command) uint32_t first; uint32_t last; - COMMAND_PARSE_NUMBER(u32, args[0], bank_nr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], bank_nr); struct flash_bank *p = get_flash_bank_by_num(bank_nr); if (!p) return ERROR_OK; - COMMAND_PARSE_NUMBER(u32, args[1], first); - if (strcmp(args[2], "last") == 0) + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], first); + if (strcmp(CMD_ARGV[2], "last") == 0) last = p->num_sectors - 1; else - COMMAND_PARSE_NUMBER(u32, args[2], last); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], last); int retval; if ((retval = flash_check_sector_parameters(cmd_ctx, @@ -579,20 +579,20 @@ COMMAND_HANDLER(handle_flash_protect_command) uint32_t last; int set; - COMMAND_PARSE_NUMBER(u32, args[0], bank_nr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], bank_nr); struct flash_bank *p = get_flash_bank_by_num(bank_nr); if (!p) return ERROR_OK; - COMMAND_PARSE_NUMBER(u32, args[1], first); - if (strcmp(args[2], "last") == 0) + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], first); + if (strcmp(CMD_ARGV[2], "last") == 0) last = p->num_sectors - 1; else - COMMAND_PARSE_NUMBER(u32, args[2], last); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], last); - if (strcmp(args[3], "on") == 0) + if (strcmp(CMD_ARGV[3], "on") == 0) set = 1; - else if (strcmp(args[3], "off") == 0) + else if (strcmp(CMD_ARGV[3], "off") == 0) set = 0; else return ERROR_COMMAND_SYNTAX_ERROR; @@ -633,16 +633,16 @@ COMMAND_HANDLER(handle_flash_write_image_command) for (;;) { - if (strcmp(args[0], "erase") == 0) + if (strcmp(CMD_ARGV[0], "erase") == 0) { auto_erase = 1; - args++; + CMD_ARGV++; CMD_ARGC--; command_print(cmd_ctx, "auto erase enabled"); - } else if (strcmp(args[0], "unlock") == 0) + } else if (strcmp(CMD_ARGV[0], "unlock") == 0) { auto_unlock = true; - args++; + CMD_ARGV++; CMD_ARGC--; command_print(cmd_ctx, "auto unlock enabled"); } else @@ -668,7 +668,7 @@ COMMAND_HANDLER(handle_flash_write_image_command) if (CMD_ARGC >= 2) { image.base_address_set = 1; - COMMAND_PARSE_NUMBER(int, args[1], image.base_address); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], image.base_address); } else { @@ -678,7 +678,7 @@ COMMAND_HANDLER(handle_flash_write_image_command) image.start_address_set = 0; - retval = image_open(&image, args[0], (CMD_ARGC == 3) ? args[2] : NULL); + retval = image_open(&image, CMD_ARGV[0], (CMD_ARGC == 3) ? CMD_ARGV[2] : NULL); if (retval != ERROR_OK) { return retval; @@ -694,7 +694,7 @@ COMMAND_HANDLER(handle_flash_write_image_command) if ((ERROR_OK == retval) && (duration_measure(&bench) == ERROR_OK)) { command_print(cmd_ctx, "wrote %" PRIu32 " byte from file %s " - "in %fs (%0.3f kb/s)", written, args[0], + "in %fs (%0.3f kb/s)", written, CMD_ARGV[0], duration_elapsed(&bench), duration_kbps(&bench, written)); } @@ -721,9 +721,9 @@ COMMAND_HANDLER(handle_flash_fill_command) if (CMD_ARGC != 3) return ERROR_COMMAND_SYNTAX_ERROR; - COMMAND_PARSE_NUMBER(u32, args[0], address); - COMMAND_PARSE_NUMBER(u32, args[1], pattern); - COMMAND_PARSE_NUMBER(u32, args[2], count); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], pattern); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], count); if (count == 0) return ERROR_OK; @@ -824,9 +824,9 @@ COMMAND_HANDLER(handle_flash_write_bank_command) if (ERROR_OK != retval) return retval; - COMMAND_PARSE_NUMBER(u32, args[2], offset); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], offset); - if (fileio_open(&fileio, args[1], FILEIO_READ, FILEIO_BINARY) != ERROR_OK) + if (fileio_open(&fileio, CMD_ARGV[1], FILEIO_READ, FILEIO_BINARY) != ERROR_OK) { return ERROR_OK; } @@ -849,7 +849,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command) { command_print(cmd_ctx, "wrote %zu byte from file %s to flash bank %u" " at offset 0x%8.8" PRIx32 " in %fs (%0.3f kb/s)", - fileio.size, args[1], p->bank_number, offset, + fileio.size, CMD_ARGV[1], p->bank_number, offset, duration_elapsed(&bench), duration_kbps(&bench, fileio.size)); } diff --git a/src/flash/flash.h b/src/flash/flash.h index df5b0c9b..23a7b818 100644 --- a/src/flash/flash.h +++ b/src/flash/flash.h @@ -105,21 +105,21 @@ struct flash_driver * layer when this routine is called, and the driver can store * additional information in its struct flash_bank::driver_priv field. * - * The args are: @par + * The CMD_ARGV are: @par * @code - * args[0] = bank - * args[1] = drivername {name above} - * args[2] = baseaddress - * args[3] = lengthbytes - * args[4] = chip_width_in bytes - * args[5] = bus_width_bytes - * args[6] = driver-specific parameters + * CMD_ARGV[0] = bank + * CMD_ARGV[1] = drivername {name above} + * CMD_ARGV[2] = baseaddress + * CMD_ARGV[3] = lengthbytes + * CMD_ARGV[4] = chip_width_in bytes + * CMD_ARGV[5] = bus_width_bytes + * CMD_ARGV[6] = driver-specific parameters * @endcode * - * For example, args[4] = 16 bit flash, args[5] = 32bit bus. + * For example, CMD_ARGV[4] = 16 bit flash, CMD_ARGV[5] = 32bit bus. * * If extra arguments are provided (@a CMD_ARGC > 6), they will - * start in @a args[6]. These can be used to implement + * start in @a CMD_ARGV[6]. These can be used to implement * driver-specific extensions. * * @returns ERROR_OK if successful; otherwise, an error code. diff --git a/src/flash/lpc2000.c b/src/flash/lpc2000.c index 60d909f1..63781309 100644 --- a/src/flash/lpc2000.c +++ b/src/flash/lpc2000.c @@ -433,7 +433,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc2000_flash_bank_command) lpc2000_info = malloc(sizeof(struct lpc2000_flash_bank)); bank->driver_priv = lpc2000_info; - if (strcmp(args[6], "lpc2000_v1") == 0) + if (strcmp(CMD_ARGV[6], "lpc2000_v1") == 0) { lpc2000_info->variant = lpc2000_v1; lpc2000_info->cmd51_dst_boundary = 512; @@ -441,7 +441,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc2000_flash_bank_command) lpc2000_info->cmd51_can_8192b = 1; lpc2000_info->checksum_vector = 5; } - else if (strcmp(args[6], "lpc2000_v2") == 0) + else if (strcmp(CMD_ARGV[6], "lpc2000_v2") == 0) { lpc2000_info->variant = lpc2000_v2; lpc2000_info->cmd51_dst_boundary = 256; @@ -449,7 +449,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc2000_flash_bank_command) lpc2000_info->cmd51_can_8192b = 0; lpc2000_info->checksum_vector = 5; } - else if (strcmp(args[6], "lpc1700") == 0) + else if (strcmp(CMD_ARGV[6], "lpc1700") == 0) { lpc2000_info->variant = lpc1700; lpc2000_info->cmd51_dst_boundary = 256; @@ -459,19 +459,19 @@ FLASH_BANK_COMMAND_HANDLER(lpc2000_flash_bank_command) } else { - LOG_ERROR("unknown LPC2000 variant: %s", args[6]); + LOG_ERROR("unknown LPC2000 variant: %s", CMD_ARGV[6]); free(lpc2000_info); return ERROR_FLASH_BANK_INVALID; } lpc2000_info->iap_working_area = NULL; - COMMAND_PARSE_NUMBER(u32, args[7], lpc2000_info->cclk); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[7], lpc2000_info->cclk); lpc2000_info->calc_checksum = 0; lpc2000_build_sector_list(bank); if (CMD_ARGC >= 9) { - if (strcmp(args[8], "calc_checksum") == 0) + if (strcmp(CMD_ARGV[8], "calc_checksum") == 0) lpc2000_info->calc_checksum = 1; } diff --git a/src/flash/lpc288x.c b/src/flash/lpc288x.c index 2ad50146..446fc9da 100644 --- a/src/flash/lpc288x.c +++ b/src/flash/lpc288x.c @@ -180,7 +180,7 @@ FLASH_BANK_COMMAND_HANDLER(lpc288x_flash_bank_command) /* part wasn't probed for info yet */ lpc288x_info->cidr = 0; - COMMAND_PARSE_NUMBER(u32, args[6], lpc288x_info->cclk); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[6], lpc288x_info->cclk); return ERROR_OK; } diff --git a/src/flash/lpc2900.c b/src/flash/lpc2900.c index 67a510e0..98b13bf1 100644 --- a/src/flash/lpc2900.c +++ b/src/flash/lpc2900.c @@ -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 ) { @@ -668,7 +668,7 @@ 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 ) { @@ -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) { @@ -823,8 +823,8 @@ 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) ) @@ -1034,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; diff --git a/src/flash/lpc3180_nand_controller.c b/src/flash/lpc3180_nand_controller.c index d7cbe388..1de48f4d 100644 --- a/src/flash/lpc3180_nand_controller.c +++ b/src/flash/lpc3180_nand_controller.c @@ -37,15 +37,15 @@ NAND_DEVICE_COMMAND_HANDLER(lpc3180_nand_device_command) return ERROR_FLASH_BANK_INVALID; } - struct target *target = get_target(args[1]); + struct target *target = get_target(CMD_ARGV[1]); if (NULL == target) { - LOG_ERROR("target '%s' not defined", args[1]); + LOG_ERROR("target '%s' not defined", CMD_ARGV[1]); return ERROR_NAND_DEVICE_INVALID; } uint32_t osc_freq; - COMMAND_PARSE_NUMBER(u32, args[2], osc_freq); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], osc_freq); struct lpc3180_nand_controller *lpc3180_info; lpc3180_info = malloc(sizeof(struct lpc3180_nand_controller)); @@ -842,11 +842,11 @@ COMMAND_HANDLER(handle_lpc3180_select_command) } unsigned num; - COMMAND_PARSE_NUMBER(uint, args[1], num); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[1], num); struct nand_device *nand = get_nand_device_by_num(num); if (!nand) { - command_print(cmd_ctx, "nand device '#%s' is out of bounds", args[0]); + command_print(cmd_ctx, "nand device '#%s' is out of bounds", CMD_ARGV[0]); return ERROR_OK; } @@ -854,11 +854,11 @@ COMMAND_HANDLER(handle_lpc3180_select_command) if (CMD_ARGC == 2) { - if (strcmp(args[1], "mlc") == 0) + if (strcmp(CMD_ARGV[1], "mlc") == 0) { lpc3180_info->selected_controller = LPC3180_MLC_CONTROLLER; } - else if (strcmp(args[1], "slc") == 0) + else if (strcmp(CMD_ARGV[1], "slc") == 0) { lpc3180_info->selected_controller = LPC3180_SLC_CONTROLLER; } diff --git a/src/flash/mflash.c b/src/flash/mflash.c index 6aeeabc6..64f332e9 100644 --- a/src/flash/mflash.c +++ b/src/flash/mflash.c @@ -714,9 +714,9 @@ COMMAND_HANDLER(mg_write_cmd) return ERROR_COMMAND_SYNTAX_ERROR; } - COMMAND_PARSE_NUMBER(u32, args[2], address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], address); - ret = fileio_open(&fileio, args[1], FILEIO_READ, FILEIO_BINARY); + ret = fileio_open(&fileio, CMD_ARGV[1], FILEIO_READ, FILEIO_BINARY); if (ret != ERROR_OK) return ret; @@ -752,7 +752,7 @@ COMMAND_HANDLER(mg_write_cmd) if (duration_measure(&bench) == ERROR_OK) { command_print(cmd_ctx, "wrote %zu byte from file %s " - "in %fs (%0.3f kB/s)", fileio.size, args[1], + "in %fs (%0.3f kB/s)", fileio.size, CMD_ARGV[1], duration_elapsed(&bench), duration_kbps(&bench, fileio.size)); } @@ -779,10 +779,10 @@ COMMAND_HANDLER(mg_dump_cmd) return ERROR_COMMAND_SYNTAX_ERROR; } - COMMAND_PARSE_NUMBER(u32, args[2], address); - COMMAND_PARSE_NUMBER(u32, args[3], size); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[3], size); - ret = fileio_open(&fileio, args[1], FILEIO_WRITE, FILEIO_BINARY); + ret = fileio_open(&fileio, CMD_ARGV[1], FILEIO_WRITE, FILEIO_BINARY); if (ret != ERROR_OK) return ret; @@ -819,7 +819,7 @@ COMMAND_HANDLER(mg_dump_cmd) { command_print(cmd_ctx, "dump image (address 0x%8.8" PRIx32 " " "size %" PRIu32 ") to file %s in %fs (%0.3f kB/s)", - address, size, args[1], + address, size, CMD_ARGV[1], duration_elapsed(&bench), duration_kbps(&bench, size)); } @@ -1225,17 +1225,17 @@ COMMAND_HANDLER(mg_config_cmd) switch (CMD_ARGC) { case 2: - if (!strcmp(args[1], "boot")) + if (!strcmp(CMD_ARGV[1], "boot")) return mg_boot_config(); - else if (!strcmp(args[1], "storage")) + else if (!strcmp(CMD_ARGV[1], "storage")) return mg_storage_config(); else return ERROR_COMMAND_NOTFOUND; break; case 3: - if (!strcmp(args[1], "pll")) { + if (!strcmp(CMD_ARGV[1], "pll")) { unsigned long freq; - COMMAND_PARSE_NUMBER(ulong, args[2], freq); + COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[2], freq); fin = freq; if (fin > MG_PLL_CLK_OUT) { @@ -1293,30 +1293,30 @@ COMMAND_HANDLER(mg_bank_cmd) return ERROR_COMMAND_SYNTAX_ERROR; } - if ((target = get_target(args[3])) == NULL) + if ((target = get_target(CMD_ARGV[3])) == NULL) { - LOG_ERROR("target '%s' not defined", args[3]); + LOG_ERROR("target '%s' not defined", CMD_ARGV[3]); return ERROR_FAIL; } mflash_bank = calloc(sizeof(struct mflash_bank), 1); - COMMAND_PARSE_NUMBER(u32, args[1], mflash_bank->base); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], mflash_bank->base); /// @todo Verify how this parsing should work, then document it. char *str; - mflash_bank->rst_pin.num = strtoul(args[2], &str, 0); + mflash_bank->rst_pin.num = strtoul(CMD_ARGV[2], &str, 0); if (*str) mflash_bank->rst_pin.port[0] = (uint16_t)tolower(str[0]); mflash_bank->target = target; for (i = 0; mflash_gpio[i] ; i++) { - if (! strcmp(mflash_gpio[i]->name, args[0])) { + if (! strcmp(mflash_gpio[i]->name, CMD_ARGV[0])) { mflash_bank->gpio_drv = mflash_gpio[i]; } } if (! mflash_bank->gpio_drv) { - LOG_ERROR("%s is unsupported soc", args[0]); + LOG_ERROR("%s is unsupported soc", CMD_ARGV[0]); return ERROR_MG_UNSUPPORTED_SOC; } diff --git a/src/flash/mx3_nand.c b/src/flash/mx3_nand.c index 49e1758b..459e2a60 100644 --- a/src/flash/mx3_nand.c +++ b/src/flash/mx3_nand.c @@ -73,10 +73,10 @@ NAND_DEVICE_COMMAND_HANDLER(imx31_nand_device_command) nand->controller_priv = mx3_nf_info; - mx3_nf_info->target = get_target (args[1]); + mx3_nf_info->target = get_target (CMD_ARGV[1]); if (mx3_nf_info->target == NULL) { - LOG_ERROR ("target '%s' not defined", args[1]); + LOG_ERROR ("target '%s' not defined", CMD_ARGV[1]); return ERROR_FAIL; } if (CMD_ARGC < 3) @@ -89,7 +89,7 @@ NAND_DEVICE_COMMAND_HANDLER(imx31_nand_device_command) */ { int hwecc_needed; - hwecc_needed = strcmp (args[2], "hwecc"); + hwecc_needed = strcmp (CMD_ARGV[2], "hwecc"); if (hwecc_needed == 0) { mx3_nf_info->flags.hw_ecc_enabled = 1; diff --git a/src/flash/nand.c b/src/flash/nand.c index 9231b9ad..ce713b9c 100644 --- a/src/flash/nand.c +++ b/src/flash/nand.c @@ -220,12 +220,12 @@ COMMAND_HANDLER(handle_nand_device_command) { struct nand_device *p, *c; - if (strcmp(args[0], nand_flash_controllers[i]->name) == 0) + if (strcmp(CMD_ARGV[0], nand_flash_controllers[i]->name) == 0) { /* register flash specific commands */ if ((retval = nand_flash_controllers[i]->register_commands(cmd_ctx)) != ERROR_OK) { - LOG_ERROR("couldn't register '%s' commands", args[0]); + LOG_ERROR("couldn't register '%s' commands", CMD_ARGV[0]); return retval; } @@ -269,7 +269,7 @@ COMMAND_HANDLER(handle_nand_device_command) /* no valid NAND controller was found (i.e. the configuration option, * didn't match one of the compiled-in controllers) */ - LOG_ERROR("No valid NAND flash controller found (%s)", args[0]); + LOG_ERROR("No valid NAND flash controller found (%s)", CMD_ARGV[0]); LOG_ERROR("compiled-in NAND flash controllers:"); for (i = 0; nand_flash_controllers[i]; i++) { @@ -307,7 +307,7 @@ struct nand_device *get_nand_device_by_num(int num) COMMAND_HELPER(nand_command_get_device_by_num, unsigned name_index, struct nand_device **nand) { - const char *str = args[name_index]; + const char *str = CMD_ARGV[name_index]; unsigned num; COMMAND_PARSE_NUMBER(uint, str, num); *nand = get_nand_device_by_num(num); @@ -1090,19 +1090,19 @@ COMMAND_HANDLER(handle_nand_info_command) last = INT32_MAX; break; case 2: - COMMAND_PARSE_NUMBER(int, args[1], i); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], i); first = last = i; i = 0; break; case 3: - 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); break; } if (NULL == p->device) { - command_print(cmd_ctx, "#%s: not probed", args[0]); + command_print(cmd_ctx, "#%s: not probed", CMD_ARGV[0]); return ERROR_OK; } @@ -1193,11 +1193,11 @@ COMMAND_HANDLER(handle_nand_erase_command) if (CMD_ARGC == 3) { unsigned long size = p->erase_size * p->num_blocks; - COMMAND_PARSE_NUMBER(ulong, args[1], offset); + COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[1], offset); if ((offset % p->erase_size) != 0 || offset >= size) return ERROR_INVALID_ARGUMENTS; - COMMAND_PARSE_NUMBER(ulong, args[2], length); + COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[2], length); if ((length == 0) || (length % p->erase_size) != 0 || (length + offset) > size) return ERROR_INVALID_ARGUMENTS; @@ -1215,7 +1215,7 @@ COMMAND_HANDLER(handle_nand_erase_command) command_print(cmd_ctx, "erased blocks %lu to %lu " "on NAND flash device #%s '%s'", offset, offset + length, - args[0], p->device->name); + CMD_ARGV[0], p->device->name); } else if (retval == ERROR_NAND_OPERATION_FAILED) { @@ -1250,12 +1250,12 @@ COMMAND_HANDLER(handle_nand_check_bad_blocks_command) unsigned long offset; unsigned long length; - COMMAND_PARSE_NUMBER(ulong, args[1], offset); + COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[1], offset); if (offset % p->erase_size) return ERROR_INVALID_ARGUMENTS; offset /= p->erase_size; - COMMAND_PARSE_NUMBER(ulong, args[2], length); + COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[2], length); if (length % p->erase_size) return ERROR_INVALID_ARGUMENTS; @@ -1399,14 +1399,14 @@ static COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state, if (NULL == nand->device) { - command_print(cmd_ctx, "#%s: not probed", args[0]); + command_print(cmd_ctx, "#%s: not probed", CMD_ARGV[0]); return ERROR_OK; } - COMMAND_PARSE_NUMBER(u32, args[2], state->address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], state->address); if (need_size) { - COMMAND_PARSE_NUMBER(u32, args[2], state->size); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], state->size); if (state->size % nand->page_size) { command_print(cmd_ctx, "only page-aligned sizes are supported"); @@ -1418,23 +1418,23 @@ static COMMAND_HELPER(nand_fileio_parse_args, struct nand_fileio_state *state, { for (unsigned i = minargs; i < CMD_ARGC; i++) { - if (!strcmp(args[i], "oob_raw")) + if (!strcmp(CMD_ARGV[i], "oob_raw")) state->oob_format |= NAND_OOB_RAW; - else if (!strcmp(args[i], "oob_only")) + else if (!strcmp(CMD_ARGV[i], "oob_only")) state->oob_format |= NAND_OOB_RAW | NAND_OOB_ONLY; - else if (sw_ecc && !strcmp(args[i], "oob_softecc")) + else if (sw_ecc && !strcmp(CMD_ARGV[i], "oob_softecc")) state->oob_format |= NAND_OOB_SW_ECC; - else if (sw_ecc && !strcmp(args[i], "oob_softecc_kw")) + else if (sw_ecc && !strcmp(CMD_ARGV[i], "oob_softecc_kw")) state->oob_format |= NAND_OOB_SW_ECC_KW; else { - command_print(cmd_ctx, "unknown option: %s", args[i]); + command_print(cmd_ctx, "unknown option: %s", CMD_ARGV[i]); return ERROR_COMMAND_SYNTAX_ERROR; } } } - retval = nand_fileio_start(cmd_ctx, nand, args[1], filemode, state); + retval = nand_fileio_start(cmd_ctx, nand, CMD_ARGV[1], filemode, state); if (ERROR_OK != retval) return retval; @@ -1528,7 +1528,7 @@ COMMAND_HANDLER(handle_nand_write_command) { command_print(cmd_ctx, "failed writing file %s " "to NAND flash %s at offset 0x%8.8" PRIx32, - args[1], args[0], s.address); + CMD_ARGV[1], CMD_ARGV[0], s.address); return nand_fileio_cleanup(&s); } s.address += s.page_size; @@ -1538,7 +1538,7 @@ COMMAND_HANDLER(handle_nand_write_command) { command_print(cmd_ctx, "wrote file %s to NAND flash %s up to " "offset 0x%8.8" PRIx32 " in %fs (%0.3f kb/s)", - args[1], args[0], s.address, duration_elapsed(&s.bench), + CMD_ARGV[1], CMD_ARGV[0], s.address, duration_elapsed(&s.bench), duration_kbps(&s.bench, total_bytes)); } return ERROR_OK; @@ -1598,7 +1598,7 @@ COMMAND_HANDLER(handle_nand_verify_command) { command_print(cmd_ctx, "verified file %s in NAND flash %s " "up to offset 0x%8.8" PRIx32 " in %fs (%0.3f kb/s)", - args[1], args[0], dev.address, duration_elapsed(&file.bench), + CMD_ARGV[1], CMD_ARGV[0], dev.address, duration_elapsed(&file.bench), duration_kbps(&file.bench, dev.size)); } @@ -1658,15 +1658,15 @@ COMMAND_HANDLER(handle_nand_raw_access_command) if (NULL == p->device) { - command_print(cmd_ctx, "#%s: not probed", args[0]); + command_print(cmd_ctx, "#%s: not probed", CMD_ARGV[0]); return ERROR_OK; } if (CMD_ARGC == 2) { - if (strcmp("enable", args[1]) == 0) + if (strcmp("enable", CMD_ARGV[1]) == 0) p->use_raw = 1; - else if (strcmp("disable", args[1]) == 0) + else if (strcmp("disable", CMD_ARGV[1]) == 0) p->use_raw = 0; else return ERROR_COMMAND_SYNTAX_ERROR; diff --git a/src/flash/orion_nand.c b/src/flash/orion_nand.c index 69d6d966..c8fc9698 100644 --- a/src/flash/orion_nand.c +++ b/src/flash/orion_nand.c @@ -143,14 +143,14 @@ NAND_DEVICE_COMMAND_HANDLER(orion_nand_device_command) } nand->controller_priv = hw; - hw->target = get_target(args[1]); + hw->target = get_target(CMD_ARGV[1]); if (!hw->target) { - LOG_ERROR("target '%s' not defined", args[1]); + LOG_ERROR("target '%s' not defined", CMD_ARGV[1]); free(hw); return ERROR_NAND_DEVICE_INVALID; } - COMMAND_PARSE_NUMBER(u32, args[2], base); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], base); cle = 0; ale = 1; diff --git a/src/flash/pic32mx.c b/src/flash/pic32mx.c index 95e2c637..05e04746 100644 --- a/src/flash/pic32mx.c +++ b/src/flash/pic32mx.c @@ -854,8 +854,8 @@ COMMAND_HANDLER(pic32mx_handle_pgm_word_command) return ERROR_OK; } - COMMAND_PARSE_NUMBER(u32, args[0], address); - COMMAND_PARSE_NUMBER(u32, args[1], value); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value); struct flash_bank *bank; int retval = CALL_COMMAND_HANDLER(flash_command_get_bank_by_num, 2, &bank); @@ -864,7 +864,7 @@ COMMAND_HANDLER(pic32mx_handle_pgm_word_command) if (address < bank->base || address >= (bank->base + bank->size)) { - command_print(cmd_ctx, "flash address '%s' is out of bounds", args[0]); + command_print(cmd_ctx, "flash address '%s' is out of bounds", CMD_ARGV[0]); return ERROR_OK; } diff --git a/src/flash/s3c24xx_nand.c b/src/flash/s3c24xx_nand.c index 75b8700c..262569e8 100644 --- a/src/flash/s3c24xx_nand.c +++ b/src/flash/s3c24xx_nand.c @@ -43,9 +43,9 @@ S3C24XX_DEVICE_COMMAND() nand->controller_priv = s3c24xx_info; - s3c24xx_info->target = get_target(args[1]); + s3c24xx_info->target = get_target(CMD_ARGV[1]); if (s3c24xx_info->target == NULL) { - LOG_ERROR("target '%s' not defined", args[1]); + LOG_ERROR("target '%s' not defined", CMD_ARGV[1]); return ERROR_COMMAND_SYNTAX_ERROR; } diff --git a/src/flash/stm32x.c b/src/flash/stm32x.c index d32e9ea4..f59ed615 100644 --- a/src/flash/stm32x.c +++ b/src/flash/stm32x.c @@ -1065,7 +1065,7 @@ COMMAND_HANDLER(stm32x_handle_options_write_command) return ERROR_TARGET_NOT_HALTED; } - if (strcmp(args[1], "SWWDG") == 0) + if (strcmp(CMD_ARGV[1], "SWWDG") == 0) { optionbyte |= (1 << 0); } @@ -1074,7 +1074,7 @@ COMMAND_HANDLER(stm32x_handle_options_write_command) optionbyte &= ~(1 << 0); } - if (strcmp(args[2], "NORSTSTNDBY") == 0) + if (strcmp(CMD_ARGV[2], "NORSTSTNDBY") == 0) { optionbyte |= (1 << 1); } @@ -1083,7 +1083,7 @@ COMMAND_HANDLER(stm32x_handle_options_write_command) optionbyte &= ~(1 << 1); } - if (strcmp(args[3], "NORSTSTOP") == 0) + if (strcmp(CMD_ARGV[3], "NORSTSTOP") == 0) { optionbyte |= (1 << 2); } diff --git a/src/flash/str7x.c b/src/flash/str7x.c index 134780b1..76b64677 100644 --- a/src/flash/str7x.c +++ b/src/flash/str7x.c @@ -127,23 +127,23 @@ FLASH_BANK_COMMAND_HANDLER(str7x_flash_bank_command) str7x_info->busy_bits = (FLASH_LOCK | FLASH_BSYA1 | FLASH_BSYA0); str7x_info->disable_bit = (1 << 1); - if (strcmp(args[6], "STR71x") == 0) + if (strcmp(CMD_ARGV[6], "STR71x") == 0) { str7x_info->register_base = 0x40100000; } - else if (strcmp(args[6], "STR73x") == 0) + else if (strcmp(CMD_ARGV[6], "STR73x") == 0) { str7x_info->register_base = 0x80100000; str7x_info->busy_bits = (FLASH_LOCK | FLASH_BSYA0); } - else if (strcmp(args[6], "STR75x") == 0) + else if (strcmp(CMD_ARGV[6], "STR75x") == 0) { str7x_info->register_base = 0x20100000; str7x_info->disable_bit = (1 << 0); } else { - LOG_ERROR("unknown STR7x variant: '%s'", args[6]); + LOG_ERROR("unknown STR7x variant: '%s'", CMD_ARGV[6]); free(str7x_info); return ERROR_FLASH_BANK_INVALID; } diff --git a/src/flash/str9x.c b/src/flash/str9x.c index c103e572..50cddaf2 100644 --- a/src/flash/str9x.c +++ b/src/flash/str9x.c @@ -647,10 +647,10 @@ COMMAND_HANDLER(str9x_handle_flash_config_command) return retval; uint32_t bbsr, nbbsr, bbadr, nbbadr; - COMMAND_PARSE_NUMBER(u32, args[1], bbsr); - COMMAND_PARSE_NUMBER(u32, args[2], nbbsr); - COMMAND_PARSE_NUMBER(u32, args[3], bbadr); - COMMAND_PARSE_NUMBER(u32, args[4], nbbadr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], bbsr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], nbbsr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[3], bbadr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[4], nbbadr); str9x_info = bank->driver_priv; diff --git a/src/flash/str9xpec.c b/src/flash/str9xpec.c index 73027e45..a87d0fff 100644 --- a/src/flash/str9xpec.c +++ b/src/flash/str9xpec.c @@ -934,7 +934,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_cmap_command) 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); } @@ -963,7 +963,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdthd_command) 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); } @@ -992,7 +992,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdsel_command) 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); } @@ -1021,7 +1021,7 @@ COMMAND_HANDLER(str9xpec_handle_flash_options_lvdwarn_command) 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); } diff --git a/src/flash/tms470.c b/src/flash/tms470.c index d52dcc13..890db734 100644 --- a/src/flash/tms470.c +++ b/src/flash/tms470.c @@ -302,12 +302,12 @@ COMMAND_HANDLER(tms470_handle_flash_keyset_command) for (i = 0; i < 4; i++) { - int start = (0 == strncmp(args[i], "0x", 2)) ? 2 : 0; + int start = (0 == strncmp(CMD_ARGV[i], "0x", 2)) ? 2 : 0; - if (1 != sscanf(&args[i][start], "%" SCNx32 "", &flashKeys[i])) + if (1 != sscanf(&CMD_ARGV[i][start], "%" SCNx32 "", &flashKeys[i])) { - command_print(cmd_ctx, "could not process flash key %s", args[i]); - LOG_ERROR("could not process flash key %s", args[i]); + command_print(cmd_ctx, "could not process flash key %s", CMD_ARGV[i]); + LOG_ERROR("could not process flash key %s", CMD_ARGV[i]); return ERROR_INVALID_ARGUMENTS; } } @@ -362,7 +362,7 @@ COMMAND_HANDLER(tms470_handle_osc_megahertz_command) } else if (CMD_ARGC == 1) { - sscanf(args[0], "%d", &oscMHz); + sscanf(CMD_ARGV[0], "%d", &oscMHz); } if (oscMHz <= 0) @@ -391,7 +391,7 @@ COMMAND_HANDLER(tms470_handle_plldis_command) } else if (CMD_ARGC == 1) { - sscanf(args[0], "%d", &plldis); + sscanf(CMD_ARGV[0], "%d", &plldis); plldis = plldis ? 1 : 0; } diff --git a/src/hello.c b/src/hello.c index b2d1d300..df0cb026 100644 --- a/src/hello.c +++ b/src/hello.c @@ -32,7 +32,7 @@ static COMMAND_HELPER(handle_hello_args, const char **sep, const char **name) if (1 == CMD_ARGC) { *sep = " "; - *name = args[0]; + *name = CMD_ARGV[0]; } else *sep = *name = ""; diff --git a/src/helper/command.c b/src/helper/command.c index 3abfdd67..fdb59f01 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -142,7 +142,7 @@ static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv) log_add_callback(tcl_output, tclOutput); - // turn words[0] into args[-1] with this cast + // turn words[0] into CMD_ARGV[-1] with this cast retval = run_command(context, c, (const char **)words + 1, nwords); log_remove_callback(tcl_output, tclOutput); @@ -725,7 +725,7 @@ COMMAND_HANDLER(handle_sleep_command) bool busy = false; if (CMD_ARGC == 2) { - if (strcmp(args[1], "busy") == 0) + if (strcmp(CMD_ARGV[1], "busy") == 0) busy = true; else return ERROR_COMMAND_SYNTAX_ERROR; @@ -734,7 +734,7 @@ COMMAND_HANDLER(handle_sleep_command) return ERROR_COMMAND_SYNTAX_ERROR; unsigned long duration = 0; - int retval = parse_ulong(args[0], &duration); + int retval = parse_ulong(CMD_ARGV[0], &duration); if (ERROR_OK != retval) return retval; @@ -758,7 +758,7 @@ COMMAND_HANDLER(handle_fast_command) if (CMD_ARGC != 1) return ERROR_COMMAND_SYNTAX_ERROR; - fast_and_dangerous = strcmp("enable", args[0]) == 0; + fast_and_dangerous = strcmp("enable", CMD_ARGV[0]) == 0; return ERROR_OK; } diff --git a/src/helper/ioutil.c b/src/helper/ioutil.c index 2e8229c5..3fc1a966 100644 --- a/src/helper/ioutil.c +++ b/src/helper/ioutil.c @@ -65,7 +65,7 @@ COMMAND_HANDLER(handle_rm_command) return ERROR_INVALID_ARGUMENTS; } - if (unlink(args[0]) != 0) + if (unlink(CMD_ARGV[0]) != 0) { command_print(cmd_ctx, "failed: %d", errno); } @@ -145,7 +145,7 @@ COMMAND_HANDLER(handle_cat_command) void *data; size_t len; - int retval = loadFile(args[0], &data, &len); + int retval = loadFile(CMD_ARGV[0], &data, &len); if (retval == ERROR_OK) { command_print(cmd_ctx, "%s", (char *)data); @@ -153,7 +153,7 @@ COMMAND_HANDLER(handle_cat_command) } else { - command_print(cmd_ctx, "%s not found %d", args[0], retval); + command_print(cmd_ctx, "%s not found %d", CMD_ARGV[0], retval); } return ERROR_OK; @@ -168,7 +168,7 @@ COMMAND_HANDLER(handle_trunc_command) } FILE *config_file = NULL; - config_file = fopen(args[0], "w"); + config_file = fopen(CMD_ARGV[0], "w"); if (config_file != NULL) fclose(config_file); @@ -211,7 +211,7 @@ COMMAND_HANDLER(handle_append_command) int retval = ERROR_FAIL; FILE *config_file = NULL; - config_file = fopen(args[0], "a"); + config_file = fopen(CMD_ARGV[0], "a"); if (config_file != NULL) { fseek(config_file, 0, SEEK_END); @@ -219,7 +219,7 @@ COMMAND_HANDLER(handle_append_command) unsigned i; for (i = 1; i < CMD_ARGC; i++) { - if (fwrite(args[i], 1, strlen(args[i]), config_file) != strlen(args[i])) + if (fwrite(CMD_ARGV[i], 1, strlen(CMD_ARGV[i]), config_file) != strlen(CMD_ARGV[i])) break; if (i != CMD_ARGC - 1) { @@ -250,11 +250,11 @@ COMMAND_HANDLER(handle_cp_command) void *data; size_t len; - int retval = loadFile(args[0], &data, &len); + int retval = loadFile(CMD_ARGV[0], &data, &len); if (retval != ERROR_OK) return retval; - FILE *f = fopen(args[1], "wb"); + FILE *f = fopen(CMD_ARGV[1], "wb"); if (f == NULL) retval = ERROR_INVALID_ARGUMENTS; @@ -286,7 +286,7 @@ COMMAND_HANDLER(handle_cp_command) if (retval == ERROR_OK) { - command_print(cmd_ctx, "Copied %s to %s", args[0], args[1]); + command_print(cmd_ctx, "Copied %s to %s", CMD_ARGV[0], CMD_ARGV[1]); } else { command_print(cmd_ctx, "Failed: %d", retval); @@ -298,7 +298,7 @@ COMMAND_HANDLER(handle_cp_command) fclose(f); if (retval != ERROR_OK) - unlink(args[1]); + unlink(CMD_ARGV[1]); return retval; } diff --git a/src/helper/log.c b/src/helper/log.c index 715f2fa6..0e04c8e1 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -278,7 +278,7 @@ COMMAND_HANDLER(handle_debug_level_command) if (CMD_ARGC == 1) { unsigned new_level; - COMMAND_PARSE_NUMBER(uint, args[0], new_level); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], new_level); debug_level = MIN(new_level, LOG_LVL_DEBUG); } else if (CMD_ARGC > 1) @@ -305,7 +305,7 @@ COMMAND_HANDLER(handle_log_output_command) { if (CMD_ARGC == 1) { - FILE* file = fopen(args[0], "w"); + FILE* file = fopen(CMD_ARGV[0], "w"); if (file) { diff --git a/src/jtag/amt_jtagaccel.c b/src/jtag/amt_jtagaccel.c index 949acec2..d35b0c21 100644 --- a/src/jtag/amt_jtagaccel.c +++ b/src/jtag/amt_jtagaccel.c @@ -503,7 +503,7 @@ COMMAND_HANDLER(amt_jtagaccel_handle_parport_port_command) if (amt_jtagaccel_port == 0) { uint16_t port; - COMMAND_PARSE_NUMBER(u16, args[0], port); + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], port); amt_jtagaccel_port = port; } else @@ -527,7 +527,7 @@ COMMAND_HANDLER(amt_jtagaccel_handle_rtck_command) } else { - if (strcmp(args[0], "enabled") == 0) + if (strcmp(CMD_ARGV[0], "enabled") == 0) { rtck_enabled = 1; } diff --git a/src/jtag/at91rm9200.c b/src/jtag/at91rm9200.c index 90d94c95..8fbdf394 100644 --- a/src/jtag/at91rm9200.c +++ b/src/jtag/at91rm9200.c @@ -185,7 +185,7 @@ static int at91rm9200_speed(int speed) return ERROR_OK; } -static int at91rm9200_handle_device_command(struct command_context *cmd_ctx, char *cmd, char **args, int argc) +static int at91rm9200_handle_device_command(struct command_context *cmd_ctx, char *cmd, char **CMD_ARGV, int argc) { if (CMD_ARGC == 0) return ERROR_OK; @@ -193,8 +193,8 @@ static int at91rm9200_handle_device_command(struct command_context *cmd_ctx, cha /* only if the device name wasn't overwritten by cmdline */ if (at91rm9200_device == 0) { - at91rm9200_device = malloc(strlen(args[0]) + sizeof(char)); - strcpy(at91rm9200_device, args[0]); + at91rm9200_device = malloc(strlen(CMD_ARGV[0]) + sizeof(char)); + strcpy(at91rm9200_device, CMD_ARGV[0]); } return ERROR_OK; diff --git a/src/jtag/ft2232.c b/src/jtag/ft2232.c index c1b3f102..451da41c 100644 --- a/src/jtag/ft2232.c +++ b/src/jtag/ft2232.c @@ -2803,7 +2803,7 @@ COMMAND_HANDLER(ft2232_handle_device_desc_command) char buf[200]; if (CMD_ARGC == 1) { - ft2232_device_desc = strdup(args[0]); + ft2232_device_desc = strdup(CMD_ARGV[0]); cp = strchr(ft2232_device_desc, 0); /* under Win32, the FTD2XX driver appends an "A" to the end * of the description, this examines the given desc @@ -2835,7 +2835,7 @@ COMMAND_HANDLER(ft2232_handle_serial_command) { if (CMD_ARGC == 1) { - ft2232_serial = strdup(args[0]); + ft2232_serial = strdup(CMD_ARGV[0]); } else { @@ -2850,8 +2850,8 @@ COMMAND_HANDLER(ft2232_handle_layout_command) if (CMD_ARGC == 0) return ERROR_OK; - ft2232_layout = malloc(strlen(args[0]) + 1); - strcpy(ft2232_layout, args[0]); + ft2232_layout = malloc(strlen(CMD_ARGV[0]) + 1); + strcpy(ft2232_layout, CMD_ARGV[0]); return ERROR_OK; } @@ -2876,8 +2876,8 @@ COMMAND_HANDLER(ft2232_handle_vid_pid_command) unsigned i; 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_PARSE_NUMBER(u16, CMD_ARGV[i], ft2232_vid[i >> 1]); + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[i + 1], ft2232_pid[i >> 1]); } /* @@ -2893,7 +2893,7 @@ COMMAND_HANDLER(ft2232_handle_latency_command) { if (CMD_ARGC == 1) { - ft2232_latency = atoi(args[0]); + ft2232_latency = atoi(CMD_ARGV[0]); } else { diff --git a/src/jtag/gw16012.c b/src/jtag/gw16012.c index d1da2a13..d0cdde6b 100644 --- a/src/jtag/gw16012.c +++ b/src/jtag/gw16012.c @@ -548,7 +548,7 @@ COMMAND_HANDLER(gw16012_handle_parport_port_command) /* only if the port wasn't overwritten by cmdline */ if (gw16012_port == 0) { - COMMAND_PARSE_NUMBER(u16, args[0], gw16012_port); + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], gw16012_port); } else { diff --git a/src/jtag/jlink.c b/src/jtag/jlink.c index 41b99a14..80e71502 100644 --- a/src/jtag/jlink.c +++ b/src/jtag/jlink.c @@ -632,7 +632,7 @@ COMMAND_HANDLER(jlink_handle_jlink_hw_jtag_command) command_print(cmd_ctx, "jlink hw jtag %i", jlink_hw_jtag_version); break; case 1: { - int request_version = atoi(args[0]); + int request_version = atoi(CMD_ARGV[0]); switch (request_version) { case 2: case 3: jlink_hw_jtag_version = request_version; diff --git a/src/jtag/parport.c b/src/jtag/parport.c index 52289c5e..e15c66d1 100644 --- a/src/jtag/parport.c +++ b/src/jtag/parport.c @@ -416,7 +416,7 @@ COMMAND_HANDLER(parport_handle_parport_port_command) /* only if the port wasn't overwritten by cmdline */ if (parport_port == 0) { - COMMAND_PARSE_NUMBER(u16, args[0], parport_port); + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], parport_port); } else { @@ -438,8 +438,8 @@ COMMAND_HANDLER(parport_handle_parport_cable_command) /* only if the cable name wasn't overwritten by cmdline */ if (parport_cable == 0) { - parport_cable = malloc(strlen(args[0]) + sizeof(char)); - strcpy(parport_cable, args[0]); + parport_cable = malloc(strlen(CMD_ARGV[0]) + sizeof(char)); + strcpy(parport_cable, CMD_ARGV[0]); } return ERROR_OK; @@ -453,9 +453,9 @@ COMMAND_HANDLER(parport_handle_write_on_exit_command) return ERROR_OK; } - if (strcmp(args[0], "on") == 0) + if (strcmp(CMD_ARGV[0], "on") == 0) parport_exit = 1; - else if (strcmp(args[0], "off") == 0) + else if (strcmp(CMD_ARGV[0], "off") == 0) parport_exit = 0; return ERROR_OK; @@ -465,7 +465,7 @@ COMMAND_HANDLER(parport_handle_parport_toggling_time_command) { if (CMD_ARGC == 1) { uint32_t ns; - int retval = parse_u32(args[0], &ns); + int retval = parse_u32(CMD_ARGV[0], &ns); if (ERROR_OK != retval) return retval; diff --git a/src/jtag/presto.c b/src/jtag/presto.c index 45d99fff..1d6bc1db 100644 --- a/src/jtag/presto.c +++ b/src/jtag/presto.c @@ -756,7 +756,7 @@ COMMAND_HANDLER(presto_handle_serial_command) { if (presto_serial) free(presto_serial); - presto_serial = strdup(args[0]); + presto_serial = strdup(CMD_ARGV[0]); } else { diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index bd3f704a..1eead8d9 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -628,12 +628,12 @@ COMMAND_HANDLER(handle_interface_command) } /* interface name is a mandatory argument */ - if (CMD_ARGC != 1 || args[0][0] == '\0') + if (CMD_ARGC != 1 || CMD_ARGV[0][0] == '\0') return ERROR_COMMAND_SYNTAX_ERROR; for (unsigned i = 0; NULL != jtag_interfaces[i]; i++) { - if (strcmp(args[0], jtag_interfaces[i]->name) != 0) + if (strcmp(CMD_ARGV[0], jtag_interfaces[i]->name) != 0) continue; int retval = jtag_interfaces[i]->register_commands(cmd_ctx); @@ -657,7 +657,7 @@ COMMAND_HANDLER(handle_interface_command) /* no valid interface was found (i.e. the configuration option, * didn't match one of the compiled-in interfaces */ - LOG_ERROR("The specified JTAG interface was not found (%s)", args[0]); + LOG_ERROR("The specified JTAG interface was not found (%s)", CMD_ARGV[0]); CALL_COMMAND_HANDLER(handle_interface_list_command); return ERROR_JTAG_INVALID_INTERFACE; } @@ -711,21 +711,21 @@ COMMAND_HANDLER(handle_reset_config_command) * Here we don't care about the order, and only change values * which have been explicitly specified. */ - for (; CMD_ARGC; CMD_ARGC--, args++) { + for (; CMD_ARGC; CMD_ARGC--, CMD_ARGV++) { int tmp = 0; int m; /* gating */ m = RESET_SRST_NO_GATING; - if (strcmp(*args, "srst_gates_jtag") == 0) + if (strcmp(*CMD_ARGV, "srst_gates_jtag") == 0) /* default: don't use JTAG while SRST asserted */; - else if (strcmp(*args, "srst_nogate") == 0) + else if (strcmp(*CMD_ARGV, "srst_nogate") == 0) tmp = RESET_SRST_NO_GATING; else m = 0; if (mask & m) { LOG_ERROR("extra reset_config %s spec (%s)", - "gating", *args); + "gating", *CMD_ARGV); return ERROR_INVALID_ARGUMENTS; } if (m) @@ -733,19 +733,19 @@ COMMAND_HANDLER(handle_reset_config_command) /* signals */ m = RESET_HAS_TRST | RESET_HAS_SRST; - if (strcmp(*args, "none") == 0) + if (strcmp(*CMD_ARGV, "none") == 0) tmp = RESET_NONE; - else if (strcmp(*args, "trst_only") == 0) + else if (strcmp(*CMD_ARGV, "trst_only") == 0) tmp = RESET_HAS_TRST; - else if (strcmp(*args, "srst_only") == 0) + else if (strcmp(*CMD_ARGV, "srst_only") == 0) tmp = RESET_HAS_SRST; - else if (strcmp(*args, "trst_and_srst") == 0) + else if (strcmp(*CMD_ARGV, "trst_and_srst") == 0) tmp = RESET_HAS_TRST | RESET_HAS_SRST; else m = 0; if (mask & m) { LOG_ERROR("extra reset_config %s spec (%s)", - "signal", *args); + "signal", *CMD_ARGV); return ERROR_INVALID_ARGUMENTS; } if (m) @@ -753,19 +753,19 @@ COMMAND_HANDLER(handle_reset_config_command) /* combination (options for broken wiring) */ m = RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST; - if (strcmp(*args, "separate") == 0) + if (strcmp(*CMD_ARGV, "separate") == 0) /* separate reset lines - default */; - else if (strcmp(*args, "srst_pulls_trst") == 0) + else if (strcmp(*CMD_ARGV, "srst_pulls_trst") == 0) tmp |= RESET_SRST_PULLS_TRST; - else if (strcmp(*args, "trst_pulls_srst") == 0) + else if (strcmp(*CMD_ARGV, "trst_pulls_srst") == 0) tmp |= RESET_TRST_PULLS_SRST; - else if (strcmp(*args, "combined") == 0) + else if (strcmp(*CMD_ARGV, "combined") == 0) tmp |= RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST; else m = 0; if (mask & m) { LOG_ERROR("extra reset_config %s spec (%s)", - "combination", *args); + "combination", *CMD_ARGV); return ERROR_INVALID_ARGUMENTS; } if (m) @@ -773,15 +773,15 @@ COMMAND_HANDLER(handle_reset_config_command) /* trst_type (NOP without HAS_TRST) */ m = RESET_TRST_OPEN_DRAIN; - if (strcmp(*args, "trst_open_drain") == 0) + if (strcmp(*CMD_ARGV, "trst_open_drain") == 0) tmp |= RESET_TRST_OPEN_DRAIN; - else if (strcmp(*args, "trst_push_pull") == 0) + else if (strcmp(*CMD_ARGV, "trst_push_pull") == 0) /* push/pull from adapter - default */; else m = 0; if (mask & m) { LOG_ERROR("extra reset_config %s spec (%s)", - "trst_type", *args); + "trst_type", *CMD_ARGV); return ERROR_INVALID_ARGUMENTS; } if (m) @@ -789,22 +789,22 @@ COMMAND_HANDLER(handle_reset_config_command) /* srst_type (NOP without HAS_SRST) */ m |= RESET_SRST_PUSH_PULL; - if (strcmp(*args, "srst_push_pull") == 0) + if (strcmp(*CMD_ARGV, "srst_push_pull") == 0) tmp |= RESET_SRST_PUSH_PULL; - else if (strcmp(*args, "srst_open_drain") == 0) + else if (strcmp(*CMD_ARGV, "srst_open_drain") == 0) /* open drain from adapter - default */; else m = 0; if (mask & m) { LOG_ERROR("extra reset_config %s spec (%s)", - "srst_type", *args); + "srst_type", *CMD_ARGV); return ERROR_INVALID_ARGUMENTS; } if (m) goto next; /* caller provided nonsense; fail */ - LOG_ERROR("unknown reset_config flag (%s)", *args); + LOG_ERROR("unknown reset_config flag (%s)", *CMD_ARGV); return ERROR_INVALID_ARGUMENTS; next: @@ -902,7 +902,7 @@ COMMAND_HANDLER(handle_jtag_nsrst_delay_command) if (CMD_ARGC == 1) { unsigned delay; - COMMAND_PARSE_NUMBER(uint, args[0], delay); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], delay); jtag_set_nsrst_delay(delay); } @@ -917,7 +917,7 @@ COMMAND_HANDLER(handle_jtag_ntrst_delay_command) if (CMD_ARGC == 1) { unsigned delay; - COMMAND_PARSE_NUMBER(uint, args[0], delay); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], delay); jtag_set_ntrst_delay(delay); } @@ -932,7 +932,7 @@ COMMAND_HANDLER(handle_jtag_nsrst_assert_width_command) if (CMD_ARGC == 1) { unsigned delay; - COMMAND_PARSE_NUMBER(uint, args[0], delay); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], delay); jtag_set_nsrst_assert_width(delay); } @@ -947,7 +947,7 @@ COMMAND_HANDLER(handle_jtag_ntrst_assert_width_command) if (CMD_ARGC == 1) { unsigned delay; - COMMAND_PARSE_NUMBER(uint, args[0], delay); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], delay); jtag_set_ntrst_assert_width(delay); } @@ -964,7 +964,7 @@ COMMAND_HANDLER(handle_jtag_khz_command) if (CMD_ARGC == 1) { unsigned khz = 0; - COMMAND_PARSE_NUMBER(uint, args[0], khz); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], khz); retval = jtag_config_khz(khz); if (ERROR_OK != retval) @@ -993,7 +993,7 @@ COMMAND_HANDLER(handle_jtag_rclk_command) if (CMD_ARGC == 1) { unsigned khz = 0; - COMMAND_PARSE_NUMBER(uint, args[0], khz); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], khz); retval = jtag_config_rclk(khz); if (ERROR_OK != retval) @@ -1019,17 +1019,17 @@ COMMAND_HANDLER(handle_jtag_reset_command) return ERROR_COMMAND_SYNTAX_ERROR; int trst = -1; - if (args[0][0] == '1') + if (CMD_ARGV[0][0] == '1') trst = 1; - else if (args[0][0] == '0') + else if (CMD_ARGV[0][0] == '0') trst = 0; else return ERROR_COMMAND_SYNTAX_ERROR; int srst = -1; - if (args[1][0] == '1') + if (CMD_ARGV[1][0] == '1') srst = 1; - else if (args[1][0] == '0') + else if (CMD_ARGV[1][0] == '0') srst = 0; else return ERROR_COMMAND_SYNTAX_ERROR; @@ -1047,7 +1047,7 @@ COMMAND_HANDLER(handle_runtest_command) return ERROR_COMMAND_SYNTAX_ERROR; unsigned num_clocks; - COMMAND_PARSE_NUMBER(uint, args[0], num_clocks); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num_clocks); jtag_add_runtest(num_clocks, TAP_IDLE); return jtag_execute_queue(); @@ -1096,13 +1096,13 @@ COMMAND_HANDLER(handle_irscan_command) if (CMD_ARGC >= 4) { /* have at least one pair of numbers. */ /* is last pair the magic text? */ - if (strcmp("-endstate", args[CMD_ARGC - 2]) == 0) { - endstate = tap_state_by_name(args[CMD_ARGC - 1]); + if (strcmp("-endstate", CMD_ARGV[CMD_ARGC - 2]) == 0) { + endstate = tap_state_by_name(CMD_ARGV[CMD_ARGC - 1]); if (endstate == TAP_INVALID) return ERROR_COMMAND_SYNTAX_ERROR; if (!scan_is_safe(endstate)) LOG_WARNING("unstable irscan endstate \"%s\"", - args[CMD_ARGC - 1]); + CMD_ARGV[CMD_ARGC - 1]); CMD_ARGC -= 2; } } @@ -1115,14 +1115,14 @@ COMMAND_HANDLER(handle_irscan_command) int retval; for (i = 0; i < num_fields; i++) { - tap = jtag_tap_by_string(args[i*2]); + tap = jtag_tap_by_string(CMD_ARGV[i*2]); if (tap == NULL) { int j; for (j = 0; j < i; j++) free(fields[j].out_value); free(fields); - command_print(cmd_ctx, "Tap: %s unknown", args[i*2]); + command_print(cmd_ctx, "Tap: %s unknown", CMD_ARGV[i*2]); return ERROR_FAIL; } @@ -1132,7 +1132,7 @@ COMMAND_HANDLER(handle_irscan_command) fields[i].out_value = malloc(DIV_ROUND_UP(field_size, 8)); uint32_t value; - retval = parse_u32(args[i * 2 + 1], &value); + retval = parse_u32(CMD_ARGV[i * 2 + 1], &value); if (ERROR_OK != retval) goto error_return; buf_set_u32(fields[i].out_value, 0, field_size, value); @@ -1357,9 +1357,9 @@ COMMAND_HANDLER(handle_verify_ircapture_command) if (CMD_ARGC == 1) { - if (strcmp(args[0], "enable") == 0) + if (strcmp(CMD_ARGV[0], "enable") == 0) jtag_set_verify_capture_ir(true); - else if (strcmp(args[0], "disable") == 0) + else if (strcmp(CMD_ARGV[0], "disable") == 0) jtag_set_verify_capture_ir(false); else return ERROR_COMMAND_SYNTAX_ERROR; @@ -1378,9 +1378,9 @@ COMMAND_HANDLER(handle_verify_jtag_command) if (CMD_ARGC == 1) { - if (strcmp(args[0], "enable") == 0) + if (strcmp(CMD_ARGV[0], "enable") == 0) jtag_set_verify(true); - else if (strcmp(args[0], "disable") == 0) + else if (strcmp(CMD_ARGV[0], "disable") == 0) jtag_set_verify(false); else return ERROR_COMMAND_SYNTAX_ERROR; @@ -1400,9 +1400,9 @@ COMMAND_HANDLER(handle_tms_sequence_command) if (CMD_ARGC == 1) { bool use_new_table; - if (strcmp(args[0], "short") == 0) + if (strcmp(CMD_ARGV[0], "short") == 0) use_new_table = true; - else if (strcmp(args[0], "long") == 0) + else if (strcmp(CMD_ARGV[0], "long") == 0) use_new_table = false; else return ERROR_COMMAND_SYNTAX_ERROR; diff --git a/src/jtag/vsllink.c b/src/jtag/vsllink.c index cbea9956..7962249c 100644 --- a/src/jtag/vsllink.c +++ b/src/jtag/vsllink.c @@ -1329,17 +1329,17 @@ COMMAND_HANDLER(vsllink_handle_mode_command) return ERROR_FAIL; } - if (!strcmp(args[0], "normal")) + if (!strcmp(CMD_ARGV[0], "normal")) { vsllink_mode = VSLLINK_MODE_NORMAL; } - else if (!strcmp(args[0], "dma")) + else if (!strcmp(CMD_ARGV[0], "dma")) { vsllink_mode = VSLLINK_MODE_DMA; } else { - LOG_ERROR("invalid vsllink_mode: %s", args[0]); + LOG_ERROR("invalid vsllink_mode: %s", CMD_ARGV[0]); return ERROR_FAIL; } @@ -1354,7 +1354,7 @@ COMMAND_HANDLER(vsllink_handle_usb_vid_command) return ERROR_OK; } - COMMAND_PARSE_NUMBER(u16, args[0], vsllink_usb_vid); + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], vsllink_usb_vid); return ERROR_OK; } @@ -1365,7 +1365,7 @@ COMMAND_HANDLER(vsllink_handle_usb_pid_command) LOG_ERROR("parameter error, should be one parameter for PID"); return ERROR_OK; } - COMMAND_PARSE_NUMBER(u16, args[0], vsllink_usb_pid); + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], vsllink_usb_pid); return ERROR_OK; } @@ -1377,7 +1377,7 @@ COMMAND_HANDLER(vsllink_handle_usb_bulkin_command) return ERROR_OK; } - COMMAND_PARSE_NUMBER(u8, args[0], vsllink_usb_bulkin); + COMMAND_PARSE_NUMBER(u8, CMD_ARGV[0], vsllink_usb_bulkin); vsllink_usb_bulkin |= 0x80; @@ -1392,7 +1392,7 @@ COMMAND_HANDLER(vsllink_handle_usb_bulkout_command) return ERROR_OK; } - COMMAND_PARSE_NUMBER(u8, args[0], vsllink_usb_bulkout); + COMMAND_PARSE_NUMBER(u8, CMD_ARGV[0], vsllink_usb_bulkout); vsllink_usb_bulkout &= ~0x80; @@ -1407,7 +1407,7 @@ COMMAND_HANDLER(vsllink_handle_usb_interface_command) return ERROR_OK; } - COMMAND_PARSE_NUMBER(u8, args[0], vsllink_usb_interface); + COMMAND_PARSE_NUMBER(u8, CMD_ARGV[0], vsllink_usb_interface); return ERROR_OK; } diff --git a/src/pld/pld.c b/src/pld/pld.c index 178da975..96d37f17 100644 --- a/src/pld/pld.c +++ b/src/pld/pld.c @@ -70,14 +70,14 @@ COMMAND_HANDLER(handle_pld_device_command) for (i = 0; pld_drivers[i]; i++) { - if (strcmp(args[0], pld_drivers[i]->name) == 0) + if (strcmp(CMD_ARGV[0], pld_drivers[i]->name) == 0) { struct pld_device *p, *c; /* register pld specific commands */ if (pld_drivers[i]->register_commands(cmd_ctx) != ERROR_OK) { - LOG_ERROR("couldn't register '%s' commands", args[0]); + LOG_ERROR("couldn't register '%s' commands", CMD_ARGV[0]); exit(-1); } @@ -88,7 +88,7 @@ COMMAND_HANDLER(handle_pld_device_command) int retval = CALL_COMMAND_HANDLER(pld_drivers[i]->pld_device_command, c); if (ERROR_OK != retval) { - LOG_ERROR("'%s' driver rejected pld device", args[0]); + LOG_ERROR("'%s' driver rejected pld device", CMD_ARGV[0]); free(c); return ERROR_OK; } @@ -113,7 +113,7 @@ COMMAND_HANDLER(handle_pld_device_command) /* no matching pld driver found */ if (!found) { - LOG_ERROR("pld driver '%s' not found", args[0]); + LOG_ERROR("pld driver '%s' not found", CMD_ARGV[0]); exit(-1); } @@ -154,18 +154,18 @@ COMMAND_HANDLER(handle_pld_load_command) } unsigned dev_id; - COMMAND_PARSE_NUMBER(uint, args[0], dev_id); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], dev_id); p = get_pld_device_by_num(dev_id); if (!p) { - command_print(cmd_ctx, "pld device '#%s' is out of bounds", args[0]); + command_print(cmd_ctx, "pld device '#%s' is out of bounds", CMD_ARGV[0]); return ERROR_OK; } - if ((retval = p->driver->load(p, args[1])) != ERROR_OK) + if ((retval = p->driver->load(p, CMD_ARGV[1])) != ERROR_OK) { command_print(cmd_ctx, "failed loading file %s to pld device %u", - args[1], dev_id); + CMD_ARGV[1], dev_id); switch (retval) { } @@ -177,7 +177,7 @@ COMMAND_HANDLER(handle_pld_load_command) timeval_subtract(&duration, &end, &start); command_print(cmd_ctx, "loaded file %s to pld device %u in %jis %jius", - args[1], dev_id, + CMD_ARGV[1], dev_id, (intmax_t)duration.tv_sec, (intmax_t)duration.tv_usec); } diff --git a/src/pld/virtex2.c b/src/pld/virtex2.c index a6587ddc..b4593cc5 100644 --- a/src/pld/virtex2.c +++ b/src/pld/virtex2.c @@ -190,11 +190,11 @@ COMMAND_HANDLER(virtex2_handle_read_stat_command) } unsigned dev_id; - COMMAND_PARSE_NUMBER(uint, args[0], dev_id); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], dev_id); device = get_pld_device_by_num(dev_id); if (!device) { - command_print(cmd_ctx, "pld device '#%s' is out of bounds", args[0]); + command_print(cmd_ctx, "pld device '#%s' is out of bounds", CMD_ARGV[0]); return ERROR_OK; } @@ -219,9 +219,9 @@ PLD_DEVICE_COMMAND_HANDLER(virtex2_pld_device_command) return ERROR_PLD_DEVICE_INVALID; } - tap = jtag_tap_by_string(args[1]); + tap = jtag_tap_by_string(CMD_ARGV[1]); if (tap == NULL) { - command_print(cmd_ctx, "Tap: %s does not exist", args[1]); + command_print(cmd_ctx, "Tap: %s does not exist", CMD_ARGV[1]); return ERROR_OK; } diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index f5eb71da..716e1cfe 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -2272,18 +2272,18 @@ COMMAND_HANDLER(handle_gdb_memory_map_command) { if (CMD_ARGC == 1) { - if (strcmp(args[0], "enable") == 0) + if (strcmp(CMD_ARGV[0], "enable") == 0) { gdb_use_memory_map = 1; return ERROR_OK; } - else if (strcmp(args[0], "disable") == 0) + else if (strcmp(CMD_ARGV[0], "disable") == 0) { gdb_use_memory_map = 0; return ERROR_OK; } else - LOG_WARNING("invalid gdb_memory_map configuration directive %s", args[0]); + LOG_WARNING("invalid gdb_memory_map configuration directive %s", CMD_ARGV[0]); } return ERROR_COMMAND_SYNTAX_ERROR; @@ -2293,18 +2293,18 @@ COMMAND_HANDLER(handle_gdb_flash_program_command) { if (CMD_ARGC == 1) { - if (strcmp(args[0], "enable") == 0) + if (strcmp(CMD_ARGV[0], "enable") == 0) { gdb_flash_program = 1; return ERROR_OK; } - else if (strcmp(args[0], "disable") == 0) + else if (strcmp(CMD_ARGV[0], "disable") == 0) { gdb_flash_program = 0; return ERROR_OK; } else - LOG_WARNING("invalid gdb_flash_program configuration directive: %s", args[0]); + LOG_WARNING("invalid gdb_flash_program configuration directive: %s", CMD_ARGV[0]); } return ERROR_COMMAND_SYNTAX_ERROR; @@ -2314,18 +2314,18 @@ COMMAND_HANDLER(handle_gdb_report_data_abort_command) { if (CMD_ARGC == 1) { - if (strcmp(args[0], "enable") == 0) + if (strcmp(CMD_ARGV[0], "enable") == 0) { gdb_report_data_abort = 1; return ERROR_OK; } - else if (strcmp(args[0], "disable") == 0) + else if (strcmp(CMD_ARGV[0], "disable") == 0) { gdb_report_data_abort = 0; return ERROR_OK; } else - LOG_WARNING("invalid gdb_report_data_abort configuration directive: %s", args[0]); + LOG_WARNING("invalid gdb_report_data_abort configuration directive: %s", CMD_ARGV[0]); } return ERROR_COMMAND_SYNTAX_ERROR; @@ -2340,13 +2340,13 @@ COMMAND_HANDLER(handle_gdb_breakpoint_override_command) } else if (CMD_ARGC == 1) { gdb_breakpoint_override = 1; - if (strcmp(args[0], "hard") == 0) + if (strcmp(CMD_ARGV[0], "hard") == 0) { gdb_breakpoint_override_type = BKPT_HARD; - } else if (strcmp(args[0], "soft") == 0) + } else if (strcmp(CMD_ARGV[0], "soft") == 0) { gdb_breakpoint_override_type = BKPT_SOFT; - } else if (strcmp(args[0], "disable") == 0) + } else if (strcmp(CMD_ARGV[0], "disable") == 0) { gdb_breakpoint_override = 0; } diff --git a/src/server/httpd.c b/src/server/httpd.c index d8659b09..1c5e6d2b 100644 --- a/src/server/httpd.c +++ b/src/server/httpd.c @@ -109,7 +109,7 @@ static int httpd_Jim_Command_writeform(Jim_Interp *interp, int argc, { if (argc != 3) { - Jim_WrongNumArgs(interp, 1, argv, "method ?args ...?"); + Jim_WrongNumArgs(interp, 1, argv, "method ?CMD_ARGV ...?"); return JIM_ERR; } char *name = (char*) Jim_GetString(argv[1], NULL); @@ -156,7 +156,7 @@ httpd_Jim_Command_formfetch(Jim_Interp *interp, { if (argc != 2) { - Jim_WrongNumArgs(interp, 1, argv, "method ?args ...?"); + Jim_WrongNumArgs(interp, 1, argv, "method ?CMD_ARGV ...?"); return JIM_ERR; } char *name = (char*)Jim_GetString(argv[1], NULL); diff --git a/src/server/server.c b/src/server/server.c index 17a116d2..258c89bc 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -558,7 +558,7 @@ SERVER_PORT_COMMAND() case 1: { uint16_t port; - COMMAND_PARSE_NUMBER(u16, args[0], port); + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], port); *out = port; break; } diff --git a/src/svf/svf.c b/src/svf/svf.c index c51e6090..45f34936 100644 --- a/src/svf/svf.c +++ b/src/svf/svf.c @@ -318,28 +318,28 @@ COMMAND_HANDLER(handle_svf_command) svf_quiet = 0; for (unsigned i = 1; i < CMD_ARGC; i++) { - if (!strcmp(args[i], "quiet")) + if (!strcmp(CMD_ARGV[i], "quiet")) { svf_quiet = 1; } else { - LOG_ERROR("unknown variant for svf: %s", args[i]); + LOG_ERROR("unknown variant for svf: %s", CMD_ARGV[i]); // no need to free anything now return ERROR_FAIL; } } - if ((svf_fd = open(args[0], O_RDONLY)) < 0) + if ((svf_fd = open(CMD_ARGV[0], O_RDONLY)) < 0) { - command_print(cmd_ctx, "file \"%s\" not found", args[0]); + command_print(cmd_ctx, "file \"%s\" not found", CMD_ARGV[0]); // no need to free anything now return ERROR_FAIL; } - LOG_USER("svf processing file: \"%s\"", args[0]); + LOG_USER("svf processing file: \"%s\"", CMD_ARGV[0]); // get time time_ago = timeval_ms(); diff --git a/src/target/arm11.c b/src/target/arm11.c index 4236ac89..65e07809 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -2014,7 +2014,7 @@ static COMMAND_HELPER(arm11_handle_bool, bool *var, char *name) if (CMD_ARGC != 1) return ERROR_COMMAND_SYNTAX_ERROR; - switch (args[0][0]) + switch (CMD_ARGV[0][0]) { case '0': /* 0 */ case 'f': /* false */ @@ -2056,7 +2056,7 @@ COMMAND_HANDLER(arm11_handle_vcr) case 0: break; case 1: - COMMAND_PARSE_NUMBER(u32, args[0], arm11_vcr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], arm11_vcr); break; default: return ERROR_COMMAND_SYNTAX_ERROR; diff --git a/src/target/arm720t.c b/src/target/arm720t.c index 53d22245..a0cde5d4 100644 --- a/src/target/arm720t.c +++ b/src/target/arm720t.c @@ -432,7 +432,7 @@ COMMAND_HANDLER(arm720t_handle_cp15_command) if (CMD_ARGC >= 1) { uint32_t opcode; - COMMAND_PARSE_NUMBER(u32, args[0], opcode); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], opcode); if (CMD_ARGC == 1) { @@ -453,7 +453,7 @@ COMMAND_HANDLER(arm720t_handle_cp15_command) else if (CMD_ARGC == 2) { uint32_t value; - COMMAND_PARSE_NUMBER(u32, args[1], value); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value); if ((retval = arm720t_write_cp15(target, opcode, value)) != ERROR_OK) { diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index 19c9791d..bd018b49 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -2771,8 +2771,8 @@ COMMAND_HANDLER(handle_arm7_9_write_xpsr_command) return ERROR_FAIL; } - COMMAND_PARSE_NUMBER(u32, args[0], value); - COMMAND_PARSE_NUMBER(int, args[1], spsr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], value); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], spsr); /* if we're writing the CPSR, mask the T bit */ if (!spsr) @@ -2815,9 +2815,9 @@ COMMAND_HANDLER(handle_arm7_9_write_xpsr_im8_command) return ERROR_FAIL; } - COMMAND_PARSE_NUMBER(u32, args[0], value); - COMMAND_PARSE_NUMBER(int, args[1], rotate); - COMMAND_PARSE_NUMBER(int, args[2], spsr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], value); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], rotate); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[2], spsr); arm7_9->write_xpsr_im8(target, value, rotate, spsr); if ((retval = jtag_execute_queue()) != ERROR_OK) @@ -2855,9 +2855,9 @@ COMMAND_HANDLER(handle_arm7_9_write_core_reg_command) return ERROR_FAIL; } - COMMAND_PARSE_NUMBER(int, args[0], num); - COMMAND_PARSE_NUMBER(u32, args[1], mode); - COMMAND_PARSE_NUMBER(u32, args[2], value); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], num); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], mode); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], value); return arm7_9_write_core_reg(target, num, mode, value); } @@ -2875,11 +2875,11 @@ COMMAND_HANDLER(handle_arm7_9_dbgrq_command) if (CMD_ARGC > 0) { - if (strcmp("enable", args[0]) == 0) + if (strcmp("enable", CMD_ARGV[0]) == 0) { arm7_9->use_dbgrq = 1; } - else if (strcmp("disable", args[0]) == 0) + else if (strcmp("disable", CMD_ARGV[0]) == 0) { arm7_9->use_dbgrq = 0; } @@ -2907,11 +2907,11 @@ COMMAND_HANDLER(handle_arm7_9_fast_memory_access_command) if (CMD_ARGC > 0) { - if (strcmp("enable", args[0]) == 0) + if (strcmp("enable", CMD_ARGV[0]) == 0) { arm7_9->fast_memory_access = 1; } - else if (strcmp("disable", args[0]) == 0) + else if (strcmp("disable", CMD_ARGV[0]) == 0) { arm7_9->fast_memory_access = 0; } @@ -2939,11 +2939,11 @@ COMMAND_HANDLER(handle_arm7_9_dcc_downloads_command) if (CMD_ARGC > 0) { - if (strcmp("enable", args[0]) == 0) + if (strcmp("enable", CMD_ARGV[0]) == 0) { arm7_9->dcc_downloads = 1; } - else if (strcmp("disable", args[0]) == 0) + else if (strcmp("disable", CMD_ARGV[0]) == 0) { arm7_9->dcc_downloads = 0; } diff --git a/src/target/arm920t.c b/src/target/arm920t.c index 58e92c35..fbb8d7f5 100644 --- a/src/target/arm920t.c +++ b/src/target/arm920t.c @@ -688,7 +688,7 @@ COMMAND_HANDLER(arm920t_handle_read_cache_command) return ERROR_OK; } - if ((output = fopen(args[0], "w")) == NULL) + if ((output = fopen(CMD_ARGV[0], "w")) == NULL) { LOG_DEBUG("error opening cache content file"); return ERROR_OK; @@ -885,7 +885,7 @@ COMMAND_HANDLER(arm920t_handle_read_cache_command) /* restore CP15 MMU and Cache settings */ arm920t_write_cp15_physical(target, ARM920T_CP15_PHYS_ADDR(0, 0x1, 0), cp15_ctrl_saved); - command_print(cmd_ctx, "cache content successfully output to %s", args[0]); + command_print(cmd_ctx, "cache content successfully output to %s", CMD_ARGV[0]); fclose(output); @@ -934,7 +934,7 @@ COMMAND_HANDLER(arm920t_handle_read_mmu_command) return ERROR_OK; } - if ((output = fopen(args[0], "w")) == NULL) + if ((output = fopen(CMD_ARGV[0], "w")) == NULL) { LOG_DEBUG("error opening mmu content file"); return ERROR_OK; @@ -1168,7 +1168,7 @@ COMMAND_HANDLER(arm920t_handle_read_mmu_command) fprintf(output, "%i: 0x%8.8" PRIx32 " 0x%8.8" PRIx32 " 0x%8.8" PRIx32 " %s\n", i, i_tlb[i].cam, i_tlb[i].ram1, i_tlb[i].ram2, (i_tlb[i].cam & 0x20) ? "(valid)" : "(invalid)"); } - command_print(cmd_ctx, "mmu content successfully output to %s", args[0]); + command_print(cmd_ctx, "mmu content successfully output to %s", CMD_ARGV[0]); fclose(output); @@ -1210,7 +1210,7 @@ COMMAND_HANDLER(arm920t_handle_cp15_command) if (CMD_ARGC >= 1) { int address; - COMMAND_PARSE_NUMBER(int, args[0], address); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], address); if (CMD_ARGC == 1) { @@ -1230,7 +1230,7 @@ COMMAND_HANDLER(arm920t_handle_cp15_command) else if (CMD_ARGC == 2) { uint32_t value; - COMMAND_PARSE_NUMBER(u32, args[1], value); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value); if ((retval = arm920t_write_cp15_physical(target, address, value)) != ERROR_OK) { command_print(cmd_ctx, "couldn't access reg %i", address); @@ -1264,7 +1264,7 @@ COMMAND_HANDLER(arm920t_handle_cp15i_command) if (CMD_ARGC >= 1) { uint32_t opcode; - COMMAND_PARSE_NUMBER(u32, args[0], opcode); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], opcode); if (CMD_ARGC == 1) { @@ -1280,7 +1280,7 @@ COMMAND_HANDLER(arm920t_handle_cp15i_command) else if (CMD_ARGC == 2) { uint32_t value; - COMMAND_PARSE_NUMBER(u32, args[1], value); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value); if ((retval = arm920t_write_cp15_interpreted(target, opcode, value, 0)) != ERROR_OK) { command_print(cmd_ctx, "couldn't execute %8.8" PRIx32 "", opcode); @@ -1291,9 +1291,9 @@ COMMAND_HANDLER(arm920t_handle_cp15i_command) else if (CMD_ARGC == 3) { uint32_t value; - COMMAND_PARSE_NUMBER(u32, args[1], value); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value); uint32_t address; - COMMAND_PARSE_NUMBER(u32, args[2], address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], address); if ((retval = arm920t_write_cp15_interpreted(target, opcode, value, address)) != ERROR_OK) { command_print(cmd_ctx, "couldn't execute %8.8" PRIx32 "", opcode); diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c index 4e206646..66780540 100644 --- a/src/target/arm926ejs.c +++ b/src/target/arm926ejs.c @@ -728,10 +728,10 @@ COMMAND_HANDLER(arm926ejs_handle_cp15_command) return ERROR_OK; } - COMMAND_PARSE_NUMBER(int, args[0], opcode_1); - COMMAND_PARSE_NUMBER(int, args[1], opcode_2); - COMMAND_PARSE_NUMBER(int, args[2], CRn); - COMMAND_PARSE_NUMBER(int, args[3], CRm); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], opcode_1); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], opcode_2); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[2], CRn); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[3], CRm); retval = arm926ejs_verify_pointer(cmd_ctx, arm926ejs); if (retval != ERROR_OK) @@ -761,7 +761,7 @@ COMMAND_HANDLER(arm926ejs_handle_cp15_command) else { uint32_t value; - COMMAND_PARSE_NUMBER(u32, args[4], value); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[4], value); if ((retval = arm926ejs->write_cp15(target, opcode_1, opcode_2, CRn, CRm, value)) != ERROR_OK) { command_print(cmd_ctx, "couldn't access register"); diff --git a/src/target/arm966e.c b/src/target/arm966e.c index 0c08a609..ffc65cde 100644 --- a/src/target/arm966e.c +++ b/src/target/arm966e.c @@ -182,7 +182,7 @@ COMMAND_HANDLER(arm966e_handle_cp15_command) if (CMD_ARGC >= 1) { uint32_t address; - COMMAND_PARSE_NUMBER(u32, args[0], address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], address); if (CMD_ARGC == 1) { @@ -205,7 +205,7 @@ COMMAND_HANDLER(arm966e_handle_cp15_command) else if (CMD_ARGC == 2) { uint32_t value; - COMMAND_PARSE_NUMBER(u32, args[1], value); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value); if ((retval = arm966e_write_cp15(target, address, value)) != ERROR_OK) { command_print(cmd_ctx, diff --git a/src/target/arm9tdmi.c b/src/target/arm9tdmi.c index b582eae3..3f074be8 100644 --- a/src/target/arm9tdmi.c +++ b/src/target/arm9tdmi.c @@ -856,11 +856,11 @@ COMMAND_HANDLER(handle_arm9tdmi_catch_vectors_command) if (CMD_ARGC > 0) { vector_catch_value = 0x0; - if (strcmp(args[0], "all") == 0) + if (strcmp(CMD_ARGV[0], "all") == 0) { vector_catch_value = 0xdf; } - else if (strcmp(args[0], "none") == 0) + else if (strcmp(CMD_ARGV[0], "none") == 0) { /* do nothing */ } @@ -872,7 +872,7 @@ COMMAND_HANDLER(handle_arm9tdmi_catch_vectors_command) unsigned j; for (j = 0; arm9tdmi_vectors[j].name; j++) { - if (strcmp(args[i], arm9tdmi_vectors[j].name) == 0) + if (strcmp(CMD_ARGV[i], arm9tdmi_vectors[j].name) == 0) { vector_catch_value |= arm9tdmi_vectors[j].value; break; @@ -882,7 +882,7 @@ COMMAND_HANDLER(handle_arm9tdmi_catch_vectors_command) /* complain if vector wasn't found */ if (!arm9tdmi_vectors[j].name) { - command_print(cmd_ctx, "vector '%s' not found, leaving current setting unchanged", args[i]); + command_print(cmd_ctx, "vector '%s' not found, leaving current setting unchanged", CMD_ARGV[i]); /* reread current setting */ vector_catch_value = buf_get_u32( diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c index dcae8181..7f4bc58c 100644 --- a/src/target/arm_adi_v5.c +++ b/src/target/arm_adi_v5.c @@ -1375,7 +1375,7 @@ DAP_COMMAND_HANDLER(dap_baseaddr_command) apsel = swjdp->apsel; break; case 1: - COMMAND_PARSE_NUMBER(u32, args[0], apsel); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel); break; default: return ERROR_COMMAND_SYNTAX_ERROR; @@ -1403,7 +1403,7 @@ DAP_COMMAND_HANDLER(dap_memaccess_command) memaccess_tck = swjdp->memaccess_tck; break; case 1: - COMMAND_PARSE_NUMBER(u32, args[0], memaccess_tck); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], memaccess_tck); break; default: return ERROR_COMMAND_SYNTAX_ERROR; @@ -1426,7 +1426,7 @@ DAP_COMMAND_HANDLER(dap_apsel_command) apsel = 0; break; case 1: - COMMAND_PARSE_NUMBER(u32, args[0], apsel); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel); break; default: return ERROR_COMMAND_SYNTAX_ERROR; @@ -1452,7 +1452,7 @@ DAP_COMMAND_HANDLER(dap_apid_command) apsel = swjdp->apsel; break; case 1: - COMMAND_PARSE_NUMBER(u32, args[0], apsel); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel); break; default: return ERROR_COMMAND_SYNTAX_ERROR; diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 4c2a6e54..5f0fe42c 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -424,11 +424,11 @@ COMMAND_HANDLER(handle_armv4_5_core_state_command) if (CMD_ARGC > 0) { - if (strcmp(args[0], "arm") == 0) + if (strcmp(CMD_ARGV[0], "arm") == 0) { armv4_5->core_state = ARMV4_5_STATE_ARM; } - if (strcmp(args[0], "thumb") == 0) + if (strcmp(CMD_ARGV[0], "thumb") == 0) { armv4_5->core_state = ARMV4_5_STATE_THUMB; } @@ -455,15 +455,15 @@ COMMAND_HANDLER(handle_armv4_5_disassemble_command) switch (CMD_ARGC) { case 3: - if (strcmp(args[2], "thumb") != 0) + if (strcmp(CMD_ARGV[2], "thumb") != 0) goto usage; thumb = 1; /* FALL THROUGH */ case 2: - COMMAND_PARSE_NUMBER(int, args[1], count); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], count); /* FALL THROUGH */ case 1: - COMMAND_PARSE_NUMBER(u32, args[0], address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], address); if (address & 0x01) { if (!thumb) { command_print(cmd_ctx, "Disassemble as Thumb"); diff --git a/src/target/armv7a.c b/src/target/armv7a.c index 31ab4b48..7f5b8349 100644 --- a/src/target/armv7a.c +++ b/src/target/armv7a.c @@ -264,7 +264,7 @@ COMMAND_HANDLER(handle_dap_info_command) apsel = swjdp->apsel; break; case 1: - COMMAND_PARSE_NUMBER(u32, args[0], apsel); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel); break; default: return ERROR_COMMAND_SYNTAX_ERROR; diff --git a/src/target/armv7m.c b/src/target/armv7m.c index e9d46dfd..4fe57943 100644 --- a/src/target/armv7m.c +++ b/src/target/armv7m.c @@ -771,7 +771,7 @@ COMMAND_HANDLER(handle_dap_baseaddr_command) apsel = swjdp->apsel; break; case 1: - COMMAND_PARSE_NUMBER(u32, args[0], apsel); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel); break; default: return ERROR_COMMAND_SYNTAX_ERROR; @@ -834,7 +834,7 @@ COMMAND_HANDLER(handle_dap_info_command) apsel = swjdp->apsel; break; case 1: - COMMAND_PARSE_NUMBER(u32, args[0], apsel); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], apsel); break; default: return ERROR_COMMAND_SYNTAX_ERROR; diff --git a/src/target/cortex_m3.c b/src/target/cortex_m3.c index 05844345..9cb4b983 100644 --- a/src/target/cortex_m3.c +++ b/src/target/cortex_m3.c @@ -1782,10 +1782,10 @@ COMMAND_HANDLER(handle_cortex_m3_disassemble_command) errno = 0; switch (CMD_ARGC) { case 2: - COMMAND_PARSE_NUMBER(ulong, args[1], count); + COMMAND_PARSE_NUMBER(ulong, CMD_ARGV[1], count); /* FALL THROUGH */ case 1: - COMMAND_PARSE_NUMBER(u32, args[0], address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], address); break; default: command_print(cmd_ctx, @@ -1836,25 +1836,25 @@ COMMAND_HANDLER(handle_cortex_m3_vector_catch_command) unsigned catch = 0; if (CMD_ARGC == 1) { - if (strcmp(args[0], "all") == 0) { + if (strcmp(CMD_ARGV[0], "all") == 0) { catch = VC_HARDERR | VC_INTERR | VC_BUSERR | VC_STATERR | VC_CHKERR | VC_NOCPERR | VC_MMERR | VC_CORERESET; goto write; - } else if (strcmp(args[0], "none") == 0) { + } else if (strcmp(CMD_ARGV[0], "none") == 0) { goto write; } } while (CMD_ARGC-- > 0) { unsigned i; for (i = 0; i < ARRAY_SIZE(vec_ids); i++) { - if (strcmp(args[CMD_ARGC], vec_ids[i].name) != 0) + if (strcmp(CMD_ARGV[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[CMD_ARGC]); + LOG_ERROR("No CM3 vector '%s'", CMD_ARGV[CMD_ARGC]); return ERROR_INVALID_ARGUMENTS; } } @@ -1892,11 +1892,11 @@ COMMAND_HANDLER(handle_cortex_m3_mask_interrupts_command) if (CMD_ARGC > 0) { - if (!strcmp(args[0], "on")) + if (!strcmp(CMD_ARGV[0], "on")) { cortex_m3_write_debug_halt_mask(target, C_HALT | C_MASKINTS, 0); } - else if (!strcmp(args[0], "off")) + else if (!strcmp(CMD_ARGV[0], "off")) { cortex_m3_write_debug_halt_mask(target, C_HALT, C_MASKINTS); } diff --git a/src/target/etb.c b/src/target/etb.c index 2ad51565..25d6d0b0 100644 --- a/src/target/etb.c +++ b/src/target/etb.c @@ -359,25 +359,25 @@ COMMAND_HANDLER(handle_etb_config_command) return ERROR_COMMAND_SYNTAX_ERROR; } - target = get_target(args[0]); + target = get_target(CMD_ARGV[0]); if (!target) { - LOG_ERROR("ETB: target '%s' not defined", args[0]); + LOG_ERROR("ETB: target '%s' not defined", CMD_ARGV[0]); return ERROR_FAIL; } arm = target_to_arm(target); if (!is_arm(arm)) { - command_print(cmd_ctx, "ETB: '%s' isn't an ARM", args[0]); + command_print(cmd_ctx, "ETB: '%s' isn't an ARM", CMD_ARGV[0]); return ERROR_FAIL; } - tap = jtag_tap_by_string(args[1]); + tap = jtag_tap_by_string(CMD_ARGV[1]); if (tap == NULL) { - command_print(cmd_ctx, "ETB: TAP %s does not exist", args[1]); + command_print(cmd_ctx, "ETB: TAP %s does not exist", CMD_ARGV[1]); return ERROR_FAIL; } diff --git a/src/target/etm.c b/src/target/etm.c index 044ccb06..72e8b3d2 100644 --- a/src/target/etm.c +++ b/src/target/etm.c @@ -1179,22 +1179,22 @@ static COMMAND_HELPER(handle_etm_tracemode_command_update, etmv1_tracemode_t tracemode; /* what parts of data access are traced? */ - if (strcmp(args[0], "none") == 0) + if (strcmp(CMD_ARGV[0], "none") == 0) tracemode = ETMV1_TRACE_NONE; - else if (strcmp(args[0], "data") == 0) + else if (strcmp(CMD_ARGV[0], "data") == 0) tracemode = ETMV1_TRACE_DATA; - else if (strcmp(args[0], "address") == 0) + else if (strcmp(CMD_ARGV[0], "address") == 0) tracemode = ETMV1_TRACE_ADDR; - else if (strcmp(args[0], "all") == 0) + else if (strcmp(CMD_ARGV[0], "all") == 0) tracemode = ETMV1_TRACE_DATA | ETMV1_TRACE_ADDR; else { - command_print(cmd_ctx, "invalid option '%s'", args[0]); + command_print(cmd_ctx, "invalid option '%s'", CMD_ARGV[0]); return ERROR_INVALID_ARGUMENTS; } uint8_t context_id; - COMMAND_PARSE_NUMBER(u8, args[1], context_id); + COMMAND_PARSE_NUMBER(u8, CMD_ARGV[1], context_id); switch (context_id) { case 0: @@ -1210,27 +1210,27 @@ static COMMAND_HELPER(handle_etm_tracemode_command_update, tracemode |= ETMV1_CONTEXTID_32; break; default: - command_print(cmd_ctx, "invalid option '%s'", args[1]); + command_print(cmd_ctx, "invalid option '%s'", CMD_ARGV[1]); return ERROR_INVALID_ARGUMENTS; } - if (strcmp(args[2], "enable") == 0) + if (strcmp(CMD_ARGV[2], "enable") == 0) tracemode |= ETMV1_CYCLE_ACCURATE; - else if (strcmp(args[2], "disable") == 0) + else if (strcmp(CMD_ARGV[2], "disable") == 0) tracemode |= 0; else { - command_print(cmd_ctx, "invalid option '%s'", args[2]); + command_print(cmd_ctx, "invalid option '%s'", CMD_ARGV[2]); return ERROR_INVALID_ARGUMENTS; } - if (strcmp(args[3], "enable") == 0) + if (strcmp(CMD_ARGV[3], "enable") == 0) tracemode |= ETMV1_BRANCH_OUTPUT; - else if (strcmp(args[3], "disable") == 0) + else if (strcmp(CMD_ARGV[3], "disable") == 0) tracemode |= 0; else { - command_print(cmd_ctx, "invalid option '%s'", args[3]); + command_print(cmd_ctx, "invalid option '%s'", CMD_ARGV[3]); return ERROR_INVALID_ARGUMENTS; } @@ -1377,10 +1377,10 @@ COMMAND_HANDLER(handle_etm_config_command) if (CMD_ARGC != 5) return ERROR_COMMAND_SYNTAX_ERROR; - target = get_target(args[0]); + target = get_target(CMD_ARGV[0]); if (!target) { - LOG_ERROR("target '%s' not defined", args[0]); + LOG_ERROR("target '%s' not defined", CMD_ARGV[0]); return ERROR_FAIL; } @@ -1404,7 +1404,7 @@ COMMAND_HANDLER(handle_etm_config_command) * "normal full" ... */ uint8_t port_width; - COMMAND_PARSE_NUMBER(u8, args[1], port_width); + COMMAND_PARSE_NUMBER(u8, CMD_ARGV[1], port_width); switch (port_width) { /* before ETMv3.0 */ @@ -1438,39 +1438,39 @@ COMMAND_HANDLER(handle_etm_config_command) break; default: command_print(cmd_ctx, - "unsupported ETM port width '%s'", args[1]); + "unsupported ETM port width '%s'", CMD_ARGV[1]); return ERROR_FAIL; } - if (strcmp("normal", args[2]) == 0) + if (strcmp("normal", CMD_ARGV[2]) == 0) { portmode |= ETM_PORT_NORMAL; } - else if (strcmp("multiplexed", args[2]) == 0) + else if (strcmp("multiplexed", CMD_ARGV[2]) == 0) { portmode |= ETM_PORT_MUXED; } - else if (strcmp("demultiplexed", args[2]) == 0) + else if (strcmp("demultiplexed", CMD_ARGV[2]) == 0) { portmode |= ETM_PORT_DEMUXED; } else { - command_print(cmd_ctx, "unsupported ETM port mode '%s', must be 'normal', 'multiplexed' or 'demultiplexed'", args[2]); + command_print(cmd_ctx, "unsupported ETM port mode '%s', must be 'normal', 'multiplexed' or 'demultiplexed'", CMD_ARGV[2]); return ERROR_FAIL; } - if (strcmp("half", args[3]) == 0) + if (strcmp("half", CMD_ARGV[3]) == 0) { portmode |= ETM_PORT_HALF_CLOCK; } - else if (strcmp("full", args[3]) == 0) + else if (strcmp("full", CMD_ARGV[3]) == 0) { portmode |= ETM_PORT_FULL_CLOCK; } else { - command_print(cmd_ctx, "unsupported ETM port clocking '%s', must be 'full' or 'half'", args[3]); + command_print(cmd_ctx, "unsupported ETM port clocking '%s', must be 'full' or 'half'", CMD_ARGV[3]); return ERROR_FAIL; } @@ -1482,7 +1482,7 @@ COMMAND_HANDLER(handle_etm_config_command) for (i = 0; etm_capture_drivers[i]; i++) { - if (strcmp(args[4], etm_capture_drivers[i]->name) == 0) + if (strcmp(CMD_ARGV[4], etm_capture_drivers[i]->name) == 0) { int retval; if ((retval = etm_capture_drivers[i]->register_commands(cmd_ctx)) != ERROR_OK) @@ -1501,7 +1501,7 @@ COMMAND_HANDLER(handle_etm_config_command) { /* no supported capture driver found, don't register an ETM */ free(etm_ctx); - LOG_ERROR("trace capture driver '%s' not found", args[4]); + LOG_ERROR("trace capture driver '%s' not found", CMD_ARGV[4]); return ERROR_FAIL; } @@ -1766,14 +1766,14 @@ COMMAND_HANDLER(handle_etm_image_command) if (CMD_ARGC >= 2) { etm_ctx->image->base_address_set = 1; - COMMAND_PARSE_NUMBER(int, args[1], etm_ctx->image->base_address); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], etm_ctx->image->base_address); } else { etm_ctx->image->base_address_set = 0; } - if (image_open(etm_ctx->image, args[0], (CMD_ARGC >= 3) ? args[2] : NULL) != ERROR_OK) + if (image_open(etm_ctx->image, CMD_ARGV[0], (CMD_ARGC >= 3) ? CMD_ARGV[2] : NULL) != ERROR_OK) { free(etm_ctx->image); etm_ctx->image = NULL; @@ -1829,7 +1829,7 @@ COMMAND_HANDLER(handle_etm_dump_command) if (etm_ctx->trace_depth == 0) etm_ctx->capture_driver->read_trace(etm_ctx); - if (fileio_open(&file, args[0], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK) + if (fileio_open(&file, CMD_ARGV[0], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK) { return ERROR_FAIL; } @@ -1886,7 +1886,7 @@ COMMAND_HANDLER(handle_etm_load_command) return ERROR_FAIL; } - if (fileio_open(&file, args[0], FILEIO_READ, FILEIO_BINARY) != ERROR_OK) + if (fileio_open(&file, CMD_ARGV[0], FILEIO_READ, FILEIO_BINARY) != ERROR_OK) { return ERROR_FAIL; } @@ -1959,7 +1959,7 @@ COMMAND_HANDLER(handle_etm_trigger_percent_command) if (CMD_ARGC > 0) { uint32_t new_value; - COMMAND_PARSE_NUMBER(u32, args[0], new_value); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], new_value); if ((new_value < 2) || (new_value > 100)) { diff --git a/src/target/etm_dummy.c b/src/target/etm_dummy.c index b0ab1fb8..ae538024 100644 --- a/src/target/etm_dummy.c +++ b/src/target/etm_dummy.c @@ -30,18 +30,18 @@ COMMAND_HANDLER(handle_etm_dummy_config_command) struct target *target; struct arm *arm; - target = get_target(args[0]); + target = get_target(CMD_ARGV[0]); if (!target) { - LOG_ERROR("target '%s' not defined", args[0]); + LOG_ERROR("target '%s' not defined", CMD_ARGV[0]); return ERROR_FAIL; } arm = target_to_arm(target); if (!is_arm(arm)) { - command_print(cmd_ctx, "target '%s' isn't an ARM", args[0]); + command_print(cmd_ctx, "target '%s' isn't an ARM", CMD_ARGV[0]); return ERROR_FAIL; } diff --git a/src/target/oocd_trace.c b/src/target/oocd_trace.c index 47c2bb49..74f89552 100644 --- a/src/target/oocd_trace.c +++ b/src/target/oocd_trace.c @@ -316,7 +316,7 @@ COMMAND_HANDLER(handle_oocd_trace_config_command) oocd_trace->etm_ctx = arm->etm; /* copy name of TTY device used to communicate with OpenOCD + trace */ - oocd_trace->tty = strndup(args[1], 256); + oocd_trace->tty = strndup(CMD_ARGV[1], 256); } else { diff --git a/src/target/target.c b/src/target/target.c index 88fea177..31431804 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -1650,9 +1650,9 @@ COMMAND_HANDLER(handle_targets_command) if (CMD_ARGC == 1) { - target = get_target(args[0]); + target = get_target(CMD_ARGV[0]); if (target == NULL) { - command_print(cmd_ctx,"Target: %s is unknown, try one of:\n", args[0]); + command_print(cmd_ctx,"Target: %s is unknown, try one of:\n", CMD_ARGV[0]); goto DumpTargets; } if (!target->tap->enabled) { @@ -1908,10 +1908,10 @@ COMMAND_HANDLER(handle_reg_command) } /* access a single register by its ordinal number */ - if ((args[0][0] >= '0') && (args[0][0] <= '9')) + if ((CMD_ARGV[0][0] >= '0') && (CMD_ARGV[0][0] <= '9')) { unsigned num; - COMMAND_PARSE_NUMBER(uint, args[0], num); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num); struct reg_cache *cache = target->reg_cache; count = 0; @@ -1938,19 +1938,19 @@ COMMAND_HANDLER(handle_reg_command) } } else /* access a single register by its name */ { - reg = register_get_by_name(target->reg_cache, args[0], 1); + reg = register_get_by_name(target->reg_cache, CMD_ARGV[0], 1); if (!reg) { - command_print(cmd_ctx, "register %s not found in current target", args[0]); + command_print(cmd_ctx, "register %s not found in current target", CMD_ARGV[0]); return ERROR_OK; } } /* display a register */ - if ((CMD_ARGC == 1) || ((CMD_ARGC == 2) && !((args[1][0] >= '0') && (args[1][0] <= '9')))) + if ((CMD_ARGC == 1) || ((CMD_ARGC == 2) && !((CMD_ARGV[1][0] >= '0') && (CMD_ARGV[1][0] <= '9')))) { - if ((CMD_ARGC == 2) && (strcmp(args[1], "force") == 0)) + if ((CMD_ARGC == 2) && (strcmp(CMD_ARGV[1], "force") == 0)) reg->valid = 0; if (reg->valid == 0) @@ -1967,7 +1967,7 @@ COMMAND_HANDLER(handle_reg_command) 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); + str_to_buf(CMD_ARGV[1], strlen(CMD_ARGV[1]), buf, reg->size, 0); reg->type->set(reg, buf); @@ -2007,11 +2007,11 @@ COMMAND_HANDLER(handle_poll_command) } else if (CMD_ARGC == 1) { - if (strcmp(args[0], "on") == 0) + if (strcmp(CMD_ARGV[0], "on") == 0) { jtag_poll_set_enabled(true); } - else if (strcmp(args[0], "off") == 0) + else if (strcmp(CMD_ARGV[0], "off") == 0) { jtag_poll_set_enabled(false); } @@ -2035,7 +2035,7 @@ COMMAND_HANDLER(handle_wait_halt_command) unsigned ms = 5000; if (1 == CMD_ARGC) { - int retval = parse_uint(args[0], &ms); + int retval = parse_uint(CMD_ARGV[0], &ms); if (ERROR_OK != retval) { command_print(cmd_ctx, "usage: %s [seconds]", CMD_NAME); @@ -2106,7 +2106,7 @@ COMMAND_HANDLER(handle_halt_command) if (CMD_ARGC == 1) { unsigned wait; - retval = parse_uint(args[0], &wait); + retval = parse_uint(CMD_ARGV[0], &wait); if (ERROR_OK != retval) return ERROR_COMMAND_SYNTAX_ERROR; if (!wait) @@ -2136,7 +2136,7 @@ COMMAND_HANDLER(handle_reset_command) if (CMD_ARGC == 1) { const Jim_Nvp *n; - n = Jim_Nvp_name2value_simple(nvp_reset_modes, args[0]); + n = Jim_Nvp_name2value_simple(nvp_reset_modes, CMD_ARGV[0]); if ((n->name == NULL) || (n->value == RESET_UNKNOWN)) { return ERROR_COMMAND_SYNTAX_ERROR; } @@ -2157,13 +2157,13 @@ COMMAND_HANDLER(handle_resume_command) struct target *target = get_current_target(cmd_ctx); target_handle_event(target, TARGET_EVENT_OLD_pre_resume); - /* with no args, resume from current pc, addr = 0, - * with one arguments, addr = args[0], + /* with no CMD_ARGV, resume from current pc, addr = 0, + * with one arguments, addr = CMD_ARGV[0], * handle breakpoints, not debugging */ uint32_t addr = 0; if (CMD_ARGC == 1) { - COMMAND_PARSE_NUMBER(u32, args[0], addr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], addr); current = 0; } @@ -2177,14 +2177,14 @@ COMMAND_HANDLER(handle_step_command) LOG_DEBUG("-"); - /* with no args, step from current pc, addr = 0, - * with one argument addr = args[0], + /* with no CMD_ARGV, step from current pc, addr = 0, + * with one argument addr = CMD_ARGV[0], * handle breakpoints, debugging */ uint32_t addr = 0; int current_pc = 1; if (CMD_ARGC == 1) { - COMMAND_PARSE_NUMBER(u32, args[0], addr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], addr); current_pc = 0; } @@ -2256,13 +2256,13 @@ COMMAND_HANDLER(handle_md_command) default: return ERROR_COMMAND_SYNTAX_ERROR; } - bool physical=strcmp(args[0], "phys")==0; + bool physical=strcmp(CMD_ARGV[0], "phys")==0; int (*fn)(struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer); if (physical) { CMD_ARGC--; - args++; + CMD_ARGV++; fn=target_read_phys_memory; } else { @@ -2274,11 +2274,11 @@ COMMAND_HANDLER(handle_md_command) } uint32_t address; - COMMAND_PARSE_NUMBER(u32, args[0], address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], address); unsigned count = 1; if (CMD_ARGC == 2) - COMMAND_PARSE_NUMBER(uint, args[1], count); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[1], count); uint8_t *buffer = calloc(count, size); @@ -2298,14 +2298,14 @@ COMMAND_HANDLER(handle_mw_command) { return ERROR_COMMAND_SYNTAX_ERROR; } - bool physical=strcmp(args[0], "phys")==0; + bool physical=strcmp(CMD_ARGV[0], "phys")==0; int (*fn)(struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer); const char *cmd_name = CMD_NAME; if (physical) { CMD_ARGC--; - args++; + CMD_ARGV++; fn=target_write_phys_memory; } else { @@ -2315,14 +2315,14 @@ COMMAND_HANDLER(handle_mw_command) return ERROR_COMMAND_SYNTAX_ERROR; uint32_t address; - COMMAND_PARSE_NUMBER(u32, args[0], address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], address); uint32_t value; - COMMAND_PARSE_NUMBER(u32, args[1], value); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value); unsigned count = 1; if (CMD_ARGC == 3) - COMMAND_PARSE_NUMBER(uint, args[2], count); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[2], count); struct target *target = get_current_target(cmd_ctx); unsigned wordsize; @@ -2357,7 +2357,7 @@ COMMAND_HANDLER(handle_mw_command) } -static COMMAND_HELPER(parse_load_image_command_args, struct image *image, +static COMMAND_HELPER(parse_load_image_command_CMD_ARGV, struct image *image, uint32_t *min_address, uint32_t *max_address) { if (CMD_ARGC < 1 || CMD_ARGC > 5) @@ -2368,7 +2368,7 @@ static COMMAND_HELPER(parse_load_image_command_args, struct image *image, if (CMD_ARGC >= 2) { uint32_t addr; - COMMAND_PARSE_NUMBER(u32, args[1], addr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], addr); image->base_address = addr; image->base_address_set = 1; } @@ -2379,11 +2379,11 @@ static COMMAND_HELPER(parse_load_image_command_args, struct image *image, if (CMD_ARGC >= 4) { - COMMAND_PARSE_NUMBER(u32, args[3], *min_address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[3], *min_address); } if (CMD_ARGC == 5) { - COMMAND_PARSE_NUMBER(u32, args[4], *max_address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[4], *max_address); // use size (given) to find max (required) *max_address += *min_address; } @@ -2404,7 +2404,7 @@ COMMAND_HANDLER(handle_load_image_command) int i; struct image image; - int retval = CALL_COMMAND_HANDLER(parse_load_image_command_args, + int retval = CALL_COMMAND_HANDLER(parse_load_image_command_CMD_ARGV, &image, &min_address, &max_address); if (ERROR_OK != retval) return retval; @@ -2414,7 +2414,7 @@ COMMAND_HANDLER(handle_load_image_command) struct duration bench; duration_start(&bench); - if (image_open(&image, args[0], (CMD_ARGC >= 3) ? args[2] : NULL) != ERROR_OK) + if (image_open(&image, CMD_ARGV[0], (CMD_ARGC >= 3) ? CMD_ARGV[2] : NULL) != ERROR_OK) { return ERROR_OK; } @@ -2502,11 +2502,11 @@ COMMAND_HANDLER(handle_dump_image_command) } uint32_t address; - COMMAND_PARSE_NUMBER(u32, args[1], address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], address); uint32_t size; - COMMAND_PARSE_NUMBER(u32, args[2], size); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], size); - if (fileio_open(&fileio, args[0], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK) + if (fileio_open(&fileio, CMD_ARGV[0], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK) { return ERROR_OK; } @@ -2579,7 +2579,7 @@ static COMMAND_HELPER(handle_verify_image_command_internal, int verify) if (CMD_ARGC >= 2) { uint32_t addr; - COMMAND_PARSE_NUMBER(u32, args[1], addr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], addr); image.base_address = addr; image.base_address_set = 1; } @@ -2591,7 +2591,7 @@ static COMMAND_HELPER(handle_verify_image_command_internal, int verify) image.start_address_set = 0; - if ((retval = image_open(&image, args[0], (CMD_ARGC == 3) ? args[2] : NULL)) != ERROR_OK) + if ((retval = image_open(&image, CMD_ARGV[0], (CMD_ARGC == 3) ? CMD_ARGV[2] : NULL)) != ERROR_OK) { return retval; } @@ -2755,14 +2755,14 @@ COMMAND_HANDLER(handle_bp_command) } uint32_t addr; - COMMAND_PARSE_NUMBER(u32, args[0], addr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], addr); uint32_t length; - COMMAND_PARSE_NUMBER(u32, args[1], length); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], length); int hw = BKPT_SOFT; if (CMD_ARGC == 3) { - if (strcmp(args[2], "hw") == 0) + if (strcmp(CMD_ARGV[2], "hw") == 0) hw = BKPT_HARD; else return ERROR_COMMAND_SYNTAX_ERROR; @@ -2777,7 +2777,7 @@ COMMAND_HANDLER(handle_rbp_command) return ERROR_COMMAND_SYNTAX_ERROR; uint32_t addr; - COMMAND_PARSE_NUMBER(u32, args[0], addr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], addr); struct target *target = get_current_target(cmd_ctx); breakpoint_remove(target, addr); @@ -2818,13 +2818,13 @@ COMMAND_HANDLER(handle_wp_command) switch (CMD_ARGC) { case 5: - COMMAND_PARSE_NUMBER(u32, args[4], data_mask); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[4], data_mask); // fall through case 4: - COMMAND_PARSE_NUMBER(u32, args[3], data_value); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[3], data_value); // fall through case 3: - switch (args[2][0]) + switch (CMD_ARGV[2][0]) { case 'r': type = WPT_READ; @@ -2836,13 +2836,13 @@ COMMAND_HANDLER(handle_wp_command) type = WPT_ACCESS; break; default: - LOG_ERROR("invalid watchpoint mode ('%c')", args[2][0]); + LOG_ERROR("invalid watchpoint mode ('%c')", CMD_ARGV[2][0]); return ERROR_COMMAND_SYNTAX_ERROR; } // fall through case 2: - COMMAND_PARSE_NUMBER(u32, args[1], length); - COMMAND_PARSE_NUMBER(u32, args[0], addr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], length); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], addr); break; default: @@ -2865,7 +2865,7 @@ COMMAND_HANDLER(handle_rwp_command) return ERROR_COMMAND_SYNTAX_ERROR; uint32_t addr; - COMMAND_PARSE_NUMBER(u32, args[0], addr); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], addr); struct target *target = get_current_target(cmd_ctx); watchpoint_remove(target, addr); @@ -2886,7 +2886,7 @@ COMMAND_HANDLER(handle_virt2phys_command) return ERROR_COMMAND_SYNTAX_ERROR; uint32_t va; - COMMAND_PARSE_NUMBER(u32, args[0], va); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], va); uint32_t pa; struct target *target = get_current_target(cmd_ctx); @@ -3025,7 +3025,7 @@ COMMAND_HANDLER(handle_profile_command) return ERROR_COMMAND_SYNTAX_ERROR; } unsigned offset; - COMMAND_PARSE_NUMBER(uint, args[0], offset); + COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], offset); timeval_add_time(&timeout, offset, 0); @@ -3088,8 +3088,8 @@ COMMAND_HANDLER(handle_profile_command) free(samples); return retval; } - writeGmon(samples, numSamples, args[1]); - command_print(cmd_ctx, "Wrote %s", args[1]); + writeGmon(samples, numSamples, CMD_ARGV[1]); + command_print(cmd_ctx, "Wrote %s", CMD_ARGV[1]); break; } } @@ -4543,7 +4543,7 @@ COMMAND_HANDLER(handle_fast_load_image_command) struct image image; - int retval = CALL_COMMAND_HANDLER(parse_load_image_command_args, + int retval = CALL_COMMAND_HANDLER(parse_load_image_command_CMD_ARGV, &image, &min_address, &max_address); if (ERROR_OK != retval) return retval; @@ -4551,7 +4551,7 @@ COMMAND_HANDLER(handle_fast_load_image_command) struct duration bench; duration_start(&bench); - if (image_open(&image, args[0], (CMD_ARGC >= 3) ? args[2] : NULL) != ERROR_OK) + if (image_open(&image, CMD_ARGV[0], (CMD_ARGC >= 3) ? CMD_ARGV[2] : NULL) != ERROR_OK) { return ERROR_OK; } @@ -4795,7 +4795,7 @@ int target_register_user_commands(struct command_context *cmd_ctx) register_command(cmd_ctx, NULL, "fast_load_image", handle_fast_load_image_command, COMMAND_ANY, - "same args as load_image, image stored in memory " + "same CMD_ARGV as load_image, image stored in memory " "- mainly for profiling purposes"); register_command(cmd_ctx, NULL, "fast_load", diff --git a/src/target/target_request.c b/src/target/target_request.c index c5de691a..1d618cc5 100644 --- a/src/target/target_request.c +++ b/src/target/target_request.c @@ -270,7 +270,7 @@ COMMAND_HANDLER(handle_target_request_debugmsgs_command) if (CMD_ARGC > 0) { - if (!strcmp(args[0], "enable") || !strcmp(args[0], "charmsg")) + if (!strcmp(CMD_ARGV[0], "enable") || !strcmp(CMD_ARGV[0], "charmsg")) { /* don't register if this command context is already receiving */ if (!receiving) @@ -278,9 +278,9 @@ COMMAND_HANDLER(handle_target_request_debugmsgs_command) receiving = 1; add_debug_msg_receiver(cmd_ctx, target); } - charmsg_mode = !strcmp(args[0], "charmsg"); + charmsg_mode = !strcmp(CMD_ARGV[0], "charmsg"); } - else if (!strcmp(args[0], "disable")) + else if (!strcmp(CMD_ARGV[0], "disable")) { /* no need to delete a receiver if none is registered */ if (receiving) diff --git a/src/target/trace.c b/src/target/trace.c index 88f4ed32..f2fd790c 100644 --- a/src/target/trace.c +++ b/src/target/trace.c @@ -66,7 +66,7 @@ COMMAND_HANDLER(handle_trace_point_command) return ERROR_OK; } - if (!strcmp(args[0], "clear")) + if (!strcmp(CMD_ARGV[0], "clear")) { if (trace->trace_points) { @@ -87,7 +87,7 @@ COMMAND_HANDLER(handle_trace_point_command) } uint32_t address; - COMMAND_PARSE_NUMBER(u32, args[0], address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], address); trace->trace_points[trace->num_trace_points].address = address; trace->trace_points[trace->num_trace_points].hit_counter = 0; trace->num_trace_points++; @@ -105,7 +105,7 @@ COMMAND_HANDLER(handle_trace_history_command) trace->trace_history_pos = 0; trace->trace_history_overflowed = 0; - if (!strcmp(args[0], "clear")) + if (!strcmp(CMD_ARGV[0], "clear")) { /* clearing is implicit, we've just reset position anyway */ return ERROR_OK; @@ -114,7 +114,7 @@ COMMAND_HANDLER(handle_trace_history_command) if (trace->trace_history) free(trace->trace_history); - COMMAND_PARSE_NUMBER(u32, args[0], trace->trace_history_size); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], trace->trace_history_size); trace->trace_history = malloc(sizeof(uint32_t) * trace->trace_history_size); command_print(cmd_ctx, "new trace history size: %i", (int)(trace->trace_history_size)); diff --git a/src/target/xscale.c b/src/target/xscale.c index 3af28d05..9500a33b 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -3001,9 +3001,9 @@ COMMAND_HANDLER(xscale_handle_debug_handler_command) return ERROR_OK; } - if ((target = get_target(args[0])) == NULL) + if ((target = get_target(CMD_ARGV[0])) == NULL) { - LOG_ERROR("target '%s' not defined", args[0]); + LOG_ERROR("target '%s' not defined", CMD_ARGV[0]); return ERROR_FAIL; } @@ -3012,7 +3012,7 @@ COMMAND_HANDLER(xscale_handle_debug_handler_command) if (retval != ERROR_OK) return retval; - COMMAND_PARSE_NUMBER(u32, args[1], handler_address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], handler_address); if (((handler_address >= 0x800) && (handler_address <= 0x1fef800)) || ((handler_address >= 0xfe000800) && (handler_address <= 0xfffff800))) @@ -3040,10 +3040,10 @@ COMMAND_HANDLER(xscale_handle_cache_clean_address_command) return ERROR_COMMAND_SYNTAX_ERROR; } - target = get_target(args[0]); + target = get_target(CMD_ARGV[0]); if (target == NULL) { - LOG_ERROR("target '%s' not defined", args[0]); + LOG_ERROR("target '%s' not defined", CMD_ARGV[0]); return ERROR_FAIL; } xscale = target_to_xscale(target); @@ -3051,7 +3051,7 @@ COMMAND_HANDLER(xscale_handle_cache_clean_address_command) if (retval != ERROR_OK) return retval; - COMMAND_PARSE_NUMBER(u32, args[1], cache_clean_address); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], cache_clean_address); if (cache_clean_address & 0xffff) { @@ -3132,12 +3132,12 @@ COMMAND_HANDLER(xscale_handle_mmu_command) if (CMD_ARGC >= 1) { - if (strcmp("enable", args[0]) == 0) + if (strcmp("enable", CMD_ARGV[0]) == 0) { xscale_enable_mmu_caches(target, 1, 0, 0); xscale->armv4_5_mmu.mmu_enabled = 1; } - else if (strcmp("disable", args[0]) == 0) + else if (strcmp("disable", CMD_ARGV[0]) == 0) { xscale_disable_mmu_caches(target, 1, 0, 0); xscale->armv4_5_mmu.mmu_enabled = 0; @@ -3173,7 +3173,7 @@ COMMAND_HANDLER(xscale_handle_idcache_command) if (CMD_ARGC >= 1) { - if (strcmp("enable", args[0]) == 0) + if (strcmp("enable", CMD_ARGV[0]) == 0) { xscale_enable_mmu_caches(target, 0, dcache, icache); @@ -3182,7 +3182,7 @@ COMMAND_HANDLER(xscale_handle_idcache_command) else if (dcache) xscale->armv4_5_mmu.armv4_5_cache.d_u_cache_enabled = 1; } - else if (strcmp("disable", args[0]) == 0) + else if (strcmp("disable", CMD_ARGV[0]) == 0) { xscale_disable_mmu_caches(target, 0, dcache, icache); @@ -3218,7 +3218,7 @@ COMMAND_HANDLER(xscale_handle_vector_catch_command) } else { - COMMAND_PARSE_NUMBER(u8, args[0], xscale->vector_catch); + COMMAND_PARSE_NUMBER(u8, CMD_ARGV[0], xscale->vector_catch); buf_set_u32(xscale->reg_cache->reg_list[XSCALE_DCSR].value, 16, 8, xscale->vector_catch); xscale_write_dcsr(target, -1, -1); } @@ -3259,19 +3259,19 @@ COMMAND_HANDLER(xscale_handle_vector_table_command) else { int idx; - COMMAND_PARSE_NUMBER(int, args[1], idx); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], idx); uint32_t vec; - COMMAND_PARSE_NUMBER(u32, args[2], vec); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], vec); if (idx < 1 || idx >= 8) err = 1; - if (!err && strcmp(args[0], "low") == 0) + if (!err && strcmp(CMD_ARGV[0], "low") == 0) { xscale->static_low_vectors_set |= (1<static_low_vectors[idx] = vec; } - else if (!err && (strcmp(args[0], "high") == 0)) + else if (!err && (strcmp(CMD_ARGV[0], "high") == 0)) { xscale->static_high_vectors_set |= (1<static_high_vectors[idx] = vec; @@ -3305,7 +3305,7 @@ COMMAND_HANDLER(xscale_handle_trace_buffer_command) return ERROR_OK; } - if ((CMD_ARGC >= 1) && (strcmp("enable", args[0]) == 0)) + if ((CMD_ARGC >= 1) && (strcmp("enable", CMD_ARGV[0]) == 0)) { struct xscale_trace_data *td, *next_td; xscale->trace.buffer_enabled = 1; @@ -3323,19 +3323,19 @@ COMMAND_HANDLER(xscale_handle_trace_buffer_command) } xscale->trace.data = NULL; } - else if ((CMD_ARGC >= 1) && (strcmp("disable", args[0]) == 0)) + else if ((CMD_ARGC >= 1) && (strcmp("disable", CMD_ARGV[0]) == 0)) { xscale->trace.buffer_enabled = 0; } - if ((CMD_ARGC >= 2) && (strcmp("fill", args[1]) == 0)) + if ((CMD_ARGC >= 2) && (strcmp("fill", CMD_ARGV[1]) == 0)) { uint32_t fill = 1; if (CMD_ARGC >= 3) - COMMAND_PARSE_NUMBER(u32, args[2], fill); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], fill); xscale->trace.buffer_fill = fill; } - else if ((CMD_ARGC >= 2) && (strcmp("wrap", args[1]) == 0)) + else if ((CMD_ARGC >= 2) && (strcmp("wrap", CMD_ARGV[1]) == 0)) { xscale->trace.buffer_fill = -1; } @@ -3397,14 +3397,14 @@ COMMAND_HANDLER(xscale_handle_trace_image_command) if (CMD_ARGC >= 2) { xscale->trace.image->base_address_set = 1; - COMMAND_PARSE_NUMBER(int, args[1], xscale->trace.image->base_address); + COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], xscale->trace.image->base_address); } else { xscale->trace.image->base_address_set = 0; } - if (image_open(xscale->trace.image, args[0], (CMD_ARGC >= 3) ? args[2] : NULL) != ERROR_OK) + if (image_open(xscale->trace.image, CMD_ARGV[0], (CMD_ARGC >= 3) ? CMD_ARGV[2] : NULL) != ERROR_OK) { free(xscale->trace.image); xscale->trace.image = NULL; @@ -3446,7 +3446,7 @@ COMMAND_HANDLER(xscale_handle_dump_trace_command) return ERROR_OK; } - if (fileio_open(&file, args[0], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK) + if (fileio_open(&file, CMD_ARGV[0], FILEIO_WRITE, FILEIO_BINARY) != ERROR_OK) { return ERROR_OK; } @@ -3505,7 +3505,7 @@ COMMAND_HANDLER(xscale_handle_cp15) struct reg *reg = NULL; if (CMD_ARGC > 0) { - COMMAND_PARSE_NUMBER(u32, args[0], reg_no); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], reg_no); /*translate from xscale cp15 register no to openocd register*/ switch (reg_no) { @@ -3552,7 +3552,7 @@ COMMAND_HANDLER(xscale_handle_cp15) else if (CMD_ARGC == 2) { uint32_t value; - COMMAND_PARSE_NUMBER(u32, args[1], value); + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], value); /* send CP write request (command 0x41) */ xscale_send_u32(target, 0x41); diff --git a/src/xsvf/xsvf.c b/src/xsvf/xsvf.c index 311acc60..1fe0b867 100644 --- a/src/xsvf/xsvf.c +++ b/src/xsvf/xsvf.c @@ -225,15 +225,15 @@ COMMAND_HANDLER(handle_xsvf_command) return ERROR_FAIL; } - /* we mess with args starting point below, snapshot filename here */ - const char *filename = args[1]; + /* we mess with CMD_ARGV starting point below, snapshot filename here */ + const char *filename = CMD_ARGV[1]; - if (strcmp(args[0], "plain") != 0) + if (strcmp(CMD_ARGV[0], "plain") != 0) { - tap = jtag_tap_by_string(args[0]); + tap = jtag_tap_by_string(CMD_ARGV[0]); if (!tap) { - command_print(cmd_ctx, "Tap: %s unknown", args[0]); + command_print(cmd_ctx, "Tap: %s unknown", CMD_ARGV[0]); return ERROR_FAIL; } } @@ -245,14 +245,14 @@ COMMAND_HANDLER(handle_xsvf_command) } /* if this argument is present, then interpret xruntest counts as TCK cycles rather than as usecs */ - if ((CMD_ARGC > 2) && (strcmp(args[2], "virt2") == 0)) + if ((CMD_ARGC > 2) && (strcmp(CMD_ARGV[2], "virt2") == 0)) { runtest_requires_tck = 1; --CMD_ARGC; - ++args; + ++CMD_ARGV; } - if ((CMD_ARGC > 2) && (strcmp(args[2], "quiet") == 0)) + if ((CMD_ARGC > 2) && (strcmp(CMD_ARGV[2], "quiet") == 0)) { verbose = 0; }