]> git.ipfire.org Git - thirdparty/pciutils.git/blob - lib/internal.h
Various PCIutils changes accumulated over last two weeks:
[thirdparty/pciutils.git] / lib / internal.h
1 /*
2 * $Id: internal.h,v 1.2 1999/07/07 11:23:10 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 #include <endian.h>
24 #if __BYTE_ORDER == __BIG_ENDIAN
25 #define cpu_to_le16 swab16
26 #define cpu_to_le32 swab32
27 #define le16_to_cpu swab16
28 #define le32_to_cpu swab32
29
30 static inline word swab16(word w)
31 {
32 return (w << 8) | ((w >> 8) & 0xff);
33 }
34
35 static inline u32 swab32(u32 w)
36 {
37 return ((w & 0xff000000) >> 24) |
38 ((w & 0x00ff0000) >> 8) |
39 ((w & 0x0000ff00) << 8) |
40 ((w & 0x000000ff) << 24);
41 }
42 #else
43 #define cpu_to_le16(x) (x)
44 #define cpu_to_le32(x) (x)
45 #define le16_to_cpu(x) (x)
46 #define le32_to_cpu(x) (x)
47 #endif
48
49 #endif
50
51 struct pci_methods {
52 char *name;
53 void (*config)(struct pci_access *);
54 int (*detect)(struct pci_access *);
55 void (*init)(struct pci_access *);
56 void (*cleanup)(struct pci_access *);
57 void (*scan)(struct pci_access *);
58 int (*fill_info)(struct pci_dev *, int flags);
59 int (*read)(struct pci_dev *, int pos, byte *buf, int len);
60 int (*write)(struct pci_dev *, int pos, byte *buf, int len);
61 void (*init_dev)(struct pci_dev *);
62 void (*cleanup_dev)(struct pci_dev *);
63 };
64
65 void pci_generic_scan(struct pci_access *);
66 int pci_generic_fill_info(struct pci_dev *, int flags);
67 int pci_generic_block_read(struct pci_dev *, int pos, byte *buf, int len);
68 int pci_generic_block_write(struct pci_dev *, int pos, byte *buf, int len);
69
70 void *pci_malloc(struct pci_access *, int);
71 void pci_mfree(void *);
72
73 struct pci_dev *pci_alloc_dev(struct pci_access *);
74 int pci_link_dev(struct pci_access *, struct pci_dev *);
75
76 extern struct pci_methods pm_intel_conf1, pm_intel_conf2, pm_linux_proc,
77 pm_syscalls, pm_dump;
78
79 #define UNUSED __attribute__((unused))