]> mj.ucw.cz Git - pciutils.git/blob - lib/i386-io-windows.h
i386-*: Cleaned up printing of initialization errors.
[pciutils.git] / lib / i386-io-windows.h
1 /*
2  *      The PCI Library -- Access to i386 I/O ports on Windows
3  *
4  *      Copyright (c) 2004 Alexander Stock <stock.alexander@gmx.de>
5  *      Copyright (c) 2006 Martin Mares <mj@ucw.cz>
6  *
7  *      Can be freely distributed and used under the terms of the GNU GPL.
8  */
9
10 #include <io.h>
11 #include <conio.h>
12 #include <windows.h>
13
14 #define outb(x,y) _outp(y,x)
15 #define outw(x,y) _outpw(y,x)
16 #define outl(x,y) _outpd(y,x)
17
18 #define inb(x) _inp(x)
19 #define inw(x) _inpw(x)
20 #define inl(x) _inpd(x)
21
22 static int
23 intel_setup_io(struct pci_access *a)
24 {
25   typedef int (*MYPROC)(void);
26   MYPROC InitializeWinIo;
27   HMODULE lib;
28
29   intel_iopl_set = 0;
30
31   lib = LoadLibrary("WinIo.dll");
32   if (!lib)
33     {
34       a->warning("i386-io-windows: Couldn't load WinIo.dll.");
35       return 0;
36     }
37   /* XXX: Is this really needed? --mj */
38   GetProcAddress(lib, "InitializeWinIo");
39
40   InitializeWinIo = (MYPROC) GetProcAddress(lib, "InitializeWinIo");
41   if (!InitializeWinIo)
42     {
43       a->warning("i386-io-windows: Couldn't find InitializeWinIo function.");
44       return 0;
45     }
46
47   if (!InitializeWinIo())
48     {
49       a->warning("i386-io-windows: InitializeWinIo() failed.");
50       return 0;
51     }
52
53   return 1;
54 }
55
56 static inline int
57 intel_cleanup_io(struct pci_access *a UNUSED)
58 {
59   //TODO: DeInitializeWinIo!
60   return 1;
61 }