"/rom",
"romfs",
"",
- (CYG_ADDRWORD) &filedata[0] );
+ (CYG_ADDRWORD) &filedata[0]);
#endif
void openocd_sleep_prelude(void)
// "romfs", // FIlesystem type
// "", // hardware device
// (CYG_ADDRWORD) CYGNUM_FS_ROM_BASE_ADDRESS // Address in ROM
-// );
+//);
// -------------------------------------------------------------------------
static int aduc702x_info(struct flash_bank_s *bank, char *buf, int buf_size)
{
- snprintf(buf, buf_size, "aduc702x flash driver info" );
+ snprintf(buf, buf_size, "aduc702x flash driver info");
return ERROR_OK;
}
}
/* Prescaler adjust */
- if ((((mckr & PMC_MCKR_PRES) >> 2) == 7) || (tmp == 0) )
+ if ((((mckr & PMC_MCKR_PRES) >> 2) == 7) || (tmp == 0))
{
at91sam7_info->mck_valid = 0;
at91sam7_info->mck_freq = 0;
at91sam7_protect_check(t_bank);
}
- LOG_DEBUG("nvptyp: 0x%3.3x, arch: 0x%4.4x", at91sam7_info->cidr_nvptyp, at91sam7_info->cidr_arch );
+ LOG_DEBUG("nvptyp: 0x%3.3x, arch: 0x%4.4x", at91sam7_info->cidr_nvptyp, at91sam7_info->cidr_arch);
return ERROR_OK;
}
return ERROR_FAIL;
}
- LOG_INFO("device id = 0x%08" PRIx32 "", device_id );
+ LOG_INFO("device id = 0x%08" PRIx32 "", device_id);
if (EXTRACT_MFG(device_id) != 0x1F)
{
LOG_ERROR("0x%" PRIx32 " is invalid Manufacturer for avr, 0x%X is expected", EXTRACT_MFG(device_id), 0x1F);
return ERROR_FAIL;
}
- LOG_INFO("device id = 0x%08" PRIx32 "", device_id );
+ LOG_INFO("device id = 0x%08" PRIx32 "", device_id);
if (EXTRACT_MFG(device_id) != 0x1F)
{
LOG_ERROR("0x%" PRIx32 " is invalid Manufacturer for avr, 0x%X is expected", EXTRACT_MFG(device_id), 0x1F);
uint8_t i;
for (i = 0;i < 2;i++)
target_read_memory(target, flash_address(bank, sector, offset + i), bank->bus_width, 1,
- &data[i*bank->bus_width] );
+ &data[i*bank->bus_width]);
}
else
target_read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 2, data);
uint8_t i;
for (i = 0;i < 4;i++)
target_read_memory(target, flash_address(bank, sector, offset + i), bank->bus_width, 1,
- &data[i*bank->bus_width] );
+ &data[i*bank->bus_width]);
}
else
target_read_memory(target, flash_address(bank, sector, offset), bank->bus_width, 4, data);
/* flash write code */
if (!cfi_info->write_algorithm)
{
- if (target_code_size > sizeof(target_code) )
+ if (target_code_size > sizeof(target_code))
{
LOG_WARNING("Internal error - target code buffer to small. Increase CFI_MAX_INTEL_CODESIZE and recompile.");
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
busy_pattern_val = cfi_command_val(bank, 0x80);
error_pattern_val = cfi_command_val(bank, 0x7e);
- LOG_INFO("Using target buffer at 0x%08" PRIx32 " and of size 0x%04" PRIx32, source->address, buffer_size );
+ LOG_INFO("Using target buffer at 0x%08" PRIx32 " and of size 0x%04" PRIx32, source->address, buffer_size);
/* Programming main loop */
while (count > 0)
buf_set_u32(reg_params[5].value, 0, 32, busy_pattern_val);
buf_set_u32(reg_params[6].value, 0, 32, error_pattern_val);
- LOG_INFO("Write 0x%04" PRIx32 " bytes to flash at 0x%08" PRIx32 , thisrun_count, address );
+ LOG_INFO("Write 0x%04" PRIx32 " bytes to flash at 0x%08" PRIx32 , thisrun_count, address);
/* Execute algorithm, assume breakpoint for last instruction */
retval = target_run_algorithm(target, 0, NULL, 7, reg_params,
write_p = address & ~(bank->bus_width - 1);
if ((align = address - write_p) != 0)
{
- LOG_INFO("Fixup %d unaligned head bytes", align );
+ LOG_INFO("Fixup %d unaligned head bytes", align);
for (i = 0; i < bank->bus_width; i++)
current_word[i] = 0;
/* handle unaligned tail bytes */
if (count > 0)
{
- LOG_INFO("Fixup %" PRId32 " unaligned tail bytes", count );
+ LOG_INFO("Fixup %" PRId32 " unaligned tail bytes", count);
copy_p = write_p;
for (i = 0; i < bank->bus_width; i++)
if (aemif == 0x01e00000 /* dm6446, dm357 */
|| aemif == 0x01e10000 /* dm335, dm355 */
|| aemif == 0x01d10000 /* dm365 */
- ) {
+) {
if (chip < 0x0200000 || chip >= 0x0a000000) {
LOG_ERROR("NAND address %08lx out of range?", chip);
goto fail;
0,
&flashErr,
timeout
- );
+);
if (retval != ERROR_OK)
return retval;
for (wrote = 0; wrote < (count*wordsize); wrote += cur_size)
{
- cur_size = MIN((count*wordsize - wrote), sizeof(chunk) );
+ cur_size = MIN((count*wordsize - wrote), sizeof(chunk));
flash_bank_t *bank;
bank = get_flash_bank_by_addr(target, address);
if (bank == NULL)
}
}
- if (first == -1 || last == -1 )
+ if (first == -1 || last == -1)
return ERROR_OK;
return flash_driver_erase(c, first, last);
run_size += pad_bytes;
padding[section_last] = 0;
- LOG_INFO("Padding image section %d with %d bytes", section_last-1, pad_bytes );
+ LOG_INFO("Padding image section %d with %d bytes", section_last-1, pad_bytes);
}
/* fit the run into bank constraints */
if (erase)
{
/* calculate and erase sectors */
- retval = flash_erase_address_range(target, run_address, run_size );
+ retval = flash_erase_address_range(target, run_address, run_size);
}
if (retval == ERROR_OK)
if (ret == ERROR_OK) {
command_print(cmd_ctx, "mflash (total %" PRIu32 " sectors) found at 0x%8.8" PRIx32 "",
- mflash_bank->drv_info->tot_sects, mflash_bank->base );
+ mflash_bank->drv_info->tot_sects, mflash_bank->base);
}
return ret;
uint8_t *buff_ptr = buff;
duration_t duration;
- if ((ret = mg_dsk_io_cmd(sect_num, sect_cnt, mg_io_cmd_read)) != ERROR_OK )
+ if ((ret = mg_dsk_io_cmd(sect_num, sect_cnt, mg_io_cmd_read)) != ERROR_OK)
return ret;
address = mflash_bank->base + MG_BUFFER_OFFSET;
uint8_t *buff_ptr = buff;
duration_t duration;
- if ((ret = mg_dsk_io_cmd(sect_num, sect_cnt, cmd)) != ERROR_OK )
+ if ((ret = mg_dsk_io_cmd(sect_num, sect_cnt, cmd)) != ERROR_OK)
return ret;
address = mflash_bank->base + MG_BUFFER_OFFSET;
page = malloc(device->page_size);
- while (data_size > 0 )
+ while (data_size > 0)
{
uint32_t thisrun_size = (data_size > device->page_size) ? device->page_size : data_size;
uint32_t page_address;
page = malloc(device->page_size);
- while (data_size > 0 )
+ while (data_size > 0)
{
uint32_t thisrun_size = (data_size > device->page_size) ? device->page_size : data_size;
uint32_t page_address;
volatile uint32 dcc_reg;
do {
- asm volatile ("mrc p14, 0, %0, C0, C0" : "=r" (dcc_reg) : );
+ asm volatile ("mrc p14, 0, %0, C0, C0" : "=r" (dcc_reg) :);
} while ((dcc_reg&1) == 0);
- asm volatile ("mrc p14, 0, %0, C1, C0" : "=r" (dcc_reg) : );
+ asm volatile ("mrc p14, 0, %0, C1, C0" : "=r" (dcc_reg) :);
return dcc_reg;
}
volatile uint32 dcc_reg;
do {
- asm volatile ("mrc p14, 0, %0, C0, C0" : "=r" (dcc_reg) : );
+ asm volatile ("mrc p14, 0, %0, C0, C0" : "=r" (dcc_reg) :);
/* operation controled by master, cancel operation
upon reception of data for immediate response */
if (dcc_reg&1) return -1;
/* wait for busy to clear */
while (((status = pic32mx_get_flash_status(bank)) & NVMCON_NVMWR) && (timeout-- > 0))
{
- LOG_DEBUG("status: 0x%" PRIx32, status );
+ LOG_DEBUG("status: 0x%" PRIx32, status);
alive_sleep(1);
}
if (timeout <= 0)
- LOG_DEBUG("timeout: status: 0x%" PRIx32, status );
+ LOG_DEBUG("timeout: status: 0x%" PRIx32, status);
return status;
}
{
LOG_DEBUG("Erasing entire program flash");
status = pic32mx_nvm_exec(bank, NVMCON_OP_PFM_ERASE, 50);
- if (status & NVMCON_NVMERR )
+ if (status & NVMCON_NVMERR)
return ERROR_FLASH_OPERATION_FAILED;
- if (status & NVMCON_LVDERR )
+ if (status & NVMCON_LVDERR)
return ERROR_FLASH_OPERATION_FAILED;
return ERROR_OK;
}
status = pic32mx_nvm_exec(bank, NVMCON_OP_PAGE_ERASE, 10);
- if (status & NVMCON_NVMERR )
+ if (status & NVMCON_NVMERR)
return ERROR_FLASH_OPERATION_FAILED;
- if (status & NVMCON_LVDERR )
+ if (status & NVMCON_LVDERR)
return ERROR_FLASH_OPERATION_FAILED;
bank->sectors[i].is_erased = 1;
}
reg = (i / pic32mx_info->ppage_size) / 8;
bit = (i / pic32mx_info->ppage_size) - (reg * 8);
- if (set )
+ if (set)
prot_reg[reg] &= ~(1 << bit);
else
prot_reg[reg] |= (1 << bit);
reg = (i / pic32mx_info->ppage_size) / 8;
bit = (i / pic32mx_info->ppage_size) - (reg * 8);
- if (set )
+ if (set)
prot_reg[reg] &= ~(1 << bit);
else
prot_reg[reg] |= (1 << bit);
}
#endif
status = pic32mx_write_row(bank, address, source->address);
- if (status & NVMCON_NVMERR ) {
+ if (status & NVMCON_NVMERR) {
LOG_ERROR("Flash write error NVMERR (status = 0x%08" PRIx32 ")", status);
retval = ERROR_FLASH_OPERATION_FAILED;
break;
}
- if (status & NVMCON_LVDERR ) {
+ if (status & NVMCON_LVDERR) {
LOG_ERROR("Flash write error LVDERR (status = 0x%08" PRIx32 ")", status);
retval = ERROR_FLASH_OPERATION_FAILED;
break;
memcpy(&value, buffer, sizeof(uint32_t));
uint32_t status = pic32mx_write_word(bank, address, value);
- if (status & NVMCON_NVMERR ) {
+ if (status & NVMCON_NVMERR) {
LOG_ERROR("Flash write error NVMERR (status = 0x%08" PRIx32 ")", status);
retval = ERROR_FLASH_OPERATION_FAILED;
break;
}
- if (status & NVMCON_LVDERR ) {
+ if (status & NVMCON_LVDERR) {
LOG_ERROR("Flash write error LVDERR (status = 0x%08" PRIx32 ")", status);
retval = ERROR_FLASH_OPERATION_FAILED;
break;
memcpy(&value, buffer + bytes_written, sizeof(uint32_t));
status = pic32mx_write_word(bank, address, value);
- if (status & NVMCON_NVMERR )
+ if (status & NVMCON_NVMERR)
return ERROR_FLASH_OPERATION_FAILED;
- if (status & NVMCON_LVDERR )
+ if (status & NVMCON_LVDERR)
return ERROR_FLASH_OPERATION_FAILED;
bytes_written += 4;
memcpy(&value, buffer + bytes_written, bytes_remaining);
status = pic32mx_write_word(bank, address, value);
- if (status & NVMCON_NVMERR )
+ if (status & NVMCON_NVMERR)
return ERROR_FLASH_OPERATION_FAILED;
- if (status & NVMCON_LVDERR )
+ if (status & NVMCON_LVDERR)
return ERROR_FLASH_OPERATION_FAILED;
}
device_id,
(unsigned)((device_id >> 1)&0x7ff),
(unsigned)((device_id >> 12)&0xff),
- (unsigned)((device_id >> 20)&0xfff) );
+ (unsigned)((device_id >> 20)&0xfff));
if (((device_id >> 1)&0x7ff) != PIC32MX_MANUF_ID) {
- LOG_WARNING("Cannot identify target as a PIC32MX family." );
+ LOG_WARNING("Cannot identify target as a PIC32MX family.");
return ERROR_FLASH_OPERATION_FAILED;
}
break;
}
if (pic32mx_devs[i].name == NULL) {
- LOG_WARNING("Cannot identify target as a PIC32MX family." );
+ LOG_WARNING("Cannot identify target as a PIC32MX family.");
return ERROR_FLASH_OPERATION_FAILED;
}
}
}
#endif
- LOG_INFO("flash size = %dkbytes", num_pages );
+ LOG_INFO("flash size = %dkbytes", num_pages);
/* calculate numbers of pages */
num_pages /= (page_size / 1024);
target_write_u32(target, PIC32MX_FLASH_CR, FLASH_LOCK);
- if (status & FLASH_WRPRTERR )
+ if (status & FLASH_WRPRTERR)
{
LOG_ERROR("pic32mx device protected");
return ERROR_OK;
}
- if (status & FLASH_PGERR )
+ if (status & FLASH_PGERR)
{
LOG_ERROR("pic32mx device programming failed");
return ERROR_OK;
res = ERROR_OK;
status = pic32mx_write_word(bank, address, value);
- if (status & NVMCON_NVMERR )
+ if (status & NVMCON_NVMERR)
res = ERROR_FLASH_OPERATION_FAILED;
- if (status & NVMCON_LVDERR )
+ if (status & NVMCON_LVDERR)
res = ERROR_FLASH_OPERATION_FAILED;
if (res == ERROR_OK)
status = stm32x_wait_status_busy(bank, 10);
- if (status & FLASH_WRPRTERR )
+ if (status & FLASH_WRPRTERR)
return ERROR_FLASH_OPERATION_FAILED;
- if (status & FLASH_PGERR )
+ if (status & FLASH_PGERR)
return ERROR_FLASH_OPERATION_FAILED;
/* clear readout protection and complementary option bytes
status = stm32x_wait_status_busy(bank, 10);
- if (status & FLASH_WRPRTERR )
+ if (status & FLASH_WRPRTERR)
return ERROR_FLASH_OPERATION_FAILED;
- if (status & FLASH_PGERR )
+ if (status & FLASH_PGERR)
return ERROR_FLASH_OPERATION_FAILED;
/* write protection byte 1 */
status = stm32x_wait_status_busy(bank, 10);
- if (status & FLASH_WRPRTERR )
+ if (status & FLASH_WRPRTERR)
return ERROR_FLASH_OPERATION_FAILED;
- if (status & FLASH_PGERR )
+ if (status & FLASH_PGERR)
return ERROR_FLASH_OPERATION_FAILED;
/* write protection byte 2 */
status = stm32x_wait_status_busy(bank, 10);
- if (status & FLASH_WRPRTERR )
+ if (status & FLASH_WRPRTERR)
return ERROR_FLASH_OPERATION_FAILED;
- if (status & FLASH_PGERR )
+ if (status & FLASH_PGERR)
return ERROR_FLASH_OPERATION_FAILED;
/* write protection byte 3 */
status = stm32x_wait_status_busy(bank, 10);
- if (status & FLASH_WRPRTERR )
+ if (status & FLASH_WRPRTERR)
return ERROR_FLASH_OPERATION_FAILED;
- if (status & FLASH_PGERR )
+ if (status & FLASH_PGERR)
return ERROR_FLASH_OPERATION_FAILED;
/* write protection byte 4 */
status = stm32x_wait_status_busy(bank, 10);
- if (status & FLASH_WRPRTERR )
+ if (status & FLASH_WRPRTERR)
return ERROR_FLASH_OPERATION_FAILED;
- if (status & FLASH_PGERR )
+ if (status & FLASH_PGERR)
return ERROR_FLASH_OPERATION_FAILED;
/* write readout protection bit */
status = stm32x_wait_status_busy(bank, 10);
- if (status & FLASH_WRPRTERR )
+ if (status & FLASH_WRPRTERR)
return ERROR_FLASH_OPERATION_FAILED;
- if (status & FLASH_PGERR )
+ if (status & FLASH_PGERR)
return ERROR_FLASH_OPERATION_FAILED;
target_write_u32(target, STM32_FLASH_CR, FLASH_LOCK);
status = stm32x_wait_status_busy(bank, 10);
- if (status & FLASH_WRPRTERR )
+ if (status & FLASH_WRPRTERR)
return ERROR_FLASH_OPERATION_FAILED;
- if (status & FLASH_PGERR )
+ if (status & FLASH_PGERR)
return ERROR_FLASH_OPERATION_FAILED;
bank->sectors[i].is_erased = 1;
}
reg = (i / stm32x_info->ppage_size) / 8;
bit = (i / stm32x_info->ppage_size) - (reg * 8);
- if (set )
+ if (set)
prot_reg[reg] &= ~(1 << bit);
else
prot_reg[reg] |= (1 << bit);
reg = (i / stm32x_info->ppage_size) / 8;
bit = (i / stm32x_info->ppage_size) - (reg * 8);
- if (set )
+ if (set)
prot_reg[reg] &= ~(1 << bit);
else
prot_reg[reg] |= (1 << bit);
status = stm32x_wait_status_busy(bank, 5);
- if (status & FLASH_WRPRTERR )
+ if (status & FLASH_WRPRTERR)
{
LOG_ERROR("flash memory not erased before writing");
return ERROR_FLASH_OPERATION_FAILED;
}
- if (status & FLASH_PGERR )
+ if (status & FLASH_PGERR)
{
LOG_ERROR("flash memory write protected");
return ERROR_FLASH_OPERATION_FAILED;
status = stm32x_wait_status_busy(bank, 5);
- if (status & FLASH_WRPRTERR )
+ if (status & FLASH_WRPRTERR)
{
LOG_ERROR("flash memory not erased before writing");
return ERROR_FLASH_OPERATION_FAILED;
}
- if (status & FLASH_PGERR )
+ if (status & FLASH_PGERR)
{
LOG_ERROR("flash memory write protected");
return ERROR_FLASH_OPERATION_FAILED;
/* read stm32 device id register */
target_read_u32(target, 0xE0042000, &device_id);
- LOG_INFO("device id = 0x%08" PRIx32 "", device_id );
+ LOG_INFO("device id = 0x%08" PRIx32 "", device_id);
/* get flash size from target */
if (target_read_u16(target, 0x1FFFF7E0, &num_pages) != ERROR_OK)
if (num_pages == 0xffff)
{
/* number of sectors incorrect on revA */
- LOG_WARNING("STM32 flash size failed, probe inaccurate - assuming 128k flash" );
+ LOG_WARNING("STM32 flash size failed, probe inaccurate - assuming 128k flash");
num_pages = 128;
}
}
if (num_pages == 0xffff)
{
/* number of sectors incorrect on revA */
- LOG_WARNING("STM32 flash size failed, probe inaccurate - assuming 32k flash" );
+ LOG_WARNING("STM32 flash size failed, probe inaccurate - assuming 32k flash");
num_pages = 32;
}
}
if (num_pages == 0xffff)
{
/* number of sectors incorrect on revZ */
- LOG_WARNING("STM32 flash size failed, probe inaccurate - assuming 512k flash" );
+ LOG_WARNING("STM32 flash size failed, probe inaccurate - assuming 512k flash");
num_pages = 512;
}
}
if (num_pages == 0xffff)
{
/* number of sectors incorrect on revZ */
- LOG_WARNING("STM32 flash size failed, probe inaccurate - assuming 256k flash" );
+ LOG_WARNING("STM32 flash size failed, probe inaccurate - assuming 256k flash");
num_pages = 256;
}
}
else
{
- LOG_WARNING("Cannot identify target as a STM32 family." );
+ LOG_WARNING("Cannot identify target as a STM32 family.");
return ERROR_FLASH_OPERATION_FAILED;
}
- LOG_INFO("flash size = %dkbytes", num_pages );
+ LOG_INFO("flash size = %dkbytes", num_pages);
/* calculate numbers of pages */
num_pages /= (page_size / 1024);
target_write_u32(target, STM32_FLASH_CR, FLASH_LOCK);
- if (status & FLASH_WRPRTERR )
+ if (status & FLASH_WRPRTERR)
{
LOG_ERROR("stm32x device protected");
return ERROR_OK;
}
- if (status & FLASH_PGERR )
+ if (status & FLASH_PGERR)
{
LOG_ERROR("stm32x device programming failed");
return ERROR_OK;
static int str7x_info(struct flash_bank_s *bank, char *buf, int buf_size)
{
- snprintf(buf, buf_size, "str7x flash driver info" );
+ snprintf(buf, buf_size, "str7x flash driver info");
return ERROR_OK;
}
{
return retval;
}
- if (status & 0x80 )
+ if (status & 0x80)
break;
alive_sleep(1);
}
return retval;
}
- if (status & 0x22 )
+ if (status & 0x22)
{
LOG_ERROR("error erasing flash bank, status: 0x%x", status);
return ERROR_FLASH_OPERATION_FAILED;
adr = bank->base + bank->sectors[i].offset;
target_write_u16(target, adr, 0x60);
- if (set )
+ if (set)
target_write_u16(target, adr, 0x01);
else
target_write_u16(target, adr, 0xD0);
for (timeout = 0; timeout < 1000; timeout++)
{
target_read_u8(target, bank_adr, &status);
- if (status & 0x80 )
+ if (status & 0x80)
break;
alive_sleep(1);
}
for (timeout = 0; timeout < 1000; timeout++)
{
target_read_u8(target, bank_adr, &status);
- if (status & 0x80 )
+ if (status & 0x80)
break;
alive_sleep(1);
}
static int str9x_info(struct flash_bank_s *bank, char *buf, int buf_size)
{
- snprintf(buf, buf_size, "str9x flash driver info" );
+ snprintf(buf, buf_size, "str9x flash driver info");
return ERROR_OK;
}
int str9xpec_set_instr(jtag_tap_t *tap, uint32_t new_instr, tap_state_t end_state)
{
- if (tap == NULL ){
+ if (tap == NULL){
return ERROR_TARGET_INVALID;
}
tap = str9xpec_info->tap;
if (!str9xpec_info->isc_enable) {
- str9xpec_isc_enable(bank );
+ str9xpec_isc_enable(bank);
}
if (!str9xpec_info->isc_enable) {
tap = str9xpec_info->tap;
if (!str9xpec_info->isc_enable) {
- str9xpec_isc_enable(bank );
+ str9xpec_isc_enable(bank);
}
if (!str9xpec_info->isc_enable) {
tap = str9xpec_info->tap;
if (!str9xpec_info->isc_enable) {
- str9xpec_isc_enable(bank );
+ str9xpec_isc_enable(bank);
}
if (!str9xpec_info->isc_enable) {
/* last bank: 0xFF signals a full device protect */
if (last == 0xFF)
{
- if (set )
+ if (set)
{
status = str9xpec_lock_device(bank);
}
{
for (i = first; i <= last; i++)
{
- if (set )
+ if (set)
buf_set_u32(str9xpec_info->options, str9xpec_info->sector_bits[i], 1, 1);
else
buf_set_u32(str9xpec_info->options, str9xpec_info->sector_bits[i], 1, 0);
static int str9xpec_info(struct flash_bank_s *bank, char *buf, int buf_size)
{
- snprintf(buf, buf_size, "str9xpec flash driver info" );
+ snprintf(buf, buf_size, "str9xpec flash driver info");
return ERROR_OK;
}
tap = str9xpec_info->tap;
/* erase config options first */
- status = str9xpec_erase_area(bank, 0xFE, 0xFE );
+ status = str9xpec_erase_area(bank, 0xFE, 0xFE);
if ((status & ISC_STATUS_ERROR) != STR9XPEC_ISC_SUCCESS)
return status;
if (!str9xpec_info->isc_enable) {
- str9xpec_isc_enable(bank );
+ str9xpec_isc_enable(bank);
}
if (!str9xpec_info->isc_enable) {
{
/* last byte */
/* mask out bits that don't really belong to the buffer if size isn't a multiple of 8 bits */
- if ((size % 8) && (i == num_bytes -1 ))
+ if ((size % 8) && (i == num_bytes -1))
{
if ((buf1[i] & ((1 << (size % 8)) - 1)) != (buf2[i] & ((1 << (size % 8)) - 1)))
return 1;
{
/* last byte */
/* mask out bits that don't really belong to the buffer if size isn't a multiple of 8 bits */
- if ((size % 8) && (i == num_bytes -1 ))
+ if ((size % 8) && (i == num_bytes -1))
{
if ((buf1[i] & ((1 << (size % 8)) - 1) & mask[i]) !=
(buf2[i] & ((1 << (size % 8)) - 1) & mask[i]))
/* we now need to add an overrideable proc */
const char *override_name = alloc_printf("proc %s%s%s {args} {if {[catch {eval ocd_%s%s%s $args}]==0} {return \"\"} else { return -code error }", t1, t2, t3, t1, t2, t3);
- Jim_Eval_Named(interp, override_name, __THIS__FILE__, __LINE__ );
+ Jim_Eval_Named(interp, override_name, __THIS__FILE__, __LINE__);
free((void *)override_name);
/* accumulate help text in Tcl helptext list. */
void command_output_text(command_context_t *context, const char *data)
{
- if (context && context->output_handler && data ){
- context->output_handler(context, data );
+ if (context && context->output_handler && data){
+ context->output_handler(context, data);
}
}
int run_command(command_context_t *context, command_t *c, char *words[], int num_words)
{
int start_word = 0;
- if (!((context->mode == COMMAND_CONFIG) || (c->mode == COMMAND_ANY) || (c->mode == context->mode) ))
+ if (!((context->mode == COMMAND_CONFIG) || (c->mode == COMMAND_ANY) || (c->mode == context->mode)))
{
/* Config commands can not run after the config stage */
LOG_ERROR("Command '%s' only runs during configuration stage", c->name);
retcode = Jim_SetAssocData(interp, "retval", NULL, &retval);
if (retcode == JIM_OK)
{
- retcode = Jim_Eval_Named(interp, line, __THIS__FILE__, __LINE__ );
+ retcode = Jim_Eval_Named(interp, line, __THIS__FILE__, __LINE__);
Jim_DeleteAssocData(interp, "retval");
}
log_add_callback(tcl_output, tclOutput);
- retcode = Jim_Eval_Named(interp, str, __THIS__FILE__, __LINE__ );
+ retcode = Jim_Eval_Named(interp, str, __THIS__FILE__, __LINE__);
log_remove_callback(tcl_output, tclOutput);
Jim_RegisterCoreCommands(interp);
#endif
-#if defined(_MSC_VER )
+#if defined(_MSC_VER)
/* WinXX - is generic, the forward
* looking problem is this:
*
HostOs = "winxx";
#elif defined(__LINUX__)
HostOs = "linux";
-#elif defined(__DARWIN__ )
+#elif defined(__DARWIN__)
HostOs = "darwin";
-#elif defined(__CYGWIN__ )
+#elif defined(__CYGWIN__)
HostOs = "cygwin";
-#elif defined(__MINGW32__ )
+#elif defined(__MINGW32__)
HostOs = "mingw32";
#else
HostOs = "other";
#endif
- Jim_SetGlobalVariableStr(interp, "ocd_HOSTOS", Jim_NewStringObj(interp, HostOs , strlen(HostOs)) );
+ Jim_SetGlobalVariableStr(interp, "ocd_HOSTOS", Jim_NewStringObj(interp, HostOs , strlen(HostOs)));
Jim_CreateCommand(interp, "ocd_find", jim_find, NULL, NULL);
Jim_CreateCommand(interp, "echo", jim_echo, NULL, NULL);
}
prev = info.fordblks;
- command_print(cmd_ctx, "Available ram: %d", info.fordblks );
+ command_print(cmd_ctx, "Available ram: %d", info.fordblks);
return ERROR_OK;
}
fd1 = open(name1, O_WRONLY | O_CREAT, 0664);
if (fd1 < 0)
- SHOW_RESULT(open, fd1 );
+ SHOW_RESULT(open, fd1);
fd2 = open(name2, O_RDONLY);
if (fd2 < 0)
- SHOW_RESULT(open, fd2 );
+ SHOW_RESULT(open, fd2);
for (;;)
{
- done = read(fd2, buf, IOSIZE );
+ done = read(fd2, buf, IOSIZE);
if (done < 0)
{
- SHOW_RESULT(read, done );
+ SHOW_RESULT(read, done);
break;
}
- if (done == 0 ) break;
+ if (done == 0) break;
wrote = write(fd1, buf, done);
- if (wrote != done ) SHOW_RESULT(write, wrote );
+ if (wrote != done) SHOW_RESULT(write, wrote);
- if (wrote != done ) break;
+ if (wrote != done) break;
}
err = close(fd1);
- if (err < 0 ) SHOW_RESULT(close, err );
+ if (err < 0) SHOW_RESULT(close, err);
err = close(fd2);
- if (err < 0 ) SHOW_RESULT(close, err );
+ if (err < 0) SHOW_RESULT(close, err);
}
}
dirp = opendir(name);
- if (dirp == NULL ) SHOW_RESULT(opendir, -1 );
+ if (dirp == NULL) SHOW_RESULT(opendir, -1);
for (;;)
{
}
err = closedir(dirp);
- if (err < 0 ) SHOW_RESULT(stat, err );
+ if (err < 0) SHOW_RESULT(stat, err);
}
* ---------------------------------------------------------------------------*/
static char *
-jim_vasprintf(const char *fmt, va_list ap )
+jim_vasprintf(const char *fmt, va_list ap)
{
#ifndef HAVE_VASPRINTF
/* yucky way */
static char buf[2048];
- vsnprintf(buf, sizeof(buf), fmt, ap );
+ vsnprintf(buf, sizeof(buf), fmt, ap);
/* garentee termination */
buf[sizeof(buf)-1] = 0;
#else
char *buf;
int result;
- result = vasprintf(&buf, fmt, ap );
+ result = vasprintf(&buf, fmt, ap);
if (result < 0) exit(-1);
#endif
return buf;
}
static void
-jim_vasprintf_done(void *buf )
+jim_vasprintf_done(void *buf)
{
#ifndef HAVE_VASPRINTF
(void)(buf);
#else
*widePtr = strtol(str, &endptr, base);
#endif
- if ((str[0] == '\0') || (str == endptr) )
+ if ((str[0] == '\0') || (str == endptr))
return JIM_ERR;
if (endptr[0] != '\0') {
while (*endptr) {
char *endptr;
*intPtr = strtol(str, &endptr, 10);
- if ((str[0] == '\0') || (str == endptr) )
+ if ((str[0] == '\0') || (str == endptr))
return JIM_ERR;
if (endptr[0] != '\0') {
while (*endptr) {
char *endptr;
*doublePtr = strtod(str, &endptr);
- if (str[0] == '\0' || endptr[0] != '\0' || (str == endptr) )
+ if (str[0] == '\0' || endptr[0] != '\0' || (str == endptr))
return JIM_ERR;
return JIM_OK;
}
#endif
/* This may actually crash... we do it last */
- if (interp && interp->cookie_stderr ){
+ if (interp && interp->cookie_stderr){
Jim_fprintf(interp, interp->cookie_stderr, JIM_NL "JIM INTERPRETER PANIC: ");
- Jim_vfprintf(interp, interp->cookie_stderr, fmt, ap );
- Jim_fprintf(interp, interp->cookie_stderr, JIM_NL JIM_NL );
+ Jim_vfprintf(interp, interp->cookie_stderr, fmt, ap);
+ Jim_fprintf(interp, interp->cookie_stderr, JIM_NL JIM_NL);
}
abort();
}
StringAppendString(objPtr, str, len);
}
-void Jim_AppendString_sprintf(Jim_Interp *interp, Jim_Obj *objPtr, const char *fmt, ... )
+void Jim_AppendString_sprintf(Jim_Interp *interp, Jim_Obj *objPtr, const char *fmt, ...)
{
char *buf;
va_list ap;
- va_start(ap, fmt );
- buf = jim_vasprintf(fmt, ap );
+ va_start(ap, fmt);
+ buf = jim_vasprintf(fmt, ap);
va_end(ap);
- if (buf ){
- Jim_AppendString(interp, objPtr, buf, -1 );
+ if (buf){
+ Jim_AppendString(interp, objPtr, buf, -1);
jim_vasprintf_done(buf);
}
}
haveprec = 0;
prec = -1; /* not found yet */
next_fmt:
- if (fmtLen <= 0 ){
+ if (fmtLen <= 0){
break;
}
- switch (*fmt ){
+ switch (*fmt){
/* terminals */
case 'b': /* binary - not all printfs() do this */
case 's': /* string */
case '8':
case '9':
accum = 0;
- while (isdigit(*fmt) && (fmtLen > 0) ){
+ while (isdigit(*fmt) && (fmtLen > 0)){
accum = (accum * 10) + (*fmt - '0');
fmt++; fmtLen--;
}
- if (inprec ){
+ if (inprec){
haveprec = 1;
prec = accum;
} else {
/* suck up the next item as an integer */
fmt++; fmtLen--;
objc--;
- if (objc <= 0 ){
+ if (objc <= 0){
goto not_enough_args;
}
- if (Jim_GetWide(interp,objv[0],&wideValue )== JIM_ERR ){
- Jim_FreeNewObj(interp, resObjPtr );
+ if (Jim_GetWide(interp,objv[0],&wideValue)== JIM_ERR){
+ Jim_FreeNewObj(interp, resObjPtr);
return NULL;
}
- if (inprec ){
+ if (inprec){
haveprec = 1;
prec = wideValue;
- if (prec < 0 ){
+ if (prec < 0){
/* man 3 printf says */
/* if prec is negative, it is zero */
prec = 0;
}
} else {
width = wideValue;
- if (width < 0 ){
+ if (width < 0){
ljust = 1;
width = -width;
}
*/
cp = fmt_str;
*cp++ = '%';
- if (altfm ){
+ if (altfm){
*cp++ = '#';
}
- if (forceplus ){
+ if (forceplus){
*cp++ = '+';
- } else if (spad ){
+ } else if (spad){
/* PLUS overrides */
*cp++ = ' ';
}
- if (ljust ){
+ if (ljust){
*cp++ = '-';
}
- if (zpad ){
+ if (zpad){
*cp++ = '0';
}
- if (width > 0 ){
- sprintf(cp, "%d", width );
+ if (width > 0){
+ sprintf(cp, "%d", width);
/* skip ahead */
cp = strchr(cp,0);
}
/* did we find a period? */
- if (inprec ){
+ if (inprec){
/* then add it */
*cp++ = '.';
/* did something occur after the period? */
- if (haveprec ){
- sprintf(cp, "%d", prec );
+ if (haveprec){
+ sprintf(cp, "%d", prec);
}
cp = strchr(cp,0);
}
*cp++ = 's';
*cp = 0;
/* BUG: we do not handled embeded NULLs */
- snprintf(sprintf_buf, JIM_MAX_FMT, fmt_str, Jim_GetString(objv[0], NULL ));
+ snprintf(sprintf_buf, JIM_MAX_FMT, fmt_str, Jim_GetString(objv[0], NULL));
break;
case 'c':
*cp++ = 'c';
return NULL;
}
c = (char) wideValue;
- snprintf(sprintf_buf, JIM_MAX_FMT, fmt_str, c );
+ snprintf(sprintf_buf, JIM_MAX_FMT, fmt_str, c);
break;
case 'f':
case 'F':
case 'E':
*cp++ = *fmt;
*cp = 0;
- if (Jim_GetDouble(interp, objv[0], &doubleValue ) == JIM_ERR ){
- Jim_FreeNewObj(interp, resObjPtr );
+ if (Jim_GetDouble(interp, objv[0], &doubleValue) == JIM_ERR){
+ Jim_FreeNewObj(interp, resObjPtr);
return NULL;
}
- snprintf(sprintf_buf, JIM_MAX_FMT, fmt_str, doubleValue );
+ snprintf(sprintf_buf, JIM_MAX_FMT, fmt_str, doubleValue);
break;
case 'b':
case 'd':
case 'x':
case 'X':
/* jim widevaluse are 64bit */
- if (sizeof(jim_wide) == sizeof(long long) ){
+ if (sizeof(jim_wide) == sizeof(long long)){
*cp++ = 'l';
*cp++ = 'l';
} else {
Jim_FreeNewObj(interp, resObjPtr);
return NULL;
}
- snprintf(sprintf_buf, JIM_MAX_FMT, fmt_str, wideValue );
+ snprintf(sprintf_buf, JIM_MAX_FMT, fmt_str, wideValue);
break;
case '%':
sprintf_buf[0] = '%';
}
/* force terminate */
#if 0
- printf("FMT was: %s\n", fmt_str );
- printf("RES was: |%s|\n", sprintf_buf );
+ printf("FMT was: %s\n", fmt_str);
+ printf("RES was: |%s|\n", sprintf_buf);
#endif
sprintf_buf[ JIM_MAX_FMT - 1] = 0;
- Jim_AppendString(interp, resObjPtr, sprintf_buf, strlen(sprintf_buf) );
+ Jim_AppendString(interp, resObjPtr, sprintf_buf, strlen(sprintf_buf));
/* next obj */
objv++;
fmt++;
Jim_Nvp *n;
int e;
- e = Jim_Nvp_name2value_obj(interp, nvp_table, objPtr, &n );
- if (e == JIM_ERR ){
+ e = Jim_Nvp_name2value_obj(interp, nvp_table, objPtr, &n);
+ if (e == JIM_ERR){
return e;
}
/* Success? found? */
- if (n->name ){
+ if (n->name){
/* remove const */
*result = (Jim_Nvp *)n;
return JIM_OK;
i->cookie_stderr = stderr;
i->cb_fwrite = ((size_t (*)(const void *, size_t, size_t, void *))(fwrite));
i->cb_fread = ((size_t (*)(void *, size_t, size_t, void *))(fread));
- i->cb_vfprintf = ((int (*)(void *, const char *fmt, va_list ))(vfprintf));
+ i->cb_vfprintf = ((int (*)(void *, const char *fmt, va_list))(vfprintf));
i->cb_fflush = ((int (*)(void *))(fflush));
i->cb_fgets = ((char * (*)(char *, int, void *))(fgets));
SetListFromAny(interp, listPtr);
if (index >= 0 && index > listPtr->internalRep.listValue.len)
index = listPtr->internalRep.listValue.len;
- else if (index < 0 )
+ else if (index < 0)
index = 0;
Jim_InvalidateStringRep(listPtr);
ListInsertElements(listPtr, index, objc, objVec);
pc->p++; pc->len--;
}
while (isdigit((int)*pc->p)
- || (allowhex && isxdigit((int)*pc->p) )
+ || (allowhex && isxdigit((int)*pc->p))
|| (allowdot && *pc->p == '.')
|| (pc->p-pc->tstart == 1 && *pc->tstart == '0' &&
(*pc->p == 'x' || *pc->p == 'X'))
- )
+)
{
if ((*pc->p == 'x') || (*pc->p == 'X')) {
allowhex = 1;
Jim_IncrRefCount(scriptObjPtr);
- if (filename ){
- JimSetSourceInfo(interp, scriptObjPtr, filename, lineno );
+ if (filename){
+ JimSetSourceInfo(interp, scriptObjPtr, filename, lineno);
}
retval = Jim_EvalObj(interp, scriptObjPtr);
int Jim_Eval(Jim_Interp *interp, const char *script)
{
- return Jim_Eval_Named(interp, script, NULL, 0 );
+ return Jim_Eval_Named(interp, script, NULL, 0);
}
const int cwd_len = 2048;
char *cwd = malloc(cwd_len);
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
- if (!getcwd(cwd, cwd_len )) strcpy(cwd, "unknown");
+ if (!getcwd(cwd, cwd_len)) strcpy(cwd, "unknown");
Jim_AppendStrings(interp, Jim_GetResult(interp),
"Error loading script \"", filename, "\"",
" cwd: ", cwd,
JIM_REGISTER_API(StackPop);
JIM_REGISTER_API(StackPeek);
JIM_REGISTER_API(FreeStackElements);
- JIM_REGISTER_API(fprintf );
- JIM_REGISTER_API(vfprintf );
- JIM_REGISTER_API(fwrite );
- JIM_REGISTER_API(fread );
- JIM_REGISTER_API(fflush );
- JIM_REGISTER_API(fgets );
+ JIM_REGISTER_API(fprintf);
+ JIM_REGISTER_API(vfprintf);
+ JIM_REGISTER_API(fwrite);
+ JIM_REGISTER_API(fread);
+ JIM_REGISTER_API(fflush);
+ JIM_REGISTER_API(fgets);
JIM_REGISTER_API(GetNvp);
JIM_REGISTER_API(Nvp_name2value);
JIM_REGISTER_API(Nvp_name2value_simple);
if (count > nbrOfLoops)
nbrOfLoops = count;
}
- for (; nbrOfLoops-- > 0; ) {
+ for (; nbrOfLoops-- > 0;) {
for (i = 0; i < nbrOfLists; ++i) {
int varIdx = 0, var = i * 2;
while (varIdx < listsEnd[var]) {
"proc lambdaFinalizer {name val} {\n"
" rename $name {}\n"
"}\n"
- );
+);
}
void Jim_RegisterCoreCommands(Jim_Interp *interp)
* Jim's idea of STDIO..
* ---------------------------------------------------------------------------*/
-int Jim_fprintf(Jim_Interp *interp, void *cookie, const char *fmt, ... )
+int Jim_fprintf(Jim_Interp *interp, void *cookie, const char *fmt, ...)
{
int r;
va_list ap;
va_start(ap,fmt);
- r = Jim_vfprintf(interp, cookie, fmt,ap );
+ r = Jim_vfprintf(interp, cookie, fmt,ap);
va_end(ap);
return r;
}
-int Jim_vfprintf(Jim_Interp *interp, void *cookie, const char *fmt, va_list ap )
+int Jim_vfprintf(Jim_Interp *interp, void *cookie, const char *fmt, va_list ap)
{
- if ((interp == NULL) || (interp->cb_vfprintf == NULL) ){
+ if ((interp == NULL) || (interp->cb_vfprintf == NULL)){
errno = ENOTSUP;
return -1;
}
- return (*(interp->cb_vfprintf))(cookie, fmt, ap );
+ return (*(interp->cb_vfprintf))(cookie, fmt, ap);
}
-size_t Jim_fwrite(Jim_Interp *interp, const void *ptr, size_t size, size_t n, void *cookie )
+size_t Jim_fwrite(Jim_Interp *interp, const void *ptr, size_t size, size_t n, void *cookie)
{
- if ((interp == NULL) || (interp->cb_fwrite == NULL) ){
+ if ((interp == NULL) || (interp->cb_fwrite == NULL)){
errno = ENOTSUP;
return 0;
}
return (*(interp->cb_fwrite))(ptr, size, n, cookie);
}
-size_t Jim_fread(Jim_Interp *interp, void *ptr, size_t size, size_t n, void *cookie )
+size_t Jim_fread(Jim_Interp *interp, void *ptr, size_t size, size_t n, void *cookie)
{
- if ((interp == NULL) || (interp->cb_fread == NULL) ){
+ if ((interp == NULL) || (interp->cb_fread == NULL)){
errno = ENOTSUP;
return 0;
}
return (*(interp->cb_fread))(ptr, size, n, cookie);
}
-int Jim_fflush(Jim_Interp *interp, void *cookie )
+int Jim_fflush(Jim_Interp *interp, void *cookie)
{
- if ((interp == NULL) || (interp->cb_fflush == NULL) ){
+ if ((interp == NULL) || (interp->cb_fflush == NULL)){
/* pretend all is well */
return 0;
}
- return (*(interp->cb_fflush))(cookie );
+ return (*(interp->cb_fflush))(cookie);
}
-char* Jim_fgets(Jim_Interp *interp, char *s, int size, void *cookie )
+char* Jim_fgets(Jim_Interp *interp, char *s, int size, void *cookie)
{
- if ((interp == NULL) || (interp->cb_fgets == NULL) ){
+ if ((interp == NULL) || (interp->cb_fgets == NULL)){
errno = ENOTSUP;
return NULL;
}
- return (*(interp->cb_fgets))(s, size, cookie );
+ return (*(interp->cb_fgets))(s, size, cookie);
}
Jim_Nvp *
-Jim_Nvp_name2value_simple(const Jim_Nvp *p, const char *name )
+Jim_Nvp_name2value_simple(const Jim_Nvp *p, const char *name)
{
- while (p->name ){
- if (0 == strcmp(name, p->name ) ){
+ while (p->name){
+ if (0 == strcmp(name, p->name)){
break;
}
p++;
}
Jim_Nvp *
-Jim_Nvp_name2value_nocase_simple(const Jim_Nvp *p, const char *name )
+Jim_Nvp_name2value_nocase_simple(const Jim_Nvp *p, const char *name)
{
- while (p->name ){
- if (0 == strcasecmp(name, p->name ) ){
+ while (p->name){
+ if (0 == strcasecmp(name, p->name)){
break;
}
p++;
Jim_Nvp_name2value_obj(Jim_Interp *interp,
const Jim_Nvp *p,
Jim_Obj *o,
- Jim_Nvp **result )
+ Jim_Nvp **result)
{
- return Jim_Nvp_name2value(interp, p, Jim_GetString(o, NULL ), result );
+ return Jim_Nvp_name2value(interp, p, Jim_GetString(o, NULL), result);
}
{
const Jim_Nvp *p;
- p = Jim_Nvp_name2value_simple(_p, name );
+ p = Jim_Nvp_name2value_simple(_p, name);
/* result */
- if (result ){
+ if (result){
*result = (Jim_Nvp *)(p);
}
/* found? */
- if (p->name ){
+ if (p->name){
return JIM_OK;
} else {
return JIM_ERR;
}
int
-Jim_Nvp_name2value_obj_nocase(Jim_Interp *interp, const Jim_Nvp *p, Jim_Obj *o, Jim_Nvp **puthere )
+Jim_Nvp_name2value_obj_nocase(Jim_Interp *interp, const Jim_Nvp *p, Jim_Obj *o, Jim_Nvp **puthere)
{
- return Jim_Nvp_name2value_nocase(interp, p, Jim_GetString(o, NULL ), puthere );
+ return Jim_Nvp_name2value_nocase(interp, p, Jim_GetString(o, NULL), puthere);
}
int
-Jim_Nvp_name2value_nocase(Jim_Interp *interp, const Jim_Nvp *_p, const char *name, Jim_Nvp **puthere )
+Jim_Nvp_name2value_nocase(Jim_Interp *interp, const Jim_Nvp *_p, const char *name, Jim_Nvp **puthere)
{
const Jim_Nvp *p;
- p = Jim_Nvp_name2value_nocase_simple(_p, name );
+ p = Jim_Nvp_name2value_nocase_simple(_p, name);
- if (puthere ){
+ if (puthere){
*puthere = (Jim_Nvp *)(p);
}
/* found */
- if (p->name ){
+ if (p->name){
return JIM_OK;
} else {
return JIM_ERR;
int
-Jim_Nvp_value2name_obj(Jim_Interp *interp, const Jim_Nvp *p, Jim_Obj *o, Jim_Nvp **result )
+Jim_Nvp_value2name_obj(Jim_Interp *interp, const Jim_Nvp *p, Jim_Obj *o, Jim_Nvp **result)
{
int e;;
jim_wide w;
- e = Jim_GetWide(interp, o, &w );
- if (e != JIM_OK ){
+ e = Jim_GetWide(interp, o, &w);
+ if (e != JIM_OK){
return e;
}
- return Jim_Nvp_value2name(interp, p, w, result );
+ return Jim_Nvp_value2name(interp, p, w, result);
}
Jim_Nvp *
-Jim_Nvp_value2name_simple(const Jim_Nvp *p, int value )
+Jim_Nvp_value2name_simple(const Jim_Nvp *p, int value)
{
- while (p->name ){
- if (value == p->value ){
+ while (p->name){
+ if (value == p->value){
break;
}
p++;
int
-Jim_Nvp_value2name(Jim_Interp *interp, const Jim_Nvp *_p, int value, Jim_Nvp **result )
+Jim_Nvp_value2name(Jim_Interp *interp, const Jim_Nvp *_p, int value, Jim_Nvp **result)
{
const Jim_Nvp *p;
- p = Jim_Nvp_value2name_simple(_p, value );
+ p = Jim_Nvp_value2name_simple(_p, value);
- if (result ){
+ if (result){
*result = (Jim_Nvp *)(p);
}
- if (p->name ){
+ if (p->name){
return JIM_OK;
} else {
return JIM_ERR;
int
Jim_GetOpt_Setup(Jim_GetOptInfo *p, Jim_Interp *interp, int argc, Jim_Obj * const * argv)
{
- memset(p, 0, sizeof(*p) );
+ memset(p, 0, sizeof(*p));
p->interp = interp;
p->argc = argc;
p->argv = argv;
}
void
-Jim_GetOpt_Debug(Jim_GetOptInfo *p )
+Jim_GetOpt_Debug(Jim_GetOptInfo *p)
{
int x;
Jim_fprintf(p->interp, p->interp->cookie_stderr, "---args---\n");
- for (x = 0 ; x < p->argc ; x++ ){
+ for (x = 0 ; x < p->argc ; x++){
Jim_fprintf(p->interp, p->interp->cookie_stderr,
"%2d) %s\n",
x,
- Jim_GetString(p->argv[x], NULL ) );
+ Jim_GetString(p->argv[x], NULL));
}
Jim_fprintf(p->interp, p->interp->cookie_stderr, "-------\n");
}
int
-Jim_GetOpt_Obj(Jim_GetOptInfo *goi, Jim_Obj **puthere )
+Jim_GetOpt_Obj(Jim_GetOptInfo *goi, Jim_Obj **puthere)
{
Jim_Obj *o;
o = NULL; // failure
- if (goi->argc ){
+ if (goi->argc){
// success
o = goi->argv[0];
goi->argc -= 1;
goi->argv += 1;
}
- if (puthere ){
+ if (puthere){
*puthere = o;
}
- if (o != NULL ){
+ if (o != NULL){
return JIM_OK;
} else {
return JIM_ERR;
}
int
-Jim_GetOpt_String(Jim_GetOptInfo *goi, char **puthere, int *len )
+Jim_GetOpt_String(Jim_GetOptInfo *goi, char **puthere, int *len)
{
int r;
Jim_Obj *o;
const char *cp;
- r = Jim_GetOpt_Obj(goi, &o );
- if (r == JIM_OK ){
- cp = Jim_GetString(o, len );
- if (puthere ){
+ r = Jim_GetOpt_Obj(goi, &o);
+ if (r == JIM_OK){
+ cp = Jim_GetString(o, len);
+ if (puthere){
/* remove const */
*puthere = (char *)(cp);
}
}
int
-Jim_GetOpt_Double(Jim_GetOptInfo *goi, double *puthere )
+Jim_GetOpt_Double(Jim_GetOptInfo *goi, double *puthere)
{
int r;
Jim_Obj *o;
double _safe;
- if (puthere == NULL ){
+ if (puthere == NULL){
puthere = &_safe;
}
- r = Jim_GetOpt_Obj(goi, &o );
- if (r == JIM_OK ){
- r = Jim_GetDouble(goi->interp, o, puthere );
- if (r != JIM_OK ){
+ r = Jim_GetOpt_Obj(goi, &o);
+ if (r == JIM_OK){
+ r = Jim_GetDouble(goi->interp, o, puthere);
+ if (r != JIM_OK){
Jim_SetResult_sprintf(goi->interp,
"not a number: %s",
- Jim_GetString(o, NULL ) );
+ Jim_GetString(o, NULL));
}
}
return r;
}
int
-Jim_GetOpt_Wide(Jim_GetOptInfo *goi, jim_wide *puthere )
+Jim_GetOpt_Wide(Jim_GetOptInfo *goi, jim_wide *puthere)
{
int r;
Jim_Obj *o;
jim_wide _safe;
- if (puthere == NULL ){
+ if (puthere == NULL){
puthere = &_safe;
}
- r = Jim_GetOpt_Obj(goi, &o );
- if (r == JIM_OK ){
- r = Jim_GetWide(goi->interp, o, puthere );
+ r = Jim_GetOpt_Obj(goi, &o);
+ if (r == JIM_OK){
+ r = Jim_GetWide(goi->interp, o, puthere);
}
return r;
}
Jim_Obj *o;
int e;
- if (puthere == NULL ){
+ if (puthere == NULL){
puthere = &_safe;
}
- e = Jim_GetOpt_Obj(goi, &o );
- if (e == JIM_OK ){
+ e = Jim_GetOpt_Obj(goi, &o);
+ if (e == JIM_OK){
e = Jim_Nvp_name2value_obj(goi->interp,
nvp,
o,
- puthere );
+ puthere);
}
return e;
void
Jim_GetOpt_NvpUnknown(Jim_GetOptInfo *goi,
const Jim_Nvp *nvptable,
- int hadprefix )
+ int hadprefix)
{
- if (hadprefix ){
+ if (hadprefix){
Jim_SetResult_NvpUnknown(goi->interp,
goi->argv[-2],
goi->argv[-1],
- nvptable );
+ nvptable);
} else {
Jim_SetResult_NvpUnknown(goi->interp,
NULL,
goi->argv[-1],
- nvptable );
+ nvptable);
}
}
Jim_Obj *o;
int e;
- if (puthere == NULL ){
+ if (puthere == NULL){
puthere = &_safe;
}
- e = Jim_GetOpt_Obj(goi, &o );
- if (e == JIM_OK ){
+ e = Jim_GetOpt_Obj(goi, &o);
+ if (e == JIM_OK){
e = Jim_GetEnum(goi->interp,
o,
lookup,
puthere,
"option",
- JIM_ERRMSG );
+ JIM_ERRMSG);
}
return e;
}
int
-Jim_SetResult_sprintf(Jim_Interp *interp, const char *fmt,... )
+Jim_SetResult_sprintf(Jim_Interp *interp, const char *fmt,...)
{
va_list ap;
char *buf;
va_start(ap,fmt);
- buf = jim_vasprintf(fmt, ap );
+ buf = jim_vasprintf(fmt, ap);
va_end(ap);
- if (buf ){
- Jim_SetResultString(interp, buf, -1 );
+ if (buf){
+ Jim_SetResultString(interp, buf, -1);
jim_vasprintf_done(buf);
}
return JIM_OK;
Jim_SetResult_NvpUnknown(Jim_Interp *interp,
Jim_Obj *param_name,
Jim_Obj *param_value,
- const Jim_Nvp *nvp )
+ const Jim_Nvp *nvp)
{
- if (param_name ){
+ if (param_name){
Jim_SetResult_sprintf(interp,
"%s: Unknown: %s, try one of: ",
- Jim_GetString(param_name, NULL ),
- Jim_GetString(param_value, NULL ) );
+ Jim_GetString(param_name, NULL),
+ Jim_GetString(param_value, NULL));
} else {
Jim_SetResult_sprintf(interp,
"Unknown param: %s, try one of: ",
- Jim_GetString(param_value, NULL ) );
+ Jim_GetString(param_value, NULL));
}
- while (nvp->name ){
+ while (nvp->name){
const char *a;
const char *b;
- if ((nvp + 1)->name ){
+ if ((nvp + 1)->name){
a = nvp->name;
b = ", ";
} else {
}
Jim_AppendStrings(interp,
Jim_GetResult(interp),
- a, b, NULL );
+ a, b, NULL);
nvp++;
}
}
static Jim_Obj *debug_string_obj;
const char *
-Jim_Debug_ArgvString(Jim_Interp *interp, int argc, Jim_Obj *const *argv )
+Jim_Debug_ArgvString(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int x;
- if (debug_string_obj ){
- Jim_FreeObj(interp, debug_string_obj );
+ if (debug_string_obj){
+ Jim_FreeObj(interp, debug_string_obj);
}
- debug_string_obj = Jim_NewEmptyStringObj(interp );
- for (x = 0 ; x < argc ; x++ ){
+ debug_string_obj = Jim_NewEmptyStringObj(interp);
+ for (x = 0 ; x < argc ; x++){
Jim_AppendStrings(interp,
debug_string_obj,
- Jim_GetString(argv[x], NULL ),
+ Jim_GetString(argv[x], NULL),
" ",
- NULL );
+ NULL);
}
- return Jim_GetString(debug_string_obj, NULL );
+ return Jim_GetString(debug_string_obj, NULL);
}
void *cookie_stdin; /* input file pointer, 'stdin' by default */
void *cookie_stdout; /* output file pointer, 'stdout' by default */
void *cookie_stderr; /* errors file pointer, 'stderr' by default */
- size_t (*cb_fwrite )(const void *ptr, size_t size, size_t n, void *cookie );
- size_t (*cb_fread )(void *ptr, size_t size, size_t n, void *cookie );
- int (*cb_vfprintf)(void *cookie, const char *fmt, va_list ap );
- int (*cb_fflush )(void *cookie );
- char *(*cb_fgets )(char *s, int size, void *cookie );
+ size_t (*cb_fwrite)(const void *ptr, size_t size, size_t n, void *cookie);
+ size_t (*cb_fread)(void *ptr, size_t size, size_t n, void *cookie);
+ int (*cb_vfprintf)(void *cookie, const char *fmt, va_list ap);
+ int (*cb_fflush)(void *cookie);
+ char *(*cb_fgets)(char *s, int size, void *cookie);
} Jim_Interp;
/* Currently provided as macro that performs the increment.
* };
*
* Jim_Nvp *result
- * e = Jim_Nvp_name2value(interp, yn, "y", &result );
+ * e = Jim_Nvp_name2value(interp, yn, "y", &result);
* returns &yn[0];
- * e = Jim_Nvp_name2value(interp, yn, "n", &result );
+ * e = Jim_Nvp_name2value(interp, yn, "n", &result);
* returns &yn[1];
- * e = Jim_Nvp_name2value(interp, yn, "Blah", &result );
+ * e = Jim_Nvp_name2value(interp, yn, "Blah", &result);
* returns &yn[4];
* \endcode
*
#ifdef DOXYGEN
#define JIM_STATIC
-#define JIM_API(X ) X
+#define JIM_API(X) X
#else
#ifndef __JIM_CORE__
# if defined JIM_EMBEDDED
#endif /* DOXYGEN */
/** Set the result - printf() style */
-JIM_STATIC int JIM_API(Jim_SetResult_sprintf )(Jim_Interp *p, const char *fmt, ... );
+JIM_STATIC int JIM_API(Jim_SetResult_sprintf)(Jim_Interp *p, const char *fmt, ...);
/* Memory allocation */
JIM_STATIC void * JIM_API(Jim_Alloc) (int size);
/* evaluation */
JIM_STATIC int JIM_API(Jim_Eval)(Jim_Interp *interp, const char *script);
/* in C code, you can do this and get better error messages */
-/* Jim_Eval_Named(interp, "some tcl commands", __FILE__, __LINE__ ); */
+/* Jim_Eval_Named(interp, "some tcl commands", __FILE__, __LINE__); */
JIM_STATIC int JIM_API(Jim_Eval_Named)(Jim_Interp *interp, const char *script,const char *filename, int lineno);
JIM_STATIC int JIM_API(Jim_EvalGlobal)(Jim_Interp *interp, const char *script);
JIM_STATIC int JIM_API(Jim_EvalFile)(Jim_Interp *interp, const char *filename);
JIM_STATIC void JIM_API(Jim_AppendString) (Jim_Interp *interp, Jim_Obj *objPtr,
const char *str, int len);
JIM_STATIC void JIM_API(Jim_AppendString_sprintf) (Jim_Interp *interp, Jim_Obj *objPtr,
- const char *fmt, ... );
+ const char *fmt, ...);
JIM_STATIC void JIM_API(Jim_AppendObj) (Jim_Interp *interp, Jim_Obj *objPtr,
Jim_Obj *appendObjPtr);
JIM_STATIC void JIM_API(Jim_AppendStrings) (Jim_Interp *interp,
JIM_STATIC void JIM_API(Jim_Panic) (Jim_Interp *interp, const char *fmt, ...);
/* Jim's STDIO */
-JIM_STATIC int JIM_API(Jim_fprintf )(Jim_Interp *interp, void *cookie, const char *fmt, ... );
-JIM_STATIC int JIM_API(Jim_vfprintf )(Jim_Interp *interp, void *cookie, const char *fmt, va_list ap );
-JIM_STATIC size_t JIM_API(Jim_fwrite )(Jim_Interp *interp, const void *ptr, size_t size, size_t nmeb, void *cookie );
-JIM_STATIC size_t JIM_API(Jim_fread )(Jim_Interp *interp, void *ptr, size_t size, size_t nmeb, void *cookie );
-JIM_STATIC int JIM_API(Jim_fflush )(Jim_Interp *interp, void *cookie );
-JIM_STATIC char * JIM_API(Jim_fgets )(Jim_Interp *interp, char *s, int size, void *cookie );
+JIM_STATIC int JIM_API(Jim_fprintf)(Jim_Interp *interp, void *cookie, const char *fmt, ...);
+JIM_STATIC int JIM_API(Jim_vfprintf)(Jim_Interp *interp, void *cookie, const char *fmt, va_list ap);
+JIM_STATIC size_t JIM_API(Jim_fwrite)(Jim_Interp *interp, const void *ptr, size_t size, size_t nmeb, void *cookie);
+JIM_STATIC size_t JIM_API(Jim_fread)(Jim_Interp *interp, void *ptr, size_t size, size_t nmeb, void *cookie);
+JIM_STATIC int JIM_API(Jim_fflush)(Jim_Interp *interp, void *cookie);
+JIM_STATIC char * JIM_API(Jim_fgets)(Jim_Interp *interp, char *s, int size, void *cookie);
/* Name Value Pairs Operations */
-JIM_STATIC Jim_Nvp *JIM_API(Jim_Nvp_name2value_simple)(const Jim_Nvp *nvp_table, const char *name );
-JIM_STATIC Jim_Nvp *JIM_API(Jim_Nvp_name2value_nocase_simple)(const Jim_Nvp *nvp_table, const char *name );
-JIM_STATIC Jim_Nvp *JIM_API(Jim_Nvp_value2name_simple)(const Jim_Nvp *nvp_table, int v );
+JIM_STATIC Jim_Nvp *JIM_API(Jim_Nvp_name2value_simple)(const Jim_Nvp *nvp_table, const char *name);
+JIM_STATIC Jim_Nvp *JIM_API(Jim_Nvp_name2value_nocase_simple)(const Jim_Nvp *nvp_table, const char *name);
+JIM_STATIC Jim_Nvp *JIM_API(Jim_Nvp_value2name_simple)(const Jim_Nvp *nvp_table, int v);
-JIM_STATIC int JIM_API(Jim_Nvp_name2value)(Jim_Interp *interp, const Jim_Nvp *nvp_table, const char *name, Jim_Nvp **result );
+JIM_STATIC int JIM_API(Jim_Nvp_name2value)(Jim_Interp *interp, const Jim_Nvp *nvp_table, const char *name, Jim_Nvp **result);
JIM_STATIC int JIM_API(Jim_Nvp_name2value_nocase)(Jim_Interp *interp, const Jim_Nvp *nvp_table, const char *name, Jim_Nvp **result);
-JIM_STATIC int JIM_API(Jim_Nvp_value2name)(Jim_Interp *interp, const Jim_Nvp *nvp_table, int value, Jim_Nvp **result );
+JIM_STATIC int JIM_API(Jim_Nvp_value2name)(Jim_Interp *interp, const Jim_Nvp *nvp_table, int value, Jim_Nvp **result);
-JIM_STATIC int JIM_API(Jim_Nvp_name2value_obj)(Jim_Interp *interp, const Jim_Nvp *nvp_table, Jim_Obj *name_obj, Jim_Nvp **result );
-JIM_STATIC int JIM_API(Jim_Nvp_name2value_obj_nocase)(Jim_Interp *interp, const Jim_Nvp *nvp_table, Jim_Obj *name_obj, Jim_Nvp **result );
-JIM_STATIC int JIM_API(Jim_Nvp_value2name_obj)(Jim_Interp *interp, const Jim_Nvp *nvp_table, Jim_Obj *value_obj, Jim_Nvp **result );
+JIM_STATIC int JIM_API(Jim_Nvp_name2value_obj)(Jim_Interp *interp, const Jim_Nvp *nvp_table, Jim_Obj *name_obj, Jim_Nvp **result);
+JIM_STATIC int JIM_API(Jim_Nvp_name2value_obj_nocase)(Jim_Interp *interp, const Jim_Nvp *nvp_table, Jim_Obj *name_obj, Jim_Nvp **result);
+JIM_STATIC int JIM_API(Jim_Nvp_value2name_obj)(Jim_Interp *interp, const Jim_Nvp *nvp_table, Jim_Obj *value_obj, Jim_Nvp **result);
/** prints a nice 'unknown' parameter error message to the 'result' */
JIM_STATIC void JIM_API(Jim_SetResult_NvpUnknown)(Jim_Interp *interp,
Jim_Obj *param_name,
Jim_Obj *param_value,
- const Jim_Nvp *nvp_table );
+ const Jim_Nvp *nvp_table);
/** Debug: convert argc/argv into a printable string for printf() debug
*
* For example might want do this:
* \code
- * fp = fopen("some.file.log", "a" );
- * fprintf(fp, "PARAMS are: %s\n", Jim_DebugArgvString(interp, argc, argv ) );
+ * fp = fopen("some.file.log", "a");
+ * fprintf(fp, "PARAMS are: %s\n", Jim_DebugArgvString(interp, argc, argv));
* fclose(fp);
* \endcode
*/
-JIM_STATIC const char *JIM_API(Jim_Debug_ArgvString )(Jim_Interp *interp, int argc, Jim_Obj *const *argv );
+JIM_STATIC const char *JIM_API(Jim_Debug_ArgvString)(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
/** A TCL -ish GetOpt like code.
* \code
* Jim_GetOptInfo goi;
*
- * Jim_GetOpt_Setup(&goi, interp, argc, argv );
+ * Jim_GetOpt_Setup(&goi, interp, argc, argv);
*
- * while (goi.argc ){
- * e = Jim_GetOpt_Nvp(&goi, nvp_options, &n );
- * if (e != JIM_OK ){
- * Jim_GetOpt_NvpUnknown(&goi, nvp_options, 0 );
+ * while (goi.argc){
+ * e = Jim_GetOpt_Nvp(&goi, nvp_options, &n);
+ * if (e != JIM_OK){
+ * Jim_GetOpt_NvpUnknown(&goi, nvp_options, 0);
* return e;
* }
*
- * switch (n->value ){
+ * switch (n->value){
* case ALIVE:
* printf("Option ALIVE specified\n");
* break;
* case FIRST:
- * if (goi.argc < 1 ){
+ * if (goi.argc < 1){
* .. not enough args error ..
* }
- * Jim_GetOpt_String(&goi, &cp, NULL );
- * printf("FIRSTNAME: %s\n", cp );
+ * Jim_GetOpt_String(&goi, &cp, NULL);
+ * printf("FIRSTNAME: %s\n", cp);
* case AGE:
- * Jim_GetOpt_Wide(&goi, &w );
- * printf("AGE: %d\n", (int)(w) );
+ * Jim_GetOpt_Wide(&goi, &w);
+ * printf("AGE: %d\n", (int)(w));
* break;
* case POLITICS:
- * e = Jim_GetOpt_Nvp(&goi, nvp_politics, &n );
- * if (e != JIM_OK ){
- * Jim_GetOpt_NvpUnknown(&goi, nvp_politics, 1 );
+ * e = Jim_GetOpt_Nvp(&goi, nvp_politics, &n);
+ * if (e != JIM_OK){
+ * Jim_GetOpt_NvpUnknown(&goi, nvp_politics, 1);
* return e;
* }
* }
* \code
* Jim_GetOptInfo goi;
*
- * Jim_GetOptSetup(&goi, interp, argc, argv );
+ * Jim_GetOptSetup(&goi, interp, argc, argv);
* \endcode
*/
-JIM_STATIC int JIM_API(Jim_GetOpt_Setup )(Jim_GetOptInfo *goi,
+JIM_STATIC int JIM_API(Jim_GetOpt_Setup)(Jim_GetOptInfo *goi,
Jim_Interp *interp,
int argc,
- Jim_Obj * const * argv );
+ Jim_Obj * const * argv);
/** Debug - Dump parameters to stderr
* \param goi - current parameters
*/
-JIM_STATIC void JIM_API(Jim_GetOpt_Debug )(Jim_GetOptInfo *goi);
+JIM_STATIC void JIM_API(Jim_GetOpt_Debug)(Jim_GetOptInfo *goi);
* \param puthere - where param is put
*
*/
-JIM_STATIC int JIM_API(Jim_GetOpt_Obj)(Jim_GetOptInfo *goi, Jim_Obj **puthere );
+JIM_STATIC int JIM_API(Jim_GetOpt_Obj)(Jim_GetOptInfo *goi, Jim_Obj **puthere);
/** Remove argv[0] as string.
*
* \param puthere - where param is put
* \param len - return its length
*/
-JIM_STATIC int JIM_API(Jim_GetOpt_String )(Jim_GetOptInfo *goi, char **puthere, int *len );
+JIM_STATIC int JIM_API(Jim_GetOpt_String)(Jim_GetOptInfo *goi, char **puthere, int *len);
/** Remove argv[0] as double.
*
* \param puthere - where param is put.
*
*/
-JIM_STATIC int JIM_API(Jim_GetOpt_Double )(Jim_GetOptInfo *goi, double *puthere );
+JIM_STATIC int JIM_API(Jim_GetOpt_Double)(Jim_GetOptInfo *goi, double *puthere);
/** Remove argv[0] as wide.
*
* \param goi - get opt info
* \param puthere - where param is put.
*/
-JIM_STATIC int JIM_API(Jim_GetOpt_Wide )(Jim_GetOptInfo *goi, jim_wide *puthere );
+JIM_STATIC int JIM_API(Jim_GetOpt_Wide)(Jim_GetOptInfo *goi, jim_wide *puthere);
/** Remove argv[0] as NVP.
*
* \param puthere - where param is put.
*
*/
-JIM_STATIC int JIM_API(Jim_GetOpt_Nvp)(Jim_GetOptInfo *goi, const Jim_Nvp *lookup, Jim_Nvp **puthere );
+JIM_STATIC int JIM_API(Jim_GetOpt_Nvp)(Jim_GetOptInfo *goi, const Jim_Nvp *lookup, Jim_Nvp **puthere);
/** Create an appropriate error message for an NVP.
*
* Example:
* \code
*
- * while (goi.argc ){
+ * while (goi.argc){
* // Get the next option
- * e = Jim_GetOpt_Nvp(&goi, cmd_options, &n );
- * if (e != JIM_OK ){
+ * e = Jim_GetOpt_Nvp(&goi, cmd_options, &n);
+ * if (e != JIM_OK){
* // option was not recognized
* // pass 'hadprefix = 0' because there is no prefix
- * Jim_GetOpt_NvpUnknown(&goi, cmd_options, 0 );
+ * Jim_GetOpt_NvpUnknown(&goi, cmd_options, 0);
* return e;
* }
*
- * switch (n->value ){
+ * switch (n->value){
* case OPT_SEX:
* // handle: --sex male | female | lots | needmore
- * e = Jim_GetOpt_Nvp(&goi, &nvp_sex, &n );
- * if (e != JIM_OK ){
- * Jim_GetOpt_NvpUnknown(&ogi, nvp_sex, 1 );
+ * e = Jim_GetOpt_Nvp(&goi, &nvp_sex, &n);
+ * if (e != JIM_OK){
+ * Jim_GetOpt_NvpUnknown(&ogi, nvp_sex, 1);
* return e;
* }
- * printf("Code: (%d) is %s\n", n->value, n->name );
+ * printf("Code: (%d) is %s\n", n->value, n->name);
* break;
* case ...:
* [snip]
* \endcode
*
*/
-JIM_STATIC void JIM_API(Jim_GetOpt_NvpUnknown)(Jim_GetOptInfo *goi, const Jim_Nvp *lookup, int hadprefix );
+JIM_STATIC void JIM_API(Jim_GetOpt_NvpUnknown)(Jim_GetOptInfo *goi, const Jim_Nvp *lookup, int hadprefix);
/** Remove argv[0] as Enum
* \param puthere - where param is put.
*
*/
-JIM_STATIC int JIM_API(Jim_GetOpt_Enum)(Jim_GetOptInfo *goi, const char * const * lookup, int *puthere );
+JIM_STATIC int JIM_API(Jim_GetOpt_Enum)(Jim_GetOptInfo *goi, const char * const * lookup, int *puthere);
#undef JIM_STATIC
JIM_GET_API(StackPop);
JIM_GET_API(StackPeek);
JIM_GET_API(FreeStackElements);
- JIM_GET_API(fprintf );
- JIM_GET_API(vfprintf );
- JIM_GET_API(fwrite );
- JIM_GET_API(fread );
- JIM_GET_API(fflush );
- JIM_GET_API(fgets );
+ JIM_GET_API(fprintf);
+ JIM_GET_API(vfprintf);
+ JIM_GET_API(fwrite);
+ JIM_GET_API(fread);
+ JIM_GET_API(fflush);
+ JIM_GET_API(fgets);
JIM_GET_API(Nvp_name2value);
JIM_GET_API(Nvp_name2value_nocase);
JIM_GET_API(Nvp_name2value_simple);
/* Avoid fn call and building parameter list if we're not outputting the information.
* Matters on feeble CPUs for DEBUG/INFO statements that are involved frequently */
-#define LOG_LEVEL_IS(FOO ) ((debug_level) >= (FOO))
+#define LOG_LEVEL_IS(FOO) ((debug_level) >= (FOO))
#define LOG_DEBUG(expr ...) \
((debug_level >= LOG_LVL_DEBUG) ? log_printf_lf (LOG_LVL_DEBUG, __FILE__, __LINE__, __FUNCTION__, expr) , 0 : 0)
#endif /* _WIN32 */
/* generic socket functions for Windows and Posix */
-static __inline int write_socket(int handle, const void *buffer, unsigned int count )
+static __inline int write_socket(int handle, const void *buffer, unsigned int count)
{
#ifdef _WIN32
return send(handle, buffer, count, 0);
#endif
}
-static __inline int read_socket(int handle, void *buffer, unsigned int count )
+static __inline int read_socket(int handle, void *buffer, unsigned int count)
{
#ifdef _WIN32
return recv(handle, buffer, count, 0);
{
#ifdef _WIN32
unsigned long nonblock = 1;
- ioctlsocket(fd, FIONBIO, &nonblock );
+ ioctlsocket(fd, FIONBIO, &nonblock);
#else
int oldopts = fcntl(fd, F_GETFL, 0);
fcntl(fd, F_SETFL, oldopts | O_NONBLOCK);
OSVERSIONINFO version;
version.dwOSVersionInfoSize = sizeof version;
- if (!GetVersionEx(&version )) {
+ if (!GetVersionEx(&version)) {
errno = EINVAL;
return -1;
}
if (version.dwPlatformId != VER_PLATFORM_WIN32_NT)
return 0;
- h = CreateFile("\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
+ h = CreateFile("\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) {
errno = ENODEV;
return -1;
}
- CloseHandle(h );
+ CloseHandle(h);
return 0;
}
break;
case JTAG_RUNTEST:
#ifdef _DEBUG_JTAG_IO_
- LOG_DEBUG("runtest %i cycles, end in %s", cmd->cmd.runtest->num_cycles, tap_state_name(cmd->cmd.runtest->end_state) );
+ LOG_DEBUG("runtest %i cycles, end in %s", cmd->cmd.runtest->num_cycles, tap_state_name(cmd->cmd.runtest->end_state));
#endif
bitbang_end_state(cmd->cmd.runtest->end_state);
bitbang_runtest(cmd->cmd.runtest->num_cycles);
break;
case JTAG_SCAN:
#ifdef _DEBUG_JTAG_IO_
- LOG_DEBUG("%s scan end in %s", (cmd->cmd.scan->ir_scan) ? "IR" : "DR", tap_state_name(cmd->cmd.scan->end_state) );
+ LOG_DEBUG("%s scan end in %s", (cmd->cmd.scan->ir_scan) ? "IR" : "DR", tap_state_name(cmd->cmd.scan->end_state));
#endif
bitbang_end_state(cmd->cmd.scan->end_state);
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
bitq_in_bufsize *= 2;
}
/* if necessary, allocate buffer and check for malloc error */
- if (bitq_in_buffer == NULL && (bitq_in_buffer = malloc(bitq_in_bufsize) ) == NULL)
+ if (bitq_in_buffer == NULL && (bitq_in_buffer = malloc(bitq_in_bufsize)) == NULL)
{
LOG_ERROR("malloc error");
exit(-1);
/* field scanning */
while (bitq_in_state.bit_pos < field->num_bits)
{
- if ((tdo = bitq_interface->in() ) < 0 )
+ if ((tdo = bitq_interface->in()) < 0)
{
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("bitq in EOF");
{
bitq_interface->out(tms, tdi, tdo_req);
/* check and process the input queue */
- if (bitq_interface->in_rdy() )
+ if (bitq_interface->in_rdy())
bitq_in_proc();
}
else
{
LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(
- tap_get_state() ), tap_state_name(cmd->path[i]) );
+ tap_get_state()), tap_state_name(cmd->path[i]));
exit(-1);
}
tap_set_state(cmd->path[i]);
}
- tap_set_end_state(tap_get_state() );
+ tap_set_end_state(tap_get_state());
}
bitq_io(0, 0, 0);
/* finish in end_state */
- if (tap_get_state() != tap_get_end_state() )
- bitq_state_move(tap_get_end_state() );
+ if (tap_get_state() != tap_get_end_state())
+ bitq_state_move(tap_get_end_state());
}
out_ptr = field->out_value;
for (bit_cnt = field->num_bits; bit_cnt > 1; bit_cnt--)
{
- bitq_io(0, ((*out_ptr) & out_mask ) != 0, tdo_req);
+ bitq_io(0, ((*out_ptr) & out_mask) != 0, tdo_req);
if (out_mask == 0x80)
{
out_mask = 0x01;
out_mask <<= 1;
}
- bitq_io(pause, ((*out_ptr) & out_mask ) != 0, tdo_req);
+ bitq_io(pause, ((*out_ptr) & out_mask) != 0, tdo_req);
}
if (pause)
#ifdef _DEBUG_JTAG_IO_
LOG_DEBUG("reset trst: %i srst %i", cmd->cmd.reset->trst, cmd->cmd.reset->srst);
#endif
- if ((cmd->cmd.reset->trst == 1) || (cmd->cmd.reset->srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST) ) )
+ if ((cmd->cmd.reset->trst == 1) || (cmd->cmd.reset->srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
{
tap_set_state(TAP_RESET);
}
bitq_interface->reset(cmd->cmd.reset->trst, cmd->cmd.reset->srst);
- if (bitq_interface->in_rdy() )
+ if (bitq_interface->in_rdy())
bitq_in_proc();
break;
LOG_DEBUG("statemove end in %i", cmd->cmd.statemove->end_state);
#endif
bitq_end_state(cmd->cmd.statemove->end_state);
- bitq_state_move(tap_get_end_state() ); /* uncoditional TAP move */
+ bitq_state_move(tap_get_end_state()); /* uncoditional TAP move */
break;
case JTAG_PATHMOVE:
#endif
bitq_end_state(cmd->cmd.scan->end_state);
bitq_scan(cmd->cmd.scan);
- if (tap_get_state() != tap_get_end_state() )
- bitq_state_move(tap_get_end_state() );
+ if (tap_get_state() != tap_get_end_state())
+ bitq_state_move(tap_get_end_state());
break;
case JTAG_SLEEP:
LOG_DEBUG("sleep %i", cmd->cmd.sleep->us);
#endif
bitq_interface->sleep(cmd->cmd.sleep->us);
- if (bitq_interface->in_rdy() )
+ if (bitq_interface->in_rdy())
bitq_in_proc();
break;
}
#ifdef _DEBUG_JTAG_IO_
- //LOG_DEBUG("bit_count totalling: %i", bit_count );
+ //LOG_DEBUG("bit_count totalling: %i", bit_count);
#endif
return bit_count;
LOG_DEBUG("cur_state=%s goal_state=%s",
tap_state_name(cur_state),
- tap_state_name(goal_state) );
+ tap_state_name(goal_state));
- if (goal_state == cur_state )
+ if (goal_state == cur_state)
; /* nothing to do */
- else if (goal_state == TAP_RESET )
+ else if (goal_state == TAP_RESET)
{
jtag_add_tlr();
}
- else if (tap_is_state_stable(cur_state) && tap_is_state_stable(goal_state) )
+ else if (tap_is_state_stable(cur_state) && tap_is_state_stable(goal_state))
{
unsigned tms_bits = tap_get_tms_path(cur_state, goal_state);
unsigned tms_count = tap_get_tms_path_len(cur_state, goal_state);
jtag_add_pathmove(tms_count, moves);
}
else if (tap_state_transition(cur_state, true) == goal_state
- || tap_state_transition(cur_state, false) == goal_state )
+ || tap_state_transition(cur_state, false) == goal_state)
{
jtag_add_pathmove(1, &goal_state);
}
(unsigned int)idcode,
(unsigned int)EXTRACT_MFG(idcode),
(unsigned int)EXTRACT_PART(idcode),
- (unsigned int)EXTRACT_VER(idcode) );
+ (unsigned int)EXTRACT_VER(idcode));
}
static bool jtag_idcode_is_final(uint32_t idcode)
total_ir_length = 0;
for (;;){
tap = jtag_tap_next_enabled(tap);
- if (tap == NULL ){
+ if (tap == NULL){
break;
}
total_ir_length += tap->ir_length;
int val;
for (;;){
tap = jtag_tap_next_enabled(tap);
- if (tap == NULL ){
+ if (tap == NULL){
break;
}
LOG_DEBUG("Init JTAG chain");
tap = jtag_tap_next_enabled(NULL);
- if (tap == NULL ){
+ if (tap == NULL){
LOG_ERROR("There are no enabled taps?");
return ERROR_JTAG_INIT_FAILED;
}
return ERROR_OK;
}
-int interface_jtag_add_clocks(int num_cycles )
+int interface_jtag_add_clocks(int num_cycles)
{
/* allocate memory for a new list member */
jtag_command_t * cmd = cmd_queue_alloc(sizeof(jtag_command_t));
static void dummy_write(int tck, int tms, int tdi)
{
/* TAP standard: "state transitions occur on rising edge of clock" */
- if (tck != dummy_clock )
+ if (tck != dummy_clock)
{
- if (tck )
+ if (tck)
{
tap_state_t old_state = dummy_state;
- dummy_state = tap_state_transition(old_state, tms );
+ dummy_state = tap_state_transition(old_state, tms);
- if (old_state != dummy_state )
+ if (old_state != dummy_state)
{
- if (clock_count )
+ if (clock_count)
{
LOG_DEBUG("dummy_tap: %d stable clocks", clock_count);
clock_count = 0;
}
- LOG_DEBUG("dummy_tap: %s", tap_state_name(dummy_state) );
+ LOG_DEBUG("dummy_tap: %s", tap_state_name(dummy_state));
#if defined(DEBUG)
if (dummy_state == TAP_DRCAPTURE)
if (trst || (srst && (jtag_get_reset_config() & RESET_SRST_PULLS_TRST)))
dummy_state = TAP_RESET;
- LOG_DEBUG("reset to: %s", tap_state_name(dummy_state) );
+ LOG_DEBUG("reset to: %s", tap_state_name(dummy_state));
}
static int dummy_khz(int khz, int *jtag_speed)
DEBUG_JTAG_IO("pathmove: %i states, current: %s end: %s", num_states,
tap_state_name(tap_get_state()),
tap_state_name(path[num_states-1])
- );
+);
/* only send the maximum buffer size that FT2232C can handle */
predicted_size = 3 * CEIL(num_states, 7);
OSVERSIONINFO version;
version.dwOSVersionInfoSize = sizeof version;
- if (!GetVersionEx(&version )) {
+ if (!GetVersionEx(&version)) {
errno = EINVAL;
return -1;
}
if (version.dwPlatformId != VER_PLATFORM_WIN32_NT)
return 0;
- h = CreateFile("\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
+ h = CreateFile("\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) {
errno = ENODEV;
return -1;
}
- CloseHandle(h );
+ CloseHandle(h);
return 0;
}
LOG_WARNING("No gw16012 port specified, using default '0x378' (LPT1)");
}
- LOG_DEBUG("requesting privileges for parallel port 0x%lx...", (long unsigned)(gw16012_port) );
+ LOG_DEBUG("requesting privileges for parallel port 0x%lx...", (long unsigned)(gw16012_port));
#if PARPORT_USE_GIVEIO == 1
if (gw16012_get_giveio_access() != 0)
#else /* PARPORT_USE_GIVEIO */
*/
static tap_state_t state_follower = TAP_RESET;
-void tap_set_state_impl(tap_state_t new_state )
+void tap_set_state_impl(tap_state_t new_state)
{
/* this is the state we think the TAPs are in now, was cur_state */
state_follower = new_state;
*/
static tap_state_t end_state_follower = TAP_RESET;
-void tap_set_end_state(tap_state_t new_end_state )
+void tap_set_end_state(tap_state_t new_end_state)
{
/* this is the state we think the TAPs will be in at completion of the
current TAP operation, was end_state
}
-int tap_move_ndx(tap_state_t astate )
+int tap_move_ndx(tap_state_t astate)
{
/* given a stable state, return the index into the tms_seqs[] array within tap_get_tms_path() */
int ndx;
- switch (astate )
+ switch (astate)
{
case TAP_RESET: ndx = 0; break;
case TAP_DRSHIFT: ndx = 2; break;
case TAP_IRSHIFT: ndx = 4; break;
case TAP_IRPAUSE: ndx = 5; break;
default:
- LOG_ERROR("fatal: unstable state \"%s\" used in tap_move_ndx()", tap_state_name(astate) );
+ LOG_ERROR("fatal: unstable state \"%s\" used in tap_move_ndx()", tap_state_name(astate));
exit(1);
}
static tms_table *tms_seqs=&short_tms_seqs;
-int tap_get_tms_path(tap_state_t from, tap_state_t to )
+int tap_get_tms_path(tap_state_t from, tap_state_t to)
{
return (*tms_seqs)[tap_move_ndx(from)][tap_move_ndx(to)].bits;
}
-int tap_get_tms_path_len(tap_state_t from, tap_state_t to )
+int tap_get_tms_path_len(tap_state_t from, tap_state_t to)
{
return (*tms_seqs)[tap_move_ndx(from)][tap_move_ndx(to)].bit_count;
}
/* A switch () is used because it is symbol dependent
(not value dependent like an array), and can also check bounds.
*/
- switch (astate )
+ switch (astate)
{
case TAP_RESET:
case TAP_IDLE:
new_state = TAP_IREXIT2;
break;
default:
- LOG_ERROR("fatal: invalid argument cur_state=%d", cur_state );
+ LOG_ERROR("fatal: invalid argument cur_state=%d", cur_state);
exit(1);
break;
}
new_state = TAP_IRPAUSE;
break;
default:
- LOG_ERROR("fatal: invalid argument cur_state=%d", cur_state );
+ LOG_ERROR("fatal: invalid argument cur_state=%d", cur_state);
exit(1);
break;
}
{
const char* ret;
- switch (state )
+ switch (state)
{
case TAP_RESET: ret = "RESET"; break;
case TAP_IDLE: ret = "RUN/IDLE"; break;
{
tap_state_t x;
- for (x = 0 ; x < TAP_NUM_STATES ; x++ ){
+ for (x = 0 ; x < TAP_NUM_STATES ; x++){
/* be nice to the human */
- if (0 == strcasecmp(name, tap_state_name(x) ) ){
+ if (0 == strcasecmp(name, tap_state_name(x))){
return x;
}
}
#if defined(_DEBUG_JTAG_IO_)
#define tap_set_state(new_state) \
do { \
- LOG_DEBUG("tap_set_state(%s)", tap_state_name(new_state) ); \
+ LOG_DEBUG("tap_set_state(%s)", tap_state_name(new_state)); \
tap_set_state_impl(new_state); \
} while (0)
#else
OSVERSIONINFO version;
version.dwOSVersionInfoSize = sizeof version;
- if (!GetVersionEx(&version )) {
+ if (!GetVersionEx(&version)) {
errno = EINVAL;
return -1;
}
if (version.dwPlatformId != VER_PLATFORM_WIN32_NT)
return 0;
- h = CreateFile("\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
+ h = CreateFile("\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) {
errno = ENODEV;
return -1;
}
- CloseHandle(h );
+ CloseHandle(h);
return 0;
}
#define DTC_CMD_SHIFT_TMS_TDI_BIT_PAIR(tms, tdi, tdo) ((0x8 << 4) | (\
(tms) ? (1 << 0) : 0 \
- ) | (\
+) | (\
(tdi) ? (1 << 1) : 0 \
- ) | (\
+) | (\
(tdo) ? (1 << 3) : 0 \
- ))
+))
/* Single bit shift. */
/* tms and tdi are the levels shifted out on TMS and TDI, respectively. */
/* tdo indicates whether a byte will be returned in the reply buffer with its least significant bit set to reflect TDO */
usb_buffer_p,
0,
sizeof(usb_buffer) - (usb_buffer_p - usb_buffer)
- );
+);
usb_ret = usb_bulk_write(
pHDev,
USB_EP1OUT_ADDR,
(char *)usb_buffer, sizeof(usb_buffer),
USB_TIMEOUT_MS
- );
+);
return(usb_ret);
}
usb_buffer + 4,
0,
sizeof(usb_buffer) - 4
- );
+);
remain = length;
count = 0;
pHDev, USB_EP1OUT_ADDR,
usb_buffer, sizeof(usb_buffer),
USB_TIMEOUT_MS
- );
+);
if (usb_ret < sizeof(usb_buffer)) {
break;
pHDev, USB_EP1IN_ADDR,
buffer, length,
USB_TIMEOUT_MS
- );
+);
if (usb_ret < length) {
break;
usb_buffer + 4,
buffer,
length
- );
+);
memset(
usb_buffer + 4 + length,
0,
sizeof(usb_buffer) - 4 - length
- );
+);
usb_ret = usb_bulk_write(
pHDev, USB_EP1OUT_ADDR,
(char *)usb_buffer, sizeof(usb_buffer),
USB_TIMEOUT_MS
- );
+);
if ((size_t)usb_ret < sizeof(usb_buffer)) {
break;
usb_err = ep1_generic_commandl(
pHDev, 1,
EP1_CMD_DTC_STOP
- );
+);
if (usb_err < 0) return(usb_err);
while (length) {
pHDev,
DTC_LOAD_BUFFER,
header->length + 1, buffer
- );
+);
if (usb_err < 0) return(usb_err);
/* Load it into the DTC. */
EP1_CMD_DTC_LOAD,
(DTC_LOAD_BUFFER >> 8),
DTC_LOAD_BUFFER
- );
+);
if (usb_err < 0) return(usb_err);
break;
EP1_CMD_DTC_CALL,
buffer[0],
EP1_CMD_DTC_WAIT
- );
+);
if (usb_err < 0) return(usb_err);
break;
pHDev,
ST7_USB_BUF_EP0OUT + lut_start,
header->length + 1, buffer
- );
+);
if (usb_err < 0) return(usb_err);
break;
ST7_EP2TXR >> 8,
ST7_EP2TXR,
1
- );
+);
if (usb_err < 0) return(usb_err);
/* read back ep2txr */
pHDev, USB_EP1IN_ADDR,
(char *)&ep2txr, 1,
USB_TIMEOUT_MS
- );
+);
if (usb_err < 0) return(usb_err);
usb_err = ep1_generic_commandl(
EP1_CMD_DTC_CALL, /* start running the DTC */
dtc_entry_download,
EP1_CMD_DTC_GET_CACHED_STATUS
- );
+);
if (usb_err < 0) return(usb_err);
/* wait for completion */
pHDev, USB_EP1IN_ADDR,
(char *)&ep2txr, 1,
USB_TIMEOUT_MS
- );
+);
return(usb_err);
}
USB_EP2OUT_ADDR,
(char *)command_buffer, USB_EP2BANK_SIZE,
USB_TIMEOUT_MS
- );
+);
if (usb_err < 0) return(usb_err);
DTC_STATUS_POLL_BYTE >> 8,
DTC_STATUS_POLL_BYTE,
1
- );
+);
if (usb_err < 0) return(usb_err);
usb_err = usb_bulk_read(
USB_EP1IN_ADDR,
(char *)ep2_buffer, 1,
USB_TIMEOUT_MS
- );
+);
if (usb_err < 0) return(usb_err);
if (ep2_buffer[0] & 0x01) break;
if (!--i) {
LOG_ERROR("%s, %d: too many retries waiting for DTC status\n",
__FILE__, __LINE__
- );
+);
return(-ETIMEDOUT);
}
}
USB_EP2IN_ADDR,
(char *)ep2_buffer, sizeof(ep2_buffer),
USB_TIMEOUT_MS
- );
+);
if (usb_err < (int)sizeof(ep2_buffer)) {
LOG_ERROR("%s, %d: Read of endpoint 2 returned %d\n",
__FILE__, __LINE__, usb_err
- );
+);
return(usb_err);
}
usb_err = dtc_run_download(pHDev,
dtc_queue.cmd_buffer, dtc_queue.cmd_index,
NULL, 0
- );
+);
if (usb_err < 0) {
LOG_ERROR("dtc_run_download: %s\n", usb_strerror());
exit(1);
usb_err = dtc_run_download(pHDev,
dtc_queue.cmd_buffer, dtc_queue.cmd_index,
reply_buffer, dtc_queue.reply_index
- );
+);
if (usb_err < 0) {
LOG_ERROR("dtc_run_download: %s\n", usb_strerror());
exit(1);
rq_p = dtc_queue.rq_head;
rq_p != NULL;
rq_p = rq_next
- ) {
+) {
tdo_p = rq_p->scan.buffer + (rq_p->scan.offset / 8);
tdo_mask = 1 << (rq_p->scan.offset % 8);
;
bit_cnt;
bit_cnt--
- ) {
+) {
if (*dtc_p & dtc_mask) {
*tdo_p |= tdo_mask;
} else {
x = *dtc_p++;
if ((
rq_p->scan.type == SCAN_IN
- ) && (
+) && (
rq_p->scan.offset != rq_p->scan.size - 1
- )) {
+)) {
/* extra bits were sent as a full byte with padding on the end */
dtc_mask = 1 << (8 - 1);
} else {
;
bit_cnt;
bit_cnt--
- ) {
+) {
if (x & dtc_mask) {
*tdo_p |= tdo_mask;
} else {
ST7_PADR >> 8,
ST7_PADR,
1
- );
+);
if (usb_err < 0) {
LOG_ERROR("%s", usb_strerror());
exit(1);
pHDev, USB_EP1IN_ADDR,
(char *)&bitmap, 1,
USB_TIMEOUT_MS
- );
+);
if (usb_err < 1) {
LOG_ERROR("%s", usb_strerror());
exit(1);
ST7_PBDDR >> 8,
ST7_PBDDR,
1
- );
+);
if (usb_err < 0) {
LOG_ERROR("%s", usb_strerror());
exit(1);
pHDev, USB_EP1IN_ADDR,
(char *)&bitmap, 1,
USB_TIMEOUT_MS
- );
+);
if (usb_err < 1) {
LOG_ERROR("%s", usb_strerror());
exit(1);
1,
bitmap,
EP1_CMD_DTC_GET_CACHED_STATUS
- );
+);
if (usb_err < 0) {
LOG_ERROR("%s", usb_strerror());
exit(1);
pHDev, USB_EP1IN_ADDR,
(char *)&bitmap, 1,
USB_TIMEOUT_MS
- );
+);
if (usb_err < 1) {
LOG_ERROR("%s", usb_strerror());
exit(1);
(!ir_scan && (tap_get_state() == TAP_DRSHIFT))
||
(ir_scan && (tap_get_state() == TAP_IRSHIFT))
- )) {
+)) {
saved_end_state = tap_get_end_state();
rlink_end_state(ir_scan ? TAP_IRSHIFT : TAP_DRSHIFT);
rlink_state_move();
/* make sure there's room for stop, byte op, and one byte */
if (
(dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1))
- ) {
+) {
dtc_queue_run();
}
type, buffer, scan_size, tdi_bit_offset,
chunk_bits,
cmd
- ) == NULL) {
+) == NULL) {
LOG_ERROR("enqueuing DTC reply entry: %s\n", strerror(errno));
exit(1);
}
(dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1))
||
(dtc_queue.reply_index >= USB_EP2IN_SIZE - (1))
- ) {
+) {
dtc_queue_run();
}
type, buffer, scan_size, tdi_bit_offset,
extra_bits,
cmd
- ) == NULL) {
+) == NULL) {
LOG_ERROR("enqueuing DTC reply entry: %s\n", strerror(errno));
exit(1);
}
(dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1))
||
(dtc_queue.reply_index >= USB_EP2IN_SIZE - (1))
- ) {
+) {
dtc_queue_run();
}
type, buffer, scan_size, tdi_bit_offset,
1,
cmd
- ) == NULL) {
+) == NULL) {
LOG_ERROR("enqueuing DTC reply entry: %s\n", strerror(errno));
exit(1);
}
ep1_generic_commandl(pHDev, 2,
EP1_CMD_SET_PORTD_LEDS,
~(ST7_PD_NBUSY_LED)
- );
+);
#endif
while (cmd)
ep1_generic_commandl(pHDev, 2,
EP1_CMD_SET_PORTD_LEDS,
~0
- );
+);
#endif
return retval;
speed = rlink_speed_table[rlink_speed_table_size - 1].prescaler;
}
- for (i = rlink_speed_table_size; i--; ) {
+ for (i = rlink_speed_table_size; i--;) {
if (rlink_speed_table[i].prescaler == speed) {
if (dtc_load_from_buffer(pHDev, rlink_speed_table[i].dtc, rlink_speed_table[i].dtc_size) != 0) {
LOG_ERROR("An error occurred while trying to load DTC code for speed \"%d\".\n", speed);
LOG_ERROR("%s, %d: starting DTC: %s",
__FILE__, __LINE__,
usb_strerror()
- );
+);
exit(1);
}
) {
int i;
- for (i = rlink_speed_table_size; i--; ) {
+ for (i = rlink_speed_table_size; i--;) {
if (rlink_speed_table[i].prescaler == speed) {
*khz = rlink_speed_table[i].khz;
return(ERROR_OK);
return ERROR_FAIL;
}
- for (i = rlink_speed_table_size; i--; ) {
+ for (i = rlink_speed_table_size; i--;) {
if (rlink_speed_table[i].khz <= khz) {
*speed = rlink_speed_table[i].prescaler;
return(ERROR_OK);
handle_dtc_directory_command,
COMMAND_CONFIG,
"The directory in which to search for DTC load images"
- );
+);
#endif
return ERROR_OK;
for (dev = bus->devices; dev; dev = dev->next)
{
- if ((dev->descriptor.idVendor == USB_IDVENDOR) && (dev->descriptor.idProduct == USB_IDPRODUCT) )
+ if ((dev->descriptor.idVendor == USB_IDVENDOR) && (dev->descriptor.idProduct == USB_IDPRODUCT))
{
found = 1;
LOG_DEBUG("Found device on bus.\n");
do
{
- if (dev->descriptor.bNumConfigurations > 1 )
+ if (dev->descriptor.bNumConfigurations > 1)
{
LOG_ERROR("Whoops! NumConfigurations is not 1, don't know what to do...\n");
break;
}
- if (dev->config->bNumInterfaces > 1 )
+ if (dev->config->bNumInterfaces > 1)
{
LOG_ERROR("Whoops! NumInterfaces is not 1, don't know what to do...\n");
break;
}
pHDev = usb_open(dev);
- if (!pHDev )
+ if (!pHDev)
LOG_ERROR ("Failed to open device.\n");
else
{
if (!i)
{
- if (usb_set_altinterface(pHDev,0) )
+ if (usb_set_altinterface(pHDev,0))
{
LOG_ERROR("Failed to set interface.\n");
break;
}
}
- if (!found )
+ if (!found)
{
LOG_ERROR("No device found on bus.\n");
exit(1);
}
- if (!success )
+ if (!success)
{
LOG_ERROR("Initialisation failed.");
exit(1);
j = ep1_generic_commandl(
pHDev, 1,
EP1_CMD_GET_FWREV
- );
+);
if (j < USB_EP1OUT_SIZE) {
LOG_ERROR("USB write error: %s", usb_strerror());
return(ERROR_FAIL);
pHDev, USB_EP1IN_ADDR,
(char *)reply_buffer, sizeof(reply_buffer),
200
- );
+);
if (j != -ETIMEDOUT) break;
}
ST7_PEDR,
1,
ST7_PE_ADAPTER_SENSE_OUT
- );
+);
usb_bulk_read(
pHDev, USB_EP1IN_ADDR,
(char *)reply_buffer, 1,
USB_TIMEOUT_MS
- );
+);
if ((reply_buffer[0] & ST7_PE_ADAPTER_SENSE_IN) != 0) {
LOG_WARNING("target detection problem\n");
0x00, /* DR */
0x00, /* DDR */
0x00 /* OR */
- );
+);
usb_bulk_read(
pHDev, USB_EP1IN_ADDR,
(char *)reply_buffer, 1,
USB_TIMEOUT_MS
- );
+);
if ((reply_buffer[0] & ST7_PE_ADAPTER_SENSE_IN) == 0) {
ST7_PBDDR,
1,
0x00
- );
+);
/* make sure DTC is stopped, set VPP control, set up ports A and B */
ep1_generic_commandl(
ST7_PBDR,
1,
0x00
- );
+);
/* set LED updating mode and make sure they're unlit */
ep1_generic_commandl(
#endif
EP1_CMD_SET_PORTD_LEDS,
~0
- );
+);
tap_state_queue_init();
dtc_queue_init();
~0,
EP1_CMD_SET_PORTD_VPP,
~0
- );
+);
usb_release_interface(pHDev,0);
usb_close(pHDev);
switch (n->value) {
case JCFG_EVENT:
if (goi->argc == 0) {
- Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event ?event-name? ..." );
+ Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event ?event-name? ...");
return JIM_ERR;
}
- e = Jim_GetOpt_Nvp(goi, nvp_jtag_tap_event, &n );
+ e = Jim_GetOpt_Nvp(goi, nvp_jtag_tap_event, &n);
if (e != JIM_OK) {
Jim_GetOpt_NvpUnknown(goi, nvp_jtag_tap_event, 1);
return e;
return (w & v) != 0;
}
-static int jim_newtap_cmd(Jim_GetOptInfo *goi )
+static int jim_newtap_cmd(Jim_GetOptInfo *goi)
{
jtag_tap_t *pTap;
jim_wide w;
/*
* we expect CHIP + TAP + OPTIONS
* */
- if (goi->argc < 3 ){
+ if (goi->argc < 3){
Jim_SetResult_sprintf(goi->interp, "Missing CHIP TAP OPTIONS ....");
return JIM_ERR;
}
- Jim_GetOpt_String(goi, &cp, NULL );
+ Jim_GetOpt_String(goi, &cp, NULL);
pTap->chip = strdup(cp);
- Jim_GetOpt_String(goi, &cp, NULL );
+ Jim_GetOpt_String(goi, &cp, NULL);
pTap->tapname = strdup(cp);
/* name + dot + name + null */
x = strlen(pTap->chip) + 1 + strlen(pTap->tapname) + 1;
- cp = malloc(x );
- sprintf(cp, "%s.%s", pTap->chip, pTap->tapname );
+ cp = malloc(x);
+ sprintf(cp, "%s.%s", pTap->chip, pTap->tapname);
pTap->dotted_name = cp;
LOG_DEBUG("Creating New Tap, Chip: %s, Tap: %s, Dotted: %s, %d params",
/* clear them as we find them */
reqbits = (NTREQ_IRLEN | NTREQ_IRCAPTURE | NTREQ_IRMASK);
- while (goi->argc ){
- e = Jim_GetOpt_Nvp(goi, opts, &n );
- if (e != JIM_OK ){
- Jim_GetOpt_NvpUnknown(goi, opts, 0 );
+ while (goi->argc){
+ e = Jim_GetOpt_Nvp(goi, opts, &n);
+ if (e != JIM_OK){
+ Jim_GetOpt_NvpUnknown(goi, opts, 0);
return e;
}
- LOG_DEBUG("Processing option: %s", n->name );
- switch (n->value ){
+ LOG_DEBUG("Processing option: %s", n->name);
+ switch (n->value){
case NTAP_OPT_ENABLED:
pTap->disabled_after_reset = false;
break;
{
uint32_t *new_expected_ids;
- e = Jim_GetOpt_Wide(goi, &w );
+ e = Jim_GetOpt_Wide(goi, &w);
if (e != JIM_OK) {
Jim_SetResult_sprintf(goi->interp, "option: %s bad parameter", n->name);
return e;
case NTAP_OPT_IRLEN:
case NTAP_OPT_IRMASK:
case NTAP_OPT_IRCAPTURE:
- e = Jim_GetOpt_Wide(goi, &w );
- if (e != JIM_OK ){
- Jim_SetResult_sprintf(goi->interp, "option: %s bad parameter", n->name );
+ e = Jim_GetOpt_Wide(goi, &w);
+ if (e != JIM_OK){
+ Jim_SetResult_sprintf(goi->interp, "option: %s bad parameter", n->name);
return e;
}
switch (n->value){
break;
}
} /* switch (n->value) */
- } /* while (goi->argc ) */
+ } /* while (goi->argc) */
/* default is enabled-after-reset */
pTap->enabled = !pTap->disabled_after_reset;
tap->dotted_name,
e,
Jim_Nvp_value2name_simple(nvp_jtag_tap_event, e)->name,
- Jim_GetString(jteap->body, NULL) );
+ Jim_GetString(jteap->body, NULL));
if (Jim_EvalObj(interp, jteap->body) != JIM_OK) {
Jim_PrintErrorMessage(interp);
} else {
}
-static int jim_jtag_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv )
+static int jim_jtag_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_GetOptInfo goi;
int e;
context = Jim_GetAssocData(interp, "context");
/* go past the command */
- Jim_GetOpt_Setup(&goi, interp, argc-1, argv + 1 );
+ Jim_GetOpt_Setup(&goi, interp, argc-1, argv + 1);
- e = Jim_GetOpt_Nvp(&goi, jtag_cmds, &n );
- if (e != JIM_OK ){
- Jim_GetOpt_NvpUnknown(&goi, jtag_cmds, 0 );
+ e = Jim_GetOpt_Nvp(&goi, jtag_cmds, &n);
+ if (e != JIM_OK){
+ Jim_GetOpt_NvpUnknown(&goi, jtag_cmds, 0);
return e;
}
- Jim_SetEmptyResult(goi.interp );
- switch (n->value ){
+ Jim_SetEmptyResult(goi.interp);
+ switch (n->value){
case JTAG_CMD_INTERFACE:
/* return the name of the interface */
/* TCL code might need to know the exact type... */
/* FUTURE: we allow this as a means to "set" the interface. */
- if (goi.argc != 0 ){
+ if (goi.argc != 0){
Jim_WrongNumArgs(goi.interp, 1, goi.argv-1, "(no params)");
return JIM_ERR;
}
- Jim_SetResultString(goi.interp, jtag_interface->name, -1 );
+ Jim_SetResultString(goi.interp, jtag_interface->name, -1);
return JIM_OK;
case JTAG_CMD_INIT_RESET:
- if (goi.argc != 0 ){
+ if (goi.argc != 0){
Jim_WrongNumArgs(goi.interp, 1, goi.argv-1, "(no params)");
return JIM_ERR;
}
e = jtag_init_reset(context);
- if (e != ERROR_OK ){
+ if (e != ERROR_OK){
Jim_SetResult_sprintf(goi.interp, "error: %d", e);
return JIM_ERR;
}
return JIM_OK;
case JTAG_CMD_NEWTAP:
- return jim_newtap_cmd(&goi );
+ return jim_newtap_cmd(&goi);
break;
case JTAG_CMD_TAPISENABLED:
case JTAG_CMD_TAPENABLE:
case JTAG_CMD_TAPDISABLE:
- if (goi.argc != 1 ){
- Jim_SetResultString(goi.interp, "Too many parameters",-1 );
+ if (goi.argc != 1){
+ Jim_SetResultString(goi.interp, "Too many parameters",-1);
return JIM_ERR;
}
break;
case JTAG_CMD_CGET:
- if (goi.argc < 2 ){
+ if (goi.argc < 2){
Jim_WrongNumArgs(goi.interp, 0, NULL, "?tap-name? -option ...");
return JIM_ERR;
}
jtag_tap_t *t;
Jim_GetOpt_Obj(&goi, &o);
- t = jtag_tap_by_jim_obj(goi.interp, o );
- if (t == NULL ){
+ t = jtag_tap_by_jim_obj(goi.interp, o);
+ if (t == NULL){
return JIM_ERR;
}
break;
case JTAG_CMD_CONFIGURE:
- if (goi.argc < 3 ){
+ if (goi.argc < 3){
Jim_WrongNumArgs(goi.interp, 0, NULL, "?tap-name? -option ?VALUE? ...");
return JIM_ERR;
}
jtag_tap_t *t;
Jim_GetOpt_Obj(&goi, &o);
- t = jtag_tap_by_jim_obj(goi.interp, o );
- if (t == NULL ){
+ t = jtag_tap_by_jim_obj(goi.interp, o);
+ if (t == NULL){
return JIM_ERR;
}
* argv[ 3] = not actually used by anything but in the docs
*/
- if (argc < 4 ){
+ if (argc < 4){
command_print(cmd_ctx, "OLD DEPRECATED SYNTAX: Please use the NEW syntax");
return ERROR_OK;
}
command_print(cmd_ctx, "jtag newtap CHIP TAP -irlen %s -ircapture %s -irvalue %s",
args[0],
args[1],
- args[2] );
+ args[2]);
command_print(cmd_ctx, "Example: STM32 has 2 taps, the cortexM3(len4) + boundaryscan(len5)");
command_print(cmd_ctx, "jtag newtap stm32 cortexm3 ....., thus creating the tap: \"stm32.cortexm3\"");
command_print(cmd_ctx, "jtag newtap stm32 boundary ....., and the tap: \"stm32.boundary\"");
command_print(cmd_ctx, "And then refer to the taps by the dotted name.");
- newargs[0] = Jim_NewStringObj(interp, "jtag", -1 );
- newargs[1] = Jim_NewStringObj(interp, "newtap", -1 );
- sprintf(buf, "chip%d", jtag_tap_count() );
- newargs[2] = Jim_NewStringObj(interp, buf, -1 );
- sprintf(buf, "tap%d", jtag_tap_count() );
- newargs[3] = Jim_NewStringObj(interp, buf, -1 );
- newargs[4] = Jim_NewStringObj(interp, "-irlen", -1 );
- newargs[5] = Jim_NewStringObj(interp, args[0], -1 );
- newargs[6] = Jim_NewStringObj(interp, "-ircapture", -1 );
- newargs[7] = Jim_NewStringObj(interp, args[1], -1 );
- newargs[8] = Jim_NewStringObj(interp, "-irmask", -1 );
- newargs[9] = Jim_NewStringObj(interp, args[2], -1 );
+ newargs[0] = Jim_NewStringObj(interp, "jtag", -1);
+ newargs[1] = Jim_NewStringObj(interp, "newtap", -1);
+ sprintf(buf, "chip%d", jtag_tap_count());
+ newargs[2] = Jim_NewStringObj(interp, buf, -1);
+ sprintf(buf, "tap%d", jtag_tap_count());
+ newargs[3] = Jim_NewStringObj(interp, buf, -1);
+ newargs[4] = Jim_NewStringObj(interp, "-irlen", -1);
+ newargs[5] = Jim_NewStringObj(interp, args[0], -1);
+ newargs[6] = Jim_NewStringObj(interp, "-ircapture", -1);
+ newargs[7] = Jim_NewStringObj(interp, args[1], -1);
+ newargs[8] = Jim_NewStringObj(interp, "-irmask", -1);
+ newargs[9] = Jim_NewStringObj(interp, args[2], -1);
command_print(cmd_ctx, "NEW COMMAND:");
sprintf(buf, "%s %s %s %s %s %s %s %s %s %s",
- Jim_GetString(newargs[0], NULL ),
- Jim_GetString(newargs[1], NULL ),
- Jim_GetString(newargs[2], NULL ),
- Jim_GetString(newargs[3], NULL ),
- Jim_GetString(newargs[4], NULL ),
- Jim_GetString(newargs[5], NULL ),
- Jim_GetString(newargs[6], NULL ),
- Jim_GetString(newargs[7], NULL ),
- Jim_GetString(newargs[8], NULL ),
- Jim_GetString(newargs[9], NULL ) );
-
- e = jim_jtag_command(interp, 10, newargs );
- if (e != JIM_OK ){
- command_print(cmd_ctx, "%s", Jim_GetString(Jim_GetResult(interp), NULL ) );
+ Jim_GetString(newargs[0], NULL),
+ Jim_GetString(newargs[1], NULL),
+ Jim_GetString(newargs[2], NULL),
+ Jim_GetString(newargs[3], NULL),
+ Jim_GetString(newargs[4], NULL),
+ Jim_GetString(newargs[5], NULL),
+ Jim_GetString(newargs[6], NULL),
+ Jim_GetString(newargs[7], NULL),
+ Jim_GetString(newargs[8], NULL),
+ Jim_GetString(newargs[9], NULL));
+
+ e = jim_jtag_command(interp, 10, newargs);
+ if (e != JIM_OK){
+ command_print(cmd_ctx, "%s", Jim_GetString(Jim_GetResult(interp), NULL));
}
return e;
}
command_print(cmd_ctx, " TapName | Enabled | IdCode Expected IrLen IrCap IrMask Instr ");
command_print(cmd_ctx, "---|--------------------|---------|------------|------------|------|------|------|---------");
- while (tap ){
+ while (tap){
uint32_t expected, expected_mask, cur_instr, ii;
expected = buf_get_u32(tap->expected, 0, tap->ir_length);
expected_mask = buf_get_u32(tap->expected_mask, 0, tap->ir_length);
*/
endstate = TAP_IDLE;
- if (argc >= 4 ){
+ if (argc >= 4){
/* have at least one pair of numbers. */
/* is last pair the magic text? */
- if (0 == strcmp("-endstate", args[ argc - 2 ] ) ){
+ if (0 == strcmp("-endstate", args[ argc - 2 ])){
const char *cpA;
const char *cpS;
cpA = args[ argc-1 ];
- for (endstate = 0 ; endstate < TAP_NUM_STATES ; endstate++ ){
- cpS = tap_state_name(endstate );
- if (0 == strcmp(cpA, cpS ) ){
+ for (endstate = 0 ; endstate < TAP_NUM_STATES ; endstate++){
+ cpS = tap_state_name(endstate);
+ if (0 == strcmp(cpA, cpS)){
break;
}
}
- if (endstate >= TAP_NUM_STATES ){
+ if (endstate >= TAP_NUM_STATES){
return ERROR_COMMAND_SYNTAX_ERROR;
} else {
if (!scan_is_safe(endstate))
int retval;
for (i = 0; i < num_fields; i++)
{
- tap = jtag_tap_by_string(args[i*2] );
+ tap = jtag_tap_by_string(args[i*2]);
if (tap == NULL)
{
- command_print(cmd_ctx, "Tap: %s unknown", args[i*2] );
+ command_print(cmd_ctx, "Tap: %s unknown", args[i*2]);
return ERROR_FAIL;
}
int field_size = tap->ir_length;
e = Jim_GetLong(interp, args[i], &bits);
/* If valid - try next arg */
- if (e == JIM_OK ){
+ if (e == JIM_OK){
continue;
}
/* Not valid.. are we at the end? */
- if (((i + 2) != argc) ){
+ if (((i + 2) != argc)){
/* nope, then error */
return e;
}
*/
/* get arg as a string. */
- cp = Jim_GetString(args[i], NULL );
+ cp = Jim_GetString(args[i], NULL);
/* is it the magic? */
- if (0 == strcmp("-endstate", cp ) ){
+ if (0 == strcmp("-endstate", cp)){
/* is the statename valid? */
- cp = Jim_GetString(args[i + 1], NULL );
+ cp = Jim_GetString(args[i + 1], NULL);
/* see if it is a valid state name */
endstate = tap_state_by_name(cp);
- if (endstate < 0 ){
+ if (endstate < 0){
/* update the error message */
- Jim_SetResult_sprintf(interp,"endstate: %s invalid", cp );
+ Jim_SetResult_sprintf(interp,"endstate: %s invalid", cp);
} else {
if (!scan_is_safe(endstate))
LOG_WARNING("drscan with unsafe "
}
/* Still an error? */
- if (e != JIM_OK ){
+ if (e != JIM_OK){
return e; /* too bad */
}
} /* validate args */
- tap = jtag_tap_by_jim_obj(interp, args[1] );
- if (tap == NULL ){
+ tap = jtag_tap_by_jim_obj(interp, args[1]);
+ if (tap == NULL){
return JIM_ERR;
}
for (i = 0; i < argc-1; i++)
{
const char *cp;
- cp = Jim_GetString(args[i + 1], NULL );
+ cp = Jim_GetString(args[i + 1], NULL);
states[i] = tap_state_by_name(cp);
- if (states[i] < 0 )
+ if (states[i] < 0)
{
/* update the error message */
- Jim_SetResult_sprintf(interp,"endstate: %s invalid", cp );
+ Jim_SetResult_sprintf(interp,"endstate: %s invalid", cp);
return JIM_ERR;
}
}
break; /* above stable states are OK */
default:
LOG_ERROR("jtag_add_clocks() was called with TAP in non-stable state \"%s\"",
- tap_state_name(tap_get_state()) );
+ tap_state_name(tap_get_state()));
exit(-1);
}
vsllink_stableclocks(cmd->cmd.stableclocks->num_cycles, scan_size);
uint8_t bits_left, tms_tmp, tdi_len;
int i;
- if (0 == scan_size )
+ if (0 == scan_size)
{
return;
}
if (in_length > 0)
{
result = vsllink_usb_read(vsllink_jtag);
- if (result == in_length )
+ if (result == in_length)
{
return result;
}
#define TEST_MANUAL() 0
#if 0
-int diag_printf(const char *fmt, ... );
+int diag_printf(const char *fmt, ...);
#define ZY1000_POKE(a, b) HAL_WRITE_UINT32(a, b); diag_printf("poke 0x%08x,0x%08x\n", a, b)
#define ZY1000_PEEK(a, b) HAL_READ_UINT32(a, b); diag_printf("peek 0x%08x = 0x%08x\n", a, b)
#else
}
LOG_DEBUG("log init complete");
- LOG_OUTPUT(OPENOCD_VERSION "\n" );
+ LOG_OUTPUT(OPENOCD_VERSION "\n");
register_command(cmd_ctx, NULL, "init", handle_init_command,
COMMAND_ANY, "initializes target and servers - nop on subsequent invocations");
return EXIT_FAILURE;
ret = parse_config_file(cmd_ctx);
- if ((ret != ERROR_OK) && (ret != ERROR_COMMAND_CLOSE_CONNECTION) )
+ if ((ret != ERROR_OK) && (ret != ERROR_COMMAND_CLOSE_CONNECTION))
return EXIT_FAILURE;
#if BUILD_HTTPD
tap = jtag_tap_by_string(args[1]);
if (tap == NULL) {
- command_print(cmd_ctx, "Tap: %s does not exist", args[1] );
+ command_print(cmd_ctx, "Tap: %s does not exist", args[1]);
return ERROR_OK;
}
break;
if ((retval = gdb_get_char(connection, &reply)) != ERROR_OK)
return retval;
- if (reply == '$' ){
+ if (reply == '$'){
/* fix a problem with some IAR tools */
- gdb_putback_char(connection, reply );
+ gdb_putback_char(connection, reply);
LOG_DEBUG("Unexpected start of new packet");
break;
}
log_remove_callback(gdb_log_callback, connection);
LOG_WARNING("negative reply, retrying");
}
- else if (reply == '$' ){
+ else if (reply == '$'){
LOG_ERROR("GDB missing ack(1) - assumed good");
- gdb_putback_char(connection, reply );
+ gdb_putback_char(connection, reply);
return ERROR_OK;
} else {
return ERROR_SERVER_REMOTE_CLOSED;
}
}
- else if (reply == '$' ){
+ else if (reply == '$'){
LOG_ERROR("GDB missing ack(2) - assumed good");
- gdb_putback_char(connection, reply );
+ gdb_putback_char(connection, reply);
return ERROR_OK;
}
else
int retval;
connection_t *connection = priv;
- target_handle_event(target, event );
+ target_handle_event(target, event);
switch (event)
{
case TARGET_EVENT_EARLY_HALTED:
target_call_event_callbacks(target, TARGET_EVENT_GDB_END);
break;
case TARGET_EVENT_GDB_FLASH_ERASE_START:
- target_handle_event(target, TARGET_EVENT_OLD_gdb_program_config );
+ target_handle_event(target, TARGET_EVENT_OLD_gdb_program_config);
if ((retval = jtag_execute_queue()) != ERROR_OK)
{
return retval;
*/
if (initial_ack != '+')
gdb_putback_char(connection, initial_ack);
- target_call_event_callbacks(gdb_service->target, TARGET_EVENT_GDB_ATTACH );
+ target_call_event_callbacks(gdb_service->target, TARGET_EVENT_GDB_ATTACH);
gdb_actual_connections++;
target_call_event_callbacks(gdb_service->target, TARGET_EVENT_GDB_END);
log_remove_callback(gdb_log_callback, connection);
- target_call_event_callbacks(gdb_service->target, TARGET_EVENT_GDB_DETACH );
+ target_call_event_callbacks(gdb_service->target, TARGET_EVENT_GDB_DETACH);
return ERROR_OK;
}
void gdb_send_error(connection_t *connection, uint8_t the_error)
{
char err[4];
- snprintf(err, 4, "E%2.2X", the_error );
+ snprintf(err, 4, "E%2.2X", the_error);
gdb_put_packet(connection, err, 3);
}
if (packet[0] == 'c')
{
LOG_DEBUG("continue");
- target_handle_event(target, TARGET_EVENT_OLD_pre_resume );
+ target_handle_event(target, TARGET_EVENT_OLD_pre_resume);
retval = target_resume(target, current, address, 0, 0); /* resume at current address, don't handle breakpoints, not debugging */
}
else if (packet[0] == 's')
/* perform any target specific operations before the erase */
target_call_event_callbacks(gdb_service->target, TARGET_EVENT_GDB_FLASH_ERASE_START);
- result = flash_erase_address_range(gdb_service->target, addr, length );
+ result = flash_erase_address_range(gdb_service->target, addr, length);
target_call_event_callbacks(gdb_service->target, TARGET_EVENT_GDB_FLASH_ERASE_END);
/* perform erase */
int gdb_detach(connection_t *connection, target_t *target)
{
- switch (detach_mode )
+ switch (detach_mode)
{
case GDB_DETACH_RESUME:
- target_handle_event(target, TARGET_EVENT_OLD_pre_resume );
+ target_handle_event(target, TARGET_EVENT_OLD_pre_resume);
target_resume(target, 1, 0, 1, 0);
break;
/* terminate with zero */
packet[packet_size] = 0;
- if (LOG_LEVEL_IS(LOG_LVL_DEBUG ) ){
- if (packet[0] == 'X' ){
+ if (LOG_LEVEL_IS(LOG_LVL_DEBUG)){
+ if (packet[0] == 'X'){
// binary packets spew junk into the debug log stream
char buf[ 50 ];
int x;
- for (x = 0 ; (x < 49) && (packet[x] != ':') ; x++ ){
+ for (x = 0 ; (x < 49) && (packet[x] != ':') ; x++){
buf[x] = packet[x];
}
buf[x] = 0;
- LOG_DEBUG("received packet: '%s:<binary-data>'", buf );
+ LOG_DEBUG("received packet: '%s:<binary-data>'", buf);
} else {
- LOG_DEBUG("received packet: '%s'", packet );
+ LOG_DEBUG("received packet: '%s'", packet);
}
}
const char *script = alloc_printf("set dummy_val $httppostdata(%s); set dummy_val",
name);
- retcode = Jim_Eval_Named(interp, script, "httpd.c", __LINE__ );
+ retcode = Jim_Eval_Named(interp, script, "httpd.c", __LINE__);
free((void *) script);
if (retcode != JIM_OK)
return retcode;
const char *script = alloc_printf("set dummy_val $httppostdata(%s); set dummy_val",
name);
- int retcode = Jim_Eval_Named(interp, script, "httpd.c", __LINE__ );
+ int retcode = Jim_Eval_Named(interp, script, "httpd.c", __LINE__);
free((void *) script);
if (retcode != JIM_OK)
{
const char *script = alloc_printf(
"global httpdata; source {%s}; set httpdata", url);
- retcode = Jim_Eval_Named(interp, script, "httpd.c", __LINE__ );
+ retcode = Jim_Eval_Named(interp, script, "httpd.c", __LINE__);
free((void *) script);
if (retcode == JIM_ERR)
int httpd_start(void)
{
pthread_mutexattr_t attr;
- pthread_mutexattr_init(&attr );
- pthread_mutex_init(&mutex, &attr );
+ pthread_mutexattr_init(&attr);
+ pthread_mutex_init(&mutex, &attr);
int port = 8888;
LOG_USER("Launching httpd server on port %d", port);
void httpd_stop(void)
{
MHD_stop_daemon(d);
- pthread_mutex_destroy(&mutex );
+ pthread_mutex_destroy(&mutex);
}
void openocd_sleep_prelude(void)
{
- pthread_mutex_unlock(&mutex );
+ pthread_mutex_unlock(&mutex);
}
void openocd_sleep_postlude(void)
{
- pthread_mutex_lock(&mutex );
+ pthread_mutex_lock(&mutex);
}
#ifdef _WIN32
WSACleanup();
- SetConsoleCtrlHandler(ControlHandler, FALSE );
+ SetConsoleCtrlHandler(ControlHandler, FALSE);
#endif
return ERROR_OK;
{
const char* ret;
- switch (state )
+ switch (state)
{
case TAP_RESET: ret = "RESET"; break;
case TAP_IDLE: ret = "IDLE"; break;
// TAP_RESET
jtag_add_tlr();
- while (ERROR_OK == svf_read_command_from_file(svf_fd) )
+ while (ERROR_OK == svf_read_command_from_file(svf_fd))
{
if (ERROR_OK != svf_run_command(cmd_ctx, svf_command_buffer))
{
char ch, *tmp_buffer = NULL;
int cmd_pos = 0, cmd_ok = 0, slash = 0, comment = 0;
- while (!cmd_ok && (read(fd, &ch, 1) > 0) )
+ while (!cmd_ok && (read(fd, &ch, 1) > 0))
{
switch (ch)
{
arm11_common_t * arm11 = target->arch_info;
LOG_USER("target halted due to %s\ncpsr: 0x%8.8" PRIx32 " pc: 0x%8.8" PRIx32 "",
- Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason )->name,
+ Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason)->name,
R(CPSR),
R(PC));
arm11_common_t * arm11 = target->arch_info;
LOG_DEBUG("target->state: %s",
- Jim_Nvp_value2name_simple(nvp_target_state, target->state )->name );
+ Jim_Nvp_value2name_simple(nvp_target_state, target->state)->name);
if (target->state == TARGET_UNKNOWN)
{
arm11_common_t * arm11 = target->arch_info;
LOG_DEBUG("target->state: %s",
- Jim_Nvp_value2name_simple(nvp_target_state, target->state )->name );
+ Jim_Nvp_value2name_simple(nvp_target_state, target->state)->name);
if (target->state != TARGET_HALTED)
FNC_INFO;
LOG_DEBUG("target->state: %s",
- Jim_Nvp_value2name_simple(nvp_target_state, target->state )->name );
+ Jim_Nvp_value2name_simple(nvp_target_state, target->state)->name);
if (target->state != TARGET_HALTED)
{
#if 0
LOG_DEBUG("target->state: %s",
- Jim_Nvp_value2name_simple(nvp_target_state, target->state )->name );
+ Jim_Nvp_value2name_simple(nvp_target_state, target->state)->name);
/* deassert reset lines */
RC_FINAL_BOOL("error_fatal", "Terminate program if transfer error was found (default: enabled)",
memwrite_error_fatal)
- ) /* memwrite */
+) /* memwrite */
RC_FINAL_BOOL("no_increment", "Don't increment address on multi-read/-write (default: disabled)",
memrw_no_increment)
RC_FINAL("mcr", "Write Coprocessor register",
arm11_handle_mcr)
- ) /* arm11 */
+) /* arm11 */
return ERROR_OK;
}
"cpsr: 0x%8.8" PRIx32 " pc: 0x%8.8" PRIx32 "\n"
"MMU: %s, Cache: %s",
armv4_5_state_strings[armv4_5->core_state],
- Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason )->name ,
+ Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason)->name ,
armv4_5_mode_strings[armv4_5_mode_to_number(armv4_5->core_mode)],
buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32),
buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32),
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W0_ADDR_VALUE], watchpoint->address);
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W0_ADDR_MASK], mask);
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W0_DATA_MASK], watchpoint->mask);
- if (watchpoint->mask != 0xffffffffu )
+ if (watchpoint->mask != 0xffffffffu)
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W0_DATA_VALUE], watchpoint->value);
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W0_CONTROL_MASK], 0xff & ~EICE_W_CTRL_nOPC & ~rw_mask);
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W0_CONTROL_VALUE], EICE_W_CTRL_ENABLE | EICE_W_CTRL_nOPC | (watchpoint->rw & 1));
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W1_ADDR_VALUE], watchpoint->address);
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W1_ADDR_MASK], mask);
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W1_DATA_MASK], watchpoint->mask);
- if (watchpoint->mask != 0xffffffffu )
+ if (watchpoint->mask != 0xffffffffu)
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W1_DATA_VALUE], watchpoint->value);
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W1_CONTROL_MASK], 0xff & ~EICE_W_CTRL_nOPC & ~rw_mask);
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W1_CONTROL_VALUE], EICE_W_CTRL_ENABLE | EICE_W_CTRL_nOPC | (watchpoint->rw & 1));
return ERROR_OK;
}
-int arm7tdmi_target_create(struct target_s *target, Jim_Interp *interp )
+int arm7tdmi_target_create(struct target_s *target, Jim_Interp *interp)
{
arm7tdmi_common_t *arm7tdmi;
return ERROR_OK;
}
-int arm966e_target_create(struct target_s *target, Jim_Interp *interp )
+int arm966e_target_create(struct target_s *target, Jim_Interp *interp)
{
arm966e_common_t *arm966e = calloc(1,sizeof(arm966e_common_t));
int handle_arm9tdmi_catch_vectors_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
/* forward declarations */
-int arm9tdmi_target_create(struct target_s *target, Jim_Interp *interp );
+int arm9tdmi_target_create(struct target_s *target, Jim_Interp *interp);
int arm9tdmi_quit(void);
arm_jtag_set_instr(jtag_info, instr, NULL);
/* Add specified number of tck clocks before accessing memory bus */
- if ((instr == DAP_IR_APACC) && ((reg_addr == AP_REG_DRW)||((reg_addr&0xF0) == AP_REG_BD0) )&& (swjdp->memaccess_tck != 0))
+ if ((instr == DAP_IR_APACC) && ((reg_addr == AP_REG_DRW)||((reg_addr&0xF0) == AP_REG_BD0))&& (swjdp->memaccess_tck != 0))
jtag_add_runtest(swjdp->memaccess_tck, jtag_set_end_state(TAP_IDLE));
fields[0].tap = jtag_info->tap;
arm_jtag_set_instr(jtag_info, instr, NULL);
/* Add specified number of tck clocks before accessing memory bus */
- if ((instr == DAP_IR_APACC) && ((reg_addr == AP_REG_DRW)||((reg_addr&0xF0) == AP_REG_BD0) )&& (swjdp->memaccess_tck != 0))
+ if ((instr == DAP_IR_APACC) && ((reg_addr == AP_REG_DRW)||((reg_addr&0xF0) == AP_REG_BD0))&& (swjdp->memaccess_tck != 0))
jtag_add_runtest(swjdp->memaccess_tck, jtag_set_end_state(TAP_IDLE));
fields[0].tap = jtag_info->tap;
if (csw != swjdp->ap_csw_value)
{
/* LOG_DEBUG("swjdp : Set CSW %x",csw); */
- dap_ap_write_reg_u32(swjdp, AP_REG_CSW, csw );
+ dap_ap_write_reg_u32(swjdp, AP_REG_CSW, csw);
swjdp->ap_csw_value = csw;
}
if (tar != swjdp->ap_tar_value)
{
/* LOG_DEBUG("swjdp : Set TAR %x",tar); */
- dap_ap_write_reg_u32(swjdp, AP_REG_TAR, tar );
+ dap_ap_write_reg_u32(swjdp, AP_REG_TAR, tar);
swjdp->ap_tar_value = tar;
}
if (csw & CSW_ADDRINC_MASK)
swjdp->trans_mode = TRANS_MODE_COMPOSITE;
dap_setup_accessport(swjdp, CSW_32BIT | CSW_ADDRINC_OFF, address & 0xFFFFFFF0);
- dap_ap_read_reg_u32(swjdp, AP_REG_BD0 | (address & 0xC), value );
+ dap_ap_read_reg_u32(swjdp, AP_REG_BD0 | (address & 0xC), value);
return ERROR_OK;
}
swjdp->trans_mode = TRANS_MODE_COMPOSITE;
dap_setup_accessport(swjdp, CSW_32BIT | CSW_ADDRINC_OFF, address & 0xFFFFFFF0);
- dap_ap_write_reg_u32(swjdp, AP_REG_BD0 | (address & 0xC), value );
+ dap_ap_write_reg_u32(swjdp, AP_REG_BD0 | (address & 0xC), value);
return ERROR_OK;
}
uint32_t outvalue;
memcpy(&outvalue, pBuffer, sizeof(uint32_t));
- for (i = 0; i < 4; i++ )
+ for (i = 0; i < 4; i++)
{
*((uint8_t*)pBuffer + (adr & 0x3)) = outvalue;
outvalue >>= 8;
for (writecount = 0; writecount < blocksize; writecount++)
{
- dap_ap_write_reg(swjdp, AP_REG_DRW, buffer + 4 * writecount );
+ dap_ap_write_reg(swjdp, AP_REG_DRW, buffer + 4 * writecount);
}
if (swjdp_transaction_endcheck(swjdp) == ERROR_OK)
{
nbytes = MIN((writecount << 1), 4);
- if (nbytes < 4 )
+ if (nbytes < 4)
{
if (mem_ap_write_buf_u16(swjdp, buffer, nbytes, address) != ERROR_OK)
{
uint32_t outvalue;
memcpy(&outvalue, buffer, sizeof(uint32_t));
- for (i = 0; i < nbytes; i++ )
+ for (i = 0; i < nbytes; i++)
{
*((uint8_t*)buffer + (address & 0x3)) = outvalue;
outvalue >>= 8;
uint16_t svalue;
memcpy(&svalue, buffer, sizeof(uint16_t));
uint32_t outvalue = (uint32_t)svalue << 8 * (address & 0x3);
- dap_ap_write_reg_u32(swjdp, AP_REG_DRW, outvalue );
+ dap_ap_write_reg_u32(swjdp, AP_REG_DRW, outvalue);
retval = swjdp_transaction_endcheck(swjdp);
count -= 2;
address += 2;
{
nbytes = MIN(writecount, 4);
- if (nbytes < 4 )
+ if (nbytes < 4)
{
if (mem_ap_write_buf_u8(swjdp, buffer, nbytes, address) != ERROR_OK)
{
uint32_t outvalue;
memcpy(&outvalue, buffer, sizeof(uint32_t));
- for (i = 0; i < nbytes; i++ )
+ for (i = 0; i < nbytes; i++)
{
*((uint8_t*)buffer + (address & 0x3)) = outvalue;
outvalue >>= 8;
{
dap_setup_accessport(swjdp, CSW_8BIT | CSW_ADDRINC_SINGLE, address);
uint32_t outvalue = (uint32_t)*buffer << 8 * (address & 0x3);
- dap_ap_write_reg_u32(swjdp, AP_REG_DRW, outvalue );
+ dap_ap_write_reg_u32(swjdp, AP_REG_DRW, outvalue);
retval = swjdp_transaction_endcheck(swjdp);
count--;
address++;
uint32_t data;
memcpy(&data, pBuffer, sizeof(uint32_t));
- for (i = 0; i < 4; i++ )
+ for (i = 0; i < 4; i++)
{
*((uint8_t*)pBuffer) = (data >> 8 * (adr & 0x3));
pBuffer++;
do
{
- dap_ap_read_reg_u32(swjdp, AP_REG_DRW, &invalue );
+ dap_ap_read_reg_u32(swjdp, AP_REG_DRW, &invalue);
if (swjdp_transaction_endcheck(swjdp) != ERROR_OK)
{
LOG_WARNING("Block read error address 0x%" PRIx32 ", count 0x%x", address, count);
nbytes = MIN((readcount << 1), 4);
- for (i = 0; i < nbytes; i++ )
+ for (i = 0; i < nbytes; i++)
{
*((uint8_t*)buffer) = (invalue >> 8 * (address & 0x3));
buffer++;
while (count > 0)
{
dap_setup_accessport(swjdp, CSW_16BIT | CSW_ADDRINC_SINGLE, address);
- dap_ap_read_reg_u32(swjdp, AP_REG_DRW, &invalue );
+ dap_ap_read_reg_u32(swjdp, AP_REG_DRW, &invalue);
retval = swjdp_transaction_endcheck(swjdp);
if (address & 0x1)
{
- for (i = 0; i < 2; i++ )
+ for (i = 0; i < 2; i++)
{
*((uint8_t*)buffer) = (invalue >> 8 * (address & 0x3));
buffer++;
do
{
- dap_ap_read_reg_u32(swjdp, AP_REG_DRW, &invalue );
+ dap_ap_read_reg_u32(swjdp, AP_REG_DRW, &invalue);
if (swjdp_transaction_endcheck(swjdp) != ERROR_OK)
{
LOG_WARNING("Block read error address 0x%" PRIx32 ", count 0x%x", address, count);
nbytes = MIN(readcount, 4);
- for (i = 0; i < nbytes; i++ )
+ for (i = 0; i < nbytes; i++)
{
*((uint8_t*)buffer) = (invalue >> 8 * (address & 0x3));
buffer++;
while (count > 0)
{
dap_setup_accessport(swjdp, CSW_8BIT | CSW_ADDRINC_SINGLE, address);
- dap_ap_read_reg_u32(swjdp, AP_REG_DRW, &invalue );
+ dap_ap_read_reg_u32(swjdp, AP_REG_DRW, &invalue);
retval = swjdp_transaction_endcheck(swjdp);
*((uint8_t*)buffer) = (invalue >> 8 * (address & 0x3));
count--;
}
else
{
- command_print(cmd_ctx, "\tROM table in legacy format" );
+ command_print(cmd_ctx, "\tROM table in legacy format");
}
/* Now we read ROM table ID registers, ref. ARM IHI 0029B sec */
mem_ap_read_u32(swjdp, (dbgbase&0xFFFFF000) | 0xFF0, &cid0);
}
else
{
- command_print(cmd_ctx, "\tMEMTYPE system memory not present. Dedicated debug bus" );
+ command_print(cmd_ctx, "\tMEMTYPE system memory not present. Dedicated debug bus");
}
/* Now we read ROM table entries from dbgbase&0xFFFFF000) | 0x000 until we get 0x00000000 */
(opcode & 0x40000) ? "s" : "",
(opcode & 0x80000) ? "f" : "",
ror(immediate, (rotate * 2))
- );
+);
}
else /* register variant */
{
(opcode & 0x40000) ? "s" : "",
(opcode & 0x80000) ? "f" : "",
Rm
- );
+);
}
}
if ((opcode & 0x0e000000) == 0x0a000000)
return evaluate_blx_imm(opcode, address, instruction);
- /* Extended coprocessor opcode space (ARMv5 and higher )*/
+ /* Extended coprocessor opcode space (ARMv5 and higher)*/
/* Coprocessor load/store and double register transfers */
if ((opcode & 0x0e000000) == 0x0c000000)
return evaluate_ldc_stc_mcrr_mrrc(opcode, address, instruction);
LOG_USER("target halted in %s state due to %s, current mode: %s\ncpsr: 0x%8.8" PRIx32 " pc: 0x%8.8" PRIx32 "",
armv4_5_state_strings[armv4_5->core_state],
- Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason )->name,
+ Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason)->name,
armv4_5_mode_strings[armv4_5_mode_to_number(armv4_5->core_mode)],
buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32),
buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32));
* Rd: source register
* SYSm: destination special register
*/
-#define ARMV7M_T_MSR(SYSm, Rn) ((0xF380 | (Rn << 8 )) | ((0x8800 | SYSm) << 16))
+#define ARMV7M_T_MSR(SYSm, Rn) ((0xF380 | (Rn << 8)) | ((0x8800 | SYSm) << 16))
/* Change Processor State. The instruction modifies the PRIMASK and FAULTMASK
* special-purpose register values (Thumb mode) 16 bit Thumb2 instruction
/* Breakpoint (Thumb mode) v5 onwards
* Im: immediate value used by debugger
*/
-#define ARMV7M_T_BKPT(Im) ((0xBE00 | Im ) | ((0xBE00 | Im ) << 16))
+#define ARMV7M_T_BKPT(Im) ((0xBE00 | Im) | ((0xBE00 | Im) << 16))
/* Store register (Thumb mode)
* Rd: source register
/* mem_ap_write_u32(swjdp, DCB_DCRSR, regnum); */
dap_setup_accessport(swjdp, CSW_32BIT | CSW_ADDRINC_OFF, DCB_DCRSR & 0xFFFFFFF0);
- dap_ap_write_reg_u32(swjdp, AP_REG_BD0 | (DCB_DCRSR & 0xC), regnum );
+ dap_ap_write_reg_u32(swjdp, AP_REG_BD0 | (DCB_DCRSR & 0xC), regnum);
/* mem_ap_read_u32(swjdp, DCB_DCRDR, value); */
dap_setup_accessport(swjdp, CSW_32BIT | CSW_ADDRINC_OFF, DCB_DCRDR & 0xFFFFFFF0);
- dap_ap_read_reg_u32(swjdp, AP_REG_BD0 | (DCB_DCRDR & 0xC), value );
+ dap_ap_read_reg_u32(swjdp, AP_REG_BD0 | (DCB_DCRDR & 0xC), value);
mem_ap_write_u32(swjdp, DCB_DCRDR, dcrdr);
retval = swjdp_transaction_endcheck(swjdp);
/* mem_ap_write_u32(swjdp, DCB_DCRDR, core_regs[i]); */
dap_setup_accessport(swjdp, CSW_32BIT | CSW_ADDRINC_OFF, DCB_DCRDR & 0xFFFFFFF0);
- dap_ap_write_reg_u32(swjdp, AP_REG_BD0 | (DCB_DCRDR & 0xC), value );
+ dap_ap_write_reg_u32(swjdp, AP_REG_BD0 | (DCB_DCRDR & 0xC), value);
- /* mem_ap_write_u32(swjdp, DCB_DCRSR, i | DCRSR_WnR ); */
+ /* mem_ap_write_u32(swjdp, DCB_DCRSR, i | DCRSR_WnR); */
dap_setup_accessport(swjdp, CSW_32BIT | CSW_ADDRINC_OFF, DCB_DCRSR & 0xFFFFFFF0);
- dap_ap_write_reg_u32(swjdp, AP_REG_BD0 | (DCB_DCRSR & 0xC), regnum | DCRSR_WnR );
+ dap_ap_write_reg_u32(swjdp, AP_REG_BD0 | (DCB_DCRSR & 0xC), regnum | DCRSR_WnR);
mem_ap_write_u32(swjdp, DCB_DCRDR, dcrdr);
retval = swjdp_transaction_endcheck(swjdp);
return ERROR_OK;
}
-int cortex_m3_exec_opcode(target_t *target,uint32_t opcode, int len /* MODE, r0_invalue, &r0_outvalue */ )
+int cortex_m3_exec_opcode(target_t *target,uint32_t opcode, int len /* MODE, r0_invalue, &r0_outvalue */)
{
/* get pointers to arch-specific information */
armv7m_common_t *armv7m = target->arch_info;
LOG_DEBUG("entered debug state in core mode: %s at PC 0x%" PRIx32 ", target->state: %s",
armv7m_mode_strings[armv7m->core_mode],
*(uint32_t*)(armv7m->core_cache->reg_list[15].value),
- Jim_Nvp_value2name_simple(nvp_target_state, target->state )->name);
+ Jim_Nvp_value2name_simple(nvp_target_state, target->state)->name);
if (armv7m->post_debug_entry)
armv7m->post_debug_entry(target);
#if 0
/* Read Debug Fault Status Register, added to figure out the lockup when running flashtest.script */
mem_ap_read_atomic_u32(swjdp, NVIC_DFSR, &cortex_m3->nvic_dfsr);
- LOG_DEBUG("dcb_dhcsr 0x%x, nvic_dfsr 0x%x, target->state: %s", cortex_m3->dcb_dhcsr, cortex_m3->nvic_dfsr, Jim_Nvp_value2name_simple(nvp_target_state, target->state )->name );
+ LOG_DEBUG("dcb_dhcsr 0x%x, nvic_dfsr 0x%x, target->state: %s", cortex_m3->dcb_dhcsr, cortex_m3->nvic_dfsr, Jim_Nvp_value2name_simple(nvp_target_state, target->state)->name);
#endif
return ERROR_OK;
int cortex_m3_halt(target_t *target)
{
LOG_DEBUG("target->state: %s",
- Jim_Nvp_value2name_simple(nvp_target_state, target->state )->name);
+ Jim_Nvp_value2name_simple(nvp_target_state, target->state)->name);
if (target->state == TARGET_HALTED)
{
int assert_srst = 1;
LOG_DEBUG("target->state: %s",
- Jim_Nvp_value2name_simple(nvp_target_state, target->state )->name );
+ Jim_Nvp_value2name_simple(nvp_target_state, target->state)->name);
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (!(jtag_reset_config & RESET_HAS_SRST))
if (!(cortex_m3->dcb_dhcsr & C_DEBUGEN))
mem_ap_write_u32(swjdp, DCB_DHCSR, DBGKEY | C_DEBUGEN);
- mem_ap_write_u32(swjdp, DCB_DCRDR, 0 );
+ mem_ap_write_u32(swjdp, DCB_DCRDR, 0);
if (!target->reset_halt)
{
int cortex_m3_deassert_reset(target_t *target)
{
LOG_DEBUG("target->state: %s",
- Jim_Nvp_value2name_simple(nvp_target_state, target->state )->name);
+ Jim_Nvp_value2name_simple(nvp_target_state, target->state)->name);
/* deassert reset lines */
jtag_add_reset(0, 0);
return ERROR_FAIL;
}
- tap = jtag_tap_by_string(args[1] );
+ tap = jtag_tap_by_string(args[1]);
if (tap == NULL)
{
- command_print(cmd_ctx, "Tap: %s does not exist", args[1] );
+ command_print(cmd_ctx, "Tap: %s does not exist", args[1]);
return ERROR_FAIL;
}
}
else if (record_type >= 1 && record_type <= 3)
{
- switch (record_type )
+ switch (record_type)
{
case 1:
/* S1 - 16 bit address data record */
cal_checksum += (uint8_t)checksum;
bytes_read += 2;
- if (cal_checksum != 0xFF )
+ if (cal_checksum != 0xFF)
{
/* checksum failed */
LOG_ERROR("incorrect record checksum found in S19 file");
memcpy(buffer + *size_read,
image_memory->cache + (address - image_memory->cache_address),
(size_in_cache > size) ? size : size_in_cache
- );
+);
*size_read += (size_in_cache > size) ? size : size_in_cache;
address += (size_in_cache > size) ? size : size_in_cache;
}
LOG_USER("target halted due to %s, pc: 0x%8.8" PRIx32 "",
- Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason )->name ,
+ Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason)->name ,
buf_get_u32(mips32->core_cache->reg_list[MIPS32_PC].value, 0, 32));
return ERROR_OK;
offset = (address - MIPS32_PRACC_PARAM_IN) / 4;
ctx->local_iparam[offset] = data;
}
- else if ((address >= MIPS32_PRACC_PARAM_OUT )
+ else if ((address >= MIPS32_PRACC_PARAM_OUT)
&& (address <= MIPS32_PRACC_PARAM_OUT + ctx->num_oparam * 4))
{
offset = (address - MIPS32_PRACC_PARAM_OUT) / 4;
#define UPPER16(uint32_t) (uint32_t >> 16)
#define LOWER16(uint32_t) (uint32_t & 0xFFFF)
#define NEG16(v) (((~(v)) + 1) & 0xFFFF)
-/*#define NEG18(v) (((~(v)) + 1) & 0x3FFFF )*/
+/*#define NEG18(v) (((~(v)) + 1) & 0x3FFFF)*/
extern int mips32_pracc_read_mem(mips_ejtag_t *ejtag_info, uint32_t addr, int size, int count, void *buf);
extern int mips32_pracc_write_mem(mips_ejtag_t *ejtag_info, uint32_t addr, int size, int count, void *buf);
ejtag_info->impcode & (1 << 16) ? " MIPS16": "",
ejtag_info->impcode & (1 << 14) ? " noDMA": " DMA",
ejtag_info->impcode & (1 << 0) ? " MIPS64": " MIPS32"
- );
+);
if ((ejtag_info->impcode & (1 << 14)) == 0)
LOG_DEBUG("EJTAG: DMA Access Mode Support Enabled");
LOG_DEBUG("entered debug state at PC 0x%" PRIx32 ", target->state: %s",
*(uint32_t*)(mips32->core_cache->reg_list[MIPS32_PC].value),
- Jim_Nvp_value2name_simple(nvp_target_state, target->state )->name);
+ Jim_Nvp_value2name_simple(nvp_target_state, target->state)->name);
return ERROR_OK;
}
mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
LOG_DEBUG("target->state: %s",
- Jim_Nvp_value2name_simple(nvp_target_state, target->state )->name);
+ Jim_Nvp_value2name_simple(nvp_target_state, target->state)->name);
if (target->state == TARGET_HALTED)
{
mips_ejtag_t *ejtag_info = &mips32->ejtag_info;
LOG_DEBUG("target->state: %s",
- Jim_Nvp_value2name_simple(nvp_target_state, target->state )->name);
+ Jim_Nvp_value2name_simple(nvp_target_state, target->state)->name);
enum reset_types jtag_reset_config = jtag_get_reset_config();
if (!(jtag_reset_config & RESET_HAS_SRST))
int mips_m4k_deassert_reset(target_t *target)
{
LOG_DEBUG("target->state: %s",
- Jim_Nvp_value2name_simple(nvp_target_state, target->state )->name);
+ Jim_Nvp_value2name_simple(nvp_target_state, target->state)->name);
/* deassert reset lines */
jtag_add_reset(0, 0);
void register_init_dummy(reg_t *reg)
{
static int dummy_arch_type = -1;
- if (dummy_arch_type == -1 )
+ if (dummy_arch_type == -1)
dummy_arch_type = register_reg_arch_type(register_get_dummy_core_reg, register_set_dummy_core_reg);
reg->arch_type = dummy_arch_type;
{ .value = -1, .name = NULL }
};
-const char *target_strerror_safe(int err )
+const char *target_strerror_safe(int err)
{
const Jim_Nvp *n;
- n = Jim_Nvp_value2name_simple(nvp_error_target, err );
- if (n->name == NULL ){
+ n = Jim_Nvp_value2name_simple(nvp_error_target, err);
+ if (n->name == NULL){
return "unknown";
} else {
return n->name;
x = -1;
t = all_targets;
- while (t ){
- if (x < t->target_number ){
+ while (t){
+ if (x < t->target_number){
x = (t->target_number) + 1;
}
t = t->next;
x = -1;
t = all_targets;
while (t){
- if (x < t->target_number ){
+ if (x < t->target_number){
x = t->target_number;
}
t = t->next;
target_t *target = all_targets;
while (target){
- if (target->target_number == num ){
+ if (target->target_number == num){
return target;
}
target = target->next;
char buf[100];
int retval;
Jim_Nvp *n;
- n = Jim_Nvp_value2name_simple(nvp_reset_modes, reset_mode );
- if (n->name == NULL ){
+ n = Jim_Nvp_value2name_simple(nvp_reset_modes, reset_mode);
+ if (n->name == NULL){
LOG_ERROR("invalid reset mode");
return ERROR_FAIL;
}
int save_poll = target_continuous_poll;
target_continuous_poll = 0;
- sprintf(buf, "ocd_process_reset %s", n->name );
- retval = Jim_Eval(interp, buf );
+ sprintf(buf, "ocd_process_reset %s", n->name);
+ retval = Jim_Eval(interp, buf);
target_continuous_poll = save_poll;
LOG_DEBUG("target event %i (%s)",
event,
- Jim_Nvp_value2name_simple(nvp_target_event, event )->name );
+ Jim_Nvp_value2name_simple(nvp_target_event, event)->name);
- target_handle_event(target, event );
+ target_handle_event(target, event);
while (callback)
{
- register_jim(cmd_ctx, "target", jim_target, "configure target" );
+ register_jim(cmd_ctx, "target", jim_target, "configure target");
return ERROR_OK;
}
target_buffer_set_u32(target, &buffer[i*sizeof(uint32_t)], target_data);
}
- retval = image_calculate_checksum(buffer, size, &checksum );
+ retval = image_calculate_checksum(buffer, size, &checksum);
free(buffer);
}
{
target = get_target(args[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", args[0]);
goto DumpTargets;
}
if (!target->tap->enabled) {
if (argc == 1)
{
const Jim_Nvp *n;
- n = Jim_Nvp_name2value_simple(nvp_reset_modes, args[0] );
- if ((n->name == NULL) || (n->value == RESET_UNKNOWN) ){
+ n = Jim_Nvp_name2value_simple(nvp_reset_modes, args[0]);
+ if ((n->name == NULL) || (n->value == RESET_UNKNOWN)){
return ERROR_COMMAND_SYNTAX_ERROR;
}
reset_mode = n->value;
if (verify)
{
/* calculate checksum of image */
- image_calculate_checksum(buffer, buf_cnt, &checksum );
+ image_calculate_checksum(buffer, buf_cnt, &checksum);
retval = target_checksum_memory(target, image.sections[i].base_address, buf_cnt, &mem_checksum);
- if (retval != ERROR_OK )
+ if (retval != ERROR_OK)
{
free(buffer);
break;
}
- if (checksum != mem_checksum )
+ if (checksum != mem_checksum)
{
/* failed crc checksum, fall back to a binary compare */
uint8_t *data;
break;
default:
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
- Jim_AppendStrings(interp, Jim_GetResult(interp), "Invalid width param, must be 8/16/32", NULL );
+ Jim_AppendStrings(interp, Jim_GetResult(interp), "Invalid width param, must be 8/16/32", NULL);
return JIM_ERR;
}
if (len == 0) {
count = (sizeof(buffer)/width);
}
- retval = target_read_memory(target, addr, width, count, buffer );
+ retval = target_read_memory(target, addr, width, count, buffer);
if (retval != ERROR_OK) {
/* BOO !*/
LOG_ERROR("mem2array: Read @ 0x%08x, w=%d, cnt=%d, failed",
return JIM_ERR;
}
- return target_array2mem(interp,target, argc-1, argv + 1 );
+ return target_array2mem(interp,target, argc-1, argv + 1);
}
static int target_array2mem(Jim_Interp *interp, target_t *target, int argc, Jim_Obj *const *argv)
break;
default:
Jim_SetResult(interp, Jim_NewEmptyStringObj(interp));
- Jim_AppendStrings(interp, Jim_GetResult(interp), "Invalid width param, must be 8/16/32", NULL );
+ Jim_AppendStrings(interp, Jim_GetResult(interp), "Invalid width param, must be 8/16/32", NULL);
return JIM_ERR;
}
if (len == 0) {
return JIM_OK;
}
-void target_all_handle_event(enum target_event e )
+void target_all_handle_event(enum target_event e)
{
target_t *target;
LOG_DEBUG("**all*targets: event: %d, %s",
(int)e,
- Jim_Nvp_value2name_simple(nvp_target_event, e )->name );
+ Jim_Nvp_value2name_simple(nvp_target_event, e)->name);
target = all_targets;
while (target){
- target_handle_event(target, e );
+ target_handle_event(target, e);
target = target->next;
}
}
-void target_handle_event(target_t *target, enum target_event e )
+void target_handle_event(target_t *target, enum target_event e)
{
target_event_action_t *teap;
int done;
teap = target->event_action;
done = 0;
- while (teap ){
- if (teap->event == e ){
+ while (teap){
+ if (teap->event == e){
done = 1;
LOG_DEBUG("target: (%d) %s (%s) event: %d (%s) action: %s\n",
target->target_number,
target->cmd_name,
target_get_name(target),
e,
- Jim_Nvp_value2name_simple(nvp_target_event, e )->name,
- Jim_GetString(teap->body, NULL ) );
- if (Jim_EvalObj(interp, teap->body ) != JIM_OK)
+ Jim_Nvp_value2name_simple(nvp_target_event, e)->name,
+ Jim_GetString(teap->body, NULL));
+ if (Jim_EvalObj(interp, teap->body) != JIM_OK)
{
Jim_PrintErrorMessage(interp);
}
}
teap = teap->next;
}
- if (!done ){
+ if (!done){
LOG_DEBUG("event: %d %s - no action",
e,
- Jim_Nvp_value2name_simple(nvp_target_event, e )->name );
+ Jim_Nvp_value2name_simple(nvp_target_event, e)->name);
}
}
{ .name = NULL, .value = -1 }
};
-static int target_configure(Jim_GetOptInfo *goi, target_t *target )
+static int target_configure(Jim_GetOptInfo *goi, target_t *target)
{
Jim_Nvp *n;
Jim_Obj *o;
int e;
/* parse config or cget options ... */
- while (goi->argc > 0 ){
- Jim_SetEmptyResult(goi->interp );
- /* Jim_GetOpt_Debug(goi ); */
+ while (goi->argc > 0){
+ Jim_SetEmptyResult(goi->interp);
+ /* Jim_GetOpt_Debug(goi); */
- if (target->type->target_jim_configure ){
+ if (target->type->target_jim_configure){
/* target defines a configure function */
/* target gets first dibs on parameters */
- e = (*(target->type->target_jim_configure))(target, goi );
- if (e == JIM_OK ){
+ e = (*(target->type->target_jim_configure))(target, goi);
+ if (e == JIM_OK){
/* more? */
continue;
}
- if (e == JIM_ERR ){
+ if (e == JIM_ERR){
/* An error */
return e;
}
/* otherwise we 'continue' below */
}
- e = Jim_GetOpt_Nvp(goi, nvp_config_opts, &n );
- if (e != JIM_OK ){
- Jim_GetOpt_NvpUnknown(goi, nvp_config_opts, 0 );
+ e = Jim_GetOpt_Nvp(goi, nvp_config_opts, &n);
+ if (e != JIM_OK){
+ Jim_GetOpt_NvpUnknown(goi, nvp_config_opts, 0);
return e;
}
- switch (n->value ){
+ switch (n->value){
case TCFG_TYPE:
/* not setable */
- if (goi->isconfigure ){
- Jim_SetResult_sprintf(goi->interp, "not setable: %s", n->name );
+ if (goi->isconfigure){
+ Jim_SetResult_sprintf(goi->interp, "not setable: %s", n->name);
return JIM_ERR;
} else {
no_params:
- if (goi->argc != 0 ){
+ if (goi->argc != 0){
Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "NO PARAMS");
return JIM_ERR;
}
}
- Jim_SetResultString(goi->interp, target_get_name(target), -1 );
+ Jim_SetResultString(goi->interp, target_get_name(target), -1);
/* loop for more */
break;
case TCFG_EVENT:
- if (goi->argc == 0 ){
+ if (goi->argc == 0){
Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event ?event-name? ...");
return JIM_ERR;
}
- e = Jim_GetOpt_Nvp(goi, nvp_target_event, &n );
- if (e != JIM_OK ){
- Jim_GetOpt_NvpUnknown(goi, nvp_target_event, 1 );
+ e = Jim_GetOpt_Nvp(goi, nvp_target_event, &n);
+ if (e != JIM_OK){
+ Jim_GetOpt_NvpUnknown(goi, nvp_target_event, 1);
return e;
}
- if (goi->isconfigure ){
- if (goi->argc != 1 ){
+ if (goi->isconfigure){
+ if (goi->argc != 1){
Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event ?event-name? ?EVENT-BODY?");
return JIM_ERR;
}
} else {
- if (goi->argc != 0 ){
+ if (goi->argc != 0){
Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event ?event-name?");
return JIM_ERR;
}
teap = target->event_action;
/* replace existing? */
- while (teap ){
- if (teap->event == (enum target_event)n->value ){
+ while (teap){
+ if (teap->event == (enum target_event)n->value){
break;
}
teap = teap->next;
}
- if (goi->isconfigure ){
- if (teap == NULL ){
+ if (goi->isconfigure){
+ if (teap == NULL){
/* create new */
- teap = calloc(1, sizeof(*teap) );
+ teap = calloc(1, sizeof(*teap));
}
teap->event = n->value;
- Jim_GetOpt_Obj(goi, &o );
- if (teap->body ){
- Jim_DecrRefCount(interp, teap->body );
+ Jim_GetOpt_Obj(goi, &o);
+ if (teap->body){
+ Jim_DecrRefCount(interp, teap->body);
}
- teap->body = Jim_DuplicateObj(goi->interp, o );
+ teap->body = Jim_DuplicateObj(goi->interp, o);
/*
* FIXME:
* Tcl/TK - "tk events" have a nice feature.
* The idea is: %N - target number
* The idea is: %E - event name.
*/
- Jim_IncrRefCount(teap->body );
+ Jim_IncrRefCount(teap->body);
/* add to head of event list */
teap->next = target->event_action;
Jim_SetEmptyResult(goi->interp);
} else {
/* get */
- if (teap == NULL ){
- Jim_SetEmptyResult(goi->interp );
+ if (teap == NULL){
+ Jim_SetEmptyResult(goi->interp);
} else {
- Jim_SetResult(goi->interp, Jim_DuplicateObj(goi->interp, teap->body ) );
+ Jim_SetResult(goi->interp, Jim_DuplicateObj(goi->interp, teap->body));
}
}
}
break;
case TCFG_WORK_AREA_VIRT:
- if (goi->isconfigure ){
+ if (goi->isconfigure){
target_free_all_working_areas(target);
- e = Jim_GetOpt_Wide(goi, &w );
- if (e != JIM_OK ){
+ e = Jim_GetOpt_Wide(goi, &w);
+ if (e != JIM_OK){
return e;
}
target->working_area_virt = w;
} else {
- if (goi->argc != 0 ){
+ if (goi->argc != 0){
goto no_params;
}
}
- Jim_SetResult(interp, Jim_NewIntObj(goi->interp, target->working_area_virt ) );
+ Jim_SetResult(interp, Jim_NewIntObj(goi->interp, target->working_area_virt));
/* loop for more */
break;
case TCFG_WORK_AREA_PHYS:
- if (goi->isconfigure ){
+ if (goi->isconfigure){
target_free_all_working_areas(target);
- e = Jim_GetOpt_Wide(goi, &w );
- if (e != JIM_OK ){
+ e = Jim_GetOpt_Wide(goi, &w);
+ if (e != JIM_OK){
return e;
}
target->working_area_phys = w;
} else {
- if (goi->argc != 0 ){
+ if (goi->argc != 0){
goto no_params;
}
}
- Jim_SetResult(interp, Jim_NewIntObj(goi->interp, target->working_area_phys ) );
+ Jim_SetResult(interp, Jim_NewIntObj(goi->interp, target->working_area_phys));
/* loop for more */
break;
case TCFG_WORK_AREA_SIZE:
- if (goi->isconfigure ){
+ if (goi->isconfigure){
target_free_all_working_areas(target);
- e = Jim_GetOpt_Wide(goi, &w );
- if (e != JIM_OK ){
+ e = Jim_GetOpt_Wide(goi, &w);
+ if (e != JIM_OK){
return e;
}
target->working_area_size = w;
} else {
- if (goi->argc != 0 ){
+ if (goi->argc != 0){
goto no_params;
}
}
- Jim_SetResult(interp, Jim_NewIntObj(goi->interp, target->working_area_size ) );
+ Jim_SetResult(interp, Jim_NewIntObj(goi->interp, target->working_area_size));
/* loop for more */
break;
case TCFG_WORK_AREA_BACKUP:
- if (goi->isconfigure ){
+ if (goi->isconfigure){
target_free_all_working_areas(target);
- e = Jim_GetOpt_Wide(goi, &w );
- if (e != JIM_OK ){
+ e = Jim_GetOpt_Wide(goi, &w);
+ if (e != JIM_OK){
return e;
}
/* make this exactly 1 or 0 */
target->backup_working_area = (!!w);
} else {
- if (goi->argc != 0 ){
+ if (goi->argc != 0){
goto no_params;
}
}
break;
case TCFG_ENDIAN:
- if (goi->isconfigure ){
- e = Jim_GetOpt_Nvp(goi, nvp_target_endian, &n );
- if (e != JIM_OK ){
- Jim_GetOpt_NvpUnknown(goi, nvp_target_endian, 1 );
+ if (goi->isconfigure){
+ e = Jim_GetOpt_Nvp(goi, nvp_target_endian, &n);
+ if (e != JIM_OK){
+ Jim_GetOpt_NvpUnknown(goi, nvp_target_endian, 1);
return e;
}
target->endianness = n->value;
} else {
- if (goi->argc != 0 ){
+ if (goi->argc != 0){
goto no_params;
}
}
- n = Jim_Nvp_value2name_simple(nvp_target_endian, target->endianness );
- if (n->name == NULL ){
+ n = Jim_Nvp_value2name_simple(nvp_target_endian, target->endianness);
+ if (n->name == NULL){
target->endianness = TARGET_LITTLE_ENDIAN;
- n = Jim_Nvp_value2name_simple(nvp_target_endian, target->endianness );
+ n = Jim_Nvp_value2name_simple(nvp_target_endian, target->endianness);
}
- Jim_SetResultString(goi->interp, n->name, -1 );
+ Jim_SetResultString(goi->interp, n->name, -1);
/* loop for more */
break;
case TCFG_VARIANT:
- if (goi->isconfigure ){
- if (goi->argc < 1 ){
+ if (goi->isconfigure){
+ if (goi->argc < 1){
Jim_SetResult_sprintf(goi->interp,
"%s ?STRING?",
- n->name );
+ n->name);
return JIM_ERR;
}
- if (target->variant ){
+ if (target->variant){
free((void *)(target->variant));
}
- e = Jim_GetOpt_String(goi, &cp, NULL );
+ e = Jim_GetOpt_String(goi, &cp, NULL);
target->variant = strdup(cp);
} else {
- if (goi->argc != 0 ){
+ if (goi->argc != 0){
goto no_params;
}
}
- Jim_SetResultString(goi->interp, target->variant,-1 );
+ Jim_SetResultString(goi->interp, target->variant,-1);
/* loop for more */
break;
case TCFG_CHAIN_POSITION:
- if (goi->isconfigure ){
+ if (goi->isconfigure){
Jim_Obj *o;
jtag_tap_t *tap;
target_free_all_working_areas(target);
- e = Jim_GetOpt_Obj(goi, &o );
- if (e != JIM_OK ){
+ e = Jim_GetOpt_Obj(goi, &o);
+ if (e != JIM_OK){
return e;
}
- tap = jtag_tap_by_jim_obj(goi->interp, o );
- if (tap == NULL ){
+ tap = jtag_tap_by_jim_obj(goi->interp, o);
+ if (tap == NULL){
return JIM_ERR;
}
/* make this exactly 1 or 0 */
target->tap = tap;
} else {
- if (goi->argc != 0 ){
+ if (goi->argc != 0){
goto no_params;
}
}
- Jim_SetResultString(interp, target->tap->dotted_name, -1 );
+ Jim_SetResultString(interp, target->tap->dotted_name, -1);
/* loop for more e*/
break;
}
- } /* while (goi->argc ) */
+ } /* while (goi->argc) */
/* done - we return */
}
/** this is the 'tcl' handler for the target specific command */
-static int tcl_target_func(Jim_Interp *interp, int argc, Jim_Obj *const *argv )
+static int tcl_target_func(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_GetOptInfo goi;
jim_wide a,b,c;
};
/* go past the "command" */
- Jim_GetOpt_Setup(&goi, interp, argc-1, argv + 1 );
+ Jim_GetOpt_Setup(&goi, interp, argc-1, argv + 1);
- target = Jim_CmdPrivData(goi.interp );
+ target = Jim_CmdPrivData(goi.interp);
cmd_ctx = Jim_GetAssocData(goi.interp, "context");
/* commands here are in an NVP table */
- e = Jim_GetOpt_Nvp(&goi, target_options, &n );
- if (e != JIM_OK ){
- Jim_GetOpt_NvpUnknown(&goi, target_options, 0 );
+ e = Jim_GetOpt_Nvp(&goi, target_options, &n);
+ if (e != JIM_OK){
+ Jim_GetOpt_NvpUnknown(&goi, target_options, 0);
return e;
}
/* Assume blank result */
- Jim_SetEmptyResult(goi.interp );
+ Jim_SetEmptyResult(goi.interp);
- switch (n->value ){
+ switch (n->value){
case TS_CMD_CONFIGURE:
- if (goi.argc < 2 ){
+ if (goi.argc < 2){
Jim_WrongNumArgs(goi.interp, goi.argc, goi.argv, "missing: -option VALUE ...");
return JIM_ERR;
}
goi.isconfigure = 1;
- return target_configure(&goi, target );
+ return target_configure(&goi, target);
case TS_CMD_CGET:
// some things take params
- if (goi.argc < 1 ){
+ if (goi.argc < 1){
Jim_WrongNumArgs(goi.interp, 0, goi.argv, "missing: ?-option?");
return JIM_ERR;
}
goi.isconfigure = 0;
- return target_configure(&goi, target );
+ return target_configure(&goi, target);
break;
case TS_CMD_MWW:
case TS_CMD_MWH:
* argv[3] = optional count.
*/
- if ((goi.argc == 2) || (goi.argc == 3) ){
+ if ((goi.argc == 2) || (goi.argc == 3)){
/* all is well */
} else {
mwx_error:
- Jim_SetResult_sprintf(goi.interp, "expected: %s ADDR DATA [COUNT]", n->name );
+ Jim_SetResult_sprintf(goi.interp, "expected: %s ADDR DATA [COUNT]", n->name);
return JIM_ERR;
}
- e = Jim_GetOpt_Wide(&goi, &a );
- if (e != JIM_OK ){
+ e = Jim_GetOpt_Wide(&goi, &a);
+ if (e != JIM_OK){
goto mwx_error;
}
- e = Jim_GetOpt_Wide(&goi, &b );
- if (e != JIM_OK ){
+ e = Jim_GetOpt_Wide(&goi, &b);
+ if (e != JIM_OK){
goto mwx_error;
}
if (goi.argc == 3) {
- e = Jim_GetOpt_Wide(&goi, &c );
- if (e != JIM_OK ){
+ e = Jim_GetOpt_Wide(&goi, &c);
+ if (e != JIM_OK){
goto mwx_error;
}
} else {
c = 1;
}
- switch (n->value ){
+ switch (n->value){
case TS_CMD_MWW:
- target_buffer_set_u32(target, target_buf, b );
+ target_buffer_set_u32(target, target_buf, b);
b = 4;
break;
case TS_CMD_MWH:
- target_buffer_set_u16(target, target_buf, b );
+ target_buffer_set_u16(target, target_buf, b);
b = 2;
break;
case TS_CMD_MWB:
- target_buffer_set_u8(target, target_buf, b );
+ target_buffer_set_u8(target, target_buf, b);
b = 1;
break;
}
- for (x = 0 ; x < c ; x++ ){
- e = target_write_memory(target, a, b, 1, target_buf );
- if (e != ERROR_OK ){
- Jim_SetResult_sprintf(interp, "Error writing @ 0x%08x: %d\n", (int)(a), e );
+ for (x = 0 ; x < c ; x++){
+ e = target_write_memory(target, a, b, 1, target_buf);
+ if (e != ERROR_OK){
+ Jim_SetResult_sprintf(interp, "Error writing @ 0x%08x: %d\n", (int)(a), e);
return JIM_ERR;
}
/* b = width */
* argv[1] = address
* argv[2] = optional count
*/
- if ((goi.argc == 2) || (goi.argc == 3) ){
- Jim_SetResult_sprintf(goi.interp, "expected: %s ADDR [COUNT]", n->name );
+ if ((goi.argc == 2) || (goi.argc == 3)){
+ Jim_SetResult_sprintf(goi.interp, "expected: %s ADDR [COUNT]", n->name);
return JIM_ERR;
}
- e = Jim_GetOpt_Wide(&goi, &a );
- if (e != JIM_OK ){
+ e = Jim_GetOpt_Wide(&goi, &a);
+ if (e != JIM_OK){
return JIM_ERR;
}
- if (goi.argc ){
- e = Jim_GetOpt_Wide(&goi, &c );
- if (e != JIM_OK ){
+ if (goi.argc){
+ e = Jim_GetOpt_Wide(&goi, &c);
+ if (e != JIM_OK){
return JIM_ERR;
}
} else {
c = 1;
}
b = 1; /* shut up gcc */
- switch (n->value ){
+ switch (n->value){
case TS_CMD_MDW:
b = 4;
break;
/* convert to "bytes" */
c = c * b;
/* count is now in 'BYTES' */
- while (c > 0 ){
+ while (c > 0){
y = c;
- if (y > 16 ){
+ if (y > 16){
y = 16;
}
- e = target_read_memory(target, a, b, y / b, target_buf );
- if (e != ERROR_OK ){
- Jim_SetResult_sprintf(interp, "error reading target @ 0x%08lx", (int)(a) );
+ e = target_read_memory(target, a, b, y / b, target_buf);
+ if (e != ERROR_OK){
+ Jim_SetResult_sprintf(interp, "error reading target @ 0x%08lx", (int)(a));
return JIM_ERR;
}
- Jim_fprintf(interp, interp->cookie_stdout, "0x%08x ", (int)(a) );
- switch (b ){
+ Jim_fprintf(interp, interp->cookie_stdout, "0x%08x ", (int)(a));
+ switch (b){
case 4:
- for (x = 0 ; (x < 16) && (x < y) ; x += 4 ){
- z = target_buffer_get_u32(target, &(target_buf[ x * 4 ]) );
- Jim_fprintf(interp, interp->cookie_stdout, "%08x ", (int)(z) );
+ for (x = 0 ; (x < 16) && (x < y) ; x += 4){
+ z = target_buffer_get_u32(target, &(target_buf[ x * 4 ]));
+ Jim_fprintf(interp, interp->cookie_stdout, "%08x ", (int)(z));
}
- for (; (x < 16) ; x += 4 ){
- Jim_fprintf(interp, interp->cookie_stdout, " " );
+ for (; (x < 16) ; x += 4){
+ Jim_fprintf(interp, interp->cookie_stdout, " ");
}
break;
case 2:
- for (x = 0 ; (x < 16) && (x < y) ; x += 2 ){
- z = target_buffer_get_u16(target, &(target_buf[ x * 2 ]) );
- Jim_fprintf(interp, interp->cookie_stdout, "%04x ", (int)(z) );
+ for (x = 0 ; (x < 16) && (x < y) ; x += 2){
+ z = target_buffer_get_u16(target, &(target_buf[ x * 2 ]));
+ Jim_fprintf(interp, interp->cookie_stdout, "%04x ", (int)(z));
}
- for (; (x < 16) ; x += 2 ){
- Jim_fprintf(interp, interp->cookie_stdout, " " );
+ for (; (x < 16) ; x += 2){
+ Jim_fprintf(interp, interp->cookie_stdout, " ");
}
break;
case 1:
default:
- for (x = 0 ; (x < 16) && (x < y) ; x += 1 ){
- z = target_buffer_get_u8(target, &(target_buf[ x * 4 ]) );
- Jim_fprintf(interp, interp->cookie_stdout, "%02x ", (int)(z) );
+ for (x = 0 ; (x < 16) && (x < y) ; x += 1){
+ z = target_buffer_get_u8(target, &(target_buf[ x * 4 ]));
+ Jim_fprintf(interp, interp->cookie_stdout, "%02x ", (int)(z));
}
- for (; (x < 16) ; x += 1 ){
- Jim_fprintf(interp, interp->cookie_stdout, " " );
+ for (; (x < 16) ; x += 1){
+ Jim_fprintf(interp, interp->cookie_stdout, " ");
}
break;
}
/* ascii-ify the bytes */
- for (x = 0 ; x < y ; x++ ){
+ for (x = 0 ; x < y ; x++){
if ((target_buf[x] >= 0x20) &&
- (target_buf[x] <= 0x7e) ){
+ (target_buf[x] <= 0x7e)){
/* good */
} else {
/* smack it */
}
}
/* space pad */
- while (x < 16 ){
+ while (x < 16){
target_buf[x] = ' ';
x++;
}
/* terminate */
target_buf[16] = 0;
/* print - with a newline */
- Jim_fprintf(interp, interp->cookie_stdout, "%s\n", target_buf );
+ Jim_fprintf(interp, interp->cookie_stdout, "%s\n", target_buf);
/* NEXT... */
c -= 16;
a += 16;
}
return JIM_OK;
case TS_CMD_MEM2ARRAY:
- return target_mem2array(goi.interp, target, goi.argc, goi.argv );
+ return target_mem2array(goi.interp, target, goi.argc, goi.argv);
break;
case TS_CMD_ARRAY2MEM:
- return target_array2mem(goi.interp, target, goi.argc, goi.argv );
+ return target_array2mem(goi.interp, target, goi.argc, goi.argv);
break;
case TS_CMD_EXAMINE:
- if (goi.argc ){
+ if (goi.argc){
Jim_WrongNumArgs(goi.interp, 2, argv, "[no parameters]");
return JIM_ERR;
}
if (!target->tap->enabled)
goto err_tap_disabled;
- e = target->type->examine(target );
- if (e != ERROR_OK ){
- Jim_SetResult_sprintf(interp, "examine-fails: %d", e );
+ e = target->type->examine(target);
+ if (e != ERROR_OK){
+ Jim_SetResult_sprintf(interp, "examine-fails: %d", e);
return JIM_ERR;
}
return JIM_OK;
case TS_CMD_POLL:
- if (goi.argc ){
+ if (goi.argc){
Jim_WrongNumArgs(goi.interp, 2, argv, "[no parameters]");
return JIM_ERR;
}
if (!target->tap->enabled)
goto err_tap_disabled;
- if (!(target_was_examined(target)) ){
+ if (!(target_was_examined(target))){
e = ERROR_TARGET_NOT_EXAMINED;
} else {
- e = target->type->poll(target );
+ e = target->type->poll(target);
}
- if (e != ERROR_OK ){
- Jim_SetResult_sprintf(interp, "poll-fails: %d", e );
+ if (e != ERROR_OK){
+ Jim_SetResult_sprintf(interp, "poll-fails: %d", e);
return JIM_ERR;
} else {
return JIM_OK;
}
break;
case TS_CMD_RESET:
- if (goi.argc != 2 ){
+ if (goi.argc != 2){
Jim_WrongNumArgs(interp, 2, argv, "t | f|assert | deassert BOOL");
return JIM_ERR;
}
- e = Jim_GetOpt_Nvp(&goi, nvp_assert, &n );
- if (e != JIM_OK ){
- Jim_GetOpt_NvpUnknown(&goi, nvp_assert, 1 );
+ e = Jim_GetOpt_Nvp(&goi, nvp_assert, &n);
+ if (e != JIM_OK){
+ Jim_GetOpt_NvpUnknown(&goi, nvp_assert, 1);
return e;
}
/* the halt or not param */
e = Jim_GetOpt_Wide(&goi, &a);
- if (e != JIM_OK ){
+ if (e != JIM_OK){
return e;
}
if (!target->tap->enabled)
target_free_all_working_areas_restore(target, 0);
/* do the assert */
- if (n->value == NVP_ASSERT ){
- target->type->assert_reset(target );
+ if (n->value == NVP_ASSERT){
+ target->type->assert_reset(target);
} else {
- target->type->deassert_reset(target );
+ target->type->deassert_reset(target);
}
return JIM_OK;
case TS_CMD_HALT:
- if (goi.argc ){
+ if (goi.argc){
Jim_WrongNumArgs(goi.interp, 0, argv, "halt [no parameters]");
return JIM_ERR;
}
if (!target->tap->enabled)
goto err_tap_disabled;
- target->type->halt(target );
+ target->type->halt(target);
return JIM_OK;
case TS_CMD_WAITSTATE:
/* params: <name> statename timeoutmsecs */
- if (goi.argc != 2 ){
- Jim_SetResult_sprintf(goi.interp, "%s STATENAME TIMEOUTMSECS", n->name );
+ if (goi.argc != 2){
+ Jim_SetResult_sprintf(goi.interp, "%s STATENAME TIMEOUTMSECS", n->name);
return JIM_ERR;
}
- e = Jim_GetOpt_Nvp(&goi, nvp_target_state, &n );
- if (e != JIM_OK ){
- Jim_GetOpt_NvpUnknown(&goi, nvp_target_state,1 );
+ e = Jim_GetOpt_Nvp(&goi, nvp_target_state, &n);
+ if (e != JIM_OK){
+ Jim_GetOpt_NvpUnknown(&goi, nvp_target_state,1);
return e;
}
- e = Jim_GetOpt_Wide(&goi, &a );
- if (e != JIM_OK ){
+ e = Jim_GetOpt_Wide(&goi, &a);
+ if (e != JIM_OK){
return e;
}
if (!target->tap->enabled)
goto err_tap_disabled;
- e = target_wait_state(target, n->value, a );
- if (e != ERROR_OK ){
+ e = target_wait_state(target, n->value, a);
+ if (e != ERROR_OK){
Jim_SetResult_sprintf(goi.interp,
"target: %s wait %s fails (%d) %s",
target->cmd_name,
n->name,
- e, target_strerror_safe(e) );
+ e, target_strerror_safe(e));
return JIM_ERR;
} else {
return JIM_OK;
teap = target->event_action;
command_print(cmd_ctx, "Event actions for target (%d) %s\n",
target->target_number,
- target->cmd_name );
+ target->cmd_name);
command_print(cmd_ctx, "%-25s | Body", "Event");
command_print(cmd_ctx, "------------------------- | ----------------------------------------");
- while (teap ){
+ while (teap){
command_print(cmd_ctx,
"%-25s | %s",
- Jim_Nvp_value2name_simple(nvp_target_event, teap->event )->name,
- Jim_GetString(teap->body, NULL ) );
+ Jim_Nvp_value2name_simple(nvp_target_event, teap->event)->name,
+ Jim_GetString(teap->body, NULL));
teap = teap->next;
}
command_print(cmd_ctx, "***END***");
return JIM_OK;
}
case TS_CMD_CURSTATE:
- if (goi.argc != 0 ){
+ if (goi.argc != 0){
Jim_WrongNumArgs(goi.interp, 0, argv, "[no parameters]");
return JIM_ERR;
}
Jim_Nvp_value2name_simple(nvp_target_state,target->state)->name,-1);
return JIM_OK;
case TS_CMD_INVOKE_EVENT:
- if (goi.argc != 1 ){
+ if (goi.argc != 1){
Jim_SetResult_sprintf(goi.interp, "%s ?EVENTNAME?",n->name);
return JIM_ERR;
}
- e = Jim_GetOpt_Nvp(&goi, nvp_target_event, &n );
- if (e != JIM_OK ){
- Jim_GetOpt_NvpUnknown(&goi, nvp_target_event, 1 );
+ e = Jim_GetOpt_Nvp(&goi, nvp_target_event, &n);
+ if (e != JIM_OK){
+ Jim_GetOpt_NvpUnknown(&goi, nvp_target_event, 1);
return e;
}
- target_handle_event(target, n->value );
+ target_handle_event(target, n->value);
return JIM_OK;
}
return JIM_ERR;
return JIM_ERR;
}
-static int target_create(Jim_GetOptInfo *goi )
+static int target_create(Jim_GetOptInfo *goi)
{
Jim_Obj *new_cmd;
Jim_Cmd *cmd;
struct command_context_s *cmd_ctx;
cmd_ctx = Jim_GetAssocData(goi->interp, "context");
- if (goi->argc < 3 ){
+ if (goi->argc < 3){
Jim_WrongNumArgs(goi->interp, 1, goi->argv, "?name? ?type? ..options...");
return JIM_ERR;
}
/* COMMAND */
- Jim_GetOpt_Obj(goi, &new_cmd );
+ Jim_GetOpt_Obj(goi, &new_cmd);
/* does this command exist? */
- cmd = Jim_GetCommand(goi->interp, new_cmd, JIM_ERRMSG );
- if (cmd ){
- cp = Jim_GetString(new_cmd, NULL );
+ cmd = Jim_GetCommand(goi->interp, new_cmd, JIM_ERRMSG);
+ if (cmd){
+ cp = Jim_GetString(new_cmd, NULL);
Jim_SetResult_sprintf(goi->interp, "Command/target: %s Exists", cp);
return JIM_ERR;
}
/* TYPE */
- e = Jim_GetOpt_String(goi, &cp2, NULL );
+ e = Jim_GetOpt_String(goi, &cp2, NULL);
cp = cp2;
/* now does target type exist */
- for (x = 0 ; target_types[x] ; x++ ){
- if (0 == strcmp(cp, target_types[x]->name ) ){
+ for (x = 0 ; target_types[x] ; x++){
+ if (0 == strcmp(cp, target_types[x]->name)){
/* found */
break;
}
}
- if (target_types[x] == NULL ){
- Jim_SetResult_sprintf(goi->interp, "Unknown target type %s, try one of ", cp );
- for (x = 0 ; target_types[x] ; x++ ){
- if (target_types[x + 1] ){
+ if (target_types[x] == NULL){
+ Jim_SetResult_sprintf(goi->interp, "Unknown target type %s, try one of ", cp);
+ for (x = 0 ; target_types[x] ; x++){
+ if (target_types[x + 1]){
Jim_AppendStrings(goi->interp,
Jim_GetResult(goi->interp),
target_types[x]->name,
Jim_AppendStrings(goi->interp,
Jim_GetResult(goi->interp),
" or ",
- target_types[x]->name,NULL );
+ target_types[x]->name,NULL);
}
}
return JIM_ERR;
e = JIM_ERR;
}
- if (e != JIM_OK ){
- free(target->type );
- free(target );
+ if (e != JIM_OK){
+ free(target->type);
+ free(target);
return e;
}
- if (target->endianness == TARGET_ENDIAN_UNKNOWN ){
+ if (target->endianness == TARGET_ENDIAN_UNKNOWN){
/* default endian to little if not specified */
target->endianness = TARGET_LITTLE_ENDIAN;
}
target->variant = strdup("");
/* create the target specific commands */
- if (target->type->register_commands ){
- (*(target->type->register_commands))(cmd_ctx );
+ if (target->type->register_commands){
+ (*(target->type->register_commands))(cmd_ctx);
}
- if (target->type->target_create ){
- (*(target->type->target_create))(target, goi->interp );
+ if (target->type->target_create){
+ (*(target->type->target_create))(target, goi->interp);
}
/* append to end of list */
{
target_t **tpp;
tpp = &(all_targets);
- while (*tpp ){
- tpp = &((*tpp)->next );
+ while (*tpp){
+ tpp = &((*tpp)->next);
}
*tpp = target;
}
- cp = Jim_GetString(new_cmd, NULL );
+ cp = Jim_GetString(new_cmd, NULL);
target->cmd_name = strdup(cp);
/* now - create the new target name command */
cp,
tcl_target_func, /* C function */
target, /* private data */
- NULL ); /* no del proc */
+ NULL); /* no del proc */
return e;
}
-static int jim_target(Jim_Interp *interp, int argc, Jim_Obj *const *argv )
+static int jim_target(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int x,r,e;
jim_wide w;
LOG_DEBUG("Target command params:");
LOG_DEBUG("%s", Jim_Debug_ArgvString(interp, argc, argv));
- cmd_ctx = Jim_GetAssocData(interp, "context" );
+ cmd_ctx = Jim_GetAssocData(interp, "context");
- Jim_GetOpt_Setup(&goi, interp, argc-1, argv + 1 );
+ Jim_GetOpt_Setup(&goi, interp, argc-1, argv + 1);
- if (goi.argc == 0 ){
+ if (goi.argc == 0){
Jim_WrongNumArgs(interp, 1, argv, "missing: command ...");
return JIM_ERR;
}
- /* Jim_GetOpt_Debug(&goi ); */
- r = Jim_GetOpt_Enum(&goi, target_cmds, &x );
- if (r != JIM_OK ){
+ /* Jim_GetOpt_Debug(&goi); */
+ r = Jim_GetOpt_Enum(&goi, target_cmds, &x);
+ if (r != JIM_OK){
return r;
}
Jim_Panic(goi.interp,"Why am I here?");
return JIM_ERR;
case TG_CMD_CURRENT:
- if (goi.argc != 0 ){
+ if (goi.argc != 0){
Jim_WrongNumArgs(goi.interp, 1, goi.argv, "Too many parameters");
return JIM_ERR;
}
- Jim_SetResultString(goi.interp, get_current_target(cmd_ctx )->cmd_name, -1 );
+ Jim_SetResultString(goi.interp, get_current_target(cmd_ctx)->cmd_name, -1);
return JIM_OK;
case TG_CMD_TYPES:
- if (goi.argc != 0 ){
- Jim_WrongNumArgs(goi.interp, 1, goi.argv, "Too many parameters" );
+ if (goi.argc != 0){
+ Jim_WrongNumArgs(goi.interp, 1, goi.argv, "Too many parameters");
return JIM_ERR;
}
- Jim_SetResult(goi.interp, Jim_NewListObj(goi.interp, NULL, 0 ) );
- for (x = 0 ; target_types[x] ; x++ ){
+ Jim_SetResult(goi.interp, Jim_NewListObj(goi.interp, NULL, 0));
+ for (x = 0 ; target_types[x] ; x++){
Jim_ListAppendElement(goi.interp,
Jim_GetResult(goi.interp),
- Jim_NewStringObj(goi.interp, target_types[x]->name, -1 ) );
+ Jim_NewStringObj(goi.interp, target_types[x]->name, -1));
}
return JIM_OK;
case TG_CMD_NAMES:
- if (goi.argc != 0 ){
- Jim_WrongNumArgs(goi.interp, 1, goi.argv, "Too many parameters" );
+ if (goi.argc != 0){
+ Jim_WrongNumArgs(goi.interp, 1, goi.argv, "Too many parameters");
return JIM_ERR;
}
- Jim_SetResult(goi.interp, Jim_NewListObj(goi.interp, NULL, 0 ) );
+ Jim_SetResult(goi.interp, Jim_NewListObj(goi.interp, NULL, 0));
target = all_targets;
- while (target ){
+ while (target){
Jim_ListAppendElement(goi.interp,
Jim_GetResult(goi.interp),
- Jim_NewStringObj(goi.interp, target->cmd_name, -1 ) );
+ Jim_NewStringObj(goi.interp, target->cmd_name, -1));
target = target->next;
}
return JIM_OK;
case TG_CMD_CREATE:
- if (goi.argc < 3 ){
+ if (goi.argc < 3){
Jim_WrongNumArgs(goi.interp, goi.argc, goi.argv, "?name ... config options ...");
return JIM_ERR;
}
- return target_create(&goi );
+ return target_create(&goi);
break;
case TG_CMD_NUMBER:
- if (goi.argc != 1 ){
+ if (goi.argc != 1){
Jim_SetResult_sprintf(goi.interp, "expected: target number ?NUMBER?");
return JIM_ERR;
}
- e = Jim_GetOpt_Wide(&goi, &w );
- if (e != JIM_OK ){
+ e = Jim_GetOpt_Wide(&goi, &w);
+ if (e != JIM_OK){
return JIM_ERR;
}
{
target_t *t;
t = get_target_by_num(w);
- if (t == NULL ){
+ if (t == NULL){
Jim_SetResult_sprintf(goi.interp,"Target: number %d does not exist", (int)(w));
return JIM_ERR;
}
- Jim_SetResultString(goi.interp, t->cmd_name, -1 );
+ Jim_SetResultString(goi.interp, t->cmd_name, -1);
return JIM_OK;
}
case TG_CMD_COUNT:
- if (goi.argc != 0 ){
+ if (goi.argc != 0){
Jim_WrongNumArgs(goi.interp, 0, goi.argv, "<no parameters>");
return JIM_ERR;
}
int target_arch_state(struct target_s *target);
void target_handle_event(target_t *t, enum target_event e);
-void target_all_handle_event(enum target_event e );
+void target_all_handle_event(enum target_event e);
#define ERROR_TARGET_INVALID (-300)
#define ERROR_TARGET_INIT_FAILED (-301)
#define ERROR_TARGET_NOT_EXAMINED (-311)
extern const Jim_Nvp nvp_error_target[];
-extern const char *target_strerror_safe(int err );
+extern const char *target_strerror_safe(int err);
#endif /* TARGET_H */
{
target_req_cmd_t target_req_cmd = request & 0xff;
- if (charmsg_mode ) {
- target_charmsg(target, target_req_cmd );
+ if (charmsg_mode) {
+ target_charmsg(target, target_req_cmd);
return ERROR_OK;
}
switch (target_req_cmd)
}
command_print(cmd_ctx, "receiving debug messages from current target %s",
- (receiving) ? (charmsg_mode?"charmsg":"enabled") : "disabled" );
+ (receiving) ? (charmsg_mode?"charmsg":"enabled") : "disabled");
return ERROR_OK;
}
int (*register_commands)(struct command_context_s *cmd_ctx);
/* called when target is created */
- int (*target_create)(struct target_s *target, Jim_Interp *interp );
+ int (*target_create)(struct target_s *target, Jim_Interp *interp);
/* called for various config parameters */
/* returns JIM_CONTINUE - if option not understood */
/* otherwise: JIM_OK, or JIM_ERR, */
- int (*target_jim_configure)(struct target_s *target, Jim_GetOptInfo *goi );
+ int (*target_jim_configure)(struct target_s *target, Jim_GetOptInfo *goi);
/* target commands specifically handled by the target */
/* returns JIM_OK, or JIM_ERR, or JIM_CONTINUE - if option not understood */
- int (*target_jim_commands)(struct target_s *target, Jim_GetOptInfo *goi );
+ int (*target_jim_commands)(struct target_s *target, Jim_GetOptInfo *goi);
/* invoked after JTAG chain has been examined & validated. During
* this stage the target is examined and any additional setup is
uint32_t first = 0;
uint32_t last = trace->trace_history_pos;
- if (!trace->trace_history_size ) {
+ if (!trace->trace_history_size) {
command_print(cmd_ctx, "trace history buffer is not allocated");
return ERROR_OK;
}
"MMU: %s, D-Cache: %s, I-Cache: %s"
"%s",
armv4_5_state_strings[armv4_5->core_state],
- Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason )->name ,
+ Jim_Nvp_value2name_simple(nvp_target_debug_reason, target->debug_reason)->name ,
armv4_5_mode_strings[armv4_5_mode_to_number(armv4_5->core_mode)],
buf_get_u32(armv4_5->core_cache->reg_list[ARMV4_5_CPSR].value, 0, 32),
buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32),
xscale_common_t *xscale = armv4_5->arch_info;
LOG_DEBUG("target->state: %s",
- Jim_Nvp_value2name_simple(nvp_target_state, target->state )->name);
+ Jim_Nvp_value2name_simple(nvp_target_state, target->state)->name);
if (target->state == TARGET_HALTED)
{
xscale_common_t *xscale = armv4_5->arch_info;
LOG_DEBUG("target->state: %s",
- Jim_Nvp_value2name_simple(nvp_target_state, target->state )->name);
+ Jim_Nvp_value2name_simple(nvp_target_state, target->state)->name);
/* select DCSR instruction (set endstate to R-T-I to ensure we don't
* end up in T-L-R, which would reset JTAG
/* map xsvf tap state to an openocd "tap_state_t" */
-static tap_state_t xsvf_to_tap(int xsvf_state )
+static tap_state_t xsvf_to_tap(int xsvf_state)
{
tap_state_t ret;
- switch (xsvf_state )
+ switch (xsvf_state)
{
case XSV_RESET: ret = TAP_RESET; break;
case XSV_IDLE: ret = TAP_IDLE; break;
case XSV_IREXIT2: ret = TAP_IREXIT2; break;
case XSV_IRUPDATE: ret = TAP_IRUPDATE; break;
default:
- LOG_ERROR("UNKNOWN XSVF STATE 0x%02X", xsvf_state );
+ LOG_ERROR("UNKNOWN XSVF STATE 0x%02X", xsvf_state);
exit(1);
}
if (strcmp(args[0], "plain") != 0)
{
- tap = jtag_tap_by_string(args[0] );
- if (!tap )
+ tap = jtag_tap_by_string(args[0]);
+ if (!tap)
{
- command_print(cmd_ctx, "Tap: %s unknown", args[0] );
+ command_print(cmd_ctx, "Tap: %s unknown", args[0]);
return ERROR_FAIL;
}
}
LOG_USER("xsvf processing file: \"%s\"", filename);
- while (read(xsvf_fd, &opcode, 1) > 0 )
+ while (read(xsvf_fd, &opcode, 1) > 0)
{
/* record the position of the just read opcode within the file */
file_offset = lseek(xsvf_fd, 0, SEEK_CUR) - 1;
else
{
xrepeat = myrepeat;
- LOG_DEBUG("XREPEAT %d", xrepeat );
+ LOG_DEBUG("XREPEAT %d", xrepeat);
}
}
break;
xsdrsize = be_to_h_u32(xsdrsize_buf);
LOG_DEBUG("XSDRSIZE %d", xsdrsize);
- if (dr_out_buf ) free(dr_out_buf);
+ if (dr_out_buf) free(dr_out_buf);
if (dr_in_buf) free(dr_in_buf);
if (dr_in_mask) free(dr_in_mask);
if (opcode == XSDRTDO)
{
- if (xsvf_read_buffer(xsdrsize, xsvf_fd, dr_in_buf) != ERROR_OK )
+ if (xsvf_read_buffer(xsdrsize, xsvf_fd, dr_in_buf) != ERROR_OK)
{
do_abort = 1;
break;
LOG_DEBUG("%s %d", op_name, xsdrsize);
- for (attempt = 0; attempt < limit; ++attempt )
+ for (attempt = 0; attempt < limit; ++attempt)
{
scan_field_t field;
- if (attempt > 0 )
+ if (attempt > 0)
{
/* perform the XC9500 exception handling sequence shown in xapp067.pdf and
illustrated in psuedo code at end of this file. We start from state
TAP_IDLE,
};
- jtag_add_pathmove(DIM(exception_path), exception_path );
+ jtag_add_pathmove(DIM(exception_path), exception_path);
if (verbose)
LOG_USER("%s mismatch, xsdrsize=%d retry=%d", op_name, xsdrsize, attempt);
mystate = xsvf_to_tap(uc);
- LOG_DEBUG("XSTATE 0x%02X %s", uc, tap_state_name(mystate) );
+ LOG_DEBUG("XSTATE 0x%02X %s", uc, tap_state_name(mystate));
/* there is no need for the lookahead code that was here since we
queue up the jtag commands anyway. This is a simple way to handle
the XSTATE.
*/
- if (jtag_add_statemove(mystate ) != ERROR_OK )
+ if (jtag_add_statemove(mystate) != ERROR_OK)
{
/* For special states known as stable states
(Test-Logic-Reset, Run-Test/Idle, Pause-DR, Pause- IR),
LOG_ERROR("XSTATE %s is not reachable from current state %s in one clock cycle",
tap_state_name(mystate),
tap_state_name(cmd_queue_cur_state)
- );
+);
}
}
break;
}
/* see page 22 of XSVF spec */
- if (uc == 0 )
+ if (uc == 0)
xendir = TAP_IDLE;
- else if (uc == 1 )
+ else if (uc == 1)
xendir = TAP_IRPAUSE;
else
{
}
/* see page 22 of XSVF spec */
- if (uc == 0 )
+ if (uc == 0)
xenddr = TAP_IDLE;
- else if (uc == 1 )
+ else if (uc == 1)
xenddr = TAP_DRPAUSE;
else
{
int bitcount;
tap_state_t my_end_state = xruntest ? TAP_IDLE : xendir;
- if (opcode == XSIR )
+ if (opcode == XSIR)
{
/* one byte bitcount */
if (read(xsvf_fd, short_buf, 1) < 0)
break;
}
- if (ndx < sizeof(comment)-1 )
+ if (ndx < sizeof(comment)-1)
comment[ndx++] = uc;
} while (uc != 0);
LOG_DEBUG("XWAIT %s %s usecs:%d", tap_state_name(wait_state), tap_state_name(end_state), delay);
- if (runtest_requires_tck && wait_state == TAP_IDLE )
+ if (runtest_requires_tck && wait_state == TAP_IDLE)
{
jtag_add_runtest(delay, end_state);
}
else
{
- jtag_add_statemove(wait_state );
+ jtag_add_statemove(wait_state);
jtag_add_sleep(delay);
- jtag_add_statemove(end_state );
+ jtag_add_statemove(end_state);
}
}
break;
if (read(xsvf_fd, &wait, 1) < 0
|| read(xsvf_fd, &end, 1) < 0
|| read(xsvf_fd, clock_buf, 4) < 0
- || read(xsvf_fd, usecs_buf, 4) < 0 )
+ || read(xsvf_fd, usecs_buf, 4) < 0)
{
do_abort = 1;
break;
}
- wait_state = xsvf_to_tap(wait );
- end_state = xsvf_to_tap(end );
+ wait_state = xsvf_to_tap(wait);
+ end_state = xsvf_to_tap(end);
clock_count = be_to_h_u32(clock_buf);
usecs = be_to_h_u32(usecs_buf);
*/
if (wait_state != TAP_IRPAUSE && wait_state != TAP_DRPAUSE && wait_state != TAP_RESET && wait_state != TAP_IDLE)
{
- LOG_ERROR("illegal XWAITSTATE wait_state: \"%s\"", tap_state_name(wait_state ));
+ LOG_ERROR("illegal XWAITSTATE wait_state: \"%s\"", tap_state_name(wait_state));
unsupported = 1;
}
- jtag_add_statemove(wait_state );
+ jtag_add_statemove(wait_state);
- jtag_add_clocks(clock_count );
+ jtag_add_clocks(clock_count);
- jtag_add_sleep(usecs );
+ jtag_add_sleep(usecs);
- jtag_add_statemove(end_state );
+ jtag_add_statemove(end_state);
}
break;
*/
uint8_t count_buf[4];
- if (read(xsvf_fd, count_buf, 4) < 0 )
+ if (read(xsvf_fd, count_buf, 4) < 0)
{
do_abort = 1;
break;
if (read(xsvf_fd, &state, 1) < 0
|| read(xsvf_fd, clock_buf, 4) < 0
- || read(xsvf_fd, usecs_buf, 4) < 0 )
+ || read(xsvf_fd, usecs_buf, 4) < 0)
{
do_abort = 1;
break;
LOG_DEBUG("LSDR");
if (xsvf_read_buffer(xsdrsize, xsvf_fd, dr_out_buf) != ERROR_OK
- || xsvf_read_buffer(xsdrsize, xsvf_fd, dr_in_buf) != ERROR_OK )
+ || xsvf_read_buffer(xsdrsize, xsvf_fd, dr_in_buf) != ERROR_OK)
{
do_abort = 1;
break;
if (limit < 1)
limit = 1;
- for (attempt = 0; attempt < limit; ++attempt )
+ for (attempt = 0; attempt < limit; ++attempt)
{
scan_field_t field;
- jtag_add_statemove(loop_state );
+ jtag_add_statemove(loop_state);
jtag_add_clocks(loop_clocks);
jtag_add_sleep(loop_usecs);
}
}
- if (!matched )
+ if (!matched)
{
- LOG_USER("LSDR mismatch" );
+ LOG_USER("LSDR mismatch");
tdo_mismatch = 1;
break;
}
break;
}
- switch (trst_mode )
+ switch (trst_mode)
{
case XTRST_ON:
jtag_add_reset(1, 0);
case XTRST_ABSENT:
break;
default:
- LOG_ERROR("XTRST mode argument (0x%02X) out of range", trst_mode );
+ LOG_ERROR("XTRST mode argument (0x%02X) out of range", trst_mode);
do_abort = 1;
}
}
LOG_DEBUG("xsvf failed, setting taps to reasonable state");
/* upon error, return the TAPs to a reasonable state */
- jtag_add_statemove(TAP_IDLE );
+ jtag_add_statemove(TAP_IDLE);
jtag_execute_queue();
break;
}
if (tdo_mismatch)
{
command_print(cmd_ctx, "TDO mismatch, somewhere near offset %lu in xsvf file, aborting",
- file_offset );
+ file_offset);
return ERROR_FAIL;