if (cmd_ack_code != AICE_CMD_SCAN_CHAIN) {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_SCAN_CHAIN, cmd_ack_code);
return ERROR_FAIL;
}
LOG_DEBUG("READ_CTRL response, data: 0x%" PRIx32, *data);
if (cmd_ack_code != AICE_CMD_READ_CTRL) {
- LOG_ERROR("aice command error (command=0x%" PRIx32 ", response=0x%" PRIx8 ")",
- (uint32_t)AICE_CMD_READ_CTRL, cmd_ack_code);
+ LOG_ERROR("aice command error (command=0x%x, response=0x%" PRIx8 ")",
+ AICE_CMD_READ_CTRL, cmd_ack_code);
return ERROR_FAIL;
}
LOG_DEBUG("WRITE_CTRL response");
if (cmd_ack_code != AICE_CMD_WRITE_CTRL) {
- LOG_ERROR("aice command error (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command error (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_WRITE_CTRL, cmd_ack_code);
return ERROR_FAIL;
}
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_T_READ_DTR, cmd_ack_code);
return ERROR_FAIL;
}
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_READ_DTR_TO_BUFFER, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_T_WRITE_DTR, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_WRITE_DTR_FROM_BUFFER, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_T_READ_MISC, cmd_ack_code);
return ERROR_FAIL;
}
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_T_WRITE_MISC, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_T_READ_EDMSR, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_T_WRITE_EDMSR, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8
- ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_T_WRITE_DIM, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_T_EXECUTE, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_T_WRITE_MEM_B, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_T_WRITE_MEM_H, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_T_WRITE_MEM, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_T_FASTREAD_MEM, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_T_FASTWRITE_MEM, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_T_READ_MEM_B, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_T_READ_MEM_H, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_T_READ_MEM, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_BATCH_BUFFER_READ, cmd_ack_code);
return ERROR_FAIL;
break;
} else {
if (retry_times > aice_max_retry_times) {
- LOG_ERROR("aice command timeout (command=0x%" PRIx8 ", response=0x%" PRIx8 ")",
+ LOG_ERROR("aice command timeout (command=0x%x, response=0x%" PRIx8 ")",
AICE_CMD_BATCH_BUFFER_WRITE, cmd_ack_code);
return ERROR_FAIL;
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;
const uint16_t pids[] = { param->pid, 0 };
struct libusb_device_handle *devh;
- if (jtag_libusb_open(vids, pids, NULL, &devh, NULL) != ERROR_OK)
+ if (jtag_libusb_open(vids, pids, &devh, NULL) != ERROR_OK)
return ERROR_FAIL;
/* BE ***VERY CAREFUL*** ABOUT MAKING CHANGES IN THIS
/* reopen jlink after usb_reset
* on win32 this may take a second or two to re-enumerate */
int retval;
- while ((retval = jtag_libusb_open(vids, pids, NULL, &devh, NULL)) != ERROR_OK) {
+ while ((retval = jtag_libusb_open(vids, pids, &devh, NULL)) != ERROR_OK) {
usleep(1000);
timeout--;
if (!timeout)
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);
bool set_op;
script_fd = fopen(script, "r");
- if (script_fd == NULL) {
+ if (!script_fd) {
return ERROR_FAIL;
} else {
- while (fgets(line_buffer, LINE_BUFFER_SIZE, script_fd) != NULL) {
+ while (fgets(line_buffer, LINE_BUFFER_SIZE, script_fd)) {
/* execute operations */
set_op = false;
op_str = strstr(line_buffer, "set");
- if (op_str != NULL) {
+ if (op_str) {
set_op = true;
goto get_reset_type;
}
op_str = strstr(line_buffer, "clear");
- if (op_str == NULL)
+ if (!op_str)
continue;
get_reset_type:
reset_str = strstr(op_str, "srst");
- if (reset_str != NULL) {
+ if (reset_str) {
if (set_op)
write_ctrl_value = AICE_CUSTOM_DELAY_SET_SRST;
else
goto get_delay;
}
reset_str = strstr(op_str, "dbgi");
- if (reset_str != NULL) {
+ if (reset_str) {
if (set_op)
write_ctrl_value = AICE_CUSTOM_DELAY_SET_DBGI;
else
goto get_delay;
}
reset_str = strstr(op_str, "trst");
- if (reset_str != NULL) {
+ if (reset_str) {
if (set_op)
write_ctrl_value = AICE_CUSTOM_DELAY_SET_TRST;
else
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);
}
return ERROR_FAIL;
/* issue TRST */
- if (custom_trst_script == NULL) {
+ if (!custom_trst_script) {
if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
AICE_JTAG_PIN_CONTROL_TRST) != ERROR_OK)
return ERROR_FAIL;
/* After issuing srst, target will be running. So we need to restore EDM_CTL. */
aice_restore_edm_registers(coreid);
- if (custom_srst_script == NULL) {
+ if (!custom_srst_script) {
if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
AICE_JTAG_PIN_CONTROL_SRST) != ERROR_OK)
return ERROR_FAIL;
aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_STATUS, pin_status & (~0x4));
/* issue restart */
- if (custom_restart_script == NULL) {
+ if (!custom_restart_script) {
if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
AICE_JTAG_PIN_CONTROL_RESTART) != ERROR_OK)
return ERROR_FAIL;
aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_STATUS, pin_status | 0x4);
/* issue restart again */
- if (custom_restart_script == NULL) {
+ if (!custom_restart_script) {
if (aice_write_ctrl(AICE_WRITE_CTRL_JTAG_PIN_CONTROL,
AICE_JTAG_PIN_CONTROL_RESTART) != ERROR_OK)
return ERROR_FAIL;
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;
}
}
/* init strtok() */
command_str = strtok(command_sequence, ";");
- if (command_str == NULL)
+ if (!command_str)
return ERROR_OK;
do {
reg_name_0 = strstr(command_str, "gen_port0");
reg_name_1 = strstr(command_str, "gen_port1");
- if (reg_name_0 != NULL) {
+ if (reg_name_0) {
data_value = strtoul(reg_name_0 + 9, NULL, 0);
if (aice_write_misc(coreid,
NDS_EDM_MISC_GEN_PORT0, data_value) != ERROR_OK)
return ERROR_FAIL;
- } else if (reg_name_1 != NULL) {
+ } else if (reg_name_1) {
data_value = strtoul(reg_name_1 + 9, NULL, 0);
if (aice_write_misc(coreid,
/* update command_str */
command_str = strtok(NULL, ";");
- } while (command_str != NULL);
+ } while (command_str);
return ERROR_OK;
}
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);