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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
/* $OpenBSD: devopen.c,v 1.4 2008/08/26 18:36:21 miod Exp $ */
/* $NetBSD: devopen.c,v 1.10 2002/05/24 21:40:59 ragge Exp $ */
/*
* Copyright (c) 1997 Ludd, University of Lule}, Sweden.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed at Ludd, University of
* Lule}, Sweden and its contributors.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <lib/libsa/stand.h>
#include "machine/rpb.h"
#include "machine/sid.h"
#include "machine/pte.h"
#define VAX780 1
#include "machine/ka750.h"
#include <arch/vax/bi/bireg.h>
#include "vaxstand.h"
int atoi(char *);
int nexaddr, csrbase;
int
devopen(f, fname, file)
struct open_file *f;
const char *fname;
char **file;
{
int dev, unit, ctlr, part, adapt, i, a[4], x;
int *mapregs;
struct devsw *dp;
extern int cnvtab[];
char *s, *c;
part = 0;
/*
* Adaptor and controller are normally zero (or uninteresting),
* but we need to do some conversion here anyway (if it's a
* manual boot, but that's checked by the device driver).
* Set them to -1 to tell if it's a set number or default.
*/
dev = bootrpb.devtyp;
unit = bootrpb.unit;
adapt = ctlr = -1;
if (dev == BDEV_KDB)
dev = BDEV_UDA; /* use the same driver */
for (i = 0, dp = 0; i < ndevs; i++)
if (cnvtab[i] == dev)
dp = devsw + i;
if ((s = index((char *)fname, '('))) {
*s++ = 0;
for (i = 0, dp = devsw; i < ndevs; i++, dp++)
if (dp->dv_name && strcmp(dp->dv_name, fname) == 0)
break;
if (i == ndevs) {
printf("No such device - Configured devices are:\n");
for (dp = devsw, i = 0; i < ndevs; i++, dp++)
if (dp->dv_name && (i == 0 ||
strcmp(dp->dv_name, (dp[-1]).dv_name) != 0))
printf(" %s", dp->dv_name);
printf("\n");
return EINVAL;
}
dev = cnvtab[i];
if ((c = index(s, ')')) == 0)
goto usage;
*c++ = 0;
/*
* If the user has specified sd(), we need to pick the
* correct BDEV_SDx value, depending on the machine type.
*/
if (dev == BDEV_SD) {
switch (vax_boardtype) {
case VAX_BTYP_46:
case VAX_BTYP_48:
case VAX_BTYP_49:
case VAX_BTYP_1303:
dev = BDEV_SDN; /* asc(4) */
break;
case VAX_BTYP_60:
dev = BDEV_SDS; /* sii(4) */
break;
}
}
x = 0;
if (*s) do {
a[x++] = atoi(s);
while (*s >= '0' && *s <= '9')
s++;
if (*s != ',' && *s != 0)
goto usage;
} while (*s++);
if (x)
part = a[x - 1];
if (x > 1)
unit = a[x - 2];
if (x > 2)
ctlr = a[x - 3];
if (x > 3)
adapt = a[0];
*file = c;
} else {
*file = (char *)fname;
c = (char *)fname;
}
if (!dp->dv_open) {
printf("Can't open device type %d\n", dev);
return ENXIO;
}
f->f_dev = dp;
bootrpb.unit = unit;
bootrpb.devtyp = dev;
nexaddr = bootrpb.adpphy;
switch (vax_boardtype) {
case VAX_BTYP_750:
csrbase = (nexaddr == 0xf30000 ? 0xffe000 : 0xfbe000);
if (adapt < 0)
break;
nexaddr = (NEX750 + NEXSIZE * adapt);
csrbase = (adapt == 8 ? 0xffe000 : 0xfbe000);
break;
case VAX_BTYP_780:
case VAX_BTYP_790:
csrbase = 0x2007e000 + 0x40000 * ((nexaddr & 0x1e000) >> 13);
if (adapt < 0)
break;
nexaddr = ((int)NEX780 + NEXSIZE * adapt);
csrbase = 0x2007e000 + 0x40000 * adapt;
break;
case VAX_BTYP_9CC: /* 6000/200 */
case VAX_BTYP_9RR: /* 6000/400 */
case VAX_BTYP_1202: /* 6000/500 */
csrbase = 0;
if (ctlr < 0)
ctlr = bootrpb.adpphy & 15;
if (adapt < 0)
adapt = (bootrpb.adpphy >> 4) & 15;
nexaddr = BI_BASE(adapt, ctlr);
break;
case VAX_BTYP_8000:
case VAX_BTYP_8800:
case VAX_BTYP_8PS:
csrbase = 0; /* _may_ be a KDB */
nexaddr = bootrpb.csrphy;
if (ctlr < 0)
break;
if (adapt < 0)
nexaddr = (nexaddr & 0xff000000) + BI_NODE(ctlr);
else
nexaddr = BI_BASE(adapt, ctlr);
break;
case VAX_BTYP_610:
nexaddr = 0; /* No map regs */
csrbase = 0x20000000;
break;
case VAX_BTYP_VXT:
nexaddr = 0;
csrbase = bootrpb.csrphy;
break;
default:
nexaddr = 0; /* No map regs */
csrbase = 0x20000000;
/* Always map in the lowest 4M on qbus-based machines */
mapregs = (void *)0x20088000;
if (bootrpb.adpphy == 0x20087800)
for (i = 0; i < 8192; i++)
mapregs[i] = PG_V | i;
break;
}
#ifdef DEV_DEBUG
printf("rpb.type %d rpb.unit %d rpb.csr %lx rpb.adp %lx\n",
bootrpb.devtyp, bootrpb.unit, bootrpb.csrphy, bootrpb.adpphy);
printf("adapter %d ctlr %d unit %d part %d\n", adapt, ctlr, unit, part);
printf("nexaddr %x csrbase %x\n", nexaddr, csrbase);
#endif
return (*dp->dv_open)(f, adapt, ctlr, unit, part);
usage:
printf("usage: dev(adapter,controller,unit,partition)file -asd\n");
return EINVAL;
}
|