diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:24:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:24:33 +0000 |
commit | 7a19c99f661602b67db95fd1d8aca5fe3a387441 (patch) | |
tree | 215ff04ec522779fa83acf394d296c2356c6b382 /lib/i386-io-haiku.h | |
parent | Initial commit. (diff) | |
download | pciutils-7a19c99f661602b67db95fd1d8aca5fe3a387441.tar.xz pciutils-7a19c99f661602b67db95fd1d8aca5fe3a387441.zip |
Adding upstream version 1:3.9.0.upstream/1%3.9.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | lib/i386-io-haiku.h | 131 |
1 files changed, 131 insertions, 0 deletions
diff --git a/lib/i386-io-haiku.h b/lib/i386-io-haiku.h new file mode 100644 index 0000000..dd00941 --- /dev/null +++ b/lib/i386-io-haiku.h @@ -0,0 +1,131 @@ +/* + * The PCI Library -- Access to i386 I/O ports on Haiku + * + * Copyright (c) 2009 Francois Revol <revol@free.fr> + * + * Can be freely distributed and used under the terms of the GNU GPL. + */ + +#include <Drivers.h> +#include <ISA.h> +#include <PCI.h> + +/* from haiku/trunk/headers/private/drivers/poke.h */ + +#define POKE_DEVICE_NAME "poke" +#define POKE_DEVICE_FULLNAME "/dev/misc/poke" +#define POKE_SIGNATURE 'wltp' // "We Like To Poke" + +enum { + POKE_PORT_READ = B_DEVICE_OP_CODES_END + 1, + POKE_PORT_WRITE, + POKE_PORT_INDEXED_READ, + POKE_PORT_INDEXED_WRITE, + POKE_PCI_READ_CONFIG, + POKE_PCI_WRITE_CONFIG, + POKE_GET_NTH_PCI_INFO, + POKE_GET_PHYSICAL_ADDRESS, + POKE_MAP_MEMORY, + POKE_UNMAP_MEMORY +}; + + +typedef struct { + uint32 signature; + uint8 index; + pci_info* info; + status_t status; +} pci_info_args; + + +typedef struct { + uint32 signature; + uint16 port; + uint8 size; // == index for POKE_PORT_INDEXED_* + uint32 value; +} port_io_args; + + +typedef struct { + uint32 signature; + uint8 bus; + uint8 device; + uint8 function; + uint8 size; + uint8 offset; + uint32 value; +} pci_io_args; + + +/* en poke.h*/ + +static int poke_driver_fd; + +static int +intel_setup_io(struct pci_access *a UNUSED) +{ + poke_driver_fd = open(POKE_DEVICE_FULLNAME, O_RDWR); + return (poke_driver_fd < 0) ? 0 : 1; +} + +static inline void +intel_cleanup_io(struct pci_access *a UNUSED) +{ + close(poke_driver_fd); +} + +static inline u8 +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) + return 0; + return (u8)args.value; +} + +static inline u16 +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) + return 0; + return (u16)args.value; +} + +static inline u32 +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) + return 0; + return (u32)args.value; +} + +static inline void +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) +{ + 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) +{ + port_io_args args = { POKE_SIGNATURE, port, sizeof(u32), value }; + ioctl(poke_driver_fd, POKE_PORT_WRITE, &args, sizeof(args)); +} + +static inline void intel_io_lock(void) +{ +} + +static inline void intel_io_unlock(void) +{ +} |