at91sam7_read_clock_info(bank);
at91sam7_set_flash_mode(bank, FMR_TIMING_FLASH);
- if(erase_all)
+ if (erase_all)
{
if (at91sam7_flash_command(bank, EA, 0) != ERROR_OK)
{
/* Write one block to the PageWriteBuffer */
buffer_pos = (pagen-first_page)*dst_min_alignment;
wcount = CEIL(count,4);
- if((retval = target_write_memory(target, bank->base+pagen*dst_min_alignment, 4, wcount, buffer+buffer_pos)) != ERROR_OK)
+ if ((retval = target_write_memory(target, bank->base+pagen*dst_min_alignment, 4, wcount, buffer+buffer_pos)) != ERROR_OK)
{
return retval;
}
{
cfi_flash_bank_t *cfi_info = bank->driver_priv;
- if(cfi_info->x16_as_x8) offset*=2;
+ if (cfi_info->x16_as_x8) offset*=2;
/* while the sector list isn't built, only accesses to sector 0 work */
if (sector == 0)
cfi_flash_bank_t *cfi_info = bank->driver_priv;
uint8_t data[CFI_MAX_BUS_WIDTH * 2];
- if(cfi_info->x16_as_x8)
+ if (cfi_info->x16_as_x8)
{
uint8_t i;
for(i=0;i<2;i++)
cfi_flash_bank_t *cfi_info = bank->driver_priv;
uint8_t data[CFI_MAX_BUS_WIDTH * 4];
- if(cfi_info->x16_as_x8)
+ if (cfi_info->x16_as_x8)
{
uint8_t i;
for(i=0;i<4;i++)
if ((pri_ext->pri[0] != 'P') || (pri_ext->pri[1] != 'R') || (pri_ext->pri[2] != 'I'))
{
cfi_command(bank, 0xf0, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0xff, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
if ((pri_ext->pri[0] != 'P') || (pri_ext->pri[1] != 'R') || (pri_ext->pri[2] != 'I'))
{
cfi_command(bank, 0xf0, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
if ((atmel_pri_ext.pri[0] != 'P') || (atmel_pri_ext.pri[1] != 'R') || (atmel_pri_ext.pri[2] != 'I'))
{
cfi_command(bank, 0xf0, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
for (i = first; i <= last; i++)
{
cfi_command(bank, 0x20, command);
- if((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0xd0, command);
- if((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
else
{
cfi_command(bank, 0xff, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
for (i = first; i <= last; i++)
{
cfi_command(bank, 0xaa, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0x55, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0x80, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0xaa, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0x55, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0x30, command);
- if((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
else
{
cfi_command(bank, 0xf0, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
{
cfi_command(bank, 0x60, command);
LOG_DEBUG("address: 0x%4.4" PRIx32 ", command: 0x%4.4" PRIx32, flash_address(bank, i, 0x0), target_buffer_get_u32(target, command));
- if((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
{
cfi_command(bank, 0x01, command);
LOG_DEBUG("address: 0x%4.4" PRIx32 ", command: 0x%4.4" PRIx32 , flash_address(bank, i, 0x0), target_buffer_get_u32(target, command));
- if((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
{
cfi_command(bank, 0xd0, command);
LOG_DEBUG("address: 0x%4.4" PRIx32 ", command: 0x%4.4" PRIx32, flash_address(bank, i, 0x0), target_buffer_get_u32(target, command));
- if((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
uint8_t block_status;
/* read block lock bit, to verify status */
cfi_command(bank, 0x90, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x55), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x55), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
{
LOG_ERROR("couldn't change block lock status (set = %i, block_status = 0x%2.2x)", set, block_status);
cfi_command(bank, 0x70, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x55), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x55), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_intel_clear_status_register(bank);
cfi_command(bank, 0x60, command);
- if((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0x01, command);
- if((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, i, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
uint32_t thisrun_count = (count > buffer_size) ? buffer_size : count;
uint32_t wsm_error;
- if((retval = target_write_buffer(target, source->address, thisrun_count, buffer)) != ERROR_OK)
+ if ((retval = target_write_buffer(target, source->address, thisrun_count, buffer)) != ERROR_OK)
{
goto cleanup;
}
}
/* write algorithm code to working area */
- if((retval = target_write_buffer(target, cfi_info->write_algorithm->address,
+ if ((retval = target_write_buffer(target, cfi_info->write_algorithm->address,
target_code_size, target_code)) != ERROR_OK)
{
free(target_code);
cfi_intel_clear_status_register(bank);
cfi_command(bank, 0x40, command);
- if((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
- if((retval = target_write_memory(target, address, bank->bus_width, 1, word)) != ERROR_OK)
+ if ((retval = target_write_memory(target, address, bank->bus_width, 1, word)) != ERROR_OK)
{
return retval;
}
if (cfi_intel_wait_status_busy(bank, 1000 * (1 << cfi_info->word_write_timeout_max)) != 0x80)
{
cfi_command(bank, 0xff, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
/* Initiate buffer operation _*/
cfi_command(bank, 0xE8, command);
- if((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
if (cfi_intel_wait_status_busy(bank, 1000 * (1 << cfi_info->buf_write_timeout_max)) != 0x80)
{
cfi_command(bank, 0xff, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
/* Write buffer wordcount-1 and data words */
cfi_command(bank, bufferwsize-1, command);
- if((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
- if((retval = target_write_memory(target, address, bank->bus_width, bufferwsize, word)) != ERROR_OK)
+ if ((retval = target_write_memory(target, address, bank->bus_width, bufferwsize, word)) != ERROR_OK)
{
return retval;
}
/* Commit write operation */
cfi_command(bank, 0xd0, command);
- if((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
if (cfi_intel_wait_status_busy(bank, 1000 * (1 << cfi_info->buf_write_timeout_max)) != 0x80)
{
cfi_command(bank, 0xff, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
uint8_t command[8];
cfi_command(bank, 0xaa, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0x55, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0xa0, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
- if((retval = target_write_memory(target, address, bank->bus_width, 1, word)) != ERROR_OK)
+ if ((retval = target_write_memory(target, address, bank->bus_width, 1, word)) != ERROR_OK)
{
return retval;
}
if (cfi_spansion_wait_status_busy(bank, 1000 * (1 << cfi_info->word_write_timeout_max)) != ERROR_OK)
{
cfi_command(bank, 0xf0, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
// Unlock
cfi_command(bank, 0xaa, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0x55, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
// Buffer load command
cfi_command(bank, 0x25, command);
- if((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
/* Write buffer wordcount-1 and data words */
cfi_command(bank, bufferwsize-1, command);
- if((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
- if((retval = target_write_memory(target, address, bank->bus_width, bufferwsize, word)) != ERROR_OK)
+ if ((retval = target_write_memory(target, address, bank->bus_width, bufferwsize, word)) != ERROR_OK)
{
return retval;
}
/* Commit write operation */
cfi_command(bank, 0x29, command);
- if((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, address, bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
if (cfi_spansion_wait_status_busy(bank, 1000 * (1 << cfi_info->word_write_timeout_max)) != ERROR_OK)
{
cfi_command(bank, 0xf0, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
for (i = 0; i < align; ++i, ++copy_p)
{
uint8_t byte;
- if((retval = target_read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK)
+ if ((retval = target_read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK)
{
return retval;
}
for (; (count == 0) && (i < bank->bus_width); ++i, ++copy_p)
{
uint8_t byte;
- if((retval = target_read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK)
+ if ((retval = target_read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK)
{
return retval;
}
/* return to read array mode, so we can read from flash again for padding */
cfi_command(bank, 0xf0, current_word);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, current_word)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, current_word)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0xff, current_word);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, current_word)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, current_word)) != ERROR_OK)
{
return retval;
}
for (; i < bank->bus_width; ++i, ++copy_p)
{
uint8_t byte;
- if((retval = target_read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK)
+ if ((retval = target_read_memory(target, copy_p, 1, 1, &byte)) != ERROR_OK)
{
return retval;
}
/* return to read array mode */
cfi_command(bank, 0xf0, current_word);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, current_word)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, current_word)) != ERROR_OK)
{
return retval;
}
/* switch to read identifier codes mode ("AUTOSELECT") */
cfi_command(bank, 0xaa, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, unlock1), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, unlock1), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0x55, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, unlock2), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, unlock2), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0x90, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, unlock1), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, unlock1), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
if (bank->chip_width == 1)
{
uint8_t manufacturer, device_id;
- if((retval = target_read_u8(target, flash_address(bank, 0, 0x00), &manufacturer)) != ERROR_OK)
+ if ((retval = target_read_u8(target, flash_address(bank, 0, 0x00), &manufacturer)) != ERROR_OK)
{
return retval;
}
- if((retval = target_read_u8(target, flash_address(bank, 0, 0x01), &device_id)) != ERROR_OK)
+ if ((retval = target_read_u8(target, flash_address(bank, 0, 0x01), &device_id)) != ERROR_OK)
{
return retval;
}
}
else if (bank->chip_width == 2)
{
- if((retval = target_read_u16(target, flash_address(bank, 0, 0x00), &cfi_info->manufacturer)) != ERROR_OK)
+ if ((retval = target_read_u16(target, flash_address(bank, 0, 0x00), &cfi_info->manufacturer)) != ERROR_OK)
{
return retval;
}
- if((retval = target_read_u16(target, flash_address(bank, 0, 0x02), &cfi_info->device_id)) != ERROR_OK)
+ if ((retval = target_read_u16(target, flash_address(bank, 0, 0x02), &cfi_info->device_id)) != ERROR_OK)
{
return retval;
}
LOG_INFO("Flash Manufacturer/Device: 0x%04x 0x%04x", cfi_info->manufacturer, cfi_info->device_id);
/* switch back to read array mode */
cfi_command(bank, 0xf0, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x00), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x00), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0xff, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x00), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x00), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
* SST flashes clearly violate this, and we will consider them incompatbile for now
*/
cfi_command(bank, 0x98, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x55), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x55), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
if ((cfi_info->qry[0] != 'Q') || (cfi_info->qry[1] != 'R') || (cfi_info->qry[2] != 'Y'))
{
cfi_command(bank, 0xf0, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0xff, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
* we use both reset commands, as some Intel flashes fail to recognize the 0xF0 command
*/
cfi_command(bank, 0xf0, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0xff, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x0), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
return ERROR_FLASH_OPERATION_FAILED;
cfi_command(bank, 0x90, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, 0x55), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, 0x55), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
int i;
cfi_command(bank, 0xaa, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0x55, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock2), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
cfi_command(bank, 0x90, command);
- if((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK)
+ if ((retval = target_write_memory(target, flash_address(bank, 0, pri_ext->_unlock1), bank->bus_width, 1, command)) != ERROR_OK)
{
return retval;
}
}
info = malloc(sizeof(ecosflash_flash_bank_t));
- if(info == NULL)
+ if (info == NULL)
{
LOG_ERROR("no memory for flash bank info");
exit(-1);
pattern = strtoul(args[1], NULL, 0);
count = strtoul(args[2], NULL, 0);
- if(count == 0)
+ if (count == 0)
return ERROR_OK;
switch(cmd[4])
cur_size = MIN( (count*wordsize - wrote), sizeof(chunk) );
flash_bank_t *bank;
bank = get_flash_bank_by_addr(target, address);
- if(bank == NULL)
+ if (bank == NULL)
{
return ERROR_FAIL;
}
return retval;
}
- if(err == ERROR_OK)
+ if (err == ERROR_OK)
{
float speed;
speed=wrote / 1024.0;
}
}
- if( first == -1 || last == -1 )
+ if ( first == -1 || last == -1 )
return ERROR_OK;
return flash_driver_erase(c, first, last);
/* write IAP code to working area */
target_buffer_set_u32(target, jump_gate, ARMV4_5_BX(12));
target_buffer_set_u32(target, jump_gate + 4, ARMV4_5_B(0xfffffe, 0));
- if((retval = target_write_memory(target, lpc2000_info->iap_working_area->address, 4, 2, jump_gate)) != ERROR_OK)
+ if ((retval = target_write_memory(target, lpc2000_info->iap_working_area->address, 4, 2, jump_gate)) != ERROR_OK)
{
return retval;
}
target_read_u32(target, F_STAT, &status);
}while (((status & FS_DONE) == 0) && timeout);
- if(timeout == 0)
+ if (timeout == 0)
{
LOG_DEBUG("Timedout!");
return ERROR_FLASH_OPERATION_FAILED;
if ((ret = target_read_u8(target, mg_task_reg + MG_REG_DRV_CTRL, &value)) != ERROR_OK)
return ret;
- if(on) {
+ if (on) {
value |= (mg_io_rbit_devc_srst);
} else {
value &= ~mg_io_rbit_devc_srst;
int i, NO;
for (i = 0, NO = 1; i < 2; ++i, output_div >>= 1)
- if(output_div & 1)
+ if (output_div & 1)
NO = NO << 1;
return NO;
LOG_DEBUG("status: 0x%" PRIx32, status );
alive_sleep(1);
}
- if(timeout <= 0)
+ if (timeout <= 0)
LOG_DEBUG("timeout: status: 0x%" PRIx32, status );
return status;
}
target_read_u32(target, PIC32MX_DEVCFG0, &devcfg0);
- if((devcfg0 & (1<<28)) == 0) /* code protect bit */
+ if ((devcfg0 & (1<<28)) == 0) /* code protect bit */
num_pages = 0xffff; /* All pages protected */
- else if(bank->base == PIC32MX_KSEG1_BOOT_FLASH)
+ else if (bank->base == PIC32MX_KSEG1_BOOT_FLASH)
{
- if(devcfg0 & (1<<24))
+ if (devcfg0 & (1<<24))
num_pages = 0; /* All pages unprotected */
else
num_pages = 0xffff; /* All pages protected */
{
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;
}
for (i = first; i <= last; i++)
{
- if(bank->base >= PIC32MX_KSEG1_PGM_FLASH)
+ if (bank->base >= PIC32MX_KSEG1_PGM_FLASH)
target_write_u32(target, PIC32MX_NVMADDR, KS1Virt2Phys(bank->base + bank->sectors[i].offset));
else
target_write_u32(target, PIC32MX_NVMADDR, KS0Virt2Phys(bank->base + bank->sectors[i].offset));
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;
{
target_t *target = bank->target;
- if(bank->base >= PIC32MX_KSEG1_PGM_FLASH)
+ if (bank->base >= PIC32MX_KSEG1_PGM_FLASH)
target_write_u32(target, PIC32MX_NVMADDR, KS1Virt2Phys(address));
else
target_write_u32(target, PIC32MX_NVMADDR, KS0Virt2Phys(address));
LOG_DEBUG("addr: 0x%08" PRIx32 " srcaddr: 0x%08" PRIx32 "", address, srcaddr);
- if(address >= PIC32MX_KSEG1_PGM_FLASH)
+ if (address >= PIC32MX_KSEG1_PGM_FLASH)
target_write_u32(target, PIC32MX_NVMADDR, KS1Virt2Phys(address));
else
target_write_u32(target, PIC32MX_NVMADDR, KS0Virt2Phys(address));
- if(srcaddr >= PIC32MX_KSEG1_RAM)
+ if (srcaddr >= PIC32MX_KSEG1_RAM)
target_write_u32(target, PIC32MX_NVMSRCADDR, KS1Virt2Phys(srcaddr));
else
target_write_u32(target, PIC32MX_NVMSRCADDR, KS0Virt2Phys(srcaddr));
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;
}
(unsigned)((device_id>>12)&0xff),
(unsigned)((device_id>>20)&0xfff) );
- if(((device_id>>1)&0x7ff) != PIC32MX_MANUF_ID) {
+ if (((device_id>>1)&0x7ff) != PIC32MX_MANUF_ID) {
LOG_WARNING( "Cannot identify target as a PIC32MX family." );
return ERROR_FLASH_OPERATION_FAILED;
}
page_size = 4096;
- if(bank->base == PIC32MX_KSEG1_BOOT_FLASH || bank->base == 1) {
+ if (bank->base == PIC32MX_KSEG1_BOOT_FLASH || bank->base == 1) {
/* 0xBFC00000: Boot flash size fixed at 12k */
num_pages = 12;
} else {
/* 0xBD000000: Program flash size varies with device */
for(i=0; pic32mx_devs[i].name != NULL; i++)
- if(pic32mx_devs[i].devid == ((device_id >> 12) & 0xff)) {
+ if (pic32mx_devs[i].devid == ((device_id >> 12) & 0xff)) {
num_pages = pic32mx_devs[i].pfm_size;
break;
}
- if(pic32mx_devs[i].name == NULL) {
+ if (pic32mx_devs[i].name == NULL) {
LOG_WARNING( "Cannot identify target as a PIC32MX family." );
return ERROR_FLASH_OPERATION_FAILED;
}
/* calculate numbers of pages */
num_pages /= (page_size / 1024);
- if(bank->base == 0) bank->base = PIC32MX_KSEG1_PGM_FLASH;
- if(bank->base == 1) bank->base = PIC32MX_KSEG1_BOOT_FLASH;
+ if (bank->base == 0) bank->base = PIC32MX_KSEG1_PGM_FLASH;
+ if (bank->base == 1) bank->base = PIC32MX_KSEG1_BOOT_FLASH;
bank->size = (num_pages * page_size);
bank->num_sectors = num_pages;
bank->chip_width = 4;
device_id = ejtag_info->idcode;
- if(((device_id>>1)&0x7ff) != PIC32MX_MANUF_ID) {
+ if (((device_id>>1)&0x7ff) != PIC32MX_MANUF_ID) {
snprintf(buf, buf_size,
"Cannot identify target as a PIC32MX family (manufacturer 0x%03d != 0x%03d)\n",
(unsigned)((device_id>>1)&0x7ff),
return ERROR_FLASH_OPERATION_FAILED;
}
for(i=0; pic32mx_devs[i].name != NULL; i++)
- if(pic32mx_devs[i].devid == ((device_id >> 12) & 0xff)) {
+ if (pic32mx_devs[i].devid == ((device_id >> 12) & 0xff)) {
printed = snprintf(buf, buf_size, "PIC32MX%s", pic32mx_devs[i].name);
break;
}
- if(pic32mx_devs[i].name == NULL) {
+ if (pic32mx_devs[i].name == NULL) {
snprintf(buf, buf_size, "Cannot identify target as a PIC32MX family\n");
return ERROR_FLASH_OPERATION_FAILED;
}
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)
did0, did1, stellaris_info->dc0, stellaris_info->dc1);
ver = did0 >> 28;
- if((ver != 0) && (ver != 1))
+ if ((ver != 0) && (ver != 1))
{
LOG_WARNING("Unknown did0 version, cannot identify target");
return ERROR_FLASH_OPERATION_FAILED;
ver = did1 >> 28;
fam = (did1 >> 24) & 0xF;
- if(((ver != 0) && (ver != 1)) || (fam != 0))
+ if (((ver != 0) && (ver != 1)) || (fam != 0))
{
LOG_WARNING("Unknown did1 version/family, cannot positively identify target as a Stellaris");
}
/* Check acess violations */
target_read_u32(target, FLASH_CRIS, &flash_cris);
- if(flash_cris & (AMASK))
+ if (flash_cris & (AMASK))
{
LOG_WARNING("Error erasing flash page %i, flash_cris 0x%" PRIx32 "", banknr, flash_cris);
target_write_u32(target, FLASH_CRIS, 0);
/* Check acess violations */
target_read_u32(target, FLASH_CRIS, &flash_cris);
- if(flash_cris & (AMASK))
+ if (flash_cris & (AMASK))
{
LOG_WARNING("Error setting flash page protection, flash_cris 0x%" PRIx32 "", flash_cris);
target_write_u32(target, FLASH_CRIS, 0);
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);
{
set = 1;
- if( protection & (1 << i))
+ if ( protection & (1 << i))
set = 0;
for (s = 0; s < stm32x_info->ppage_size; s++)
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;
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;
{
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);
}
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;
}
/* 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);
void command_output_text(command_context_t *context, const char *data)
{
- if( context && context->output_handler && data ){
+ if ( context && context->output_handler && data ){
context->output_handler( context, data );
}
}
static inline int fileio_local_fgets(fileio_t *fileio, uint32_t size, char *buffer)
{
- if( fgets(buffer, size, fileio->file) == NULL)
+ if ( fgets(buffer, size, fileio->file) == NULL)
return ERROR_FILEIO_OPERATION_FAILED;
return ERROR_OK;
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 );
}
#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 );
buf = jim_vasprintf( fmt, ap );
va_end(ap);
- if( buf ){
+ 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 ){
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 ){
+ 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 ){
+ 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 ){
+ if ( haveprec ){
sprintf( cp, "%d", prec );
}
cp = strchr(cp,0);
case 'E':
*cp++ = *fmt;
*cp = 0;
- if( Jim_GetDouble( interp, objv[0], &doubleValue ) == JIM_ERR ){
+ if ( Jim_GetDouble( interp, objv[0], &doubleValue ) == JIM_ERR ){
Jim_FreeNewObj( interp, resObjPtr );
return NULL;
}
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 {
int e;
e = Jim_Nvp_name2value_obj( interp, nvp_table, objPtr, &n );
- if( e == JIM_ERR ){
+ if ( e == JIM_ERR ){
return e;
}
/* Success? found? */
- if( n->name ){
+ if ( n->name ){
/* remove const */
*result = (Jim_Nvp *)n;
return JIM_OK;
{
DIR *dir = 0;
- if(name && name[0]) {
+ if (name && name[0]) {
size_t base_length = strlen(name);
const char *all = /* search pattern must end with suitable wildcard */
strchr("/\\", name[base_length - 1]) ? "*" : "/*";
- if((dir = (DIR *) Jim_Alloc(sizeof *dir)) != 0 &&
+ if ((dir = (DIR *) Jim_Alloc(sizeof *dir)) != 0 &&
(dir->name = (char *) Jim_Alloc(base_length + strlen(all) + 1)) != 0)
{
strcat(strcpy(dir->name, name), all);
- if((dir->handle = (long) _findfirst(dir->name, &dir->info)) != -1)
+ if ((dir->handle = (long) _findfirst(dir->name, &dir->info)) != -1)
dir->result.d_name = 0;
else { /* rollback */
Jim_Free(dir->name);
{
int result = -1;
- if(dir) {
- if(dir->handle != -1)
+ if (dir) {
+ if (dir->handle != -1)
result = _findclose(dir->handle);
Jim_Free(dir->name);
Jim_Free(dir);
}
- if(result == -1) /* map all errors to EBADF */
+ if (result == -1) /* map all errors to EBADF */
errno = EBADF;
return result;
}
{
struct dirent *result = 0;
- if(dir && dir->handle != -1) {
- if(!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1) {
+ if (dir && dir->handle != -1) {
+ if (!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1) {
result = &dir->result;
result->d_name = dir->info.name;
}
Jim_IncrRefCount(scriptObjPtr);
- if( filename ){
+ if ( filename ){
JimSetSourceInfo( interp, scriptObjPtr, filename, lineno );
}
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;
}
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;
}
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;
}
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;
}
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;
}
Jim_Nvp_name2value_simple( const Jim_Nvp *p, const char *name )
{
while( p->name ){
- if( 0 == strcmp( name, p->name ) ){
+ if ( 0 == strcmp( name, p->name ) ){
break;
}
p++;
Jim_Nvp_name2value_nocase_simple( const Jim_Nvp *p, const char *name )
{
while( p->name ){
- if( 0 == strcasecmp( name, p->name ) ){
+ if ( 0 == strcasecmp( name, p->name ) ){
break;
}
p++;
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;
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;
jim_wide w;
e = Jim_GetWide( interp, o, &w );
- if( e != JIM_OK ){
+ if ( e != JIM_OK ){
return e;
}
Jim_Nvp_value2name_simple( const Jim_Nvp *p, int value )
{
while( p->name ){
- if( value == p->value ){
+ if ( value == p->value ){
break;
}
p++;
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;
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;
r = Jim_GetOpt_Obj( goi, &o );
- if( r == JIM_OK ){
+ if ( r == JIM_OK ){
cp = Jim_GetString( o, len );
- if( puthere ){
+ if ( puthere ){
/* remove const */
*puthere = (char *)(cp);
}
Jim_Obj *o;
double _safe;
- if( puthere == NULL ){
+ if ( puthere == NULL ){
puthere = &_safe;
}
r = Jim_GetOpt_Obj( goi, &o );
- if( r == JIM_OK ){
+ if ( r == JIM_OK ){
r = Jim_GetDouble( goi->interp, o, puthere );
- if( r != JIM_OK ){
+ if ( r != JIM_OK ){
Jim_SetResult_sprintf( goi->interp,
"not a number: %s",
Jim_GetString( o, NULL ) );
Jim_Obj *o;
jim_wide _safe;
- if( puthere == NULL ){
+ if ( puthere == NULL ){
puthere = &_safe;
}
r = Jim_GetOpt_Obj( goi, &o );
- if( r == JIM_OK ){
+ 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 ){
+ if ( e == JIM_OK ){
e = Jim_Nvp_name2value_obj( goi->interp,
nvp,
o,
const Jim_Nvp *nvptable,
int hadprefix )
{
- if( hadprefix ){
+ if ( hadprefix ){
Jim_SetResult_NvpUnknown( goi->interp,
goi->argv[-2],
goi->argv[-1],
Jim_Obj *o;
int e;
- if( puthere == NULL ){
+ if ( puthere == NULL ){
puthere = &_safe;
}
e = Jim_GetOpt_Obj( goi, &o );
- if( e == JIM_OK ){
+ if ( e == JIM_OK ){
e = Jim_GetEnum( goi->interp,
o,
lookup,
va_start(ap,fmt);
buf = jim_vasprintf( fmt, ap );
va_end(ap);
- if( buf ){
+ if ( buf ){
Jim_SetResultString( interp, buf, -1 );
jim_vasprintf_done(buf);
}
Jim_Obj *param_value,
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 ),
const char *a;
const char *b;
- if( (nvp+1)->name ){
+ if ( (nvp+1)->name ){
a = nvp->name;
b = ", ";
} else {
{
int x;
- if( debug_string_obj ){
+ if ( debug_string_obj ){
Jim_FreeObj( interp, debug_string_obj );
}
*
* while( goi.argc ){
* e = Jim_GetOpt_Nvp( &goi, nvp_options, &n );
- * if( e != JIM_OK ){
+ * if ( e != JIM_OK ){
* Jim_GetOpt_NvpUnknown( &goi, nvp_options, 0 );
* return e;
* }
* 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 );
* break;
* case POLITICS:
* e = Jim_GetOpt_Nvp( &goi, nvp_politics, &n );
- * if( e != JIM_OK ){
+ * if ( e != JIM_OK ){
* Jim_GetOpt_NvpUnknown( &goi, nvp_politics, 1 );
* return e;
* }
* while( goi.argc ){
* // Get the next option
* e = Jim_GetOpt_Nvp( &goi, cmd_options, &n );
- * if( e != JIM_OK ){
+ * if ( e != JIM_OK ){
* // option was not recognized
* // pass 'hadprefix=0' because there is no prefix
* Jim_GetOpt_NvpUnknown( &goi, cmd_options, 0 );
* case OPT_SEX:
* // handle: --sex male|female|lots|needmore
* e = Jim_GetOpt_Nvp( &goi, &nvp_sex, &n );
- * if( e != JIM_OK ){
+ * if ( e != JIM_OK ){
* Jim_GetOpt_NvpUnknown( &ogi, nvp_sex, 1 );
* return e;
* }
#endif
string);
}
- else if(server_use_pipes == 0)
+ else if (server_use_pipes == 0)
{
/* if we are using gdb through pipes then we do not want any output
* to the pipe otherwise we get repeated strings */
*strrchr(strExePath, '\\')=0;
strcat(strExePath, "/../lib/"PACKAGE);
for(p=strExePath; *p; p++) {
- if(*p == '\\')
+ if (*p == '\\')
*p = '/';
}
add_script_search_dir(strExePath);
usb_out_buffer[0] = CMD_GET_TCK_FREQUENCY;
result = armjtagew_usb_message(armjtagew_jtag_handle, 1, 4);
speed_real = (int)buf_get_u32(usb_in_buffer,0,32);
- if(result < 0)
+ if (result < 0)
{
LOG_ERROR("ARM-JTAG-EW getting speed failed (%d)", result);
return ERROR_JTAG_DEVICE_ERROR;
int stat;
stat = (int)buf_get_u32(usb_in_buffer + byte_length, 0, 32);
- if(stat) {
+ if (stat) {
LOG_ERROR("armjtagew_tap_execute, emulator returned error code %d for a CMD_TAP_SHIFT command", stat);
return ERROR_JTAG_QUEUE_FAILED;
}
*/
retval = ERROR_OK;
- if(bitbang_interface->blink)
+ if (bitbang_interface->blink)
bitbang_interface->blink(1);
while (cmd)
}
cmd = cmd->next;
}
- if(bitbang_interface->blink)
+ if (bitbang_interface->blink)
bitbang_interface->blink(0);
return retval;
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
+ else if ( tap_state_transition(cur_state, true) == goal_state
|| tap_state_transition(cur_state, false) == goal_state )
{
jtag_add_pathmove(1, &goal_state);
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_ERROR("JTAG interface has to be specified, see \"interface\" command");
return ERROR_JTAG_INVALID_INTERFACE;
}
- if(hasKHz)
+ if (hasKHz)
{
jtag_interface->khz(jtag_get_speed_khz(), &jtag_speed);
hasKHz = false;
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;
}
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 );
- 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) );
#if defined(DEBUG)
- if(dummy_state == TAP_DRCAPTURE)
+ if (dummy_state == TAP_DRCAPTURE)
dummy_data = 0x01255043;
#endif
}
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;
}
}
va_list ap;
int usb_ret;
- if(length > sizeof(usb_buffer)) {
+ if (length > sizeof(usb_buffer)) {
length = sizeof(usb_buffer);
}
count = 0;
while(remain) {
- if(remain > sizeof(usb_buffer)) {
+ if (remain > sizeof(usb_buffer)) {
length = sizeof(usb_buffer);
} else {
length = remain;
USB_TIMEOUT_MS
);
- if(usb_ret < sizeof(usb_buffer)) {
+ if (usb_ret < sizeof(usb_buffer)) {
break;
}
USB_TIMEOUT_MS
);
- if(usb_ret < length) {
+ if (usb_ret < length) {
break;
}
count = 0;
while(remain) {
- if(remain > (sizeof(usb_buffer) - 4)) {
+ if (remain > (sizeof(usb_buffer) - 4)) {
length = (sizeof(usb_buffer) - 4);
} else {
length = remain;
USB_TIMEOUT_MS
);
- if((size_t)usb_ret < sizeof(usb_buffer)) {
+ if ((size_t)usb_ret < sizeof(usb_buffer)) {
break;
}
va_list ap;
size_t remain;
- if(length > sizeof(buffer)) {
+ if (length > sizeof(buffer)) {
length = sizeof(buffer);
}
pHDev, 1,
EP1_CMD_DTC_STOP
);
- if(usb_err < 0) return(usb_err);
+ if (usb_err < 0) return(usb_err);
while(length) {
- if(length < sizeof(*header)) {
+ if (length < sizeof(*header)) {
LOG_ERROR("Malformed DTC image\n");
exit(1);
}
buffer += sizeof(*header);
length -= sizeof(*header);
- if(length < (size_t)header->length + 1) {
+ if (length < (size_t)header->length + 1) {
LOG_ERROR("Malformed DTC image\n");
exit(1);
}
case DTCLOAD_ENTRY:
/* store entry addresses somewhere */
- if(!strncmp("download", (char *)buffer + 1, 8)) {
+ if (!strncmp("download", (char *)buffer + 1, 8)) {
dtc_entry_download = buffer[0];
}
break;
DTC_LOAD_BUFFER,
header->length + 1, buffer
);
- if(usb_err < 0) return(usb_err);
+ if (usb_err < 0) return(usb_err);
/* Load it into the DTC. */
usb_err = ep1_generic_commandl(
(DTC_LOAD_BUFFER >> 8),
DTC_LOAD_BUFFER
);
- if(usb_err < 0) return(usb_err);
+ if (usb_err < 0) return(usb_err);
break;
buffer[0],
EP1_CMD_DTC_WAIT
);
- if(usb_err < 0) return(usb_err);
+ if (usb_err < 0) return(usb_err);
break;
ST7_USB_BUF_EP0OUT + lut_start,
header->length + 1, buffer
);
- if(usb_err < 0) return(usb_err);
+ if (usb_err < 0) return(usb_err);
break;
default:
ST7_EP2TXR,
1
);
- if(usb_err < 0) return(usb_err);
+ if (usb_err < 0) return(usb_err);
/* read back ep2txr */
usb_err = usb_bulk_read(
(char *)&ep2txr, 1,
USB_TIMEOUT_MS
);
- if(usb_err < 0) return(usb_err);
+ if (usb_err < 0) return(usb_err);
usb_err = ep1_generic_commandl(
pHDev, 13,
dtc_entry_download,
EP1_CMD_DTC_GET_CACHED_STATUS
);
- if(usb_err < 0) return(usb_err);
+ if (usb_err < 0) return(usb_err);
/* wait for completion */
usb_err = usb_bulk_read(
(char *)command_buffer, USB_EP2BANK_SIZE,
USB_TIMEOUT_MS
);
- if(usb_err < 0) return(usb_err);
+ if (usb_err < 0) return(usb_err);
/* Wait for DTC to finish running command buffer */
DTC_STATUS_POLL_BYTE,
1
);
- if(usb_err < 0) return(usb_err);
+ if (usb_err < 0) return(usb_err);
usb_err = usb_bulk_read(
pHDev,
(char *)ep2_buffer, 1,
USB_TIMEOUT_MS
);
- if(usb_err < 0) return(usb_err);
+ if (usb_err < 0) return(usb_err);
- if(ep2_buffer[0] & 0x01) break;
+ if (ep2_buffer[0] & 0x01) break;
- if(!--i) {
+ if (!--i) {
LOG_ERROR("%s, %d: too many retries waiting for DTC status\n",
__FILE__, __LINE__
);
}
- if(!reply_buffer) reply_buffer_size = 0;
- if(reply_buffer_size) {
+ if (!reply_buffer) reply_buffer_size = 0;
+ if (reply_buffer_size) {
usb_err = usb_bulk_read(
pHDev,
USB_EP2IN_ADDR,
USB_TIMEOUT_MS
);
- if(usb_err < (int)sizeof(ep2_buffer)) {
+ if (usb_err < (int)sizeof(ep2_buffer)) {
LOG_ERROR("%s, %d: Read of endpoint 2 returned %d\n",
__FILE__, __LINE__, usb_err
);
dtc_reply_queue_entry_t *rq_entry;
rq_entry = malloc(sizeof(dtc_reply_queue_entry_t));
- if(rq_entry != NULL) {
+ if (rq_entry != NULL) {
rq_entry->scan.type = type;
rq_entry->scan.buffer = buffer;
rq_entry->scan.size = size;
rq_entry->cmd = cmd;
rq_entry->next = NULL;
- if(dtc_queue.rq_head == NULL)
+ if (dtc_queue.rq_head == NULL)
dtc_queue.rq_head = rq_entry;
else
dtc_queue.rq_tail->next = rq_entry;
retval = ERROR_OK;
- if(dtc_queue.cmd_index < 1) return(retval);
+ if (dtc_queue.cmd_index < 1) return(retval);
dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = DTC_CMD_STOP;
/* run the cmd */
- if(dtc_queue.rq_head == NULL) {
+ if (dtc_queue.rq_head == NULL) {
usb_err = dtc_run_download(pHDev,
dtc_queue.cmd_buffer, dtc_queue.cmd_index,
NULL, 0
);
- if(usb_err < 0) {
+ if (usb_err < 0) {
LOG_ERROR("dtc_run_download: %s\n", usb_strerror());
exit(1);
}
dtc_queue.cmd_buffer, dtc_queue.cmd_index,
reply_buffer, dtc_queue.reply_index
);
- if(usb_err < 0) {
+ if (usb_err < 0) {
LOG_ERROR("dtc_run_download: %s\n", usb_strerror());
exit(1);
} else {
bit_cnt = rq_p->scan.length;
- if(bit_cnt >= 8) {
+ if (bit_cnt >= 8) {
/* bytes */
dtc_mask = 1 << (8 - 1);
bit_cnt;
bit_cnt--
) {
- if(*dtc_p & dtc_mask) {
+ if (*dtc_p & dtc_mask) {
*tdo_p |= tdo_mask;
} else {
*tdo_p &=~ tdo_mask;
}
dtc_mask >>= 1;
- if(dtc_mask == 0) {
+ if (dtc_mask == 0) {
dtc_p++;
dtc_mask = 1 << (8 - 1);
}
tdo_mask <<= 1;
- if(tdo_mask == 0) {
+ if (tdo_mask == 0) {
tdo_p++;
tdo_mask = 1;
}
/* extra bits or last bit */
x = *dtc_p++;
- if((
+ if ((
rq_p->scan.type == SCAN_IN
) && (
rq_p->scan.offset != rq_p->scan.size - 1
bit_cnt;
bit_cnt--
) {
- if(x & dtc_mask) {
+ if (x & dtc_mask) {
*tdo_p |= tdo_mask;
} else {
*tdo_p &=~ tdo_mask;
dtc_mask >>= 1;
tdo_mask <<= 1;
- if(tdo_mask == 0) {
+ if (tdo_mask == 0) {
tdo_p++;
tdo_mask = 1;
}
}
}
- if((rq_p->scan.offset + rq_p->scan.length) >= rq_p->scan.size) {
+ if ((rq_p->scan.offset + rq_p->scan.length) >= rq_p->scan.size) {
/* feed scan buffer back into openocd and free it */
- if(jtag_read_buffer(rq_p->scan.buffer, rq_p->cmd->cmd.scan) != ERROR_OK) {
+ if (jtag_read_buffer(rq_p->scan.buffer, rq_p->cmd->cmd.scan) != ERROR_OK) {
retval = ERROR_JTAG_QUEUE_FAILED;
}
free(rq_p->scan.buffer);
int retval;
retval = 0;
- if(!tap_state_queue.length) return(retval);
+ if (!tap_state_queue.length) return(retval);
bits = 1;
byte = 0;
for(i = tap_state_queue.length; i--;) {
byte <<= 1;
- if(tap_state_queue.buffer & 1) {
+ if (tap_state_queue.buffer & 1) {
byte |= 1;
}
- if((bits >= 8) || !i) {
+ if ((bits >= 8) || !i) {
byte <<= (8 - bits);
/* 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))) {
+ if (dtc_queue.cmd_index >= (sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1))) {
dtc_queue.cmd_buffer[dtc_queue.cmd_index++] =
DTC_CMD_STOP;
dtc_queue_run();
}
#ifdef USE_HARDWARE_SHIFTER_FOR_TMS
- if(bits == 8) {
+ if (bits == 8) {
dtc_queue.cmd_buffer[dtc_queue.cmd_index++] =
DTC_CMD_SHIFT_TMS_BYTES(1);
} else {
) {
int retval;
- if(tap_state_queue.length >= sizeof(tap_state_queue.buffer) * 8) {
+ if (tap_state_queue.length >= sizeof(tap_state_queue.buffer) * 8) {
retval = tap_state_queue_run();
- if(retval != 0) return(retval);
+ if (retval != 0) return(retval);
}
- if(tms) {
+ if (tms) {
tap_state_queue.buffer |= (1 << tap_state_queue.length);
}
tap_state_queue.length++;
ST7_PADR,
1
);
- if(usb_err < 0) {
+ if (usb_err < 0) {
LOG_ERROR("%s", usb_strerror());
exit(1);
}
(char *)&bitmap, 1,
USB_TIMEOUT_MS
);
- if(usb_err < 1) {
+ if (usb_err < 1) {
LOG_ERROR("%s", usb_strerror());
exit(1);
}
- if(trst) {
+ if (trst) {
bitmap &= ~ST7_PA_NTRST;
} else {
bitmap |= ST7_PA_NTRST;
ST7_PBDDR,
1
);
- if(usb_err < 0) {
+ if (usb_err < 0) {
LOG_ERROR("%s", usb_strerror());
exit(1);
}
(char *)&bitmap, 1,
USB_TIMEOUT_MS
);
- if(usb_err < 1) {
+ if (usb_err < 1) {
LOG_ERROR("%s", usb_strerror());
exit(1);
}
- if(srst) {
+ if (srst) {
bitmap |= ST7_PB_NSRST;
} else {
bitmap &= ~ST7_PB_NSRST;
bitmap,
EP1_CMD_DTC_GET_CACHED_STATUS
);
- if(usb_err < 0) {
+ if (usb_err < 0) {
LOG_ERROR("%s", usb_strerror());
exit(1);
}
(char *)&bitmap, 1,
USB_TIMEOUT_MS
);
- if(usb_err < 1) {
+ if (usb_err < 1) {
LOG_ERROR("%s", usb_strerror());
exit(1);
}
uint8_t tdi_mask, *tdi_p;
uint8_t dtc_mask;
- if(scan_size < 1) {
+ if (scan_size < 1) {
LOG_ERROR("scan_size cannot be less than 1 bit\n");
exit(1);
}
tdi_p = buffer;
tdi_mask = 1;
- if(extra_bits && (type == SCAN_OUT)) {
+ if (extra_bits && (type == SCAN_OUT)) {
/* Schedule any extra bits into the DTC command buffer, padding as needed */
/* For SCAN_OUT, this comes before the full bytes so the (leading) padding bits will fall off the end */
/* make sure there's room for stop, byte op, and one byte */
- if(
+ if (
(dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1))
) {
dtc_queue_run();
dtc_mask = 1 << (extra_bits - 1);
while(extra_bits--) {
- if(*tdi_p & tdi_mask) {
+ if (*tdi_p & tdi_mask) {
x |= dtc_mask;
}
dtc_mask >>= 1;
tdi_mask <<= 1;
- if(tdi_mask == 0) {
+ if (tdi_mask == 0) {
tdi_p++;
tdi_mask = 1;
}
/* Loop scheduling full bytes into the DTC command buffer */
while(byte_bits) {
- if(type == SCAN_IN) {
+ if (type == SCAN_IN) {
/* make sure there's room for stop and byte op */
x = (dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1));
} else {
x = (dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1));
}
- if(type != SCAN_OUT) {
+ if (type != SCAN_OUT) {
/* make sure there's room for at least one reply byte */
x |= (dtc_queue.reply_index >= USB_EP2IN_SIZE - (1));
}
- if(x) {
+ if (x) {
dtc_queue_run();
}
chunk_bits = byte_bits;
/* we can only use up to 16 bytes at a time */
- if(chunk_bits > (16 * 8)) chunk_bits = (16 * 8);
+ if (chunk_bits > (16 * 8)) chunk_bits = (16 * 8);
- if(type != SCAN_IN) {
+ if (type != SCAN_IN) {
/* how much is there room for, considering stop and byte op? */
x = (sizeof(dtc_queue.cmd_buffer) - (dtc_queue.cmd_index + 1 + 1)) * 8;
- if(chunk_bits > x) chunk_bits = x;
+ if (chunk_bits > x) chunk_bits = x;
}
- if(type != SCAN_OUT) {
+ if (type != SCAN_OUT) {
/* how much is there room for in the reply buffer? */
x = (USB_EP2IN_SIZE - dtc_queue.reply_index) * 8;
- if(chunk_bits > x) chunk_bits = x;
+ if (chunk_bits > x) chunk_bits = x;
}
/* so the loop will end */
byte_bits -= chunk_bits;
- if(type != SCAN_OUT) {
- if(dtc_queue_enqueue_reply(
+ if (type != SCAN_OUT) {
+ if (dtc_queue_enqueue_reply(
type, buffer, scan_size, tdi_bit_offset,
chunk_bits,
cmd
}
dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = x;
- if(type != SCAN_IN) {
+ if (type != SCAN_IN) {
x = 0;
dtc_mask = 1 << (8 - 1);
while(chunk_bits--) {
- if(*tdi_p & tdi_mask) {
+ if (*tdi_p & tdi_mask) {
x |= dtc_mask;
}
dtc_mask >>= 1;
- if(dtc_mask == 0) {
+ if (dtc_mask == 0) {
dtc_queue.cmd_buffer[dtc_queue.cmd_index++] = x;
dtc_queue.reply_index++;
x = 0;
}
tdi_mask <<= 1;
- if(tdi_mask == 0) {
+ if (tdi_mask == 0) {
tdi_p++;
tdi_mask = 1;
}
}
}
- if(extra_bits && (type != SCAN_OUT)) {
+ if (extra_bits && (type != SCAN_OUT)) {
/* Schedule any extra bits into the DTC command buffer */
/* make sure there's room for stop, byte op, and one byte */
- if(
+ if (
(dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1 + 1))
||
(dtc_queue.reply_index >= USB_EP2IN_SIZE - (1))
dtc_queue_run();
}
- if(dtc_queue_enqueue_reply(
+ if (dtc_queue_enqueue_reply(
type, buffer, scan_size, tdi_bit_offset,
extra_bits,
cmd
tdi_bit_offset += extra_bits;
- if(type == SCAN_IN) {
+ if (type == SCAN_IN) {
dtc_queue.cmd_buffer[dtc_queue.cmd_index++] =
DTC_CMD_SHIFT_TDO_BYTES(1);
dtc_mask = 1 << (8 - 1);
while(extra_bits--) {
- if(*tdi_p & tdi_mask) {
+ if (*tdi_p & tdi_mask) {
x |= dtc_mask;
}
dtc_mask >>= 1;
tdi_mask <<= 1;
- if(tdi_mask == 0) {
+ if (tdi_mask == 0) {
tdi_p++;
tdi_mask = 1;
}
/* Schedule the last bit into the DTC command buffer */
{
/* make sure there's room for stop, and bit pair command */
- if(
+ if (
(dtc_queue.cmd_index >= sizeof(dtc_queue.cmd_buffer) - (1 + 1))
||
(dtc_queue.reply_index >= USB_EP2IN_SIZE - (1))
dtc_queue_run();
}
- if(type == SCAN_OUT) {
+ if (type == SCAN_OUT) {
dtc_queue.cmd_buffer[dtc_queue.cmd_index++] =
DTC_CMD_SHIFT_TMS_TDI_BIT_PAIR(1, (*tdi_p & tdi_mask), 0);
} else {
- if(dtc_queue_enqueue_reply(
+ if (dtc_queue_enqueue_reply(
type, buffer, scan_size, tdi_bit_offset,
1,
cmd
rlink_end_state(cmd->cmd.scan->end_state);
scan_size = jtag_build_buffer(cmd->cmd.scan, &buffer);
type = jtag_scan_type(cmd->cmd.scan);
- if(rlink_scan(cmd, type, buffer, scan_size) != ERROR_OK) {
+ if (rlink_scan(cmd, type, buffer, scan_size) != ERROR_OK) {
retval = ERROR_FAIL;
}
break;
/* Flush the DTC queue to make sure any pending reads have been done before exiting this function */
tap_state_queue_run();
tmp_retval = dtc_queue_run();
- if(tmp_retval != ERROR_OK) {
+ if (tmp_retval != ERROR_OK) {
retval = tmp_retval;
}
{
int i;
- if(speed == 0) {
+ if (speed == 0) {
/* fastest speed */
speed = rlink_speed_table[rlink_speed_table_size - 1].prescaler;
}
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) {
+ 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);
exit(1);
}
- if(dtc_start_download() < 0) {
+ if (dtc_start_download() < 0) {
LOG_ERROR("%s, %d: starting DTC: %s",
__FILE__, __LINE__,
usb_strerror()
int i;
for(i = rlink_speed_table_size; i--; ) {
- if(rlink_speed_table[i].prescaler == speed) {
+ if (rlink_speed_table[i].prescaler == speed) {
*khz = rlink_speed_table[i].khz;
return(ERROR_OK);
}
) {
int i;
- if(khz == 0) {
+ if (khz == 0) {
LOG_ERROR("RCLK not supported");
return ERROR_FAIL;
}
for(i = rlink_speed_table_size; i--; ) {
- if(rlink_speed_table[i].khz <= khz) {
+ if (rlink_speed_table[i].khz <= khz) {
*speed = rlink_speed_table[i].prescaler;
return(ERROR_OK);
}
char **args,
int argc
) {
- if(argc != 1) {
+ if (argc != 1) {
LOG_ERROR("expected exactly one argument to rlink_dtc_directory <directory-path>");
return(ERROR_INVALID_ARGUMENTS);
}
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
{
do
{
i = usb_claim_interface(pHDev,0);
- if(i)
+ if (i)
{
LOG_ERROR("usb_claim_interface: %s", usb_strerror());
#ifdef LIBUSB_HAS_DETACH_KERNEL_DRIVER_NP
j = usb_detach_kernel_driver_np(pHDev, 0);
- if(j)
+ if (j)
LOG_ERROR("detach kernel driver: %s", usb_strerror());
#endif
}
}
} while(--retries);
- if(!i)
+ 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);
pHDev, 1,
EP1_CMD_GET_FWREV
);
- if(j < USB_EP1OUT_SIZE) {
+ if (j < USB_EP1OUT_SIZE) {
LOG_ERROR("USB write error: %s", usb_strerror());
return(ERROR_FAIL);
}
(char *)reply_buffer, sizeof(reply_buffer),
200
);
- if(j != -ETIMEDOUT) break;
+ if (j != -ETIMEDOUT) break;
}
- if(j < (int)sizeof(reply_buffer)) {
+ if (j < (int)sizeof(reply_buffer)) {
LOG_ERROR("USB read error: %s", usb_strerror());
return(ERROR_FAIL);
}
LOG_DEBUG(INTERFACE_NAME" firmware version: %d.%d.%d\n", reply_buffer[0], reply_buffer[1], reply_buffer[2]);
- if((reply_buffer[0] != 0) || (reply_buffer[1] != 0) || (reply_buffer[2] != 3)) {
+ if ((reply_buffer[0] != 0) || (reply_buffer[1] != 0) || (reply_buffer[2] != 3)) {
LOG_WARNING("The rlink device is not of the version that the developers have played with. It may or may not work.\n");
}
USB_TIMEOUT_MS
);
- if((reply_buffer[0] & ST7_PE_ADAPTER_SENSE_IN) != 0) {
+ if ((reply_buffer[0] & ST7_PE_ADAPTER_SENSE_IN) != 0) {
LOG_WARNING("target detection problem\n");
}
);
- if((reply_buffer[0] & ST7_PE_ADAPTER_SENSE_IN) == 0) {
+ if ((reply_buffer[0] & ST7_PE_ADAPTER_SENSE_IN) == 0) {
LOG_WARNING("target not plugged in\n");
}
/*
* 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;
}
while( goi->argc ){
e = Jim_GetOpt_Nvp( goi, opts, &n );
- if( e != JIM_OK ){
+ if ( e != JIM_OK ){
Jim_GetOpt_NvpUnknown( goi, opts, 0 );
return e;
}
uint32_t *new_expected_ids;
e = Jim_GetOpt_Wide( goi, &w );
- if( e != JIM_OK) {
+ if ( e != JIM_OK) {
Jim_SetResult_sprintf(goi->interp, "option: %s bad parameter", n->name);
return e;
}
case NTAP_OPT_IRMASK:
case NTAP_OPT_IRCAPTURE:
e = Jim_GetOpt_Wide( goi, &w );
- if( e != JIM_OK ){
+ if ( e != JIM_OK ){
Jim_SetResult_sprintf( goi->interp, "option: %s bad parameter", n->name );
return e;
}
Jim_GetOpt_Setup( &goi, interp, argc-1, argv+1 );
e = Jim_GetOpt_Nvp( &goi, jtag_cmds, &n );
- if( e != JIM_OK ){
+ if ( e != JIM_OK ){
Jim_GetOpt_NvpUnknown( &goi, jtag_cmds, 0 );
return e;
}
/* 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 );
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;
}
case JTAG_CMD_TAPISENABLED:
case JTAG_CMD_TAPENABLE:
case JTAG_CMD_TAPDISABLE:
- if( goi.argc != 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;
}
Jim_GetOpt_Obj(&goi, &o);
t = jtag_tap_by_jim_obj( goi.interp, o );
- if( t == NULL ){
+ 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;
}
Jim_GetOpt_Obj(&goi, &o);
t = jtag_tap_by_jim_obj( goi.interp, o );
- if( t == NULL ){
+ 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;
}
Jim_GetString( newargs[9], NULL ) );
e = jim_jtag_command( interp, 10, newargs );
- if( e != JIM_OK ){
+ if ( e != JIM_OK ){
command_print( cmd_ctx, "%s", Jim_GetString( Jim_GetResult(interp), NULL ) );
}
return e;
*/
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 ) ){
+ 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))
e = Jim_GetLong(interp, args[i], &bits);
/* If valid - try next arg */
- if( e == JIM_OK ){
+ if ( e == JIM_OK ){
continue;
}
/* get arg as a string. */
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 );
/* 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 );
} else {
}
/* 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 ){
+ if ( tap == NULL ){
return JIM_ERR;
}
const char *cp;
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 );
{
send_bits = size;
loops = size/8;
- /* if(loops==0) */
+ /* if (loops==0) */
loops++;
size = 0;
}
{
// already in IRSHIFT or DRSHIFT state
// merge tms data in the last tms shift command into next scan command
- if(*vsllink_tms_cmd_pos < 1)
+ if (*vsllink_tms_cmd_pos < 1)
{
LOG_ERROR("There MUST be some bugs in the driver");
exit(-1);
}
- else if(*vsllink_tms_cmd_pos < 2)
+ else if (*vsllink_tms_cmd_pos < 2)
{
tms_tmp = vsllink_usb_out_buffer[vsllink_usb_out_buffer_idx];
vsllink_usb_out_buffer_idx--;
if (vsllink_tms_data_len > 0)
{
- if((tap_get_state() != TAP_RESET) && (tap_get_state() != TAP_IDLE) && (tap_get_state() != TAP_IRPAUSE) && (tap_get_state() != TAP_DRPAUSE))
+ if ((tap_get_state() != TAP_RESET) && (tap_get_state() != TAP_IDLE) && (tap_get_state() != TAP_IRPAUSE) && (tap_get_state() != TAP_DRPAUSE))
{
LOG_WARNING("%s is not in RESET or IDLE or PAUSR state", tap_state_name(tap_get_state()));
}
void zy1000_reset(int trst, int srst)
{
LOG_DEBUG("zy1000 trst=%d, srst=%d", trst, srst);
- if(!srst)
+ if (!srst)
{
ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x00000001);
}
ZY1000_POKE(ZY1000_JTAG_BASE+0x10, 0x00000001);
}
- if(!trst)
+ if (!trst)
{
ZY1000_POKE(ZY1000_JTAG_BASE+0x14, 0x00000002);
}
int zy1000_speed(int speed)
{
- if(speed == 0)
+ if (speed == 0)
{
/*0 means RCLK*/
speed = 0;
}
else
{
- if(speed > 8190 || speed < 2)
+ if (speed > 8190 || speed < 2)
{
LOG_USER("valid ZY1000 jtag_speed=[8190,2]. Divisor is 64MHz / even values between 8190-2, i.e. min 7814Hz, max 32MHz");
return ERROR_INVALID_ARGUMENTS;
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 );
LOG_DEBUG("Unexpected start of new packet");
local_buffer[len++] = '#';
local_buffer[len++] = DIGITS[(my_checksum >> 4) & 0xf];
local_buffer[len++] = DIGITS[my_checksum & 0xf];
- if((retval = gdb_write(connection, local_buffer, len)) != ERROR_OK)
+ if ((retval = gdb_write(connection, local_buffer, len)) != ERROR_OK)
{
return retval;
}
local_buffer[1] = '#';
local_buffer[2] = DIGITS[(my_checksum >> 4) & 0xf];
local_buffer[3] = DIGITS[my_checksum & 0xf];
- if((retval = gdb_write(connection, local_buffer, 1)) != ERROR_OK)
+ if ((retval = gdb_write(connection, local_buffer, 1)) != ERROR_OK)
{
return retval;
}
- if((retval = gdb_write(connection, buffer, len)) != ERROR_OK)
+ if ((retval = gdb_write(connection, buffer, len)) != ERROR_OK)
{
return retval;
}
- if((retval = gdb_write(connection, local_buffer+1, 3)) != ERROR_OK)
+ if ((retval = gdb_write(connection, local_buffer+1, 3)) != ERROR_OK)
{
return retval;
}
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 );
return ERROR_OK;
return ERROR_SERVER_REMOTE_CLOSED;
}
}
- else if( reply == '$' ){
+ else if ( reply == '$' ){
LOG_ERROR("GDB missing ack(2) - assumed good");
gdb_putback_char( connection, reply );
return ERROR_OK;
break;
case TARGET_EVENT_GDB_FLASH_ERASE_START:
target_handle_event( target, TARGET_EVENT_OLD_gdb_program_config );
- if((retval = jtag_execute_queue()) != ERROR_OK)
+ if ((retval = jtag_execute_queue()) != ERROR_OK)
{
return retval;
}
}
/* create new section with content from packet buffer */
- if((retval = image_add_section(gdb_connection->vflash_image, addr, length, 0x0, (uint8_t*)parse)) != ERROR_OK)
+ if ((retval = image_add_section(gdb_connection->vflash_image, addr, length, 0x0, (uint8_t*)parse)) != ERROR_OK)
{
return retval;
}
/* 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;
buf_set_u32(out_buf, 0, 32, flip_u32(out, 32));
jtag_set_end_state(TAP_DRPAUSE);
- if((retval = arm_jtag_scann(jtag_info, 0xf)) != ERROR_OK)
+ if ((retval = arm_jtag_scann(jtag_info, 0xf)) != ERROR_OK)
{
return retval;
}
- if((retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL)) != ERROR_OK)
+ if ((retval = arm_jtag_set_instr(jtag_info, jtag_info->intest_instr, NULL)) != ERROR_OK)
{
return retval;
}
jtag_add_runtest(0, jtag_get_end_state());
#ifdef _DEBUG_INSTRUCTION_EXECUTION_
- if((retval = jtag_execute_queue()) != ERROR_OK)
+ if ((retval = jtag_execute_queue()) != ERROR_OK)
{
return retval;
}
armv4_5_common_t *armv4_5 = target->arch_info;
arm7_9_common_t *arm7_9 = armv4_5->arch_info;
- if((retval = arm7_9_unset_breakpoint(target, breakpoint)) != ERROR_OK)
+ if ((retval = arm7_9_unset_breakpoint(target, breakpoint)) != ERROR_OK)
{
return retval;
}
if (arm7_9->breakpoint_count==0)
{
/* make sure we don't have any dangling breakpoints */
- if((retval = arm7_9_clear_watchpoints(arm7_9)) != ERROR_OK)
+ if ((retval = arm7_9_clear_watchpoints(arm7_9)) != ERROR_OK)
{
return retval;
}
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));
- if((retval = jtag_execute_queue()) != ERROR_OK)
+ if ((retval = jtag_execute_queue()) != ERROR_OK)
{
return retval;
}
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));
- if((retval = jtag_execute_queue()) != ERROR_OK)
+ if ((retval = jtag_execute_queue()) != ERROR_OK)
{
return retval;
}
if (watchpoint->set == 1)
{
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W0_CONTROL_VALUE], 0x0);
- if((retval = jtag_execute_queue()) != ERROR_OK)
+ if ((retval = jtag_execute_queue()) != ERROR_OK)
{
return retval;
}
else if (watchpoint->set == 2)
{
embeddedice_set_reg(&arm7_9->eice_cache->reg_list[EICE_W1_CONTROL_VALUE], 0x0);
- if((retval = jtag_execute_queue()) != ERROR_OK)
+ if ((retval = jtag_execute_queue()) != ERROR_OK)
{
return retval;
}
if (watchpoint->set)
{
- if((retval = arm7_9_unset_watchpoint(target, watchpoint)) != ERROR_OK)
+ if ((retval = arm7_9_unset_watchpoint(target, watchpoint)) != ERROR_OK)
{
return retval;
}
uint32_t current_pc;
current_pc = buf_get_u32(armv4_5->core_cache->reg_list[15].value, 0, 32);
- if(next_pc != current_pc)
+ if (next_pc != current_pc)
{
/* setup an inverse breakpoint on the current PC
* - comparator 1 matches the current address
retval = arm7_9_execute_fast_sys_speed(target);
else
retval = arm7_9_execute_sys_speed(target);
- if(retval != ERROR_OK)
+ if (retval != ERROR_OK)
{
return retval;
}
retval = arm7_9_execute_fast_sys_speed(target);
else
retval = arm7_9_execute_sys_speed(target);
- if(retval != ERROR_OK)
+ if (retval != ERROR_OK)
{
return retval;
}
retval = arm7_9_execute_fast_sys_speed(target);
else
retval = arm7_9_execute_sys_speed(target);
- if(retval != ERROR_OK)
+ if (retval != ERROR_OK)
{
return retval;
}
retval = arm7_9_execute_fast_sys_speed(target);
else
retval = arm7_9_execute_sys_speed(target);
- if(retval != ERROR_OK)
+ if (retval != ERROR_OK)
{
return retval;
}
retval = arm7_9_execute_fast_sys_speed(target);
else
retval = arm7_9_execute_sys_speed(target);
- if(retval != ERROR_OK)
+ if (retval != ERROR_OK)
{
return retval;
}
}
}
- if((retval = target_halt(target))!= ERROR_OK)
+ if ((retval = target_halt(target))!= ERROR_OK)
{
return retval;
}
arm7_9->common_magic = ARM7_9_COMMON_MAGIC;
- if((retval = arm_jtag_setup_connection(&arm7_9->jtag_info)) != ERROR_OK)
+ if ((retval = arm_jtag_setup_connection(&arm7_9->jtag_info)) != ERROR_OK)
{
return retval;
}
armv4_5->write_core_reg = arm7_9_write_core_reg;
armv4_5->full_context = arm7_9_full_context;
- if((retval = armv4_5_init_arch_info(target, armv4_5)) != ERROR_OK)
+ if ((retval = armv4_5_init_arch_info(target, armv4_5)) != ERROR_OK)
{
return retval;
}
- if((retval = target_register_timer_callback(arm7_9_handle_target_request, 1, 1, target)) != ERROR_OK)
+ if ((retval = target_register_timer_callback(arm7_9_handle_target_request, 1, 1, target)) != ERROR_OK)
{
return retval;
}
fields[1].out_value = NULL;
fields[1].in_value = databus;
- if((retval = arm_jtag_scann(&arm7_9->jtag_info, 0x1)) != ERROR_OK)
+ if ((retval = arm_jtag_scann(&arm7_9->jtag_info, 0x1)) != ERROR_OK)
{
return retval;
}
arm_jtag_set_instr(&arm7_9->jtag_info, arm7_9->jtag_info.intest_instr, NULL);
jtag_add_dr_scan(2, fields, jtag_set_end_state(TAP_DRPAUSE));
- if((retval = jtag_execute_queue()) != ERROR_OK)
+ if ((retval = jtag_execute_queue()) != ERROR_OK)
{
return retval;
}
scan_field_t fields[2];
jtag_set_end_state(TAP_DRPAUSE);
- if((retval = arm_jtag_scann(jtag_info, 0x1)) != ERROR_OK)
+ if ((retval = arm_jtag_scann(jtag_info, 0x1)) != ERROR_OK)
{
return retval;
}
#ifdef _DEBUG_INSTRUCTION_EXECUTION_
{
- if((retval = jtag_execute_queue()) != ERROR_OK)
+ if ((retval = jtag_execute_queue()) != ERROR_OK)
{
return retval;
}
scan_field_t fields[2];
jtag_set_end_state(TAP_DRPAUSE);
- if((retval = arm_jtag_scann(jtag_info, 0x1)) != ERROR_OK)
+ if ((retval = arm_jtag_scann(jtag_info, 0x1)) != ERROR_OK)
{
return retval;
}
#ifdef _DEBUG_INSTRUCTION_EXECUTION_
{
- if((retval = jtag_execute_queue()) != ERROR_OK)
+ if ((retval = jtag_execute_queue()) != ERROR_OK)
{
return retval;
}
int arm_jtag_scann(arm_jtag_t *jtag_info, uint32_t new_scan_chain)
{
int retval = ERROR_OK;
- if(jtag_info->cur_scan_chain != new_scan_chain)
+ if (jtag_info->cur_scan_chain != new_scan_chain)
{
uint32_t values[1];
int num_bits[1];
values[0]=new_scan_chain;
num_bits[0]=jtag_info->scann_size;
- if((retval = arm_jtag_set_instr(jtag_info, jtag_info->scann_instr, NULL)) != ERROR_OK)
+ if ((retval = arm_jtag_set_instr(jtag_info, jtag_info->scann_instr, NULL)) != ERROR_OK)
{
return retval;
}
uint32_t opcode;
/* get current instruction, and identify it */
- if((retval = target_read_u32(target, current_pc, &opcode)) != ERROR_OK)
+ if ((retval = target_read_u32(target, current_pc, &opcode)) != ERROR_OK)
{
return retval;
}
- if((retval = arm_evaluate_opcode(opcode, current_pc, &instruction)) != ERROR_OK)
+ if ((retval = arm_evaluate_opcode(opcode, current_pc, &instruction)) != ERROR_OK)
{
return retval;
}
{
uint16_t opcode;
- if((retval = target_read_u16(target, current_pc, &opcode)) != ERROR_OK)
+ if ((retval = target_read_u16(target, current_pc, &opcode)) != ERROR_OK)
{
return retval;
}
- if((retval = thumb_evaluate_opcode(opcode, current_pc, &instruction)) != ERROR_OK)
+ if ((retval = thumb_evaluate_opcode(opcode, current_pc, &instruction)) != ERROR_OK)
{
return retval;
}
else
{
target = buf_get_u32(ARMV4_5_CORE_REG_MODE(armv4_5->core_cache, armv4_5->core_mode, instruction.info.b_bl_bx_blx.reg_operand).value, 0, 32);
- if(instruction.info.b_bl_bx_blx.reg_operand == 15)
+ if (instruction.info.b_bl_bx_blx.reg_operand == 15)
{
target += 2 * instruction_size;
}
load_address = Rn;
}
- if((!dry_run_pc) || (instruction.info.load_store.Rd == 15))
+ if ((!dry_run_pc) || (instruction.info.load_store.Rd == 15))
{
- if((retval = target_read_u32(target, load_address, &load_value)) != ERROR_OK)
+ if ((retval = target_read_u32(target, load_address, &load_value)) != ERROR_OK)
{
return retval;
}
{
if (instruction.info.load_store_multiple.register_list & (1 << i))
{
- if((!dry_run_pc) || (i == 15))
+ if ((!dry_run_pc) || (i == 15))
{
target_read_u32(target, Rn, &load_values[i]);
}
int retval;
/* This code relies on the target specific resume() and poll()->debug_entry()
* sequence to write register values to the processor and the read them back */
- if((retval = target_resume(target, 0, entry_point, 1, 1)) != ERROR_OK)
+ if ((retval = target_resume(target, 0, entry_point, 1, 1)) != ERROR_OK)
{
return retval;
}
for (i = 0; i < num_mem_params; i++)
{
if (mem_params[i].direction != PARAM_OUT)
- if((retval = target_read_buffer(target, mem_params[i].address, mem_params[i].size, mem_params[i].value)) != ERROR_OK)
+ if ((retval = target_read_buffer(target, mem_params[i].address, mem_params[i].size, mem_params[i].value)) != ERROR_OK)
{
return retval;
}
/* convert flash writing code into a buffer in target endianness */
for (i = 0; i < (sizeof(cortex_m3_crc_code)/sizeof(uint16_t)); i++)
- if((retval = target_write_u16(target, crc_algorithm->address + i*sizeof(uint16_t), cortex_m3_crc_code[i])) != ERROR_OK)
+ if ((retval = target_write_u16(target, crc_algorithm->address + i*sizeof(uint16_t), cortex_m3_crc_code[i])) != ERROR_OK)
{
return retval;
}
{
uint8_t code[4];
buf_set_u32(code, 0, 32, ARMV7M_T_BKPT(0x11));
- if((retval = target_read_memory(target, breakpoint->address & 0xFFFFFFFE, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK)
+ if ((retval = target_read_memory(target, breakpoint->address & 0xFFFFFFFE, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK)
{
return retval;
}
- if((retval = target_write_memory(target, breakpoint->address & 0xFFFFFFFE, breakpoint->length, 1, code)) != ERROR_OK)
+ if ((retval = target_write_memory(target, breakpoint->address & 0xFFFFFFFE, breakpoint->length, 1, code)) != ERROR_OK)
{
return retval;
}
/* restore original instruction (kept in target endianness) */
if (breakpoint->length == 4)
{
- if((retval = target_write_memory(target, breakpoint->address & 0xFFFFFFFE, 4, 1, breakpoint->orig_instr)) != ERROR_OK)
+ if ((retval = target_write_memory(target, breakpoint->address & 0xFFFFFFFE, 4, 1, breakpoint->orig_instr)) != ERROR_OK)
{
return retval;
}
}
else
{
- if((retval = target_write_memory(target, breakpoint->address & 0xFFFFFFFE, 2, 1, breakpoint->orig_instr)) != ERROR_OK)
+ if ((retval = target_write_memory(target, breakpoint->address & 0xFFFFFFFE, 2, 1, breakpoint->orig_instr)) != ERROR_OK)
{
return retval;
}
target_buffer_set_u32(target, dcc_code_buf + i*4, dcc_code[i]);
/* write DCC code to working area */
- if((retval = target_write_memory(target, arm7_9->dcc_working_area->address, 4, dcc_size/4, dcc_code_buf)) != ERROR_OK)
+ if ((retval = target_write_memory(target, arm7_9->dcc_working_area->address, 4, dcc_size/4, dcc_code_buf)) != ERROR_OK)
{
return retval;
}
elf->header = malloc(sizeof(Elf32_Ehdr));
- if(elf->header == NULL)
+ if (elf->header == NULL)
{
LOG_ERROR("insufficient memory to perform operation ");
return ERROR_FILEIO_OPERATION_FAILED;
}
elf->segments = malloc(elf->segment_count*sizeof(Elf32_Phdr));
- if(elf->segments == NULL)
+ if (elf->segments == NULL)
{
LOG_ERROR("insufficient memory to perform operation ");
return ERROR_FILEIO_OPERATION_FAILED;
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");
case 2:
return mips32_pracc_read_mem16(ejtag_info, addr, count, (uint16_t*)buf);
case 4:
- if(count==1)
+ if (count==1)
return mips32_pracc_read_u32(ejtag_info, addr, (uint32_t*)buf);
else
return mips32_pracc_read_mem32(ejtag_info, addr, count, (uint32_t*)buf);
case 2:
return mips32_pracc_write_mem16(ejtag_info, addr, count,(uint16_t*)buf);
case 4:
- if(count==1)
+ if (count==1)
return mips32_pracc_write_u32(ejtag_info, addr, (uint32_t*)buf);
else
return mips32_pracc_write_mem32(ejtag_info, addr, count, (uint32_t*)buf);
ejtag_ctrl = ejtag_info->ejtag_ctrl;
mips_ejtag_drscan_32(ejtag_info, &ejtag_ctrl);
LOG_DEBUG("ejtag_ctrl: 0x%8.8" PRIx32 "", ejtag_ctrl);
- if((ejtag_ctrl & EJTAG_CTRL_BRKST) == 0)
+ if ((ejtag_ctrl & EJTAG_CTRL_BRKST) == 0)
LOG_DEBUG("Failed to enter Debug Mode!");
return ERROR_OK;
ejtag_info->impcode & (1<<0) ? " MIPS64": " MIPS32"
);
- if((ejtag_info->impcode & (1<<14)) == 0)
+ if ((ejtag_info->impcode & (1<<14)) == 0)
LOG_DEBUG("EJTAG: DMA Access Mode Support Enabled");
/* set initial state for ejtag control reg */
{
uint32_t verify = 0xffffffff;
- if((retval = target_read_memory(target, breakpoint->address, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK)
+ if ((retval = target_read_memory(target, breakpoint->address, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK)
{
return retval;
}
{
uint16_t verify = 0xffff;
- if((retval = target_read_memory(target, breakpoint->address, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK)
+ if ((retval = target_read_memory(target, breakpoint->address, breakpoint->length, 1, breakpoint->orig_instr)) != ERROR_OK)
{
return retval;
}
}
if (current_instr == MIPS32_SDBBP)
{
- if((retval = target_write_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK)
+ if ((retval = target_write_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK)
{
return retval;
}
if (current_instr == MIPS16_SDBBP)
{
- if((retval = target_write_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK)
+ if ((retval = target_write_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK)
{
return retval;
}
/* if noDMA off, use DMAACC mode for memory read */
int retval;
- if(ejtag_info->impcode & EJTAG_IMP_NODMA)
+ if (ejtag_info->impcode & EJTAG_IMP_NODMA)
retval = mips32_pracc_read_mem(ejtag_info, address, size, count, (void *)buffer);
else
retval = mips32_dmaacc_read_mem(ejtag_info, address, size, count, (void *)buffer);
}
/* if noDMA off, use DMAACC mode for memory write */
- if(ejtag_info->impcode & EJTAG_IMP_NODMA)
+ if (ejtag_info->impcode & EJTAG_IMP_NODMA)
return mips32_pracc_write_mem(ejtag_info, address, size, count, (void *)buffer);
else
return mips32_dmaacc_write_mem(ejtag_info, address, size, count, (void *)buffer);
oocd_trace->tty_fd = open(oocd_trace->tty, O_RDWR | O_NOCTTY | O_NONBLOCK);
- if(oocd_trace->tty_fd < 0)
+ if (oocd_trace->tty_fd < 0)
{
LOG_ERROR("can't open tty");
return ERROR_ETM_CAPTURE_INIT_FAILED;
const Jim_Nvp *n;
n = Jim_Nvp_value2name_simple( nvp_error_target, err );
- if( n->name == NULL ){
+ if ( n->name == NULL ){
return "unknown";
} else {
return n->name;
x = -1;
t = all_targets;
while( t ){
- if( x < t->target_number ){
+ 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;
int retval;
Jim_Nvp *n;
n = Jim_Nvp_value2name_simple( nvp_reset_modes, reset_mode );
- if( n->name == NULL ){
+ if ( n->name == NULL ){
LOG_ERROR("invalid reset mode");
return ERROR_FAIL;
}
target_continuous_poll = save_poll;
- if(retval != JIM_OK) {
+ if (retval != JIM_OK) {
Jim_PrintErrorMessage(interp);
return ERROR_FAIL;
}
if (all_targets)
{
- if((retval = target_register_user_commands(cmd_ctx)) != ERROR_OK)
+ if ((retval = target_register_user_commands(cmd_ctx)) != ERROR_OK)
return retval;
- if((retval = target_register_timer_callback(handle_target, 100, 1, NULL)) != ERROR_OK)
+ if ((retval = target_register_timer_callback(handle_target, 100, 1, NULL)) != ERROR_OK)
return retval;
}
{
int retval;
new_wa->backup = malloc(new_wa->size);
- if((retval = target_read_memory(target, new_wa->address, 4, new_wa->size / 4, new_wa->backup)) != ERROR_OK)
+ if ((retval = target_read_memory(target, new_wa->address, 4, new_wa->size / 4, new_wa->backup)) != ERROR_OK)
{
free(new_wa->backup);
free(new_wa);
if (restore&&target->backup_working_area)
{
int retval;
- if((retval = target_write_memory(target, area->address, 4, area->size / 4, area->backup)) != ERROR_OK)
+ if ((retval = target_write_memory(target, area->address, 4, area->size / 4, area->backup)) != ERROR_OK)
return retval;
}
register_command(cmd_ctx, NULL, "verify_image", handle_verify_image_command, COMMAND_EXEC, "verify_image <file> [offset] [type]");
register_command(cmd_ctx, NULL, "test_image", handle_test_image_command, COMMAND_EXEC, "test_image <file> [offset] [type]");
- if((retval = target_request_register_commands(cmd_ctx)) != ERROR_OK)
+ if ((retval = target_request_register_commands(cmd_ctx)) != ERROR_OK)
return retval;
- if((retval = trace_register_commands(cmd_ctx)) != ERROR_OK)
+ if ((retval = trace_register_commands(cmd_ctx)) != ERROR_OK)
return retval;
return retval;
if (!powerDropout && !srstAsserted)
{
/* polling may fail silently until the target has been examined */
- if((retval = target_poll(target)) != ERROR_OK)
+ if ((retval = target_poll(target)) != ERROR_OK)
return retval;
}
}
{
const Jim_Nvp *n;
n = Jim_Nvp_name2value_simple( nvp_reset_modes, args[0] );
- if( (n->name == NULL) || (n->value == RESET_UNKNOWN) ){
+ if ( (n->name == NULL) || (n->value == RESET_UNKNOWN) ){
return ERROR_COMMAND_SYNTAX_ERROR;
}
reset_mode = n->value;
free(buffer);
}
- if((retvaltemp = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
+ if ((retvaltemp = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
{
image_close(&image);
return retvaltemp;
address += this_run_size;
}
- if((retvaltemp = fileio_close(&fileio)) != ERROR_OK)
+ if ((retvaltemp = fileio_close(&fileio)) != ERROR_OK)
return retvaltemp;
- if((retvaltemp = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
+ if ((retvaltemp = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
return retvaltemp;
if (retval==ERROR_OK)
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;
}
done:
- if((retvaltemp = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
+ if ((retvaltemp = duration_stop_measure(&duration, &duration_text)) != ERROR_OK)
{
image_close(&image);
return retvaltemp;
} else if (target->state == TARGET_RUNNING)
{
/* We want to quickly sample the PC. */
- if((retval = target_halt(target)) != ERROR_OK)
+ if ((retval = target_halt(target)) != ERROR_OK)
{
free(samples);
return retval;
if ((numSamples>=maxSample) || ((now.tv_sec >= timeout.tv_sec) && (now.tv_usec >= timeout.tv_usec)))
{
command_print(cmd_ctx, "Profiling completed. %d samples.", numSamples);
- if((retval = target_poll(target)) != ERROR_OK)
+ if ((retval = target_poll(target)) != ERROR_OK)
{
free(samples);
return retval;
{
target_resume(target, 1, 0, 0, 0); /* current pc, addr = 0, do not handle breakpoints, not debugging */
}
- if((retval = target_poll(target)) != ERROR_OK)
+ if ((retval = target_poll(target)) != ERROR_OK)
{
free(samples);
return retval;
done = 0;
while( teap ){
- if( teap->event == e ){
+ if ( teap->event == e ){
done = 1;
LOG_DEBUG( "target: (%d) %s (%s) event: %d (%s) action: %s\n",
target->target_number,
}
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_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 ){
+ 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 ){
+ if ( e != JIM_OK ){
Jim_GetOpt_NvpUnknown( goi, nvp_config_opts, 0 );
return e;
}
switch( n->value ){
case TCFG_TYPE:
/* not setable */
- if( goi->isconfigure ){
+ 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;
}
/* 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 ){
+ 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 ){
+ 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->event = n->value;
Jim_GetOpt_Obj( goi, &o );
- if( teap->body ){
+ if ( teap->body ){
Jim_DecrRefCount( interp, teap->body );
}
teap->body = Jim_DuplicateObj( goi->interp, o );
Jim_SetEmptyResult(goi->interp);
} else {
/* get */
- if( teap == NULL ){
+ if ( teap == NULL ){
Jim_SetEmptyResult( goi->interp );
} else {
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 ){
+ if ( e != JIM_OK ){
return e;
}
target->working_area_virt = w;
} else {
- if( goi->argc != 0 ){
+ if ( goi->argc != 0 ){
goto no_params;
}
}
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 ){
+ if ( e != JIM_OK ){
return e;
}
target->working_area_phys = w;
} else {
- if( goi->argc != 0 ){
+ if ( goi->argc != 0 ){
goto no_params;
}
}
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 ){
+ if ( e != JIM_OK ){
return e;
}
target->working_area_size = w;
} else {
- if( goi->argc != 0 ){
+ if ( goi->argc != 0 ){
goto no_params;
}
}
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 ){
+ 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 ){
+ if ( goi->isconfigure ){
e = Jim_GetOpt_Nvp( goi, nvp_target_endian, &n );
- if( e != JIM_OK ){
+ 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 ){
+ if ( n->name == NULL ){
target->endianness = TARGET_LITTLE_ENDIAN;
n = Jim_Nvp_value2name_simple( nvp_target_endian, target->endianness );
}
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 );
return JIM_ERR;
}
- if( target->variant ){
+ if ( target->variant ){
free((void *)(target->variant));
}
e = Jim_GetOpt_String( goi, &cp, NULL );
target->variant = strdup(cp);
} else {
- if( goi->argc != 0 ){
+ if ( goi->argc != 0 ){
goto no_params;
}
}
/* 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 ){
+ if ( e != JIM_OK ){
return e;
}
tap = jtag_tap_by_jim_obj( goi->interp, o );
- if( tap == NULL ){
+ 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;
}
}
/* commands here are in an NVP table */
e = Jim_GetOpt_Nvp( &goi, target_options, &n );
- if( e != JIM_OK ){
+ if ( e != JIM_OK ){
Jim_GetOpt_NvpUnknown( &goi, target_options, 0 );
return e;
}
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;
}
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;
}
* argv[3] = optional count.
*/
- if( (goi.argc == 2) || (goi.argc == 3) ){
+ if ( (goi.argc == 2) || (goi.argc == 3) ){
/* all is well */
} else {
mwx_error:
}
e = Jim_GetOpt_Wide( &goi, &a );
- if( e != JIM_OK ){
+ if ( e != JIM_OK ){
goto mwx_error;
}
e = Jim_GetOpt_Wide( &goi, &b );
- if( e != JIM_OK ){
+ if ( e != JIM_OK ){
goto mwx_error;
}
if (goi.argc == 3) {
e = Jim_GetOpt_Wide( &goi, &c );
- if( e != JIM_OK ){
+ if ( e != JIM_OK ){
goto mwx_error;
}
} else {
}
for( x = 0 ; x < c ; x++ ){
e = target_write_memory( target, a, b, 1, target_buf );
- if( e != ERROR_OK ){
+ if ( e != ERROR_OK ){
Jim_SetResult_sprintf( interp, "Error writing @ 0x%08x: %d\n", (int)(a), e );
return JIM_ERR;
}
* argv[1] = address
* argv[2] = optional count
*/
- if( (goi.argc == 2) || (goi.argc == 3) ){
+ 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 ){
+ if ( e != JIM_OK ){
return JIM_ERR;
}
- if( goi.argc ){
+ if ( goi.argc ){
e = Jim_GetOpt_Wide( &goi, &c );
- if( e != JIM_OK ){
+ if ( e != JIM_OK ){
return JIM_ERR;
}
} else {
/* count is now in 'BYTES' */
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 ){
+ if ( e != ERROR_OK ){
Jim_SetResult_sprintf( interp, "error reading target @ 0x%08lx", (int)(a) );
return JIM_ERR;
}
}
/* ascii-ify the bytes */
for( x = 0 ; x < y ; x++ ){
- if( (target_buf[x] >= 0x20) &&
+ if ( (target_buf[x] >= 0x20) &&
(target_buf[x] <= 0x7e) ){
/* good */
} else {
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 ){
+ 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 );
}
- if( e != ERROR_OK ){
+ if ( e != ERROR_OK ){
Jim_SetResult_sprintf( interp, "poll-fails: %d", e );
return JIM_ERR;
} else {
}
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 ){
+ 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 ){
+ if ( n->value == NVP_ASSERT ){
target->type->assert_reset( target );
} else {
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;
}
return JIM_OK;
case TS_CMD_WAITSTATE:
/* params: <name> statename timeoutmsecs */
- if( goi.argc != 2 ){
+ 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 ){
+ if ( e != JIM_OK ){
Jim_GetOpt_NvpUnknown( &goi, nvp_target_state,1 );
return e;
}
e = Jim_GetOpt_Wide( &goi, &a );
- if( e != JIM_OK ){
+ 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 ){
+ if ( e != ERROR_OK ){
Jim_SetResult_sprintf( goi.interp,
"target: %s wait %s fails (%d) %s",
target->cmd_name,
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 ){
+ if ( e != JIM_OK ){
Jim_GetOpt_NvpUnknown( &goi, nvp_target_event, 1 );
return e;
}
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;
}
Jim_GetOpt_Obj( goi, &new_cmd );
/* does this command exist? */
cmd = Jim_GetCommand( goi->interp, new_cmd, JIM_ERRMSG );
- if( cmd ){
+ if ( cmd ){
cp = Jim_GetString( new_cmd, NULL );
Jim_SetResult_sprintf(goi->interp, "Command/target: %s Exists", cp);
return JIM_ERR;
cp = cp2;
/* now does target type exist */
for( x = 0 ; target_types[x] ; x++ ){
- if( 0 == strcmp( cp, target_types[x]->name ) ){
+ if ( 0 == strcmp( cp, target_types[x]->name ) ){
/* found */
break;
}
}
- if( target_types[x] == NULL ){
+ 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+1] ){
Jim_AppendStrings( goi->interp,
Jim_GetResult(goi->interp),
target_types[x]->name,
e=JIM_ERR;
}
- if( e != JIM_OK ){
+ 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 ){
+ if ( target->type->register_commands ){
(*(target->type->register_commands))( cmd_ctx );
}
- if( target->type->target_create ){
+ if ( target->type->target_create ){
(*(target->type->target_create))( target, goi->interp );
}
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 ){
+ 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 );
return JIM_OK;
case TG_CMD_TYPES:
- if( goi.argc != 0 ){
+ if ( goi.argc != 0 ){
Jim_WrongNumArgs( goi.interp, 1, goi.argv, "Too many parameters" );
return JIM_ERR;
}
}
return JIM_OK;
case TG_CMD_NAMES:
- if( goi.argc != 0 ){
+ if ( goi.argc != 0 ){
Jim_WrongNumArgs( goi.interp, 1, goi.argv, "Too many parameters" );
return JIM_ERR;
}
}
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 );
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 ){
+ 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;
}
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;
}
if (breakpoint->length == 4)
{
/* keep the original instruction in target endianness */
- if((retval = target_read_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK)
+ if ((retval = target_read_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK)
{
return retval;
}
/* write the original instruction in target endianness (arm7_9->arm_bkpt is host endian) */
- if((retval = target_write_u32(target, breakpoint->address, xscale->arm_bkpt)) != ERROR_OK)
+ if ((retval = target_write_u32(target, breakpoint->address, xscale->arm_bkpt)) != ERROR_OK)
{
return retval;
}
else
{
/* keep the original instruction in target endianness */
- if((retval = target_read_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK)
+ if ((retval = target_read_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK)
{
return retval;
}
/* write the original instruction in target endianness (arm7_9->arm_bkpt is host endian) */
- if((retval = target_write_u32(target, breakpoint->address, xscale->thumb_bkpt)) != ERROR_OK)
+ if ((retval = target_write_u32(target, breakpoint->address, xscale->thumb_bkpt)) != ERROR_OK)
{
return retval;
}
/* restore original instruction (kept in target endianness) */
if (breakpoint->length == 4)
{
- if((retval = target_write_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK)
+ if ((retval = target_write_memory(target, breakpoint->address, 4, 1, breakpoint->orig_instr)) != ERROR_OK)
{
return retval;
}
}
else
{
- if((retval = target_write_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK)
+ if ((retval = target_write_memory(target, breakpoint->address, 2, 1, breakpoint->orig_instr)) != ERROR_OK)
{
return retval;
}
}
uint32_t reg_no = 0;
reg_t *reg = NULL;
- if(argc > 0)
+ if (argc > 0)
{
reg_no = strtoul(args[0], NULL, 0);
/*translate from xscale cp15 register no to openocd register*/
reg = &xscale->reg_cache->reg_list[reg_no];
}
- if(argc == 1)
+ if (argc == 1)
{
uint32_t value;
value = buf_get_u32(reg->value, 0, 32);
command_print(cmd_ctx, "%s (/%i): 0x%" PRIx32 "", reg->name, (int)(reg->size), value);
}
- else if(argc == 2)
+ else if (argc == 2)
{
uint32_t value = strtoul(args[1], NULL, 0);
xsdrsize = be_to_h_u32(xsdrsize_buf);
LOG_DEBUG("XSDRSIZE %d", xsdrsize);
- 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 ( dr_out_buf ) free(dr_out_buf);
+ if ( dr_in_buf) free(dr_in_buf);
+ if ( dr_in_mask) free(dr_in_mask);
dr_out_buf = malloc((xsdrsize + 7) / 8);
dr_in_buf = malloc((xsdrsize + 7) / 8);
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;
{
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
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),
}
/* 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)
/* LOG_DEBUG("FLUSHING QUEUE"); */
result = jtag_execute_queue();
- if(result != ERROR_OK)
+ if (result != ERROR_OK)
{
tdo_mismatch = 1;
}
/* LOG_DEBUG("FLUSHING QUEUE"); */
result = jtag_execute_queue();
- if(result == ERROR_OK)
+ if (result == ERROR_OK)
{
matched = 1;
break;