mirror of
https://github.com/linux-msm/openocd.git
synced 2026-02-25 13:15:07 -08:00
nds32: add new target type nds32_v2, nds32_v3, nds32_v3m
Add target code for Andes targets. Change-Id: Ibf0e1b61b06127ca7d9ed502d98d7e2aeebbbe82 Signed-off-by: Hsiangkai Wang <hsiangkai@gmail.com> Reviewed-on: http://openocd.zylin.com/1259 Tested-by: jenkins Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
This commit is contained in:
committed by
Spencer Oliver
parent
ceb402dc9e
commit
cf8a3c3d70
@@ -109,7 +109,16 @@ MIPS32_SRC = \
|
||||
mips_ejtag.c
|
||||
|
||||
NDS32_SRC = \
|
||||
nds32_reg.c
|
||||
nds32.c \
|
||||
nds32_reg.c \
|
||||
nds32_cmd.c \
|
||||
nds32_disassembler.c \
|
||||
nds32_tlb.c \
|
||||
nds32_v2.c \
|
||||
nds32_v3_common.c \
|
||||
nds32_v3.c \
|
||||
nds32_v3m.c \
|
||||
nds32_aice.c
|
||||
|
||||
|
||||
noinst_HEADERS = \
|
||||
@@ -168,9 +177,17 @@ noinst_HEADERS = \
|
||||
avr32_mem.h \
|
||||
avr32_regs.h \
|
||||
nds32.h \
|
||||
nds32_cmd.h \
|
||||
nds32_disassembler.h \
|
||||
nds32_edm.h \
|
||||
nds32_insn.h \
|
||||
nds32_reg.h
|
||||
nds32_reg.h \
|
||||
nds32_tlb.h \
|
||||
nds32_v2.h \
|
||||
nds32_v3_common.h \
|
||||
nds32_v3.h \
|
||||
nds32_v3m.h \
|
||||
nds32_aice.h
|
||||
|
||||
ocddatadir = $(pkglibdir)
|
||||
nobase_dist_ocddata_DATA =
|
||||
|
||||
2156
src/target/nds32.c
Normal file
2156
src/target/nds32.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 by Andes Technology *
|
||||
* Copyright (C) 2013 Andes Technology *
|
||||
* Hsiangkai Wang <hkwang@andestech.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -22,7 +22,6 @@
|
||||
#define __NDS32_H__
|
||||
|
||||
#include <jtag/jtag.h>
|
||||
#include <jtag/aice/aice_port.h>
|
||||
#include "target.h"
|
||||
#include "target_type.h"
|
||||
#include "register.h"
|
||||
@@ -31,6 +30,8 @@
|
||||
#include "nds32_insn.h"
|
||||
#include "nds32_edm.h"
|
||||
|
||||
#define NDS32_EDM_OPERATION_MAX_NUM 64
|
||||
|
||||
#define CHECK_RETVAL(action) \
|
||||
do { \
|
||||
int __retval = (action); \
|
||||
@@ -62,18 +63,11 @@ enum nds32_debug_reason {
|
||||
NDS32_DEBUG_LOAD_STORE_GLOBAL_STOP,
|
||||
};
|
||||
|
||||
enum nds32_tdesc_type {
|
||||
NDS32_CORE_TDESC = 0,
|
||||
NDS32_SYSTEM_TDESC,
|
||||
NDS32_AUDIO_TDESC,
|
||||
NDS32_FPU_TDESC,
|
||||
NDS32_NUM_TDESC,
|
||||
};
|
||||
|
||||
#define NDS32_STRUCT_STAT_SIZE 60
|
||||
#define NDS32_STRUCT_TIMEVAL_SIZE 8
|
||||
|
||||
enum nds32_syscall_id {
|
||||
NDS32_SYSCALL_UNDEFINED = 0,
|
||||
NDS32_SYSCALL_EXIT = 1,
|
||||
NDS32_SYSCALL_OPEN = 2,
|
||||
NDS32_SYSCALL_CLOSE = 3,
|
||||
@@ -100,7 +94,8 @@ struct nds32_edm {
|
||||
/** The number of hardware breakpoints */
|
||||
int breakpoint_num;
|
||||
|
||||
/** EDM_CFG.DALM, indicate if direct local memory access feature is supported or not */
|
||||
/** EDM_CFG.DALM, indicate if direct local memory access
|
||||
* feature is supported or not */
|
||||
bool direct_access_local_memory;
|
||||
|
||||
/** Support ACC_CTL register */
|
||||
@@ -173,10 +168,10 @@ struct nds32_memory {
|
||||
int dlm_end;
|
||||
|
||||
/** Memory access method */
|
||||
enum aice_memory_access access_channel;
|
||||
enum nds_memory_access access_channel;
|
||||
|
||||
/** Memory access mode */
|
||||
enum aice_memory_mode mode;
|
||||
enum nds_memory_select mode;
|
||||
|
||||
/** Address translation */
|
||||
bool address_translation;
|
||||
@@ -275,7 +270,7 @@ struct nds32 {
|
||||
/** Backup target registers may be modified in debug state */
|
||||
int (*enter_debug_state)(struct nds32 *nds32, bool enable_watchpoint);
|
||||
|
||||
/** Get address hitted watchpoint */
|
||||
/** Get address hit watchpoint */
|
||||
int (*get_watched_address)(struct nds32 *nds32, uint32_t *address, uint32_t reason);
|
||||
|
||||
/** maximum interrupt level */
|
||||
@@ -289,24 +284,28 @@ struct nds32 {
|
||||
/** Flag reporting whether virtual hosting is active. */
|
||||
bool virtual_hosting;
|
||||
|
||||
/** Flag reporting whether continue/step hits syscall or not */
|
||||
bool hit_syscall;
|
||||
|
||||
/** Value to be returned by virtual hosting SYS_ERRNO request. */
|
||||
int virtual_hosting_errno;
|
||||
|
||||
/** Flag reporting whether syscall is aborted */
|
||||
bool virtual_hosting_ctrl_c;
|
||||
|
||||
/** Record syscall ID for other operations to do special processing for target */
|
||||
int active_syscall_id;
|
||||
|
||||
/** Flag reporting whether global stop is active. */
|
||||
bool global_stop;
|
||||
|
||||
/** Flag reporting whether to use soft-reset-halt or not as issuing reset-halt. */
|
||||
bool soft_reset_halt;
|
||||
|
||||
/** reset-halt as target examine */
|
||||
bool reset_halt_as_examine;
|
||||
|
||||
/** backup/restore target EDM_CTL value. As debugging target debug
|
||||
* handler, it should be true. */
|
||||
bool keep_target_edm_ctl;
|
||||
|
||||
/** always use word-aligned address to access memory */
|
||||
bool word_access_mem;
|
||||
|
||||
/** EDM passcode for debugging secure MCU */
|
||||
char *edm_passcode;
|
||||
|
||||
/** current privilege_level if using secure MCU. value 0 is the highest level. */
|
||||
int privilege_level;
|
||||
|
||||
/** Period to wait after SRST. */
|
||||
uint32_t boot_time;
|
||||
|
||||
@@ -322,12 +321,19 @@ struct nds32 {
|
||||
/** Flag to indicate fpu-extension is enabled or not */
|
||||
bool fpu_enable;
|
||||
|
||||
/* Andes Core has mixed endian model. Instruction is always big-endian.
|
||||
* Data may be big or little endian. Device registers may have different
|
||||
* endian from data and instruction. */
|
||||
/** Endian of data memory */
|
||||
enum target_endianness data_endian;
|
||||
|
||||
/** Endian of device registers */
|
||||
enum target_endianness device_reg_endian;
|
||||
|
||||
/** Flag to indicate if auto convert software breakpoints to
|
||||
* hardware breakpoints or not in ROM */
|
||||
bool auto_convert_hw_bp;
|
||||
|
||||
int (*setup_virtual_hosting)(struct target *target, int enable);
|
||||
|
||||
/** Backpointer to the target. */
|
||||
struct target *target;
|
||||
|
||||
@@ -343,32 +349,33 @@ struct nds32_reg {
|
||||
bool enable;
|
||||
};
|
||||
|
||||
struct nds32_edm_operation {
|
||||
uint32_t reg_no;
|
||||
uint32_t value;
|
||||
};
|
||||
|
||||
extern int nds32_config(struct nds32 *nds32);
|
||||
extern int nds32_init_arch_info(struct target *target, struct nds32 *nds32);
|
||||
extern int nds32_full_context(struct nds32 *nds32);
|
||||
extern int nds32_arch_state(struct target *target);
|
||||
extern int nds32_add_software_breakpoint(struct target *target,
|
||||
struct breakpoint *breakpoint);
|
||||
struct breakpoint *breakpoint);
|
||||
extern int nds32_remove_software_breakpoint(struct target *target,
|
||||
struct breakpoint *breakpoint);
|
||||
struct breakpoint *breakpoint);
|
||||
|
||||
extern int nds32_get_gdb_general_reg_list(struct target *target,
|
||||
struct reg **reg_list[], int *reg_list_size);
|
||||
extern int nds32_get_gdb_reg_list(struct target *target,
|
||||
struct reg **reg_list[], int *reg_list_size);
|
||||
extern int nds32_get_gdb_target_description(struct target *target, char **xml,
|
||||
char *annex, int32_t offset, uint32_t length);
|
||||
struct reg **reg_list[], int *reg_list_size);
|
||||
|
||||
extern int nds32_write_buffer(struct target *target, uint32_t address,
|
||||
uint32_t size, const uint8_t *buffer);
|
||||
uint32_t size, const uint8_t *buffer);
|
||||
extern int nds32_read_buffer(struct target *target, uint32_t address,
|
||||
uint32_t size, uint8_t *buffer);
|
||||
uint32_t size, uint8_t *buffer);
|
||||
extern int nds32_bulk_write_memory(struct target *target,
|
||||
uint32_t address, uint32_t count, const uint8_t *buffer);
|
||||
uint32_t address, uint32_t count, const uint8_t *buffer);
|
||||
extern int nds32_read_memory(struct target *target, uint32_t address,
|
||||
uint32_t size, uint32_t count, uint8_t *buffer);
|
||||
uint32_t size, uint32_t count, uint8_t *buffer);
|
||||
extern int nds32_write_memory(struct target *target, uint32_t address,
|
||||
uint32_t size, uint32_t count, const uint8_t *buffer);
|
||||
uint32_t size, uint32_t count, const uint8_t *buffer);
|
||||
|
||||
extern int nds32_init_register_table(struct nds32 *nds32);
|
||||
extern int nds32_init_memory_info(struct nds32 *nds32);
|
||||
@@ -377,31 +384,27 @@ extern int nds32_get_mapped_reg(struct nds32 *nds32, unsigned regnum, uint32_t *
|
||||
extern int nds32_set_mapped_reg(struct nds32 *nds32, unsigned regnum, uint32_t value);
|
||||
|
||||
extern int nds32_edm_config(struct nds32 *nds32);
|
||||
extern int nds32_check_extension(struct nds32 *nds32);
|
||||
extern int nds32_cache_sync(struct target *target, uint32_t address, uint32_t length);
|
||||
extern int nds32_mmu(struct target *target, int *enabled);
|
||||
extern int nds32_virtual_to_physical(struct target *target, uint32_t address, uint32_t *physical);
|
||||
extern int nds32_virtual_to_physical(struct target *target, uint32_t address,
|
||||
uint32_t *physical);
|
||||
extern int nds32_read_phys_memory(struct target *target, uint32_t address,
|
||||
uint32_t size, uint32_t count, uint8_t *buffer);
|
||||
uint32_t size, uint32_t count, uint8_t *buffer);
|
||||
extern int nds32_write_phys_memory(struct target *target, uint32_t address,
|
||||
uint32_t size, uint32_t count, const uint8_t *buffer);
|
||||
extern int nds32_soft_reset_halt(struct target *target);
|
||||
uint32_t size, uint32_t count, const uint8_t *buffer);
|
||||
extern uint32_t nds32_nextpc(struct nds32 *nds32, int current, uint32_t address);
|
||||
extern int nds32_examine_debug_reason(struct nds32 *nds32);
|
||||
extern int nds32_step(struct target *target, int current,
|
||||
uint32_t address, int handle_breakpoints);
|
||||
uint32_t address, int handle_breakpoints);
|
||||
extern int nds32_target_state(struct nds32 *nds32, enum target_state *state);
|
||||
extern int nds32_halt(struct target *target);
|
||||
extern int nds32_poll(struct target *target);
|
||||
extern int nds32_resume(struct target *target, int current,
|
||||
uint32_t address, int handle_breakpoints, int debug_execution);
|
||||
uint32_t address, int handle_breakpoints, int debug_execution);
|
||||
extern int nds32_assert_reset(struct target *target);
|
||||
extern int nds32_init(struct nds32 *nds32);
|
||||
extern int nds32_get_gdb_fileio_info(struct target *target, struct gdb_fileio_info *fileio_info);
|
||||
extern int nds32_gdb_fileio_write_memory(struct nds32 *nds32, uint32_t address,
|
||||
uint32_t size, const uint8_t *buffer);
|
||||
extern int nds32_gdb_fileio_end(struct target *target, int retcode, int fileio_errno, bool ctrl_c);
|
||||
extern int nds32_reset_halt(struct nds32 *nds32);
|
||||
extern int nds32_login(struct nds32 *nds32);
|
||||
|
||||
/** Convert target handle to generic Andes target state handle. */
|
||||
static inline struct nds32 *target_to_nds32(struct target *target)
|
||||
|
||||
157
src/target/nds32_aice.c
Normal file
157
src/target/nds32_aice.c
Normal file
@@ -0,0 +1,157 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 Andes technology. *
|
||||
* Hsiangkai Wang <hkwang@andestech.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
|
||||
***************************************************************************/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <helper/log.h>
|
||||
#include "nds32_aice.h"
|
||||
|
||||
int aice_read_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t *val)
|
||||
{
|
||||
if (aice->port->api->read_reg_64 == NULL) {
|
||||
LOG_WARNING("Not implemented: %s", __func__);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
return aice->port->api->read_reg_64(num, val);
|
||||
}
|
||||
|
||||
int aice_write_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t val)
|
||||
{
|
||||
if (aice->port->api->write_reg_64 == NULL) {
|
||||
LOG_WARNING("Not implemented: %s", __func__);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
return aice->port->api->write_reg_64(num, val);
|
||||
}
|
||||
|
||||
int aice_select_target(struct aice_port_s *aice, uint32_t target_id)
|
||||
{
|
||||
if (aice->port->api->select_target == NULL) {
|
||||
LOG_WARNING("Not implemented: %s", __func__);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
return aice->port->api->select_target(target_id);
|
||||
}
|
||||
|
||||
int aice_read_tlb(struct aice_port_s *aice, uint32_t virtual_address,
|
||||
uint32_t *physical_address)
|
||||
{
|
||||
if (aice->port->api->read_tlb == NULL) {
|
||||
LOG_WARNING("Not implemented: %s", __func__);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
return aice->port->api->read_tlb(virtual_address, physical_address);
|
||||
}
|
||||
|
||||
int aice_cache_ctl(struct aice_port_s *aice, uint32_t subtype, uint32_t address)
|
||||
{
|
||||
if (aice->port->api->cache_ctl == NULL) {
|
||||
LOG_WARNING("Not implemented: %s", __func__);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
return aice->port->api->cache_ctl(subtype, address);
|
||||
}
|
||||
|
||||
int aice_set_retry_times(struct aice_port_s *aice, uint32_t a_retry_times)
|
||||
{
|
||||
if (aice->port->api->set_retry_times == NULL) {
|
||||
LOG_WARNING("Not implemented: %s", __func__);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
return aice->port->api->set_retry_times(a_retry_times);
|
||||
}
|
||||
|
||||
int aice_program_edm(struct aice_port_s *aice, char *command_sequence)
|
||||
{
|
||||
if (aice->port->api->program_edm == NULL) {
|
||||
LOG_WARNING("Not implemented: %s", __func__);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
return aice->port->api->program_edm(command_sequence);
|
||||
}
|
||||
|
||||
int aice_pack_command(struct aice_port_s *aice, bool enable_pack_command)
|
||||
{
|
||||
if (aice->port->api->pack_command == NULL) {
|
||||
LOG_WARNING("Not implemented: %s", __func__);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
return aice->port->api->pack_command(enable_pack_command);
|
||||
}
|
||||
|
||||
int aice_execute(struct aice_port_s *aice, uint32_t *instructions,
|
||||
uint32_t instruction_num)
|
||||
{
|
||||
if (aice->port->api->execute == NULL) {
|
||||
LOG_WARNING("Not implemented: %s", __func__);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
return aice->port->api->execute(instructions, instruction_num);
|
||||
}
|
||||
|
||||
int aice_set_custom_srst_script(struct aice_port_s *aice, const char *script)
|
||||
{
|
||||
if (aice->port->api->set_custom_srst_script == NULL) {
|
||||
LOG_WARNING("Not implemented: %s", __func__);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
return aice->port->api->set_custom_srst_script(script);
|
||||
}
|
||||
|
||||
int aice_set_custom_trst_script(struct aice_port_s *aice, const char *script)
|
||||
{
|
||||
if (aice->port->api->set_custom_trst_script == NULL) {
|
||||
LOG_WARNING("Not implemented: %s", __func__);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
return aice->port->api->set_custom_trst_script(script);
|
||||
}
|
||||
|
||||
int aice_set_custom_restart_script(struct aice_port_s *aice, const char *script)
|
||||
{
|
||||
if (aice->port->api->set_custom_restart_script == NULL) {
|
||||
LOG_WARNING("Not implemented: %s", __func__);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
return aice->port->api->set_custom_restart_script(script);
|
||||
}
|
||||
|
||||
int aice_set_count_to_check_dbger(struct aice_port_s *aice, uint32_t count_to_check)
|
||||
{
|
||||
if (aice->port->api->set_count_to_check_dbger == NULL) {
|
||||
LOG_WARNING("Not implemented: %s", __func__);
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
return aice->port->api->set_count_to_check_dbger(count_to_check);
|
||||
}
|
||||
160
src/target/nds32_aice.h
Normal file
160
src/target/nds32_aice.h
Normal file
@@ -0,0 +1,160 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 Andes technology. *
|
||||
* Hsiangkai Wang <hkwang@andestech.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
|
||||
***************************************************************************/
|
||||
#ifndef __NDS32_AICE_H__
|
||||
#define __NDS32_AICE_H__
|
||||
|
||||
#include <jtag/aice/aice_port.h>
|
||||
|
||||
int aice_read_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t *val);
|
||||
int aice_write_reg_64(struct aice_port_s *aice, uint32_t num, uint64_t val);
|
||||
int aice_select_target(struct aice_port_s *aice, uint32_t target_id);
|
||||
int aice_read_tlb(struct aice_port_s *aice, uint32_t virtual_address,
|
||||
uint32_t *physical_address);
|
||||
int aice_cache_ctl(struct aice_port_s *aice, uint32_t subtype, uint32_t address);
|
||||
int aice_set_retry_times(struct aice_port_s *aice, uint32_t a_retry_times);
|
||||
int aice_program_edm(struct aice_port_s *aice, char *command_sequence);
|
||||
int aice_pack_command(struct aice_port_s *aice, bool enable_pack_command);
|
||||
int aice_execute(struct aice_port_s *aice, uint32_t *instructions,
|
||||
uint32_t instruction_num);
|
||||
int aice_set_custom_srst_script(struct aice_port_s *aice, const char *script);
|
||||
int aice_set_custom_trst_script(struct aice_port_s *aice, const char *script);
|
||||
int aice_set_custom_restart_script(struct aice_port_s *aice, const char *script);
|
||||
int aice_set_count_to_check_dbger(struct aice_port_s *aice, uint32_t count_to_check);
|
||||
|
||||
static inline int aice_open(struct aice_port_s *aice, struct aice_port_param_s *param)
|
||||
{
|
||||
return aice->port->api->open(param);
|
||||
}
|
||||
|
||||
static inline int aice_close(struct aice_port_s *aice)
|
||||
{
|
||||
return aice->port->api->close();
|
||||
}
|
||||
|
||||
static inline int aice_reset(struct aice_port_s *aice)
|
||||
{
|
||||
return aice->port->api->reset();
|
||||
}
|
||||
|
||||
static inline int aice_assert_srst(struct aice_port_s *aice,
|
||||
enum aice_srst_type_s srst)
|
||||
{
|
||||
return aice->port->api->assert_srst(srst);
|
||||
}
|
||||
|
||||
static inline int aice_run(struct aice_port_s *aice)
|
||||
{
|
||||
return aice->port->api->run();
|
||||
}
|
||||
|
||||
static inline int aice_halt(struct aice_port_s *aice)
|
||||
{
|
||||
return aice->port->api->halt();
|
||||
}
|
||||
|
||||
static inline int aice_step(struct aice_port_s *aice)
|
||||
{
|
||||
return aice->port->api->step();
|
||||
}
|
||||
|
||||
static inline int aice_read_register(struct aice_port_s *aice, uint32_t num,
|
||||
uint32_t *val)
|
||||
{
|
||||
return aice->port->api->read_reg(num, val);
|
||||
}
|
||||
|
||||
static inline int aice_write_register(struct aice_port_s *aice, uint32_t num,
|
||||
uint32_t val)
|
||||
{
|
||||
return aice->port->api->write_reg(num, val);
|
||||
}
|
||||
|
||||
static inline int aice_read_debug_reg(struct aice_port_s *aice, uint32_t addr,
|
||||
uint32_t *val)
|
||||
{
|
||||
return aice->port->api->read_debug_reg(addr, val);
|
||||
}
|
||||
|
||||
static inline int aice_write_debug_reg(struct aice_port_s *aice, uint32_t addr,
|
||||
const uint32_t val)
|
||||
{
|
||||
return aice->port->api->write_debug_reg(addr, val);
|
||||
}
|
||||
|
||||
static inline int aice_read_mem_unit(struct aice_port_s *aice, uint32_t addr,
|
||||
uint32_t size, uint32_t count, uint8_t *buffer)
|
||||
{
|
||||
return aice->port->api->read_mem_unit(addr, size, count, buffer);
|
||||
}
|
||||
|
||||
static inline int aice_write_mem_unit(struct aice_port_s *aice, uint32_t addr,
|
||||
uint32_t size, uint32_t count, const uint8_t *buffer)
|
||||
{
|
||||
return aice->port->api->write_mem_unit(addr, size, count, buffer);
|
||||
}
|
||||
|
||||
static inline int aice_read_mem_bulk(struct aice_port_s *aice, uint32_t addr,
|
||||
uint32_t length, uint8_t *buffer)
|
||||
{
|
||||
return aice->port->api->read_mem_bulk(addr, length, buffer);
|
||||
}
|
||||
|
||||
static inline int aice_write_mem_bulk(struct aice_port_s *aice, uint32_t addr,
|
||||
uint32_t length, const uint8_t *buffer)
|
||||
{
|
||||
return aice->port->api->write_mem_bulk(addr, length, buffer);
|
||||
}
|
||||
|
||||
static inline int aice_idcode(struct aice_port_s *aice, uint32_t *idcode,
|
||||
uint8_t *num_of_idcode)
|
||||
{
|
||||
return aice->port->api->idcode(idcode, num_of_idcode);
|
||||
}
|
||||
|
||||
static inline int aice_state(struct aice_port_s *aice,
|
||||
enum aice_target_state_s *state)
|
||||
{
|
||||
return aice->port->api->state(state);
|
||||
}
|
||||
|
||||
static inline int aice_set_jtag_clock(struct aice_port_s *aice, uint32_t a_clock)
|
||||
{
|
||||
return aice->port->api->set_jtag_clock(a_clock);
|
||||
}
|
||||
|
||||
static inline int aice_memory_access(struct aice_port_s *aice,
|
||||
enum nds_memory_access a_access)
|
||||
{
|
||||
return aice->port->api->memory_access(a_access);
|
||||
}
|
||||
|
||||
static inline int aice_memory_mode(struct aice_port_s *aice,
|
||||
enum nds_memory_select mem_select)
|
||||
{
|
||||
return aice->port->api->memory_mode(mem_select);
|
||||
}
|
||||
|
||||
static inline int aice_set_data_endian(struct aice_port_s *aice,
|
||||
enum aice_target_endian target_data_endian)
|
||||
{
|
||||
return aice->port->api->set_data_endian(target_data_endian);
|
||||
}
|
||||
|
||||
#endif
|
||||
1106
src/target/nds32_cmd.c
Normal file
1106
src/target/nds32_cmd.c
Normal file
File diff suppressed because it is too large
Load Diff
27
src/target/nds32_cmd.h
Normal file
27
src/target/nds32_cmd.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 Andes Technology *
|
||||
* Hsiangkai Wang <hkwang@andestech.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __NDS32_CMD_H__
|
||||
#define __NDS32_CMD_H__
|
||||
#include <helper/command.h>
|
||||
|
||||
extern const struct command_registration nds32_command_handlers[];
|
||||
|
||||
#endif /* __NDS32_CMD_H__ */
|
||||
3637
src/target/nds32_disassembler.c
Normal file
3637
src/target/nds32_disassembler.c
Normal file
File diff suppressed because it is too large
Load Diff
58
src/target/nds32_disassembler.h
Normal file
58
src/target/nds32_disassembler.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 Andes Technology *
|
||||
* Hsiangkai Wang <hkwang@andestech.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __NDS32_DISASSEMBLER_H__
|
||||
#define __NDS32_DISASSEMBLER_H__
|
||||
|
||||
#include <target/nds32.h>
|
||||
|
||||
enum nds32_instruction_type {
|
||||
NDS32_INSN_DATA_PROC = 0,
|
||||
NDS32_INSN_LOAD_STORE,
|
||||
NDS32_INSN_JUMP_BRANCH,
|
||||
NDS32_INSN_RESOURCE_ACCESS,
|
||||
NDS32_INSN_MISC,
|
||||
};
|
||||
|
||||
struct nds32_instruction {
|
||||
enum nds32_instruction_type type;
|
||||
char text[128];
|
||||
uint32_t opcode;
|
||||
uint8_t instruction_size;
|
||||
uint32_t access_start;
|
||||
uint32_t access_end;
|
||||
|
||||
struct {
|
||||
uint8_t opc_6;
|
||||
uint8_t rt;
|
||||
uint8_t ra;
|
||||
uint8_t rb;
|
||||
uint8_t rd;
|
||||
uint8_t sub_opc;
|
||||
int32_t imm;
|
||||
} info;
|
||||
|
||||
};
|
||||
|
||||
int nds32_read_opcode(struct nds32 *nds32, uint32_t address, uint32_t *value);
|
||||
int nds32_evaluate_opcode(struct nds32 *nds32, uint32_t opcode, uint32_t address,
|
||||
struct nds32_instruction *instruction);
|
||||
|
||||
#endif /* __NDS32_DISASSEMBLER_H__ */
|
||||
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 by Andes Technology *
|
||||
* Copyright (C) 2013 Andes Technology *
|
||||
* Hsiangkai Wang <hkwang@andestech.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 by Andes Technology *
|
||||
* Copyright (C) 2013 Andes Technology *
|
||||
* Hsiangkai Wang <hkwang@andestech.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -21,13 +21,13 @@
|
||||
#define __NDS32_INSN_H__
|
||||
|
||||
|
||||
#define NOP (0x40000009)
|
||||
#define DSB (0x64000008)
|
||||
#define ISB (0x64000009)
|
||||
#define NOP (0x40000009)
|
||||
#define DSB (0x64000008)
|
||||
#define ISB (0x64000009)
|
||||
#define BEQ_MINUS_12 (0x4C000000 | 0x3FFA)
|
||||
#define MTSR_DTR(a) (0x64000003 | (((0x03 << 7) | (0x08 << 3) | (0x00 << 0)) << 10) | (((a) & 0x1F) << 20))
|
||||
#define MFSR_DTR(a) (0x64000002 | (((0x03 << 7) | (0x08 << 3) | (0x00 << 0)) << 10) | (((a) & 0x1F) << 20))
|
||||
#define SETHI(a, b) (0x46000000 | ((a) << 20) | (b))
|
||||
#define MTSR_DTR(a) (0x64000003 | (((0x03 << 7) | (0x08 << 3) | (0x00 << 0)) << 10) | (((a) & 0x1F) << 20))
|
||||
#define MFSR_DTR(a) (0x64000002 | (((0x03 << 7) | (0x08 << 3) | (0x00 << 0)) << 10) | (((a) & 0x1F) << 20))
|
||||
#define SETHI(a, b) (0x46000000 | ((a) << 20) | (b))
|
||||
#define ORI(a, b, c) (0x58000000 | ((a) << 20) | ((b) << 15) | (c))
|
||||
#define LWI_BI(a, b) (0x0C000001 | (a << 20) | (b << 15))
|
||||
#define LHI_BI(a, b) (0x0A000001 | (a << 20) | (b << 15))
|
||||
@@ -35,7 +35,7 @@
|
||||
#define SWI_BI(a, b) (0x1C000001 | (a << 20) | (b << 15))
|
||||
#define SHI_BI(a, b) (0x1A000001 | (a << 20) | (b << 15))
|
||||
#define SBI_BI(a, b) (0x18000001 | (a << 20) | (b << 15))
|
||||
#define IRET (0x64000004)
|
||||
#define IRET (0x64000004)
|
||||
#define L1D_IX_WB(a) (0x64000021 | ((a) << 15))
|
||||
#define L1D_IX_INVAL(a) (0x64000001 | ((a) << 15))
|
||||
#define L1D_VA_INVAL(a) (0x64000101 | ((a) << 15))
|
||||
@@ -47,31 +47,31 @@
|
||||
#define L1I_IX_RTAG(a) (0x64000261 | ((a) << 15))
|
||||
#define L1I_IX_RWD(a) (0x64000281 | ((a) << 15))
|
||||
#define L1I_VA_FILLCK(a) (0x64000361 | ((a) << 15))
|
||||
#define ISYNC(a) (0x6400000d | ((a) << 20))
|
||||
#define MSYNC_STORE (0x6400002c)
|
||||
#define MSYNC_ALL (0x6400000c)
|
||||
#define TLBOP_TARGET_READ(a) (0x6400000e | ((a) << 15))
|
||||
#define TLBOP_TARGET_PROBE(a, b) (0x640000AE | ((a) << 20) | ((b) << 15))
|
||||
#define ISYNC(a) (0x6400000d | ((a) << 20))
|
||||
#define MSYNC_STORE (0x6400002c)
|
||||
#define MSYNC_ALL (0x6400000c)
|
||||
#define TLBOP_TARGET_READ(a) (0x6400000e | ((a) << 15))
|
||||
#define TLBOP_TARGET_PROBE(a, b) (0x640000AE | ((a) << 20) | ((b) << 15))
|
||||
#define MFCPD(a, b, c) (0x6A000041 | (a << 20) | (b << 8) | (c << 4))
|
||||
#define MFCPW(a, b, c) (0x6A000001 | (a << 20) | (b << 8) | (c << 4))
|
||||
#define MTCPD(a, b, c) (0x6A000049 | (a << 20) | (b << 8) | (c << 4))
|
||||
#define MTCPW(a, b, c) (0x6A000009 | (a << 20) | (b << 8) | (c << 4))
|
||||
#define MOVI_(a, b) (0x44000000 | (a << 20) | (b & 0xFFFFF))
|
||||
#define MOVI_(a, b) (0x44000000 | (a << 20) | (b & 0xFFFFF))
|
||||
#define MFUSR_G0(a, b) (0x42000020 | (a << 20) | (b << 15))
|
||||
#define MTUSR_G0(a, b) (0x42000021 | (a << 20) | (b << 15))
|
||||
#define MFSR(a, b) (0x64000002 | (b << 10) | (a << 20))
|
||||
#define MTSR(a, b) (0x64000003 | (b << 10) | (a << 20))
|
||||
#define AMFAR(a, b) (0x60300060 | (a << 15) | b)
|
||||
#define AMTAR(a, b) (0x60300040 | (a << 15) | b)
|
||||
#define MFSR(a, b) (0x64000002 | (b << 10) | (a << 20))
|
||||
#define MTSR(a, b) (0x64000003 | (b << 10) | (a << 20))
|
||||
#define AMFAR(a, b) (0x60300060 | (a << 15) | b)
|
||||
#define AMTAR(a, b) (0x60300040 | (a << 15) | b)
|
||||
#define AMFAR2(a, b) (0x60300260 | (a << 15) | b)
|
||||
#define AMTAR2(a, b) (0x60300240 | (a << 15) | b)
|
||||
#define FMFCSR (0x6A000701)
|
||||
#define FMTCSR (0x6A000709)
|
||||
#define FMFCFG (0x6A000301)
|
||||
#define FMFSR(a, b) (0x6A000001 | ((a) << 20) | ((b) << 15))
|
||||
#define FMTSR(a, b) (0x6A000009 | ((a) << 20) | ((b) << 15))
|
||||
#define FMFDR(a, b) (0x6A000041 | ((a) << 20) | ((b) << 15))
|
||||
#define FMTDR(a, b) (0x6A000049 | ((a) << 20) | ((b) << 15))
|
||||
#define FMFCSR (0x6A000701)
|
||||
#define FMTCSR (0x6A000709)
|
||||
#define FMFCFG (0x6A000301)
|
||||
#define FMFSR(a, b) (0x6A000001 | ((a) << 20) | ((b) << 15))
|
||||
#define FMTSR(a, b) (0x6A000009 | ((a) << 20) | ((b) << 15))
|
||||
#define FMFDR(a, b) (0x6A000041 | ((a) << 20) | ((b) << 15))
|
||||
#define FMTDR(a, b) (0x6A000049 | ((a) << 20) | ((b) << 15))
|
||||
|
||||
/* break instructions */
|
||||
extern const int NDS32_BREAK_16;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 by Andes Technology *
|
||||
* Copyright (C) 2013 Andes Technology *
|
||||
* Hsiangkai Wang <hkwang@andestech.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -21,14 +21,28 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <helper/log.h>
|
||||
#include "nds32_reg.h"
|
||||
|
||||
static bool nds32_reg_init_done;
|
||||
static struct nds32_reg_s nds32_regs[TOTAL_REG_NUM];
|
||||
static struct nds32_reg_exception_s nds32_ex_reg_values[] = {
|
||||
{IR0, 3, 0x3, 2},
|
||||
{IR0, 3, 0x3, 3},
|
||||
{IR1, 3, 0x3, 2},
|
||||
{IR1, 3, 0x3, 3},
|
||||
{IR2, 3, 0x3, 2},
|
||||
{IR2, 3, 0x3, 3},
|
||||
{MR3, 1, 0x7, 0},
|
||||
{MR3, 1, 0x7, 4},
|
||||
{MR3, 1, 0x7, 6},
|
||||
{MR3, 8, 0x7, 3},
|
||||
{0, 0, 0, 0},
|
||||
};
|
||||
|
||||
static inline void nds32_reg_set(uint32_t number, const char *simple_mnemonic,
|
||||
const char *symbolic_mnemonic, uint32_t sr_index,
|
||||
enum nds32_reg_type_s type, uint8_t size)
|
||||
const char *symbolic_mnemonic, uint32_t sr_index,
|
||||
enum nds32_reg_type_s type, uint8_t size)
|
||||
{
|
||||
nds32_regs[number].simple_mnemonic = simple_mnemonic;
|
||||
nds32_regs[number].symbolic_mnemonic = symbolic_mnemonic;
|
||||
@@ -117,6 +131,11 @@ void nds32_reg_init(void)
|
||||
nds32_reg_set(IR23, "ir23", "", SRIDX(1, 10, 5), NDS32_REG_TYPE_IR, 32);
|
||||
nds32_reg_set(IR24, "ir24", "", SRIDX(1, 10, 6), NDS32_REG_TYPE_IR, 32);
|
||||
nds32_reg_set(IR25, "ir25", "", SRIDX(1, 10, 7), NDS32_REG_TYPE_IR, 32);
|
||||
nds32_reg_set(IR26, "ir26", "", SRIDX(1, 8, 1), NDS32_REG_TYPE_IR, 32);
|
||||
nds32_reg_set(IR27, "ir27", "", SRIDX(1, 9, 1), NDS32_REG_TYPE_IR, 32);
|
||||
nds32_reg_set(IR28, "ir28", "", SRIDX(1, 11, 1), NDS32_REG_TYPE_IR, 32);
|
||||
nds32_reg_set(IR29, "ir29", "", SRIDX(1, 9, 4), NDS32_REG_TYPE_IR, 32);
|
||||
nds32_reg_set(IR30, "ir30", "", SRIDX(1, 1, 3), NDS32_REG_TYPE_IR, 32);
|
||||
|
||||
nds32_reg_set(MR0, "mr0", "MMU_CTL", SRIDX(2, 0, 0), NDS32_REG_TYPE_MR, 32);
|
||||
nds32_reg_set(MR1, "mr1", "L1_PPTB", SRIDX(2, 1, 0), NDS32_REG_TYPE_MR, 32);
|
||||
@@ -335,3 +354,29 @@ const char *nds32_reg_symbolic_name(uint32_t number)
|
||||
{
|
||||
return nds32_regs[number].symbolic_mnemonic;
|
||||
}
|
||||
|
||||
bool nds32_reg_exception(uint32_t number, uint32_t value)
|
||||
{
|
||||
int i;
|
||||
struct nds32_reg_exception_s *ex_reg_value;
|
||||
uint32_t field_value;
|
||||
|
||||
i = 0;
|
||||
while (nds32_ex_reg_values[i].reg_num != 0) {
|
||||
ex_reg_value = nds32_ex_reg_values + i;
|
||||
|
||||
if (ex_reg_value->reg_num == number) {
|
||||
field_value = (value >> ex_reg_value->ex_value_bit_pos) &
|
||||
ex_reg_value->ex_value_mask;
|
||||
if (field_value == ex_reg_value->ex_value) {
|
||||
LOG_WARNING("It will generate exceptions as setting %d to %s",
|
||||
value, nds32_regs[number].simple_mnemonic);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 by Andes Technology *
|
||||
* Copyright (C) 2013 Andes Technology *
|
||||
* Hsiangkai Wang <hkwang@andestech.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
@@ -24,8 +24,7 @@
|
||||
#define NDS32_REGISTER_DISABLE (0x0)
|
||||
|
||||
enum nds32_reg_number_s {
|
||||
/* general registers */
|
||||
R0 = 0,
|
||||
R0 = 0, /* general registers */
|
||||
R1,
|
||||
R2,
|
||||
R3,
|
||||
@@ -64,9 +63,7 @@ enum nds32_reg_number_s {
|
||||
D1HI,
|
||||
ITB,
|
||||
IFC_LP,
|
||||
|
||||
/* system registers */
|
||||
CR0,
|
||||
CR0, /* system registers */
|
||||
CR1,
|
||||
CR2,
|
||||
CR3,
|
||||
@@ -99,6 +96,11 @@ enum nds32_reg_number_s {
|
||||
IR23,
|
||||
IR24,
|
||||
IR25,
|
||||
IR26,
|
||||
IR27,
|
||||
IR28,
|
||||
IR29,
|
||||
IR30,
|
||||
MR0,
|
||||
MR1,
|
||||
MR2,
|
||||
@@ -180,9 +182,7 @@ enum nds32_reg_number_s {
|
||||
IDR0,
|
||||
IDR1,
|
||||
SECUR0,
|
||||
|
||||
/* audio registers */
|
||||
D0L24,
|
||||
D0L24, /* audio registers */
|
||||
D1L24,
|
||||
I0,
|
||||
I1,
|
||||
@@ -214,9 +214,7 @@ enum nds32_reg_number_s {
|
||||
CBE1,
|
||||
CBE2,
|
||||
CBE3,
|
||||
|
||||
/* fpu */
|
||||
FPCSR,
|
||||
FPCSR, /* fpu */
|
||||
FPCFG,
|
||||
FS0,
|
||||
FS1,
|
||||
@@ -310,11 +308,19 @@ struct nds32_reg_s {
|
||||
uint8_t size;
|
||||
};
|
||||
|
||||
struct nds32_reg_exception_s {
|
||||
uint32_t reg_num;
|
||||
uint32_t ex_value_bit_pos;
|
||||
uint32_t ex_value_mask;
|
||||
uint32_t ex_value;
|
||||
};
|
||||
|
||||
void nds32_reg_init(void);
|
||||
uint32_t nds32_reg_sr_index(uint32_t number);
|
||||
enum nds32_reg_type_s nds32_reg_type(uint32_t number);
|
||||
uint8_t nds32_reg_size(uint32_t number);
|
||||
const char *nds32_reg_simple_name(uint32_t number);
|
||||
const char *nds32_reg_symbolic_name(uint32_t number);
|
||||
bool nds32_reg_exception(uint32_t number, uint32_t value);
|
||||
|
||||
#endif
|
||||
|
||||
80
src/target/nds32_tlb.c
Normal file
80
src/target/nds32_tlb.c
Normal file
@@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 Andes Technology *
|
||||
* Hsiangkai Wang <hkwang@andestech.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
|
||||
***************************************************************************/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "nds32_aice.h"
|
||||
#include "nds32_tlb.h"
|
||||
|
||||
int nds32_probe_tlb(struct nds32 *nds32, const uint32_t virtual_address,
|
||||
uint32_t *physical_address)
|
||||
{
|
||||
struct target *target = nds32->target;
|
||||
struct aice_port_s *aice = target_to_aice(target);
|
||||
|
||||
return aice_read_tlb(aice, virtual_address, physical_address);
|
||||
}
|
||||
|
||||
struct page_table_walker_info_s page_table_info[PAGE_SIZE_NUM] = {
|
||||
/* 4K page */
|
||||
{0xFFC00000, 20, 0x003FF000, 10, 0x00000FFF, 0xFFFFF000, 0xFFFFF000, 0xFFFFF000},
|
||||
/* 8K page */
|
||||
{0xFF000000, 22, 0x00FFE000, 11, 0x00001FFF, 0xFFFFF000, 0xFFFFE000, 0xFFFFE000},
|
||||
};
|
||||
|
||||
int nds32_walk_page_table(struct nds32 *nds32, const uint32_t virtual_address,
|
||||
uint32_t *physical_address)
|
||||
{
|
||||
struct target *target = nds32->target;
|
||||
uint32_t value_mr1;
|
||||
uint32_t load_address;
|
||||
uint32_t L1_page_table_entry;
|
||||
uint32_t L2_page_table_entry;
|
||||
uint32_t page_size_index = nds32->mmu_config.default_min_page_size;
|
||||
struct page_table_walker_info_s *page_table_info_p =
|
||||
&(page_table_info[page_size_index]);
|
||||
|
||||
/* Read L1 Physical Page Table */
|
||||
nds32_get_mapped_reg(nds32, MR1, &value_mr1);
|
||||
load_address = (value_mr1 & page_table_info_p->L1_base_mask) |
|
||||
((virtual_address & page_table_info_p->L1_offset_mask) >>
|
||||
page_table_info_p->L1_offset_shift);
|
||||
/* load_address is physical address */
|
||||
nds32_read_buffer(target, load_address, 4, (uint8_t *)&L1_page_table_entry);
|
||||
|
||||
/* Read L2 Physical Page Table */
|
||||
if (L1_page_table_entry & 0x1) /* L1_PTE not present */
|
||||
return ERROR_FAIL;
|
||||
|
||||
load_address = (L1_page_table_entry & page_table_info_p->L2_base_mask) |
|
||||
((virtual_address & page_table_info_p->L2_offset_mask) >>
|
||||
page_table_info_p->L2_offset_shift);
|
||||
/* load_address is physical address */
|
||||
nds32_read_buffer(target, load_address, 4, (uint8_t *)&L2_page_table_entry);
|
||||
|
||||
if ((L2_page_table_entry & 0x1) != 0x1) /* L2_PTE not valid */
|
||||
return ERROR_FAIL;
|
||||
|
||||
*physical_address = (L2_page_table_entry & page_table_info_p->ppn_mask) |
|
||||
(virtual_address & page_table_info_p->va_offset_mask);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
48
src/target/nds32_tlb.h
Normal file
48
src/target/nds32_tlb.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 Andes Technology *
|
||||
* Hsiangkai Wang <hkwang@andestech.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
|
||||
***************************************************************************/
|
||||
#ifndef __NDS32_TLB_H__
|
||||
#define __NDS32_TLB_H__
|
||||
|
||||
#include "nds32.h"
|
||||
|
||||
enum {
|
||||
PAGE_SIZE_4K = 0,
|
||||
PAGE_SIZE_8K,
|
||||
PAGE_SIZE_NUM,
|
||||
};
|
||||
|
||||
struct page_table_walker_info_s {
|
||||
|
||||
uint32_t L1_offset_mask;
|
||||
uint32_t L1_offset_shift;
|
||||
uint32_t L2_offset_mask;
|
||||
uint32_t L2_offset_shift;
|
||||
uint32_t va_offset_mask;
|
||||
uint32_t L1_base_mask;
|
||||
uint32_t L2_base_mask;
|
||||
uint32_t ppn_mask;
|
||||
};
|
||||
|
||||
extern int nds32_probe_tlb(struct nds32 *nds32, const uint32_t virtual_address,
|
||||
uint32_t *physical_address);
|
||||
extern int nds32_walk_page_table(struct nds32 *nds32, const uint32_t virtual_address,
|
||||
uint32_t *physical_address);
|
||||
|
||||
#endif
|
||||
763
src/target/nds32_v2.c
Normal file
763
src/target/nds32_v2.c
Normal file
File diff suppressed because it is too large
Load Diff
44
src/target/nds32_v2.h
Normal file
44
src/target/nds32_v2.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 Andes Technology *
|
||||
* Hsiangkai Wang <hkwang@andestech.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
|
||||
***************************************************************************/
|
||||
#ifndef __NDS32_V2_H__
|
||||
#define __NDS32_V2_H__
|
||||
|
||||
#include "nds32.h"
|
||||
|
||||
struct nds32_v2_common {
|
||||
struct nds32 nds32;
|
||||
|
||||
uint32_t backup_ir0;
|
||||
|
||||
/** number of hardware breakpoints */
|
||||
int32_t n_hbr;
|
||||
|
||||
/** next hardware breakpoint index */
|
||||
/** increase from low index to high index */
|
||||
int32_t next_hbr_index;
|
||||
};
|
||||
|
||||
static inline struct nds32_v2_common *target_to_nds32_v2(struct target *target)
|
||||
{
|
||||
return container_of(target->arch_info, struct nds32_v2_common, nds32);
|
||||
}
|
||||
|
||||
|
||||
#endif /* __NDS32_V2_H__ */
|
||||
522
src/target/nds32_v3.c
Normal file
522
src/target/nds32_v3.c
Normal file
File diff suppressed because it is too large
Load Diff
46
src/target/nds32_v3.h
Normal file
46
src/target/nds32_v3.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 Andes Technology *
|
||||
* Hsiangkai Wang <hkwang@andestech.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
|
||||
***************************************************************************/
|
||||
#ifndef __NDS32_V3_H__
|
||||
#define __NDS32_V3_H__
|
||||
|
||||
#include "nds32.h"
|
||||
|
||||
struct nds32_v3_common {
|
||||
struct nds32 nds32;
|
||||
|
||||
/** number of hardware breakpoints */
|
||||
int32_t n_hbr;
|
||||
|
||||
/** number of used hardware watchpoints */
|
||||
int32_t used_n_wp;
|
||||
|
||||
/** next hardware breakpoint index */
|
||||
int32_t next_hbr_index;
|
||||
|
||||
/** low interference profiling */
|
||||
bool low_interference_profile;
|
||||
};
|
||||
|
||||
static inline struct nds32_v3_common *target_to_nds32_v3(struct target *target)
|
||||
{
|
||||
return container_of(target->arch_info, struct nds32_v3_common, nds32);
|
||||
}
|
||||
|
||||
#endif /* __NDS32_V3_H__ */
|
||||
492
src/target/nds32_v3_common.c
Normal file
492
src/target/nds32_v3_common.c
Normal file
@@ -0,0 +1,492 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2013 Andes Technology *
|
||||
* Hsiangkai Wang <hkwang@andestech.com> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "breakpoints.h"
|
||||
#include "nds32_reg.h"
|
||||
#include "nds32_disassembler.h"
|
||||
#include "nds32.h"
|
||||
#include "nds32_aice.h"
|
||||
#include "nds32_v3_common.h"
|
||||
|
||||
static struct nds32_v3_common_callback *v3_common_callback;
|
||||
|
||||
static int nds32_v3_register_mapping(struct nds32 *nds32, int reg_no)
|
||||
{
|
||||
if (reg_no == PC)
|
||||
return IR11;
|
||||
|
||||
return reg_no;
|
||||
}
|
||||
|
||||
static int nds32_v3_get_debug_reason(struct nds32 *nds32, uint32_t *reason)
|
||||
{
|
||||
uint32_t edmsw;
|
||||
struct aice_port_s *aice = target_to_aice(nds32->target);
|
||||
aice_read_debug_reg(aice, NDS_EDM_SR_EDMSW, &edmsw);
|
||||
|
||||
*reason = (edmsw >> 12) & 0x0F;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save processor state. This is called after a HALT instruction
|
||||
* succeeds, and on other occasions the processor enters debug mode
|
||||
* (breakpoint, watchpoint, etc).
|
||||
*/
|
||||
static int nds32_v3_debug_entry(struct nds32 *nds32, bool enable_watchpoint)
|
||||
{
|
||||
LOG_DEBUG("nds32_v3_debug_entry");
|
||||
|
||||
jtag_poll_set_enabled(false);
|
||||
|
||||
enum target_state backup_state = nds32->target->state;
|
||||
nds32->target->state = TARGET_HALTED;
|
||||
|
||||
if (nds32->init_arch_info_after_halted == false) {
|
||||
/* init architecture info according to config registers */
|
||||
CHECK_RETVAL(nds32_config(nds32));
|
||||
|
||||
nds32->init_arch_info_after_halted = true;
|
||||
}
|
||||
|
||||
/* REVISIT entire cache should already be invalid !!! */
|
||||
register_cache_invalidate(nds32->core_cache);
|
||||
|
||||
/* deactivate all hardware breakpoints */
|
||||
CHECK_RETVAL(v3_common_callback->deactivate_hardware_breakpoint(nds32->target));
|
||||
|
||||
if (enable_watchpoint)
|
||||
CHECK_RETVAL(v3_common_callback->deactivate_hardware_watchpoint(nds32->target));
|
||||
|
||||
if (ERROR_OK != nds32_examine_debug_reason(nds32)) {
|
||||
nds32->target->state = backup_state;
|
||||
|
||||
/* re-activate all hardware breakpoints & watchpoints */
|
||||
CHECK_RETVAL(v3_common_callback->activate_hardware_breakpoint(nds32->target));
|
||||
|
||||
if (enable_watchpoint)
|
||||
CHECK_RETVAL(v3_common_callback->activate_hardware_watchpoint(nds32->target));
|
||||
|
||||
jtag_poll_set_enabled(true);
|
||||
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
/* Save registers. */
|
||||
nds32_full_context(nds32);
|
||||
|
||||
/* check interrupt level */
|
||||
v3_common_callback->check_interrupt_stack(nds32);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore processor state.
|
||||
*/
|
||||
static int nds32_v3_leave_debug_state(struct nds32 *nds32, bool enable_watchpoint)
|
||||
{
|
||||
LOG_DEBUG("nds32_v3_leave_debug_state");
|
||||
|
||||
struct target *target = nds32->target;
|
||||
|
||||
/* activate all hardware breakpoints */
|
||||
CHECK_RETVAL(v3_common_callback->activate_hardware_breakpoint(target));
|
||||
|
||||
if (enable_watchpoint) {
|
||||
/* activate all watchpoints */
|
||||
CHECK_RETVAL(v3_common_callback->activate_hardware_watchpoint(target));
|
||||
}
|
||||
|
||||
/* restore interrupt stack */
|
||||
v3_common_callback->restore_interrupt_stack(nds32);
|
||||
|
||||
/* REVISIT once we start caring about MMU and cache state,
|
||||
* address it here ...
|
||||
*/
|
||||
|
||||
/* restore PSW, PC, and R0 ... after flushing any modified
|
||||
* registers.
|
||||
*/
|
||||
CHECK_RETVAL(nds32_restore_context(target));
|
||||
|
||||
/* enable polling */
|
||||
jtag_poll_set_enabled(true);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
static int nds32_v3_get_exception_address(struct nds32 *nds32,
|
||||
uint32_t *address, uint32_t reason)
|
||||
{
|
||||
LOG_DEBUG("nds32_v3_get_exception_address");
|
||||
|
||||
struct aice_port_s *aice = target_to_aice(nds32->target);
|
||||
struct target *target = nds32->target;
|
||||
uint32_t edmsw;
|
||||
uint32_t edm_cfg;
|
||||
uint32_t match_bits;
|
||||
uint32_t match_count;
|
||||
int32_t i;
|
||||
static int32_t number_of_hard_break;
|
||||
|
||||
if (number_of_hard_break == 0) {
|
||||
aice_read_debug_reg(aice, NDS_EDM_SR_EDM_CFG, &edm_cfg);
|
||||
number_of_hard_break = (edm_cfg & 0x7) + 1;
|
||||
}
|
||||
|
||||
aice_read_debug_reg(aice, NDS_EDM_SR_EDMSW, &edmsw);
|
||||
/* clear matching bits (write-one-clear) */
|
||||
aice_write_debug_reg(aice, NDS_EDM_SR_EDMSW, edmsw);
|
||||
match_bits = (edmsw >> 4) & 0xFF;
|
||||
match_count = 0;
|
||||
for (i = 0 ; i < number_of_hard_break ; i++) {
|
||||
if (match_bits & (1 << i)) {
|
||||
aice_read_debug_reg(aice, NDS_EDM_SR_BPA0 + i, address);
|
||||
match_count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (match_count > 1) { /* multiple hits */
|
||||
*address = 0;
|
||||
return ERROR_OK;
|
||||
} else if (match_count == 1) {
|
||||
uint32_t val_pc;
|
||||
uint32_t opcode;
|
||||
struct nds32_instruction instruction;
|
||||
struct watchpoint *wp;
|
||||
bool hit;
|
||||
|
||||
nds32_get_mapped_reg(nds32, PC, &val_pc);
|
||||
|
||||
if ((NDS32_DEBUG_DATA_ADDR_WATCHPOINT_NEXT_PRECISE == reason) ||
|
||||
(NDS32_DEBUG_DATA_VALUE_WATCHPOINT_NEXT_PRECISE == reason)) {
|
||||
if (edmsw & 0x4) /* check EDMSW.IS_16BIT */
|
||||
val_pc -= 2;
|
||||
else
|
||||
val_pc -= 4;
|
||||
}
|
||||
|
||||
nds32_read_opcode(nds32, val_pc, &opcode);
|
||||
nds32_evaluate_opcode(nds32, opcode, val_pc, &instruction);
|
||||
|
||||
LOG_DEBUG("PC: 0x%08x, access start: 0x%08x, end: 0x%08x", val_pc,
|
||||
instruction.access_start, instruction.access_end);
|
||||
|
||||
/* check if multiple hits in the access range */
|
||||
uint32_t in_range_watch_count = 0;
|
||||
for (wp = target->watchpoints; wp; wp = wp->next) {
|
||||
if ((instruction.access_start <= wp->address) &&
|
||||
(wp->address < instruction.access_end))
|
||||
in_range_watch_count++;
|
||||
}
|
||||
if (in_range_watch_count > 1) {
|
||||
/* Hit LSMW instruction. */
|
||||
*address = 0;
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
/* dispel false match */
|
||||
hit = false;
|
||||
for (wp = target->watchpoints; wp; wp = wp->next) {
|
||||
if (((*address ^ wp->address) & (~wp->mask)) == 0) {
|
||||
uint32_t watch_start;
|
||||
uint32_t watch_end;
|
||||
|
||||
watch_start = wp->address;
|
||||
watch_end = wp->address + wp->length;
|
||||
|
||||
if ((watch_end <= instruction.access_start) ||
|
||||
(instruction.access_end <= watch_start))
|
||||
continue;
|
||||
|
||||
hit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hit)
|
||||
return ERROR_OK;
|
||||
else
|
||||
return ERROR_FAIL;
|
||||
} else if (match_count == 0) {
|
||||
/* global stop is precise exception */
|
||||
if ((NDS32_DEBUG_LOAD_STORE_GLOBAL_STOP == reason) && nds32->global_stop) {
|
||||
/* parse instruction to get correct access address */
|
||||
uint32_t val_pc;
|
||||
uint32_t opcode;
|
||||
struct nds32_instruction instruction;
|
||||
|
||||
nds32_get_mapped_reg(nds32, PC, &val_pc);
|
||||
nds32_read_opcode(nds32, val_pc, &opcode);
|
||||
nds32_evaluate_opcode(nds32, opcode, val_pc, &instruction);
|
||||
|
||||
*address = instruction.access_start;
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
}
|
||||
|
||||
*address = 0xFFFFFFFF;
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
void nds32_v3_common_register_callback(struct nds32_v3_common_callback *callback)
|
||||
{
|
||||
v3_common_callback = callback;
|
||||
}
|
||||
|
||||
/** target_type functions: */
|
||||
/* target request support */
|
||||
int nds32_v3_target_request_data(struct target *target,
|
||||
uint32_t size, uint8_t *buffer)
|
||||
{
|
||||
/* AndesCore could use DTR register to communicate with OpenOCD
|
||||
* to output messages
|
||||
* Target data will be put in buffer
|
||||
* The format of DTR is as follow
|
||||
* DTR[31:16] => length, DTR[15:8] => size, DTR[7:0] => target_req_cmd
|
||||
* target_req_cmd has three possible values:
|
||||
* TARGET_REQ_TRACEMSG
|
||||
* TARGET_REQ_DEBUGMSG
|
||||
* TARGET_REQ_DEBUGCHAR
|
||||
* if size == 0, target will call target_asciimsg(),
|
||||
* else call target_hexmsg()
|
||||
*/
|
||||
LOG_WARNING("Not implemented: %s", __func__);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
int nds32_v3_soft_reset_halt(struct target *target)
|
||||
{
|
||||
struct aice_port_s *aice = target_to_aice(target);
|
||||
return aice_assert_srst(aice, AICE_RESET_HOLD);
|
||||
}
|
||||
|
||||
int nds32_v3_checksum_memory(struct target *target,
|
||||
uint32_t address, uint32_t count, uint32_t *checksum)
|
||||
{
|
||||
LOG_WARNING("Not implemented: %s", __func__);
|
||||
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
int nds32_v3_target_create_common(struct target *target, struct nds32 *nds32)
|
||||
{
|
||||
nds32->register_map = nds32_v3_register_mapping;
|
||||
nds32->get_debug_reason = nds32_v3_get_debug_reason;
|
||||
nds32->enter_debug_state = nds32_v3_debug_entry;
|
||||
nds32->leave_debug_state = nds32_v3_leave_debug_state;
|
||||
nds32->get_watched_address = nds32_v3_get_exception_address;
|
||||
|
||||
/* Init target->arch_info in nds32_init_arch_info().
|
||||
* After this, user could use target_to_nds32() to get nds32 object */
|
||||
nds32_init_arch_info(target, nds32);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
|
||||
int nds32_v3_run_algorithm(struct target *target,
|
||||
int num_mem_params,
|
||||
struct mem_param *mem_params,
|
||||
int num_reg_params,
|
||||
struct reg_param *reg_params,
|
||||
uint32_t entry_point,
|
||||
uint32_t exit_point,
|
||||
int timeout_ms,
|
||||
void *arch_info)
|
||||
{
|
||||
LOG_WARNING("Not implemented: %s", __func__);
|
||||
|
||||
return ERROR_FAIL;
|
||||
}
|
||||
|
||||
int nds32_v3_read_buffer(struct target *target, uint32_t address,
|
||||
uint32_t size, uint8_t *buffer)
|
||||
{
|
||||
struct nds32 *nds32 = target_to_nds32(target);
|
||||
struct nds32_memory *memory = &(nds32->memory);
|
||||
|
||||
if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
|
||||
(target->state != TARGET_HALTED)) {
|
||||
LOG_WARNING("target was not halted");
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
uint32_t physical_address;
|
||||
/* BUG: If access range crosses multiple pages, the translation will not correct
|
||||
* for second page or so. */
|
||||
|
||||
/* When DEX is set to one, hardware will enforce the following behavior without
|
||||
* modifying the corresponding control bits in PSW.
|
||||
*
|
||||
* Disable all interrupts
|
||||
* Become superuser mode
|
||||
* Turn off IT/DT
|
||||
* Use MMU_CFG.DE as the data access endian
|
||||
* Use MMU_CFG.DRDE as the device register access endian if MMU_CTL.DREE is asserted
|
||||
* Disable audio special features
|
||||
* Disable inline function call
|
||||
*
|
||||
* 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))
|
||||
address = physical_address;
|
||||
else
|
||||
return ERROR_FAIL;
|
||||
|
||||
return nds32_read_buffer(target, address, size, buffer);
|
||||
}
|
||||
|
||||
int nds32_v3_write_buffer(struct target *target, uint32_t address,
|
||||
uint32_t size, const uint8_t *buffer)
|
||||
{
|
||||
struct nds32 *nds32 = target_to_nds32(target);
|
||||
struct nds32_memory *memory = &(nds32->memory);
|
||||
|
||||
if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
|
||||
(target->state != TARGET_HALTED)) {
|
||||
LOG_WARNING("target was not halted");
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
uint32_t physical_address;
|
||||
/* BUG: If access range crosses multiple pages, the translation will not correct
|
||||
* for second page or so. */
|
||||
|
||||
/* When DEX is set to one, hardware will enforce the following behavior without
|
||||
* modifying the corresponding control bits in PSW.
|
||||
*
|
||||
* Disable all interrupts
|
||||
* Become superuser mode
|
||||
* Turn off IT/DT
|
||||
* Use MMU_CFG.DE as the data access endian
|
||||
* Use MMU_CFG.DRDE as the device register access endian if MMU_CTL.DREE is asserted
|
||||
* Disable audio special features
|
||||
* Disable inline function call
|
||||
*
|
||||
* 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))
|
||||
address = physical_address;
|
||||
else
|
||||
return ERROR_FAIL;
|
||||
|
||||
return nds32_write_buffer(target, address, size, buffer);
|
||||
}
|
||||
|
||||
int nds32_v3_read_memory(struct target *target, uint32_t address,
|
||||
uint32_t size, uint32_t count, uint8_t *buffer)
|
||||
{
|
||||
struct nds32 *nds32 = target_to_nds32(target);
|
||||
struct nds32_memory *memory = &(nds32->memory);
|
||||
|
||||
if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
|
||||
(target->state != TARGET_HALTED)) {
|
||||
LOG_WARNING("target was not halted");
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
uint32_t physical_address;
|
||||
/* BUG: If access range crosses multiple pages, the translation will not correct
|
||||
* for second page or so. */
|
||||
|
||||
/* When DEX is set to one, hardware will enforce the following behavior without
|
||||
* modifying the corresponding control bits in PSW.
|
||||
*
|
||||
* Disable all interrupts
|
||||
* Become superuser mode
|
||||
* Turn off IT/DT
|
||||
* Use MMU_CFG.DE as the data access endian
|
||||
* Use MMU_CFG.DRDE as the device register access endian if MMU_CTL.DREE is asserted
|
||||
* Disable audio special features
|
||||
* Disable inline function call
|
||||
*
|
||||
* 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))
|
||||
address = physical_address;
|
||||
else
|
||||
return ERROR_FAIL;
|
||||
|
||||
int result;
|
||||
|
||||
result = nds32_read_memory(target, address, size, count, buffer);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int nds32_v3_write_memory(struct target *target, uint32_t address,
|
||||
uint32_t size, uint32_t count, const uint8_t *buffer)
|
||||
{
|
||||
struct nds32 *nds32 = target_to_nds32(target);
|
||||
struct nds32_memory *memory = &(nds32->memory);
|
||||
|
||||
if ((NDS_MEMORY_ACC_CPU == memory->access_channel) &&
|
||||
(target->state != TARGET_HALTED)) {
|
||||
LOG_WARNING("target was not halted");
|
||||
return ERROR_TARGET_NOT_HALTED;
|
||||
}
|
||||
|
||||
uint32_t physical_address;
|
||||
/* BUG: If access range crosses multiple pages, the translation will not correct
|
||||
* for second page or so. */
|
||||
|
||||
/* When DEX is set to one, hardware will enforce the following behavior without
|
||||
* modifying the corresponding control bits in PSW.
|
||||
*
|
||||
* Disable all interrupts
|
||||
* Become superuser mode
|
||||
* Turn off IT/DT
|
||||
* Use MMU_CFG.DE as the data access endian
|
||||
* Use MMU_CFG.DRDE as the device register access endian if MMU_CTL.DREE is asserted
|
||||
* Disable audio special features
|
||||
* Disable inline function call
|
||||
*
|
||||
* 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))
|
||||
address = physical_address;
|
||||
else
|
||||
return ERROR_FAIL;
|
||||
|
||||
return nds32_write_memory(target, address, size, count, buffer);
|
||||
}
|
||||
|
||||
int nds32_v3_init_target(struct command_context *cmd_ctx,
|
||||
struct target *target)
|
||||
{
|
||||
/* Initialize anything we can set up without talking to the target */
|
||||
struct nds32 *nds32 = target_to_nds32(target);
|
||||
|
||||
nds32_init(nds32);
|
||||
|
||||
return ERROR_OK;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user