]> git.ipfire.org Git - thirdparty/pciutils.git/blame - lib/internal.h
Changed all my email addresses to mj@ucw.cz.
[thirdparty/pciutils.git] / lib / internal.h
CommitLineData
727ce158 1/*
a27a33dd 2 * $Id: internal.h,v 1.6 2002/03/30 15:39:25 mj Exp $
727ce158
MM
3 *
4 * The PCI Library -- Internal Include File
5 *
a27a33dd 6 * Copyright (c) 1997--2000 Martin Mares <mj@ucw.cz>
727ce158
MM
7 *
8 * Can be freely distributed and used under the terms of the GNU GPL.
9 */
10
11#include "pci.h"
12
a239ade6
MM
13#ifdef __GNUC__
14#define UNUSED __attribute__((unused))
15#else
16#define UNUSED
17#define inline
18#endif
19
727ce158
MM
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
168b4f46 30#ifdef OS_LINUX
727ce158 31#include <endian.h>
168b4f46
MM
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
727ce158
MM
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
46static inline word swab16(word w)
47{
48 return (w << 8) | ((w >> 8) & 0xff);
49}
50
51static 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
67struct 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 *);
e95c8373 74 int (*fill_info)(struct pci_dev *, int flags);
727ce158
MM
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
14d6c0a3 81void pci_generic_scan_bus(struct pci_access *, byte *busmap, int bus);
727ce158 82void pci_generic_scan(struct pci_access *);
e95c8373 83int pci_generic_fill_info(struct pci_dev *, int flags);
727ce158
MM
84int pci_generic_block_read(struct pci_dev *, int pos, byte *buf, int len);
85int pci_generic_block_write(struct pci_dev *, int pos, byte *buf, int len);
86
87void *pci_malloc(struct pci_access *, int);
88void pci_mfree(void *);
89
90struct pci_dev *pci_alloc_dev(struct pci_access *);
91int pci_link_dev(struct pci_access *, struct pci_dev *);
92
93extern struct pci_methods pm_intel_conf1, pm_intel_conf2, pm_linux_proc,
14d6c0a3 94 pm_syscalls, pm_fbsd_device, pm_aix_device, pm_dump;