xref: /aosp_15_r20/external/pciutils/lib/i386-io-openbsd.h (revision c2e0c6b56a71da9abe8df5c8348fb3eb5c2c9251)
1 /*
2  *	The PCI Library -- Access to i386 I/O ports on OpenBSD
3  *
4  *	Copyright (c) 2023 Grant Pannell <[email protected]>
5  *
6  *	Can be freely distributed and used under the terms of the GNU GPL.
7  */
8 
9 #include <sys/types.h>
10 #include <machine/sysarch.h>
11 #include <machine/pio.h>
12 
13 #include "i386-io-access.h"
14 
15 #if defined(__amd64__)
16   #define obsd_iopl amd64_iopl
17 #else
18   #define obsd_iopl i386_iopl
19 #endif
20 
21 static int iopl_enabled;
22 
23 static int
intel_setup_io(struct pci_access * a UNUSED)24 intel_setup_io(struct pci_access *a UNUSED)
25 {
26   if (iopl_enabled)
27     return 1;
28 
29   if (obsd_iopl(3) < 0)
30     {
31       return 0;
32     }
33 
34   iopl_enabled = 1;
35   return 1;
36 }
37 
38 static inline void
intel_cleanup_io(struct pci_access * a UNUSED)39 intel_cleanup_io(struct pci_access *a UNUSED)
40 {
41   if (iopl_enabled)
42     {
43       obsd_iopl(0);
44       iopl_enabled = 0;
45     }
46 }
47 
intel_io_lock(void)48 static inline void intel_io_lock(void)
49 {
50 }
51 
intel_io_unlock(void)52 static inline void intel_io_unlock(void)
53 {
54 }
55