]> mj.ucw.cz Git - pciutils.git/blobdiff - lib/i386-io-haiku.h
MacOS: An attempt to appease compiler picky about attribute placement
[pciutils.git] / lib / i386-io-haiku.h
index 2bbe592672abaa8471c123a7c3ff026b4994f186..23843eabb525c99d63c7e4c0d4b2cc5d4085f0ab 100644 (file)
@@ -3,7 +3,9 @@
  *
  *     Copyright (c) 2009 Francois Revol <revol@free.fr>
  *
- *     Can be freely distributed and used under the terms of the GNU GPL.
+ *     Can be freely distributed and used under the terms of the GNU GPL v2+
+ *
+ *     SPDX-License-Identifier: GPL-2.0-or-later
  */
 
 #include <Drivers.h>
@@ -64,19 +66,27 @@ static int poke_driver_fd;
 static int
 intel_setup_io(struct pci_access *a UNUSED)
 {
+  /*
+   * Opening poke device on systems with the linked change below
+   * automatically changes process IOPL to 3 and closing its file
+   * descriptor changes process IOPL back to 0, which give access
+   * to all x86 IO ports via x86 in/out instructions for this
+   * userspace process. To support also older systems without this
+   * change, access IO ports via ioctl() instead of x86 in/out.
+   * https://review.haiku-os.org/c/haiku/+/1077
+   */
   poke_driver_fd = open(POKE_DEVICE_FULLNAME, O_RDWR);
   return (poke_driver_fd < 0) ? 0 : 1;
 }
 
-static inline int
+static inline void
 intel_cleanup_io(struct pci_access *a UNUSED)
 {
   close(poke_driver_fd);
-  return 1;
 }
 
 static inline u8
-inb (u16 port)
+intel_inb (u16 port)
 {
   port_io_args args = { POKE_SIGNATURE, port, sizeof(u8), 0 };
   if (ioctl(poke_driver_fd, POKE_PORT_READ, &args, sizeof(args)) < 0)
@@ -85,7 +95,7 @@ inb (u16 port)
 }
 
 static inline u16
-inw (u16 port)
+intel_inw (u16 port)
 {
   port_io_args args = { POKE_SIGNATURE, port, sizeof(u16), 0 };
   if (ioctl(poke_driver_fd, POKE_PORT_READ, &args, sizeof(args)) < 0)
@@ -94,7 +104,7 @@ inw (u16 port)
 }
 
 static inline u32
-inl (u16 port)
+intel_inl (u16 port)
 {
   port_io_args args = { POKE_SIGNATURE, port, sizeof(u32), 0 };
   if (ioctl(poke_driver_fd, POKE_PORT_READ, &args, sizeof(args)) < 0)
@@ -103,21 +113,21 @@ inl (u16 port)
 }
 
 static inline void
-outb (u8 value, u16 port)
+intel_outb (u8 value, u16 port)
 {
   port_io_args args = { POKE_SIGNATURE, port, sizeof(u8), value };
   ioctl(poke_driver_fd, POKE_PORT_WRITE, &args, sizeof(args));
 }
 
 static inline void
-outw (u16 value, u16 port)
+intel_outw (u16 value, u16 port)
 {
   port_io_args args = { POKE_SIGNATURE, port, sizeof(u16), value };
   ioctl(poke_driver_fd, POKE_PORT_WRITE, &args, sizeof(args));
 }
 
 static inline void
-outl (u32 value, u16 port)
+intel_outl (u32 value, u16 port)
 {
   port_io_args args = { POKE_SIGNATURE, port, sizeof(u32), value };
   ioctl(poke_driver_fd, POKE_PORT_WRITE, &args, sizeof(args));