nand_fileio_init(state);
unsigned minargs = need_size ? 4 : 3;
- if (CMD_ARGC < minargs)
+ if (minargs > CMD_ARGC)
return ERROR_COMMAND_SYNTAX_ERROR;
struct nand_device *nand;
}
}
- if (CMD_ARGC > minargs) {
+ if (minargs < CMD_ARGC) {
for (unsigned i = minargs; i < CMD_ARGC; i++) {
if (!strcmp(CMD_ARGV[i], "oob_raw"))
state->oob_format |= NAND_OOB_RAW;
&poll_value,
0x3380,
AVR_JTAG_REG_PROGRAMMING_COMMAND_LEN);
- if (ERROR_OK != mcu_execute_queue())
+ if (mcu_execute_queue() != ERROR_OK)
return ERROR_FAIL;
LOG_DEBUG("poll_value = 0x%04" PRIx32 "", poll_value);
} while (!(poll_value & 0x0200));
&poll_value,
0x3700,
AVR_JTAG_REG_PROGRAMMING_COMMAND_LEN);
- if (ERROR_OK != mcu_execute_queue())
+ if (mcu_execute_queue() != ERROR_OK)
return ERROR_FAIL;
LOG_DEBUG("poll_value = 0x%04" PRIx32 "", poll_value);
} while (!(poll_value & 0x0200));
LOG_DEBUG("offset is 0x%08" PRIx32 "", offset);
LOG_DEBUG("count is %" PRIu32 "", count);
- if (ERROR_OK != avr_jtagprg_enterprogmode(avr))
+ if (avr_jtagprg_enterprogmode(avr) != ERROR_OK)
return ERROR_FAIL;
if (bank->size > 0x20000)
avrf_info->probed = false;
avr_jtag_read_jtagid(avr, &device_id);
- if (ERROR_OK != mcu_execute_queue())
+ if (mcu_execute_queue() != ERROR_OK)
return ERROR_FAIL;
LOG_INFO("device id = 0x%08" PRIx32 "", device_id);
}
avr_jtag_read_jtagid(avr, &device_id);
- if (ERROR_OK != mcu_execute_queue())
+ if (mcu_execute_queue() != ERROR_OK)
return ERROR_FAIL;
LOG_INFO("device id = 0x%08" PRIx32 "", device_id);
return ERROR_TARGET_NOT_HALTED;
}
- if ((ERROR_OK != avr_jtagprg_enterprogmode(avr))
- || (ERROR_OK != avr_jtagprg_chiperase(avr))
- || (ERROR_OK != avr_jtagprg_leaveprogmode(avr)))
+ if ((avr_jtagprg_enterprogmode(avr) != ERROR_OK)
+ || (avr_jtagprg_chiperase(avr) != ERROR_OK)
+ || (avr_jtagprg_leaveprogmode(avr) != ERROR_OK))
return ERROR_FAIL;
return ERROR_OK;
return retval;
/* Confirm the defined working address is the area we need to use */
- if (CC26XX_ALGO_BASE_ADDRESS != cc26xx_bank->working_area->address)
+ if (cc26xx_bank->working_area->address != CC26XX_ALGO_BASE_ADDRESS)
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
/* Write flash helper algorithm into target memory */
int retval;
- if (TARGET_HALTED != target->state) {
+ if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
}
uint32_t length;
int retval;
- if (TARGET_HALTED != target->state) {
+ if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
}
uint32_t index;
int retval;
- if (TARGET_HALTED != target->state) {
+ if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
}
int retval = ERROR_OK;
- if (TARGET_HALTED != target->state) {
+ if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
}
int retval = ERROR_OK;
- if (TARGET_HALTED != target->state) {
+ if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
}
int retval = ERROR_OK;
- if (TARGET_HALTED != target->state) {
+ if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
}
/* Check that the head value was written to flash */
result = buf_get_u32(reg_params[2].value, 0, 32);
- if (0 != result) {
+ if (result != 0) {
retval = ERROR_FAIL;
LOG_ERROR("cc3220sf: Flash operation failed");
}
/* Check that all words were written to flash */
result = buf_get_u32(reg_params[2].value, 0, 32);
- if (0 != result) {
+ if (result != 0) {
retval = ERROR_FAIL;
LOG_ERROR("cc3220sf: Flash operation failed");
break;
}
/* Do one word write for any final bytes less than a full word */
- if ((retval == ERROR_OK) && (0 != tail_count)) {
+ if ((retval == ERROR_OK) && (tail_count != 0)) {
uint8_t tail[4];
/* Set starting byte offset for data to write */
/* Check that the tail was written to flash */
result = buf_get_u32(reg_params[2].value, 0, 32);
- if (0 != result) {
+ if (result != 0) {
retval = ERROR_FAIL;
LOG_ERROR("cc3220sf: Flash operation failed");
}
LOG_DEBUG("status: 0x%" PRIx32 "", status);
- if (((status & wait_mask) == 0) && (0 == wait_for_set))
+ if (((status & wait_mask) == 0) && (wait_for_set == 0))
break;
else if (((status & wait_mask) != 0) && wait_for_set)
break;
struct target *target = bank->target;
int ret = 0;
- if (TARGET_HALTED != target->state) {
+ if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
}
LOG_INFO("flash size = %dkbytes", efm32_mcu_info.flash_sz_kib);
LOG_INFO("flash page size = %dbytes", efm32_mcu_info.page_size);
- assert(0 != efm32_mcu_info.page_size);
+ assert(efm32_mcu_info.page_size != 0);
int num_pages = efm32_mcu_info.flash_sz_kib * 1024 /
efm32_mcu_info.page_size;
break;
}
case STEP_WRITE_REG:
- if (4 > bytes_left) {
+ if (bytes_left < 4) {
finish_early = true;
break;
}
offset += 3;
break;
case STEP_SET_DIR:
- if (3 > bytes_left) {
+ if (bytes_left < 3) {
finish_early = true;
break;
}
break;
case STEP_TXWM_WAIT:
case STEP_WIP_WAIT:
- if (2 > bytes_left) {
+ if (bytes_left < 2) {
finish_early = true;
break;
}
int retval = ERROR_OK;
start_ms = timeval_ms();
- while ((0 == return_code) || (return_code == FLASH_BUSY)) {
+ while ((return_code == 0) || (return_code == FLASH_BUSY)) {
retval = target_read_u32(target, ALGO_RETURN_CODE_ADDR, &return_code);
if (retval != ERROR_OK)
return retval;
"msp432: Unrecognized MSP432P4 Device ID and Hardware "
"Rev (%04" PRIX32 ", %02" PRIX32 ")", msp432_bank->device_id,
msp432_bank->hardware_rev);
- } else if (MSP432P401X_DEPR == msp432_bank->device_type) {
+ } else if (msp432_bank->device_type == MSP432P401X_DEPR) {
LOG_WARNING(
"msp432: MSP432P401x pre-production device (deprecated "
"silicon)\n" SUPPORT_MESSAGE);
- } else if (MSP432E4X_GUESS == msp432_bank->device_type) {
+ } else if (msp432_bank->device_type == MSP432E4X_GUESS) {
/* Explicit device type check failed. Report this. */
LOG_WARNING(
"msp432: Unrecognized MSP432E4 DID0 and DID1 values "
return retval;
/* Confirm the defined working address is the area we need to use */
- if (ALGO_BASE_ADDR != msp432_bank->working_area->address)
+ if (msp432_bank->working_area->address != ALGO_BASE_ADDR)
return ERROR_TARGET_RESOURCE_NOT_AVAILABLE;
/* Write flash helper algorithm into target memory */
int retval;
- if (TARGET_HALTED != target->state) {
+ if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
}
msp432_bank = bank->driver_priv;
- if (MSP432E4 == msp432_bank->family_type) {
+ if (msp432_bank->family_type == MSP432E4) {
/* MSP432E4 does not have main vs info regions, ignore "all" */
all = false;
}
if (retval != ERROR_OK)
return retval;
- if (MSP432E4 == msp432_bank->family_type) {
+ if (msp432_bank->family_type == MSP432E4) {
/* MSP432E4 does not have main vs info regions */
LOG_INFO("msp432: Mass erase of flash is complete");
} else {
msp432_bank = bank->driver_priv;
- if (MSP432E4 == msp432_bank->family_type) {
+ if (msp432_bank->family_type == MSP432E4) {
LOG_WARNING("msp432: MSP432E4 does not have a BSL region");
return ERROR_OK;
}
int retval;
- if (TARGET_HALTED != target->state) {
+ if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
}
int retval;
- if (TARGET_HALTED != target->state) {
+ if (target->state != TARGET_HALTED) {
LOG_ERROR("Target not halted");
return ERROR_TARGET_NOT_HALTED;
}
if (retval != ERROR_OK)
return retval;
- if (0 == size) {
+ if (size == 0) {
/* This is likely an MSP432E4 */
msp432_bank->family_type = MSP432E4;
msp432_bank->device_type = msp432_device_type(msp432_bank->family_type,
msp432_bank->device_id, msp432_bank->hardware_rev);
- if (MSP432P4 == msp432_bank->family_type) {
+ if (msp432_bank->family_type == MSP432P4) {
/* Set up MSP432P4 specific flash parameters */
if (is_main) {
retval = target_read_u32(target, P4_FLASH_MAIN_SIZE_REG, &size);
switch (msp432_bank->device_type) {
case MSP432P401X_DEPR:
- if (0xFFFF == msp432_bank->device_id) {
+ if (msp432_bank->device_id == 0xFFFF) {
/* Very early pre-production silicon currently deprecated */
command_print_sameline(cmd, "MSP432P401x pre-production device (deprecated silicon)\n"
SUPPORT_MESSAGE);
target_write_u32(target, 0xFFE89C0C, key_set[i]);
}
- if (ERROR_OK == tms470_check_flash_unlocked(target)) {
+ if (tms470_check_flash_unlocked(target) == ERROR_OK) {
/*
* There seems to be a side-effect of reading the FMPKEY
* register in that it re-enables the protection. So we
unsigned *_radix)
{
unsigned radix = *_radix;
- if (0 != radix)
+ if (radix != 0)
return;
const char *str = *_str;
unsigned str_len = *_str_len;
struct jim_nvp *jim_nvp_name2value_simple(const struct jim_nvp *p, const char *name)
{
while (p->name) {
- if (0 == strcmp(name, p->name))
+ if (strcmp(name, p->name) == 0)
break;
p++;
}
struct jim_nvp *jim_nvp_name2value_nocase_simple(const struct jim_nvp *p, const char *name)
{
while (p->name) {
- if (0 == strcasecmp(name, p->name))
+ if (strcasecmp(name, p->name) == 0)
break;
p++;
}
if (retcode < 0)
retcode = 0;
for (i = 0; i < n_handles; i++) {
- if (WAIT_OBJECT_0 == WaitForSingleObject(handles[i], 0)) {
+ if (WaitForSingleObject(handles[i], 0) == WAIT_OBJECT_0) {
if (SAFE_FD_ISSET(handle_slot_to_fd[i], rfds)) {
DWORD bytes;
intptr_t handle = (intptr_t) _get_osfhandle(
{
struct timeval end;
int retval = gettimeofday(&end, NULL);
- if (0 == retval)
+ if (retval == 0)
timeval_subtract(&duration->elapsed, &end, &duration->start);
return retval;
}
*/
static int aice_init(void)
{
- if (ERROR_OK != aice_port->api->open(¶m)) {
+ if (aice_port->api->open(¶m) != ERROR_OK) {
LOG_ERROR("Cannot find AICE Interface! Please check "
"connection and permissions.");
return ERROR_JTAG_INIT_FAILED;
int i;
for (i = 0 ; i < AICE_KHZ_TO_SPEED_MAP_SIZE ; i++) {
if (khz == aice_khz_to_speed_map[i]) {
- if (8 <= i)
+ if (i >= 8)
*jtag_speed = i | AICE_TCK_CONTROL_TCK3048;
else
*jtag_speed = i;
aice_read_misc(coreid, NDS_EDM_MISC_DBGER, &value_dbger);
if ((value_dbger & expect_status) == expect_status) {
- if (ERROR_OK != check_suppressed_exception(coreid, value_dbger))
+ if (check_suppressed_exception(coreid, value_dbger) != ERROR_OK)
return ERROR_FAIL;
- if (ERROR_OK != check_privilege(coreid, value_dbger))
+ if (check_privilege(coreid, value_dbger) != ERROR_OK)
return ERROR_FAIL;
return ERROR_OK;
}
uint32_t instructions[4]; /** execute instructions in DIM */
- if (NDS32_REG_TYPE_GPR == nds32_reg_type(num)) { /* general registers */
+ if (nds32_reg_type(num) == NDS32_REG_TYPE_GPR) { /* general registers */
instructions[0] = MTSR_DTR(num);
instructions[1] = DSB;
instructions[2] = NOP;
instructions[3] = BEQ_MINUS_12;
- } else if (NDS32_REG_TYPE_SPR == nds32_reg_type(num)) { /* user special registers */
+ } else if (nds32_reg_type(num) == NDS32_REG_TYPE_SPR) { /* user special registers */
instructions[0] = MFUSR_G0(0, nds32_reg_sr_index(num));
instructions[1] = MTSR_DTR(0);
instructions[2] = DSB;
instructions[3] = BEQ_MINUS_12;
- } else if (NDS32_REG_TYPE_AUMR == nds32_reg_type(num)) { /* audio registers */
- if ((CB_CTL <= num) && (num <= CBE3)) {
+ } else if (nds32_reg_type(num) == NDS32_REG_TYPE_AUMR) { /* audio registers */
+ if ((num >= CB_CTL) && (num <= CBE3)) {
instructions[0] = AMFAR2(0, nds32_reg_sr_index(num));
instructions[1] = MTSR_DTR(0);
instructions[2] = DSB;
instructions[2] = DSB;
instructions[3] = BEQ_MINUS_12;
}
- } else if (NDS32_REG_TYPE_FPU == nds32_reg_type(num)) { /* fpu registers */
+ } else if (nds32_reg_type(num) == NDS32_REG_TYPE_FPU) { /* fpu registers */
if (num == FPCSR) {
instructions[0] = FMFCSR;
instructions[1] = MTSR_DTR(0);
} else if ((core_info[coreid].target_dtr_valid == true) && (num == DR43)) {
*val = core_info[coreid].target_dtr_backup;
} else {
- if (ERROR_OK != aice_read_reg(coreid, num, val))
+ if (aice_read_reg(coreid, num, val) != ERROR_OK)
*val = 0xBBADBEEF;
}
return ERROR_FAIL;
}
- if (NDS32_REG_TYPE_GPR == nds32_reg_type(num)) { /* general registers */
+ if (nds32_reg_type(num) == NDS32_REG_TYPE_GPR) { /* general registers */
instructions[0] = MFSR_DTR(num);
instructions[1] = DSB;
instructions[2] = NOP;
instructions[3] = BEQ_MINUS_12;
- } else if (NDS32_REG_TYPE_SPR == nds32_reg_type(num)) { /* user special registers */
+ } else if (nds32_reg_type(num) == NDS32_REG_TYPE_SPR) { /* user special registers */
instructions[0] = MFSR_DTR(0);
instructions[1] = MTUSR_G0(0, nds32_reg_sr_index(num));
instructions[2] = DSB;
instructions[3] = BEQ_MINUS_12;
- } else if (NDS32_REG_TYPE_AUMR == nds32_reg_type(num)) { /* audio registers */
- if ((CB_CTL <= num) && (num <= CBE3)) {
+ } else if (nds32_reg_type(num) == NDS32_REG_TYPE_AUMR) { /* audio registers */
+ if ((num >= CB_CTL) && (num <= CBE3)) {
instructions[0] = MFSR_DTR(0);
instructions[1] = AMTAR2(0, nds32_reg_sr_index(num));
instructions[2] = DSB;
instructions[2] = DSB;
instructions[3] = BEQ_MINUS_12;
}
- } else if (NDS32_REG_TYPE_FPU == nds32_reg_type(num)) { /* fpu registers */
+ } else if (nds32_reg_type(num) == NDS32_REG_TYPE_FPU) { /* fpu registers */
if (num == FPCSR) {
instructions[0] = MFSR_DTR(0);
instructions[1] = FMTCSR;
uint32_t value;
uint32_t high_value;
- if (ERROR_OK != aice_read_reg(coreid, num, &value))
+ if (aice_read_reg(coreid, num, &value) != ERROR_OK)
value = 0xBBADBEEF;
aice_read_reg(coreid, R1, &high_value);
static int aice_open_device(struct aice_port_param_s *param)
{
- if (ERROR_OK != aice_usb_open(param))
+ if (aice_usb_open(param) != ERROR_OK)
return ERROR_FAIL;
- if (ERROR_FAIL == aice_get_version_info()) {
+ if (aice_get_version_info() == ERROR_FAIL) {
LOG_ERROR("Cannot get AICE version!");
return ERROR_FAIL;
}
LOG_INFO("AICE initialization started");
/* attempt to reset Andes EDM */
- if (ERROR_FAIL == aice_reset_box()) {
+ if (aice_reset_box() == ERROR_FAIL) {
LOG_ERROR("Cannot initial AICE box!");
return ERROR_FAIL;
}
{
jtag_clock = a_clock;
- if (ERROR_OK != aice_usb_set_clock(a_clock)) {
+ if (aice_usb_set_clock(a_clock) != ERROR_OK) {
LOG_ERROR("Cannot set AICE JTAG clock!");
return ERROR_FAIL;
}
/* Clear CRST */
aice_write_misc(coreid, NDS_EDM_MISC_DBGER, NDS_DBGER_CRST);
} else if ((dbger_value & NDS_DBGER_DEX) == NDS_DBGER_DEX) {
- if (AICE_TARGET_RUNNING == core_info[coreid].core_state) {
+ if (core_info[coreid].core_state == AICE_TARGET_RUNNING) {
/* enter debug mode, init EDM registers */
/* backup EDM registers */
aice_backup_edm_registers(coreid);
aice_init_edm_registers(coreid, true);
aice_backup_tmp_registers(coreid);
core_info[coreid].core_state = AICE_TARGET_HALTED;
- } else if (AICE_TARGET_UNKNOWN == core_info[coreid].core_state) {
+ } else if (core_info[coreid].core_state == AICE_TARGET_UNKNOWN) {
/* debug 'debug mode', use force debug to halt core */
aice_usb_halt(coreid);
}
if (srst == AICE_SRST)
result = aice_issue_srst(coreid);
else {
- if (1 == total_num_of_core)
+ if (total_num_of_core == 1)
result = aice_issue_reset_hold(coreid);
else
result = aice_issue_reset_hold_multi();
aice_write_reg(coreid, ir0_reg_num, ir0_value);
}
- if (ERROR_FAIL == aice_usb_run(coreid))
+ if (aice_usb_run(coreid) == ERROR_FAIL)
return ERROR_FAIL;
int i = 0;
", size: %" PRIu32 ", count: %" PRIu32 "",
addr, size, count);
- if (NDS_MEMORY_ACC_CPU == core_info[coreid].access_channel)
+ if (core_info[coreid].access_channel == NDS_MEMORY_ACC_CPU)
aice_usb_set_address_dim(coreid, addr);
uint32_t value;
switch (size) {
case 1:
- if (NDS_MEMORY_ACC_BUS == core_info[coreid].access_channel)
+ if (core_info[coreid].access_channel == NDS_MEMORY_ACC_BUS)
read_mem_func = aice_usb_read_mem_b_bus;
else
read_mem_func = aice_usb_read_mem_b_dim;
}
break;
case 2:
- if (NDS_MEMORY_ACC_BUS == core_info[coreid].access_channel)
+ if (core_info[coreid].access_channel == NDS_MEMORY_ACC_BUS)
read_mem_func = aice_usb_read_mem_h_bus;
else
read_mem_func = aice_usb_read_mem_h_dim;
}
break;
case 4:
- if (NDS_MEMORY_ACC_BUS == core_info[coreid].access_channel)
+ if (core_info[coreid].access_channel == NDS_MEMORY_ACC_BUS)
read_mem_func = aice_usb_read_mem_w_bus;
else
read_mem_func = aice_usb_read_mem_w_dim;
", size: %" PRIu32 ", count: %" PRIu32 "",
addr, size, count);
- if (NDS_MEMORY_ACC_CPU == core_info[coreid].access_channel)
+ if (core_info[coreid].access_channel == NDS_MEMORY_ACC_CPU)
aice_usb_set_address_dim(coreid, addr);
size_t i;
switch (size) {
case 1:
- if (NDS_MEMORY_ACC_BUS == core_info[coreid].access_channel)
+ if (core_info[coreid].access_channel == NDS_MEMORY_ACC_BUS)
write_mem_func = aice_usb_write_mem_b_bus;
else
write_mem_func = aice_usb_write_mem_b_dim;
}
break;
case 2:
- if (NDS_MEMORY_ACC_BUS == core_info[coreid].access_channel)
+ if (core_info[coreid].access_channel == NDS_MEMORY_ACC_BUS)
write_mem_func = aice_usb_write_mem_h_bus;
else
write_mem_func = aice_usb_write_mem_h_dim;
}
break;
case 4:
- if (NDS_MEMORY_ACC_BUS == core_info[coreid].access_channel)
+ if (core_info[coreid].access_channel == NDS_MEMORY_ACC_BUS)
write_mem_func = aice_usb_write_mem_w_bus;
else
write_mem_func = aice_usb_write_mem_w_dim;
int retval;
- if (NDS_MEMORY_ACC_CPU == core_info[coreid].access_channel)
+ if (core_info[coreid].access_channel == NDS_MEMORY_ACC_CPU)
aice_usb_set_address_dim(coreid, addr);
- if (NDS_MEMORY_ACC_CPU == core_info[coreid].access_channel)
+ if (core_info[coreid].access_channel == NDS_MEMORY_ACC_CPU)
retval = aice_usb_read_memory_unit(coreid, addr, 4, length / 4, buffer);
else
retval = aice_bulk_read_mem(coreid, addr, length / 4, buffer);
int retval;
- if (NDS_MEMORY_ACC_CPU == core_info[coreid].access_channel)
+ if (core_info[coreid].access_channel == NDS_MEMORY_ACC_CPU)
aice_usb_set_address_dim(coreid, addr);
- if (NDS_MEMORY_ACC_CPU == core_info[coreid].access_channel)
+ if (core_info[coreid].access_channel == NDS_MEMORY_ACC_CPU)
retval = aice_usb_write_memory_unit(coreid, addr, 4, length / 4, buffer);
else
retval = aice_bulk_write_mem(coreid, addr, length / 4, buffer);
static int aice_usb_read_debug_reg(uint32_t coreid, uint32_t addr, uint32_t *val)
{
- if (AICE_TARGET_HALTED == core_info[coreid].core_state) {
+ if (core_info[coreid].core_state == AICE_TARGET_HALTED) {
if (addr == NDS_EDM_SR_EDMSW) {
*val = core_info[coreid].edmsw_backup;
} else if (addr == NDS_EDM_SR_EDM_DTR) {
static int aice_usb_write_debug_reg(uint32_t coreid, uint32_t addr, const uint32_t val)
{
- if (AICE_TARGET_HALTED == core_info[coreid].core_state) {
+ if (core_info[coreid].core_state == AICE_TARGET_HALTED) {
if (addr == NDS_EDM_SR_EDM_DTR) {
core_info[coreid].host_dtr_backup = val;
core_info[coreid].edmsw_backup |= 0x2;
core_info[coreid].memory_select = mem_select;
- if (NDS_MEMORY_SELECT_AUTO != core_info[coreid].memory_select)
+ if (core_info[coreid].memory_select != NDS_MEMORY_SELECT_AUTO)
aice_write_misc(coreid, NDS_EDM_MISC_ACC_CTL,
core_info[coreid].memory_select - 1);
else
aice_read_reg(coreid, MR4, &value_mr4);
access_page_size = value_mr4 & 0xF;
- if (0 == access_page_size) { /* 4K page */
+ if (access_page_size == 0) { /* 4K page */
virtual_offset = virtual_address & 0x00000FFF;
physical_page_number = value_mr3 & 0xFFFFF000;
- } else if (1 == access_page_size) { /* 8K page */
+ } else if (access_page_size == 1) { /* 8K page */
virtual_offset = virtual_address & 0x00001FFF;
physical_page_number = value_mr3 & 0xFFFFE000;
- } else if (5 == access_page_size) { /* 1M page */
+ } else if (access_page_size == 5) { /* 1M page */
virtual_offset = virtual_address & 0x000FFFFF;
physical_page_number = value_mr3 & 0xFFF00000;
} else {
cache_index = (way_index << (dcache->log2_set + dcache->log2_line_size)) |
(set_index << dcache->log2_line_size);
- if (ERROR_OK != aice_write_dtr(coreid, cache_index))
+ if (aice_write_dtr(coreid, cache_index) != ERROR_OK)
return ERROR_FAIL;
- if (ERROR_OK != aice_execute_dim(coreid, instructions, 4))
+ if (aice_execute_dim(coreid, instructions, 4) != ERROR_OK)
return ERROR_FAIL;
}
}
cache_index = (way_index << (dcache->log2_set + dcache->log2_line_size)) |
(set_index << dcache->log2_line_size);
- if (ERROR_OK != aice_write_dtr(coreid, cache_index))
+ if (aice_write_dtr(coreid, cache_index) != ERROR_OK)
return ERROR_FAIL;
- if (ERROR_OK != aice_execute_dim(coreid, instructions, 4))
+ if (aice_execute_dim(coreid, instructions, 4) != ERROR_OK)
return ERROR_FAIL;
}
}
cache_index = (way_index << (icache->log2_set + icache->log2_line_size)) |
(set_index << icache->log2_line_size);
- if (ERROR_OK != aice_write_dtr(coreid, cache_index))
+ if (aice_write_dtr(coreid, cache_index) != ERROR_OK)
return ERROR_FAIL;
- if (ERROR_OK != aice_execute_dim(coreid, instructions, 4))
+ if (aice_execute_dim(coreid, instructions, 4) != ERROR_OK)
return ERROR_FAIL;
}
}
aice_read_dtr_to_buffer(coreid, AICE_BATCH_DATA_BUFFER_0);
/* get samples */
- if (NDS32_REG_TYPE_GPR == nds32_reg_type(reg_no)) {
+ if (nds32_reg_type(reg_no) == NDS32_REG_TYPE_GPR) {
/* general registers */
dim_instructions[0] = MTSR_DTR(reg_no);
dim_instructions[1] = DSB;
dim_instructions[2] = NOP;
dim_instructions[3] = BEQ_MINUS_12;
- } else if (NDS32_REG_TYPE_SPR == nds32_reg_type(reg_no)) {
+ } else if (nds32_reg_type(reg_no) == NDS32_REG_TYPE_SPR) {
/* user special registers */
dim_instructions[0] = MFUSR_G0(0, nds32_reg_sr_index(reg_no));
dim_instructions[1] = MTSR_DTR(0);
struct jtag_tap *t = jtag_all_taps();
while (t) {
- if (0 == strcmp(t->dotted_name, s))
+ if (strcmp(t->dotted_name, s) == 0)
return t;
t = t->next_tap;
}
return true;
/* treat "-expected-id 0" as a "don't-warn" wildcard */
- if (0 == tap->expected_ids[ii])
+ if (tap->expected_ids[ii] == 0)
return true;
}
int bit_index = tap_chain_index % 8;
uint8_t bit = 1 << bit_index;
- if (0 == bit_index) {
+ if (bit_index == 0) {
/* Let's say that the TAP shift operation wants to shift 9 bits,
so we will be sending to the Bus Pirate a bit count of 9 but still
full 16 bits (2 bytes) of shift data.
/* set the serial port parameters */
fcntl(fd, F_SETFL, 0);
- if (0 != tcgetattr(fd, &t_opt))
+ if (tcgetattr(fd, &t_opt) != 0)
return -1;
- if (0 != cfsetispeed(&t_opt, baud))
+ if (cfsetispeed(&t_opt, baud) != 0)
return -1;
- if (0 != cfsetospeed(&t_opt, baud))
+ if (cfsetospeed(&t_opt, baud) != 0)
return -1;
t_opt.c_cflag |= (CLOCAL | CREAD);
/* Note that, in the past, TCSANOW was used below instead of TCSADRAIN,
and CMD_UART_SPEED did not work properly then, at least with
the Bus Pirate v3.5 (USB). */
- if (0 != tcsetattr(fd, TCSADRAIN, &t_opt)) {
+ if (tcsetattr(fd, TCSADRAIN, &t_opt) != 0) {
/* According to the Linux documentation, this is actually not enough
to detect errors, you need to call tcgetattr() and check that
all changes have been performed successfully. */
while (cur_dev) {
bool found = false;
- if (0 == vids[0]) {
+ if (vids[0] == 0) {
if (!cur_dev->product_string) {
LOG_DEBUG("Cannot read product string of device 0x%x:0x%x",
cur_dev->vendor_id, cur_dev->product_id);
return ERROR_FAIL;
}
- if (ERROR_OK != usbtoxxx_validate_current_command_type()) {
+ if (usbtoxxx_validate_current_command_type() != ERROR_OK) {
LOG_BUG(ERRMSG_FAILURE_OPERATION, "validate previous commands");
versaloon_free_want_pos();
return ERRCODE_FAILURE_OPERATION;
}
- if (3 == usbtoxxx_buffer_index) {
+ if (usbtoxxx_buffer_index == 3) {
versaloon_free_want_pos();
return ERROR_OK;
}
versaloon_buf[0] = USB_TO_ALL;
SET_LE_U16(&versaloon_buf[1], usbtoxxx_buffer_index);
- if (ERROR_OK != versaloon_send_command(usbtoxxx_buffer_index, &inlen)) {
+ if (versaloon_send_command(usbtoxxx_buffer_index, &inlen) != ERROR_OK) {
versaloon_free_want_pos();
return ERROR_FAIL;
}
usbtoxxx_buffer_index = 0;
for (i = 0; i < versaloon_pending_idx; i++) {
/* check result */
- if ((0 == i) || !((versaloon_pending[i].collect)
+ if ((i == 0) || !((versaloon_pending[i].collect)
&& (versaloon_pending[i - 1].collect)
&& (versaloon_pending[i].cmd
== versaloon_pending[i - 1].cmd))) {
"current dongle");
result = ERROR_FAIL;
break;
- } else if (USB_TO_XXX_OK != versaloon_buf[usbtoxxx_buffer_index]) {
+ } else if (versaloon_buf[usbtoxxx_buffer_index] != USB_TO_XXX_OK) {
LOG_ERROR("%s command 0x%02x failed with 0x%02x",
usbtoxxx_get_type_name(versaloon_pending[i].type),
versaloon_pending[i].cmd,
{
versaloon_pending_idx = 0;
- if ((ERROR_OK != usbtoinfo_get_abilities(usbtoxxx_abilities)) ||
- (ERROR_OK != usbtoxxx_execute_command()))
+ if ((usbtoinfo_get_abilities(usbtoxxx_abilities) != ERROR_OK) ||
+ (usbtoxxx_execute_command() != ERROR_OK))
return ERROR_FAIL;
LOG_INFO("USB_TO_XXX abilities: 0x%08X:0x%08X:0x%08X",
GET_LE_U32(&usbtoxxx_abilities[0]),
memset(&context_tmp, 0, sizeof(context_tmp));
if (poll_nesting) {
- if (0 == poll_context.type_pre) {
+ if (poll_context.type_pre == 0) {
LOG_BUG("USB_TO_POLL toooooo long");
return ERROR_OK;
}
/* 3 more bytes by usbtoxxx_validate_current_command_type */
/* 3 more bytes when ((0 == collect_index) || (collect_cmd != cmd)) */
- if (ERROR_OK != usbtoxxx_ensure_buffer_size(cmdlen + 6))
+ if (usbtoxxx_ensure_buffer_size(cmdlen + 6) != ERROR_OK)
return ERROR_FAIL;
if ((type_pre != type) || (!usbtoxxx_buffer)) {
- if (ERROR_OK != usbtoxxx_validate_current_command_type()) {
+ if (usbtoxxx_validate_current_command_type() != ERROR_OK) {
LOG_BUG(ERRMSG_FAILURE_OPERATION, "validate previous commands");
return ERRCODE_FAILURE_OPERATION;
}
type_pre = type;
}
- if ((0 == collect_index) || (collect_cmd != cmd)) {
+ if ((collect_index == 0) || (collect_cmd != cmd)) {
usbtoxxx_buffer[usbtoxxx_current_cmd_index++] = cmd;
if (collect) {
RESULT usbtoinfo_get_abilities(uint8_t abilities[USB_TO_XXX_ABILITIES_LEN])
{
- if (ERROR_OK != usbtoxxx_ensure_buffer_size(3))
+ if (usbtoxxx_ensure_buffer_size(3) != ERROR_OK)
return ERROR_FAIL;
- if (ERROR_OK != usbtoxxx_validate_current_command_type()) {
+ if (usbtoxxx_validate_current_command_type() != ERROR_OK) {
LOG_BUG(ERRMSG_FAILURE_OPERATION, "validate previous commands");
return ERRCODE_FAILURE_OPERATION;
}
RESULT usbtopoll_start(uint16_t retry_cnt, uint16_t interval_us)
{
- if (ERROR_OK != usbtoxxx_ensure_buffer_size(3 + 5))
+ if (usbtoxxx_ensure_buffer_size(3 + 5) != ERROR_OK)
return ERROR_FAIL;
if (!poll_nesting)
usbtoxxx_save_context(&poll_context);
- if (ERROR_OK != usbtoxxx_validate_current_command_type()) {
+ if (usbtoxxx_validate_current_command_type() != ERROR_OK) {
LOG_BUG(ERRMSG_FAILURE_OPERATION, "validate previous commands");
return ERRCODE_FAILURE_OPERATION;
}
LOG_BUG(ERRMSG_FAILURE_OPERATION, "check poll nesting");
return ERRCODE_FAILURE_OPERATION;
}
- if (ERROR_OK != usbtoxxx_ensure_buffer_size(3 + 1))
+ if (usbtoxxx_ensure_buffer_size(3 + 1) != ERROR_OK)
return ERROR_FAIL;
- if (ERROR_OK != usbtoxxx_validate_current_command_type()) {
+ if (usbtoxxx_validate_current_command_type() != ERROR_OK) {
LOG_BUG(ERRMSG_FAILURE_OPERATION, "validate previous commands");
return ERRCODE_FAILURE_OPERATION;
}
LOG_BUG(ERRMSG_FAILURE_OPERATION, "check poll nesting");
return ERRCODE_FAILURE_OPERATION;
}
- if (ERROR_OK != usbtoxxx_ensure_buffer_size(3 + 4 + 2 * size))
+ if (usbtoxxx_ensure_buffer_size(3 + 4 + 2 * size) != ERROR_OK)
return ERROR_FAIL;
- if (ERROR_OK != usbtoxxx_validate_current_command_type()) {
+ if (usbtoxxx_validate_current_command_type() != ERROR_OK) {
LOG_BUG(ERRMSG_FAILURE_OPERATION, "validate previous commands");
return ERRCODE_FAILURE_OPERATION;
}
LOG_BUG(ERRMSG_FAILURE_OPERATION, "check poll nesting");
return ERRCODE_FAILURE_OPERATION;
}
- if (ERROR_OK != usbtoxxx_ensure_buffer_size(3 + 4 + 2 * size))
+ if (usbtoxxx_ensure_buffer_size(3 + 4 + 2 * size) != ERROR_OK)
return ERROR_FAIL;
- if (ERROR_OK != usbtoxxx_validate_current_command_type()) {
+ if (usbtoxxx_validate_current_command_type() != ERROR_OK) {
LOG_BUG(ERRMSG_FAILURE_OPERATION, "validate previous commands");
return ERRCODE_FAILURE_OPERATION;
}
LOG_BUG(ERRMSG_FAILURE_OPERATION, "check poll nesting");
return ERRCODE_FAILURE_OPERATION;
}
- if (ERROR_OK != usbtoxxx_ensure_buffer_size(3 + 5 + size))
+ if (usbtoxxx_ensure_buffer_size(3 + 5 + size) != ERROR_OK)
return ERROR_FAIL;
- if (ERROR_OK != usbtoxxx_validate_current_command_type()) {
+ if (usbtoxxx_validate_current_command_type() != ERROR_OK) {
LOG_BUG(ERRMSG_FAILURE_OPERATION, "validate previous commands");
return ERRCODE_FAILURE_OPERATION;
}
RESULT usbtodelay_delay(uint16_t dly)
{
- if (ERROR_OK != usbtoxxx_ensure_buffer_size(3 + 2))
+ if (usbtoxxx_ensure_buffer_size(3 + 2) != ERROR_OK)
return ERROR_FAIL;
- if (ERROR_OK != usbtoxxx_validate_current_command_type()) {
+ if (usbtoxxx_validate_current_command_type() != ERROR_OK) {
LOG_BUG(ERRMSG_FAILURE_OPERATION, "validate previous commands");
return ERRCODE_FAILURE_OPERATION;
}
LOG_BUG(ERRMSG_INVALID_BUFFER, TO_STR(versaloon_buf));
return ERRCODE_INVALID_BUFFER;
}
- if ((0 == out_len) || (out_len > versaloon_interface.usb_setting.buf_size)) {
+ if ((out_len == 0) || (out_len > versaloon_interface.usb_setting.buf_size)) {
LOG_BUG(ERRMSG_INVALID_PARAMETER, __func__);
return ERRCODE_INVALID_PARAMETER;
}
versaloon_interface.usb_setting.ep_in,
versaloon_buf, versaloon_interface.usb_setting.buf_size,
&transferred, versaloon_usb_to);
- if (0 == ret) {
+ if (ret == 0) {
*inlen = (uint16_t)transferred;
return ERROR_OK;
} else {
versaloon_usb_to = 100;
for (retry = 0; retry < VERSALOON_RETRY_CNT; retry++) {
versaloon_buf[0] = VERSALOON_GET_INFO;
- if ((ERROR_OK == versaloon_send_command(1, &ret)) && (ret >= 3))
+ if ((versaloon_send_command(1, &ret) == ERROR_OK) && (ret >= 3))
break;
}
versaloon_usb_to = timeout_tmp;
LOG_ERROR(ERRMSG_NOT_ENOUGH_MEMORY);
return ERRCODE_NOT_ENOUGH_MEMORY;
}
- if (ERROR_OK != usbtoxxx_init()) {
+ if (usbtoxxx_init() != ERROR_OK) {
LOG_ERROR(ERRMSG_FAILURE_OPERATION, "initialize usbtoxxx");
return ERROR_FAIL;
}
versaloon_buf[0] = VERSALOON_GET_TVCC;
- if ((ERROR_OK != versaloon_send_command(1, &inlen)) || (inlen != 2)) {
+ if ((versaloon_send_command(1, &inlen) != ERROR_OK) || (inlen != 2)) {
LOG_ERROR(ERRMSG_FAILURE_OPERATION, "communicate with versaloon");
return ERRCODE_FAILURE_OPERATION;
} else {
libusb_init(&vsllink_handle->libusb_ctx);
- if (ERROR_OK != vsllink_usb_open(vsllink_handle)) {
+ if (vsllink_usb_open(vsllink_handle) != ERROR_OK) {
LOG_ERROR("Can't find USB JTAG Interface!"
"Please check connection and permissions.");
return ERROR_JTAG_INIT_FAILED;
versaloon_interface.usb_setting.pid);
versaloon_usb_device_handle = vsllink_handle->usb_device_handle;
- if (ERROR_OK != versaloon_interface.init())
+ if (versaloon_interface.init() != ERROR_OK)
return ERROR_FAIL;
if (versaloon_interface.usb_setting.buf_size < 32) {
versaloon_interface.fini();
GPIO_TRST, GPIO_SRST, GPIO_SRST);
}
- if (ERROR_OK != versaloon_interface.adaptors.peripheral_commit())
+ if (versaloon_interface.adaptors.peripheral_commit() != ERROR_OK)
return ERROR_FAIL;
vsllink_reset(0, 0);
/* Initialize libusb context */
result = libusb_init(&ctx);
- if (0 == result) {
+ if (result == 0) {
/* Get list of USB devices attached to system */
count = libusb_get_device_list(ctx, &list);
if (count <= 0) {
}
}
- if (0 == result) {
+ if (result == 0) {
/* Scan through list of devices for any XDS110s */
for (i = 0; i < count; i++) {
/* Check for device vid/pid match */
}
if (match) {
result = libusb_open(list[i], &dev);
- if (0 == result) {
+ if (result == 0) {
const int max_data = 256;
unsigned char data[max_data + 1];
*data = '\0';
/* May be the requested device if serial number matches */
- if (0 == xds110.serial[0]) {
+ if (xds110.serial[0] == 0) {
/* No serial number given; match first XDS110 found */
found = true;
break;
}
/* On an error, clean up what we can */
- if (0 != result) {
+ if (result != 0) {
if (dev) {
/* Release the debug and data interface on the XDS110 */
(void)libusb_release_interface(dev, xds110.interface);
}
/* Log the results */
- if (0 == result)
+ if (result == 0)
LOG_INFO("XDS110: connected");
else
LOG_ERROR("XDS110: failed to connect");
- return (0 == result) ? true : false;
+ return (result == 0) ? true : false;
}
static void usb_disconnect(void)
return false;
/* Force a non-zero timeout to prevent blocking */
- if (0 == timeout)
+ if (timeout == 0)
timeout = DEFAULT_TIMEOUT;
result = libusb_bulk_transfer(xds110.dev, xds110.endpoint_in, buffer, size,
bytes_read, timeout);
- return (0 == result) ? true : false;
+ return (result == 0) ? true : false;
}
static bool usb_write(unsigned char *buffer, int size, int *written)
if (!success)
error = SC_ERR_XDS110_FAIL;
- if (0 != error)
+ if (error != 0)
success = false;
return success;
uint32_t value;
bool success = true;
- if (0 == xds110.txn_request_size)
+ if (xds110.txn_request_size == 0)
return ERROR_OK;
/* Terminate request queue */
/* Transfer results into caller's buffers */
for (result = 0; result < xds110.txn_result_count; result++)
- if (0 != xds110.txn_dap_results[result])
+ if (xds110.txn_dap_results[result] != 0)
*xds110.txn_dap_results[result] = dap_results[result];
xds110.txn_request_size = 0;
(((firmware >> 12) & 0xf) * 10) + ((firmware >> 8) & 0xf),
(((firmware >> 4) & 0xf) * 10) + ((firmware >> 0) & 0xf));
LOG_INFO("XDS110: hardware version = 0x%04x", xds110.hardware);
- if (0 != xds110.serial[0])
+ if (xds110.serial[0] != 0)
LOG_INFO("XDS110: serial number = %s", xds110.serial);
if (xds110.is_swd_mode) {
LOG_INFO("XDS110: connected to target via SWD");
if (success) {
/* Set supply voltage for stand-alone probes */
- if (XDS110_STAND_ALONE_ID == xds110.hardware) {
+ if (xds110.hardware == XDS110_STAND_ALONE_ID) {
success = xds_set_supply(xds110.voltage);
/* Allow time for target device to power up */
/* (CC32xx takes up to 1300 ms before debug is enabled) */
alive_sleep(1500);
- } else if (0 != xds110.voltage) {
+ } else if (xds110.voltage != 0) {
/* Voltage supply not a feature of embedded probes */
LOG_WARNING(
"XDS110: ignoring supply voltage, not supported on this probe");
uint8_t data_in[MAX_DATA_BLOCK];
uint8_t *data_pntr;
- if (0 == xds110.txn_request_size)
+ if (xds110.txn_request_size == 0)
return;
/* Terminate request queue */
{
size_t i = 0;
while ((i < ARRAY_SIZE(embkernel_params_list)) &&
- (0 != strcmp(embkernel_params_list[i].target_name, target->type->name)))
+ (strcmp(embkernel_params_list[i].target_name, target->type->name) != 0))
i++;
if (i >= ARRAY_SIZE(embkernel_params_list)) {
{
/* check target name against supported architectures */
for (unsigned int i = 0; i < ARRAY_SIZE(mqx_params_list); i++) {
- if (0 == strcmp(mqx_params_list[i].target_name, target->type->name)) {
+ if (strcmp(mqx_params_list[i].target_name, target->type->name) == 0) {
target->rtos->rtos_specific_params = (void *)&mqx_params_list[i];
/* LOG_DEBUG("MQX RTOS - valid architecture: %s", target->type->name); */
return 0;
/* clear old data */
rtos_free_threadlist(rtos);
/* check scheduler */
- if (ERROR_OK != mqx_is_scheduler_running(rtos))
+ if (mqx_is_scheduler_running(rtos) != ERROR_OK)
return ERROR_FAIL;
/* get kernel_data symbol */
if (mqx_get_symbol(rtos, MQX_VAL_MQX_KERNEL_DATA, &kernel_data_addr) != ERROR_OK)
LOG_ERROR("MQX RTOS - invalid threadid: 0x%X", (int)thread_id);
return ERROR_FAIL;
}
- if (ERROR_OK != mqx_is_scheduler_running(rtos))
+ if (mqx_is_scheduler_running(rtos) != ERROR_OK)
return ERROR_FAIL;
/* get kernel_data symbol */
if (mqx_get_symbol(rtos, MQX_VAL_MQX_KERNEL_DATA, &kernel_data_addr) != ERROR_OK)
/* lookup if target is supported by RIOT */
while ((i < RIOT_NUM_PARAMS) &&
- (0 != strcmp(riot_params_list[i].target_name, target->type->name))) {
+ (strcmp(riot_params_list[i].target_name, target->type->name) != 0)) {
i++;
}
if (i >= RIOT_NUM_PARAMS) {
}
for (x = 0; rtos_types[x]; x++)
- if (0 == strcmp(cp, rtos_types[x]->name))
+ if (strcmp(cp, rtos_types[x]->name) == 0)
return os_alloc_create(target, rtos_types[x]);
Jim_SetResultFormatted(goi->interp, "Unknown RTOS type %s, try one of: ", cp);
LOG_DEBUG("-");
#endif
- if ((target->rtos) && (ERROR_OK == rtos_get_gdb_reg_list(connection)))
+ if ((target->rtos) && (rtos_get_gdb_reg_list(connection) == ERROR_OK))
return ERROR_OK;
retval = target_get_gdb_reg_list(target, ®_list, ®_list_size,
LOG_DEBUG("-");
#endif
- if ((target->rtos) && (ERROR_OK == rtos_get_gdb_reg(connection, reg_num)))
+ if ((target->rtos) && (rtos_get_gdb_reg(connection, reg_num) == ERROR_OK))
return ERROR_OK;
retval = target_get_gdb_reg_list_noread(target, ®_list, ®_list_size,
gdb_target_to_reg(target, separator + 1, chars, bin_buf);
if ((target->rtos) &&
- (ERROR_OK == rtos_set_reg(connection, reg_num, bin_buf))) {
+ (rtos_set_reg(connection, reg_num, bin_buf) == ERROR_OK)) {
free(bin_buf);
gdb_put_packet(connection, "OK", 2);
return ERROR_OK;
}
/* HDR %d TDI (0) */
- if (ERROR_OK != svf_set_padding(&svf_para.hdr_para, header_dr_len, 0)) {
+ if (svf_set_padding(&svf_para.hdr_para, header_dr_len, 0) != ERROR_OK) {
LOG_ERROR("failed to set data header");
return ERROR_FAIL;
}
/* HIR %d TDI (0xFF) */
- if (ERROR_OK != svf_set_padding(&svf_para.hir_para, header_ir_len, 0xFF)) {
+ if (svf_set_padding(&svf_para.hir_para, header_ir_len, 0xFF) != ERROR_OK) {
LOG_ERROR("failed to set instruction header");
return ERROR_FAIL;
}
/* TDR %d TDI (0) */
- if (ERROR_OK != svf_set_padding(&svf_para.tdr_para, trailer_dr_len, 0)) {
+ if (svf_set_padding(&svf_para.tdr_para, trailer_dr_len, 0) != ERROR_OK) {
LOG_ERROR("failed to set data trailer");
return ERROR_FAIL;
}
/* TIR %d TDI (0xFF) */
- if (ERROR_OK != svf_set_padding(&svf_para.tir_para, trailer_ir_len, 0xFF)) {
+ if (svf_set_padding(&svf_para.tir_para, trailer_ir_len, 0xFF) != ERROR_OK) {
LOG_ERROR("failed to set instruction trailer");
return ERROR_FAIL;
}
}
rewind(svf_fd);
}
- while (ERROR_OK == svf_read_command_from_file(svf_fd)) {
+ while (svf_read_command_from_file(svf_fd) == ERROR_OK) {
/* Log Output */
if (svf_quiet) {
if (svf_progress_enabled) {
LOG_USER_N("%s", svf_read_line);
}
/* Run Command */
- if (ERROR_OK != svf_run_command(CMD_CTX, svf_command_buffer)) {
+ if (svf_run_command(CMD_CTX, svf_command_buffer) != ERROR_OK) {
LOG_ERROR("fail to run command at line %d", svf_line_number);
ret = ERROR_FAIL;
break;
command_num++;
}
- if ((!svf_nil) && (ERROR_OK != jtag_execute_queue()))
+ if ((!svf_nil) && (jtag_execute_queue() != ERROR_OK))
ret = ERROR_FAIL;
- else if (ERROR_OK != svf_check_tdo())
+ else if (svf_check_tdo() != ERROR_OK)
ret = ERROR_FAIL;
/* print time */
int i, str_len = strlen(str), str_hbyte_len = (bit_len + 3) >> 2;
uint8_t ch = 0;
- if (ERROR_OK != svf_adjust_array_length(bin, orig_bit_len, bit_len)) {
+ if (svf_adjust_array_length(bin, orig_bit_len, bit_len) != ERROR_OK) {
LOG_ERROR("fail to adjust length of array");
return ERROR_FAIL;
}
static int svf_execute_tap(void)
{
- if ((!svf_nil) && (ERROR_OK != jtag_execute_queue()))
+ if ((!svf_nil) && (jtag_execute_queue() != ERROR_OK))
return ERROR_FAIL;
- else if (ERROR_OK != svf_check_tdo())
+ else if (svf_check_tdo() != ERROR_OK)
return ERROR_FAIL;
svf_buffer_index = 0;
/* flag padding commands skipped due to -tap command */
int padding_command_skipped = 0;
- if (ERROR_OK != svf_parse_cmd_string(cmd_str, strlen(cmd_str), argus, &num_of_argu))
+ if (svf_parse_cmd_string(cmd_str, strlen(cmd_str), argus, &num_of_argu) != ERROR_OK)
return ERROR_FAIL;
/* NOTE: we're a bit loose here, because we ignore case in
LOG_ERROR("invalid parameter of %s", argus[0]);
return ERROR_FAIL;
}
- if (1 == num_of_argu) {
+ if (num_of_argu == 1) {
/* TODO: set jtag speed to full speed */
svf_para.frequency = 0;
} else {
LOG_ERROR("HZ not found in FREQUENCY command");
return ERROR_FAIL;
}
- if (ERROR_OK != svf_execute_tap())
+ if (svf_execute_tap() != ERROR_OK)
return ERROR_FAIL;
svf_para.frequency = atof(argus[1]);
/* TODO: set jtag speed to */
return ERROR_FAIL;
}
/* OpenOCD refuses paths containing TAP_RESET */
- if (TAP_RESET == path[i]) {
+ if (path[i] == TAP_RESET) {
/* FIXME last state MUST be stable! */
if (i > 0) {
if (!svf_nil)
return ERROR_FAIL;
}
if (svf_para.trst_mode != TRST_ABSENT) {
- if (ERROR_OK != svf_execute_tap())
+ if (svf_execute_tap() != ERROR_OK)
return ERROR_FAIL;
i_tmp = svf_find_string_in_array(argus[1],
(char **)svf_trst_mode_name,
if ((svf_buffer_index > 0) &&
(((command != STATE) && (command != RUNTEST)) ||
((command == STATE) && (num_of_argu == 2)))) {
- if (ERROR_OK != svf_execute_tap())
+ if (svf_execute_tap() != ERROR_OK)
return ERROR_FAIL;
/* output debug info */
return ERROR_OK;
}
- while (CMD_ARGC > argp) {
+ while (argp < CMD_ARGC) {
n = jim_nvp_name2value_simple(nvp_ecatch_modes, CMD_ARGV[argp]);
if (!n->name) {
LOG_ERROR("Unknown option: %s", CMD_ARGV[argp]);
unsigned i;
struct x86_32_common *x86_32 = target_to_x86_32(t);
for (i = 0; i < (x86_32->cache->num_regs); i++) {
- if (NOT_AVAIL_REG == regs[i].pm_idx)
+ if (regs[i].pm_idx == NOT_AVAIL_REG)
continue;
err = read_hw_reg(t, regs[i].id, ®val, 1);
if (err != ERROR_OK) {
unsigned i;
struct x86_32_common *x86_32 = target_to_x86_32(t);
for (i = 0; i < (x86_32->cache->num_regs); i++) {
- if (NOT_AVAIL_REG == regs[i].pm_idx)
+ if (regs[i].pm_idx == NOT_AVAIL_REG)
continue;
err = write_hw_reg(t, i, 0, 1);
if (err != ERROR_OK) {
} else {
uint32_t val = 0;
if ((nds32->fpu_enable == false)
- && (NDS32_REG_TYPE_FPU == nds32_reg_type(mapped_regnum))) {
+ && (nds32_reg_type(mapped_regnum) == NDS32_REG_TYPE_FPU)) {
retval = ERROR_OK;
} else if ((nds32->audio_enable == false)
- && (NDS32_REG_TYPE_AUMR == nds32_reg_type(mapped_regnum))) {
+ && (nds32_reg_type(mapped_regnum) == NDS32_REG_TYPE_AUMR)) {
retval = ERROR_OK;
} else {
retval = aice_read_register(aice, mapped_regnum, &val);
} else {
uint64_t val = 0;
if ((nds32->fpu_enable == false)
- && ((FD0 <= reg_arch_info->num) && (reg_arch_info->num <= FD31))) {
+ && ((reg_arch_info->num >= FD0) && (reg_arch_info->num <= FD31))) {
retval = ERROR_OK;
} else {
retval = aice_read_reg_64(aice, reg_arch_info->num, &val);
{
uint32_t value;
- if (ERROR_OK == nds32_get_mapped_reg(nds32, MR8, &value)) {
+ if (nds32_get_mapped_reg(nds32, MR8, &value) == ERROR_OK) {
if (value & 0x1)
nds32->memory.icache.enable = true;
else
reg_arch_info->num, reg->name, value);
if ((nds32->fpu_enable == false) &&
- (NDS32_REG_TYPE_FPU == nds32_reg_type(mapped_regnum))) {
+ (nds32_reg_type(mapped_regnum) == NDS32_REG_TYPE_FPU)) {
buf_set_u32(reg->value, 0, 32, 0);
} else if ((nds32->audio_enable == false) &&
- (NDS32_REG_TYPE_AUMR == nds32_reg_type(mapped_regnum))) {
+ (nds32_reg_type(mapped_regnum) == NDS32_REG_TYPE_AUMR)) {
buf_set_u32(reg->value, 0, 32, 0);
} else {
}
if ((nds32->fpu_enable == false) &&
- ((FD0 <= reg_arch_info->num) && (reg_arch_info->num <= FD31))) {
+ ((reg_arch_info->num >= FD0) && (reg_arch_info->num <= FD31))) {
buf_set_u32(reg->value, 0, 32, 0);
buf_set_u32(reg->value, 32, 32, 0);
reg_list[i].type = &nds32_reg_access_type;
reg_list[i].group = "general";
- if ((FS0 <= reg_arch_info[i].num) && (reg_arch_info[i].num <= FS31)) {
+ if ((reg_arch_info[i].num >= FS0) && (reg_arch_info[i].num <= FS31)) {
reg_list[i].reg_data_type->type = REG_TYPE_IEEE_SINGLE;
reg_list[i].reg_data_type->id = "ieee_single";
reg_list[i].group = "float";
r = nds32_reg_current(nds32, regnum);
- if (ERROR_OK != r->type->get(r))
+ if (r->type->get(r) != ERROR_OK)
return ERROR_FAIL;
*value = buf_get_u32(r->value, 0, 32);
/* init end_address */
*end_address = address_end;
- if (NDS_MEMORY_ACC_CPU == memory->access_channel)
+ if (memory->access_channel == NDS_MEMORY_ACC_CPU)
return ERROR_OK;
if (edm->access_control == false) {
return ERROR_OK;
}
- if (NDS_MEMORY_SELECT_AUTO != memory->mode) {
+ if (memory->mode != NDS_MEMORY_SELECT_AUTO) {
LOG_DEBUG("Memory mode is not AUTO");
return ERROR_OK;
}
struct nds32 *nds32 = target_to_nds32(target);
struct nds32_memory *memory = &(nds32->memory);
- if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
+ if ((memory->access_channel == NDS_MEMORY_ACC_CPU) &&
(target->state != TARGET_HALTED)) {
LOG_WARNING("target was not halted");
return ERROR_TARGET_NOT_HALTED;
struct nds32 *nds32 = target_to_nds32(target);
struct nds32_memory *memory = &(nds32->memory);
- if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
+ if ((memory->access_channel == NDS_MEMORY_ACC_CPU) &&
(target->state != TARGET_HALTED)) {
LOG_WARNING("target was not halted");
return ERROR_TARGET_NOT_HALTED;
nds32->edm.breakpoint_num = (edm_cfg & 0x7) + 1;
- if ((nds32->edm.version & 0x1000) || (0x60 <= nds32->edm.version))
+ if ((nds32->edm.version & 0x1000) || (nds32->edm.version >= 0x60))
nds32->edm.access_control = true;
else
nds32->edm.access_control = false;
nds32_reg_init();
- if (ERROR_FAIL == nds32_reg_cache_init(target, nds32))
+ if (nds32_reg_cache_init(target, nds32) == ERROR_FAIL)
return ERROR_FAIL;
- if (ERROR_OK != nds32_init_register_table(nds32))
+ if (nds32_init_register_table(nds32) != ERROR_OK)
return ERROR_FAIL;
return ERROR_OK;
return ERROR_OK;
}
- if (ERROR_OK == nds32_probe_tlb(nds32, address, physical))
+ if (nds32_probe_tlb(nds32, address, physical) == ERROR_OK)
return ERROR_OK;
- if (ERROR_OK == nds32_walk_page_table(nds32, address, physical))
+ if (nds32_walk_page_table(nds32, address, physical) == ERROR_OK)
return ERROR_OK;
return ERROR_FAIL;
if (no_step == false) {
struct aice_port_s *aice = target_to_aice(target);
- if (ERROR_OK != aice_step(aice))
+ if (aice_step(aice) != ERROR_OK)
return ERROR_FAIL;
}
struct aice_port_s *aice = target_to_aice(target);
- if (ERROR_OK != aice_step(aice))
+ if (aice_step(aice) != ERROR_OK)
return ERROR_FAIL;
/* save state */
nds32_get_mapped_reg(nds32, PC, &value_pc);
- if (ERROR_OK != nds32_read_opcode(nds32, value_pc, &opcode))
+ if (nds32_read_opcode(nds32, value_pc, &opcode) != ERROR_OK)
return ERROR_FAIL;
if (nds32_evaluate_opcode(nds32, opcode, value_pc, &instruction) != ERROR_OK)
return ERROR_FAIL;
strcat(command_sequence, command_str);
}
- if (ERROR_OK != aice_program_edm(aice, command_sequence))
+ if (aice_program_edm(aice, command_sequence) != ERROR_OK)
return ERROR_FAIL;
/* get current privilege level */
return ERROR_FAIL;
sprintf(command_str, "write_misc %s 0x%" PRIx32 ";", reg_name, code);
- if (ERROR_OK != aice_program_edm(aice, command_str))
+ if (aice_program_edm(aice, command_str) != ERROR_OK)
return ERROR_FAIL;
}
}
if (state != TARGET_HALTED)
/* TODO: if state == TARGET_HALTED, check ETYPE is DBGI or not */
- if (ERROR_OK != aice_halt(aice))
+ if (aice_halt(aice) != ERROR_OK)
return ERROR_FAIL;
CHECK_RETVAL(nds32->enter_debug_state(nds32, true));
if (state == TARGET_HALTED) {
if (target->state != TARGET_HALTED) {
/* if false_hit, continue free_run */
- if (ERROR_OK != nds32->enter_debug_state(nds32, true)) {
+ if (nds32->enter_debug_state(nds32, true) != ERROR_OK) {
struct aice_port_s *aice = target_to_aice(target);
aice_run(aice);
return ERROR_OK;
int nds32_gdb_fileio_write_memory(struct nds32 *nds32, uint32_t address,
uint32_t size, const uint8_t *buffer)
{
- if ((NDS32_SYSCALL_FSTAT == nds32->active_syscall_id) ||
- (NDS32_SYSCALL_STAT == nds32->active_syscall_id)) {
+ if ((nds32->active_syscall_id == NDS32_SYSCALL_FSTAT) ||
+ (nds32->active_syscall_id == NDS32_SYSCALL_STAT)) {
/* If doing GDB file-I/O, target should convert 'struct stat'
* from gdb-format to target-format */
uint8_t stat_buffer[NDS32_STRUCT_STAT_SIZE];
stat_buffer[59] = 0;
return nds32_write_buffer(nds32->target, address, NDS32_STRUCT_STAT_SIZE, stat_buffer);
- } else if (NDS32_SYSCALL_GETTIMEOFDAY == nds32->active_syscall_id) {
+ } else if (nds32->active_syscall_id == NDS32_SYSCALL_GETTIMEOFDAY) {
/* If doing GDB file-I/O, target should convert 'struct timeval'
* from gdb-format to target-format */
uint8_t timeval_buffer[NDS32_STRUCT_TIMEVAL_SIZE];
read_addr = addr;
i = 0;
while (i < insn_count) {
- if (ERROR_OK != nds32_read_opcode(nds32, read_addr, &opcode))
+ if (nds32_read_opcode(nds32, read_addr, &opcode) != ERROR_OK)
return ERROR_FAIL;
if (nds32_evaluate_opcode(nds32, opcode, read_addr, &instruction) != ERROR_OK)
return ERROR_FAIL;
COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], addr);
- if (ERROR_OK != nds32_read_opcode(nds32, addr, &opcode))
+ if (nds32_read_opcode(nds32, addr, &opcode) != ERROR_OK)
return ERROR_FAIL;
- if (ERROR_OK != nds32_evaluate_opcode(nds32, opcode, addr, &instruction))
+ if (nds32_evaluate_opcode(nds32, opcode, addr, &instruction) != ERROR_OK)
return ERROR_FAIL;
command_print(CMD, "%s", instruction.text);
uint32_t max_level = nds32->max_interrupt_level;
uint32_t cur_level = nds32->current_interrupt_level;
- if ((1 <= cur_level) && (cur_level < max_level)) {
+ if ((cur_level >= 1) && (cur_level < max_level)) {
if (reg_no == IR0) {
LOG_DEBUG("Map PSW to IPSW");
return IR1;
LOG_DEBUG("Map PC to IPC");
return IR9;
}
- } else if ((2 <= cur_level) && (cur_level < max_level)) {
+ } else if ((cur_level >= 2) && (cur_level < max_level)) {
if (reg_no == R26) {
LOG_DEBUG("Mapping P0 to P_P0");
return IR12;
if (enable_watchpoint)
CHECK_RETVAL(nds32_v2_deactivate_hardware_watchpoint(nds32->target));
- if (ERROR_OK != nds32_examine_debug_reason(nds32)) {
+ if (nds32_examine_debug_reason(nds32) != ERROR_OK) {
nds32->target->state = backup_state;
/* re-activate all hardware breakpoints & watchpoints */
/* Following conditions need to do address translation
* 1. BUS mode
* 2. CPU mode under maximum interrupt level */
- if ((NDS_MEMORY_ACC_BUS == memory->access_channel) ||
- ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
+ if ((memory->access_channel == NDS_MEMORY_ACC_BUS) ||
+ ((memory->access_channel == NDS_MEMORY_ACC_CPU) &&
nds32_reach_max_interrupt_level(nds32))) {
- if (ERROR_OK == target->type->virt2phys(target, *address, &physical_address))
+ if (target->type->virt2phys(target, *address, &physical_address) == ERROR_OK)
*address = physical_address;
else
return ERROR_FAIL;
struct nds32 *nds32 = target_to_nds32(target);
struct nds32_memory *memory = &(nds32->memory);
- if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
+ if ((memory->access_channel == NDS_MEMORY_ACC_CPU) &&
(target->state != TARGET_HALTED)) {
LOG_WARNING("target was not halted");
return ERROR_TARGET_NOT_HALTED;
struct nds32 *nds32 = target_to_nds32(target);
struct nds32_memory *memory = &(nds32->memory);
- if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
+ if ((memory->access_channel == NDS_MEMORY_ACC_CPU) &&
(target->state != TARGET_HALTED)) {
LOG_WARNING("target was not halted");
return ERROR_TARGET_NOT_HALTED;
struct nds32 *nds32 = target_to_nds32(target);
struct nds32_memory *memory = &(nds32->memory);
- if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
+ if ((memory->access_channel == NDS_MEMORY_ACC_CPU) &&
(target->state != TARGET_HALTED)) {
LOG_WARNING("target was not halted");
return ERROR_TARGET_NOT_HALTED;
struct nds32 *nds32 = target_to_nds32(target);
struct nds32_memory *memory = &(nds32->memory);
- if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
+ if ((memory->access_channel == NDS_MEMORY_ACC_CPU) &&
(target->state != TARGET_HALTED)) {
LOG_WARNING("target was not halted");
return ERROR_TARGET_NOT_HALTED;
}
}
- if (ERROR_OK != nds32_examine_debug_reason(nds32)) {
+ if (nds32_examine_debug_reason(nds32) != ERROR_OK) {
nds32->target->state = backup_state;
/* re-activate all hardware breakpoints & watchpoints */
struct nds32 *nds32 = target_to_nds32(target);
struct nds32_memory *memory = &(nds32->memory);
- if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
+ if ((memory->access_channel == NDS_MEMORY_ACC_CPU) &&
(target->state != TARGET_HALTED)) {
LOG_WARNING("target was not halted");
return ERROR_TARGET_NOT_HALTED;
* Because hardware will turn off IT/DT by default, it MUST translate virtual address
* to physical address.
*/
- if (ERROR_OK == target->type->virt2phys(target, address, &physical_address))
+ if (target->type->virt2phys(target, address, &physical_address) == ERROR_OK)
address = physical_address;
else
return ERROR_FAIL;
struct nds32 *nds32 = target_to_nds32(target);
struct nds32_memory *memory = &(nds32->memory);
- if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
+ if ((memory->access_channel == NDS_MEMORY_ACC_CPU) &&
(target->state != TARGET_HALTED)) {
LOG_WARNING("target was not halted");
return ERROR_TARGET_NOT_HALTED;
* Because hardware will turn off IT/DT by default, it MUST translate virtual address
* to physical address.
*/
- if (ERROR_OK == target->type->virt2phys(target, address, &physical_address))
+ if (target->type->virt2phys(target, address, &physical_address) == ERROR_OK)
address = physical_address;
else
return ERROR_FAIL;
struct nds32 *nds32 = target_to_nds32(target);
struct nds32_memory *memory = &(nds32->memory);
- if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
+ if ((memory->access_channel == NDS_MEMORY_ACC_CPU) &&
(target->state != TARGET_HALTED)) {
LOG_WARNING("target was not halted");
return ERROR_TARGET_NOT_HALTED;
* Because hardware will turn off IT/DT by default, it MUST translate virtual address
* to physical address.
*/
- if (ERROR_OK == target->type->virt2phys(target, address, &physical_address))
+ if (target->type->virt2phys(target, address, &physical_address) == ERROR_OK)
address = physical_address;
else
return ERROR_FAIL;
struct nds32 *nds32 = target_to_nds32(target);
struct nds32_memory *memory = &(nds32->memory);
- if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
+ if ((memory->access_channel == NDS_MEMORY_ACC_CPU) &&
(target->state != TARGET_HALTED)) {
LOG_WARNING("target was not halted");
return ERROR_TARGET_NOT_HALTED;
* Because hardware will turn off IT/DT by default, it MUST translate virtual address
* to physical address.
*/
- if (ERROR_OK == target->type->virt2phys(target, address, &physical_address))
+ if (target->type->virt2phys(target, address, &physical_address) == ERROR_OK)
address = physical_address;
else
return ERROR_FAIL;
}
/* now does target type exist */
for (x = 0 ; target_types[x] ; x++) {
- if (0 == strcmp(cp, target_types[x]->name)) {
+ if (strcmp(cp, target_types[x]->name) == 0) {
/* found */
break;
}