panthema / 2006 / SDIOS06 / sdios06 / src / pci / pci-server.cc (Download File)
/*****************************************************************
 * Source file : src/pci/pci.idl
 * Platform    : V4 IA32
 * Mapping     : CORBA C
 * 
 * Generated by IDL4 1.0.2 (roadrunner) on 22/06/2006 17:38
 * Report bugs to haeberlen@ira.uka.de
 *****************************************************************/
#include <config.h>

#include <sdi/panic.h>
#include <sdi/locator.h>
#include <sdi/log.h>

#include <idl4glue.h>
#include <if/iflocator.h>
#include "pci-server.h"
#include "pci.h"

IDL4_PUBLISH_PCI_SCANFORDEVICE(pci_ScanForDevice);

void *pci_vtable[PCI_DEFAULT_VTABLE_SIZE] = PCI_DEFAULT_VTABLE_15;

static void announce()
{
	if(Register(GetLocator(), "pci", IF_PCI_ID, 0) != OK)
		panic("Couldn't register pci server");
}

void pci_server()
{
  L4_ThreadId_t partner;
  L4_MsgTag_t msgtag;
  idl4_msgbuf_t msgbuf;
  long cnt;

  idl4_msgbuf_init(&msgbuf);
  for (cnt = 0;cnt < PCI_STRBUF_SIZE;cnt++)
    idl4_msgbuf_add_buffer(&msgbuf, malloc(8000), 8000);

	announce();    

  while (1)
    {
      partner = L4_nilthread;
      msgtag.raw = 0;
      cnt = 0;

      while (1)
        {
          idl4_msgbuf_sync(&msgbuf);

          idl4_reply_and_wait(&partner, &msgtag, &msgbuf, &cnt);

          if (idl4_is_error(&msgtag))
            break;

          idl4_process_request(&partner, &msgtag, &msgbuf, &cnt, pci_vtable[idl4_get_function_id(&msgtag) & PCI_FID_MASK]);
        }
    }
}

void pci_discard()
{
	panic("pci message discarded");
}