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 335 to Rev 336
    Reverse comparison

Rev 335 → Rev 336

/trunk/or1ksim/peripheral/16450.c
35,6 → 35,7
#include "16450.h"
#include "sim-config.h"
#include "pic.h"
#include "vapi.h"
 
static struct dev_16450 uarts[NR_UARTS];
static int thre_int;
185,6 → 186,12
return value;
}
 
/* Function that handles incoming VAPI data. */
void uart_vapi_read (unsigned long id, unsigned long data)
{
printf ("UART: id %08x, data %08x\n", id, data);
}
 
/* Reset. It initializes all registers of all UART devices to zero values,
(re)opens all RX/TX file streams and places devices in memory address
space. */
192,11 → 199,11
{
int i;
printf("Resetting %u UART(s).\n", NR_UARTS);
memset(uarts, 0, sizeof(uarts));
if (!config.uarts_enabled)
config.nuarts = 0;
printf("Resetting %u UART(s).\n", config.nuarts);
memset(uarts, 0, sizeof(uarts));
 
for(i = 0; i < config.nuarts; i++)
if (config.uarts[i].txfile) { /* MM: Try to create stream. */
213,7 → 220,10
} else
printf("UART%d has problems with TX file stream.\n", i);
register_memoryarea(uarts[i].baseaddr, UART_ADDR_SPACE, 1, uart_read_byte, uart_write_byte);
}
 
if (config.uarts[i].vapi_id)
vapi_install_handler (config.uarts[i].vapi_id, uart_vapi_read);
}
}
 
/* Simulation hook. Must be called every clock cycle to simulate all UART
343,6 → 353,9
printf("rxser: %d txser: %d\n", uarts[i].istat.rxser, uarts[i].istat.txser);
printf("rxbuf: %d txbuf: %d\n", uarts[i].istat.rxbuf, uarts[i].istat.txbuf);
 
printf("RX fs: %p TX fs: %p\n\n", uarts[i].rxfs, uarts[i].txfs);
if (config.uarts[i].vapi_id)
printf ("Connected to vapi ID=%x\n\n", config.uarts[i].vapi_id);
else
printf("RX fs: %p TX fs: %p\n\n", uarts[i].rxfs, uarts[i].txfs);
}
}
/trunk/or1ksim/vapi/vapi.c
17,7 → 17,7
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
//#include "config.h"
#include "config.h"
 
#include <stdio.h>
#include <ctype.h>
40,21 → 40,10
#include <netinet/tcp.h>
#include <inttypes.h>
 
//#include "sim-config.h"
#include "sim-config.h"
 
static unsigned int serverIP = 0;
 
struct {
struct {
int enabled;
unsigned int server_port;
} vapi;
struct {
int verbose;
} sim;
} config;
#define debug printf
 
static unsigned int server_fd = 0;
static unsigned int nhandlers = 0;
 
65,12 → 54,11
static struct vapi_handler {
int fd;
unsigned long id;
void (*read_func)(unsigned long);
void (*read_func)(unsigned long, unsigned long);
struct vapi_handler *next;
int temp;
} *vapi_handler;
 
 
/* Structure for polling, it is cached, that it doesn't have to be rebuilt each time */
static struct pollfd *fds = NULL;
static int nfds = 0;
225,13 → 213,13
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);
301,7 → 289,7
struct sockaddr_in sa;
struct sockaddr* addr = (struct sockaddr*)&sa;
int n = sizeof(struct sockaddr_in);
int fd = accept(server_fd,addr,&n);
int fd = accept(server_fd, addr, &n);
int on_off = 0; /* Turn off Nagel's algorithm on the socket */
int flags;
char sTemp[256];
316,7 → 304,7
server_fd = 0;
config.vapi.enabled = 0;
serverIP = 0;
}
}
return;
}
 
364,7 → 352,7
rebuild_fds ();
}
if(config.sim.verbose)
printf ("Connection with test (id %x) established.\n", id);
printf ("\nConnection with test (id %x) established.\n", id);
}
}
 
414,7 → 402,7
if (!t->read_func)
fprintf (stderr, "WARNING: packet sent to undefined id %x, %x\n", t->id, data);
else
t->read_func(data);
t->read_func(t->id, data);
}
 
void vapi_check ()
509,7 → 497,7
}
 
/* Installs a vapi handler to VAPI id */
void vapi_install_handler (unsigned long id, void (*read_func) (unsigned long))
void vapi_install_handler (unsigned long id, void (*read_func) (unsigned long, unsigned long))
{
struct vapi_handler *tt;
if (read_func == NULL) {
531,12 → 519,16
}
 
/* Returns number of unconnected handles. */
int vapi_num_unconnected ()
int vapi_num_unconnected (int printout)
{
struct vapi_handler *t = vapi_handler;
int numu = 0;
for (; t; t = t->next)
if (!t->fd) numu++;
for (; t; t = t->next) {
if (!t->fd) {
numu++;
if (printout) printf (" %x", t->id);
}
}
return numu;
}
 
/trunk/or1ksim/vapi/vapi.h
24,13 → 24,13
void vapi_done ();
 
/* Installs a vapi handler to VAPI id */
void vapi_install_handler (unsigned long id, void (*read_func) (unsigned long));
void vapi_install_handler (unsigned long id, void (*read_func) (unsigned long, unsigned long));
 
/* Checks for incoming packets */
void vapi_check ();
 
/* Returns number of unconnected handles. */
int vapi_num_unconnected ();
int vapi_num_unconnected (int printout);
 
/* Sends a packet to specified test */
int vapi_send (unsigned long id, unsigned long data);
/trunk/or1ksim/toplevel.c
52,7 → 52,7
#include "gdbcomm.h"
 
/* CVS revision number. */
const char rcsrev[] = "$Revision: 1.42 $";
const char rcsrev[] = "$Revision: 1.43 $";
 
/* Continuos run versus single step tracing switch. */
int cont_run;
262,14 → 262,18
reset();
/* Wait till all test are connected. */
if (config.vapi.enabled) {
int numu = vapi_num_unconnected ();
if (config.vapi.enabled) {
int numu = vapi_num_unconnected (0);
if (numu) {
printf ("\nWaiting for VAPI tests with ids:\n");
vapi_num_unconnected (1);
printf ("\n");
while (numu = vapi_num_unconnected ()) {
printf ("\rWaiting for %i VAPI tests to connect. ", numu);
while (numu = vapi_num_unconnected (0)) {
vapi_check ();
printf ("\rStill waiting for %i VAPI test(s) to connect. ", numu);
usleep (100);
}
printf ("\n");
}
printf ("All devices connected \n");
}
335,8 → 339,8
/* Read configuration file. */
read_script_file (config.script_file);
print_config();
sim_init ();
signal(SIGINT, ctrl_c);
sim_init ();
 
while(1) {
if (config.sim.iprompt) {

powered by: WebSVN 2.1.0

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