From 837511b78ce0f1831353ac67f6a6b9a918aa4015 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sat, 29 May 2004 20:19:03 +0000 Subject: [PATCH] The rest of the Windows port. git-archimport-id: mj@ucw.cz--public/pciutils--main--2.2--patch-47 --- lib/i386-io-windows.h | 65 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 lib/i386-io-windows.h diff --git a/lib/i386-io-windows.h b/lib/i386-io-windows.h new file mode 100644 index 0000000..7006aa5 --- /dev/null +++ b/lib/i386-io-windows.h @@ -0,0 +1,65 @@ +/* + * The PCI Library -- Access to i386 I/O ports on Windows + * + * Copyright (c) 2004 Alexander Stock + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#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) +{ + 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; + } + GetProcAddress(lib, "InitializeWinIo"); + + InitializeWinIo = (MYPROC) GetProcAddress(lib, "InitializeWinIo"); + if (!InitializeWinIo) + { + fprintf(stderr, "libpci: Couldn't find InitialieWinIo function.\n"); + return 0; + } + + if (!InitializeWinIo()) + { + fprintf(stderr, "libpci: InitializeWinIo() failed.\n"); + return 0; + } + + intel_iopl_set=1; + } + return intel_iopl_set; +} + +static inline void +intel_cleanup_io(void) +{ + //TODO: DeInitializeWinIo! + //intel_iopl_set = -1; +} -- 2.39.5