This source file includes following definitions.
- twe_pci_match
- twe_pci_attach
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29 #include <sys/param.h>
30 #include <sys/systm.h>
31 #include <sys/kernel.h>
32 #include <sys/malloc.h>
33 #include <sys/device.h>
34
35 #include <dev/pci/pcidevs.h>
36 #include <dev/pci/pcivar.h>
37
38 #include <machine/bus.h>
39
40 #include <scsi/scsi_all.h>
41 #include <scsi/scsi_disk.h>
42 #include <scsi/scsiconf.h>
43
44 #include <dev/ic/twereg.h>
45 #include <dev/ic/twevar.h>
46
47 #define TWE_BAR 0x10
48
49 int twe_pci_match(struct device *, void *, void *);
50 void twe_pci_attach(struct device *, struct device *, void *);
51
52 struct cfattach twe_pci_ca = {
53 sizeof(struct twe_softc), twe_pci_match, twe_pci_attach
54 };
55
56 const struct pci_matchid twe_pci_devices[] = {
57 { PCI_VENDOR_3WARE, PCI_PRODUCT_3WARE_ESCALADE },
58 { PCI_VENDOR_3WARE, PCI_PRODUCT_3WARE_ESCALADE_ASIC }
59 };
60
61 int
62 twe_pci_match(parent, match, aux)
63 struct device *parent;
64 void *match;
65 void *aux;
66 {
67 return (pci_matchbyid((struct pci_attach_args *)aux, twe_pci_devices,
68 sizeof(twe_pci_devices)/sizeof(twe_pci_devices[0])));
69 }
70
71 void
72 twe_pci_attach(parent, self, aux)
73 struct device *parent, *self;
74 void *aux;
75 {
76 struct twe_softc *sc = (struct twe_softc *)self;
77 struct pci_attach_args *pa = aux;
78 pci_intr_handle_t ih;
79 const char *intrstr;
80 bus_size_t size;
81
82 if (pci_mapreg_map(pa, TWE_BAR, PCI_MAPREG_TYPE_IO, 0,
83 &sc->iot, &sc->ioh, NULL, &size, 0)) {
84 printf(": can't map controller i/o space\n");
85 return;
86 }
87 sc->dmat = pa->pa_dmat;
88
89 if (pci_intr_map(pa, &ih)) {
90 printf(": can't map interrupt\n");
91 bus_space_unmap(sc->iot, sc->ioh, size);
92 return;
93 }
94 intrstr = pci_intr_string(pa->pa_pc, ih);
95 sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_BIO, twe_intr, sc,
96 sc->sc_dev.dv_xname);
97 if (!sc->sc_ih) {
98 printf(": can't establish interrupt");
99 if (intrstr)
100 printf(" at %s", intrstr);
101 printf("\n");
102 bus_space_unmap(sc->iot, sc->ioh, size);
103 return;
104 }
105
106 printf(": %s\n%s", intrstr, sc->sc_dev.dv_xname);
107
108 if (twe_attach(sc)) {
109 pci_intr_disestablish(pa->pa_pc, sc->sc_ih);
110 sc->sc_ih = NULL;
111 bus_space_unmap(sc->iot, sc->ioh, size);
112 }
113 }