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