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