OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 438 to Rev 439
    Reverse comparison

Rev 438 → Rev 439

/trunk/or1ksim/sim-config.h
160,6 → 160,7
int enabled; /* Whether is debug module enabled */
int gdb_enabled; /* Whether is debugging with gdb possible */
int server_port; /* A user specified port number for services */
unsigned long vapi_id; /* "Fake" vapi device id for JTAG proxy */
} debug;
 
struct { /* Verification API, part of Advanced Core Verification */
/trunk/or1ksim/debug/gdbcomm.c
34,6 → 34,7
 
#include "gdb.h"
#include "gdbcomm.h"
#include "vapi.h"
#include "sim-config.h"
 
static unsigned int serverIP = 0;
568,85 → 569,84
}
}
 
static int gdb_write(void* buf,int len)
static int gdb_write(const void* buf,int len)
{
int n;
char* w_buf = (char*)buf;
int n, log_n = 0;
const char* w_buf = (const char*)buf;
const uint32_t* log_buf = (const uint32_t*)buf;
struct pollfd block;
 
while(len)
{
if((n = write(gdb_fd,w_buf,len)) < 0)
{
switch(errno)
{
case EWOULDBLOCK: /* or EAGAIN */
/* We've been called on a descriptor marked
for nonblocking I/O. We better simulate
blocking behavior. */
block.fd = gdb_fd;
block.events = POLLOUT;
block.revents = 0;
poll(&block,1,-1);
continue;
case EINTR:
continue;
case EPIPE:
close(gdb_fd);
gdb_fd = 0;
return -1;
default:
return -1;
}
}
else
{
len -= n;
w_buf += n;
}
while(len) {
if((n = write(gdb_fd,w_buf,len)) < 0) {
switch(errno) {
case EWOULDBLOCK: /* or EAGAIN */
/* We've been called on a descriptor marked
for nonblocking I/O. We better simulate
blocking behavior. */
block.fd = gdb_fd;
block.events = POLLOUT;
block.revents = 0;
poll(&block,1,-1);
continue;
case EINTR:
continue;
case EPIPE:
close(gdb_fd);
gdb_fd = 0;
return -1;
default:
return -1;
}
}
else {
len -= n;
w_buf += n;
if ( config.debug.vapi_id )
for ( log_n += n; log_n >= 4; log_n -= 4, ++ log_buf )
vapi_write_log_file( VAPI_COMMAND_SEND, config.debug.vapi_id, ntohl(*log_buf) );
}
}
return 0;
}
 
static int gdb_read(void* buf,int len)
{
int n;
int n, log_n = 0;
char* r_buf = (char*)buf;
uint32_t* log_buf = (uint32_t*)buf;
struct pollfd block;
 
while(len)
{
if((n = read(gdb_fd,r_buf,len)) < 0)
{
switch(errno)
{
case EWOULDBLOCK: /* or EAGAIN */
/* We've been called on a descriptor marked
for nonblocking I/O. We better simulate
blocking behavior. */
block.fd = gdb_fd;
block.events = POLLIN;
block.revents = 0;
poll(&block,1,-1);
continue;
case EINTR:
continue;
default:
return -1;
}
}
else if(n == 0)
{
close(gdb_fd);
gdb_fd = 0;
return -1;
}
else
{
len -= n;
r_buf += n;
}
while(len) {
if((n = read(gdb_fd,r_buf,len)) < 0) {
switch(errno) {
case EWOULDBLOCK: /* or EAGAIN */
/* We've been called on a descriptor marked
for nonblocking I/O. We better simulate
blocking behavior. */
block.fd = gdb_fd;
block.events = POLLIN;
block.revents = 0;
poll(&block,1,-1);
continue;
case EINTR:
continue;
default:
return -1;
}
}
else if(n == 0) {
close(gdb_fd);
gdb_fd = 0;
return -1;
}
else {
len -= n;
r_buf += n;
if ( config.debug.vapi_id )
for ( log_n += n; log_n >= 4; log_n -= 4, ++ log_buf )
vapi_write_log_file( VAPI_COMMAND_REQUEST, config.debug.vapi_id, ntohl(*log_buf) );
}
}
return 0;
}
 
/trunk/or1ksim/debug/gdbcomm.h
32,7 → 32,7
void GDBRequest(void);
void ProtocolClean(int,int32_t);
static int gdb_read(void*,int);
static int gdb_write(void*,int);
static int gdb_write(const void*,int);
void BlockJTAG(void);
int GetServerSocket(const char* name,const char* proto,int port);
 
/trunk/or1ksim/peripheral/ethernet.c
48,7 → 48,7
static void eth_start_rx( struct eth_device * );
static void eth_finish_rx( struct eth_device * );
 
static void eth_write_rx_bd_adr( struct eth_device *, unsigned long value );
static void eth_write_tx_bd_num( struct eth_device *, unsigned long value );
static unsigned long eth_rx( struct eth_device * );
static void eth_tx( struct eth_device *, unsigned long );
static void eth_rx_next_packet( struct eth_device * );
/trunk/or1ksim/vapi/vapi.c
41,6 → 41,7
#include <inttypes.h>
 
#include "sim-config.h"
#include "vapi.h"
 
static unsigned int serverIP = 0;
 
118,13 → 119,13
}
 
/* Added by Erez 09/12/01 */
static void write_vapi_file(unsigned msgtype, unsigned long devid, unsigned long data)
void vapi_write_log_file(VAPI_COMMAND command, unsigned long devid, unsigned long data)
{
if (!runtime.vapi.vapi_file)
return;
if (config.vapi.log_device_id)
fprintf (runtime.vapi.vapi_file, "%08x", devid);
fprintf (runtime.vapi.vapi_file, "%1x%08x\n", msgtype, data);
if (!runtime.vapi.vapi_file)
return;
if (config.vapi.log_device_id)
fprintf (runtime.vapi.vapi_file, "%08x", devid);
fprintf (runtime.vapi.vapi_file, "%1x%08x\n", command, data);
}
 
static int vapi_write_stream(int fd, void* buf, int len)
412,7 → 413,7
return;
}
 
