- use device_t and cfdriver_t - use device_private() and device_xname() - use proper types or variables for device_t/softcdiff -r1.16 -r1.17 src/sys/arch/sparc/dev/bootbus.c
(tsutsui)
--- src/sys/arch/sparc/dev/bootbus.c 2008/04/28 20:23:35 1.16
+++ src/sys/arch/sparc/dev/bootbus.c 2009/09/20 16:18:21 1.17
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: bootbus.c,v 1.16 2008/04/28 20:23:35 martin Exp $ */ | 1 | /* $NetBSD: bootbus.c,v 1.17 2009/09/20 16:18:21 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 2002 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 2002 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Jason R. Thorpe. | 8 | * by Jason R. Thorpe. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -24,126 +24,125 @@ | @@ -24,126 +24,125 @@ | |||
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | /* | 32 | /* | |
33 | * Autoconfiguration support for Sun4d "bootbus". | 33 | * Autoconfiguration support for Sun4d "bootbus". | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | __KERNEL_RCSID(0, "$NetBSD: bootbus.c,v 1.16 2008/04/28 20:23:35 martin Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: bootbus.c,v 1.17 2009/09/20 16:18:21 tsutsui Exp $"); | |
38 | 38 | |||
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/malloc.h> | 40 | #include <sys/malloc.h> | |
41 | #include <sys/systm.h> | 41 | #include <sys/systm.h> | |
42 | #include <sys/device.h> | 42 | #include <sys/device.h> | |
43 | 43 | |||
44 | #include <machine/autoconf.h> | 44 | #include <machine/autoconf.h> | |
45 | #include <machine/bus.h> | 45 | #include <machine/bus.h> | |
46 | 46 | |||
47 | #include <sparc/sparc/cpuunitvar.h> | 47 | #include <sparc/sparc/cpuunitvar.h> | |
48 | #include <sparc/dev/bootbusvar.h> | 48 | #include <sparc/dev/bootbusvar.h> | |
49 | 49 | |||
50 | #include "locators.h" | 50 | #include "locators.h" | |
51 | 51 | |||
52 | struct bootbus_softc { | 52 | struct bootbus_softc { | |
53 | struct device sc_dev; | 53 | struct device sc_dev; | |
54 | int sc_node; /* our OBP node */ | 54 | int sc_node; /* our OBP node */ | |
55 | 55 | |||
56 | bus_space_tag_t sc_st; /* ours */ | 56 | bus_space_tag_t sc_st; /* ours */ | |
57 | bus_space_tag_t sc_bustag; /* passed on to children */ | 57 | bus_space_tag_t sc_bustag; /* passed on to children */ | |
58 | }; | 58 | }; | |
59 | 59 | |||
60 | static int bootbus_match(struct device *, struct cfdata *, void *); | 60 | static int bootbus_match(device_t, cfdata_t, void *); | |
61 | static void bootbus_attach(struct device *, struct device *, void *); | 61 | static void bootbus_attach(device_t, device_t, void *); | |
62 | 62 | |||
63 | CFATTACH_DECL(bootbus, sizeof(struct bootbus_softc), | 63 | CFATTACH_DECL(bootbus, sizeof(struct bootbus_softc), | |
64 | bootbus_match, bootbus_attach, NULL, NULL); | 64 | bootbus_match, bootbus_attach, NULL, NULL); | |
65 | 65 | |||
66 | static int bootbus_submatch(struct device *, struct cfdata *, | 66 | static int bootbus_submatch(struct device *, struct cfdata *, | |
67 | const int *, void *); | 67 | const int *, void *); | |
68 | static int bootbus_print(void *, const char *); | 68 | static int bootbus_print(void *, const char *); | |
69 | 69 | |||
70 | static int bootbus_setup_attach_args(struct bootbus_softc *, bus_space_tag_t, | 70 | static int bootbus_setup_attach_args(struct bootbus_softc *, bus_space_tag_t, | |
71 | int, struct bootbus_attach_args *); | 71 | int, struct bootbus_attach_args *); | |
72 | static void bootbus_destroy_attach_args(struct bootbus_attach_args *); | 72 | static void bootbus_destroy_attach_args(struct bootbus_attach_args *); | |
73 | 73 | |||
74 | static int | 74 | static int | |
75 | bootbus_match(struct device *parent, struct cfdata *cf, void *aux) | 75 | bootbus_match(device_t parent, cfdata_t cf, void *aux) | |
76 | { | 76 | { | |
77 | struct cpuunit_attach_args *cpua = aux; | 77 | struct cpuunit_attach_args *cpua = aux; | |
78 | 78 | |||
79 | if (strcmp(cpua->cpua_name, cf->cf_name) == 0) | 79 | if (strcmp(cpua->cpua_name, cf->cf_name) == 0) | |
80 | return (1); | 80 | return (1); | |
81 | 81 | |||
82 | return (0); | 82 | return (0); | |
83 | } | 83 | } | |
84 | 84 | |||
85 | static void | 85 | static void | |
86 | bootbus_attach(struct device *parent, struct device *self, void *aux) | 86 | bootbus_attach(device_t parent, device_t self, void *aux) | |
87 | { | 87 | { | |
88 | struct bootbus_softc *sc = (void *) self; | 88 | struct bootbus_softc *sc = device_private(self); | |
89 | struct cpuunit_attach_args *cpua = aux; | 89 | struct cpuunit_attach_args *cpua = aux; | |
90 | int node, error; | 90 | int node, error; | |
91 | 91 | |||
92 | sc->sc_node = cpua->cpua_node; | 92 | sc->sc_node = cpua->cpua_node; | |
93 | sc->sc_st = cpua->cpua_bustag; | 93 | sc->sc_st = cpua->cpua_bustag; | |
94 | 94 | |||
95 | printf("\n"); | 95 | printf("\n"); | |
96 | 96 | |||
97 | /* | 97 | /* | |
98 | * Initialize the bus space tag we pass on to our children. | 98 | * Initialize the bus space tag we pass on to our children. | |
99 | */ | 99 | */ | |
100 | sc->sc_bustag = malloc(sizeof(*sc->sc_bustag), M_DEVBUF, | 100 | sc->sc_bustag = malloc(sizeof(*sc->sc_bustag), M_DEVBUF, | |
101 | M_WAITOK|M_ZERO); | 101 | M_WAITOK|M_ZERO); | |
102 | sc->sc_bustag->cookie = sc; | 102 | sc->sc_bustag->cookie = sc; | |
103 | sc->sc_bustag->parent = sc->sc_st; | 103 | sc->sc_bustag->parent = sc->sc_st; | |
104 | sc->sc_bustag->sparc_bus_map = sc->sc_st->sparc_bus_map; | 104 | sc->sc_bustag->sparc_bus_map = sc->sc_st->sparc_bus_map; | |
105 | sc->sc_bustag->sparc_bus_mmap = sc->sc_st->sparc_bus_mmap; | 105 | sc->sc_bustag->sparc_bus_mmap = sc->sc_st->sparc_bus_mmap; | |
106 | 106 | |||
107 | /* | 107 | /* | |
108 | * Collect address translations from the OBP. | 108 | * Collect address translations from the OBP. | |
109 | */ | 109 | */ | |
110 | error = prom_getprop(sc->sc_node, "ranges", | 110 | error = prom_getprop(sc->sc_node, "ranges", | |
111 | sizeof(struct openprom_range), &sc->sc_bustag->nranges, | 111 | sizeof(struct openprom_range), &sc->sc_bustag->nranges, | |
112 | &sc->sc_bustag->ranges); | 112 | &sc->sc_bustag->ranges); | |
113 | if (error) { | 113 | if (error) { | |
114 | printf("%s: error %d getting \"ranges\" property\n", | 114 | printf("%s: error %d getting \"ranges\" property\n", | |
115 | sc->sc_dev.dv_xname, error); | 115 | device_xname(self), error); | |
116 | panic("bootbus_attach"); | 116 | panic("bootbus_attach"); | |
117 | } | 117 | } | |
118 | 118 | |||
119 | /* Attach the CPU (and possibly bootbus) child nodes. */ | 119 | /* Attach the CPU (and possibly bootbus) child nodes. */ | |
120 | for (node = firstchild(sc->sc_node); node != 0; | 120 | for (node = firstchild(sc->sc_node); node != 0; | |
121 | node = nextsibling(node)) { | 121 | node = nextsibling(node)) { | |
122 | struct bootbus_attach_args baa; | 122 | struct bootbus_attach_args baa; | |
123 | 123 | |||
124 | if (bootbus_setup_attach_args(sc, sc->sc_bustag, node, &baa)) | 124 | if (bootbus_setup_attach_args(sc, sc->sc_bustag, node, &baa)) | |
125 | panic("bootbus_attach: failed to set up attach args"); | 125 | panic("bootbus_attach: failed to set up attach args"); | |
126 | 126 | |||
127 | (void) config_found_sm_loc(&sc->sc_dev, "bootbus", NULL, &baa, | 127 | (void) config_found_sm_loc(self, "bootbus", NULL, &baa, | |
128 | bootbus_print, bootbus_submatch); | 128 | bootbus_print, bootbus_submatch); | |
129 | 129 | |||
130 | bootbus_destroy_attach_args(&baa); | 130 | bootbus_destroy_attach_args(&baa); | |
131 | } | 131 | } | |
132 | } | 132 | } | |
133 | 133 | |||
134 | static int | 134 | static int | |
135 | bootbus_submatch(struct device *parent, struct cfdata *cf, | 135 | bootbus_submatch(device_t parent, cfdata_t cf, const int *ldesc, void *aux) | |
136 | const int *ldesc, void *aux) | |||
137 | { | 136 | { | |
138 | struct bootbus_attach_args *baa = aux; | 137 | struct bootbus_attach_args *baa = aux; | |
139 | 138 | |||
140 | if (cf->cf_loc[BOOTBUSCF_SLOT] != BOOTBUSCF_SLOT_DEFAULT && | 139 | if (cf->cf_loc[BOOTBUSCF_SLOT] != BOOTBUSCF_SLOT_DEFAULT && | |
141 | cf->cf_loc[BOOTBUSCF_SLOT] != baa->ba_slot) | 140 | cf->cf_loc[BOOTBUSCF_SLOT] != baa->ba_slot) | |
142 | return (0); | 141 | return (0); | |
143 | 142 | |||
144 | if (cf->cf_loc[BOOTBUSCF_OFFSET] != BOOTBUSCF_OFFSET_DEFAULT && | 143 | if (cf->cf_loc[BOOTBUSCF_OFFSET] != BOOTBUSCF_OFFSET_DEFAULT && | |
145 | cf->cf_loc[BOOTBUSCF_OFFSET] != baa->ba_offset) | 144 | cf->cf_loc[BOOTBUSCF_OFFSET] != baa->ba_offset) | |
146 | return (0); | 145 | return (0); | |
147 | 146 | |||
148 | return (config_match(parent, cf, aux)); | 147 | return (config_match(parent, cf, aux)); | |
149 | } | 148 | } |
--- src/sys/arch/sparc/dev/ebus.c 2008/05/29 14:51:26 1.30
+++ src/sys/arch/sparc/dev/ebus.c 2009/09/20 16:18:21 1.31
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ebus.c,v 1.30 2008/05/29 14:51:26 mrg Exp $ */ | 1 | /* $NetBSD: ebus.c,v 1.31 2009/09/20 16:18:21 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1999, 2000 Matthew R. Green | 4 | * Copyright (c) 1999, 2000 Matthew R. Green | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -22,27 +22,27 @@ | @@ -22,27 +22,27 @@ | |||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | 22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED | |
23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 24 | * 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 | 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
26 | * SUCH DAMAGE. | 26 | * SUCH DAMAGE. | |
27 | */ | 27 | */ | |
28 | 28 | |||
29 | /* | 29 | /* | |
30 | * EBus support for PCI based SPARC systems (ms-IIep, Ultra). | 30 | * EBus support for PCI based SPARC systems (ms-IIep, Ultra). | |
31 | * EBus is documented in PCIO manual (Sun Part#: 802-7837-01). | 31 | * EBus is documented in PCIO manual (Sun Part#: 802-7837-01). | |
32 | */ | 32 | */ | |
33 | 33 | |||
34 | #include <sys/cdefs.h> | 34 | #include <sys/cdefs.h> | |
35 | __KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.30 2008/05/29 14:51:26 mrg Exp $"); | 35 | __KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.31 2009/09/20 16:18:21 tsutsui Exp $"); | |
36 | 36 | |||
37 | #if defined(DEBUG) && !defined(EBUS_DEBUG) | 37 | #if defined(DEBUG) && !defined(EBUS_DEBUG) | |
38 | #define EBUS_DEBUG | 38 | #define EBUS_DEBUG | |
39 | #endif | 39 | #endif | |
40 | 40 | |||
41 | #ifdef EBUS_DEBUG | 41 | #ifdef EBUS_DEBUG | |
42 | #define EDB_PROM 0x01 | 42 | #define EDB_PROM 0x01 | |
43 | #define EDB_CHILD 0x02 | 43 | #define EDB_CHILD 0x02 | |
44 | #define EDB_INTRMAP 0x04 | 44 | #define EDB_INTRMAP 0x04 | |
45 | #define EDB_BUSMAP 0x08 | 45 | #define EDB_BUSMAP 0x08 | |
46 | #define EDB_BUSDMA 0x10 | 46 | #define EDB_BUSDMA 0x10 | |
47 | #define EDB_INTR 0x20 | 47 | #define EDB_INTR 0x20 | |
48 | int ebus_debug = 0; | 48 | int ebus_debug = 0; | |
@@ -73,42 +73,42 @@ int ebus_debug = 0; | @@ -73,42 +73,42 @@ int ebus_debug = 0; | |||
73 | #include <dev/ebus/ebusvar.h> | 73 | #include <dev/ebus/ebusvar.h> | |
74 | 74 | |||
75 | #include "opt_blink.h" | 75 | #include "opt_blink.h" | |
76 | 76 | |||
77 | volatile uint32_t *ebus_LED = NULL; | 77 | volatile uint32_t *ebus_LED = NULL; | |
78 | 78 | |||
79 | #ifdef BLINK | 79 | #ifdef BLINK | |
80 | static callout_t ebus_blink_ch; | 80 | static callout_t ebus_blink_ch; | |
81 | static void ebus_blink(void *); | 81 | static void ebus_blink(void *); | |
82 | #endif | 82 | #endif | |
83 | 83 | |||
84 | struct ebus_softc { | 84 | struct ebus_softc { | |
85 | struct device sc_dev; | 85 | struct device sc_dev; | |
86 | struct device *sc_parent; /* PCI bus */ | 86 | device_t sc_parent; /* PCI bus */ | |
87 | 87 | |||
88 | int sc_node; /* PROM node */ | 88 | int sc_node; /* PROM node */ | |
89 | 89 | |||
90 | bus_space_tag_t sc_bustag; /* mem tag from pci */ | 90 | bus_space_tag_t sc_bustag; /* mem tag from pci */ | |
91 | 91 | |||
92 | /* | 92 | /* | |
93 | * "reg" contains exactly the info we'd get by processing | 93 | * "reg" contains exactly the info we'd get by processing | |
94 | * "ranges", so don't bother with "ranges" and use "reg" directly. | 94 | * "ranges", so don't bother with "ranges" and use "reg" directly. | |
95 | */ | 95 | */ | |
96 | struct ofw_pci_register *sc_reg; | 96 | struct ofw_pci_register *sc_reg; | |
97 | int sc_nreg; | 97 | int sc_nreg; | |
98 | }; | 98 | }; | |
99 | 99 | |||
100 | static int ebus_match(struct device *, struct cfdata *, void *); | 100 | static int ebus_match(device_t, cfdata_t, void *); | |
101 | static void ebus_attach(struct device *, struct device *, void *); | 101 | static void ebus_attach(device_t, device_t, void *); | |
102 | 102 | |||
103 | CFATTACH_DECL(ebus, sizeof(struct ebus_softc), | 103 | CFATTACH_DECL(ebus, sizeof(struct ebus_softc), | |
104 | ebus_match, ebus_attach, NULL, NULL); | 104 | ebus_match, ebus_attach, NULL, NULL); | |
105 | 105 | |||
106 | static int ebus_setup_attach_args(struct ebus_softc *, bus_space_tag_t, | 106 | static int ebus_setup_attach_args(struct ebus_softc *, bus_space_tag_t, | |
107 | bus_dma_tag_t, int, struct ebus_attach_args *); | 107 | bus_dma_tag_t, int, struct ebus_attach_args *); | |
108 | static void ebus_destroy_attach_args(struct ebus_attach_args *); | 108 | static void ebus_destroy_attach_args(struct ebus_attach_args *); | |
109 | static int ebus_print(void *, const char *); | 109 | static int ebus_print(void *, const char *); | |
110 | 110 | |||
111 | /* | 111 | /* | |
112 | * here are our bus space and bus DMA routines. | 112 | * here are our bus space and bus DMA routines. | |
113 | */ | 113 | */ | |
114 | static paddr_t ebus_bus_mmap(bus_space_tag_t, bus_addr_t, off_t, int, int); | 114 | static paddr_t ebus_bus_mmap(bus_space_tag_t, bus_addr_t, off_t, int, int); | |
@@ -171,27 +171,27 @@ static const struct msiiep_known_ebus_wi | @@ -171,27 +171,27 @@ static const struct msiiep_known_ebus_wi | |||
171 | * XXX: This assumes single EBus. However I don't think any ms-IIep | 171 | * XXX: This assumes single EBus. However I don't think any ms-IIep | |
172 | * system ever used more than one. In any case, without looking at a | 172 | * system ever used more than one. In any case, without looking at a | |
173 | * system with multiple PCIO chips I don't know how to correctly | 173 | * system with multiple PCIO chips I don't know how to correctly | |
174 | * program the driver to handle PROM glitches in them, so for the time | 174 | * program the driver to handle PROM glitches in them, so for the time | |
175 | * being just use globals. | 175 | * being just use globals. | |
176 | */ | 176 | */ | |
177 | static const struct msiiep_ebus_intr_wiring *wiring_map; | 177 | static const struct msiiep_ebus_intr_wiring *wiring_map; | |
178 | static int wiring_map_size; | 178 | static int wiring_map_size; | |
179 | 179 | |||
180 | static int ebus_init_wiring_table(struct ebus_softc *); | 180 | static int ebus_init_wiring_table(struct ebus_softc *); | |
181 | 181 | |||
182 | 182 | |||
183 | static int | 183 | static int | |
184 | ebus_match(struct device *parent, struct cfdata *match, void *aux) | 184 | ebus_match(device_t parent, cfdata_t cf, void *aux) | |
185 | { | 185 | { | |
186 | struct pci_attach_args *pa = aux; | 186 | struct pci_attach_args *pa = aux; | |
187 | char name[10]; | 187 | char name[10]; | |
188 | int node; | 188 | int node; | |
189 | 189 | |||
190 | /* Only attach if there's a PROM node. */ | 190 | /* Only attach if there's a PROM node. */ | |
191 | node = PCITAG_NODE(pa->pa_tag); | 191 | node = PCITAG_NODE(pa->pa_tag); | |
192 | if (node == -1) | 192 | if (node == -1) | |
193 | return (0); | 193 | return (0); | |
194 | 194 | |||
195 | prom_getpropstringA(node, "name", name, sizeof name); | 195 | prom_getpropstringA(node, "name", name, sizeof name); | |
196 | if (PCI_CLASS(pa->pa_class) == PCI_CLASS_BRIDGE | 196 | if (PCI_CLASS(pa->pa_class) == PCI_CLASS_BRIDGE | |
197 | && PCI_VENDOR(pa->pa_id) == PCI_VENDOR_SUN | 197 | && PCI_VENDOR(pa->pa_id) == PCI_VENDOR_SUN | |
@@ -202,75 +202,75 @@ ebus_match(struct device *parent, struct | @@ -202,75 +202,75 @@ ebus_match(struct device *parent, struct | |||
202 | return (0); | 202 | return (0); | |
203 | } | 203 | } | |
204 | 204 | |||
205 | 205 | |||
206 | static int | 206 | static int | |
207 | ebus_init_wiring_table(struct ebus_softc *sc) | 207 | ebus_init_wiring_table(struct ebus_softc *sc) | |
208 | { | 208 | { | |
209 | const struct msiiep_known_ebus_wiring *p; | 209 | const struct msiiep_known_ebus_wiring *p; | |
210 | char buf[32]; | 210 | char buf[32]; | |
211 | char *model; | 211 | char *model; | |
212 | 212 | |||
213 | if (wiring_map != NULL) { | 213 | if (wiring_map != NULL) { | |
214 | printf("%s: global ebus wiring map already initalized\n", | 214 | printf("%s: global ebus wiring map already initalized\n", | |
215 | sc->sc_dev.dv_xname); | 215 | device_xname(&sc->sc_dev)); | |
216 | return (0); | 216 | return (0); | |
217 | } | 217 | } | |
218 | 218 | |||
219 | model = prom_getpropstringA(prom_findroot(), "model", | 219 | model = prom_getpropstringA(prom_findroot(), "model", | |
220 | buf, sizeof(buf)); | 220 | buf, sizeof(buf)); | |
221 | if (model == NULL) | 221 | if (model == NULL) | |
222 | panic("ebus_init_wiring_table: no \"model\" property"); | 222 | panic("ebus_init_wiring_table: no \"model\" property"); | |
223 | 223 | |||
224 | for (p = known_models; p->model != NULL; ++p) | 224 | for (p = known_models; p->model != NULL; ++p) | |
225 | if (strcmp(model, p->model) == 0) { | 225 | if (strcmp(model, p->model) == 0) { | |
226 | wiring_map = p->map; | 226 | wiring_map = p->map; | |
227 | wiring_map_size = p->mapsize; | 227 | wiring_map_size = p->mapsize; | |
228 | return (1); | 228 | return (1); | |
229 | } | 229 | } | |
230 | 230 | |||
231 | /* not found? we should have failed in pci_attach_hook then. */ | 231 | /* not found? we should have failed in pci_attach_hook then. */ | |
232 | panic("ebus_init_wiring_table: unknown model %s", model); | 232 | panic("ebus_init_wiring_table: unknown model %s", model); | |
233 | } | 233 | } | |
234 | 234 | |||
235 | 235 | |||
236 | /* | 236 | /* | |
237 | * attach an ebus and all it's children. this code is modeled | 237 | * attach an ebus and all it's children. this code is modeled | |
238 | * after the sbus code which does similar things. | 238 | * after the sbus code which does similar things. | |
239 | */ | 239 | */ | |
240 | static void | 240 | static void | |
241 | ebus_attach(struct device *parent, struct device *self, void *aux) | 241 | ebus_attach(device_t parent, device_t self, void *aux) | |
242 | { | 242 | { | |
243 | struct ebus_softc *sc = (struct ebus_softc *)self; | 243 | struct ebus_softc *sc = device_private(self); | |
244 | struct pci_attach_args *pa = aux; | 244 | struct pci_attach_args *pa = aux; | |
245 | struct ebus_attach_args ea; | 245 | struct ebus_attach_args ea; | |
246 | bus_space_tag_t sbt; | 246 | bus_space_tag_t sbt; | |
247 | bus_dma_tag_t dmatag; | 247 | bus_dma_tag_t dmatag; | |
248 | bus_space_handle_t hLED; | 248 | bus_space_handle_t hLED; | |
249 | pcireg_t base14; | 249 | pcireg_t base14; | |
250 | int node, error; | 250 | int node, error; | |
251 | char devinfo[256]; | 251 | char devinfo[256]; | |
252 | 252 | |||
253 | #ifdef BLINK | 253 | #ifdef BLINK | |
254 | callout_init(&ebus_blink_ch, 0); | 254 | callout_init(&ebus_blink_ch, 0); | |
255 | #endif | 255 | #endif | |
256 | 256 | |||
257 | pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo)); | 257 | pci_devinfo(pa->pa_id, pa->pa_class, 0, devinfo, sizeof(devinfo)); | |
258 | printf(": %s, revision 0x%02x\n", | 258 | printf(": %s, revision 0x%02x\n", | |
259 | devinfo, PCI_REVISION(pa->pa_class)); | 259 | devinfo, PCI_REVISION(pa->pa_class)); | |
260 | 260 | |||
261 | node = PCITAG_NODE(pa->pa_tag); | 261 | node = PCITAG_NODE(pa->pa_tag); | |
262 | if (node == -1) | 262 | if (node == -1) | |
263 | panic("%s: unable to find ebus node", self->dv_xname); | 263 | panic("%s: unable to find ebus node", device_xname(self)); | |
264 | 264 | |||
265 | if (ebus_init_wiring_table(sc) == 0) | 265 | if (ebus_init_wiring_table(sc) == 0) | |
266 | return; | 266 | return; | |
267 | 267 | |||
268 | /* map the LED register */ | 268 | /* map the LED register */ | |
269 | base14 = pci_conf_read(pa->pa_pc, pa->pa_tag, 0x14); | 269 | base14 = pci_conf_read(pa->pa_pc, pa->pa_tag, 0x14); | |
270 | if (bus_space_map(pa->pa_memt, base14 + 0x726000, 4, 0, &hLED) == 0) { | 270 | if (bus_space_map(pa->pa_memt, base14 + 0x726000, 4, 0, &hLED) == 0) { | |
271 | ebus_LED = bus_space_vaddr(pa->pa_memt, hLED); | 271 | ebus_LED = bus_space_vaddr(pa->pa_memt, hLED); | |
272 | #ifdef BLINK | 272 | #ifdef BLINK | |
273 | ebus_blink((void *)0); | 273 | ebus_blink((void *)0); | |
274 | #endif | 274 | #endif | |
275 | } else { | 275 | } else { | |
276 | printf("unable to map the LED register\n"); | 276 | printf("unable to map the LED register\n"); | |
@@ -288,27 +288,27 @@ ebus_attach(struct device *parent, struc | @@ -288,27 +288,27 @@ ebus_attach(struct device *parent, struc | |||
288 | sbt->sparc_intr_establish = ebus_intr_establish; | 288 | sbt->sparc_intr_establish = ebus_intr_establish; | |
289 | 289 | |||
290 | dmatag = ebus_alloc_dma_tag(sc, pa->pa_dmat); | 290 | dmatag = ebus_alloc_dma_tag(sc, pa->pa_dmat); | |
291 | 291 | |||
292 | /* | 292 | /* | |
293 | * Setup ranges. The interesting thing is that we use "reg" | 293 | * Setup ranges. The interesting thing is that we use "reg" | |
294 | * not "ranges", since "reg" on ebus has exactly the data we'd | 294 | * not "ranges", since "reg" on ebus has exactly the data we'd | |
295 | * get by processing "ranges". | 295 | * get by processing "ranges". | |
296 | */ | 296 | */ | |
297 | error = prom_getprop(node, "reg", sizeof(struct ofw_pci_register), | 297 | error = prom_getprop(node, "reg", sizeof(struct ofw_pci_register), | |
298 | &sc->sc_nreg, &sc->sc_reg); | 298 | &sc->sc_nreg, &sc->sc_reg); | |
299 | if (error) | 299 | if (error) | |
300 | panic("%s: unable to read ebus registers (error %d)", | 300 | panic("%s: unable to read ebus registers (error %d)", | |
301 | self->dv_xname, error); | 301 | device_xname(self), error); | |
302 | 302 | |||
303 | /* | 303 | /* | |
304 | * now attach all our children | 304 | * now attach all our children | |
305 | */ | 305 | */ | |
306 | DPRINTF(EDB_CHILD, ("ebus node %08x, searching children...\n", node)); | 306 | DPRINTF(EDB_CHILD, ("ebus node %08x, searching children...\n", node)); | |
307 | for (node = firstchild(node); node; node = nextsibling(node)) { | 307 | for (node = firstchild(node); node; node = nextsibling(node)) { | |
308 | char *name = prom_getpropstring(node, "name"); | 308 | char *name = prom_getpropstring(node, "name"); | |
309 | 309 | |||
310 | if (ebus_setup_attach_args(sc, sbt, dmatag, node, &ea) != 0) { | 310 | if (ebus_setup_attach_args(sc, sbt, dmatag, node, &ea) != 0) { | |
311 | printf("ebus_attach: %s: incomplete\n", name); | 311 | printf("ebus_attach: %s: incomplete\n", name); | |
312 | continue; | 312 | continue; | |
313 | } | 313 | } | |
314 | DPRINTF(EDB_CHILD, | 314 | DPRINTF(EDB_CHILD, |
--- src/sys/arch/sparc/dev/if_ie_obio.c 2008/04/28 20:23:35 1.36
+++ src/sys/arch/sparc/dev/if_ie_obio.c 2009/09/20 16:18:21 1.37
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: if_ie_obio.c,v 1.36 2008/04/28 20:23:35 martin Exp $ */ | 1 | /* $NetBSD: if_ie_obio.c,v 1.37 2009/09/20 16:18:21 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Paul Kranenburg. | 8 | * by Paul Kranenburg. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -68,27 +68,27 @@ | @@ -68,27 +68,27 @@ | |||
68 | * October 1994, January 1995. | 68 | * October 1994, January 1995. | |
69 | */ | 69 | */ | |
70 | 70 | |||
71 | /* | 71 | /* | |
72 | * The i82586 is a very painful chip, found in sun3's, sun-4/100's | 72 | * The i82586 is a very painful chip, found in sun3's, sun-4/100's | |
73 | * sun-4/200's, and VME based suns. The byte order is all wrong for a | 73 | * sun-4/200's, and VME based suns. The byte order is all wrong for a | |
74 | * SUN, making life difficult. Programming this chip is mostly the same, | 74 | * SUN, making life difficult. Programming this chip is mostly the same, | |
75 | * but certain details differ from system to system. This driver is | 75 | * but certain details differ from system to system. This driver is | |
76 | * written so that different "ie" interfaces can be controled by the same | 76 | * written so that different "ie" interfaces can be controled by the same | |
77 | * driver. | 77 | * driver. | |
78 | */ | 78 | */ | |
79 | 79 | |||
80 | #include <sys/cdefs.h> | 80 | #include <sys/cdefs.h> | |
81 | __KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.36 2008/04/28 20:23:35 martin Exp $"); | 81 | __KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.37 2009/09/20 16:18:21 tsutsui Exp $"); | |
82 | 82 | |||
83 | #include <sys/param.h> | 83 | #include <sys/param.h> | |
84 | #include <sys/systm.h> | 84 | #include <sys/systm.h> | |
85 | #include <sys/errno.h> | 85 | #include <sys/errno.h> | |
86 | #include <sys/device.h> | 86 | #include <sys/device.h> | |
87 | #include <sys/malloc.h> | 87 | #include <sys/malloc.h> | |
88 | #include <sys/protosw.h> | 88 | #include <sys/protosw.h> | |
89 | #include <sys/socket.h> | 89 | #include <sys/socket.h> | |
90 | 90 | |||
91 | #include <net/if.h> | 91 | #include <net/if.h> | |
92 | #include <net/if_types.h> | 92 | #include <net/if_types.h> | |
93 | #include <net/if_dl.h> | 93 | #include <net/if_dl.h> | |
94 | #include <net/if_media.h> | 94 | #include <net/if_media.h> | |
@@ -115,28 +115,28 @@ struct ieob { | @@ -115,28 +115,28 @@ struct ieob { | |||
115 | #define IEOB_IENAB 0x10 /* interrupt enable */ | 115 | #define IEOB_IENAB 0x10 /* interrupt enable */ | |
116 | #define IEOB_XXXXX 0x08 /* free bit */ | 116 | #define IEOB_XXXXX 0x08 /* free bit */ | |
117 | #define IEOB_XCVRL2 0x04 /* level 2 transceiver? */ | 117 | #define IEOB_XCVRL2 0x04 /* level 2 transceiver? */ | |
118 | #define IEOB_BUSERR 0x02 /* bus error */ | 118 | #define IEOB_BUSERR 0x02 /* bus error */ | |
119 | #define IEOB_INT 0x01 /* interrupt */ | 119 | #define IEOB_INT 0x01 /* interrupt */ | |
120 | 120 | |||
121 | #define IEOB_ADBASE 0xff000000 /* KVA base addr of 24 bit address space */ | 121 | #define IEOB_ADBASE 0xff000000 /* KVA base addr of 24 bit address space */ | |
122 | 122 | |||
123 | 123 | |||
124 | static void ie_obreset(struct ie_softc *, int); | 124 | static void ie_obreset(struct ie_softc *, int); | |
125 | static void ie_obattend(struct ie_softc *, int); | 125 | static void ie_obattend(struct ie_softc *, int); | |
126 | static void ie_obrun(struct ie_softc *); | 126 | static void ie_obrun(struct ie_softc *); | |
127 | 127 | |||
128 | int ie_obio_match(struct device *, struct cfdata *, void *); | 128 | int ie_obio_match(device_t, cfdata_t, void *); | |
129 | void ie_obio_attach(struct device *, struct device *, void *); | 129 | void ie_obio_attach(device_t, device_t, void *); | |
130 | 130 | |||
131 | CFATTACH_DECL(ie_obio, sizeof(struct ie_softc), | 131 | CFATTACH_DECL(ie_obio, sizeof(struct ie_softc), | |
132 | ie_obio_match, ie_obio_attach, NULL, NULL); | 132 | ie_obio_match, ie_obio_attach, NULL, NULL); | |
133 | 133 | |||
134 | /* Supported media */ | 134 | /* Supported media */ | |
135 | static int media[] = { | 135 | static int media[] = { | |
136 | IFM_ETHER | IFM_10_2, | 136 | IFM_ETHER | IFM_10_2, | |
137 | }; | 137 | }; | |
138 | #define NMEDIA (sizeof(media) / sizeof(media[0])) | 138 | #define NMEDIA (sizeof(media) / sizeof(media[0])) | |
139 | 139 | |||
140 | 140 | |||
141 | /* | 141 | /* | |
142 | * OBIO ie support routines | 142 | * OBIO ie support routines | |
@@ -221,48 +221,48 @@ ie_obio_write24(struct ie_softc *sc, int | @@ -221,48 +221,48 @@ ie_obio_write24(struct ie_softc *sc, int | |||
221 | uint16_t v0, v1; | 221 | uint16_t v0, v1; | |
222 | u_char *t; | 222 | u_char *t; | |
223 | 223 | |||
224 | t = (u_char *)&v0; | 224 | t = (u_char *)&v0; | |
225 | t[0] = f[3]; t[1] = f[2]; | 225 | t[0] = f[3]; t[1] = f[2]; | |
226 | bus_space_write_2(sc->bt, sc->bh, offset, v0); | 226 | bus_space_write_2(sc->bt, sc->bh, offset, v0); | |
227 | 227 | |||
228 | t = (u_char *)&v1; | 228 | t = (u_char *)&v1; | |
229 | t[0] = f[1]; t[1] = 0; | 229 | t[0] = f[1]; t[1] = 0; | |
230 | bus_space_write_2(sc->bt, sc->bh, offset+2, v1); | 230 | bus_space_write_2(sc->bt, sc->bh, offset+2, v1); | |
231 | } | 231 | } | |
232 | 232 | |||
233 | int | 233 | int | |
234 | ie_obio_match(struct device *parent, struct cfdata *cf, void *aux) | 234 | ie_obio_match(device_t parent, cfdata_t cf, void *aux) | |
235 | { | 235 | { | |
236 | union obio_attach_args *uoba = aux; | 236 | union obio_attach_args *uoba = aux; | |
237 | struct obio4_attach_args *oba; | 237 | struct obio4_attach_args *oba; | |
238 | 238 | |||
239 | if (uoba->uoba_isobio4 == 0) | 239 | if (uoba->uoba_isobio4 == 0) | |
240 | return (0); | 240 | return (0); | |
241 | 241 | |||
242 | oba = &uoba->uoba_oba4; | 242 | oba = &uoba->uoba_oba4; | |
243 | return (bus_space_probe(oba->oba_bustag, oba->oba_paddr, | 243 | return (bus_space_probe(oba->oba_bustag, oba->oba_paddr, | |
244 | 1, /* probe size */ | 244 | 1, /* probe size */ | |
245 | 0, /* offset */ | 245 | 0, /* offset */ | |
246 | 0, /* flags */ | 246 | 0, /* flags */ | |
247 | NULL, NULL)); | 247 | NULL, NULL)); | |
248 | } | 248 | } | |
249 | 249 | |||
250 | void | 250 | void | |
251 | ie_obio_attach(struct device *parent, struct device *self, void *aux) | 251 | ie_obio_attach(device_t parent, device_t self, void *aux) | |
252 | { | 252 | { | |
253 | union obio_attach_args *uoba = aux; | 253 | union obio_attach_args *uoba = aux; | |
254 | struct obio4_attach_args *oba = &uoba->uoba_oba4; | 254 | struct obio4_attach_args *oba = &uoba->uoba_oba4; | |
255 | struct ie_softc *sc = (void *) self; | 255 | struct ie_softc *sc = device_private(self); | |
256 | bus_dma_tag_t dmatag = oba->oba_dmatag; | 256 | bus_dma_tag_t dmatag = oba->oba_dmatag; | |
257 | bus_space_handle_t bh; | 257 | bus_space_handle_t bh; | |
258 | bus_dma_segment_t seg; | 258 | bus_dma_segment_t seg; | |
259 | int rseg; | 259 | int rseg; | |
260 | int error; | 260 | int error; | |
261 | paddr_t pa; | 261 | paddr_t pa; | |
262 | struct intrhand *ih; | 262 | struct intrhand *ih; | |
263 | bus_size_t memsize; | 263 | bus_size_t memsize; | |
264 | u_long iebase; | 264 | u_long iebase; | |
265 | uint8_t myaddr[ETHER_ADDR_LEN]; | 265 | uint8_t myaddr[ETHER_ADDR_LEN]; | |
266 | 266 | |||
267 | sc->bt = oba->oba_bustag; | 267 | sc->bt = oba->oba_bustag; | |
268 | 268 | |||
@@ -272,65 +272,65 @@ ie_obio_attach(struct device *parent, st | @@ -272,65 +272,65 @@ ie_obio_attach(struct device *parent, st | |||
272 | sc->memcopyout = ie_obio_memcopyout; | 272 | sc->memcopyout = ie_obio_memcopyout; | |
273 | sc->memcopyin = ie_obio_memcopyin; | 273 | sc->memcopyin = ie_obio_memcopyin; | |
274 | 274 | |||
275 | sc->ie_bus_barrier = NULL; | 275 | sc->ie_bus_barrier = NULL; | |
276 | sc->ie_bus_read16 = ie_obio_read16; | 276 | sc->ie_bus_read16 = ie_obio_read16; | |
277 | sc->ie_bus_write16 = ie_obio_write16; | 277 | sc->ie_bus_write16 = ie_obio_write16; | |
278 | sc->ie_bus_write24 = ie_obio_write24; | 278 | sc->ie_bus_write24 = ie_obio_write24; | |
279 | sc->sc_msize = memsize = 65536; /* XXX */ | 279 | sc->sc_msize = memsize = 65536; /* XXX */ | |
280 | 280 | |||
281 | if (bus_space_map(oba->oba_bustag, oba->oba_paddr, | 281 | if (bus_space_map(oba->oba_bustag, oba->oba_paddr, | |
282 | sizeof(struct ieob), | 282 | sizeof(struct ieob), | |
283 | BUS_SPACE_MAP_LINEAR, | 283 | BUS_SPACE_MAP_LINEAR, | |
284 | &bh) != 0) { | 284 | &bh) != 0) { | |
285 | printf("%s: cannot map registers\n", self->dv_xname); | 285 | printf("%s: cannot map registers\n", device_xname(self)); | |
286 | return; | 286 | return; | |
287 | } | 287 | } | |
288 | sc->sc_reg = (void *)bh; | 288 | sc->sc_reg = (void *)bh; | |
289 | 289 | |||
290 | /* | 290 | /* | |
291 | * Allocate control & buffer memory. | 291 | * Allocate control & buffer memory. | |
292 | */ | 292 | */ | |
293 | if ((error = bus_dmamap_create(dmatag, memsize, 1, memsize, 0, | 293 | if ((error = bus_dmamap_create(dmatag, memsize, 1, memsize, 0, | |
294 | BUS_DMA_NOWAIT|BUS_DMA_24BIT, | 294 | BUS_DMA_NOWAIT|BUS_DMA_24BIT, | |
295 | &sc->sc_dmamap)) != 0) { | 295 | &sc->sc_dmamap)) != 0) { | |
296 | printf("%s: DMA map create error %d\n", | 296 | printf("%s: DMA map create error %d\n", | |
297 | sc->sc_dev.dv_xname, error); | 297 | device_xname(self), error); | |
298 | return; | 298 | return; | |
299 | } | 299 | } | |
300 | if ((error = bus_dmamem_alloc(dmatag, memsize, 64*1024, 0, | 300 | if ((error = bus_dmamem_alloc(dmatag, memsize, 64*1024, 0, | |
301 | &seg, 1, &rseg, | 301 | &seg, 1, &rseg, | |
302 | BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) { | 302 | BUS_DMA_NOWAIT | BUS_DMA_24BIT)) != 0) { | |
303 | printf("%s: DMA memory allocation error %d\n", | 303 | printf("%s: DMA memory allocation error %d\n", | |
304 | self->dv_xname, error); | 304 | device_xname(self), error); | |
305 | return; | 305 | return; | |
306 | } | 306 | } | |
307 | 307 | |||
308 | /* Map DMA buffer in CPU addressable space */ | 308 | /* Map DMA buffer in CPU addressable space */ | |
309 | if ((error = bus_dmamem_map(dmatag, &seg, rseg, memsize, | 309 | if ((error = bus_dmamem_map(dmatag, &seg, rseg, memsize, | |
310 | (void **)&sc->sc_maddr, | 310 | (void **)&sc->sc_maddr, | |
311 | BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) { | 311 | BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) != 0) { | |
312 | printf("%s: DMA buffer map error %d\n", | 312 | printf("%s: DMA buffer map error %d\n", | |
313 | sc->sc_dev.dv_xname, error); | 313 | device_xname(self), error); | |
314 | bus_dmamem_free(dmatag, &seg, rseg); | 314 | bus_dmamem_free(dmatag, &seg, rseg); | |
315 | return; | 315 | return; | |
316 | } | 316 | } | |
317 | 317 | |||
318 | /* Load the segment */ | 318 | /* Load the segment */ | |
319 | if ((error = bus_dmamap_load(dmatag, sc->sc_dmamap, | 319 | if ((error = bus_dmamap_load(dmatag, sc->sc_dmamap, | |
320 | sc->sc_maddr, memsize, NULL, | 320 | sc->sc_maddr, memsize, NULL, | |
321 | BUS_DMA_NOWAIT)) != 0) { | 321 | BUS_DMA_NOWAIT)) != 0) { | |
322 | printf("%s: DMA buffer map load error %d\n", | 322 | printf("%s: DMA buffer map load error %d\n", | |
323 | sc->sc_dev.dv_xname, error); | 323 | device_xname(self), error); | |
324 | bus_dmamem_unmap(dmatag, sc->sc_maddr, memsize); | 324 | bus_dmamem_unmap(dmatag, sc->sc_maddr, memsize); | |
325 | bus_dmamem_free(dmatag, &seg, rseg); | 325 | bus_dmamem_free(dmatag, &seg, rseg); | |
326 | return; | 326 | return; | |
327 | } | 327 | } | |
328 | 328 | |||
329 | wzero(sc->sc_maddr, memsize); | 329 | wzero(sc->sc_maddr, memsize); | |
330 | sc->bh = (bus_space_handle_t)(sc->sc_maddr); | 330 | sc->bh = (bus_space_handle_t)(sc->sc_maddr); | |
331 | 331 | |||
332 | /* | 332 | /* | |
333 | * The i82586's 24-bit address space maps to the last 16MB of | 333 | * The i82586's 24-bit address space maps to the last 16MB of | |
334 | * KVA space (). In addition, the SCP must appear | 334 | * KVA space (). In addition, the SCP must appear | |
335 | * at IE_SCP_ADDR within the 24-bit address space, | 335 | * at IE_SCP_ADDR within the 24-bit address space, | |
336 | * i.e. at KVA IEOB_ADBASE+IE_SCP_ADDR, at the very top of | 336 | * i.e. at KVA IEOB_ADBASE+IE_SCP_ADDR, at the very top of |
--- src/sys/arch/sparc/dev/rtc.c 2006/09/04 23:45:30 1.14
+++ src/sys/arch/sparc/dev/rtc.c 2009/09/20 16:18:21 1.15
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: rtc.c,v 1.14 2006/09/04 23:45:30 gdamore Exp $ */ | 1 | /* $NetBSD: rtc.c,v 1.15 2009/09/20 16:18:21 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001 Valeriy E. Ushakov | 4 | * Copyright (c) 2001 Valeriy E. Ushakov | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -24,55 +24,55 @@ | @@ -24,55 +24,55 @@ | |||
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | /* | 30 | /* | |
31 | * `rtc' is a DS1287A (== MC146818A) time-of-day clock at EBus. | 31 | * `rtc' is a DS1287A (== MC146818A) time-of-day clock at EBus. | |
32 | * In Krups it's not used to store idprom so this driver doesn't | 32 | * In Krups it's not used to store idprom so this driver doesn't | |
33 | * support it. Don't know about other ms-IIep systems. | 33 | * support it. Don't know about other ms-IIep systems. | |
34 | */ | 34 | */ | |
35 | 35 | |||
36 | #include <sys/cdefs.h> | 36 | #include <sys/cdefs.h> | |
37 | __KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.14 2006/09/04 23:45:30 gdamore Exp $"); | 37 | __KERNEL_RCSID(0, "$NetBSD: rtc.c,v 1.15 2009/09/20 16:18:21 tsutsui Exp $"); | |
38 | 38 | |||
39 | #include <sys/param.h> | 39 | #include <sys/param.h> | |
40 | #include <sys/kernel.h> | 40 | #include <sys/kernel.h> | |
41 | #include <sys/device.h> | 41 | #include <sys/device.h> | |
42 | #include <sys/malloc.h> | 42 | #include <sys/malloc.h> | |
43 | #include <sys/systm.h> | 43 | #include <sys/systm.h> | |
44 | #ifdef GPROF | 44 | #ifdef GPROF | |
45 | #include <sys/gmon.h> | 45 | #include <sys/gmon.h> | |
46 | #endif | 46 | #endif | |
47 | 47 | |||
48 | #include <machine/bus.h> | 48 | #include <machine/bus.h> | |
49 | #include <machine/autoconf.h> | 49 | #include <machine/autoconf.h> | |
50 | 50 | |||
51 | #include <dev/clock_subr.h> | 51 | #include <dev/clock_subr.h> | |
52 | #include <dev/ic/mc146818reg.h> | 52 | #include <dev/ic/mc146818reg.h> | |
53 | 53 | |||
54 | #include <dev/ebus/ebusreg.h> | 54 | #include <dev/ebus/ebusreg.h> | |
55 | #include <dev/ebus/ebusvar.h> | 55 | #include <dev/ebus/ebusvar.h> | |
56 | 56 | |||
57 | struct rtc_ebus_softc { | 57 | struct rtc_ebus_softc { | |
58 | struct device sc_dev; | 58 | struct device sc_dev; | |
59 | 59 | |||
60 | bus_space_tag_t sc_bt; /* parent bus tag */ | 60 | bus_space_tag_t sc_bt; /* parent bus tag */ | |
61 | bus_space_handle_t sc_bh; /* handle for registers */ | 61 | bus_space_handle_t sc_bh; /* handle for registers */ | |
62 | }; | 62 | }; | |
63 | 63 | |||
64 | static int rtcmatch_ebus(struct device *, struct cfdata *, void *); | 64 | static int rtcmatch_ebus(device_t, cfdata_t, void *); | |
65 | static void rtcattach_ebus(struct device *, struct device *, void *); | 65 | static void rtcattach_ebus(device_t, device_t, void *); | |
66 | 66 | |||
67 | CFATTACH_DECL(rtc_ebus, sizeof(struct rtc_ebus_softc), | 67 | CFATTACH_DECL(rtc_ebus, sizeof(struct rtc_ebus_softc), | |
68 | rtcmatch_ebus, rtcattach_ebus, NULL, NULL); | 68 | rtcmatch_ebus, rtcattach_ebus, NULL, NULL); | |
69 | 69 | |||
70 | /* XXX: global TOD clock handle (sparc/clock.c) */ | 70 | /* XXX: global TOD clock handle (sparc/clock.c) */ | |
71 | extern todr_chip_handle_t todr_handle; | 71 | extern todr_chip_handle_t todr_handle; | |
72 | 72 | |||
73 | /* todr(9) methods */ | 73 | /* todr(9) methods */ | |
74 | static int rtc_gettime(todr_chip_handle_t, volatile struct timeval *); | 74 | static int rtc_gettime(todr_chip_handle_t, volatile struct timeval *); | |
75 | static int rtc_settime(todr_chip_handle_t, volatile struct timeval *); | 75 | static int rtc_settime(todr_chip_handle_t, volatile struct timeval *); | |
76 | 76 | |||
77 | int rtc_auto_century_adjust = 1; /* XXX: do we ever want not to? */ | 77 | int rtc_auto_century_adjust = 1; /* XXX: do we ever want not to? */ | |
78 | 78 | |||
@@ -93,39 +93,38 @@ mc146818_read(void *cookie, u_int reg) | @@ -93,39 +93,38 @@ mc146818_read(void *cookie, u_int reg) | |||
93 | } | 93 | } | |
94 | 94 | |||
95 | void | 95 | void | |
96 | mc146818_write(void *cookie, u_int reg, u_int datum) | 96 | mc146818_write(void *cookie, u_int reg, u_int datum) | |
97 | { | 97 | { | |
98 | struct rtc_ebus_softc *sc = cookie; | 98 | struct rtc_ebus_softc *sc = cookie; | |
99 | 99 | |||
100 | bus_space_write_1(sc->sc_bt, sc->sc_bh, RTC_ADDR, reg); | 100 | bus_space_write_1(sc->sc_bt, sc->sc_bh, RTC_ADDR, reg); | |
101 | bus_space_write_1(sc->sc_bt, sc->sc_bh, RTC_DATA, datum); | 101 | bus_space_write_1(sc->sc_bt, sc->sc_bh, RTC_DATA, datum); | |
102 | } | 102 | } | |
103 | 103 | |||
104 | 104 | |||
105 | static int | 105 | static int | |
106 | rtcmatch_ebus(struct device *parent, struct cfdata *cf, void *aux) | 106 | rtcmatch_ebus(device_t parent, cfdata_t cf, void *aux) | |
107 | { | 107 | { | |
108 | struct ebus_attach_args *ea = aux; | 108 | struct ebus_attach_args *ea = aux; | |
109 | 109 | |||
110 | return (strcmp(cf->cf_name, ea->ea_name) == 0); | 110 | return (strcmp(cf->cf_name, ea->ea_name) == 0); | |
111 | } | 111 | } | |
112 | 112 | |||
113 | static void | 113 | static void | |
114 | rtcattach_ebus(struct device *parent, struct device *self, void *aux) | 114 | rtcattach_ebus(device_t parent, device_t self, void *aux) | |
115 | { | 115 | { | |
116 | struct rtc_ebus_softc *sc = (void *)self; | 116 | struct rtc_ebus_softc *sc = device_private(self); | |
117 | struct ebus_attach_args *ea = aux; | 117 | struct ebus_attach_args *ea = aux; | |
118 | ||||
119 | todr_chip_handle_t handle; | 118 | todr_chip_handle_t handle; | |
120 | 119 | |||
121 | sc->sc_bt = ea->ea_bustag; | 120 | sc->sc_bt = ea->ea_bustag; | |
122 | if (bus_space_map(sc->sc_bt, EBUS_ADDR_FROM_REG(&ea->ea_reg[0]), | 121 | if (bus_space_map(sc->sc_bt, EBUS_ADDR_FROM_REG(&ea->ea_reg[0]), | |
123 | ea->ea_reg[0].size, 0, &sc->sc_bh) != 0) | 122 | ea->ea_reg[0].size, 0, &sc->sc_bh) != 0) | |
124 | { | 123 | { | |
125 | printf(": unable to map registers\n"); | 124 | printf(": unable to map registers\n"); | |
126 | return; | 125 | return; | |
127 | } | 126 | } | |
128 | 127 | |||
129 | /* XXX: no "model" property in Krups */ | 128 | /* XXX: no "model" property in Krups */ | |
130 | printf(": time-of-day clock\n"); | 129 | printf(": time-of-day clock\n"); | |
131 | 130 |
--- src/sys/arch/sparc/dev/vme_machdep.c 2008/12/19 18:49:38 1.59
+++ src/sys/arch/sparc/dev/vme_machdep.c 2009/09/20 16:18:21 1.60
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: vme_machdep.c,v 1.59 2008/12/19 18:49:38 cegger Exp $ */ | 1 | /* $NetBSD: vme_machdep.c,v 1.60 2009/09/20 16:18:21 tsutsui Exp $ */ | |
2 | 2 | |||
3 | /*- | 3 | /*- | |
4 | * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. | 4 | * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * This code is derived from software contributed to The NetBSD Foundation | 7 | * This code is derived from software contributed to The NetBSD Foundation | |
8 | * by Paul Kranenburg. | 8 | * by Paul Kranenburg. | |
9 | * | 9 | * | |
10 | * Redistribution and use in source and binary forms, with or without | 10 | * Redistribution and use in source and binary forms, with or without | |
11 | * modification, are permitted provided that the following conditions | 11 | * modification, are permitted provided that the following conditions | |
12 | * are met: | 12 | * are met: | |
13 | * 1. Redistributions of source code must retain the above copyright | 13 | * 1. Redistributions of source code must retain the above copyright | |
14 | * notice, this list of conditions and the following disclaimer. | 14 | * notice, this list of conditions and the following disclaimer. | |
@@ -20,27 +20,27 @@ | @@ -20,27 +20,27 @@ | |||
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
29 | * POSSIBILITY OF SUCH DAMAGE. | 29 | * POSSIBILITY OF SUCH DAMAGE. | |
30 | */ | 30 | */ | |
31 | 31 | |||
32 | #include <sys/cdefs.h> | 32 | #include <sys/cdefs.h> | |
33 | __KERNEL_RCSID(0, "$NetBSD: vme_machdep.c,v 1.59 2008/12/19 18:49:38 cegger Exp $"); | 33 | __KERNEL_RCSID(0, "$NetBSD: vme_machdep.c,v 1.60 2009/09/20 16:18:21 tsutsui Exp $"); | |
34 | 34 | |||
35 | #include <sys/param.h> | 35 | #include <sys/param.h> | |
36 | #include <sys/extent.h> | 36 | #include <sys/extent.h> | |
37 | #include <sys/systm.h> | 37 | #include <sys/systm.h> | |
38 | #include <sys/device.h> | 38 | #include <sys/device.h> | |
39 | #include <sys/malloc.h> | 39 | #include <sys/malloc.h> | |
40 | #include <sys/errno.h> | 40 | #include <sys/errno.h> | |
41 | 41 | |||
42 | #include <sys/proc.h> | 42 | #include <sys/proc.h> | |
43 | #include <sys/user.h> | 43 | #include <sys/user.h> | |
44 | #include <sys/syslog.h> | 44 | #include <sys/syslog.h> | |
45 | 45 | |||
46 | #include <uvm/uvm_extern.h> | 46 | #include <uvm/uvm_extern.h> | |
@@ -66,30 +66,30 @@ struct sparcvme_softc { | @@ -66,30 +66,30 @@ struct sparcvme_softc { | |||
66 | bus_space_tag_t sc_bustag; | 66 | bus_space_tag_t sc_bustag; | |
67 | bus_dma_tag_t sc_dmatag; | 67 | bus_dma_tag_t sc_dmatag; | |
68 | struct vmebusreg *sc_reg; /* VME control registers */ | 68 | struct vmebusreg *sc_reg; /* VME control registers */ | |
69 | struct vmebusvec *sc_vec; /* VME interrupt vector */ | 69 | struct vmebusvec *sc_vec; /* VME interrupt vector */ | |
70 | struct rom_range *sc_range; /* ROM range property */ | 70 | struct rom_range *sc_range; /* ROM range property */ | |
71 | int sc_nrange; | 71 | int sc_nrange; | |
72 | volatile uint32_t *sc_ioctags; /* VME IO-cache tag registers */ | 72 | volatile uint32_t *sc_ioctags; /* VME IO-cache tag registers */ | |
73 | volatile uint32_t *sc_iocflush;/* VME IO-cache flush registers */ | 73 | volatile uint32_t *sc_iocflush;/* VME IO-cache flush registers */ | |
74 | int (*sc_vmeintr)(void *); | 74 | int (*sc_vmeintr)(void *); | |
75 | }; | 75 | }; | |
76 | struct sparcvme_softc *sparcvme_sc;/*XXX*/ | 76 | struct sparcvme_softc *sparcvme_sc;/*XXX*/ | |
77 | 77 | |||
78 | /* autoconfiguration driver */ | 78 | /* autoconfiguration driver */ | |
79 | static int vmematch_iommu(struct device *, struct cfdata *, void *); | 79 | static int vmematch_iommu(device_t, cfdata_t, void *); | |
80 | static void vmeattach_iommu(struct device *, struct device *, void *); | 80 | static void vmeattach_iommu(device_t, device_t, void *); | |
81 | static int vmematch_mainbus(struct device *, struct cfdata *, void *); | 81 | static int vmematch_mainbus(device_t, cfdata_t, void *); | |
82 | static void vmeattach_mainbus(struct device *, struct device *, void *); | 82 | static void vmeattach_mainbus(device_t, device_t, void *); | |
83 | #if defined(SUN4) | 83 | #if defined(SUN4) | |
84 | int vmeintr4(void *); | 84 | int vmeintr4(void *); | |
85 | #endif | 85 | #endif | |
86 | #if defined(SUN4M) | 86 | #if defined(SUN4M) | |
87 | int vmeintr4m(void *); | 87 | int vmeintr4m(void *); | |
88 | static int sparc_vme_error(void); | 88 | static int sparc_vme_error(void); | |
89 | #endif | 89 | #endif | |
90 | 90 | |||
91 | 91 | |||
92 | static int sparc_vme_probe(void *, vme_addr_t, vme_size_t, | 92 | static int sparc_vme_probe(void *, vme_addr_t, vme_size_t, | |
93 | vme_am_t, vme_datasize_t, | 93 | vme_am_t, vme_datasize_t, | |
94 | int (*)(void *, | 94 | int (*)(void *, | |
95 | bus_space_tag_t, bus_space_handle_t), | 95 | bus_space_tag_t, bus_space_handle_t), | |
@@ -253,68 +253,68 @@ struct sparc_bus_dma_tag sparc_vme_iommu | @@ -253,68 +253,68 @@ struct sparc_bus_dma_tag sparc_vme_iommu | |||
253 | sparc_vme_iommu_dmamap_unload, | 253 | sparc_vme_iommu_dmamap_unload, | |
254 | sparc_vme_iommu_dmamap_sync, | 254 | sparc_vme_iommu_dmamap_sync, | |
255 | 255 | |||
256 | _bus_dmamem_alloc, | 256 | _bus_dmamem_alloc, | |
257 | _bus_dmamem_free, | 257 | _bus_dmamem_free, | |
258 | sparc_vme_dmamem_map, | 258 | sparc_vme_dmamem_map, | |
259 | _bus_dmamem_unmap, | 259 | _bus_dmamem_unmap, | |
260 | _bus_dmamem_mmap | 260 | _bus_dmamem_mmap | |
261 | }; | 261 | }; | |
262 | #endif | 262 | #endif | |
263 | 263 | |||
264 | 264 | |||
265 | static int | 265 | static int | |
266 | vmematch_mainbus(struct device *parent, struct cfdata *cf, void *aux) | 266 | vmematch_mainbus(device_t parent, cfdata_t cf, void *aux) | |
267 | { | 267 | { | |
268 | struct mainbus_attach_args *ma = aux; | 268 | struct mainbus_attach_args *ma = aux; | |
269 | 269 | |||
270 | if (!CPU_ISSUN4 || vme_attached) | 270 | if (!CPU_ISSUN4 || vme_attached) | |
271 | return (0); | 271 | return (0); | |
272 | 272 | |||
273 | return (strcmp("vme", ma->ma_name) == 0); | 273 | return (strcmp("vme", ma->ma_name) == 0); | |
274 | } | 274 | } | |
275 | 275 | |||
276 | static int | 276 | static int | |
277 | vmematch_iommu(struct device *parent, struct cfdata *cf, void *aux) | 277 | vmematch_iommu(device_t parent, cfdata_t cf, void *aux) | |
278 | { | 278 | { | |
279 | struct iommu_attach_args *ia = aux; | 279 | struct iommu_attach_args *ia = aux; | |
280 | 280 | |||
281 | if (vme_attached) | 281 | if (vme_attached) | |
282 | return 0; | 282 | return 0; | |
283 | 283 | |||
284 | return (strcmp("vme", ia->iom_name) == 0); | 284 | return (strcmp("vme", ia->iom_name) == 0); | |
285 | } | 285 | } | |
286 | 286 | |||
287 | 287 | |||
288 | static void | 288 | static void | |
289 | vmeattach_mainbus(struct device *parent, struct device *self, void *aux) | 289 | vmeattach_mainbus(device_t parent, device_t self, void *aux) | |
290 | { | 290 | { | |
291 | #if defined(SUN4) | 291 | #if defined(SUN4) | |
292 | struct mainbus_attach_args *ma = aux; | 292 | struct mainbus_attach_args *ma = aux; | |
293 | struct sparcvme_softc *sc = (struct sparcvme_softc *)self; | 293 | struct sparcvme_softc *sc = device_private(self); | |
294 | struct vmebus_attach_args vba; | 294 | struct vmebus_attach_args vba; | |
295 | 295 | |||
296 | vme_attached = 1; | 296 | vme_attached = 1; | |
297 | 297 | |||
298 | sc->sc_bustag = ma->ma_bustag; | 298 | sc->sc_bustag = ma->ma_bustag; | |
299 | sc->sc_dmatag = ma->ma_dmatag; | 299 | sc->sc_dmatag = ma->ma_dmatag; | |
300 | 300 | |||
301 | /* VME interrupt entry point */ | 301 | /* VME interrupt entry point */ | |
302 | sc->sc_vmeintr = vmeintr4; | 302 | sc->sc_vmeintr = vmeintr4; | |
303 | 303 | |||
304 | /*XXX*/ sparc_vme_chipset_tag.cookie = self; | 304 | /*XXX*/ sparc_vme_chipset_tag.cookie = sc; | |
305 | /*XXX*/ sparc_vme_chipset_tag.vct_dmamap_create = sparc_vct4_dmamap_create; | 305 | /*XXX*/ sparc_vme_chipset_tag.vct_dmamap_create = sparc_vct4_dmamap_create; | |
306 | /*XXX*/ sparc_vme_chipset_tag.vct_dmamap_destroy = sparc_vct_dmamap_destroy; | 306 | /*XXX*/ sparc_vme_chipset_tag.vct_dmamap_destroy = sparc_vct_dmamap_destroy; | |
307 | /*XXX*/ sparc_vme4_dma_tag._cookie = self; | 307 | /*XXX*/ sparc_vme4_dma_tag._cookie = sc; | |
308 | 308 | |||
309 | vba.va_vct = &sparc_vme_chipset_tag; | 309 | vba.va_vct = &sparc_vme_chipset_tag; | |
310 | vba.va_bdt = &sparc_vme4_dma_tag; | 310 | vba.va_bdt = &sparc_vme4_dma_tag; | |
311 | vba.va_slaveconfig = 0; | 311 | vba.va_slaveconfig = 0; | |
312 | 312 | |||
313 | /* Fall back to our own `range' construction */ | 313 | /* Fall back to our own `range' construction */ | |
314 | sc->sc_range = vmebus_translations; | 314 | sc->sc_range = vmebus_translations; | |
315 | sc->sc_nrange = | 315 | sc->sc_nrange = | |
316 | sizeof(vmebus_translations)/sizeof(vmebus_translations[0]); | 316 | sizeof(vmebus_translations)/sizeof(vmebus_translations[0]); | |
317 | 317 | |||
318 | vme_dvmamap = extent_create("vmedvma", VME4_DVMA_BASE, VME4_DVMA_END, | 318 | vme_dvmamap = extent_create("vmedvma", VME4_DVMA_BASE, VME4_DVMA_END, | |
319 | M_DEVBUF, 0, 0, EX_NOWAIT); | 319 | M_DEVBUF, 0, 0, EX_NOWAIT); | |
320 | if (vme_dvmamap == NULL) | 320 | if (vme_dvmamap == NULL) | |
@@ -322,110 +322,110 @@ vmeattach_mainbus(struct device *parent, | @@ -322,110 +322,110 @@ vmeattach_mainbus(struct device *parent, | |||
322 | 322 | |||
323 | printf("\n"); | 323 | printf("\n"); | |
324 | (void)config_found(self, &vba, 0); | 324 | (void)config_found(self, &vba, 0); | |
325 | 325 | |||
326 | #endif /* SUN4 */ | 326 | #endif /* SUN4 */ | |
327 | return; | 327 | return; | |
328 | } | 328 | } | |
329 | 329 | |||
330 | /* sun4m vmebus */ | 330 | /* sun4m vmebus */ | |
331 | static void | 331 | static void | |
332 | vmeattach_iommu(struct device *parent, struct device *self, void *aux) | 332 | vmeattach_iommu(struct device *parent, struct device *self, void *aux) | |
333 | { | 333 | { | |
334 | #if defined(SUN4M) | 334 | #if defined(SUN4M) | |
335 | struct sparcvme_softc *sc = (struct sparcvme_softc *)self; | 335 | struct sparcvme_softc *sc = device_private(self); | |
336 | struct iommu_attach_args *ia = aux; | 336 | struct iommu_attach_args *ia = aux; | |
337 | struct vmebus_attach_args vba; | 337 | struct vmebus_attach_args vba; | |
338 | bus_space_handle_t bh; | 338 | bus_space_handle_t bh; | |
339 | int node; | 339 | int node; | |
340 | int cline; | 340 | int cline; | |
341 | 341 | |||
342 | sc->sc_bustag = ia->iom_bustag; | 342 | sc->sc_bustag = ia->iom_bustag; | |
343 | sc->sc_dmatag = ia->iom_dmatag; | 343 | sc->sc_dmatag = ia->iom_dmatag; | |
344 | 344 | |||
345 | /* VME interrupt entry point */ | 345 | /* VME interrupt entry point */ | |
346 | sc->sc_vmeintr = vmeintr4m; | 346 | sc->sc_vmeintr = vmeintr4m; | |
347 | 347 | |||
348 | /*XXX*/ sparc_vme_chipset_tag.cookie = self; | 348 | /*XXX*/ sparc_vme_chipset_tag.cookie = sc; | |
349 | /*XXX*/ sparc_vme_chipset_tag.vct_dmamap_create = sparc_vct_iommu_dmamap_create; | 349 | /*XXX*/ sparc_vme_chipset_tag.vct_dmamap_create = sparc_vct_iommu_dmamap_create; | |
350 | /*XXX*/ sparc_vme_chipset_tag.vct_dmamap_destroy = sparc_vct_dmamap_destroy; | 350 | /*XXX*/ sparc_vme_chipset_tag.vct_dmamap_destroy = sparc_vct_dmamap_destroy; | |
351 | /*XXX*/ sparc_vme_iommu_dma_tag._cookie = self; | 351 | /*XXX*/ sparc_vme_iommu_dma_tag._cookie = sc; | |
352 | 352 | |||
353 | vba.va_vct = &sparc_vme_chipset_tag; | 353 | vba.va_vct = &sparc_vme_chipset_tag; | |
354 | vba.va_bdt = &sparc_vme_iommu_dma_tag; | 354 | vba.va_bdt = &sparc_vme_iommu_dma_tag; | |
355 | vba.va_slaveconfig = 0; | 355 | vba.va_slaveconfig = 0; | |
356 | 356 | |||
357 | node = ia->iom_node; | 357 | node = ia->iom_node; | |
358 | 358 | |||
359 | /* | 359 | /* | |
360 | * Map VME control space | 360 | * Map VME control space | |
361 | */ | 361 | */ | |
362 | if (ia->iom_nreg < 2) { | 362 | if (ia->iom_nreg < 2) { | |
363 | printf("%s: only %d register sets\n", self->dv_xname, | 363 | printf("%s: only %d register sets\n", device_xname(self), | |
364 | ia->iom_nreg); | 364 | ia->iom_nreg); | |
365 | return; | 365 | return; | |
366 | } | 366 | } | |
367 | 367 | |||
368 | if (bus_space_map(ia->iom_bustag, | 368 | if (bus_space_map(ia->iom_bustag, | |
369 | (bus_addr_t) BUS_ADDR(ia->iom_reg[0].oa_space, | 369 | (bus_addr_t) BUS_ADDR(ia->iom_reg[0].oa_space, | |
370 | ia->iom_reg[0].oa_base), | 370 | ia->iom_reg[0].oa_base), | |
371 | (bus_size_t)ia->iom_reg[0].oa_size, | 371 | (bus_size_t)ia->iom_reg[0].oa_size, | |
372 | BUS_SPACE_MAP_LINEAR, | 372 | BUS_SPACE_MAP_LINEAR, | |
373 | &bh) != 0) { | 373 | &bh) != 0) { | |
374 | panic("%s: can't map vmebusreg", self->dv_xname); | 374 | panic("%s: can't map vmebusreg", device_xname(self)); | |
375 | } | 375 | } | |
376 | sc->sc_reg = (struct vmebusreg *)bh; | 376 | sc->sc_reg = (struct vmebusreg *)bh; | |
377 | 377 | |||
378 | if (bus_space_map(ia->iom_bustag, | 378 | if (bus_space_map(ia->iom_bustag, | |
379 | (bus_addr_t) BUS_ADDR(ia->iom_reg[1].oa_space, | 379 | (bus_addr_t) BUS_ADDR(ia->iom_reg[1].oa_space, | |
380 | ia->iom_reg[1].oa_base), | 380 | ia->iom_reg[1].oa_base), | |
381 | (bus_size_t)ia->iom_reg[1].oa_size, | 381 | (bus_size_t)ia->iom_reg[1].oa_size, | |
382 | BUS_SPACE_MAP_LINEAR, | 382 | BUS_SPACE_MAP_LINEAR, | |
383 | &bh) != 0) { | 383 | &bh) != 0) { | |
384 | panic("%s: can't map vmebusvec", self->dv_xname); | 384 | panic("%s: can't map vmebusvec", device_xname(self)); | |
385 | } | 385 | } | |
386 | sc->sc_vec = (struct vmebusvec *)bh; | 386 | sc->sc_vec = (struct vmebusvec *)bh; | |
387 | 387 | |||
388 | /* | 388 | /* | |
389 | * Map VME IO cache tags and flush control. | 389 | * Map VME IO cache tags and flush control. | |
390 | */ | 390 | */ | |
391 | if (bus_space_map(ia->iom_bustag, | 391 | if (bus_space_map(ia->iom_bustag, | |
392 | (bus_addr_t) BUS_ADDR( | 392 | (bus_addr_t) BUS_ADDR( | |
393 | ia->iom_reg[1].oa_space, | 393 | ia->iom_reg[1].oa_space, | |
394 | ia->iom_reg[1].oa_base + VME_IOC_TAGOFFSET), | 394 | ia->iom_reg[1].oa_base + VME_IOC_TAGOFFSET), | |
395 | VME_IOC_SIZE, | 395 | VME_IOC_SIZE, | |
396 | BUS_SPACE_MAP_LINEAR, | 396 | BUS_SPACE_MAP_LINEAR, | |
397 | &bh) != 0) { | 397 | &bh) != 0) { | |
398 | panic("%s: can't map IOC tags", self->dv_xname); | 398 | panic("%s: can't map IOC tags", device_xname(self)); | |
399 | } | 399 | } | |
400 | sc->sc_ioctags = (uint32_t *)bh; | 400 | sc->sc_ioctags = (uint32_t *)bh; | |
401 | 401 | |||
402 | if (bus_space_map(ia->iom_bustag, | 402 | if (bus_space_map(ia->iom_bustag, | |
403 | (bus_addr_t) BUS_ADDR( | 403 | (bus_addr_t) BUS_ADDR( | |
404 | ia->iom_reg[1].oa_space, | 404 | ia->iom_reg[1].oa_space, | |
405 | ia->iom_reg[1].oa_base + VME_IOC_FLUSHOFFSET), | 405 | ia->iom_reg[1].oa_base + VME_IOC_FLUSHOFFSET), | |
406 | VME_IOC_SIZE, | 406 | VME_IOC_SIZE, | |
407 | BUS_SPACE_MAP_LINEAR, | 407 | BUS_SPACE_MAP_LINEAR, | |
408 | &bh) != 0) { | 408 | &bh) != 0) { | |
409 | panic("%s: can't map IOC flush registers", self->dv_xname); | 409 | panic("%s: can't map IOC flush registers", device_xname(self)); | |
410 | } | 410 | } | |
411 | sc->sc_iocflush = (uint32_t *)bh; | 411 | sc->sc_iocflush = (uint32_t *)bh; | |
412 | 412 | |||
413 | /* | 413 | /* | |
414 | * Get "range" property. | 414 | * Get "range" property. | |
415 | */ | 415 | */ | |
416 | if (prom_getprop(node, "ranges", sizeof(struct rom_range), | 416 | if (prom_getprop(node, "ranges", sizeof(struct rom_range), | |
417 | &sc->sc_nrange, &sc->sc_range) != 0) { | 417 | &sc->sc_nrange, &sc->sc_range) != 0) { | |
418 | panic("%s: can't get ranges property", self->dv_xname); | 418 | panic("%s: can't get ranges property", device_xname(self)); | |
419 | } | 419 | } | |
420 | 420 | |||
421 | sparcvme_sc = sc; | 421 | sparcvme_sc = sc; | |
422 | vmeerr_handler = sparc_vme_error; | 422 | vmeerr_handler = sparc_vme_error; | |
423 | 423 | |||
424 | /* | 424 | /* | |
425 | * Invalidate all IO-cache entries. | 425 | * Invalidate all IO-cache entries. | |
426 | */ | 426 | */ | |
427 | for (cline = VME_IOC_SIZE/VME_IOC_LINESZ; cline > 0;) { | 427 | for (cline = VME_IOC_SIZE/VME_IOC_LINESZ; cline > 0;) { | |
428 | sc->sc_ioctags[--cline] = 0; | 428 | sc->sc_ioctags[--cline] = 0; | |
429 | } | 429 | } | |
430 | 430 | |||
431 | /* Enable IO-cache */ | 431 | /* Enable IO-cache */ | |
@@ -488,27 +488,27 @@ vmeprobe_mycb(void *bh, void *arg) | @@ -488,27 +488,27 @@ vmeprobe_mycb(void *bh, void *arg) | |||
488 | { | 488 | { | |
489 | struct vmeprobe_myarg *a = arg; | 489 | struct vmeprobe_myarg *a = arg; | |
490 | 490 | |||
491 | a->res = (*a->cb)(a->cbarg, a->tag, (bus_space_handle_t)bh); | 491 | a->res = (*a->cb)(a->cbarg, a->tag, (bus_space_handle_t)bh); | |
492 | return (!a->res); | 492 | return (!a->res); | |
493 | } | 493 | } | |
494 | 494 | |||
495 | static int | 495 | static int | |
496 | sparc_vme_probe(void *cookie, vme_addr_t addr, vme_size_t len, vme_am_t mod, | 496 | sparc_vme_probe(void *cookie, vme_addr_t addr, vme_size_t len, vme_am_t mod, | |
497 | vme_datasize_t datasize, | 497 | vme_datasize_t datasize, | |
498 | int (*callback)(void *, bus_space_tag_t, bus_space_handle_t), | 498 | int (*callback)(void *, bus_space_tag_t, bus_space_handle_t), | |
499 | void *arg) | 499 | void *arg) | |
500 | { | 500 | { | |
501 | struct sparcvme_softc *sc = (struct sparcvme_softc *)cookie; | 501 | struct sparcvme_softc *sc = cookie; | |
502 | bus_addr_t paddr; | 502 | bus_addr_t paddr; | |
503 | bus_size_t size; | 503 | bus_size_t size; | |
504 | struct vmeprobe_myarg myarg; | 504 | struct vmeprobe_myarg myarg; | |
505 | int res, i; | 505 | int res, i; | |
506 | 506 | |||
507 | if (vmebus_translate(sc, mod, addr, &paddr) != 0) | 507 | if (vmebus_translate(sc, mod, addr, &paddr) != 0) | |
508 | return (EINVAL); | 508 | return (EINVAL); | |
509 | 509 | |||
510 | size = (datasize == VME_D8 ? 1 : (datasize == VME_D16 ? 2 : 4)); | 510 | size = (datasize == VME_D8 ? 1 : (datasize == VME_D16 ? 2 : 4)); | |
511 | 511 | |||
512 | if (callback) { | 512 | if (callback) { | |
513 | myarg.cb = callback; | 513 | myarg.cb = callback; | |
514 | myarg.cbarg = arg; | 514 | myarg.cbarg = arg; | |
@@ -525,27 +525,27 @@ sparc_vme_probe(void *cookie, vme_addr_t | @@ -525,27 +525,27 @@ sparc_vme_probe(void *cookie, vme_addr_t | |||
525 | 0, 0, 0); | 525 | 0, 0, 0); | |
526 | if (res == 0) | 526 | if (res == 0) | |
527 | return (EIO); | 527 | return (EIO); | |
528 | paddr += size; | 528 | paddr += size; | |
529 | } | 529 | } | |
530 | return (0); | 530 | return (0); | |
531 | } | 531 | } | |
532 | 532 | |||
533 | static int | 533 | static int | |
534 | sparc_vme_map(void *cookie, vme_addr_t addr, vme_size_t size, vme_am_t mod, | 534 | sparc_vme_map(void *cookie, vme_addr_t addr, vme_size_t size, vme_am_t mod, | |
535 | vme_datasize_t datasize, vme_swap_t swap, | 535 | vme_datasize_t datasize, vme_swap_t swap, | |
536 | bus_space_tag_t *tp, bus_space_handle_t *hp, vme_mapresc_t *rp) | 536 | bus_space_tag_t *tp, bus_space_handle_t *hp, vme_mapresc_t *rp) | |
537 | { | 537 | { | |
538 | struct sparcvme_softc *sc = (struct sparcvme_softc *)cookie; | 538 | struct sparcvme_softc *sc = cookie; | |
539 | bus_addr_t paddr; | 539 | bus_addr_t paddr; | |
540 | int error; | 540 | int error; | |
541 | 541 | |||
542 | error = vmebus_translate(sc, mod, addr, &paddr); | 542 | error = vmebus_translate(sc, mod, addr, &paddr); | |
543 | if (error != 0) | 543 | if (error != 0) | |
544 | return (error); | 544 | return (error); | |
545 | 545 | |||
546 | *tp = sc->sc_bustag; | 546 | *tp = sc->sc_bustag; | |
547 | return (bus_space_map(sc->sc_bustag, paddr, size, 0, hp)); | 547 | return (bus_space_map(sc->sc_bustag, paddr, size, 0, hp)); | |
548 | } | 548 | } | |
549 | 549 | |||
550 | int | 550 | int | |
551 | sparc_vme_mmap_cookie(vme_addr_t addr, vme_am_t mod, bus_space_handle_t *hp) | 551 | sparc_vme_mmap_cookie(vme_addr_t addr, vme_am_t mod, bus_space_handle_t *hp) | |
@@ -559,27 +559,27 @@ sparc_vme_mmap_cookie(vme_addr_t addr, v | @@ -559,27 +559,27 @@ sparc_vme_mmap_cookie(vme_addr_t addr, v | |||
559 | return (error); | 559 | return (error); | |
560 | 560 | |||
561 | return (bus_space_mmap(sc->sc_bustag, paddr, 0, | 561 | return (bus_space_mmap(sc->sc_bustag, paddr, 0, | |
562 | 0/*prot is ignored*/, 0)); | 562 | 0/*prot is ignored*/, 0)); | |
563 | } | 563 | } | |
564 | 564 | |||
565 | #ifdef notyet | 565 | #ifdef notyet | |
566 | #if defined(SUN4M) | 566 | #if defined(SUN4M) | |
567 | static void | 567 | static void | |
568 | sparc_vme_iommu_barrier(bus_space_tag_t t, bus_space_handle_t h, | 568 | sparc_vme_iommu_barrier(bus_space_tag_t t, bus_space_handle_t h, | |
569 | bus_size_t offset, bus_size_t size. | 569 | bus_size_t offset, bus_size_t size. | |
570 | int flags) | 570 | int flags) | |
571 | { | 571 | { | |
572 | struct vmebusreg *vbp = (struct vmebusreg *)t->cookie; | 572 | struct vmebusreg *vbp = t->cookie; | |
573 | 573 | |||
574 | /* Read async fault status to flush write-buffers */ | 574 | /* Read async fault status to flush write-buffers */ | |
575 | (*(volatile int *)&vbp->vmebus_afsr); | 575 | (*(volatile int *)&vbp->vmebus_afsr); | |
576 | } | 576 | } | |
577 | #endif /* SUN4M */ | 577 | #endif /* SUN4M */ | |
578 | #endif | 578 | #endif | |
579 | 579 | |||
580 | 580 | |||
581 | 581 | |||
582 | /* | 582 | /* | |
583 | * VME Interrupt Priority Level to sparc Processor Interrupt Level. | 583 | * VME Interrupt Priority Level to sparc Processor Interrupt Level. | |
584 | */ | 584 | */ | |
585 | static int vme_ipl_to_pil[] = { | 585 | static int vme_ipl_to_pil[] = { | |
@@ -731,27 +731,27 @@ sparc_vme_intr_map(void *cookie, int lev | @@ -731,27 +731,27 @@ sparc_vme_intr_map(void *cookie, int lev | |||
731 | 731 | |||
732 | static const struct evcnt * | 732 | static const struct evcnt * | |
733 | sparc_vme_intr_evcnt(void *cookie, vme_intr_handle_t vih) | 733 | sparc_vme_intr_evcnt(void *cookie, vme_intr_handle_t vih) | |
734 | { | 734 | { | |
735 | 735 | |||
736 | /* XXX for now, no evcnt parent reported */ | 736 | /* XXX for now, no evcnt parent reported */ | |
737 | return NULL; | 737 | return NULL; | |
738 | } | 738 | } | |
739 | 739 | |||
740 | static void * | 740 | static void * | |
741 | sparc_vme_intr_establish(void *cookie, vme_intr_handle_t vih, int level, | 741 | sparc_vme_intr_establish(void *cookie, vme_intr_handle_t vih, int level, | |
742 | int (*func)(void *), void *arg) | 742 | int (*func)(void *), void *arg) | |
743 | { | 743 | { | |
744 | struct sparcvme_softc *sc = (struct sparcvme_softc *)cookie; | 744 | struct sparcvme_softc *sc = cookie; | |
745 | struct sparc_vme_intr_handle *svih = | 745 | struct sparc_vme_intr_handle *svih = | |
746 | (struct sparc_vme_intr_handle *)vih; | 746 | (struct sparc_vme_intr_handle *)vih; | |
747 | struct intrhand *ih; | 747 | struct intrhand *ih; | |
748 | int pil; | 748 | int pil; | |
749 | 749 | |||
750 | /* Translate VME priority to processor IPL */ | 750 | /* Translate VME priority to processor IPL */ | |
751 | pil = vme_ipl_to_pil[svih->pri]; | 751 | pil = vme_ipl_to_pil[svih->pri]; | |
752 | 752 | |||
753 | if (level < pil) | 753 | if (level < pil) | |
754 | panic("vme_intr_establish: class lvl (%d) < pil (%d)\n", | 754 | panic("vme_intr_establish: class lvl (%d) < pil (%d)\n", | |
755 | level, pil); | 755 | level, pil); | |
756 | 756 | |||
757 | svih->ih.ih_fun = func; | 757 | svih->ih.ih_fun = func; | |
@@ -795,41 +795,41 @@ sparc_vme_intr_disestablish(void *cookie | @@ -795,41 +795,41 @@ sparc_vme_intr_disestablish(void *cookie | |||
795 | panic("sparc_vme_intr_disestablish"); | 795 | panic("sparc_vme_intr_disestablish"); | |
796 | } | 796 | } | |
797 | 797 | |||
798 | 798 | |||
799 | 799 | |||
800 | /* | 800 | /* | |
801 | * VME DMA functions. | 801 | * VME DMA functions. | |
802 | */ | 802 | */ | |
803 | 803 | |||
804 | #if defined(SUN4) || defined(SUN4M) | 804 | #if defined(SUN4) || defined(SUN4M) | |
805 | static void | 805 | static void | |
806 | sparc_vct_dmamap_destroy(void *cookie, bus_dmamap_t map) | 806 | sparc_vct_dmamap_destroy(void *cookie, bus_dmamap_t map) | |
807 | { | 807 | { | |
808 | struct sparcvme_softc *sc = (struct sparcvme_softc *)cookie; | 808 | struct sparcvme_softc *sc = cookie; | |
809 | 809 | |||
810 | bus_dmamap_destroy(sc->sc_dmatag, map); | 810 | bus_dmamap_destroy(sc->sc_dmatag, map); | |
811 | } | 811 | } | |
812 | #endif | 812 | #endif | |
813 | 813 | |||
814 | #if defined(SUN4) | 814 | #if defined(SUN4) | |
815 | static int | 815 | static int | |
816 | sparc_vct4_dmamap_create(void *cookie, vme_size_t size, vme_am_t am, | 816 | sparc_vct4_dmamap_create(void *cookie, vme_size_t size, vme_am_t am, | |
817 | vme_datasize_t datasize, vme_swap_t swap, | 817 | vme_datasize_t datasize, vme_swap_t swap, | |
818 | int nsegments, vme_size_t maxsegsz, | 818 | int nsegments, vme_size_t maxsegsz, | |
819 | vme_addr_t boundary, int flags, | 819 | vme_addr_t boundary, int flags, | |
820 | bus_dmamap_t *dmamp) | 820 | bus_dmamap_t *dmamp) | |
821 | { | 821 | { | |
822 | struct sparcvme_softc *sc = (struct sparcvme_softc *)cookie; | 822 | struct sparcvme_softc *sc = cookie; | |
823 | 823 | |||
824 | /* Allocate a base map through parent bus ops */ | 824 | /* Allocate a base map through parent bus ops */ | |
825 | return (bus_dmamap_create(sc->sc_dmatag, size, nsegments, maxsegsz, | 825 | return (bus_dmamap_create(sc->sc_dmatag, size, nsegments, maxsegsz, | |
826 | boundary, flags, dmamp)); | 826 | boundary, flags, dmamp)); | |
827 | } | 827 | } | |
828 | 828 | |||
829 | static int | 829 | static int | |
830 | sparc_vme4_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, | 830 | sparc_vme4_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, | |
831 | void *buf, bus_size_t buflen, | 831 | void *buf, bus_size_t buflen, | |
832 | struct proc *p, int flags) | 832 | struct proc *p, int flags) | |
833 | { | 833 | { | |
834 | bus_addr_t dva; | 834 | bus_addr_t dva; | |
835 | bus_size_t sgsize; | 835 | bus_size_t sgsize; | |
@@ -946,27 +946,27 @@ sparc_vme_iommu_dmamap_create(bus_dma_ta | @@ -946,27 +946,27 @@ sparc_vme_iommu_dmamap_create(bus_dma_ta | |||
946 | { | 946 | { | |
947 | 947 | |||
948 | printf("sparc_vme_dmamap_create: please use `vme_dmamap_create'\n"); | 948 | printf("sparc_vme_dmamap_create: please use `vme_dmamap_create'\n"); | |
949 | return (EINVAL); | 949 | return (EINVAL); | |
950 | } | 950 | } | |
951 | 951 | |||
952 | static int | 952 | static int | |
953 | sparc_vct_iommu_dmamap_create(void *cookie, vme_size_t size, vme_am_t am, | 953 | sparc_vct_iommu_dmamap_create(void *cookie, vme_size_t size, vme_am_t am, | |
954 | vme_datasize_t datasize, vme_swap_t swap, | 954 | vme_datasize_t datasize, vme_swap_t swap, | |
955 | int nsegments, vme_size_t maxsegsz, | 955 | int nsegments, vme_size_t maxsegsz, | |
956 | vme_addr_t boundary, int flags, | 956 | vme_addr_t boundary, int flags, | |
957 | bus_dmamap_t *dmamp) | 957 | bus_dmamap_t *dmamp) | |
958 | { | 958 | { | |
959 | struct sparcvme_softc *sc = (struct sparcvme_softc *)cookie; | 959 | struct sparcvme_softc *sc = cookie; | |
960 | bus_dmamap_t map; | 960 | bus_dmamap_t map; | |
961 | int error; | 961 | int error; | |
962 | 962 | |||
963 | /* Allocate a base map through parent bus ops */ | 963 | /* Allocate a base map through parent bus ops */ | |
964 | error = bus_dmamap_create(sc->sc_dmatag, size, nsegments, maxsegsz, | 964 | error = bus_dmamap_create(sc->sc_dmatag, size, nsegments, maxsegsz, | |
965 | boundary, flags, &map); | 965 | boundary, flags, &map); | |
966 | if (error != 0) | 966 | if (error != 0) | |
967 | return (error); | 967 | return (error); | |
968 | 968 | |||
969 | /* | 969 | /* | |
970 | * Each I/O cache line maps to a 8K section of VME DVMA space, so | 970 | * Each I/O cache line maps to a 8K section of VME DVMA space, so | |
971 | * we must ensure that DVMA alloctions are always 8K aligned. | 971 | * we must ensure that DVMA alloctions are always 8K aligned. | |
972 | */ | 972 | */ | |
@@ -986,27 +986,27 @@ sparc_vct_iommu_dmamap_create(void *cook | @@ -986,27 +986,27 @@ sparc_vct_iommu_dmamap_create(void *cook | |||
986 | map->_dm_ex_end = VME_IOMMU_DVMA_AM32_END; | 986 | map->_dm_ex_end = VME_IOMMU_DVMA_AM32_END; | |
987 | break; | 987 | break; | |
988 | } | 988 | } | |
989 | 989 | |||
990 | *dmamp = map; | 990 | *dmamp = map; | |
991 | return (0); | 991 | return (0); | |
992 | } | 992 | } | |
993 | 993 | |||
994 | static int | 994 | static int | |
995 | sparc_vme_iommu_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, | 995 | sparc_vme_iommu_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, | |
996 | void *buf, bus_size_t buflen, | 996 | void *buf, bus_size_t buflen, | |
997 | struct proc *p, int flags) | 997 | struct proc *p, int flags) | |
998 | { | 998 | { | |
999 | struct sparcvme_softc *sc = (struct sparcvme_softc *)t->_cookie; | 999 | struct sparcvme_softc *sc = t->_cookie; | |
1000 | volatile uint32_t *ioctags; | 1000 | volatile uint32_t *ioctags; | |
1001 | int error; | 1001 | int error; | |
1002 | 1002 | |||
1003 | /* Round request to a multiple of the I/O cache size */ | 1003 | /* Round request to a multiple of the I/O cache size */ | |
1004 | buflen = (buflen + VME_IOC_PAGESZ - 1) & -VME_IOC_PAGESZ; | 1004 | buflen = (buflen + VME_IOC_PAGESZ - 1) & -VME_IOC_PAGESZ; | |
1005 | error = bus_dmamap_load(sc->sc_dmatag, map, buf, buflen, p, flags); | 1005 | error = bus_dmamap_load(sc->sc_dmatag, map, buf, buflen, p, flags); | |
1006 | if (error != 0) | 1006 | if (error != 0) | |
1007 | return (error); | 1007 | return (error); | |
1008 | 1008 | |||
1009 | /* Allocate I/O cache entries for this range */ | 1009 | /* Allocate I/O cache entries for this range */ | |
1010 | ioctags = sc->sc_ioctags + VME_IOC_LINE(map->dm_segs[0].ds_addr); | 1010 | ioctags = sc->sc_ioctags + VME_IOC_LINE(map->dm_segs[0].ds_addr); | |
1011 | while (buflen > 0) { | 1011 | while (buflen > 0) { | |
1012 | *ioctags = VME_IOC_IC | VME_IOC_W; | 1012 | *ioctags = VME_IOC_IC | VME_IOC_W; | |
@@ -1017,27 +1017,27 @@ sparc_vme_iommu_dmamap_load(bus_dma_tag_ | @@ -1017,27 +1017,27 @@ sparc_vme_iommu_dmamap_load(bus_dma_tag_ | |||
1017 | /* | 1017 | /* | |
1018 | * Adjust DVMA address to VME view. | 1018 | * Adjust DVMA address to VME view. | |
1019 | * Note: the DVMA base address is the same for all | 1019 | * Note: the DVMA base address is the same for all | |
1020 | * VME address spaces. | 1020 | * VME address spaces. | |
1021 | */ | 1021 | */ | |
1022 | map->dm_segs[0].ds_addr -= VME_IOMMU_DVMA_BASE; | 1022 | map->dm_segs[0].ds_addr -= VME_IOMMU_DVMA_BASE; | |
1023 | return (0); | 1023 | return (0); | |
1024 | } | 1024 | } | |
1025 | 1025 | |||
1026 | 1026 | |||
1027 | static void | 1027 | static void | |
1028 | sparc_vme_iommu_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map) | 1028 | sparc_vme_iommu_dmamap_unload(bus_dma_tag_t t, bus_dmamap_t map) | |
1029 | { | 1029 | { | |
1030 | struct sparcvme_softc *sc = (struct sparcvme_softc *)t->_cookie; | 1030 | struct sparcvme_softc *sc = t->_cookie; | |
1031 | volatile uint32_t *flushregs; | 1031 | volatile uint32_t *flushregs; | |
1032 | int len; | 1032 | int len; | |
1033 | 1033 | |||
1034 | /* Go from VME to CPU view */ | 1034 | /* Go from VME to CPU view */ | |
1035 | map->dm_segs[0].ds_addr += VME_IOMMU_DVMA_BASE; | 1035 | map->dm_segs[0].ds_addr += VME_IOMMU_DVMA_BASE; | |
1036 | 1036 | |||
1037 | /* Flush VME I/O cache */ | 1037 | /* Flush VME I/O cache */ | |
1038 | len = map->dm_segs[0]._ds_sgsize; | 1038 | len = map->dm_segs[0]._ds_sgsize; | |
1039 | flushregs = sc->sc_iocflush + VME_IOC_LINE(map->dm_segs[0].ds_addr); | 1039 | flushregs = sc->sc_iocflush + VME_IOC_LINE(map->dm_segs[0].ds_addr); | |
1040 | while (len > 0) { | 1040 | while (len > 0) { | |
1041 | *flushregs = 0; | 1041 | *flushregs = 0; | |
1042 | flushregs += VME_IOC_LINESZ/sizeof(*flushregs); | 1042 | flushregs += VME_IOC_LINESZ/sizeof(*flushregs); | |
1043 | len -= VME_IOC_PAGESZ; | 1043 | len -= VME_IOC_PAGESZ; | |
@@ -1058,18 +1058,18 @@ sparc_vme_iommu_dmamap_sync(bus_dma_tag_ | @@ -1058,18 +1058,18 @@ sparc_vme_iommu_dmamap_sync(bus_dma_tag_ | |||
1058 | { | 1058 | { | |
1059 | 1059 | |||
1060 | /* | 1060 | /* | |
1061 | * XXX Should perform cache flushes as necessary. | 1061 | * XXX Should perform cache flushes as necessary. | |
1062 | */ | 1062 | */ | |
1063 | } | 1063 | } | |
1064 | #endif /* SUN4M */ | 1064 | #endif /* SUN4M */ | |
1065 | 1065 | |||
1066 | #if defined(SUN4) || defined(SUN4M) | 1066 | #if defined(SUN4) || defined(SUN4M) | |
1067 | static int | 1067 | static int | |
1068 | sparc_vme_dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, | 1068 | sparc_vme_dmamem_map(bus_dma_tag_t t, bus_dma_segment_t *segs, int nsegs, | |
1069 | size_t size, void **kvap, int flags) | 1069 | size_t size, void **kvap, int flags) | |
1070 | { | 1070 | { | |
1071 | struct sparcvme_softc *sc = (struct sparcvme_softc *)t->_cookie; | 1071 | struct sparcvme_softc *sc = t->_cookie; | |
1072 | 1072 | |||
1073 | return (bus_dmamem_map(sc->sc_dmatag, segs, nsegs, size, kvap, flags)); | 1073 | return (bus_dmamem_map(sc->sc_dmatag, segs, nsegs, size, kvap, flags)); | |
1074 | } | 1074 | } | |
1075 | #endif /* SUN4 || SUN4M */ | 1075 | #endif /* SUN4 || SUN4M */ |