Sun Mar 23 16:40:12 2008 UTC ()
Split device_t and softc for pci(4).


(cube)
diff -r1.114 -r1.115 src/sys/dev/pci/pci.c
diff -r1.14 -r1.15 src/sys/dev/pci/pci_usrreq.c
diff -r1.78 -r1.79 src/sys/dev/pci/pcivar.h

cvs diff -r1.114 -r1.115 src/sys/dev/pci/pci.c (expand / switch to unified diff)

--- src/sys/dev/pci/pci.c 2008/03/21 07:47:43 1.114
+++ src/sys/dev/pci/pci.c 2008/03/23 16:40:12 1.115
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pci.c,v 1.114 2008/03/21 07:47:43 dyoung Exp $ */ 1/* $NetBSD: pci.c,v 1.115 2008/03/23 16:40:12 cube Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1995, 1996, 1997, 1998 4 * Copyright (c) 1995, 1996, 1997, 1998
5 * Christopher G. Demetriou. All rights reserved. 5 * Christopher G. Demetriou. All rights reserved.
6 * Copyright (c) 1994 Charles M. Hannum. All rights reserved. 6 * Copyright (c) 1994 Charles M. Hannum. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -26,27 +26,27 @@ @@ -26,27 +26,27 @@
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34/* 34/*
35 * PCI bus autoconfiguration. 35 * PCI bus autoconfiguration.
36 */ 36 */
37 37
38#include <sys/cdefs.h> 38#include <sys/cdefs.h>
39__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.114 2008/03/21 07:47:43 dyoung Exp $"); 39__KERNEL_RCSID(0, "$NetBSD: pci.c,v 1.115 2008/03/23 16:40:12 cube Exp $");
40 40
41#include "opt_pci.h" 41#include "opt_pci.h"
42 42
43#include <sys/param.h> 43#include <sys/param.h>
44#include <sys/malloc.h> 44#include <sys/malloc.h>
45#include <sys/systm.h> 45#include <sys/systm.h>
46#include <sys/device.h> 46#include <sys/device.h>
47 47
48#include <dev/pci/pcireg.h> 48#include <dev/pci/pcireg.h>
49#include <dev/pci/pcivar.h> 49#include <dev/pci/pcivar.h>
50#include <dev/pci/pcidevs.h> 50#include <dev/pci/pcidevs.h>
51 51
52#include <uvm/uvm_extern.h> 52#include <uvm/uvm_extern.h>
@@ -101,27 +101,27 @@ int pci_enumerate_bus(struct pci_softc * @@ -101,27 +101,27 @@ int pci_enumerate_bus(struct pci_softc *
101static int 101static int
102pcirescan(device_t self, const char *ifattr, const int *locators) 102pcirescan(device_t self, const char *ifattr, const int *locators)
103{ 103{
104 struct pci_softc *sc = device_private(self); 104 struct pci_softc *sc = device_private(self);
105 105
106 KASSERT(ifattr && !strcmp(ifattr, "pci")); 106 KASSERT(ifattr && !strcmp(ifattr, "pci"));
107 KASSERT(locators); 107 KASSERT(locators);
108 108
109 pci_enumerate_bus(sc, locators, NULL, NULL); 109 pci_enumerate_bus(sc, locators, NULL, NULL);
110 return 0; 110 return 0;
111} 111}
112 112
113static int 113static int
114pcimatch(device_t parent, struct cfdata *cf, void *aux) 114pcimatch(device_t parent, cfdata_t cf, void *aux)
115{ 115{
116 struct pcibus_attach_args *pba = aux; 116 struct pcibus_attach_args *pba = aux;
117 117
118 /* Check the locators */ 118 /* Check the locators */
119 if (cf->cf_loc[PCIBUSCF_BUS] != PCIBUSCF_BUS_DEFAULT && 119 if (cf->cf_loc[PCIBUSCF_BUS] != PCIBUSCF_BUS_DEFAULT &&
120 cf->cf_loc[PCIBUSCF_BUS] != pba->pba_bus) 120 cf->cf_loc[PCIBUSCF_BUS] != pba->pba_bus)
121 return (0); 121 return (0);
122 122
123 /* sanity */ 123 /* sanity */
124 if (pba->pba_bus < 0 || pba->pba_bus > 255) 124 if (pba->pba_bus < 0 || pba->pba_bus > 255)
125 return (0); 125 return (0);
126 126
127 /* 127 /*
@@ -132,49 +132,51 @@ pcimatch(device_t parent, struct cfdata  @@ -132,49 +132,51 @@ pcimatch(device_t parent, struct cfdata
132} 132}
133 133
134static void 134static void
135pciattach(device_t parent, device_t self, void *aux) 135pciattach(device_t parent, device_t self, void *aux)
136{ 136{
137 struct pcibus_attach_args *pba = aux; 137 struct pcibus_attach_args *pba = aux;
138 struct pci_softc *sc = device_private(self); 138 struct pci_softc *sc = device_private(self);
139 int io_enabled, mem_enabled, mrl_enabled, mrm_enabled, mwi_enabled; 139 int io_enabled, mem_enabled, mrl_enabled, mrm_enabled, mwi_enabled;
140 const char *sep = ""; 140 const char *sep = "";
141 static const int wildcard[PCICF_NLOCS] = { 141 static const int wildcard[PCICF_NLOCS] = {
142 PCICF_DEV_DEFAULT, PCICF_FUNCTION_DEFAULT 142 PCICF_DEV_DEFAULT, PCICF_FUNCTION_DEFAULT
143 }; 143 };
144 144
 145 sc->sc_dev = self;
 146
145 pci_attach_hook(parent, self, pba); 147 pci_attach_hook(parent, self, pba);
146 148
147 aprint_naive("\n"); 149 aprint_naive("\n");
148 aprint_normal("\n"); 150 aprint_normal("\n");
149 151
150 io_enabled = (pba->pba_flags & PCI_FLAGS_IO_ENABLED); 152 io_enabled = (pba->pba_flags & PCI_FLAGS_IO_ENABLED);
151 mem_enabled = (pba->pba_flags & PCI_FLAGS_MEM_ENABLED); 153 mem_enabled = (pba->pba_flags & PCI_FLAGS_MEM_ENABLED);
152 mrl_enabled = (pba->pba_flags & PCI_FLAGS_MRL_OKAY); 154 mrl_enabled = (pba->pba_flags & PCI_FLAGS_MRL_OKAY);
153 mrm_enabled = (pba->pba_flags & PCI_FLAGS_MRM_OKAY); 155 mrm_enabled = (pba->pba_flags & PCI_FLAGS_MRM_OKAY);
154 mwi_enabled = (pba->pba_flags & PCI_FLAGS_MWI_OKAY); 156 mwi_enabled = (pba->pba_flags & PCI_FLAGS_MWI_OKAY);
155 157
156 if (io_enabled == 0 && mem_enabled == 0) { 158 if (io_enabled == 0 && mem_enabled == 0) {
157 aprint_error_dev(self, "no spaces enabled!\n"); 159 aprint_error_dev(self, "no spaces enabled!\n");
158 goto fail; 160 goto fail;
159 } 161 }
160 162
161#define PRINT(str) \ 163#define PRINT(str) \
162do { \ 164do { \
163 aprint_verbose("%s%s", sep, str); \ 165 aprint_verbose("%s%s", sep, str); \
164 sep = ", "; \ 166 sep = ", "; \
165} while (/*CONSTCOND*/0) 167} while (/*CONSTCOND*/0)
166 168
167 aprint_verbose_dev(self, " "); 169 aprint_verbose_dev(self, "");
168 170
169 if (io_enabled) 171 if (io_enabled)
170 PRINT("i/o space"); 172 PRINT("i/o space");
171 if (mem_enabled) 173 if (mem_enabled)
172 PRINT("memory space"); 174 PRINT("memory space");
173 aprint_verbose(" enabled"); 175 aprint_verbose(" enabled");
174 176
175 if (mrl_enabled || mrm_enabled || mwi_enabled) { 177 if (mrl_enabled || mrm_enabled || mwi_enabled) {
176 if (mrl_enabled) 178 if (mrl_enabled)
177 PRINT("rd/line"); 179 PRINT("rd/line");
178 if (mrm_enabled) 180 if (mrm_enabled)
179 PRINT("rd/mult"); 181 PRINT("rd/mult");
180 if (mwi_enabled) 182 if (mwi_enabled)
@@ -188,29 +190,29 @@ do { \ @@ -188,29 +190,29 @@ do { \
188 190
189 sc->sc_iot = pba->pba_iot; 191 sc->sc_iot = pba->pba_iot;
190 sc->sc_memt = pba->pba_memt; 192 sc->sc_memt = pba->pba_memt;
191 sc->sc_dmat = pba->pba_dmat; 193 sc->sc_dmat = pba->pba_dmat;
192 sc->sc_dmat64 = pba->pba_dmat64; 194 sc->sc_dmat64 = pba->pba_dmat64;
193 sc->sc_pc = pba->pba_pc; 195 sc->sc_pc = pba->pba_pc;
194 sc->sc_bus = pba->pba_bus; 196 sc->sc_bus = pba->pba_bus;
195 sc->sc_bridgetag = pba->pba_bridgetag; 197 sc->sc_bridgetag = pba->pba_bridgetag;
196 sc->sc_maxndevs = pci_bus_maxdevs(pba->pba_pc, pba->pba_bus); 198 sc->sc_maxndevs = pci_bus_maxdevs(pba->pba_pc, pba->pba_bus);
197 sc->sc_intrswiz = pba->pba_intrswiz; 199 sc->sc_intrswiz = pba->pba_intrswiz;
198 sc->sc_intrtag = pba->pba_intrtag; 200 sc->sc_intrtag = pba->pba_intrtag;
199 sc->sc_flags = pba->pba_flags; 201 sc->sc_flags = pba->pba_flags;
200 202
201 device_pmf_driver_set_child_register(&sc->sc_dev, pci_child_register); 203 device_pmf_driver_set_child_register(sc->sc_dev, pci_child_register);
202 204
203 pcirescan(&sc->sc_dev, "pci", wildcard); 205 pcirescan(sc->sc_dev, "pci", wildcard);
204 206
205fail: 207fail:
206 if (!pmf_device_register(self, NULL, NULL)) 208 if (!pmf_device_register(self, NULL, NULL))
207 aprint_error_dev(self, "couldn't establish power handler\n"); 209 aprint_error_dev(self, "couldn't establish power handler\n");
208} 210}
209 211
210static int 212static int
211pcidetach(device_t self, int flags) 213pcidetach(device_t self, int flags)
212{ 214{
213 int rc; 215 int rc;
214 216
215 if ((rc = config_detach_children(self, flags)) != 0) 217 if ((rc = config_detach_children(self, flags)) != 0)
216 return rc; 218 return rc;
@@ -351,50 +353,50 @@ pci_probe_device(struct pci_softc *sc, p @@ -351,50 +353,50 @@ pci_probe_device(struct pci_softc *sc, p
351 pa.pa_intrpin = /* XXX */ 353 pa.pa_intrpin = /* XXX */
352 ((pin + pa.pa_intrswiz - 1) % 4) + 1; 354 ((pin + pa.pa_intrswiz - 1) % 4) + 1;
353 } 355 }
354 pa.pa_intrline = PCI_INTERRUPT_LINE(intr); 356 pa.pa_intrline = PCI_INTERRUPT_LINE(intr);
355 357
356 if (match != NULL) { 358 if (match != NULL) {
357 ret = (*match)(&pa); 359 ret = (*match)(&pa);
358 if (ret != 0 && pap != NULL) 360 if (ret != 0 && pap != NULL)
359 *pap = pa; 361 *pap = pa;
360 } else { 362 } else {
361 locs[PCICF_DEV] = device; 363 locs[PCICF_DEV] = device;
362 locs[PCICF_FUNCTION] = function; 364 locs[PCICF_FUNCTION] = function;
363 365
364 subdev = config_found_sm_loc(&sc->sc_dev, "pci", locs, &pa, 366 subdev = config_found_sm_loc(sc->sc_dev, "pci", locs, &pa,
365 pciprint, config_stdsubmatch); 367 pciprint, config_stdsubmatch);
366 sc->PCI_SC_DEVICESC(device, function) = subdev; 368 sc->PCI_SC_DEVICESC(device, function) = subdev;
367 ret = (subdev != NULL); 369 ret = (subdev != NULL);
368 } 370 }
369 371
370 return (ret); 372 return (ret);
371} 373}
372 374
373static void 375static void
374pcidevdetached(device_t self, device_t child) 376pcidevdetached(device_t self, device_t child)
375{ 377{
376 struct pci_softc *psc = device_private(self); 378 struct pci_softc *psc = device_private(self);
377 int d, f; 379 int d, f;
378 380
379 d = device_locator(child, PCICF_DEV); 381 d = device_locator(child, PCICF_DEV);
380 f = device_locator(child, PCICF_FUNCTION); 382 f = device_locator(child, PCICF_FUNCTION);
381 383
382 KASSERT(psc->PCI_SC_DEVICESC(d, f) == child); 384 KASSERT(psc->PCI_SC_DEVICESC(d, f) == child);
383 385
384 psc->PCI_SC_DEVICESC(d, f) = 0; 386 psc->PCI_SC_DEVICESC(d, f) = 0;
385} 387}
386 388
387CFATTACH_DECL2(pci, sizeof(struct pci_softc), 389CFATTACH_DECL2_NEW(pci, sizeof(struct pci_softc),
388 pcimatch, pciattach, pcidetach, NULL, pcirescan, pcidevdetached); 390 pcimatch, pciattach, pcidetach, NULL, pcirescan, pcidevdetached);
389 391
390int 392int
391pci_get_capability(pci_chipset_tag_t pc, pcitag_t tag, int capid, 393pci_get_capability(pci_chipset_tag_t pc, pcitag_t tag, int capid,
392 int *offset, pcireg_t *value) 394 int *offset, pcireg_t *value)
393{ 395{
394 pcireg_t reg; 396 pcireg_t reg;
395 unsigned int ofs; 397 unsigned int ofs;
396 398
397 reg = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG); 399 reg = pci_conf_read(pc, tag, PCI_COMMAND_STATUS_REG);
398 if (!(reg & PCI_STATUS_CAPLIST_SUPPORT)) 400 if (!(reg & PCI_STATUS_CAPLIST_SUPPORT))
399 return (0); 401 return (0);
400 402
@@ -437,27 +439,27 @@ pci_find_device(struct pci_attach_args * @@ -437,27 +439,27 @@ pci_find_device(struct pci_attach_args *
437 int (*match)(struct pci_attach_args *)) 439 int (*match)(struct pci_attach_args *))
438{ 440{
439 extern struct cfdriver pci_cd; 441 extern struct cfdriver pci_cd;
440 device_t pcidev; 442 device_t pcidev;
441 int i; 443 int i;
442 static const int wildcard[2] = { 444 static const int wildcard[2] = {
443 PCICF_DEV_DEFAULT, 445 PCICF_DEV_DEFAULT,
444 PCICF_FUNCTION_DEFAULT 446 PCICF_FUNCTION_DEFAULT
445 }; 447 };
446 448
447 for (i = 0; i < pci_cd.cd_ndevs; i++) { 449 for (i = 0; i < pci_cd.cd_ndevs; i++) {
448 pcidev = pci_cd.cd_devs[i]; 450 pcidev = pci_cd.cd_devs[i];
449 if (pcidev != NULL && 451 if (pcidev != NULL &&
450 pci_enumerate_bus((struct pci_softc *)pcidev, wildcard, 452 pci_enumerate_bus(device_private(pcidev), wildcard,
451 match, pa) != 0) 453 match, pa) != 0)
452 return (1); 454 return (1);
453 } 455 }
454 return (0); 456 return (0);
455} 457}
456 458
457#ifndef PCI_MACHDEP_ENUMERATE_BUS 459#ifndef PCI_MACHDEP_ENUMERATE_BUS
458/* 460/*
459 * Generic PCI bus enumeration routine. Used unless machine-dependent 461 * Generic PCI bus enumeration routine. Used unless machine-dependent
460 * code needs to provide something else. 462 * code needs to provide something else.
461 */ 463 */
462int 464int
463pci_enumerate_bus(struct pci_softc *sc, const int *locators, 465pci_enumerate_bus(struct pci_softc *sc, const int *locators,

cvs diff -r1.14 -r1.15 src/sys/dev/pci/pci_usrreq.c (expand / switch to unified diff)

--- src/sys/dev/pci/pci_usrreq.c 2007/03/04 06:02:25 1.14
+++ src/sys/dev/pci/pci_usrreq.c 2008/03/23 16:40:12 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pci_usrreq.c,v 1.14 2007/03/04 06:02:25 christos Exp $ */ 1/* $NetBSD: pci_usrreq.c,v 1.15 2008/03/23 16:40:12 cube Exp $ */
2 2
3/* 3/*
4 * Copyright 2001 Wasabi Systems, Inc. 4 * Copyright 2001 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Jason R. Thorpe for Wasabi Systems, Inc. 7 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -30,60 +30,60 @@ @@ -30,60 +30,60 @@
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE. 35 * POSSIBILITY OF SUCH DAMAGE.
36 */ 36 */
37 37
38/* 38/*
39 * User -> kernel interface for PCI bus access. 39 * User -> kernel interface for PCI bus access.
40 */ 40 */
41 41
42#include <sys/cdefs.h> 42#include <sys/cdefs.h>
43__KERNEL_RCSID(0, "$NetBSD: pci_usrreq.c,v 1.14 2007/03/04 06:02:25 christos Exp $"); 43__KERNEL_RCSID(0, "$NetBSD: pci_usrreq.c,v 1.15 2008/03/23 16:40:12 cube Exp $");
44 44
45#include <sys/param.h> 45#include <sys/param.h>
46#include <sys/conf.h> 46#include <sys/conf.h>
47#include <sys/device.h> 47#include <sys/device.h>
48#include <sys/ioctl.h> 48#include <sys/ioctl.h>
49#include <sys/proc.h> 49#include <sys/proc.h>
50#include <sys/systm.h> 50#include <sys/systm.h>
51#include <sys/errno.h> 51#include <sys/errno.h>
52#include <sys/fcntl.h> 52#include <sys/fcntl.h>
53 53
54#include <dev/pci/pcireg.h> 54#include <dev/pci/pcireg.h>
55#include <dev/pci/pcivar.h> 55#include <dev/pci/pcivar.h>
56#include <dev/pci/pciio.h> 56#include <dev/pci/pciio.h>
57 57
58static int 58static int
59pciopen(dev_t dev, int flags, int mode, 59pciopen(dev_t dev, int flags, int mode, struct lwp *l)
60 struct lwp *l) 
61{ 60{
62 struct pci_softc *sc; 61 device_t dv;
63 int unit; 62 int unit;
64 63
65 unit = minor(dev); 64 unit = minor(dev);
66 sc = device_lookup(&pci_cd, unit); 65 dv = device_lookup(&pci_cd, unit);
67 if (sc == NULL) 66 if (dv == NULL)
68 return (ENXIO); 67 return (ENXIO);
69 68
70 return (0); 69 return (0);
71} 70}
72 71
73static int 72static int
74pciioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l) 73pciioctl(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
75{ 74{
76 struct pci_softc *sc = device_lookup(&pci_cd, minor(dev)); 75 struct pci_softc *sc =
 76 device_lookup_private(&pci_cd, minor(dev));
77 struct pciio_bdf_cfgreg *bdfr = (void *) data; 77 struct pciio_bdf_cfgreg *bdfr = (void *) data;
78 struct pciio_businfo *binfo = (void *) data; 78 struct pciio_businfo *binfo = (void *) data;
79 pcitag_t tag; 79 pcitag_t tag;
80 80
81 switch (cmd) { 81 switch (cmd) {
82 case PCI_IOC_BDF_CFGREAD: 82 case PCI_IOC_BDF_CFGREAD:
83 case PCI_IOC_BDF_CFGWRITE: 83 case PCI_IOC_BDF_CFGWRITE:
84 if (bdfr->bus > 255 || bdfr->device >= sc->sc_maxndevs || 84 if (bdfr->bus > 255 || bdfr->device >= sc->sc_maxndevs ||
85 bdfr->function > 7) 85 bdfr->function > 7)
86 return (EINVAL); 86 return (EINVAL);
87 tag = pci_make_tag(sc->sc_pc, bdfr->bus, bdfr->device, 87 tag = pci_make_tag(sc->sc_pc, bdfr->bus, bdfr->device,
88 bdfr->function); 88 bdfr->function);
89 if (cmd == PCI_IOC_BDF_CFGREAD) 89 if (cmd == PCI_IOC_BDF_CFGREAD)
@@ -103,27 +103,27 @@ pciioctl(dev_t dev, u_long cmd, void *da @@ -103,27 +103,27 @@ pciioctl(dev_t dev, u_long cmd, void *da
103 break; 103 break;
104 104
105 default: 105 default:
106 return (ENOTTY); 106 return (ENOTTY);
107 } 107 }
108 108
109 return (0); 109 return (0);
110} 110}
111 111
112static paddr_t 112static paddr_t
113pcimmap(dev_t dev, off_t offset, int prot) 113pcimmap(dev_t dev, off_t offset, int prot)
114{ 114{
115#if 0 115#if 0
116 struct pci_softc *sc = device_lookup(&pci_cd, minor(dev)); 116 struct pci_softc *sc = device_lookup_private(&pci_cd, minor(dev));
117 117
118 /* 118 /*
119 * Since we allow mapping of the entire bus, we 119 * Since we allow mapping of the entire bus, we
120 * take the offset to be the address on the bus, 120 * take the offset to be the address on the bus,
121 * and pass 0 as the offset into that range. 121 * and pass 0 as the offset into that range.
122 * 122 *
123 * XXX Need a way to deal with linear/prefetchable/etc. 123 * XXX Need a way to deal with linear/prefetchable/etc.
124 */ 124 */
125 return (bus_space_mmap(sc->sc_memt, offset, 0, prot, 0)); 125 return (bus_space_mmap(sc->sc_memt, offset, 0, prot, 0));
126#else 126#else
127 /* XXX Consider this further. */ 127 /* XXX Consider this further. */
128 return (-1); 128 return (-1);
129#endif 129#endif

cvs diff -r1.78 -r1.79 src/sys/dev/pci/pcivar.h (expand / switch to unified diff)

--- src/sys/dev/pci/pcivar.h 2008/03/21 07:47:43 1.78
+++ src/sys/dev/pci/pcivar.h 2008/03/23 16:40:12 1.79
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pcivar.h,v 1.78 2008/03/21 07:47:43 dyoung Exp $ */ 1/* $NetBSD: pcivar.h,v 1.79 2008/03/23 16:40:12 cube Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved. 4 * Copyright (c) 1996, 1997 Christopher G. Demetriou. All rights reserved.
5 * Copyright (c) 1994 Charles M. Hannum. All rights reserved. 5 * Copyright (c) 1994 Charles M. Hannum. 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.
@@ -147,38 +147,38 @@ struct pci_quirkdata { @@ -147,38 +147,38 @@ struct pci_quirkdata {
147#define PCI_QUIRK_MULTIFUNCTION 1 147#define PCI_QUIRK_MULTIFUNCTION 1
148#define PCI_QUIRK_MONOFUNCTION 2 148#define PCI_QUIRK_MONOFUNCTION 2
149#define PCI_QUIRK_SKIP_FUNC(n) (4 << n) 149#define PCI_QUIRK_SKIP_FUNC(n) (4 << n)
150#define PCI_QUIRK_SKIP_FUNC0 PCI_QUIRK_SKIP_FUNC(0) 150#define PCI_QUIRK_SKIP_FUNC0 PCI_QUIRK_SKIP_FUNC(0)
151#define PCI_QUIRK_SKIP_FUNC1 PCI_QUIRK_SKIP_FUNC(1) 151#define PCI_QUIRK_SKIP_FUNC1 PCI_QUIRK_SKIP_FUNC(1)
152#define PCI_QUIRK_SKIP_FUNC2 PCI_QUIRK_SKIP_FUNC(2) 152#define PCI_QUIRK_SKIP_FUNC2 PCI_QUIRK_SKIP_FUNC(2)
153#define PCI_QUIRK_SKIP_FUNC3 PCI_QUIRK_SKIP_FUNC(3) 153#define PCI_QUIRK_SKIP_FUNC3 PCI_QUIRK_SKIP_FUNC(3)
154#define PCI_QUIRK_SKIP_FUNC4 PCI_QUIRK_SKIP_FUNC(4) 154#define PCI_QUIRK_SKIP_FUNC4 PCI_QUIRK_SKIP_FUNC(4)
155#define PCI_QUIRK_SKIP_FUNC5 PCI_QUIRK_SKIP_FUNC(5) 155#define PCI_QUIRK_SKIP_FUNC5 PCI_QUIRK_SKIP_FUNC(5)
156#define PCI_QUIRK_SKIP_FUNC6 PCI_QUIRK_SKIP_FUNC(6) 156#define PCI_QUIRK_SKIP_FUNC6 PCI_QUIRK_SKIP_FUNC(6)
157#define PCI_QUIRK_SKIP_FUNC7 PCI_QUIRK_SKIP_FUNC(7) 157#define PCI_QUIRK_SKIP_FUNC7 PCI_QUIRK_SKIP_FUNC(7)
158 158
159struct pci_softc { 159struct pci_softc {
160 struct device sc_dev; 160 device_t sc_dev;
161 bus_space_tag_t sc_iot, sc_memt; 161 bus_space_tag_t sc_iot, sc_memt;
162 bus_dma_tag_t sc_dmat; 162 bus_dma_tag_t sc_dmat;
163 bus_dma_tag_t sc_dmat64; 163 bus_dma_tag_t sc_dmat64;
164 pci_chipset_tag_t sc_pc; 164 pci_chipset_tag_t sc_pc;
165 int sc_bus, sc_maxndevs; 165 int sc_bus, sc_maxndevs;
166 pcitag_t *sc_bridgetag; 166 pcitag_t *sc_bridgetag;
167 u_int sc_intrswiz; 167 u_int sc_intrswiz;
168 pcitag_t sc_intrtag; 168 pcitag_t sc_intrtag;
169 int sc_flags; 169 int sc_flags;
170 /* accounting of child devices */ 170 /* accounting of child devices */
171 struct device *sc_devices[32*8]; 171 device_t sc_devices[32*8];
172#define PCI_SC_DEVICESC(d, f) sc_devices[(d) * 8 + (f)] 172#define PCI_SC_DEVICESC(d, f) sc_devices[(d) * 8 + (f)]
173}; 173};
174 174
175struct pci_conf_state { 175struct pci_conf_state {
176 pcireg_t reg[16]; 176 pcireg_t reg[16];
177}; 177};
178 178
179extern struct cfdriver pci_cd; 179extern struct cfdriver pci_cd;
180 180
181int pcibusprint(void *, const char *); 181int pcibusprint(void *, const char *);
182 182
183/* 183/*
184 * Configuration space access and utility functions. (Note that most, 184 * Configuration space access and utility functions. (Note that most,