write_vapi_file (0, t->id, data);
vapi_write_log_file (0, t->id, data);
debug (4, "[%08x, %08x]\n", t->id, data);
if (!t->read_func)
fprintf (stderr, "WARNING: packet sent to undefined id %x, %x\n", t->id, data);
512,7 → 513,7
fds = 0;
if (runtime.vapi.vapi_file) {
/* Mark end of simulation */
write_vapi_file (2, t->id, 0);
vapi_write_log_file (2, t->id, 0);
fclose (runtime.vapi.vapi_file);
}
 
528,7 → 529,7
{
struct vapi_handler *tt;
debug(4, "vapi_install_handler %08x, %08x", id, read_func);
debug(4, "vapi_install_handler %08x, %08x\n", id, read_func);
if (read_func == NULL) {
struct vapi_handler **t = &vapi_handler;
while ((*t) && (*t)->id != id)
571,7 → 572,7
int vapi_send (unsigned long id, unsigned long data)
{
debug (4, "vapi_send [%08x %08x]\n", id, data);
write_vapi_file (1, id, data);
vapi_write_log_file (1, id, data);
write_packet (id, data);
}
 
/trunk/or1ksim/vapi/vapi.h
36,3 → 36,13
int vapi_send (unsigned long id, unsigned long data);
 
#define VAPI_DEVICE_ID (0xff)
 
/* Types of commands that can be written to the VAPI log file */
typedef enum {
VAPI_COMMAND_REQUEST = 0, /* Data coming from outside world to device */
VAPI_COMMAND_SEND = 1, /* Device writing data to the outside world */
VAPI_COMMAND_END = 2 /* End of log for device */
} VAPI_COMMAND;
 
/* Writes a line directly to the log file (used by JTAG proxy) */
void vapi_write_log_file(VAPI_COMMAND command, unsigned long device_id, unsigned long data);
/trunk/or1ksim/sim-config.c
419,6 → 419,7
{7, 0, "enabled", "=%i", NULL, (void *)(&config.debug.enabled)},
{7, 0, "gdb_enabled", "=%i", NULL, (void *)(&config.debug.gdb_enabled)},
{7, 0, "server_port", "=%i", NULL, (void *)(&config.debug.server_port)},
{7, 0, "vapi_id", "=0x%x", NULL, (void *)(&config.debug.vapi_id)},
 
{8, 0, "enabled", "=%i", NULL, (void *)(&config.vapi.enabled)},
{8, 0, "server_port", "=%i", NULL, (void *)(&config.vapi.server_port)},

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.