sebuf.c revision 1.1 1 /* $NetBSD: sebuf.c,v 1.1 1997/10/17 03:39:47 gwr Exp $ */
2
3 /*-
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Gordon W. Ross.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * Sun3/E SCSI/Ethernet board. This is a VME board with some memory,
41 * an Intel Ether, and an NCR5380 SCSI with a cheap DMA engine.
42 * Note that the SCSI DMA engine can ONLY access the memory on
43 * the SE board, NOT the main memory, because it can not master
44 * VME transfers.
45 *
46 * This driver ("sebuf") is the parent of two child drivers:
47 * se: yet another variant of NCR 5380 SCSI H/W
48 * ie: yet anotehr variant of Intel 82586 Ethernet
49 *
50 * The job of this parent is to map the memory and partition it for
51 * the two children. This driver has no device nodes.
52 */
53
54 #include <sys/param.h>
55 #include <sys/systm.h>
56 #include <sys/conf.h>
57 #include <sys/device.h>
58 #include <sys/ioctl.h>
59 #include <sys/malloc.h>
60 #include <sys/mman.h>
61 #include <sys/proc.h>
62 #include <sys/tty.h>
63
64 #include <vm/vm.h>
65
66 #include <machine/autoconf.h>
67 #include <machine/cpu.h>
68
69 #include "sereg.h"
70 #include "sevar.h"
71
72 struct sebuf_softc {
73 struct device sc_dev; /* base device (required) */
74 struct sebuf_regs *sc_regs;
75 };
76
77 /*
78 * Autoconfig attachment
79 */
80
81 static int sebuf_match __P((struct device *, struct cfdata *, void *));
82 static void sebuf_attach __P((struct device *, struct device *, void *));
83 static int sebuf_print __P((void *, const char *));
84
85 struct cfattach sebuf_ca = {
86 sizeof(struct sebuf_softc), sebuf_match, sebuf_attach
87 };
88
89 struct cfdriver sebuf_cd = {
90 NULL, "sebuf", DV_DULL
91 };
92
93
94 static int
95 sebuf_match(parent, cf, args)
96 struct device *parent;
97 struct cfdata *cf;
98 void *args;
99 {
100 struct confargs *ca = args;
101 int x;
102
103 if (ca->ca_paddr == -1)
104 return (0);
105
106 /* Is it there at all? */
107 x = bus_peek(ca->ca_bustype, ca->ca_paddr, 2);
108 if (x == -1)
109 return (0);
110
111 /* How about the middle of the IE buffer? */
112 x = bus_peek(ca->ca_bustype, ca->ca_paddr + 0x18000, 2);
113 if (x == -1)
114 return (0);
115
116 /* Default interrupt priority always splbio==2 */
117 if (ca->ca_intpri == -1)
118 ca->ca_intpri = 2;
119
120 return (1);
121 }
122
123 static void
124 sebuf_attach(parent, self, args)
125 struct device *parent, *self;
126 void *args;
127 {
128 struct sebuf_softc *sc = (struct sebuf_softc *)self;
129 struct confargs *ca = args;
130 struct sebuf_attach_args aa;
131 struct sebuf_regs *regs;
132
133 if (ca->ca_intpri != 2)
134 panic("sebuf: bad level");
135
136 /* Map in the whole board. */
137 regs = (struct sebuf_regs *)
138 bus_mapin(ca->ca_bustype, ca->ca_paddr,
139 sizeof(struct sebuf_regs));
140 if (regs == NULL)
141 panic("sebuf_attach");
142 sc->sc_regs = regs;
143
144 /* Attach the SCSI child. */
145 aa.ca = *ca; /* structure copy */
146 aa.ca.ca_paddr = 0; /* prevent misuse */
147 aa.name = "se";
148 aa.buf = ®s->se_scsi_buf[0];
149 aa.blen = SE_NCRBUFSIZE;
150 aa.regs = ®s->se_scsi_regs;
151 (void) config_found(self, (void *) &aa, sebuf_print);
152
153 /* Attach the Ethernet child. */
154 aa.ca.ca_intpri++;
155 aa.ca.ca_intvec++;
156 aa.name = "ie";
157 aa.buf = ®s->se_eth_buf[0];
158 aa.blen = SE_IEBUFSIZE;
159 aa.regs = ®s->se_eth_regs;
160 (void) config_found(self, (void *) &aa, sebuf_print);
161 }
162
163 static int
164 sebuf_print(aux, name)
165 void *aux;
166 const char *name;
167 {
168
169 if (name != NULL)
170 printf("%s: ", name);
171
172 return UNCONF;
173 }
174