1 /* $NetBSD: pci_machdep.h,v 1.7 2005/12/11 12:18:43 christos Exp $ */
4 * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
5 * Copyright (c) 1994 Charles M. Hannum. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Charles M. Hannum.
18 * 4. The name of the author may not be used to endorse or promote products
19 * derived from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef __MACHINE_PCI_MACHDEP_H
34 #define __MACHINE_PCI_MACHDEP_H
37 * Machine-specific definitions for PCI autoconfiguration.
39 #define __PCI_BUS_DEVORDER 1
40 #define __HAVE_PCI_CONF_HOOK 1
43 * be-specific PCI structure and type definitions.
44 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
46 * Configuration tag; created from a {bus,device,function} triplet by
47 * pci_make_tag(), and passed to pci_conf_read() and pci_conf_write().
48 * We could instead always pass the {bus,device,function} triplet to
49 * the read and write routines, but this would cause extra overhead.
52 struct pci_attach_args
; /* Forward declaration */
55 * Types provided to machine-independent PCI code
57 typedef struct pci_chipset
*pci_chipset_tag_t
;
59 typedef int pci_intr_handle_t
;
61 struct pci_chipset_functions
{
62 void (*pcf_bus_attach_hook
)(struct device
*, struct device
*,
63 struct pcibus_attach_args
*);
64 int (*pcf_bus_maxdevs
)(pci_chipset_tag_t
, int);
65 void (*pcf_bus_devorder
)(pci_chipset_tag_t
, int, char []);
67 pcitag_t (*pcf_make_tag
)(pci_chipset_tag_t
, int, int, int);
68 void (*pcf_decompose_tag
)(pci_chipset_tag_t
, pcitag_t
, int *, int *,
71 pcireg_t (*pcf_conf_read
)(pci_chipset_tag_t
, pcitag_t
, int);
72 void (*pcf_conf_write
)(pci_chipset_tag_t
, pcitag_t
, int, pcireg_t
);
73 int (*pcf_conf_hook
)(pci_chipset_tag_t
, int, int, int, pcireg_t
);
74 void (*pcf_conf_interrupt
)(pci_chipset_tag_t
, int, int, int, int,
77 int (*pcf_intr_map
)(struct pci_attach_args
*, pci_intr_handle_t
*);
78 const char *(*pcf_intr_string
)(pci_chipset_tag_t
, pci_intr_handle_t
);
79 const struct evcnt
*(*pcf_intr_evcnt
)(pci_chipset_tag_t
,
81 void *(*pcf_intr_establish
)(pci_chipset_tag_t
, pci_intr_handle_t
,
82 int, int (*)(void *), void *);
83 void (*pcf_intr_disestablish
)(pci_chipset_tag_t
, void *);
87 struct device
*pc_parent
;
88 const struct pci_chipset_functions
*pc_funcs
;
92 * Functions provided to machine-independent PCI code.
95 #define pci_attach_hook(parent, self, pba) \
96 ((*(pba)->pba_pc->pc_funcs->pcf_bus_attach_hook)((parent), (self), (pba)))
97 #define pci_bus_maxdevs(pc, busno) \
98 ((*(pc)->pc_funcs->pcf_bus_maxdevs)((pc), (busno)))
99 #define pci_make_tag(pc, bus, dev, func) \
100 ((*(pc)->pc_funcs->pcf_make_tag)((pc), (bus), (dev), (func)))
101 #define pci_decompose_tag(pc, tag, bp, dp, fp) \
102 ((*(pc)->pc_funcs->pcf_decompose_tag)((pc), (tag), (bp), (dp), (fp)))
103 #define pci_conf_read(pc, tag, reg) \
104 ((*(pc)->pc_funcs->pcf_conf_read)((pc), (tag), (reg)))
105 #define pci_conf_write(pc, tag, reg, data) \
106 ((*(pc)->pc_funcs->pcf_conf_write)((pc), (tag), (reg), (data)))
107 #define pci_conf_hook(pc, bus, dev, func, id) \
108 ((*(pc)->pc_funcs->pcf_conf_hook)((pc), (bus), (dev), (func), (id)))
109 #define pci_conf_interrupt(pc, bus, dev, pin, swiz, iline) \
110 ((*(pc)->pc_funcs->pcf_conf_interrupt)((pc), (bus), (dev), (pin), (swiz), (iline)))
111 #define pci_intr_map(pa, ihp) \
112 ((*(pa)->pa_pc->pc_funcs->pcf_intr_map)((pa), (ihp)))
113 #define pci_intr_string(pc, ih) \
114 ((*(pc)->pc_funcs->pcf_intr_string)((pc), (ih)))
115 #define pci_intr_evcnt(pc, ih) \
116 ((*(pc)->pc_funcs->pcf_intr_evcnt)((pc), (ih)))
117 #define pci_intr_establish(pc, ih, ipl, func, arg) \
118 ((*(pc)->pc_funcs->pcf_intr_establish)((pc), (ih), (ipl), (func), (arg)))
119 #define pci_intr_disestablish(pc, ih) \
120 ((*(pc)->pc_funcs->pcf_intr_disestablish)((pc), (ih)))
121 #define pci_bus_devorder(pc, bus, devs) \
122 ((*(pc)->pc_funcs->pcf_bus_devorder)((pc), (bus), (devs)))
124 #endif /* __MACHINE_PCI_MACHDEP_H */