]> mj.ucw.cz Git - pciutils.git/blobdiff - lib/i386-io-windows.h
lspci: Indent PCIe Capability DevCap2 & DevCtl2 correctly
[pciutils.git] / lib / i386-io-windows.h
index c875a7d1dcb8e29c6d94a6cedcce08f37d3b6c93..6e3dec009afc2061f8e1497c3975a959305ed13a 100644 (file)
@@ -2,14 +2,25 @@
  *     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 <conio.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 inw(x) _inpw(x)
 #define inl(x) _inpd(x)
 
-static int intel_iopl_set = -1;
-
 static int
-intel_setup_io(void)
+intel_setup_io(struct pci_access *a)
 {
-  if (intel_iopl_set < 0)
-    {
-      typedef int (*MYPROC)(void);
-      MYPROC InitializeWinIo;
-      HMODULE lib;
-
-      intel_iopl_set = 0;
-
-      lib = LoadLibrary("WinIo.dll");
-      if (!lib)
-       {
-         fprintf(stderr, "libpci: Couldn't load WinIo.dll.\n");
-         return 0;
-       }
-      /* XXX: Is this really needed? --mj */
-      GetProcAddress(lib, "InitializeWinIo");
+  typedef int (*MYPROC)(void);
+  MYPROC InitializeWinIo;
+  HMODULE lib;
 
-      InitializeWinIo = (MYPROC) GetProcAddress(lib, "InitializeWinIo");
-      if (!InitializeWinIo)
-       {
-         fprintf(stderr, "libpci: Couldn't find InitializeWinIo function.\n");
-         return 0;
-       }
+  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");
 
-      if (!InitializeWinIo())
-       {
-         fprintf(stderr, "libpci: InitializeWinIo() failed.\n");
-         return 0;
-       }
+  InitializeWinIo = (MYPROC) GetProcAddress(lib, "InitializeWinIo");
+  if (!InitializeWinIo)
+    {
+      a->warning("i386-io-windows: Couldn't find InitializeWinIo function.");
+      return 0;
+    }
 
-      intel_iopl_set = 1;
+  if (!InitializeWinIo())
+    {
+      a->warning("i386-io-windows: InitializeWinIo() failed.");
+      return 0;
     }
-  return intel_iopl_set;
+
+  return 1;
 }
 
-static inline void
-intel_cleanup_io(void)
+static inline int
+intel_cleanup_io(struct pci_access *a UNUSED)
 {
   //TODO: DeInitializeWinIo!
-  //intel_iopl_set = -1;
+  return 1;
 }