]> git.ipfire.org Git - thirdparty/pciutils.git/blob - lib/internal.h
Merged in AIX port.
[thirdparty/pciutils.git] / lib / internal.h
1 /*
2 * $Id: internal.h,v 1.4 2000/04/21 11:58:00 mj Exp $
3 *
4 * The PCI Library -- Internal Include File
5 *
6 * Copyright (c) 1997--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
7 *
8 * Can be freely distributed and used under the terms of the GNU GPL.
9 */
10
11 #include "pci.h"
12
13 #ifdef HAVE_PM_LINUX_BYTEORDER_H
14
15 #include <asm/byteorder.h>
16 #define cpu_to_le16 __cpu_to_le16
17 #define cpu_to_le32 __cpu_to_le32
18 #define le16_to_cpu __le16_to_cpu
19 #define le32_to_cpu __le32_to_cpu
20
21 #else
22
23 #ifdef OS_LINUX
24 #include <endian.h>
25 #define BYTE_ORDER __BYTE_ORDER
26 #define BIG_ENDIAN __BIG_ENDIAN
27 #endif
28
29 #ifdef OS_FREEBSD
30 #include <sys/types.h>
31 #endif
32
33 #if BYTE_ORDER == BIG_ENDIAN
34 #define cpu_to_le16 swab16
35 #define cpu_to_le32 swab32
36 #define le16_to_cpu swab16
37 #define le32_to_cpu swab32
38
39 static inline word swab16(word w)
40 {
41 return (w << 8) | ((w >> 8) & 0xff);
42 }
43
44 static inline u32 swab32(u32 w)
45 {
46 return ((w & 0xff000000) >> 24) |
47 ((w & 0x00ff0000) >> 8) |
48 ((w & 0x0000ff00) << 8) |
49 ((w & 0x000000ff) << 24);
50 }
51 #else
52 #define cpu_to_le16(x) (x)
53 #define cpu_to_le32(x) (x)
54 #define le16_to_cpu(x) (x)
55 #define le32_to_cpu(x) (x)
56 #endif
57
58 #endif
59
60 struct pci_methods {
61 char *name;
62 void (*config)(struct pci_access *);
63 int (*detect)(struct pci_access *);
64 void (*init)(struct pci_access *);
65 void (*cleanup)(struct pci_access *);
66 void (*scan)(struct pci_access *);
67 int (*fill_info)(struct pci_dev *, int flags);
68 int (*read)(struct pci_dev *, int pos, byte *buf, int len);
69 int (*write)(struct pci_dev *, int pos, byte *buf, int len);
70 void (*init_dev)(struct pci_dev *);
71 void (*cleanup_dev)(struct pci_dev *);
72 };
73
74 void pci_generic_scan_bus(struct pci_access *, byte *busmap, int bus);
75 void pci_generic_scan(struct pci_access *);
76 int pci_generic_fill_info(struct pci_dev *, int flags);
77 int pci_generic_block_read(struct pci_dev *, int pos, byte *buf, int len);
78 int pci_generic_block_write(struct pci_dev *, int pos, byte *buf, int len);
79
80 void *pci_malloc(struct pci_access *, int);
81 void pci_mfree(void *);
82
83 struct pci_dev *pci_alloc_dev(struct pci_access *);
84 int pci_link_dev(struct pci_access *, struct pci_dev *);
85
86 extern struct pci_methods pm_intel_conf1, pm_intel_conf2, pm_linux_proc,
87 pm_syscalls, pm_fbsd_device, pm_aix_device, pm_dump;
88
89 #ifdef __GNUC__
90 #define UNUSED __attribute__((unused))
91 #else
92 #define UNUSED
93 #define inline
94 #endif