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

Subversion Repositories or1k

[/] [or1k/] [tags/] [stable_0_2_0_rc1/] [or1ksim/] [vapi/] [vapi.c] - Diff between revs 1358 and 1366

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

Rev 1358 Rev 1366
Line 59... Line 59...
static int tcp_level = 0;
static int tcp_level = 0;
 
 
static struct vapi_handler {
static struct vapi_handler {
  int fd;
  int fd;
  unsigned long base_id, num_ids;
  unsigned long base_id, num_ids;
  void (*read_func)(unsigned long, unsigned long);
  void (*read_func)(unsigned long, unsigned long, void *);
 
  void *priv_dat;
  struct vapi_handler *next;
  struct vapi_handler *next;
  int temp;
  int temp;
} *vapi_handler = NULL;
} *vapi_handler = NULL;
 
 
/* Structure for polling, it is cached, that it doesn't have to be rebuilt each time */
/* Structure for polling, it is cached, that it doesn't have to be rebuilt each time */
Line 119... Line 120...
  tt = (struct vapi_handler *)malloc (sizeof (struct vapi_handler));
  tt = (struct vapi_handler *)malloc (sizeof (struct vapi_handler));
  tt->next = NULL;
  tt->next = NULL;
  tt->base_id = base_id;
  tt->base_id = base_id;
  tt->num_ids = num_ids;
  tt->num_ids = num_ids;
  tt->read_func = NULL;
  tt->read_func = NULL;
 
  tt->priv_dat = NULL;
  tt->fd = 0;
  tt->fd = 0;
  (*t) = tt;
  (*t) = tt;
  free (fds);
  free (fds);
  fds = NULL;
  fds = NULL;
  nhandlers++;
  nhandlers++;
Line 428... Line 430...
  if (!handler_fits_id (t, id))
  if (!handler_fits_id (t, id))
    t = find_handler (id);
    t = find_handler (id);
  if (!t || !t->read_func)
  if (!t || !t->read_func)
    fprintf (stderr, "WARNING: Received packet for undefined id %08lx, data %08lx\n", id, data);
    fprintf (stderr, "WARNING: Received packet for undefined id %08lx, data %08lx\n", id, data);
  else
  else
    t->read_func(id, data);
    t->read_func(id, data, t->priv_dat);
}
}
 
 
void vapi_check ()
void vapi_check ()
{
{
  struct vapi_handler *t;
  struct vapi_handler *t;
Line 536... Line 538...
    free (t);
    free (t);
  }
  }
}
}
 
 
/* Installs a vapi handler for one VAPI id */
/* Installs a vapi handler for one 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, void *), void *dat)
{
{
  vapi_install_multi_handler (id, 1, read_func);
  vapi_install_multi_handler (id, 1, read_func, dat);
}
}
 
 
/* Installs a vapi handler for many VAPI id */
/* Installs a vapi handler for many VAPI id */
void vapi_install_multi_handler (unsigned long base_id, unsigned long num_ids, void (*read_func) (unsigned long, unsigned long))
void vapi_install_multi_handler (unsigned long base_id, unsigned long num_ids, void (*read_func) (unsigned long, unsigned long, void *), void *dat)
{
{
  struct vapi_handler *tt;
  struct vapi_handler *tt;
 
 
  debug(4, "vapi_install_handler %08lx, %lu, %08p\n", base_id, num_ids, read_func);
  debug(4, "vapi_install_handler %08lx, %lu, %08p\n", base_id, num_ids, read_func);
  if (read_func == NULL) {
  if (read_func == NULL) {
Line 565... Line 567...
  } else {
  } else {
    tt = find_handler (base_id);
    tt = find_handler (base_id);
    if (!tt) {
    if (!tt) {
      tt = add_handler (base_id, num_ids);
      tt = add_handler (base_id, num_ids);
      tt->read_func = read_func;
      tt->read_func = read_func;
 
      tt->priv_dat = dat;
    } else {
    } else {
      tt->read_func = read_func;
      tt->read_func = read_func;
 
      tt->priv_dat = dat;
      rebuild_fds ();
      rebuild_fds ();
    }
    }
  }
  }
}
}
 
 

powered by: WebSVN 2.1.0

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