]> mj.ucw.cz Git - pciutils.git/blob - lib/i386-io-sunos.h
More Windows stuff.
[pciutils.git] / lib / i386-io-sunos.h
1 /*
2  *      The PCI Library -- Access to i386 I/O ports on Solaris
3  *
4  *      Copyright (c) 2003 Bill Moore <billm@eng.sun.com>
5  *      Copyright (c) 2003 Martin Mares <mj@ucw.cz>
6  *
7  *      Can be freely distributed and used under the terms of the GNU GPL.
8  */
9
10 #include <sys/sysi86.h>
11 #include <sys/psw.h>
12
13 static int intel_iopl_set = -1;
14
15 static int
16 intel_setup_io(void)
17 {
18   if (intel_iopl_set < 0)
19     {
20       if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)
21         intel_iopl_set = 0;
22       else
23         intel_iopl_set = 1;
24     }
25   return intel_iopl_set;
26 }
27
28 static inline void
29 intel_cleanup_io(void)
30 {
31   if (intel_iopl_set > 0)
32     {
33       /* FIXME: How to switch off I/O port access? */
34     }
35   intel_iopl_set = -1;
36 }
37
38 static inline u8
39 inb (u16 port)
40 {
41   u8 v;
42   __asm__ __volatile__ ("inb (%w1)":"=a" (v):"Nd" (port));
43   return v;
44 }
45
46 static inline u16
47 inw (u16 port)
48 {
49   u16 v;
50   __asm__ __volatile__ ("inw (%w1)":"=a" (v):"Nd" (port));
51   return v;
52 }
53
54 static inline u32
55 inl (u16 port)
56 {
57   u32 v;
58   __asm__ __volatile__ ("inl (%w1)":"=a" (v):"Nd" (port));
59   return v;
60 }
61
62 static inline void
63 outb (u8 value, u16 port)
64 {
65   __asm__ __volatile__ ("outb (%w1)": :"a" (value), "Nd" (port));
66 }
67
68 static inline void
69 outw (u16 value, u16 port)
70 {
71   __asm__ __volatile__ ("outw (%w1)": :"a" (value), "Nd" (port));
72 }
73
74 static inline void
75 outl (u32 value, u16 port)
76 {
77   __asm__ __volatile__ ("outl (%w1)": :"a" (value), "Nd" (port));
78 }