Line 46... |
Line 46... |
#endif
|
#endif
|
|
|
pthread_mutex_t dbg_access_mutex = PTHREAD_MUTEX_INITIALIZER;
|
pthread_mutex_t dbg_access_mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
|
/* read a word from wishbone */
|
/* read a word from wishbone */
|
int dbg_wb_read32(unsigned long adr, unsigned long *data) {
|
int dbg_wb_read32(uint32_t adr, uint32_t *data) {
|
int err;
|
int err;
|
pthread_mutex_lock(&dbg_access_mutex);
|
pthread_mutex_lock(&dbg_access_mutex);
|
|
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
{
|
{
|
Line 73... |
Line 73... |
pthread_mutex_unlock(&dbg_access_mutex);
|
pthread_mutex_unlock(&dbg_access_mutex);
|
return err;
|
return err;
|
}
|
}
|
|
|
/* write a word to wishbone */
|
/* write a word to wishbone */
|
int dbg_wb_write32(unsigned long adr, unsigned long data) {
|
int dbg_wb_write32(uint32_t adr, uint32_t data) {
|
int err;
|
int err;
|
pthread_mutex_lock(&dbg_access_mutex);
|
pthread_mutex_lock(&dbg_access_mutex);
|
|
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
{
|
{
|
Line 101... |
Line 101... |
return err;
|
return err;
|
}
|
}
|
|
|
// write a word to wishbone
|
// write a word to wishbone
|
// Never actually called from the GDB interface
|
// Never actually called from the GDB interface
|
int dbg_wb_write16(unsigned long adr, uint16_t data) {
|
int dbg_wb_write16(uint32_t adr, uint16_t data) {
|
int err;
|
int err;
|
pthread_mutex_lock(&dbg_access_mutex);
|
pthread_mutex_lock(&dbg_access_mutex);
|
|
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
{
|
{
|
Line 129... |
Line 129... |
return err;
|
return err;
|
}
|
}
|
|
|
// write a word to wishbone
|
// write a word to wishbone
|
// Never actually called from the GDB interface
|
// Never actually called from the GDB interface
|
int dbg_wb_write8(unsigned long adr, uint8_t data) {
|
int dbg_wb_write8(uint32_t adr, uint8_t data) {
|
int err;
|
int err;
|
pthread_mutex_lock(&dbg_access_mutex);
|
pthread_mutex_lock(&dbg_access_mutex);
|
|
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
{
|
{
|
Line 155... |
Line 155... |
pthread_mutex_unlock(&dbg_access_mutex);
|
pthread_mutex_unlock(&dbg_access_mutex);
|
return err;
|
return err;
|
}
|
}
|
|
|
|
|
int dbg_wb_read_block32(unsigned long adr, unsigned long *data, int len) {
|
int dbg_wb_read_block32(uint32_t adr, uint32_t *data, int len) {
|
int err;
|
int err;
|
|
|
if(!len)
|
if(!len)
|
return APP_ERR_NONE; // GDB may issue a 0-length transaction to test if a feature is supported
|
return APP_ERR_NONE; // GDB may issue a 0-length transaction to test if a feature is supported
|
|
|
Line 188... |
Line 188... |
return err;
|
return err;
|
}
|
}
|
|
|
|
|
// Never actually called from the GDB interface
|
// Never actually called from the GDB interface
|
int dbg_wb_read_block16(unsigned long adr, uint16_t *data, int len) {
|
int dbg_wb_read_block16(uint32_t adr, uint16_t *data, int len) {
|
int err;
|
int err;
|
|
|
if(!len)
|
if(!len)
|
return APP_ERR_NONE; // GDB may issue a 0-length transaction to test if a feature is supported
|
return APP_ERR_NONE; // GDB may issue a 0-length transaction to test if a feature is supported
|
|
|
Line 220... |
Line 220... |
pthread_mutex_unlock(&dbg_access_mutex);
|
pthread_mutex_unlock(&dbg_access_mutex);
|
return err;
|
return err;
|
}
|
}
|
|
|
// Never actually called from the GDB interface
|
// Never actually called from the GDB interface
|
int dbg_wb_read_block8(unsigned long adr, uint8_t *data, int len) {
|
int dbg_wb_read_block8(uint32_t adr, uint8_t *data, int len) {
|
int err;
|
int err;
|
|
|
if(!len)
|
if(!len)
|
return APP_ERR_NONE; // GDB may issue a 0-length transaction to test if a feature is supported
|
return APP_ERR_NONE; // GDB may issue a 0-length transaction to test if a feature is supported
|
|
|
Line 250... |
Line 250... |
return err;
|
return err;
|
}
|
}
|
|
|
|
|
// write a block to wishbone
|
// write a block to wishbone
|
int dbg_wb_write_block32(unsigned long adr, unsigned long *data, int len) {
|
int dbg_wb_write_block32(uint32_t adr, uint32_t *data, int len) {
|
int err;
|
int err;
|
|
|
if(!len)
|
if(!len)
|
return APP_ERR_NONE; // GDB may issue a 0-length transaction to test if a feature is supported
|
return APP_ERR_NONE; // GDB may issue a 0-length transaction to test if a feature is supported
|
|
|
Line 284... |
Line 284... |
}
|
}
|
|
|
|
|
// write a block to wishbone
|
// write a block to wishbone
|
// Never actually called from the GDB interface
|
// Never actually called from the GDB interface
|
int dbg_wb_write_block16(unsigned long adr, uint16_t *data, int len) {
|
int dbg_wb_write_block16(uint32_t adr, uint16_t *data, int len) {
|
int err;
|
int err;
|
|
|
if(!len)
|
if(!len)
|
return APP_ERR_NONE; // GDB may issue a 0-length transaction to test if a feature is supported
|
return APP_ERR_NONE; // GDB may issue a 0-length transaction to test if a feature is supported
|
|
|
Line 316... |
Line 316... |
pthread_mutex_unlock(&dbg_access_mutex);
|
pthread_mutex_unlock(&dbg_access_mutex);
|
return err;
|
return err;
|
}
|
}
|
|
|
// write a block to wishbone
|
// write a block to wishbone
|
int dbg_wb_write_block8(unsigned long adr, uint8_t *data, int len) {
|
int dbg_wb_write_block8(uint32_t adr, uint8_t *data, int len) {
|
int err;
|
int err;
|
|
|
if(!len)
|
if(!len)
|
return APP_ERR_NONE; // GDB may issue a 0-length transaction to test if a feature is supported
|
return APP_ERR_NONE; // GDB may issue a 0-length transaction to test if a feature is supported
|
|
|
Line 346... |
Line 346... |
return err;
|
return err;
|
}
|
}
|
|
|
|
|
/* read a register from cpu0. This is assumed to be an OR32 CPU, with 32-bit regs. */
|
/* read a register from cpu0. This is assumed to be an OR32 CPU, with 32-bit regs. */
|
int dbg_cpu0_read(unsigned long adr, unsigned long *data) {
|
int dbg_cpu0_read(uint32_t adr, uint32_t *data) {
|
int err;
|
int err;
|
pthread_mutex_lock(&dbg_access_mutex);
|
pthread_mutex_lock(&dbg_access_mutex);
|
|
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
{
|
{
|
Line 374... |
Line 374... |
debug("dbg_cpu_read(), addr 0x%X, data[0] = 0x%X\n", adr, data[0]);
|
debug("dbg_cpu_read(), addr 0x%X, data[0] = 0x%X\n", adr, data[0]);
|
return err;
|
return err;
|
}
|
}
|
|
|
/* read multiple registers from cpu0. This is assumed to be an OR32 CPU, with 32-bit regs. */
|
/* read multiple registers from cpu0. This is assumed to be an OR32 CPU, with 32-bit regs. */
|
int dbg_cpu0_read_block(unsigned long adr, unsigned long *data, int count) {
|
int dbg_cpu0_read_block(uint32_t adr, uint32_t *data, int count) {
|
int err;
|
int err;
|
|
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
{
|
{
|
pthread_mutex_lock(&dbg_access_mutex);
|
pthread_mutex_lock(&dbg_access_mutex);
|
Line 405... |
Line 405... |
debug("dbg_cpu_read_block(), addr 0x%X, count %i, data[0] = 0x%X\n", adr, count, data[0]);
|
debug("dbg_cpu_read_block(), addr 0x%X, count %i, data[0] = 0x%X\n", adr, count, data[0]);
|
return err;
|
return err;
|
}
|
}
|
|
|
/* write a cpu register to cpu0. This is assumed to be an OR32 CPU, with 32-bit regs. */
|
/* write a cpu register to cpu0. This is assumed to be an OR32 CPU, with 32-bit regs. */
|
int dbg_cpu0_write(unsigned long adr, unsigned long data) {
|
int dbg_cpu0_write(uint32_t adr, uint32_t data) {
|
int err;
|
int err;
|
pthread_mutex_lock(&dbg_access_mutex);
|
pthread_mutex_lock(&dbg_access_mutex);
|
|
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
{
|
{
|
Line 433... |
Line 433... |
pthread_mutex_unlock(&dbg_access_mutex);
|
pthread_mutex_unlock(&dbg_access_mutex);
|
return err;
|
return err;
|
}
|
}
|
|
|
/* write multiple cpu registers to cpu0. This is assumed to be an OR32 CPU, with 32-bit regs. */
|
/* write multiple cpu registers to cpu0. This is assumed to be an OR32 CPU, with 32-bit regs. */
|
int dbg_cpu0_write_block(unsigned long adr, unsigned long *data, int count) {
|
int dbg_cpu0_write_block(uint32_t adr, uint32_t *data, int count) {
|
int err;
|
int err;
|
|
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
{
|
{
|
pthread_mutex_lock(&dbg_access_mutex);
|
pthread_mutex_lock(&dbg_access_mutex);
|
Line 466... |
Line 466... |
}
|
}
|
|
|
/* write a debug unit cpu module register
|
/* write a debug unit cpu module register
|
* Since OR32 debug module has only 1 register,
|
* Since OR32 debug module has only 1 register,
|
* adr is ignored (for now) */
|
* adr is ignored (for now) */
|
int dbg_cpu0_write_ctrl(unsigned long adr, unsigned char data) {
|
int dbg_cpu0_write_ctrl(uint32_t adr, uint8_t data) {
|
int err = APP_ERR_NONE;
|
int err = APP_ERR_NONE;
|
uint32_t dataword = data;
|
uint32_t dataword = data;
|
pthread_mutex_lock(&dbg_access_mutex);
|
pthread_mutex_lock(&dbg_access_mutex);
|
|
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
Line 501... |
Line 501... |
|
|
|
|
/* read a register from cpu module of the debug unit.
|
/* read a register from cpu module of the debug unit.
|
* Currently, there is only 1 register, so we do not need to select it, adr is ignored
|
* Currently, there is only 1 register, so we do not need to select it, adr is ignored
|
*/
|
*/
|
int dbg_cpu0_read_ctrl(unsigned long adr, unsigned char *data) {
|
int dbg_cpu0_read_ctrl(uint32_t adr, uint8_t *data) {
|
int err = APP_ERR_NONE;
|
int err = APP_ERR_NONE;
|
uint32_t dataword;
|
uint32_t dataword;
|
pthread_mutex_lock(&dbg_access_mutex);
|
pthread_mutex_lock(&dbg_access_mutex);
|
|
|
// reset is bit 1, stall is bit 0 in *data
|
// reset is bit 1, stall is bit 0 in *data
|
Line 539... |
Line 539... |
}
|
}
|
|
|
// CPU1 Functions. Note that 2 CPUs are not currently supported by GDB, so these are never actually
|
// CPU1 Functions. Note that 2 CPUs are not currently supported by GDB, so these are never actually
|
// called from the GDB interface. They are included for completeness and future use.
|
// called from the GDB interface. They are included for completeness and future use.
|
// read a register from cpu1
|
// read a register from cpu1
|
int dbg_cpu1_read(unsigned long adr, unsigned long *data)
|
int dbg_cpu1_read(uint32_t adr, uint32_t *data)
|
{
|
{
|
int err;
|
int err;
|
pthread_mutex_lock(&dbg_access_mutex);
|
pthread_mutex_lock(&dbg_access_mutex);
|
|
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
Line 568... |
Line 568... |
return err;
|
return err;
|
}
|
}
|
|
|
|
|
// write a cpu register
|
// write a cpu register
|
int dbg_cpu1_write(unsigned long adr, unsigned long data)
|
int dbg_cpu1_write(uint32_t adr, uint32_t data)
|
{
|
{
|
int err;
|
int err;
|
pthread_mutex_lock(&dbg_access_mutex);
|
pthread_mutex_lock(&dbg_access_mutex);
|
|
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
Line 597... |
Line 597... |
return err;
|
return err;
|
}
|
}
|
|
|
|
|
// write a debug unit cpu module register
|
// write a debug unit cpu module register
|
int dbg_cpu1_write_ctrl(unsigned long adr, unsigned char data) {
|
int dbg_cpu1_write_ctrl(uint32_t adr, uint8_t data) {
|
int err;
|
int err;
|
uint32_t dataword = data;
|
uint32_t dataword = data;
|
pthread_mutex_lock(&dbg_access_mutex);
|
pthread_mutex_lock(&dbg_access_mutex);
|
|
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
if(DEBUG_HARDWARE == DBG_HW_ADVANCED)
|
Line 629... |
Line 629... |
return err;
|
return err;
|
}
|
}
|
|
|
|
|
// read a debug unit cpu module register
|
// read a debug unit cpu module register
|
int dbg_cpu1_read_ctrl(unsigned long adr, unsigned char *data) {
|
int dbg_cpu1_read_ctrl(uint32_t adr, uint8_t *data) {
|
int err;
|
int err;
|
uint32_t dataword;
|
uint32_t dataword;
|
pthread_mutex_lock(&dbg_access_mutex);
|
pthread_mutex_lock(&dbg_access_mutex);
|
|
|
// reset is bit 1, stall is bit 0 in *data
|
// reset is bit 1, stall is bit 0 in *data
|
Line 664... |
Line 664... |
cable_flush();
|
cable_flush();
|
pthread_mutex_unlock(&dbg_access_mutex);
|
pthread_mutex_unlock(&dbg_access_mutex);
|
return err;
|
return err;
|
}
|
}
|
|
|
int dbg_serial_sndrcv(unsigned int *bytes_to_send, const char *data_to_send, unsigned int *bytes_received, char *data_received) {
|
int dbg_serial_sndrcv(unsigned int *bytes_to_send, const uint8_t *data_to_send, unsigned int *bytes_received, uint8_t *data_received) {
|
int err;
|
int err;
|
|
|
pthread_mutex_lock(&dbg_access_mutex);
|
pthread_mutex_lock(&dbg_access_mutex);
|
|
|
if ((err = adbg_select_module(DC_JSP))) {
|
if ((err = adbg_select_module(DC_JSP))) {
|