1 /* $NetBSD: pci_machdep.h,v 1.5 2009/08/09 04:02:00 matt Exp $ */
4 * Copyright (c) 1996 Carnegie-Mellon University.
7 * Author: Chris G. Demetriou
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
19 * Carnegie Mellon requests users of this software to return to
21 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
30 #ifndef _MIPS_INCLUDE_PCI_MACHDEP_H_
31 #define _MIPS_INCLUDE_PCI_MACHDEP_H_
34 * __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH (if used) needs to be
35 * defined before this file is included
39 * Types provided to machine-independent PCI code
41 typedef struct mips_pci_chipset
*pci_chipset_tag_t
;
42 typedef u_long pcitag_t
;
43 typedef u_long pci_intr_handle_t
;
46 * Forward declarations.
48 struct pci_attach_args
;
51 * mips-specific PCI structure and type definitions.
52 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
54 struct mips_pci_chipset
{
56 void (*pc_attach_hook
)(device_t
, device_t
,
57 struct pcibus_attach_args
*);
58 int (*pc_bus_maxdevs
)(void *, int);
59 pcitag_t (*pc_make_tag
)(void *, int, int, int);
60 void (*pc_decompose_tag
)(void *, pcitag_t
, int *,
62 pcireg_t (*pc_conf_read
)(void *, pcitag_t
, int);
63 void (*pc_conf_write
)(void *, pcitag_t
, int, pcireg_t
);
66 int (*pc_intr_map
)(struct pci_attach_args
*,
68 const char *(*pc_intr_string
)(void *, pci_intr_handle_t
);
69 const struct evcnt
*(*pc_intr_evcnt
)(void *, pci_intr_handle_t
);
70 void *(*pc_intr_establish
)(void *, pci_intr_handle_t
,
71 int, int (*)(void *), void *);
72 void (*pc_intr_disestablish
)(void *, void *);
74 void (*pc_conf_interrupt
)(void *, int, int, int,
77 #ifdef __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH
78 void *(*pc_pciide_compat_intr_establish
)(void *,
79 device_t
, struct pci_attach_args
*, int,
80 int (*)(void *), void *);
85 * Functions provided to machine-independent PCI code.
87 #define pci_attach_hook(p, s, pba) \
88 (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
89 #define pci_bus_maxdevs(c, b) \
90 (*(c)->pc_bus_maxdevs)((c)->pc_conf_v, (b))
91 #define pci_make_tag(c, b, d, f) \
92 (*(c)->pc_make_tag)((c)->pc_conf_v, (b), (d), (f))
93 #define pci_decompose_tag(c, t, bp, dp, fp) \
94 (*(c)->pc_decompose_tag)((c)->pc_conf_v, (t), (bp), (dp), (fp))
95 #define pci_conf_read(c, t, r) \
96 (*(c)->pc_conf_read)((c)->pc_conf_v, (t), (r))
97 #define pci_conf_write(c, t, r, v) \
98 (*(c)->pc_conf_write)((c)->pc_conf_v, (t), (r), (v))
99 #define pci_intr_map(pa, ihp) \
100 (*(pa)->pa_pc->pc_intr_map)((pa), (ihp))
101 #define pci_intr_string(c, ih) \
102 (*(c)->pc_intr_string)((c)->pc_intr_v, (ih))
103 #define pci_intr_evcnt(c, ih) \
104 (*(c)->pc_intr_evcnt)((c)->pc_intr_v, (ih))
105 #define pci_intr_establish(c, ih, l, h, a) \
106 (*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a))
107 #define pci_intr_disestablish(c, iv) \
108 (*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv))
109 #define pci_conf_interrupt(c, b, d, p, s, lp) \
110 (*(c)->pc_conf_interrupt)((c)->pc_intr_v, (b), (d), (p), (s), (lp))
113 * mips-specific PCI functions.
114 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
116 #ifdef __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH
117 #define mips_pciide_compat_intr_establish(c, d, p, ch, f, a) \
118 ((c)->pc_pciide_compat_intr_establish == NULL ? NULL : \
119 (*(c)->pc_pciide_compat_intr_establish)((c)->pc_conf_v, (d), (p), \
123 #endif /* _MIPS_INCLUDE_PCI_MACHDEP_H_ */