URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
Compare Revisions
- This comparison shows the changes necessary to convert path
/or1k/trunk
- from Rev 1779 to Rev 1780
- ↔ Reverse comparison
Rev 1779 → Rev 1780
/or_debug_proxy/src/or_debug_proxy.c
65,8 → 65,15
#endif |
|
#include "gdb.h" |
|
#ifdef USB_ENDPOINT_ENABLED |
#include "usb_functions.h" |
#endif |
|
#ifdef VPI_ENDPOINT_ENABLED |
#include "vpi_functions.h" |
#endif |
|
#include "or_debug_proxy.h" |
|
// Defines of endpoint numbers |
73,6 → 80,7
#define ENDPOINT_TARGET_NONE 0 |
#define ENDPOINT_TARGET_USB 1 |
#define ENDPOINT_TARGET_VPI 2 |
|
static int endpoint_target; // Either VPI interface via sockets, or the USB device |
|
#define GDB_PROTOCOL_JTAG 1 |
94,6 → 102,14
endpoint_target = ENDPOINT_TARGET_NONE; |
int inp_arg = 1; |
|
// Check we were compiled with at least one endpoint enabled |
#ifndef USB_ENDPOINT_ENABLED |
#ifndef VPI_ENDPOINT_ENABLED |
printf("No endpoints enabled.\nRecompile the proxy with at least one endpoint enabled\n"); |
exit(0); |
#endif |
#endif |
|
// init our global error number |
err = DBG_ERR_OK; |
|
155,6 → 171,7
|
/* Initialise connection to our OR1k system */ |
current_chain = -1; |
#ifdef USB_ENDPOINT_ENABLED |
/* USB Endpoint */ |
if (endpoint_target == ENDPOINT_TARGET_USB) |
{ |
162,8 → 179,10
if ((err = usb_dbg_reset())) goto JtagIfError; |
dbg_test(); // Perform some tests |
} |
#endif |
#ifdef VPI_ENDPOINT_ENABLED |
/* RTL simulation endpoint */ |
else if (endpoint_target == ENDPOINT_TARGET_VPI){ |
if (endpoint_target == ENDPOINT_TARGET_VPI){ |
printf("\nConnecting to OR1k RTL simulation\n\n"); |
// Connect to the (hopefully) already running RTL simulation server running via VPI |
vpi_fd = vpi_connect(); |
171,6 → 190,7
if ((err = vpi_dbg_reset())) goto JtagIfError; |
vpi_dbg_test(); // Perform some tests |
} |
#endif |
|
/* We have a connection to the target system. Now establish server connection. */ |
if(gdb_protocol == GDB_PROTOCOL_JTAG) |
213,115 → 233,172
|
int dbg_reset() |
{ |
#ifdef USB_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_USB) return usb_dbg_reset(); |
else if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_reset(); |
else return DBG_ERR_INVALID_ENDPOINT; |
#endif |
#ifdef VPI_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_reset(); |
#endif |
return DBG_ERR_INVALID_ENDPOINT; |
} |
|
void dbg_test() { |
#ifdef USB_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_USB) usb_dbg_test(); |
else if (endpoint_target == ENDPOINT_TARGET_VPI) vpi_dbg_test(); |
#endif |
#ifdef VPI_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_VPI) vpi_dbg_test(); |
#endif |
} |
|
/* Set TAP instruction register */ |
int dbg_set_tap_ir(uint32_t ir) { |
#ifdef USB_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_USB) usb_set_tap_ir(ir); |
else return DBG_ERR_INVALID_ENDPOINT; |
return 0; |
#endif |
return DBG_ERR_INVALID_ENDPOINT; |
} |
|
/* Sets scan chain. */ |
int dbg_set_chain(uint32_t chain) { |
#ifdef USB_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_USB) return usb_dbg_set_chain(chain); |
else if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_set_chain(chain); |
else return DBG_ERR_INVALID_ENDPOINT; |
#endif |
#ifdef VPI_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_set_chain(chain); |
#endif |
return DBG_ERR_INVALID_ENDPOINT; |
} |
|
/* sends out a command with 32bit address and 16bit length, if len >= 0 */ |
int dbg_command(uint32_t type, uint32_t adr, uint32_t len) { |
// This is never called by any of the VPI functions, so only USB endpoint |
#ifdef USB_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_USB) return usb_dbg_command(type,adr,len); |
else return DBG_ERR_INVALID_ENDPOINT; |
#endif |
return DBG_ERR_INVALID_ENDPOINT; |
} |
|
/* writes a ctrl reg */ |
int dbg_ctrl(uint32_t reset, uint32_t stall) { |
#ifdef USB_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_USB) return usb_dbg_ctrl(reset, stall); |
else if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_ctrl(reset, stall); |
else return DBG_ERR_INVALID_ENDPOINT; |
#endif |
#ifdef VPI_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_ctrl(reset, stall); |
#endif |
return DBG_ERR_INVALID_ENDPOINT; |
} |
|
/* reads control register */ |
int dbg_ctrl_read(uint32_t *reset, uint32_t *stall) { |
#ifdef USB_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_USB) return usb_dbg_ctrl_read(reset, stall); |
else if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_ctrl_read(reset, stall); |
else return DBG_ERR_INVALID_ENDPOINT; |
#endif |
#ifdef VPI_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_ctrl_read(reset, stall); |
#endif |
return DBG_ERR_INVALID_ENDPOINT; |
} |
|
/* issues a burst read/write */ |
int dbg_go(unsigned char *data, uint16_t len, uint32_t read) { |
// Only USB endpouint32_t option here |
#ifdef USB_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_USB) return usb_dbg_go(data, len, read); |
else return DBG_ERR_INVALID_ENDPOINT; |
#endif |
return DBG_ERR_INVALID_ENDPOINT; |
} |
|
/* read a word from wishbone */ |
int dbg_wb_read32(uint32_t adr, uint32_t *data) { |
#ifdef USB_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_USB) return usb_dbg_wb_read32(adr, data); |
else if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_wb_read32(adr, data); |
else return DBG_ERR_INVALID_ENDPOINT; |
#endif |
#ifdef VPI_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_wb_read32(adr, data); |
#endif |
return DBG_ERR_INVALID_ENDPOINT; |
} |
|
|
/* write a word to wishbone */ |
int dbg_wb_write32(uint32_t adr, uint32_t data) { |
#ifdef USB_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_USB) return usb_dbg_wb_write32( adr, data); |
else if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_wb_write32( adr, data); |
else return DBG_ERR_INVALID_ENDPOINT; |
#endif |
#ifdef VPI_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_wb_write32( adr, data); |
#endif |
return DBG_ERR_INVALID_ENDPOINT; |
} |
|
/* read a block from wishbone */ |
int dbg_wb_read_block32(uint32_t adr, uint32_t *data, uint32_t len) { |
#ifdef USB_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_USB) return usb_dbg_wb_read_block32( adr, data, len); |
else if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_wb_read_block32( adr, data, len); |
else return DBG_ERR_INVALID_ENDPOINT; |
#endif |
#ifdef VPI_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_wb_read_block32( adr, data, len); |
#endif |
return DBG_ERR_INVALID_ENDPOINT; |
} |
|
|
/* write a block to wishbone */ |
int dbg_wb_write_block32(uint32_t adr, uint32_t *data, uint32_t len) { |
#ifdef USB_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_USB) return usb_dbg_wb_write_block32( adr, data, len); |
else if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_wb_write_block32( adr, data, len); |
else return DBG_ERR_INVALID_ENDPOINT; |
#endif |
#ifdef VPI_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_wb_write_block32( adr, data, len); |
#endif |
return DBG_ERR_INVALID_ENDPOINT; |
} |
|
/* read a register from cpu */ |
int dbg_cpu0_read(uint32_t adr, uint32_t *data) { |
#ifdef USB_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_USB) return usb_dbg_cpu0_read( adr, data); |
else if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_cpu0_read( adr, data); |
else return DBG_ERR_INVALID_ENDPOINT; |
#endif |
#ifdef VPI_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_cpu0_read( adr, data); |
#endif |
return DBG_ERR_INVALID_ENDPOINT; |
} |
|
/* write a cpu register */ |
int dbg_cpu0_write(uint32_t adr, uint32_t data) { |
#ifdef USB_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_USB) return usb_dbg_cpu0_write( adr, data); |
else if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_cpu0_write( adr, data); |
else return DBG_ERR_INVALID_ENDPOINT; |
#endif |
#ifdef VPI_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_cpu0_write( adr, data); |
#endif |
return DBG_ERR_INVALID_ENDPOINT; |
} |
|
/* write a cpu module register */ |
int dbg_cpu0_write_ctrl(uint32_t adr, unsigned char data) { |
#ifdef USB_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_USB) return usb_dbg_cpu0_write_ctrl( adr, data); |
else if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_cpu0_write_ctrl( adr, data); |
else return DBG_ERR_INVALID_ENDPOINT; |
#endif |
#ifdef VPI_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_cpu0_write_ctrl( adr, data); |
#endif |
return DBG_ERR_INVALID_ENDPOINT; |
} |
|
|
/* read a register from cpu module */ |
int dbg_cpu0_read_ctrl(uint32_t adr, unsigned char *data) { |
#ifdef USB_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_USB) return usb_dbg_cpu0_read_ctrl( adr, data); |
else if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_cpu0_read_ctrl( adr, data); |
else return DBG_ERR_INVALID_ENDPOINT; |
#endif |
#ifdef VPI_ENDPOINT_ENABLED |
if (endpoint_target == ENDPOINT_TARGET_VPI) return vpi_dbg_cpu0_read_ctrl( adr, data); |
#endif |
return DBG_ERR_INVALID_ENDPOINT; |
} |
|
|
333,10 → 410,14
void catch_sigint(int sig_num) |
{ |
// Close down any potentially open sockets and USB handles |
#ifdef VPI_ENDPOINT_ENABLED |
if (vpi_fd) close(vpi_fd); |
#endif |
if (server_fd) close(server_fd); |
gdb_close(); |
#ifdef USB_ENDPOINT_ENABLED |
usb_close_device_handle(); |
gdb_close(); |
#endif |
printf("\nInterrupt signal received. Closing down connections and exiting\n\n"); |
exit(0); |
} |
348,16 → 429,27
printf("OpenRISC GDB proxy server usage: or_debug_proxy -server_type port\n"); |
printf("\n"); |
printf("server_type:\n"); |
#ifdef USB_ENDPOINT_ENABLED |
printf("\t-r Start a server using RSP, connection to hadware target via\n\t USB\n"); |
printf("\t-j Start a server using legacy OR remote JTAG protocol, to\n\t hardware target via USB\n"); |
#endif |
#ifdef VPI_ENDPOINT_ENABLED |
printf("\t-v Start a server using RSP, connection to RTL sim. VPI server\n\t target via sockets\n"); |
#endif |
printf("\n"); |
printf("port:\n"); |
printf("\tAny free port within the usable range of 0 - 65535\n"); |
printf("\n"); |
printf("Example:\n"); |
#ifdef USB_ENDPOINT_ENABLED |
printf("\tStart a GDB server on port 5555, using RSP, connecting to\n\thardware target via USB\n"); |
printf("\tor_debug_proxy -r 5555\n"); |
printf("\n"); |
#endif |
#ifdef VPI_ENDPOINT_ENABLED |
printf("\tStart a GDB server on port 5555, using RSP, connecting to\n\trtl target via VPI\n"); |
printf("\tor_debug_proxy -v 5555\n"); |
printf("\n"); |
#endif |
fflush (stdout); |
} |
/or_debug_proxy/Makefile
61,6 → 61,9
STATIC_LIB = libftd2xx.a.0.4.16 |
STATIC_LDFLAGS = $(COMMON_LDFLAGS) $(STATIC_LIBDIR)/$(STATIC_LIB) \ |
-lpthread -ldl |
# Defines to enable certain endpoint handling functions to be used |
USB_FLAGS = -D USB_ENDPOINT_ENABLED=1 |
VPI_FLAGS = -D VPI_ENDPOINT_ENABLED=1 |
|
#Determine whether we're on Cygwin |
ifndef OSTYPE |
87,12 → 90,12
EXE = .exe |
else |
OR_DEBUG_PROXY_SRC = src/or_debug_proxy.c \ |
src/gdb.c \ |
src/FT2232c.cpp \ |
src/gdb.c |
OR_DEBUG_PROXY_USB_SRC = src/FT2232c.cpp \ |
src/FT2232cMpsseJtag.cpp \ |
src/usb_functions.c \ |
src/linux_usb_driver_calls.c \ |
src/vpi_functions.c |
src/linux_usb_driver_calls.c |
OR_DEBUG_PROXY_VPI_SRC = src/vpi_functions.c |
CXX = g++ |
CPPFLAGS = $(COMMON_CPPFLAGS) $(DBGCPPFLAGS) |
CXXFLAGS = $(COMMON_CXXFLAGS) |
103,8 → 106,8
APP = or_debug_proxy |
APP_DYNAMIC = $(APP)$(EXE) |
APP_STATIC = $(APP)_static$(EXE) |
APP_VPI = $(APP)_vpi$(EXE) |
|
|
# ----------------------------------------------------------------------------- |
# Build dynamic and static targets from scratch |
.PHONY: all |
112,15 → 115,21
|
static: clean $(APP_STATIC) |
|
vpi: clean $(APP_VPI) |
|
# Dynamic target |
$(APP_DYNAMIC): $(OR_DEBUG_PROXY_SRC) |
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $+ $(DYNAMIC_LDFLAGS) -o $@ |
$(APP_DYNAMIC): $(OR_DEBUG_PROXY_SRC) $(OR_DEBUG_PROXY_USB_SRC) $(OR_DEBUG_PROXY_VPI_SRC) |
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(USB_FLAGS) $(VPI_FLAGS) $+ $(DYNAMIC_LDFLAGS) -o $@ |
|
# Static target |
$(APP_STATIC): $(OR_DEBUG_PROXY_SRC) $(STATIC_LIBDIR)/$(STATIC_LIB) |
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $+ $(STATIC_LDFLAGS) -o $@ |
$(APP_STATIC): $(OR_DEBUG_PROXY_SRC) $(OR_DEBUG_PROXY_USB_SRC) $(STATIC_LIBDIR)/$(STATIC_LIB) |
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(USB_FLAGS) $(VPI_FLAGS) $+ $(STATIC_LDFLAGS) -o $@ |
cp $(APP_STATIC) $(APP) |
|
# VPI target only |
$(APP_VPI): $(OR_DEBUG_PROXY_SRC) $(OR_DEBUG_PROXY_VPI_SRC) |
$(CXX) $(CPPFLAGS) $(VPI_FLAGS) $(CXXFLAGS) $+ -o $@ |
|
# ----------------------------------------------------------------------------- |
# Target for checking the static lib is in the place it should be |
$(STATIC_LIBDIR)/$(STATIC_LIB): |
138,4 → 147,5
clean: |
$(RM) $(APP_DYNAMIC) |
$(RM) $(APP_STATIC) |
$(RM) $(APP_VPI) |
find ./ -name "*~" | xargs $(RM) |