2 * The PCI Library -- Access to i386 I/O ports on Haiku
4 * Copyright (c) 2009 Francois Revol <revol@free.fr>
6 * Can be freely distributed and used under the terms of the GNU GPL v2+
8 * SPDX-License-Identifier: GPL-2.0-or-later
15 /* from haiku/trunk/headers/private/drivers/poke.h */
17 #define POKE_DEVICE_NAME "poke"
18 #define POKE_DEVICE_FULLNAME "/dev/misc/poke"
19 #define POKE_SIGNATURE 'wltp' // "We Like To Poke"
22 POKE_PORT_READ = B_DEVICE_OP_CODES_END + 1,
24 POKE_PORT_INDEXED_READ,
25 POKE_PORT_INDEXED_WRITE,
27 POKE_PCI_WRITE_CONFIG,
28 POKE_GET_NTH_PCI_INFO,
29 POKE_GET_PHYSICAL_ADDRESS,
46 uint8 size; // == index for POKE_PORT_INDEXED_*
64 static int poke_driver_fd;
67 intel_setup_io(struct pci_access *a UNUSED)
69 poke_driver_fd = open(POKE_DEVICE_FULLNAME, O_RDWR);
70 return (poke_driver_fd < 0) ? 0 : 1;
74 intel_cleanup_io(struct pci_access *a UNUSED)
76 close(poke_driver_fd);
82 port_io_args args = { POKE_SIGNATURE, port, sizeof(u8), 0 };
83 if (ioctl(poke_driver_fd, POKE_PORT_READ, &args, sizeof(args)) < 0)
85 return (u8)args.value;
91 port_io_args args = { POKE_SIGNATURE, port, sizeof(u16), 0 };
92 if (ioctl(poke_driver_fd, POKE_PORT_READ, &args, sizeof(args)) < 0)
94 return (u16)args.value;
100 port_io_args args = { POKE_SIGNATURE, port, sizeof(u32), 0 };
101 if (ioctl(poke_driver_fd, POKE_PORT_READ, &args, sizeof(args)) < 0)
103 return (u32)args.value;
107 outb (u8 value, u16 port)
109 port_io_args args = { POKE_SIGNATURE, port, sizeof(u8), value };
110 ioctl(poke_driver_fd, POKE_PORT_WRITE, &args, sizeof(args));
114 outw (u16 value, u16 port)
116 port_io_args args = { POKE_SIGNATURE, port, sizeof(u16), value };
117 ioctl(poke_driver_fd, POKE_PORT_WRITE, &args, sizeof(args));
121 outl (u32 value, u16 port)
123 port_io_args args = { POKE_SIGNATURE, port, sizeof(u32), value };
124 ioctl(poke_driver_fd, POKE_PORT_WRITE, &args, sizeof(args));
127 static inline void intel_io_lock(void)
131 static inline void intel_io_unlock(void)