This source file includes following definitions.
- lebufprint
- lebufmatch
- lebufattach
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
30
31
32
33
34
35
36
37
38
39
40 #include <sys/cdefs.h>
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/kernel.h>
44 #include <sys/errno.h>
45 #include <sys/device.h>
46 #include <sys/malloc.h>
47
48 #include <machine/bus.h>
49 #include <machine/autoconf.h>
50 #include <machine/cpu.h>
51
52 #include <dev/sbus/sbusvar.h>
53 #include <dev/sbus/lebuffervar.h>
54
55 int lebufprint(void *, const char *);
56 int lebufmatch(struct device *, void *, void *);
57 void lebufattach(struct device *, struct device *, void *);
58
59 struct cfattach lebuffer_ca = {
60 sizeof(struct lebuf_softc), lebufmatch, lebufattach
61 };
62
63 int
64 lebufprint(void *aux, const char *busname)
65 {
66 struct sbus_attach_args *sa = aux;
67 bus_space_tag_t t = sa->sa_bustag;
68 struct lebuf_softc *sc = t->cookie;
69
70 sa->sa_bustag = sc->sc_bustag;
71 sbus_print(aux, busname);
72 sa->sa_bustag = t;
73 return (UNCONF);
74 }
75
76 int
77 lebufmatch(struct device *parent, void *vcf, void *aux)
78 {
79 struct sbus_attach_args *sa = aux;
80 struct cfdata *cf = vcf;
81
82 return (strcmp(cf->cf_driver->cd_name, sa->sa_name) == 0);
83 }
84
85
86
87
88 void
89 lebufattach(struct device *parent, struct device *self, void *aux)
90 {
91 struct sbus_attach_args *sa = aux;
92 struct lebuf_softc *sc = (void *)self;
93 int node;
94 int sbusburst;
95 struct sparc_bus_space_tag *sbt;
96 bus_space_handle_t bh;
97
98 sc->sc_bustag = sa->sa_bustag;
99 sc->sc_dmatag = sa->sa_dmatag;
100
101 if (sbus_bus_map(sa->sa_bustag,
102 sa->sa_slot, sa->sa_offset, sa->sa_size,
103 BUS_SPACE_MAP_LINEAR, 0, &bh) != 0) {
104 printf("%s: attach: cannot map registers\n", self->dv_xname);
105 return;
106 }
107
108
109
110
111
112
113 sc->sc_buffer = (void *)bus_space_vaddr(sa->sa_bustag, bh);
114 sc->sc_bufsiz = sa->sa_size;
115
116 node = sc->sc_node = sa->sa_node;
117
118
119
120
121 sbusburst = ((struct sbus_softc *)parent)->sc_burst;
122 if (sbusburst == 0)
123 sbusburst = SBUS_BURST_32 - 1;
124
125 sc->sc_burst = getpropint(node, "burst-sizes", -1);
126 if (sc->sc_burst == -1)
127
128 sc->sc_burst = sbusburst;
129
130
131 sc->sc_burst &= sbusburst;
132
133
134 sbt = malloc(sizeof(*sbt), M_DEVBUF, M_NOWAIT);
135 if (sbt == NULL) {
136 printf("%s: attach: out of memory\n", self->dv_xname);
137 return;
138 }
139 bzero(sbt, sizeof(*sbt));
140
141 printf(": %dK memory\n", sc->sc_bufsiz / 1024);
142
143 sbt->cookie = sc;
144 sbt->parent = sc->sc_bustag;
145 sbt->asi = sbt->parent->asi;
146 sbt->sasi = sbt->parent->sasi;
147
148
149 for (node = firstchild(node); node; node = nextsibling(node)) {
150 struct sbus_attach_args sa;
151 sbus_setup_attach_args((struct sbus_softc *)parent,
152 sbt, sc->sc_dmatag, node, &sa);
153 (void)config_found(&sc->sc_dev, (void *)&sa, lebufprint);
154 sbus_destroy_attach_args(&sa);
155 }
156 }