BSD 4_4 release
[unix-history] / usr / src / sys / hp300 / dev / rd_compat.c
CommitLineData
7e16cfa6
MH
1/*
2 * Copyright (c) 1988 University of Utah.
ad787160
C
3 * Copyright (c) 1982, 1990, 1993
4 * The Regents of the University of California. All rights reserved.
7e16cfa6
MH
5 *
6 * This code is derived from software contributed to Berkeley by
7 * the Systems Programming Group of the University of Utah Computer
8 * Science Department.
9 *
ad787160
C
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 University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
7e16cfa6
MH
37 *
38 * from: Utah $Hdr: rd_compat.c 1.1 92/12/21$
39 *
ad787160 40 * @(#)rd_compat.c 8.1 (Berkeley) 6/10/93
7e16cfa6
MH
41 */
42
43/*
44 * Compatibility for CS80 disks without disklabels.
45 */
46#include "rd.h"
47#if NRD > 0
48
49#include <sys/param.h>
50#include <sys/disklabel.h>
51#include <hp/dev/device.h>
52#include <hp300/dev/rdreg.h>
53#include <hp300/dev/rdvar.h>
54
55/*
56 * CS/80 partitions. We reserve the first cylinder for a LIF
57 * style boot directory (the 8k allowed in the BSD filesystem
58 * is just way too small). This boot area is outside of all but
59 * the C partition. This implies that you cannot use the C
60 * partition on a bootable disk since the filesystem would overlay
61 * the boot area. You must use the A partition.
62 *
63 * These maps support four basic layouts:
64 *
65 * A/B/G: This is the "traditional" setup for a bootable disk.
66 * A is the root partition, B the swap, and G a user partition.
67 * A/D/H: This is a setup for bootable systems requiring more swap
68 * (e.g. those who use HPCL). It has A as the root, D as a
69 * larger swap, and H as a smaller user partition.
70 * A/D/E/F: Similar to A/D/H with E and F breaking H into two partitions.
71 * E could be used for /usr and F for users.
72 * C: This gives a single, non-bootable, large user filesystem.
73 * Good for second drives on a machine (e.g. /usr/src).
74 */
75struct size {
76 daddr_t nblocks;
77 int cyloff;
78} rd7945A_sizes[8] = {
79 RDSZ(15904), 1, /* A=cyl 1 thru 142 */
80 RDSZ(20160), 143, /* B=cyl 143 thru 322 */
81 RDSZ(108416), 0, /* C=cyl 0 thru 967 */
82 RDSZ(40320), 143, /* D=cyl 143 thru 502 */
83 RDSZ(0), 0, /* E=<undefined> */
84 RDSZ(0), 0, /* F=<undefined> */
85 RDSZ(72240), 323, /* G=cyl 323 thru 967 */
86 RDSZ(52080), 503, /* H=cyl 503 thru 967 */
87}, rd9134D_sizes[8] = {
88 RDSZ(15936), 1, /* A=cyl 1 thru 166 */
89 RDSZ(13056), 167, /* B=cyl 167 thru 302 */
90 RDSZ(29088), 0, /* C=cyl 0 thru 302 */
91 RDSZ(0), 0, /* D=<undefined> */
92 RDSZ(0), 0, /* E=<undefined> */
93 RDSZ(0), 0, /* F=<undefined> */
94 RDSZ(0), 0, /* G=<undefined> */
95 RDSZ(0), 0, /* H=<undefined> */
96}, rd9122S_sizes[8] = {
97 RDSZ(0), 0, /* A=<undefined> */
98 RDSZ(0), 0, /* B=<undefined> */
99 RDSZ(1232), 0, /* C=cyl 0 thru 76 */
100 RDSZ(0), 0, /* D=<undefined> */
101 RDSZ(0), 0, /* E=<undefined> */
102 RDSZ(0), 0, /* F=<undefined> */
103 RDSZ(0), 0, /* G=<undefined> */
104 RDSZ(0), 0, /* H=<undefined> */
105}, rd7912P_sizes[8] = {
106 RDSZ(15904), 0, /* A=cyl 1 thru 71 */
107 RDSZ(22400), 72, /* B=cyl 72 thru 171 */
108 RDSZ(128128), 0, /* C=cyl 0 thru 571 */
109 RDSZ(42560), 72, /* D=cyl 72 thru 261 */
110 RDSZ(0), 292, /* E=<undefined> */
111 RDSZ(0), 542, /* F=<undefined> */
112 RDSZ(89600), 172, /* G=cyl 221 thru 571 */
113 RDSZ(69440), 262, /* H=cyl 262 thru 571 */
114}, rd7914P_sizes[8] = {
115 RDSZ(15904), 1, /* A=cyl 1 thru 71 */
116 RDSZ(40320), 72, /* B=cyl 72 thru 251 */
117 RDSZ(258048), 0, /* C=cyl 0 thru 1151 */
118 RDSZ(64960), 72, /* D=cyl 72 thru 361 */
119 RDSZ(98560), 362, /* E=cyl 362 thru 801 */
120 RDSZ(78400), 802, /* F=cyl 802 thru 1151 */
121 RDSZ(201600), 252, /* G=cyl 221 thru 1151 */
122 RDSZ(176960), 362, /* H=cyl 362 thru 1151 */
123}, rd7933H_sizes[8] = {
124 RDSZ(16146), 1, /* A=cyl 1 thru 27 */
125 RDSZ(66976), 28, /* B=cyl 28 thru 139 */
126 RDSZ(789958), 0, /* C=cyl 0 thru 1320 */
127 RDSZ(16146), 140, /* D=cyl 140 thru 166 */
128 RDSZ(165646), 167, /* E=cyl 167 thru 443 */
129 RDSZ(165646), 444, /* F=cyl 444 thru 720 */
130 RDSZ(706238), 140, /* G=cyl 140 thru 1320 */
131 RDSZ(358800), 721, /* H=cyl 721 thru 1320 */
132}, rd9134L_sizes[8] = {
133 RDSZ(15920), 1, /* A=cyl 1 thru 199 */
134 RDSZ(20000), 200, /* B=cyl 200 thru 449 */
135 RDSZ(77840), 0, /* C=cyl 0 thru 972 */
136 RDSZ(32000), 200, /* D=cyl 200 thru 599 */
137 RDSZ(0), 0, /* E=<undefined> */
138 RDSZ(0), 0, /* F=<undefined> */
139 RDSZ(41840), 450, /* G=cyl 450 thru 972 */
140 RDSZ(29840), 600, /* H=cyl 600 thru 972 */
141}, rd7957A_sizes[8] = {
142 RDSZ(16016), 1, /* A=cyl 1 thru 104 */
143 RDSZ(24640), 105, /* B=cyl 105 thru 264 */
144 RDSZ(159544), 0, /* C=cyl 0 thru 1035 */
145 RDSZ(42350), 105, /* D=cyl 105 thru 379 */
146 RDSZ(54824), 380, /* E=cyl 380 thru 735 */
147 RDSZ(46200), 736, /* F=cyl 736 thru 1035 */
148 RDSZ(118734), 265, /* G=cyl 265 thru 1035 */
149 RDSZ(101024), 380, /* H=cyl 380 thru 1035 */
150}, rd7958A_sizes[8] = {
151 RDSZ(16128), 1, /* A=cyl 1 thru 64 */
152 RDSZ(32256), 65, /* B=cyl 65 thru 192 */
153 RDSZ(255276), 0, /* C=cyl 0 thru 1012 */
154 RDSZ(48384), 65, /* D=cyl 65 thru 256 */
155 RDSZ(100800), 257, /* E=cyl 257 thru 656 */
156 RDSZ(89712), 657, /* F=cyl 657 thru 1012 */
157 RDSZ(206640), 193, /* G=cyl 193 thru 1012 */
158 RDSZ(190512), 257, /* H=cyl 257 thru 1012 */
159}, rd7957B_sizes[8] = {
160 RDSZ(16002), 1, /* A=cyl 1 thru 127 */
161 RDSZ(32760), 128, /* B=cyl 128 thru 387 */
162 RDSZ(159894), 0, /* C=cyl 0 thru 1268 */
163 RDSZ(49140), 128, /* D=cyl 128 thru 517 */
164 RDSZ(50400), 518, /* E=cyl 518 thru 917 */
165 RDSZ(44226), 918, /* F=cyl 918 thru 1268 */
166 RDSZ(111006), 388, /* G=cyl 388 thru 1268 */
167 RDSZ(94626), 518, /* H=cyl 518 thru 1268 */
168}, rd7958B_sizes[8] = {
169 RDSZ(16254), 1, /* A=cyl 1 thru 43 */
170 RDSZ(32886), 44, /* B=cyl 44 thru 130 */
171 RDSZ(297108), 0, /* C=cyl 0 thru 785 */
172 RDSZ(49140), 44, /* D=cyl 44 thru 173 */
173 RDSZ(121716), 174, /* E=cyl 174 thru 495 */
174 RDSZ(109620), 496, /* F=cyl 496 thru 785 */
175 RDSZ(247590), 131, /* G=cyl 131 thru 785 */
176 RDSZ(231336), 174, /* H=cyl 174 thru 785 */
177}, rd7959B_sizes[8] = {
178 RDSZ(16254), 1, /* A=cyl 1 thru 43 */
179 RDSZ(49140), 44, /* B=cyl 44 thru 173 */
180 RDSZ(594216), 0, /* C=cyl 0 thru 1571 */
181 RDSZ(65772), 44, /* D=cyl 44 thru 217 */
182 RDSZ(303912), 218, /* E=cyl 218 thru 1021 */
183 RDSZ(207900), 1022, /* F=cyl 1022 thru 1571 */
184 RDSZ(528444), 174, /* G=cyl 174 thru 1571 */
185 RDSZ(511812), 218, /* H=cyl 218 thru 1571 */
186}, rd2200A_sizes[8] = {
187 RDSZ(16272), 1, /* A=cyl 1 thru 36 */
188 RDSZ(49720), 37, /* B=cyl 37 thru 146 */
189 RDSZ(654948), 0, /* C=cyl 0 thru 1448 */
190 RDSZ(65992), 37, /* D=cyl 37 thru 182 */
191 RDSZ(304648), 183, /* E=cyl 183 thru 856 */
192 RDSZ(267584), 857, /* F=cyl 857 thru 1448 */
193 RDSZ(588504), 147, /* G=cyl 147 thru 1448 */
194 RDSZ(572232), 183, /* H=cyl 183 thru 1448 */
195}, rd2203A_sizes[8] = {
196 /* modelled after the 7937; i.e. bogus */
197 RDSZ(16272), 1, /* A=cyl 1 thru 18 */
198 RDSZ(67800), 19, /* B=cyl 19 thru 93 */
199 RDSZ(1309896), 0, /* C=cyl 0 thru 1448 */
200 RDSZ(16272), 94, /* D=cyl 19 thru 111 */
201 RDSZ(305552), 112, /* E=cyl 112 thru 449 */
202 RDSZ(305552), 450, /* F=cyl 450 thru 787 */
203 RDSZ(1224920), 94, /* G=cyl 94 thru 1448 */
204 RDSZ(597544), 788, /* H=cyl 788 thru 1448 */
205}, rd7936H_sizes[8] = {
206 RDSZ(16359), 1, /* A=cyl 1 thru 19 */
207 RDSZ(67158), 20, /* B=cyl 20 thru 97 */
208 RDSZ(600978), 0, /* C=cyl 0 thru 697 */
209 RDSZ(16359), 98, /* D=cyl 98 thru 116 */
210 RDSZ(120540), 117, /* E=cyl 117 thru 256 */
211 RDSZ(120540), 256, /* F=cyl 256 thru 396 */
212 RDSZ(516600), 98, /* G=cyl 98 thru 697 */
213 RDSZ(259161), 397, /* H=cyl 397 thru 697 */
214}, rd7937H_sizes[8] = {
215 RDSZ(15990), 1, /* A=cyl 1 thru 10 */
216 RDSZ(67158), 11, /* B=cyl 11 thru 52 */
217 RDSZ(1116102), 0, /* C=cyl 0 thru 697 */
218 RDSZ(124722), 53, /* D=cyl 53 thru 130 */
219 RDSZ(163098), 131, /* E=cyl 131 thru 232 */
220 RDSZ(287820), 233, /* F=cyl 233 thru 412 */
221 RDSZ(1031355), 53, /* G=cyl 53 thru 697 */
222 RDSZ(455715), 413, /* H=cyl 413 thru 697 */
223};
224
225/*
226 * Indexed the same as rdidentinfo array.
227 */
228struct rdcompatinfo {
229 int nbpt; /* DEV_BSIZE blocks per track */
230 int ntpc; /* tracks per cylinder */
231 int ncyl; /* cylinders per unit */
232 struct size *sizes; /* partition info */
233} rdcompatinfo[] = {
234 NRD7945ABPT, NRD7945ATRK, 968, rd7945A_sizes,
235 NRD9134DBPT, NRD9134DTRK, 303, rd9134D_sizes,
236 NRD9122SBPT, NRD9122STRK, 77, rd9122S_sizes,
237 NRD7912PBPT, NRD7912PTRK, 572, rd7912P_sizes,
238 NRD7914PBPT, NRD7914PTRK, 1152, rd7914P_sizes,
239 NRD7958ABPT, NRD7958ATRK, 1013, rd7958A_sizes,
240 NRD7957ABPT, NRD7957ATRK, 1036, rd7957A_sizes,
241 NRD7933HBPT, NRD7933HTRK, 1321, rd7933H_sizes,
242 NRD9134LBPT, NRD9134LTRK, 973, rd9134L_sizes,
243 NRD7936HBPT, NRD7936HTRK, 698, rd7936H_sizes,
244 NRD7937HBPT, NRD7937HTRK, 698, rd7937H_sizes,
245 NRD7914PBPT, NRD7914PTRK, 1152, rd7914P_sizes,
246 NRD7945ABPT, NRD7945ATRK, 968, rd7945A_sizes,
247 NRD9122SBPT, NRD9122STRK, 77, rd9122S_sizes,
248 NRD7957BBPT, NRD7957BTRK, 1269, rd7957B_sizes,
249 NRD7958BBPT, NRD7958BTRK, 786, rd7958B_sizes,
250 NRD7959BBPT, NRD7959BTRK, 1572, rd7959B_sizes,
251 NRD2200ABPT, NRD2200ATRK, 1449, rd2200A_sizes,
252 NRD2203ABPT, NRD2203ATRK, 1449, rd2203A_sizes,
253};
254int nrdcompatinfo = sizeof(rdcompatinfo) / sizeof(rdcompatinfo[0]);
255
256extern struct rd_softc rd_softc[];
257
258rdmakedisklabel(unit, lp)
259 int unit;
260 struct disklabel *lp;
261{
262 register struct rd_softc *rs = &rd_softc[unit];
263 register struct rdcompatinfo *ci = &rdcompatinfo[rs->sc_type];
264 register struct partition *pi;
265 register int dcount;
266
267 lp->d_nsectors = ci->nbpt;
268 lp->d_ntracks = ci->ntpc;
269 lp->d_ncylinders = ci->ncyl;
270 lp->d_secpercyl = ci->nbpt * ci->ntpc;
271 lp->d_secperunit = lp->d_secpercyl * ci->ncyl;
272 lp->d_rpm = 3600;
273 lp->d_interleave = 1;
274 lp->d_npartitions = 8;
275
276 pi = lp->d_partitions;
277 for (dcount = 0; dcount < lp->d_npartitions; dcount++) {
278 pi->p_size = ci->sizes[dcount].nblocks;
279 pi->p_offset = ci->sizes[dcount].cyloff * lp->d_secpercyl;
280 pi->p_fsize = 1024;
281 if (dcount == 1 || dcount == 3)
282 pi->p_fstype = FS_SWAP;
7677f574
MH
283 else if (dcount == 2)
284 pi->p_fstype = FS_BOOT;
7e16cfa6
MH
285 else
286 pi->p_fstype = FS_BSDFFS;
287 pi->p_frag = 8;
288 pi++;
289 }
290}
291#endif