Line 27... |
Line 27... |
#include <string.h>
|
#include <string.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
#include <unistd.h>
|
#include <unistd.h>
|
#include <signal.h>
|
#include <signal.h>
|
#include <stdarg.h>
|
#include <stdarg.h>
|
|
/* Added by CZ 24/05/01 */
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
#include <sys/socket.h>
|
|
#include <netinet/in.h>
|
|
#include <sys/select.h>
|
|
#include <sys/poll.h>
|
|
#include <fcntl.h>
|
|
#include <netdb.h>
|
|
#include <netinet/tcp.h>
|
|
|
#ifdef HAVE_LIBREADLINE
|
#ifdef HAVE_LIBREADLINE
|
#include <readline/readline.h>
|
#include <readline/readline.h>
|
#include <readline/history.h>
|
#include <readline/history.h>
|
#endif /* HAVE_LIBREADLINE */
|
#endif /* HAVE_LIBREADLINE */
|
Line 43... |
Line 53... |
#include "sim-config.h"
|
#include "sim-config.h"
|
#include "spr_defs.h"
|
#include "spr_defs.h"
|
|
|
#include "coff.h"
|
#include "coff.h"
|
|
|
|
/* Added by CZ 24/05/01 */
|
|
#include <signal.h>
|
|
#include <errno.h>
|
|
typedef enum {
|
|
false = 0,
|
|
true = 1,
|
|
} Boolean;
|
|
unsigned int serverIP = 0;
|
|
unsigned int serverPort = 0;
|
|
unsigned int server_fd = 0;
|
|
unsigned int gdb_fd = 0;
|
|
void HandleServerSocket(Boolean);
|
|
void JTAGRequest(void);
|
|
void GDBRequest(void);
|
|
int GlobalMode = 0; /* Start off in the orginal mode */
|
|
|
/* CVS revision number. */
|
/* CVS revision number. */
|
const char rcsrev[] = "$Revision: 1.15 $";
|
const char rcsrev[] = "$Revision: 1.16 $";
|
|
|
/* Continuos run versus single step tracing switch. */
|
/* Continuos run versus single step tracing switch. */
|
int cont_run;
|
int cont_run;
|
|
|
/* History of execution */
|
/* History of execution */
|
Line 132... |
Line 158... |
void
|
void
|
ctrl_c(signum)
|
ctrl_c(signum)
|
int signum;
|
int signum;
|
{
|
{
|
cont_run = 1;
|
cont_run = 1;
|
|
config.iprompt = 1;
|
signal(SIGINT, ctrl_c);
|
signal(SIGINT, ctrl_c);
|
}
|
}
|
|
|
void
|
void
|
version()
|
version()
|
Line 186... |
Line 213... |
{
|
{
|
char *linestr;
|
char *linestr;
|
char item1[500], b2[500];
|
char item1[500], b2[500];
|
char *redirstr;
|
char *redirstr;
|
int hush;
|
int hush;
|
unsigned long endaddr;
|
unsigned long endaddr = 0xFFFFFFFF;
|
|
int first_prompt = 1;
|
|
|
srand(getpid());
|
srand(getpid());
|
init_defconfig();
|
init_defconfig();
|
if ((argc < 2) || parse_args(argc, argv)) {
|
if (parse_args(argc, argv)) {
|
printf("Usage: %s [options] <filename>\n", argv[0]);
|
printf("Usage: %s [options] <filename>\n", argv[0]);
|
printf("Options:\n");
|
printf("Options:\n");
|
printf(" -v: version and copyright note\n");
|
printf(" -v: version and copyright note\n");
|
printf(" -i: enable interactive command prompt\n");
|
printf(" -i: enable interactive command prompt\n");
|
printf(" -bpb: disable branch prediction buffer analysis\n");
|
printf(" -bpb: disable branch prediction buffer analysis\n");
|
printf(" -btic: disable branch prediction target insn cache analysis\n");
|
printf(" -btic: disable branch prediction target insn cache analysis\n");
|
printf(" -hazards: disable dependency hazards analysis\n");
|
printf(" -hazards: disable dependency hazards analysis\n");
|
printf(" -history: disable instruction stream history analysis\n");
|
printf(" -history: disable instruction stream history analysis\n");
|
printf(" -superscalar: disable superscalar analysis\n");
|
printf(" -superscalar: disable superscalar analysis\n");
|
printf(" -fast: disable BPB, BTIC, SLP, dependency hazards, history analysis etc.\n");
|
printf(" -fast: disable BPB, BTIC, SLP, dependency hazards, history"
|
|
" analysis etc.\n");
|
printf(" -upr <n>: set UPR to n\n");
|
printf(" -upr <n>: set UPR to n\n");
|
printf(" -ver <n>: set VR[VER] to n\n");
|
printf(" -ver <n>: set VR[VER] to n\n");
|
printf(" -rev <n>: set VR[REV] to n\n");
|
printf(" -rev <n>: set VR[REV] to n\n");
|
|
printf(" -loadmem[@<n>] <filename>: load memory with file, "
|
|
"optionally at address <n>\n"); /* (CZ) */
|
|
printf(" -nosrv: do not launch JTAG proxy server\n"); /* (CZ) */
|
|
printf(" -srv <n>: launch JTAG proxy server on port <n>\n"); /* (CZ) */
|
|
printf(" -initmem <n | random>: initialize memory to value "
|
|
"<n> or random\n"); /* (CZ) */
|
exit(-1);
|
exit(-1);
|
}
|
}
|
|
|
#ifdef HAVE_LIBREADLINE
|
#ifdef HAVE_LIBREADLINE
|
initialize_readline (); /* Bind our completer. */
|
initialize_readline (); /* Bind our completer. */
|
#endif
|
#endif
|
|
|
|
if(!config.inhibit_server)
|
|
{
|
|
serverPort = config.server_port;
|
|
if(server_fd = GetServerSocket("or1ksim","tcp",serverPort))
|
|
printf("JTAG Proxy server started on port %d\n",serverPort);
|
|
}
|
|
|
print_config();
|
print_config();
|
signal(SIGINT, ctrl_c);
|
signal(SIGINT, ctrl_c);
|
initstats();
|
initstats();
|
memset(mem, 0, sizeof(mem));
|
|
endaddr = loadcode(argv[argc-1], MEMORY_START, 0);
|
/* Modified by CZ on 24/05/01 ... if a filename is
|
|
specified, behave as the simulator always has. This way,
|
|
no existing test suites should be broken. If a filename
|
|
is not specified, default to the new style behavior. Let
|
|
the simulator start up and execute garbage, the same way
|
|
a real CPU would. This should maximize the reality of
|
|
the capabilities. In this mode, we will expect that
|
|
someone will attach to us over the JTAG Proxy interface
|
|
and begin debugging that way. */
|
|
|
|
if(config.filename)
|
|
{
|
|
endaddr = loadcode(config.filename, MEMORY_START, 0);
|
if (endaddr == -1) {
|
if (endaddr == -1) {
|
printf("Problems loading boot code.\n");
|
printf("Problems loading boot code.\n");
|
exit(1);
|
exit(1);
|
}
|
}
|
|
}
|
|
else
|
|
{
|
|
if(config.random_mem)
|
|
{
|
|
int n = 0;
|
|
int len = sizeof(mem);
|
|
unsigned int* mptr = (unsigned int*)mem;
|
|
unsigned int val = 0;
|
|
int seed = time(NULL);
|
|
|
|
srandom(seed);
|
|
/* Print out the seed just in case we ever need to debug */
|
|
printf("Seeding random generator with value %d\n",seed);
|
|
|
|
for(n=0;n<len;n+=sizeof(unsigned int))
|
|
{
|
|
val = random();
|
|
if(random() > RAND_MAX/2)
|
|
val |= 0x80000000;
|
|
*mptr++ = val;
|
|
}
|
|
}
|
|
else if(config.pattern_mem)
|
|
{
|
|
int n = 0;
|
|
int len = sizeof(mem);
|
|
unsigned int* mptr = (unsigned int*)mem;
|
|
|
|
for(n=0;n<len;n+=sizeof(unsigned int))
|
|
*mptr++ = config.pattern_mem;
|
|
}
|
|
else
|
|
memset(mem,0,sizeof(mem));
|
|
|
|
if(config.memory)
|
|
{
|
|
MemoryBlock* block = config.memory;
|
|
|
|
while(block)
|
|
{
|
|
int fd = open(block->file,O_RDONLY);
|
|
int len,i;
|
|
struct stat buf;
|
|
char *mptr = (char*)mem;
|
|
char buffer[8192];
|
|
|
|
if(fd < 0)
|
|
{
|
|
perror(block->file);
|
|
exit(1);
|
|
}
|
|
if(fstat(fd,&buf) < 0)
|
|
{
|
|
char sTemp[256];
|
|
|
|
sprintf(sTemp,"stat(\"%s\")",block->file);
|
|
perror(sTemp);
|
|
exit(1);
|
|
}
|
|
if(!S_ISREG(buf.st_mode))
|
|
{
|
|
fprintf(stderr,"File \"%s\" is not a regular file.\n",
|
|
block->file);
|
|
exit(1);
|
|
}
|
|
|
|
len = buf.st_size;
|
|
mptr += block->address;
|
|
for(i=0;i<len;)
|
|
{
|
|
int n = read(fd,buffer,sizeof(buffer));
|
|
|
|
switch(n)
|
|
{
|
|
case -1:
|
|
if(errno == EINTR)
|
|
continue;
|
|
perror(block->file);
|
|
exit(1);
|
|
case 0:
|
|
fprintf(stderr,"File \"%s\": premature end of file.\n",
|
|
block->file);
|
|
exit(1);
|
|
default:
|
|
memcpy(mptr,buffer,n);
|
|
i+= n;
|
|
break;
|
|
}
|
|
}
|
|
close(fd);
|
|
}
|
|
}
|
|
}
|
|
GlobalMode = config.filename == NULL; /* Old mode = 0, New mode = 1 */
|
|
|
uart_reset();
|
uart_reset();
|
tick_reset();
|
tick_reset();
|
pm_reset();
|
pm_reset();
|
pic_reset();
|
pic_reset();
|
reset();
|
reset();
|
|
if(!GlobalMode) /* Only in old mode */
|
set_reg32("r3", endaddr);
|
set_reg32("r3", endaddr);
|
|
|
while(1) {
|
while(1) {
|
if (config.iprompt) {
|
if (config.iprompt) {
|
|
if(server_fd)
|
|
{
|
|
printf ("(sim) ");
|
|
fflush(stdout);
|
|
HandleServerSocket(true); /* block & check_stdin = true */
|
|
}
|
#ifdef HAVE_LIBREADLINE
|
#ifdef HAVE_LIBREADLINE
|
|
/* Must disable readline in new mode. It isn't compatible
|
|
with non blocking environments */
|
|
if(!server_fd)
|
linestr = readline("(sim) ");
|
linestr = readline("(sim) ");
|
|
else
|
|
linestr = fgets(b2, sizeof b2, stdin);
|
#else
|
#else
|
|
if(!server_fd)
|
printf ("(sim) ");
|
printf ("(sim) ");
|
linestr = fgets(b2, sizeof b2, stdin);
|
linestr = fgets(b2, sizeof b2, stdin);
|
#endif
|
#endif
|
} else
|
} else
|
strcpy(linestr = b2, "run 100000000 hush");
|
strcpy(linestr = b2, "run 100000000 hush");
|
Line 243... |
Line 406... |
if (!linestr)
|
if (!linestr)
|
break;
|
break;
|
linestr = stripwhite (linestr);
|
linestr = stripwhite (linestr);
|
|
|
#ifdef HAVE_LIBREADLINE
|
#ifdef HAVE_LIBREADLINE
|
|
/* Readline only works in the old mode */
|
|
if(!server_fd)
|
|
{
|
if (strlen(linestr) == 0) {
|
if (strlen(linestr) == 0) {
|
char *l = repeat_last_command ();
|
char *l = repeat_last_command ();
|
|
|
if (l) {
|
if (l) {
|
free (linestr);
|
free (linestr);
|
Line 255... |
Line 421... |
}
|
}
|
|
|
if (*linestr) {
|
if (*linestr) {
|
add_history (linestr);
|
add_history (linestr);
|
}
|
}
|
|
}
|
#endif /* HAVE_LIBREADLINE */
|
#endif /* HAVE_LIBREADLINE */
|
|
|
if (redirstr = strstr(linestr, ">")) {
|
if (redirstr = strstr(linestr, ">")) {
|
*redirstr = '\0';
|
*redirstr = '\0';
|
strtoken(&redirstr[1], item1, 1);
|
strtoken(&redirstr[1], item1, 1);
|
Line 341... |
Line 508... |
} else
|
} else
|
if (strcmp(item1, "pm") == 0) { /* patch memory */
|
if (strcmp(item1, "pm") == 0) { /* patch memory */
|
char item2[20];
|
char item2[20];
|
char item3[20];
|
char item3[20];
|
static int addr = 0;
|
static int addr = 0;
|
|
int breakpoint = 0;
|
|
|
strtoken(linestr, item2, 2);
|
strtoken(linestr, item2, 2);
|
strtoken(linestr, item3, 3);
|
strtoken(linestr, item3, 3);
|
if (strlen(item2))
|
if (strlen(item2))
|
if (item2[0] == '_')
|
if (item2[0] == '_')
|
addr = eval_label(item2);
|
addr = eval_label(item2);
|
else
|
else
|
addr = strtoul(item2, NULL, 0);
|
addr = strtoul(item2, NULL, 0);
|
set_mem32(addr, strtoul(item3, NULL, 0));
|
set_mem32(addr, strtoul(item3, NULL, 0), &breakpoint);
|
} else
|
} else
|
if (strcmp(item1, "pr") == 0) { /* patch regs */
|
if (strcmp(item1, "pr") == 0) { /* patch regs */
|
char item2[20];
|
char item2[20];
|
char item3[20];
|
char item3[20];
|
|
|
Line 382... |
Line 550... |
if (strcmp(item1, "reset") == 0) { /* reset simulator */
|
if (strcmp(item1, "reset") == 0) { /* reset simulator */
|
uart_reset();
|
uart_reset();
|
tick_reset();
|
tick_reset();
|
pm_reset();
|
pm_reset();
|
pic_reset();
|
pic_reset();
|
reset();
|
reset(); /* Old or new mode */
|
} else
|
} else
|
if (strcmp(item1, "debug") == 0) { /* debug mode */
|
if (strcmp(item1, "debug") == 0) { /* debug mode */
|
config.simdebug ^= 1;
|
config.simdebug ^= 1;
|
} else
|
} else
|
if (strcmp(item1, "hist") == 0) { /* dump history */
|
if (strcmp(item1, "hist") == 0) { /* dump history */
|
Line 432... |
Line 600... |
} else {
|
} else {
|
printf("%s: Unknown command.\n", linestr);
|
printf("%s: Unknown command.\n", linestr);
|
}
|
}
|
|
|
while(cont_run) {
|
while(cont_run) {
|
cont_run--;
|
extern int cycle_delay; /* Added by CZ 27/05/01. Set during exception. */
|
|
|
if (!getsprbits(SPR_PMR, SPR_PMR_DME | SPR_PMR_SME)) {
|
if (!getsprbits(SPR_PMR, SPR_PMR_DME | SPR_PMR_SME)) {
|
fetch();
|
if(cycle_delay <= 0)
|
|
{
|
|
cont_run--;
|
|
if(fetch()) {
|
|
cont_run = 0; /* memory breakpoint encountered */
|
|
break;
|
|
}
|
decode_execute(&iqueue[0]);
|
decode_execute(&iqueue[0]);
|
|
update_pc();
|
analysis();
|
analysis();
|
if (!hush)
|
if (!hush)
|
dumpreg();
|
dumpreg();
|
|
}
|
|
else
|
|
cycle_delay--;
|
|
|
pic_clock();
|
pic_clock();
|
dc_clock();
|
dc_clock();
|
ic_clock();
|
ic_clock();
|
}
|
}
|
if (!getsprbits(SPR_PMR, SPR_PMR_SME))
|
if (!getsprbits(SPR_PMR, SPR_PMR_SME))
|
tick_clock();
|
tick_clock();
|
pm_clock();
|
pm_clock();
|
uart_clock();
|
uart_clock();
|
|
HandleServerSocket(false); /* block & check_stdin = false */
|
}
|
}
|
|
|
hush = 0;
|
hush = 0;
|
fflush(stdout);
|
fflush(stdout);
|
freopen("/dev/fd/0", "w+", stdout);
|
freopen("/dev/fd/0", "w+", stdout);
|
|
|
if (!config.iprompt) /* non-interactive quit */
|
if (!config.iprompt && !GlobalMode) /* non-interactive quit in old mode */
|
exit(0);
|
exit(0);
|
|
|
#ifdef HAVE_LIBREADLINE
|
#ifdef HAVE_LIBREADLINE
|
if (linestr)
|
if (linestr)
|
free (linestr);
|
free (linestr);
|
Line 572... |
Line 752... |
printf("starting to dump mem...\n");
|
printf("starting to dump mem...\n");
|
for(i=0; i<500; i++) {
|
for(i=0; i<500; i++) {
|
printf("i=%x :: ", i);
|
printf("i=%x :: ", i);
|
if (mem[i].label)
|
if (mem[i].label)
|
printf("label: %s |", mem[i].label->name);
|
printf("label: %s |", mem[i].label->name);
|
printf("%s ", mem[i].insn->insn);
|
printf("%s ", insn_name (mem[i].insn->insn_index));
|
if(strlen(mem[i].insn->op1) != 0) printf("%s ", mem[i].insn->op1);
|
if(strlen(mem[i].insn->op1) != 0) printf("%s ", mem[i].insn->op1);
|
if(strlen(mem[i].insn->op2) != 0) printf("%s ", mem[i].insn->op2);
|
if(strlen(mem[i].insn->op2) != 0) printf("%s ", mem[i].insn->op2);
|
if(strlen(mem[i].insn->op3) != 0) printf("%s ", mem[i].insn->op3);
|
if(strlen(mem[i].insn->op3) != 0) printf("%s ", mem[i].insn->op3);
|
if(strlen(mem[i].insn->op4) != 0) printf("%s ", mem[i].insn->op4);
|
if(strlen(mem[i].insn->op4) != 0) printf("%s ", mem[i].insn->op4);
|
printf("\n");
|
printf("\n");
|
}
|
}
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|
|
/* Added by CZ 24/05/01 */
|
|
int GetServerSocket(const char* name,const char* proto,int port)
|
|
{
|
|
struct servent *service;
|
|
struct protoent *protocol;
|
|
struct sockaddr_in sa;
|
|
struct hostent *hp;
|
|
int sockfd;
|
|
char myname[256];
|
|
int flags;
|
|
char sTemp[256];
|
|
|
|
/* First, get the protocol number of TCP */
|
|
if(!(protocol = getprotobyname(proto)))
|
|
{
|
|
sprintf(sTemp,"Unable to load protocol \"%s\"",proto);
|
|
perror(sTemp);
|
|
return 0;
|
|
}
|
|
|
|
/* If we weren't passed a non standard port, get the port
|
|
from the services directory. */
|
|
if(!port)
|
|
{
|
|
if(service = getservbyname(name,protocol->p_name))
|
|
port = ntohs(service->s_port);
|
|
}
|
|
|
|
/* Create the socket using the TCP protocol */
|
|
if((sockfd = socket(PF_INET,SOCK_STREAM,protocol->p_proto)) < 0)
|
|
{
|
|
perror("Unable to create socket");
|
|
return 0;
|
|
}
|
|
|
|
flags = 1;
|
|
if(setsockopt(sockfd,SOL_SOCKET,SO_REUSEADDR,(const char*)&flags,sizeof(int))
|
|
< 0)
|
|
{
|
|
sprintf(sTemp,"Can not set SO_REUSEADDR option on socket %d",sockfd);
|
|
perror(sTemp);
|
|
close(sockfd);
|
|
return 0;
|
|
}
|
|
|
|
/* The server should also be non blocking. Get the current flags. */
|
|
if(fcntl(sockfd,F_GETFL,&flags) < 0)
|
|
{
|
|
sprintf(sTemp,"Unable to get flags for socket %d",sockfd);
|
|
perror(sTemp);
|
|
close(sockfd);
|
|
return 0;
|
|
}
|
|
|
|
/* Set the nonblocking flag */
|
|
if(fcntl(sockfd,F_SETFL, flags | O_NONBLOCK) < 0)
|
|
{
|
|
sprintf(sTemp,"Unable to set flags for socket %d to value 0x%08x",
|
|
sockfd,flags | O_NONBLOCK);
|
|
perror(sTemp);
|
|
close(sockfd);
|
|
return 0;
|
|
}
|
|
|
|
/* Find out what our address is */
|
|
memset(&sa,0,sizeof(struct sockaddr_in));
|
|
gethostname(myname,sizeof(myname));
|
|
if(!(hp = gethostbyname(myname)))
|
|
{
|
|
perror("Unable to read hostname");
|
|
close(sockfd);
|
|
return 0;
|
|
}
|
|
|
|
/* Bind our socket to the appropriate address */
|
|
sa.sin_family = hp->h_addrtype;
|
|
sa.sin_port = htons(port);
|
|
if(bind(sockfd,(struct sockaddr*)&sa,sizeof(struct sockaddr_in)) < 0)
|
|
{
|
|
sprintf(sTemp,"Unable to bind socket %d to port %d",sockfd,port);
|
|
perror(sTemp);
|
|
close(sockfd);
|
|
return 0;
|
|
}
|
|
serverIP = sa.sin_addr.s_addr;
|
|
flags = sizeof(struct sockaddr_in);
|
|
if(getsockname(sockfd,(struct sockaddr*)&sa,&flags) < 0)
|
|
{
|
|
sprintf(sTemp,"Unable to get socket information for socket %d",sockfd);
|
|
perror(sTemp);
|
|
close(sockfd);
|
|
return 0;
|
|
}
|
|
serverPort = ntohs(sa.sin_port);
|
|
|
|
/* Set the backlog to 1 connections */
|
|
if(listen(sockfd,1) < 0)
|
|
{
|
|
sprintf(sTemp,"Unable to set backlog on socket %d to %d",sockfd,1);
|
|
perror(sTemp);
|
|
close(sockfd);
|
|
return 0;
|
|
}
|
|
|
|
return sockfd;
|
|
}
|
|
|
|
void HandleServerSocket(Boolean block)
|
|
{
|
|
struct pollfd fds[2];
|
|
int n = 0;
|
|
int timeout = block ? -1 : 0;
|
|
int server_index = -1;
|
|
int gdb_index = -1;
|
|
Boolean data_on_stdin = false;
|
|
int o_serv_fd = server_fd;
|
|
|
|
if(!o_serv_fd && !gdb_fd)
|
|
return;
|
|
|
|
if(o_serv_fd)
|
|
{
|
|
fds[n].fd = o_serv_fd;
|
|
fds[n].events = POLLIN;
|
|
fds[n++].revents = 0;
|
|
}
|
|
if(gdb_fd)
|
|
{
|
|
fds[n].fd = gdb_fd;
|
|
fds[n].events = POLLIN;
|
|
fds[n++].revents = 0;
|
|
}
|
|
if(block)
|
|
{
|
|
fds[n].fd = 0;
|
|
fds[n].events = POLLIN;
|
|
fds[n++].revents = 0;
|
|
}
|
|
|
|
while(!data_on_stdin)
|
|
{
|
|
switch(poll(fds,n,timeout))
|
|
{
|
|
case -1:
|
|
if(errno == EINTR)
|
|
continue;
|
|
perror("poll");
|
|
server_fd = 0;
|
|
break;
|
|
case 0: /* Nothing interesting going on */
|
|
data_on_stdin = true; /* Can only get here if nonblocking */
|
|
break;
|
|
default:
|
|
if(fds[0].revents && o_serv_fd)
|
|
{
|
|
if(fds[0].revents & POLLIN)
|
|
JTAGRequest();
|
|
else /* Error Occurred */
|
|
{
|
|
fprintf(stderr,"Received flags 0x%08x on server. Shutting down.\n",fds[0].revents);
|
|
close(o_serv_fd);
|
|
server_fd = 0;
|
|
serverPort = 0;
|
|
serverIP = 0;
|
|
}
|
|
}
|
|
if((fds[0].revents && (gdb_fd && !o_serv_fd) ||
|
|
fds[1].revents && (server_fd && gdb_fd)))
|
|
{
|
|
int revents = o_serv_fd ? fds[1].revents : fds[0].revents;
|
|
|
|
if(revents & POLLIN)
|
|
GDBRequest();
|
|
else /* Error Occurred */
|
|
{
|
|
fprintf(stderr,"Received flags 0x%08x on gdb socket. Shutting down.\n",revents);
|
|
close(gdb_fd);
|
|
gdb_fd = 0;
|
|
}
|
|
}
|
|
if(fds[2].revents || (fds[1].revents && !gdb_fd))
|
|
data_on_stdin = true;
|
|
break;
|
|
} /* End of switch statement */
|
|
} /* End of while statement */
|
|
}
|
|
|
|
void JTAGRequest()
|
|
{
|
|
struct sockaddr_in sa;
|
|
struct sockaddr* addr = (struct sockaddr*)&sa;
|
|
int n = sizeof(struct sockaddr_in);
|
|
int fd = accept(server_fd,addr,&n);
|
|
int on_off = 0; /* Turn off Nagel's algorithm on the socket */
|
|
int flags;
|
|
char sTemp[256];
|
|
|
|
if(fd < 0)
|
|
{
|
|
/* This is valid, because a connection could have started,
|
|
and then terminated due to a protocol error or user
|
|
initiation before the accept could take place. */
|
|
if(errno != EWOULDBLOCK && errno != EAGAIN)
|
|
{
|
|
perror("accept");
|
|
close(server_fd);
|
|
server_fd = 0;
|
|
serverPort = 0;
|
|
serverIP = 0;
|
|
}
|
|
return;
|
|
}
|
|
|
|
if(gdb_fd)
|
|
{
|
|
close(fd);
|
|
return;
|
|
}
|
|
|
|
if(fcntl(fd,F_GETFL,&flags) < 0)
|
|
{
|
|
sprintf(sTemp,"Unable to get flags for gdb socket %d",fd);
|
|
perror(sTemp);
|
|
close(fd);
|
|
return;
|
|
}
|
|
|
|
if(fcntl(fd,F_SETFL, flags | O_NONBLOCK) < 0)
|
|
{
|
|
sprintf(sTemp,"Unable to set flags for gdb socket %d to value 0x%08x",
|
|
fd,flags | O_NONBLOCK);
|
|
perror(sTemp);
|
|
close(fd);
|
|
return;
|
|
}
|
|
|
|
if(setsockopt(fd,SOL_TCP,TCP_NODELAY,&on_off,sizeof(int)) < 0)
|
|
{
|
|
sprintf(sTemp,"Unable to disable Nagel's algorithm for socket %d.\nsetsockopt",fd);
|
|
perror(sTemp);
|
|
close(fd);
|
|
return;
|
|
}
|
|
|
|
gdb_fd = fd;
|
|
}
|
|
|
|
void GDBRequest()
|
|
{
|
|
/* Debug interface simulation should go here. */
|
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|