xref: /csrg-svn/sys/hp300/dev/sd_compat.c (revision 57330)
1*57330Shibler /*
2*57330Shibler  * Copyright (c) 1990 The Regents of the University of California.
3*57330Shibler  * All rights reserved.
4*57330Shibler  *
5*57330Shibler  * This code is derived from software contributed to Berkeley by
6*57330Shibler  * Van Jacobson of Lawrence Berkeley Laboratory.
7*57330Shibler  *
8*57330Shibler  * %sccs.include.redist.c%
9*57330Shibler  *
10*57330Shibler  *	@(#)sd_compat.c	7.1 (Berkeley) 12/27/92
11*57330Shibler  */
12*57330Shibler 
13*57330Shibler /*
14*57330Shibler  * Compatibility for SCSI disks without labels.
15*57330Shibler  */
16*57330Shibler #include "sd.h"
17*57330Shibler #if NSD > 0
18*57330Shibler 
19*57330Shibler #include <sys/param.h>
20*57330Shibler #include <sys/disklabel.h>
21*57330Shibler #include <hp/dev/device.h>
22*57330Shibler #include <hp300/dev/sdvar.h>
23*57330Shibler 
24*57330Shibler /*
25*57330Shibler  * Since the SCSI standard tends to hide the disk structure, we define
26*57330Shibler  * partitions in terms of DEV_BSIZE blocks.  The default partition table
27*57330Shibler  * (for an unlabeled disk) reserves 512K for a boot area, has an 8 meg
28*57330Shibler  * root (A) and 32 meg of swap (B).  The rest of the space on the drive
29*57330Shibler  * goes in the G partition.  As usual, the C partition covers the entire
30*57330Shibler  * disk (including the boot area).
31*57330Shibler  *
32*57330Shibler  * We also define the D, E, F and H partitions as an alternative to B and G.
33*57330Shibler  * D is 48Mb, starts after A and is intended for swapping.
34*57330Shibler  * E is 50Mb, starts after D and is intended for /usr.
35*57330Shibler  * F starts after E and is what ever is left.
36*57330Shibler  * H starts after D and is what ever is left (i.e. combo of E and F).
37*57330Shibler  */
38*57330Shibler struct partition sddefaultpart[] = {
39*57330Shibler 	{  16384,   1024, 1024, FS_BSDFFS, 8 },
40*57330Shibler 	{  65536,  17408,    0, FS_SWAP,   0 },
41*57330Shibler 	{      0,      0, 1024, FS_BSDFFS, 8 },
42*57330Shibler 	{  98304,  17408,    0, FS_SWAP,   0 },
43*57330Shibler 	{ 102400, 115712, 1024, FS_BSDFFS, 8 },
44*57330Shibler 	{      0, 218112, 1024, FS_BSDFFS, 8 },
45*57330Shibler 	{      0,  82944, 1024, FS_BSDFFS, 8 },
46*57330Shibler 	{      0, 115712, 1024, FS_BSDFFS, 8 }
47*57330Shibler };
48*57330Shibler int sdnumdefaultpart = sizeof(sddefaultpart)/sizeof(sddefaultpart[0]);
49*57330Shibler 
50*57330Shibler extern struct sd_softc sd_softc[];
51*57330Shibler 
52*57330Shibler sdmakedisklabel(unit, lp)
53*57330Shibler 	int unit;
54*57330Shibler 	register struct disklabel *lp;
55*57330Shibler {
56*57330Shibler 	register struct sd_softc *sc = &sd_softc[unit];
57*57330Shibler 	register struct partition *pi, *dpi;
58*57330Shibler 	register int dcount;
59*57330Shibler 
60*57330Shibler 	lp->d_secperunit = sc->sc_blks;
61*57330Shibler 	lp->d_rpm = 3600;
62*57330Shibler 	lp->d_interleave = 1;
63*57330Shibler 	if (sc->sc_flags & SDF_RMEDIA)
64*57330Shibler 		lp->d_flags |= D_REMOVABLE;
65*57330Shibler 	lp->d_npartitions = sdnumdefaultpart;
66*57330Shibler 
67*57330Shibler 	pi = lp->d_partitions;
68*57330Shibler 	dpi = sddefaultpart;
69*57330Shibler 	dcount = sdnumdefaultpart;
70*57330Shibler 	while (dcount-- > 0)
71*57330Shibler 		*pi++ = *dpi++;
72*57330Shibler 
73*57330Shibler 	pi = lp->d_partitions;
74*57330Shibler 
75*57330Shibler 	/*
76*57330Shibler 	 * C gets everything
77*57330Shibler 	 */
78*57330Shibler 	pi[2].p_size = sc->sc_blks;
79*57330Shibler 	/*
80*57330Shibler 	 * G gets from end of B to end of disk
81*57330Shibler 	 */
82*57330Shibler 	pi[6].p_size = sc->sc_blks - pi[6].p_offset;
83*57330Shibler 	/*
84*57330Shibler 	 * H gets from end of D to end of disk
85*57330Shibler 	 */
86*57330Shibler 	pi[7].p_size = sc->sc_blks - pi[7].p_offset;
87*57330Shibler 	/*
88*57330Shibler 	 * If disk is big enough, define E and F
89*57330Shibler 	 */
90*57330Shibler 	if (sc->sc_blks > pi[5].p_offset)
91*57330Shibler 		pi[5].p_size = sc->sc_blks - pi[5].p_offset;
92*57330Shibler 	else {
93*57330Shibler 		pi[4].p_offset = pi[4].p_size = 0;
94*57330Shibler 		pi[5].p_offset = pi[5].p_size = 0;
95*57330Shibler 	}
96*57330Shibler }
97*57330Shibler #endif
98