X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fi386-io-windows.h;h=0e282442a792cd0a41a1e0f405f326e28f63ed68;hb=d305d70445ca10684c68c5f68474458742326ca7;hp=7006aa5cc1ceee33fda661e8cd304605bfe42f0c;hpb=837511b78ce0f1831353ac67f6a6b9a918aa4015;p=pciutils.git diff --git a/lib/i386-io-windows.h b/lib/i386-io-windows.h index 7006aa5..0e28244 100644 --- a/lib/i386-io-windows.h +++ b/lib/i386-io-windows.h @@ -2,6 +2,7 @@ * 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. */ @@ -9,57 +10,52 @@ #include #include #include - + #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_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; + typedef int (*MYPROC)(void); + MYPROC InitializeWinIo; + HMODULE lib; - intel_iopl_set = 0; + intel_iopl_set = 0; - lib = LoadLibrary("WinIo.dll"); - if (!lib) - { - fprintf(stderr, "libpci: Couldn't load WinIo.dll.\n"); - return 0; - } - GetProcAddress(lib, "InitializeWinIo"); - - InitializeWinIo = (MYPROC) GetProcAddress(lib, "InitializeWinIo"); - if (!InitializeWinIo) - { - fprintf(stderr, "libpci: Couldn't find InitialieWinIo 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; }