pci_machdep.h revision 1.1 1 /* $NetBSD: pci_machdep.h,v 1.1 2001/06/13 07:32:47 enami Exp $ */
2
3 /*-
4 * Copyright (c) 2001 Enami Tsugutomo.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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 *
16 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 /*
30 * Machine-specific definitions for PCI autoconfiguration.
31 */
32
33 /*
34 * We want to contro both device probe order.
35 */
36 #define __PCI_BUS_DEVORDER
37
38 /*
39 * Types provided to machine-independent PCI code
40 */
41 typedef struct hpcmips_pci_chipset *pci_chipset_tag_t;
42 typedef u_long pcitag_t;
43 typedef u_long pci_intr_handle_t;
44
45 /*
46 * Forward declarations.
47 */
48 struct pci_attach_args;
49
50 /*
51 * hpcmips-specific PCI structure and type definitions.
52 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
53 */
54 struct hpcmips_pci_chipset {
55 struct device *pc_dev;
56
57 void (*pc_attach_hook)(struct device *, struct device *,
58 struct pcibus_attach_args *);
59 int (*pc_bus_maxdevs)(pci_chipset_tag_t, int);
60 int (*pc_bus_devorder)(pci_chipset_tag_t, int, char *);
61 pcitag_t (*pc_make_tag)(pci_chipset_tag_t, int, int, int);
62 void (*pc_decompose_tag)(pci_chipset_tag_t, pcitag_t, int *, int *,
63 int *);
64 pcireg_t (*pc_conf_read)(pci_chipset_tag_t, pcitag_t, int);
65 void (*pc_conf_write)(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
66 int (*pc_intr_map)(struct pci_attach_args *, pci_intr_handle_t *);
67 const char *(*pc_intr_string)(pci_chipset_tag_t, pci_intr_handle_t);
68 const struct evcnt *(*pc_intr_evcnt)(pci_chipset_tag_t,
69 pci_intr_handle_t);
70 void *(*pc_intr_establish)(pci_chipset_tag_t, pci_intr_handle_t, int,
71 int (*)(void *), void *);
72 void (*pc_intr_disestablish)(pci_chipset_tag_t, void *);
73
74 /* hpcmips specific */
75 void *(*pc_vrcintr_establish)(pci_chipset_tag_t, int,
76 int (*)(void *), void *);
77 void (*pc_vrcintr_disestablish)(pci_chipset_tag_t, void *);
78 };
79
80 /*
81 * Functions provided to machine-independent PCI code.
82 */
83 #define pci_attach_hook(p, s, pba) \
84 (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba))
85 #define pci_bus_maxdevs(c, b) \
86 (*(c)->pc_bus_maxdevs)((c), (b))
87 #ifdef __PCI_BUS_DEVORDER
88 #define pci_bus_devorder(c, b, d) \
89 (*(c)->pc_bus_devorder)((c), (b), (d))
90 #endif
91 #define pci_make_tag(c, b, d, f) \
92 (*(c)->pc_make_tag)((c), (b), (d), (f))
93 #define pci_decompose_tag(c, t, bp, dp, fp) \
94 (*(c)->pc_decompose_tag)((c), (t), (bp), (dp), (fp))
95 #define pci_conf_read(c, t, r) \
96 (*(c)->pc_conf_read)((c), (t), (r))
97 #define pci_conf_write(c, t, r, v) \
98 (*(c)->pc_conf_write)((c), (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), (ih))
103 #define pci_intr_evcnt(c, ih) \
104 (*(c)->pc_intr_evcnt)((c), (ih))
105 #define pci_intr_establish(c, ih, l, h, a) \
106 (*(c)->pc_intr_establish)((c), (ih), (l), (h), (a))
107 #define pci_intr_disestablish(c, iv) \
108 (*(c)->pc_intr_disestablish)((c), (iv))
109
110 /* XXX */
111 #define pci_vrcintr_establish(c, p, func, arg) \
112 (*(c)->pc_vrcintr_establish)((c), (p), (func), (arg))
113 #define pci_vrcintr_disestablish(c, iv) \
114 (*(c)->pc_vrcintr_disestablish)((c), (iv))
115