]> git.ipfire.org Git - thirdparty/pciutils.git/blame - lib/i386-io-haiku.h
pciutils: Add the support for a DOS/DJGPP environment
[thirdparty/pciutils.git] / lib / i386-io-haiku.h
CommitLineData
40e253d7
FR
1/*
2 * The PCI Library -- Access to i386 I/O ports on Haiku
3 *
4 * Copyright (c) 2009 Francois Revol <revol@free.fr>
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9#include <Drivers.h>
10#include <ISA.h>
11#include <PCI.h>
12
13/* from haiku/trunk/headers/private/drivers/poke.h */
14
15#define POKE_DEVICE_NAME "poke"
16#define POKE_DEVICE_FULLNAME "/dev/misc/poke"
17#define POKE_SIGNATURE 'wltp' // "We Like To Poke"
18
19enum {
20 POKE_PORT_READ = B_DEVICE_OP_CODES_END + 1,
21 POKE_PORT_WRITE,
22 POKE_PORT_INDEXED_READ,
23 POKE_PORT_INDEXED_WRITE,
24 POKE_PCI_READ_CONFIG,
25 POKE_PCI_WRITE_CONFIG,
26 POKE_GET_NTH_PCI_INFO,
27 POKE_GET_PHYSICAL_ADDRESS,
28 POKE_MAP_MEMORY,
29 POKE_UNMAP_MEMORY
30};
31
32
33typedef struct {
34 uint32 signature;
35 uint8 index;
36 pci_info* info;
37 status_t status;
38} pci_info_args;
39
40
41typedef struct {
42 uint32 signature;
43 uint16 port;
44 uint8 size; // == index for POKE_PORT_INDEXED_*
45 uint32 value;
46} port_io_args;
47
48
49typedef struct {
50 uint32 signature;
51 uint8 bus;
52 uint8 device;
53 uint8 function;
54 uint8 size;
55 uint8 offset;
56 uint32 value;
57} pci_io_args;
58
59
60/* en poke.h*/
61
62static int poke_driver_fd;
63
64static int
65intel_setup_io(struct pci_access *a UNUSED)
66{
67 poke_driver_fd = open(POKE_DEVICE_FULLNAME, O_RDWR);
68 return (poke_driver_fd < 0) ? 0 : 1;
69}
70
71static inline int
72intel_cleanup_io(struct pci_access *a UNUSED)
73{
74 close(poke_driver_fd);
75 return 1;
76}
77
78static inline u8
79inb (u16 port)
80{
81 port_io_args args = { POKE_SIGNATURE, port, sizeof(u8), 0 };
82 if (ioctl(poke_driver_fd, POKE_PORT_READ, &args, sizeof(args)) < 0)
83 return 0;
84 return (u8)args.value;
85}
86
87static inline u16
88inw (u16 port)
89{
90 port_io_args args = { POKE_SIGNATURE, port, sizeof(u16), 0 };
91 if (ioctl(poke_driver_fd, POKE_PORT_READ, &args, sizeof(args)) < 0)
92 return 0;
93 return (u16)args.value;
94}
95
96static inline u32
97inl (u16 port)
98{
99 port_io_args args = { POKE_SIGNATURE, port, sizeof(u32), 0 };
100 if (ioctl(poke_driver_fd, POKE_PORT_READ, &args, sizeof(args)) < 0)
101 return 0;
102 return (u32)args.value;
103}
104
105static inline void
106outb (u8 value, u16 port)
107{
108 port_io_args args = { POKE_SIGNATURE, port, sizeof(u8), value };
109 ioctl(poke_driver_fd, POKE_PORT_WRITE, &args, sizeof(args));
110}
111
112static inline void
113outw (u16 value, u16 port)
114{
115 port_io_args args = { POKE_SIGNATURE, port, sizeof(u16), value };
116 ioctl(poke_driver_fd, POKE_PORT_WRITE, &args, sizeof(args));
117}
118
119static inline void
120outl (u32 value, u16 port)
121{
122 port_io_args args = { POKE_SIGNATURE, port, sizeof(u32), value };
123 ioctl(poke_driver_fd, POKE_PORT_WRITE, &args, sizeof(args));
124}
5c5ce192
RM
125
126static inline void intel_io_lock(void)
127{
128}
129
130static inline void intel_io_unlock(void)
131{
132}