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.
13 /* from haiku/trunk/headers/private/drivers/poke.h */
15 #define POKE_DEVICE_NAME "poke"
16 #define POKE_DEVICE_FULLNAME "/dev/misc/poke"
17 #define POKE_SIGNATURE 'wltp' // "We Like To Poke"
20 POKE_PORT_READ = B_DEVICE_OP_CODES_END + 1,
22 POKE_PORT_INDEXED_READ,
23 POKE_PORT_INDEXED_WRITE,
25 POKE_PCI_WRITE_CONFIG,
26 POKE_GET_NTH_PCI_INFO,
27 POKE_GET_PHYSICAL_ADDRESS,
44 uint8 size; // == index for POKE_PORT_INDEXED_*
62 static int poke_driver_fd;
65 intel_setup_io(struct pci_access *a UNUSED)
67 poke_driver_fd = open(POKE_DEVICE_FULLNAME, O_RDWR);
68 return (poke_driver_fd < 0) ? 0 : 1;
72 intel_cleanup_io(struct pci_access *a UNUSED)
74 close(poke_driver_fd);
81 port_io_args args = { POKE_SIGNATURE, port, sizeof(u8), 0 };
82 if (ioctl(poke_driver_fd, POKE_PORT_READ, &args, sizeof(args)) < 0)
84 return (u8)args.value;
90 port_io_args args = { POKE_SIGNATURE, port, sizeof(u16), 0 };
91 if (ioctl(poke_driver_fd, POKE_PORT_READ, &args, sizeof(args)) < 0)
93 return (u16)args.value;
99 port_io_args args = { POKE_SIGNATURE, port, sizeof(u32), 0 };
100 if (ioctl(poke_driver_fd, POKE_PORT_READ, &args, sizeof(args)) < 0)
102 return (u32)args.value;
106 outb (u8 value, u16 port)
108 port_io_args args = { POKE_SIGNATURE, port, sizeof(u8), value };
109 ioctl(poke_driver_fd, POKE_PORT_WRITE, &args, sizeof(args));
113 outw (u16 value, u16 port)
115 port_io_args args = { POKE_SIGNATURE, port, sizeof(u16), value };
116 ioctl(poke_driver_fd, POKE_PORT_WRITE, &args, sizeof(args));
120 outl (u32 value, u16 port)
122 port_io_args args = { POKE_SIGNATURE, port, sizeof(u32), value };
123 ioctl(poke_driver_fd, POKE_PORT_WRITE, &args, sizeof(args));
126 static inline void intel_io_lock(void)
130 static inline void intel_io_unlock(void)