xref: /netbsd-src/usr.sbin/sysinst/arch/mac68k/md.h (revision de7834a35d1398df31fd438a4fb2d00fe858b885)
1 /*	$NetBSD: md.h,v 1.2 2018/11/18 10:34:46 martin Exp $	*/
2 
3 /*
4  * Copyright 1997 Piermont Information Systems Inc.
5  * All rights reserved.
6  *
7  * Written by Philip A. Nelson for Piermont Information Systems Inc.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. The name of Piermont Information Systems Inc. may not be used to endorse
18  *    or promote products derived from this software without specific prior
19  *    written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31  * THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  */
34 
35 #include <sys/disklabel.h>
36 #include <sys/bootblock.h>
37 
38 /* md.h -- Machine specific definitions for the mac68k */
39 
40 /*
41  * Apple Partition Map Types
42  *    Reserved - Entry hidden by sysinst from user
43  *    NetBSD   - Entry used for NetBSD
44  *    MacOS    - Entry used for MacOS and mapped to NetBSD
45  *    Other    - Entry use unknown, mapped for scratch. This may
46  *               include partitions used by other systems (Linux).
47  */
48 #define MAP_EOL      0
49 #define MAP_RESERVED 1
50 #define MAP_NETBSD   2
51 #define MAP_MACOS    3
52 #define MAP_OTHER    4
53 
54 typedef struct {
55 	int type;               /* Entry type from above */
56 	const char *name;             /* Partition Type string */
57 } MAP_TYPE;
58 
59 /*
60  * Define Apple Partition Map types typically seen on 68k Macs
61  *    This should match the definitions in include/machine/disklabel.h
62  *    and must conform to the matching rules in arch/mac68k/mac68k/disksubr.c
63  */
64 extern MAP_TYPE map_types[];
65 
66 /*
67  * Define NetBSD partition types
68  */
69 #define ROOT_PART 1
70 #define UFS_PART 2
71 #define SWAP_PART 3
72 #define HFS_PART 4
73 #define SCRATCH_PART 5
74 
75 int usefull;			/* on install, clobber entire disk */
76 
77 typedef struct {
78         int size;               /* number of blocks in map for I/O */
79         int in_use_cnt;         /* number of block in current use in map */
80         int usable_cnt;         /* number of partitions usable by NetBSD */
81         int hfs_cnt;            /* number of MacOS partitions found */
82         int root_cnt;           /* number of root partitions in map */
83         int swap_cnt;           /* number of swap partitions in map */
84         int usr_cnt;            /* number of usr partitions in map */
85         int selected;           /* current partition selection in mblk */
86 	int mblk[MAXPARTITIONS];/* map block number of usable partition */
87         struct apple_part_map_entry *blk;
88 } MAP;
89 
90 /*
91  * Define the default size for the Disk Partition Map if we have to
92  *  write one to the disk.  It should be a power of two minus one for
93  *  the Block0 block, i.e. 7, 15, 31, 63.
94  */
95 #define NEW_MAP_SIZE 15
96 
97 MAP map;
98 
99 /* constants and defines */
100 
101 /*
102  * The Block Zero Block is stored in the Partition Map Entry in the
103  *  pmPad (or pmBootArgs) area.  The current NetBSD definition of this
104  *  area is incomplete, so we have our own local definition here.
105  */
106 typedef struct {
107     u_int32_t magic;	/* magic number that identifes Block Zero Block */
108     u_int8_t cluster;	/* Autorecovery cluster grouping */
109     u_int8_t type;	/* 1=>Std FS, 2=>Autorecovery FS, 3=>SWAP FS */
110     u_int16_t inode;	/* bad block inode number */
111     struct {
112 	unsigned int root : 1;	/* FS contains a Root FS */
113 	unsigned int usr  : 1;	/* FS contains a Usr FS */
114 	unsigned int crit : 1;	/* FS contains a "Critical"? FS */
115 	unsigned int used : 1;  /* FS in use */
116 	unsigned int      : 7;
117 	unsigned int slice : 5;	/* Slice number to assocate with plus one */
118 	unsigned int part  : 16; /* reserved, but we'll hide disk part here */
119     } flags;
120     u_int32_t tmade;	/* time FS was created */
121     u_int32_t tmount;	/* time of last mount */
122     u_int32_t tumount;	/* time of last umount */
123     struct {
124 	u_int32_t size;		/* size of map in bytes */
125 	u_int32_t ents;		/* number of used entries */
126 	u_int32_t start;	/* start of cltblk map */
127     } abm;		/* altblk map */
128     u_int32_t filler[7];	/* reserved for abm expansion */
129     u_int8_t mount_point[64];	/* mount point for the FS */
130 } EBZB;
131 
132 /*
133  * Also define Block 0 on the device.  We only use this when we have to
134  *  initialize the entire disk and then we really only care about the
135  *  Signature word, but someday someone might want to fill in other
136  *  parts.
137  */
138 typedef struct {
139     unsigned short	sbSig;		/* unique value for SCSI block 0 */
140     unsigned short 	sbBlkSize;	/* block size of device */
141     unsigned long 	sbBlkCount;	/* number of blocks on device */
142     unsigned short 	sbDevType;	/* device type */
143     unsigned short 	sbDevId;	/* device id */
144     unsigned long 	sbData;		/* not used */
145     unsigned short 	sbDrvrCount;	/* driver descriptor count */
146     unsigned long 	ddBlock;	/* 1st driver's starting block */
147     unsigned short 	ddSize;		/* size of 1st driver (512-byte blks) */
148     unsigned short 	ddType;		/* system type (1 for Mac+) */
149     unsigned short 	ddPad[243];	/* ARRAY[0..242] OF INTEGER; not used */
150 } Block0;
151 
152 /*
153  * Default Disk Partition Map used for an uninitilized disk.
154  *  Has minimal entry for an old Apple SCSI driver, a newer 43 SCSI
155  *  driver and an IDE driver (for those Macs with IDE).
156  */
157 extern struct apple_part_map_entry new_map[];
158 
159 
160 /* Megs for the / partition, if separate */
161 #define	DEFROOTSIZE	60
162 
163 /* Megs required for a full X installation. */
164 #define XNEEDMB		225
165 
166 /*
167  * Machine-specific command to write a new label to a disk.
168  * For example, i386 uses "/sbin/disklabel -w -r", just like i386
169  * miniroot scripts, though this may leave a bogus incore label.
170  * Sun ports should probably use DISKLABEL_CMD "/sbin/disklabel -w"
171  * to get incore to ondisk inode translation for the Sun proms.
172  * If not defined, we assume the port does not support disklabels and
173  * hand-edited disklabel will NOT be written by MI code.
174  *
175  * The mac68k port doesn't support real disklabels so we don't define the
176  * command string. The Apple Disk Partition Map gets written in the
177  * md_pre_disklabel() routine, which also forces the incore copy to be
178  * updated. If native disklabels are supported or if disklabel() is
179  * fixed to work for writing labels, this command should be defined
180  * to a value that will force the writing of the label. In that case,
181  * the code in md_pre_disklabel() which forces the incore update can be
182  * removed, though its presence won't hurt.
183  *
184  * #define DISKLABEL_CMD
185  */
186 
187 /* Definition of files to retrieve from ftp. */
188 #define SET_KERNEL_1_NAME	"kern-GENERIC"
189 #define SET_KERNEL_2_NAME	"kern-GENERICSBC"
190 
191 extern void	sortmerge(void);
192 extern void	disp_selected_part(int);
193 extern void	reset_part_flags(struct apple_part_map_entry *);
194 extern int	whichType(struct apple_part_map_entry *);
195 extern void	report_errors(void);
196