Annotation of sys/arch/sparc/dev/lebuffer.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: lebuffer.c,v 1.6 2006/06/02 20:00:54 miod Exp $ */
2: /* $NetBSD: lebuffer.c,v 1.3 1997/05/24 20:16:28 pk Exp $ */
3:
4: /*
5: * Copyright (c) 1996 Paul Kranenburg. All rights reserved.
6: *
7: * Redistribution and use in source and binary forms, with or without
8: * modification, are permitted provided that the following conditions
9: * are met:
10: * 1. Redistributions of source code must retain the above copyright
11: * notice, this list of conditions and the following disclaimer.
12: * 2. Redistributions in binary form must reproduce the above copyright
13: * notice, this list of conditions and the following disclaimer in the
14: * documentation and/or other materials provided with the distribution.
15: * 3. All advertising materials mentioning features or use of this software
16: * must display the following acknowledgement:
17: * This product includes software developed by Peter Galbavy.
18: * 4. The name of the author may not be used to endorse or promote products
19: * derived from this software without specific prior written permission.
20: *
21: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31: */
32:
33: #include <sys/types.h>
34: #include <sys/param.h>
35: #include <sys/systm.h>
36: #include <sys/kernel.h>
37: #include <sys/errno.h>
38: #include <sys/ioctl.h>
39: #include <sys/device.h>
40: #include <sys/malloc.h>
41: #include <sys/buf.h>
42: #include <sys/proc.h>
43: #include <sys/user.h>
44:
45: #include <sparc/autoconf.h>
46: #include <sparc/cpu.h>
47:
48: #include <sparc/dev/sbusvar.h>
49: #include <sparc/dev/lebuffervar.h>
50: #include <sparc/dev/dmareg.h>/*XXX*/
51:
52: int lebufprint(void *, const char *);
53: int lebufmatch(struct device *, void *, void *);
54: void lebufattach(struct device *, struct device *, void *);
55:
56: struct cfattach lebuffer_ca = {
57: sizeof(struct lebuf_softc), lebufmatch, lebufattach
58: };
59:
60: struct cfdriver lebuffer_cd = {
61: NULL, "lebuffer", DV_DULL
62: };
63:
64: int
65: lebufprint(aux, name)
66: void *aux;
67: const char *name;
68: {
69: register struct confargs *ca = aux;
70:
71: if (name)
72: printf("[%s at %s]", ca->ca_ra.ra_name, name);
73: printf(" offset 0x%x", ca->ca_offset);
74: return (UNCONF);
75: }
76:
77: /*
78: * Match a lebuffer card in a slot capable of dma.
79: */
80: int
81: lebufmatch(parent, vcf, aux)
82: struct device *parent;
83: void *vcf, *aux;
84: {
85: struct cfdata *cf = vcf;
86: struct confargs *ca = aux;
87: register struct romaux *ra = &ca->ca_ra;
88:
89: if (strcmp(cf->cf_driver->cd_name, ra->ra_name))
90: return(0);
91:
92: if (!sbus_testdma((struct sbus_softc *)parent, ca))
93: return(0);
94:
95: return (1);
96: }
97:
98: /*
99: * Attach all the sub-devices we can find
100: */
101: void
102: lebufattach(parent, self, aux)
103: struct device *parent, *self;
104: void *aux;
105: {
106: #if defined(SUN4C) || defined(SUN4M)
107: register struct confargs *ca = aux;
108: struct lebuf_softc *sc = (void *)self;
109: int node;
110: struct confargs oca;
111: char *name;
112: int sbusburst;
113:
114: if (ca->ca_ra.ra_vaddr == NULL || ca->ca_ra.ra_nvaddrs == 0)
115: ca->ca_ra.ra_vaddr =
116: mapiodev(ca->ca_ra.ra_reg, 0, ca->ca_ra.ra_len);
117:
118: /*
119: * This device's "register space" is just a buffer where the
120: * Lance ring-buffers can be stored. Note the buffer's location
121: * and size, so the `le' driver can pick them up.
122: */
123: sc->sc_buffer = (caddr_t)ca->ca_ra.ra_vaddr;
124: sc->sc_bufsiz = ca->ca_ra.ra_len;
125:
126: /*
127: * Get transfer burst size from PROM
128: */
129: sbusburst = ((struct sbus_softc *)parent)->sc_burst;
130: if (sbusburst == 0)
131: sbusburst = SBUS_BURST_32 - 1; /* 1->16 */
132:
133: sc->sc_burst = getpropint(ca->ca_ra.ra_node, "burst-sizes", -1);
134: if (sc->sc_burst == -1)
135: /* take SBus burst sizes */
136: sc->sc_burst = sbusburst;
137:
138: /* Clamp at parent's burst sizes */
139: sc->sc_burst &= sbusburst;
140:
141: printf(": %dK memory\n", sc->sc_bufsiz / 1024);
142:
143: node = sc->sc_node = ca->ca_ra.ra_node;
144:
145: /* Propagate bootpath */
146: if (ca->ca_ra.ra_bp != NULL)
147: oca.ca_ra.ra_bp = ca->ca_ra.ra_bp + 1;
148: else
149: oca.ca_ra.ra_bp = NULL;
150:
151: /* search through children */
152: for (node = firstchild(node); node; node = nextsibling(node)) {
153: name = getpropstring(node, "name");
154: if (!romprop(&oca.ca_ra, name, node))
155: continue;
156:
157: sbus_translate(parent, &oca);
158: oca.ca_bustype = BUS_SBUS;
159: (void) config_found(&sc->sc_dev, (void *)&oca, lebufprint);
160: }
161: #endif /* SUN4C || SUN4M */
162: }
CVSweb