File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / pciutils / lib / i386-io-windows.h
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Fri Feb 17 15:18:43 2012 UTC (12 years, 10 months ago) by misho
Branches: pciutils, MAIN
CVS tags: v3_1_9, HEAD
pciutils

/*
 *	The PCI Library -- Access to i386 I/O ports on Windows
 *
 *	Copyright (c) 2004 Alexander Stock <stock.alexander@gmx.de>
 *	Copyright (c) 2006 Martin Mares <mj@ucw.cz>
 *
 *	Can be freely distributed and used under the terms of the GNU GPL.
 */

#include <io.h>
#include <windows.h>

#ifndef __GNUC__
#include <conio.h>
#else
int _outp(unsigned short port, int databyte);
unsigned short _outpw(unsigned short port, unsigned short dataword);
unsigned long _outpd(unsigned short port, unsigned long dataword);
int _inp(unsigned short port);
unsigned short _inpw(unsigned short port);
unsigned long _inpd(unsigned short port);
#endif

#define outb(x,y) _outp(y,x)
#define outw(x,y) _outpw(y,x)
#define outl(x,y) _outpd(y,x)

#define inb(x) _inp(x)
#define inw(x) _inpw(x)
#define inl(x) _inpd(x)

static int
intel_setup_io(struct pci_access *a)
{
  typedef int (*MYPROC)(void);
  MYPROC InitializeWinIo;
  HMODULE lib;

  lib = LoadLibrary("WinIo.dll");
  if (!lib)
    {
      a->warning("i386-io-windows: Couldn't load WinIo.dll.");
      return 0;
    }
  /* XXX: Is this really needed? --mj */
  GetProcAddress(lib, "InitializeWinIo");

  InitializeWinIo = (MYPROC) GetProcAddress(lib, "InitializeWinIo");
  if (!InitializeWinIo)
    {
      a->warning("i386-io-windows: Couldn't find InitializeWinIo function.");
      return 0;
    }

  if (!InitializeWinIo())
    {
      a->warning("i386-io-windows: InitializeWinIo() failed.");
      return 0;
    }

  return 1;
}

static inline int
intel_cleanup_io(struct pci_access *a UNUSED)
{
  //TODO: DeInitializeWinIo!
  return 1;
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>