]> mj.ucw.cz Git - pciutils.git/blob - lib/i386-io-windows.h
More Windows stuff.
[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  *
6  *      Can be freely distributed and used under the terms of the GNU GPL.
7  */
8
9 #include <io.h>
10 #include <conio.h>
11 #include <windows.h>
12   
13 #define outb(x,y) _outp(y,x)
14 #define outw(x,y) _outpw(y,x)
15 #define outl(x,y) _outpd(y,x)
16   
17 #define inb(x) _inp(x)
18 #define inw(x) _inpw(x)
19 #define inl(x) _inpd(x)
20
21 static int intel_iopl_set = -1;
22
23 static int
24 intel_setup_io(void)
25 {
26   if (intel_iopl_set < 0)
27     {
28       typedef int (*MYPROC)(void);
29       MYPROC InitializeWinIo;  
30       HMODULE lib;
31
32       intel_iopl_set = 0;
33
34       lib = LoadLibrary("WinIo.dll");
35       if (!lib)
36         {
37           fprintf(stderr, "libpci: Couldn't load WinIo.dll.\n");
38           return 0;
39         }
40       GetProcAddress(lib, "InitializeWinIo");
41   
42       InitializeWinIo = (MYPROC) GetProcAddress(lib, "InitializeWinIo");
43       if (!InitializeWinIo)
44         {
45           fprintf(stderr, "libpci: Couldn't find InitialieWinIo function.\n");
46           return 0;
47         }
48
49       if (!InitializeWinIo())
50         {
51           fprintf(stderr, "libpci: InitializeWinIo() failed.\n");
52           return 0;
53         }
54
55       intel_iopl_set=1;
56     }
57   return intel_iopl_set;
58 }
59
60 static inline void
61 intel_cleanup_io(void)
62 {
63   //TODO: DeInitializeWinIo!
64   //intel_iopl_set = -1;
65 }