OpenOCD
nds32.c File Reference
Include dependency graph for nds32.c:

Go to the source code of this file.

Functions

int nds32_add_software_breakpoint (struct target *target, struct breakpoint *breakpoint)
 
int nds32_arch_state (struct target *target)
 
int nds32_assert_reset (struct target *target)
 
static struct reg_cachends32_build_reg_cache (struct target *target, struct nds32 *nds32)
 
int nds32_cache_sync (struct target *target, target_addr_t address, uint32_t length)
 
static int nds32_callback_event_handler (struct target *target, enum target_event event, void *priv)
 
static int nds32_check_extension (struct nds32 *nds32)
 If fpu/audio is disabled, to access fpu/audio registers will cause exceptions. More...
 
int nds32_config (struct nds32 *nds32)
 
int nds32_edm_config (struct nds32 *nds32)
 
int nds32_examine_debug_reason (struct nds32 *nds32)
 
int nds32_full_context (struct nds32 *nds32)
 
static int nds32_gdb_attach (struct nds32 *nds32)
 
static int nds32_gdb_detach (struct nds32 *nds32)
 
int nds32_gdb_fileio_end (struct target *target, int retcode, int fileio_errno, bool ctrl_c)
 
int nds32_gdb_fileio_write_memory (struct nds32 *nds32, uint32_t address, uint32_t size, const uint8_t *buffer)
 
static int nds32_get_all_reg_list (struct nds32 *nds32, struct reg **reg_list[], int *reg_list_size)
 get all register list More...
 
static int nds32_get_core_reg (struct reg *reg)
 
static int nds32_get_core_reg_64 (struct reg *reg)
 
int nds32_get_gdb_fileio_info (struct target *target, struct gdb_fileio_info *fileio_info)
 
int nds32_get_gdb_reg_list (struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class)
 get all register list More...
 
static int nds32_get_general_reg_list (struct nds32 *nds32, struct reg **reg_list[], int *reg_list_size)
 get general register list More...
 
int nds32_get_mapped_reg (struct nds32 *nds32, unsigned regnum, uint32_t *value)
 
int nds32_halt (struct target *target)
 
int nds32_init (struct nds32 *nds32)
 
int nds32_init_arch_info (struct target *target, struct nds32 *nds32)
 
static void nds32_init_config (struct nds32 *nds32)
 
static int nds32_init_memory_config (struct nds32 *nds32)
 
static void nds32_init_must_have_registers (struct nds32 *nds32)
 
static int nds32_init_option_registers (struct nds32 *nds32)
 
int nds32_init_register_table (struct nds32 *nds32)
 
int nds32_login (struct nds32 *nds32)
 
int nds32_mmu (struct target *target, int *enabled)
 
uint32_t nds32_nextpc (struct nds32 *nds32, int current, uint32_t address)
 
int nds32_poll (struct target *target)
 
int nds32_profiling (struct target *target, uint32_t *samples, uint32_t max_num_samples, uint32_t *num_samples, uint32_t seconds)
 
int nds32_read_buffer (struct target *target, uint32_t address, uint32_t size, uint8_t *buffer)
 
int nds32_read_memory (struct target *target, uint32_t address, uint32_t size, uint32_t count, uint8_t *buffer)
 
int nds32_read_phys_memory (struct target *target, target_addr_t address, uint32_t size, uint32_t count, uint8_t *buffer)
 
static int nds32_reg_cache_init (struct target *target, struct nds32 *nds32)
 
static struct regnds32_reg_current (struct nds32 *nds32, unsigned regnum)
 
int nds32_remove_software_breakpoint (struct target *target, struct breakpoint *breakpoint)
 
int nds32_reset_halt (struct nds32 *nds32)
 
int nds32_restore_context (struct target *target)
 Restore the processor context on an Andes target. More...
 
int nds32_resume (struct target *target, int current, target_addr_t address, int handle_breakpoints, int debug_execution)
 
static int nds32_select_memory_mode (struct target *target, uint32_t address, uint32_t length, uint32_t *end_address)
 
static int nds32_set_core_reg (struct reg *reg, uint8_t *buf)
 
static int nds32_set_core_reg_64 (struct reg *reg, uint8_t *buf)
 
int nds32_set_mapped_reg (struct nds32 *nds32, unsigned regnum, uint32_t value)
 set register internally More...
 
