Expand PMF_FN_* macros.
[netbsd-mini2440.git] / distrib / utils / sysinst / mbr.h
blob9cf4bf5cbaaa618b6516821adfe07f5f3febfebc
1 /* $NetBSD: mbr.h,v 1.23 2009/05/14 16:23:38 sborrill Exp $ */
3 /*
4 * Copyright 1997, 1988 Piermont Information Systems Inc.
5 * All rights reserved.
7 * Written by Philip A. Nelson for Piermont Information Systems Inc.
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 * notice, this list of conditions and the following disclaimer.
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. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed for the NetBSD Project by
20 * Piermont Information Systems Inc.
21 * 4. The name of Piermont Information Systems Inc. may not be used to endorse
22 * or promote products derived from this software without specific prior
23 * written permission.
25 * THIS SOFTWARE IS PROVIDED BY PIERMONT INFORMATION SYSTEMS INC. ``AS IS''
26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL PIERMONT INFORMATION SYSTEMS INC. BE
29 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
35 * THE POSSIBILITY OF SUCH DAMAGE.
39 #ifndef _MBR_H
40 #define _MBR_H
43 * mbr.h -- definitions for reading, writing and editing DOS MBRs.
44 * Use by including from md.h on ports which use MBRs (i386, powerpc, arc)
45 * naming convention: dlxxxx => NetBSD disklabel, bxxxx => bios
48 /* constants and defines */
50 #include <sys/bootblock.h>
52 /*
53 * XXX I (dsl) haven't the foggiest idea what the MBR extended chain
54 * looks like if the sector size isn't 512.
55 */
56 #define MBR_SECSIZE 512
58 #define MBR_PUT_LSCYL(c) ((c) & 0xff)
59 #define MBR_PUT_MSCYLANDSEC(c,s) (((s) & 0x3f) | (((c) >> 2) & 0xc0))
61 typedef struct mbr_info_t mbr_info_t;
62 struct mbr_info_t {
63 struct mbr_sector mbr;
64 #ifdef BOOTSEL
65 struct mbr_bootsel mbrb; /* writeable for any mbr code */
66 uint oflags;
67 #endif
68 uint sector; /* where we read this from */
69 mbr_info_t *extended; /* next in extended partition list */
70 mbr_info_t *prev_ext; /* and back ptr */
71 const char *last_mounted[MBR_PART_COUNT];
72 /* only in first item... */
73 int opt; /* entry being edited */
74 uint install; /* start sector of install partition */
75 #ifdef BOOTSEL
76 uint bootsec; /* start sector of bootmenu default */
77 #endif
80 /* incore fdisk (mbr, bios) geometry */
81 int bcyl, bhead, bsec;
83 mbr_info_t mbr;
85 #ifdef BOOTSEL
86 struct mbr_bootsel *mbs;
88 /* sync with src/sbin/fdisk/fdisk.c */
89 #define DEFAULT_BOOTDIR "/usr/mdec"
90 #define DEFAULT_BOOTCODE "mbr"
91 #define DEFAULT_BOOTSELCODE "mbr_bootsel"
92 #define DEFAULT_BOOTEXTCODE "mbr_ext"
94 /* Scan values for the various keys we use, as returned by the BIOS */
95 #define SCAN_ENTER 0x1c
96 #define SCAN_F1 0x3b
97 #define SCAN_1 0x2
99 #endif /* BOOTSEL */
101 /* from mbr.c */
102 void set_fdisk_geom(void); /* edit incore BIOS geometry */
103 void disp_cur_geom(void);
104 int check_geom(void); /* primitive geometry sanity-check */
106 void disp_cur_part(struct mbr_partition *, int, int);
107 int edit_mbr(mbr_info_t *);
108 int mbr_use_wholedisk(mbr_info_t *);
109 int partsoverlap(struct mbr_partition *, int, int);
111 /* from mbr.c */
113 int read_mbr(const char *, mbr_info_t *);
114 int write_mbr(const char *, mbr_info_t *, int);
115 int valid_mbr(struct mbr_sector *);
116 int guess_biosgeom_from_mbr(mbr_info_t *, int *, int *, daddr_t *);
117 int set_bios_geom_with_mbr_guess(void);
118 void set_bios_geom(int, int, int);
119 int otherpart(int);
120 int ourpart(int);
121 const char *get_partname(int);
122 void edit_ptn_bounds(void);
123 #ifdef BOOTSEL
124 void disp_bootsel(void);
125 void edit_bootsel_entry(int);
126 void edit_bootsel_timeout(void);
127 void edit_bootsel_default_ptn(int);
128 void edit_bootsel_default_disk(int);
129 void configure_bootsel(void);
130 #endif
132 /* Machine dependant mbr functions */
133 int md_mbr_use_wholedisk(mbr_info_t *mbri);
134 int md_check_mbr(mbr_info_t *mbri);
136 #endif