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

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc2/] [or1ksim/] [vapi/] [vapi.c] - Diff between revs 419 and 439

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 419 Rev 439
Line 39... Line 39...
#include <netdb.h>
#include <netdb.h>
#include <netinet/tcp.h>
#include <netinet/tcp.h>
#include <inttypes.h>
#include <inttypes.h>
 
 
#include "sim-config.h"
#include "sim-config.h"
 
#include "vapi.h"
 
 
static unsigned int serverIP = 0;
static unsigned int serverIP = 0;
 
 
static unsigned int server_fd = 0;
static unsigned int server_fd = 0;
static unsigned int nhandlers = 0;
static unsigned int nhandlers = 0;
Line 116... Line 117...
  rebuild_fds ();
  rebuild_fds ();
  return tt;
  return tt;
}
}
 
 
/* Added by Erez 09/12/01 */
/* 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)
        if (!runtime.vapi.vapi_file)
                return;
                return;
        if (config.vapi.log_device_id)
        if (config.vapi.log_device_id)
                fprintf (runtime.vapi.vapi_file, "%08x", devid);
                fprintf (runtime.vapi.vapi_file, "%08x", devid);
        fprintf (runtime.vapi.vapi_file, "%1x%08x\n", msgtype, data);
  fprintf (runtime.vapi.vapi_file, "%1x%08x\n", command, data);
}
}
 
 
static int vapi_write_stream(int fd, void* buf, int len)
static int vapi_write_stream(int fd, void* buf, int len)
{
{
  int n;
  int n;
Line 410... Line 411...
      rebuild_fds ();
      rebuild_fds ();
    }
    }
    return;
    return;
  }
  }
 
 
        write_vapi_file (0, t->id, data);
  vapi_write_log_file (0, t->id, data);
  debug (4, "[%08x, %08x]\n", t->id, data);
  debug (4, "[%08x, %08x]\n", t->id, data);
  if (!t->read_func)
  if (!t->read_func)
    fprintf (stderr, "WARNING: packet sent to undefined id %x, %x\n", t->id, data);
    fprintf (stderr, "WARNING: packet sent to undefined id %x, %x\n", t->id, data);
  else
  else
    t->read_func(t->id, data);
    t->read_func(t->id, data);
Line 510... Line 511...
  serverIP = 0;
  serverIP = 0;
  free (fds);
  free (fds);
  fds = 0;
  fds = 0;
  if (runtime.vapi.vapi_file) {
  if (runtime.vapi.vapi_file) {
    /* Mark end of simulation */
    /* Mark end of simulation */
                write_vapi_file (2, t->id, 0);
    vapi_write_log_file (2, t->id, 0);
    fclose (runtime.vapi.vapi_file);
    fclose (runtime.vapi.vapi_file);
  }
  }
 
 
  while (vapi_handler) {
  while (vapi_handler) {
    t = vapi_handler;
    t = vapi_handler;
Line 526... Line 527...
/* Installs a vapi handler to VAPI id */
/* Installs a vapi handler to VAPI id */
void vapi_install_handler (unsigned long id, void (*read_func) (unsigned long, unsigned long))
void vapi_install_handler (unsigned long id, void (*read_func) (unsigned long, unsigned long))
{
{
  struct vapi_handler *tt;
  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) {
  if (read_func == NULL) {
    struct vapi_handler **t = &vapi_handler;
    struct vapi_handler **t = &vapi_handler;
    while ((*t) && (*t)->id != id)
    while ((*t) && (*t)->id != id)
      t = &(*t)->next;
      t = &(*t)->next;
    if (!t) {
    if (!t) {
Line 569... Line 570...
 
 
/* Sends a packet to specified test */
/* Sends a packet to specified test */
int vapi_send (unsigned long id, unsigned long data)
int vapi_send (unsigned long id, unsigned long data)
{
{
  debug (4, "vapi_send [%08x %08x]\n", id, 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);
  write_packet (id, data);
}
}
 
 
/*
/*
int main ()
int main ()

powered by: WebSVN 2.1.0

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