static int nds32_soft_reset_halt (struct target *target)
 
int nds32_step (struct target *target, int current, target_addr_t address, int handle_breakpoints)
 
static int nds32_step_without_watchpoint (struct nds32 *nds32)
 
int nds32_target_state (struct nds32 *nds32, enum target_state *state)
 
static int nds32_update_cache_info (struct nds32 *nds32)
 
static int nds32_update_lm_info (struct nds32 *nds32)
 
static int nds32_update_mmu_info (struct nds32 *nds32)
 
static int nds32_update_psw (struct nds32 *nds32)
 
int nds32_virtual_to_physical (struct target *target, target_addr_t address, target_addr_t *physical)
 
int nds32_write_buffer (struct target *target, uint32_t address, uint32_t size, const uint8_t *buffer)
 
int nds32_write_memory (struct target *target, uint32_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
 
int nds32_write_phys_memory (struct target *target, target_addr_t address, uint32_t size, uint32_t count, const uint8_t *buffer)
 

Variables

const char * nds32_debug_type_name [11]
 
struct nds32_edm_operation nds32_edm_ops [NDS32_EDM_OPERATION_MAX_NUM]
 
uint32_t nds32_edm_ops_num
 
static const int nds32_line_size_table [6]
 
static const int nds32_lm_size_table [16]
 
static const struct reg_arch_type nds32_reg_access_type
 
static const struct reg_arch_type nds32_reg_access_type_64
 

Function Documentation

◆ nds32_add_software_breakpoint()

◆ nds32_arch_state()

◆ nds32_assert_reset()

◆ nds32_build_reg_cache()

◆ nds32_cache_sync()

◆ nds32_callback_event_handler()

static int nds32_callback_event_handler ( struct target target,
enum target_event  event,
void *  priv 
)
static

◆ nds32_check_extension()

static int nds32_check_extension ( struct nds32 nds32)
static

If fpu/audio is disabled, to access fpu/audio registers will cause exceptions.

So, we need to check if fpu/audio is enabled or not as target is halted. If fpu/audio is disabled, as users access fpu/audio registers, OpenOCD will return fake value 0 instead of accessing registers through DIM.

Definition at line 253 of file nds32.c.

References nds32::audio_enable, ERROR_OK, nds32::fpu_enable, FUCPR, nds32_get_mapped_reg(), and NDS32_REGISTER_DISABLE.

Referenced by nds32_full_context(), and nds32_set_core_reg().

◆ nds32_config()

◆ nds32_edm_config()

◆ nds32_examine_debug_reason()

◆ nds32_full_context()

◆ nds32_gdb_attach()

◆ nds32_gdb_detach()

◆ nds32_gdb_fileio_end()

int nds32_gdb_fileio_end ( struct target target,
int  retcode,
int  fileio_errno,
bool  ctrl_c 
)

◆ nds32_gdb_fileio_write_memory()

int nds32_gdb_fileio_write_memory ( struct nds32 nds32,
uint32_t  address,
uint32_t  size,
const uint8_t *  buffer 
)

◆ nds32_get_all_reg_list()

static int nds32_get_all_reg_list ( struct nds32 nds32,
struct reg **  reg_list[],
int *  reg_list_size 
)
static

get all register list

freed in gdb_server.c

Definition at line 573 of file nds32.c.

References reg::arch_info, nds32::core_cache, ERROR_OK, reg::exist, nds32_reg_current(), and reg_cache::num_regs.

Referenced by nds32_get_gdb_reg_list().

◆ nds32_get_core_reg()

◆ nds32_get_core_reg_64()

◆ nds32_get_gdb_fileio_info()

◆ nds32_get_gdb_reg_list()

int nds32_get_gdb_reg_list ( struct target target,
struct reg **  reg_list[],
int *  reg_list_size,
enum target_register_class  reg_class 
)

get all register list

Definition at line 596 of file nds32.c.

References ERROR_FAIL, nds32_get_all_reg_list(), nds32_get_general_reg_list(), REG_CLASS_ALL, REG_CLASS_GENERAL, and target_to_nds32().

◆ nds32_get_general_reg_list()

static int nds32_get_general_reg_list ( struct nds32 nds32,
struct reg **  reg_list[],
int *  reg_list_size 
)
static

get general register list

freed in gdb_server.c

Definition at line 549 of file nds32.c.

References reg::arch_info, ERROR_OK, IFC_LP, nds32_reg_current(), and R0.

Referenced by nds32_get_gdb_reg_list().

◆ nds32_get_mapped_reg()

◆ nds32_halt()

◆ nds32_init()

◆ nds32_init_arch_info()

◆ nds32_init_config()

static void nds32_init_config ( struct nds32 nds32)
static

Definition at line 1070 of file nds32.c.

References nds32_cpu_version::_16bit_extension, nds32_mmu_config::_8k_page_support, nds32_misc_config::addr_24, nds32_misc_config::audio_isa, nds32_misc_config::baseline_instruction, nds32_cpu_version::cop_fpu_extension, nds32_cpu_version::cpu_id_family, nds32_cpu_version::cpu_id_version, nds32::cpu_version, CR0, CR3, CR4, nds32_misc_config::debug_tracer, nds32_mmu_config::default_endian, nds32_misc_config::div_instruction, nds32_mmu_config::drde, nds32_misc_config::edm, nds32_misc_config::ex9, nds32_mmu_config::extra_page_size_support, nds32_mmu_config::fully_associative_tlb, nds32_mmu_config::hardware_page_table_walker, nds32_misc_config::high_speed_memory_port, nds32_misc_config::ifc, nds32_misc_config::implement_dependant_register, nds32_misc_config::implement_dependant_sr_encoding, nds32_misc_config::interruption_level, nds32_mmu_config::invisible_tlb, nds32_misc_config::l2_cache, nds32_misc_config::local_memory_dma, nds32_misc_config::mac_instruction, nds32_misc_config::mcu, nds32_mmu_config::memory_protection, nds32_mmu_config::memory_protection_version, nds32::misc_config, nds32::mmu_config, nds32_get_mapped_reg(), nds32_init_memory_config(), nds32_misc_config::no_dx_register, nds32_mmu_config::ntme, nds32_mmu_config::partition_num, nds32_cpu_version::performance_extension, nds32_cpu_version::performance_extension_2, nds32_misc_config::performance_monitor, nds32_misc_config::reduce_register, nds32_cpu_version::revision, nds32_misc_config::shadow, nds32_cpu_version::string_extension, nds32_mmu_config::tlb_lock, nds32_mmu_config::tlb_sets, nds32_mmu_config::tlb_size, nds32_mmu_config::tlb_ways, and nds32_mmu_config::vlpt.

Referenced by nds32_config().

◆ nds32_init_memory_config()

◆ nds32_init_must_have_registers()

static void nds32_init_must_have_registers ( struct nds32 nds32)
static

MUST have general registers

MUST have configuration system registers

MUST have interrupt system registers

MUST have MMU system registers

MUST have EDM system registers

Definition at line 992 of file nds32.c.

References reg::arch_info, nds32::core_cache, CR0, CR1, CR2, CR3, CR4, DR40, DR42, IR0, IR1, IR11, IR14, IR15, IR3, IR4, IR6, IR9, MR0, PC, R0, R1, R10, R15, R2, R28, R29, R3, R30, R31, R4, R5, R6, R7, R8, R9, and reg_cache::reg_list.

Referenced by nds32_init_register_table().

◆ nds32_init_option_registers()

static int nds32_init_option_registers ( struct nds32 nds32)
static

Definition at line 1139 of file nds32.c.

References ADM_VBASE, reg::arch_info, nds32_misc_config::audio_isa, nds32_edm::breakpoint_num, CB_CTL, CBB0, CBB1, CBB2, CBB3, CBE0, CBE1, CBE2, CBE3, nds32_cpu_version::cop_fpu_extension, nds32::core_cache, nds32_cpu_version::cpu_id_family, nds32::cpu_version, CR5, CR6, D0HI, D0L24, D0LO, D1HI, D1L24, D1LO, nds32_memory::dcache, nds32_misc_config::debug_tracer, nds32_memory::dlm_base, DMAR0, DMAR1, DMAR10, DMAR2, DMAR3, DMAR4, DMAR5, DMAR6, DMAR7, DMAR8, DMAR9, DR0, DR41, DR43, DR44, DR45, DR46, DR47, nds32_misc_config::edm, nds32::edm, nds32_reg::enable, ERROR_OK, nds32_misc_config::ex9, FPCFG, FPCSR, FUCPR, nds32_misc_config::high_speed_memory_port, I0, I1, I2, I3, I4, I5, I6, I7, nds32_memory::icache, IDR0, IDR1, nds32_misc_config::ifc, IFC_LP, nds32_memory::ilm_base, nds32_misc_config::interruption_level, IR1, IR10, IR12, IR13, IR16, IR17, IR18, IR19, IR2, IR20, IR21, IR22, IR23, IR24, IR25, IR26, IR27, IR28, IR29, IR3, IR30, IR4, IR5, IR7, IR8, IR9, ITB, LBE, LC, LE, nds32_cache::line_size, nds32_misc_config::local_memory_dma, M1, M2, M3, M5, M6, M7, nds32_misc_config::mcu, nds32::memory, nds32_mmu_config::memory_protection, nds32_mmu_config::memory_protection_version, nds32::misc_config, nds32::mmu_config, MOD, MR0, MR1, MR10, MR11, MR2, MR3, MR4, MR5, MR6, MR7, MR8, MR9, nds32_get_mapped_reg(), nds32_set_mapped_reg(), nds32_misc_config::no_dx_register, nds32_misc_config::performance_monitor, PFR0, PFR1, PFR2, PFR3, nds32::privilege_level, R11, R12, R13, R14, R16, R17, R18, R19, R20, R21, R22, R23, R24, R25, R26, R27, RACR, nds32_misc_config::reduce_register, reg_cache::reg_list, nds32_cpu_version::revision, SECUR0, nds32_misc_config::shadow, SHFT_CTL0, and SHFT_CTL1.

Referenced by nds32_config().

◆ nds32_init_register_table()

int nds32_init_register_table ( struct nds32 nds32)

Definition at line 1424 of file nds32.c.

References ERROR_OK, and nds32_init_must_have_registers().

Referenced by nds32_init_arch_info().

◆ nds32_login()

◆ nds32_mmu()

◆ nds32_nextpc()

uint32_t nds32_nextpc ( struct nds32 nds32,
int  current,
uint32_t  address 
)

Definition at line 1740 of file nds32.c.

References nds32_get_mapped_reg(), nds32_set_mapped_reg(), and PC.

Referenced by nds32_resume(), and nds32_step().

◆ nds32_poll()

◆ nds32_profiling()

int nds32_profiling ( struct target target,
uint32_t *  samples,
uint32_t  max_num_samples,
uint32_t *  num_samples,
uint32_t  seconds 
)

◆ nds32_read_buffer()

◆ nds32_read_memory()

int nds32_read_memory ( struct target target,
uint32_t  address,
uint32_t  size,
uint32_t  count,
uint8_t *  buffer 
)

Definition at line 804 of file nds32.c.

References aice_read_mem_unit(), buffer, count, size, and target_to_aice().

Referenced by nds32_v2_read_memory(), and nds32_v3_read_memory().

◆ nds32_read_phys_memory()

int nds32_read_phys_memory ( struct target target,
target_addr_t  address,
uint32_t  size,
uint32_t  count,
uint8_t *  buffer 
)

◆ nds32_reg_cache_init()

static int nds32_reg_cache_init ( struct target target,
struct nds32 nds32 
)
static

◆ nds32_reg_current()

static struct reg* nds32_reg_current ( struct nds32 nds32,
unsigned  regnum 
)
static

◆ nds32_remove_software_breakpoint()

◆ nds32_reset_halt()

int nds32_reset_halt ( struct nds32 nds32)

◆ nds32_restore_context()

int nds32_restore_context ( struct target target)

Restore the processor context on an Andes target.

The full processor context is analyzed to see if any of the registers are dirty on this end, but have a valid new value. If this is the case, the processor is changed to the appropriate mode and the new register values are written out to the processor. If there happens to be a dirty register with an invalid value, an error will be logged.

Parameters
targetPointer to the Andes target to have its context restored
Returns
Error status if the target is not halted.

Definition at line 1510 of file nds32.c.

References aice_write_reg_64(), aice_write_register(), reg::arch_info, buf_get_u32(), buf_get_u64(), nds32::core_cache, reg::dirty, ERROR_OK, ERROR_TARGET_NOT_HALTED, FD0, FD31, LOG_DEBUG, LOG_WARNING, reg::name, nds32_reg::num, reg_cache::num_regs, reg_cache::reg_list, target::state, TARGET_HALTED, target_to_aice(), target_to_nds32(), reg::valid, nds32_reg::value, and reg::value.

Referenced by nds32_v2_leave_debug_state(), and nds32_v3_leave_debug_state().

◆ nds32_resume()

◆ nds32_select_memory_mode()

◆ nds32_set_core_reg()

◆ nds32_set_core_reg_64()

static int nds32_set_core_reg_64 ( struct reg reg,
uint8_t *  buf 
)
static

Definition at line 339 of file nds32.c.

◆ nds32_set_mapped_reg()

◆ nds32_soft_reset_halt()

static int nds32_soft_reset_halt ( struct target target)
static

◆ nds32_step()

◆ nds32_step_without_watchpoint()

◆ nds32_target_state()

◆ nds32_update_cache_info()

static int nds32_update_cache_info ( struct nds32 nds32)
static

◆ nds32_update_lm_info()

◆ nds32_update_mmu_info()

static int nds32_update_mmu_info ( struct nds32 nds32)
static

◆ nds32_update_psw()

◆ nds32_virtual_to_physical()

int nds32_virtual_to_physical ( struct target target,
target_addr_t  address,
target_addr_t physical 
)

◆ nds32_write_buffer()

◆ nds32_write_memory()

int nds32_write_memory ( struct target target,
uint32_t  address,
uint32_t  size,
uint32_t  count,
const uint8_t *  buffer 
)

Definition at line 913 of file nds32.c.

References aice_write_mem_unit(), buffer, count, size, and target_to_aice().

Referenced by nds32_v3_write_memory().

◆ nds32_write_phys_memory()

int nds32_write_phys_memory ( struct target target,
target_addr_t  address,
uint32_t  size,
uint32_t  count,
const uint8_t *  buffer 
)

Variable Documentation

◆ nds32_debug_type_name

const char* nds32_debug_type_name[11]
Initial value:
= {
"SOFTWARE BREAK",
"SOFTWARE BREAK_16",
"HARDWARE BREAKPOINT",
"DATA ADDR WATCHPOINT PRECISE",
"DATA VALUE WATCHPOINT PRECISE",
"DATA VALUE WATCHPOINT IMPRECISE",
"DEBUG INTERRUPT",
"HARDWARE SINGLE STEP",
"DATA ADDR WATCHPOINT NEXT PRECISE",
"DATA VALUE WATCHPOINT NEXT PRECISE",
"LOAD STORE GLOBAL STOP",
}

Definition at line 22 of file nds32.c.

Referenced by nds32_examine_debug_reason().

◆ nds32_edm_ops

Definition at line 1 of file nds32.c.

Referenced by COMMAND_HANDLER(), and nds32_login().

◆ nds32_edm_ops_num

uint32_t nds32_edm_ops_num

Definition at line 20 of file nds32.c.

Referenced by COMMAND_HANDLER(), and nds32_login().

◆ nds32_line_size_table

const int nds32_line_size_table[6]
static
Initial value:
= {
0,
8,
16,
32,
64,
128,
}

Definition at line 50 of file nds32.c.

Referenced by nds32_cache_sync().

◆ nds32_lm_size_table

const int nds32_lm_size_table[16]
static
Initial value:
= {
4 * 1024,
8 * 1024,
16 * 1024,
32 * 1024,
64 * 1024,
128 * 1024,
256 * 1024,
512 * 1024,
1024 * 1024,
1 * 1024,
2 * 1024,
}

Definition at line 36 of file nds32.c.

Referenced by nds32_config().

◆ nds32_reg_access_type

const struct reg_arch_type nds32_reg_access_type
static
Initial value:
= {
}
static int nds32_get_core_reg(struct reg *reg)
Definition: nds32.c:59
static int nds32_set_core_reg(struct reg *reg, uint8_t *buf)
Definition: nds32.c:277

Definition at line 339 of file nds32.c.

Referenced by nds32_build_reg_cache().

◆ nds32_reg_access_type_64

const struct reg_arch_type nds32_reg_access_type_64
static
Initial value:
= {
}
static int nds32_get_core_reg_64(struct reg *reg)
Definition: nds32.c:109
static int nds32_set_core_reg_64(struct reg *reg, uint8_t *buf)
Definition: nds32.c:339

Definition at line 339 of file nds32.c.

Referenced by nds32_build_reg_cache().