X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fi386-io-windows.h;h=e2492df71a73e6c4f1c1b53f3332065aca928ee9;hb=8e6f2fcd2580894419c2807f8c1c5a8630a7d644;hp=f8b896db8c0de8452bd5c56603d6b49c81a3c71c;hpb=9007a292f24685d7c1ab51506fae8df22ced007f;p=pciutils.git diff --git a/lib/i386-io-windows.h b/lib/i386-io-windows.h index f8b896d..e2492df 100644 --- a/lib/i386-io-windows.h +++ b/lib/i386-io-windows.h @@ -2,14 +2,25 @@ * The PCI Library -- Access to i386 I/O ports on Windows * * Copyright (c) 2004 Alexander Stock + * Copyright (c) 2006 Martin Mares * * Can be freely distributed and used under the terms of the GNU GPL. */ #include -#include #include +#ifndef __GNUC__ +#include +#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) @@ -19,18 +30,27 @@ #define inl(x) _inpd(x) static int -intel_setup_io(void) +intel_setup_io(struct pci_access *a) { typedef int (*MYPROC)(void); MYPROC InitializeWinIo; HMODULE lib; - intel_iopl_set = 0; +#ifndef _WIN64 + /* 16/32-bit non-NT systems allow applications to access PCI I/O ports without any special setup. */ + OSVERSIONINFOA version; + version.dwOSVersionInfoSize = sizeof(version); + if (GetVersionExA(&version) && version.dwPlatformId < VER_PLATFORM_WIN32_NT) + { + a->debug("Detected 16/32-bit non-NT system, skipping NT setup..."); + return 1; + } +#endif lib = LoadLibrary("WinIo.dll"); if (!lib) { - fprintf(stderr, "libpci: Couldn't load WinIo.dll.\n"); + a->warning("i386-io-windows: Couldn't load WinIo.dll."); return 0; } /* XXX: Is this really needed? --mj */ @@ -39,13 +59,13 @@ intel_setup_io(void) InitializeWinIo = (MYPROC) GetProcAddress(lib, "InitializeWinIo"); if (!InitializeWinIo) { - fprintf(stderr, "libpci: Couldn't find InitializeWinIo function.\n"); + a->warning("i386-io-windows: Couldn't find InitializeWinIo function."); return 0; } if (!InitializeWinIo()) { - fprintf(stderr, "libpci: InitializeWinIo() failed.\n"); + a->warning("i386-io-windows: InitializeWinIo() failed."); return 0; } @@ -53,8 +73,16 @@ intel_setup_io(void) } static inline int -intel_cleanup_io(void) +intel_cleanup_io(struct pci_access *a UNUSED) { //TODO: DeInitializeWinIo! return 1; } + +static inline void intel_io_lock(void) +{ +} + +static inline void intel_io_unlock(void) +{ +}