Change partition type if we're installing into an old 386bsd partition.
Check if there's no active partition after MBR editing. Ask for own MBR to be installed if we're booting from out of CHS range. Ask for bootselector to be installed if > 1 OS, and configure it.
This commit is contained in:
parent
ec559f688b
commit
337300d376
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: md.c,v 1.24 1999/04/13 14:49:57 bouyer Exp $ */
|
||||
/* $NetBSD: md.c,v 1.25 1999/05/02 13:07:16 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -55,8 +55,18 @@ int c1024_resp;
|
|||
struct disklist *disklist = NULL;
|
||||
struct nativedisk_info *nativedisk;
|
||||
struct biosdisk_info *biosdisk = NULL;
|
||||
int netbsd_mbr_installed = 0;
|
||||
int netbsd_bootsel_installed = 0;
|
||||
|
||||
static int md_read_bootcode __P((char *, char *, size_t));
|
||||
static int count_mbr_parts __P((struct mbr_partition *));
|
||||
static int mbr_part_above_chs __P((struct mbr_partition *));
|
||||
static int mbr_partstart_above_chs __P((struct mbr_partition *));
|
||||
static void configure_bootsel __P((void));
|
||||
|
||||
struct mbr_bootsel *mbs;
|
||||
int defbootselpart, defbootseldisk;
|
||||
|
||||
|
||||
/* prototypes */
|
||||
|
||||
|
@ -70,16 +80,43 @@ md_get_info()
|
|||
NMBRPART * sizeof (struct mbr_partition));
|
||||
/* XXX check result and give up if < 0 */
|
||||
mbr_len = md_read_bootcode(_PATH_MBR, mbr, sizeof mbr);
|
||||
netbsd_mbr_installed = 1;
|
||||
} else
|
||||
mbr_len = MBR_SECSIZE;
|
||||
md_bios_info(diskdev);
|
||||
|
||||
return edit_mbr((struct mbr_partition *)&mbr[MBR_PARTOFF]);
|
||||
edit:
|
||||
edit_mbr((struct mbr_partition *)&mbr[MBR_PARTOFF]);
|
||||
|
||||
/*
|
||||
* XXX Check for > 8G, and ask if NetBSD MBR is to be used
|
||||
* if ext13 supported.
|
||||
*/
|
||||
if (mbr_part_above_chs(part) &&
|
||||
(biosdisk == NULL || !(biosdisk->bi_flags & BIFLAG_EXTINT13))) {
|
||||
msg_display(MSG_partabovechs);
|
||||
process_menu(MENU_noyes);
|
||||
if (!yesno)
|
||||
goto edit;
|
||||
}
|
||||
|
||||
if (count_mbr_parts(part) > 1) {
|
||||
msg_display(MSG_installbootsel);
|
||||
process_menu(MENU_yesno);
|
||||
if (yesno) {
|
||||
mbr_len =
|
||||
md_read_bootcode(_PATH_BOOTSEL, mbr, sizeof mbr);
|
||||
configure_bootsel();
|
||||
netbsd_mbr_installed = netbsd_bootsel_installed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (mbr_partstart_above_chs(part) && !netbsd_mbr_installed) {
|
||||
msg_display(MSG_installmbr);
|
||||
process_menu(MENU_yesno);
|
||||
if (yesno) {
|
||||
mbr_len = md_read_bootcode(_PATH_MBR, mbr, sizeof mbr);
|
||||
netbsd_mbr_installed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -347,7 +384,8 @@ custom: ask_sizemult();
|
|||
/*
|
||||
* XXX check for int13 extensions.
|
||||
*/
|
||||
if ((bsdlabel[A].pi_offset + bsdlabel[A].pi_size) / bcylsize > 1024) {
|
||||
if ((bsdlabel[A].pi_offset + bsdlabel[A].pi_size) / bcylsize > 1024 &&
|
||||
(biosdisk == NULL || !(biosdisk->bi_flags & BIFLAG_EXTINT13))) {
|
||||
process_menu(MENU_cyl1024);
|
||||
/* XXX UGH! need arguments to process_menu */
|
||||
switch (c1024_resp) {
|
||||
|
@ -497,3 +535,67 @@ nogeom:
|
|||
bcylsize = bhead * bsec;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
count_mbr_parts(pt)
|
||||
struct mbr_partition *pt;
|
||||
{
|
||||
int i, count = 0;;
|
||||
|
||||
for (i = 0; i < NMBRPART; i++)
|
||||
if (pt[i].mbrp_typ != 0)
|
||||
count++;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static int
|
||||
mbr_part_above_chs(pt)
|
||||
struct mbr_partition *pt;
|
||||
{
|
||||
return ((pt[bsdpart].mbrp_start + pt[bsdpart].mbrp_size) >=
|
||||
bcyl * bhead * bsec);
|
||||
}
|
||||
|
||||
static int
|
||||
mbr_partstart_above_chs(pt)
|
||||
struct mbr_partition *pt;
|
||||
{
|
||||
return (pt[bsdpart].mbrp_start >= bcyl * bhead * bsec);
|
||||
}
|
||||
|
||||
static void
|
||||
configure_bootsel()
|
||||
{
|
||||
struct mbr_partition *parts =
|
||||
(struct mbr_partition *)&mbr[MBR_PARTOFF];
|
||||
int i;
|
||||
|
||||
|
||||
mbs = (struct mbr_bootsel *)&mbr[MBR_BOOTSELOFF];
|
||||
mbs->flags = BFL_SELACTIVE;
|
||||
|
||||
process_menu(MENU_configbootsel);
|
||||
|
||||
for (i = 0; i < NMBRPART; i++) {
|
||||
if (parts[i].mbrp_typ != 0 &&
|
||||
parts[i].mbrp_start >= (bcyl * bhead * bsec)) {
|
||||
mbs->flags |= BFL_EXTINT13;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
disp_bootsel(part, mbsp)
|
||||
struct mbr_partition *part;
|
||||
struct mbr_bootsel *mbsp;
|
||||
{
|
||||
int i;
|
||||
|
||||
msg_display_add(MSG_bootselheader);
|
||||
for (i = 0; i < 4; i++) {
|
||||
msg_printf_add("%6d %-32s %s\n",
|
||||
i, get_partname(i), mbs->nametab[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: md.h,v 1.13 1999/04/19 13:17:09 ws Exp $ */
|
||||
/* $NetBSD: md.h,v 1.14 1999/05/02 13:07:16 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -136,8 +136,29 @@ extern struct nativedisk_info *nativedisk;
|
|||
extern struct biosdisk_info *biosdisk;
|
||||
|
||||
#define _PATH_MBR "/usr/mdec/mbr"
|
||||
#define _PATH_BOOTSEL "/usr/mdec/mbr.bootsel"
|
||||
#define _PATH_BOOTSEL "/usr/mdec/mbr_bootsel"
|
||||
|
||||
struct mbr_bootsel {
|
||||
u_int8_t defkey;
|
||||
u_int8_t flags;
|
||||
u_int16_t timeo;
|
||||
char nametab[4][9];
|
||||
u_int16_t magic;
|
||||
} __attribute__((packed));
|
||||
|
||||
extern struct mbr_bootsel *mbs;
|
||||
|
||||
#define BFL_SELACTIVE 0x01
|
||||
#define BFL_EXTINT13 0x02
|
||||
|
||||
#define SCAN_ENTER 0x1c
|
||||
#define SCAN_F1 0x3b
|
||||
|
||||
#define MBR_BOOTSELOFF (MBR_PARTOFF - sizeof (struct mbr_bootsel))
|
||||
|
||||
extern int defbootselpart, defbootseldisk;
|
||||
|
||||
void disp_bootsel __P((struct mbr_partition *, struct mbr_bootsel *));
|
||||
|
||||
/*
|
||||
* prototypes for MD code.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: menus.md.eng,v 1.19 1999/04/11 22:40:26 bouyer Exp $ */
|
||||
/* $NetBSD: menus.md.eng,v 1.20 1999/05/02 13:07:16 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -234,3 +234,93 @@ menu biosmultmatch;
|
|||
set_bios_geom(dlcyl, dlhead, dlsec);
|
||||
biosdisk = NULL;
|
||||
};
|
||||
|
||||
menu configbootsel, title " Change a bootmenu item", exit;
|
||||
display action { msg_display(MSG_configbootsel);
|
||||
disp_bootsel((struct mbr_partition *)&mbr[MBR_PARTOFF], mbs);
|
||||
msg_display_add(MSG_bootseltimeout, (1000 * mbs->timeo) / 18200);
|
||||
msg_display_add(MSG_defbootselopt);
|
||||
if (mbs->defkey == SCAN_ENTER)
|
||||
msg_display_add(MSG_defbootseloptactive);
|
||||
else if (mbs->defkey < (SCAN_F1 + 4))
|
||||
msg_display_add(MSG_defbootseloptpart,
|
||||
defbootselpart);
|
||||
else
|
||||
msg_display_add(MSG_defbootseloptdisk,
|
||||
defbootseldisk);
|
||||
};
|
||||
option "Edit menu entry 0",
|
||||
action {
|
||||
if (part[0].mbrp_typ != 0)
|
||||
msg_prompt(MSG_bootselitemname, mbs->nametab[0],
|
||||
mbs->nametab[0], 8);
|
||||
};
|
||||
option "Edit menu entry 1",
|
||||
action {
|
||||
if (part[1].mbrp_typ != 0)
|
||||
msg_prompt(MSG_bootselitemname, mbs->nametab[1],
|
||||
mbs->nametab[1], 8);
|
||||
};
|
||||
option "Edit menu entry 2",
|
||||
action {
|
||||
if (part[2].mbrp_typ != 0)
|
||||
msg_prompt(MSG_bootselitemname, mbs->nametab[2],
|
||||
mbs->nametab[2], 8);
|
||||
};
|
||||
option "Edit menu entry 3",
|
||||
action {
|
||||
if (part[3].mbrp_typ != 0)
|
||||
msg_prompt(MSG_bootselitemname, mbs->nametab[3],
|
||||
mbs->nametab[3], 8);
|
||||
};
|
||||
option "Set timeout value",
|
||||
action {
|
||||
char tstr[8];
|
||||
unsigned timo;
|
||||
|
||||
do {
|
||||
snprintf(tstr, 8, "%u",
|
||||
(1000 * mbs->timeo) / 18200);
|
||||
msg_prompt(MSG_bootseltimeoutval, tstr, tstr,
|
||||
8);
|
||||
timo = (unsigned)atoi(tstr);
|
||||
} while (timo > 3600);
|
||||
mbs->timeo = (u_int16_t)((timo * 18200) / 1000);
|
||||
};
|
||||
option "Set default option", sub menu defaultbootsel;
|
||||
|
||||
menu defaultbootsel, title " Pick a default partition/disk to boot ";
|
||||
option "Partition 0", exit,
|
||||
action {
|
||||
if (mbs->nametab[0][0] != 0 && part[0].mbrp_typ != 0)
|
||||
mbs->defkey = SCAN_F1; defbootselpart = 0;
|
||||
};
|
||||
option "Partition 1", exit,
|
||||
action {
|
||||
if (mbs->nametab[1][0] != 0 && part[1].mbrp_typ != 0)
|
||||
mbs->defkey = SCAN_F1 + 1; defbootselpart = 1;
|
||||
};
|
||||
option "Partition 2", exit,
|
||||
action {
|
||||
if (mbs->nametab[2][0] != 0 && part[2].mbrp_typ != 0)
|
||||
mbs->defkey = SCAN_F1 + 2; defbootselpart = 2;
|
||||
};
|
||||
option "Partition 3", exit,
|
||||
action {
|
||||
if (mbs->nametab[3][0] != 0 && part[3].mbrp_typ != 0)
|
||||
mbs->defkey = SCAN_F1 + 3; defbootselpart = 3;
|
||||
};
|
||||
option "Harddisk 0", exit,
|
||||
action { mbs->defkey = SCAN_F1 + 4; defbootseldisk = 0; };
|
||||
option "Harddisk 1", exit,
|
||||
action { mbs->defkey = SCAN_F1 + 5; defbootseldisk = 1; };
|
||||
option "Harddisk 2", exit,
|
||||
action { mbs->defkey = SCAN_F1 + 6; defbootseldisk = 2; };
|
||||
option "Harddisk 3", exit,
|
||||
action { mbs->defkey = SCAN_F1 + 7; defbootseldisk = 3; };
|
||||
option "Harddisk 4", exit,
|
||||
action { mbs->defkey = SCAN_F1 + 8; defbootseldisk = 4; };
|
||||
option "Harddisk 5", exit,
|
||||
action { mbs->defkey = SCAN_F1 + 9; defbootseldisk = 5; };
|
||||
option "First active partition", exit,
|
||||
action { mbs->defkey = SCAN_ENTER; };
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: msg.md.eng,v 1.11 1999/04/11 22:40:26 bouyer Exp $ */
|
||||
/* $NetBSD: msg.md.eng,v 1.12 1999/05/02 13:07:16 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -182,7 +182,7 @@ message askfspart2
|
|||
{Partition size? }
|
||||
|
||||
message cyl1024
|
||||
{ The disklabel (set of partitions) you specified has a root partition that
|
||||
{The disklabel (set of partitions) you specified has a root partition that
|
||||
ends beyond the 1024 BIOS cylinder boundary. To be sure that the system
|
||||
can be booted at all times, the entire root partition must lie below that
|
||||
limit. You can either: }
|
||||
|
@ -202,3 +202,53 @@ message pickdisk
|
|||
|
||||
message wmbrfail
|
||||
{Rewrite of MBR failed. I can't continue.}
|
||||
|
||||
message partabovechs
|
||||
{The NetBSD part of the disk lies outside of the range that the BIOS on
|
||||
your machine can address. Booting from it may not be possible. Are you
|
||||
sure you that you want to do this?
|
||||
|
||||
(Answering 'no' will take you back to the partition edit menu.)}
|
||||
|
||||
message installbootsel
|
||||
{You appear to have more than one operating system installed on your
|
||||
disk. Do you want to install a bootselector so that you can select
|
||||
which system to start up when your computer is (re)started?}
|
||||
|
||||
message installmbr
|
||||
{The start of the NetBSD part of the disk lies outside of the range
|
||||
that the BIOS can address. The initial bootcode in the Master Boot
|
||||
Record needs to be able to use the extended BIOS interface to boot
|
||||
off this partition. Do you want to install the NetBSD bootcode into
|
||||
the Master Boot Record so that this is ensured? Note that this will
|
||||
overwrite the existing code in the MBR, like some bootselectors.}
|
||||
|
||||
message configbootsel
|
||||
{Configure the different bootselection menu items. You can change the
|
||||
simple menu entries for the matching partition entries that are displayed
|
||||
when the system boots. Also, you can specify the timeout and default
|
||||
action to be taken (if no selection is made in the bootmenu).\n}
|
||||
|
||||
message bootseltimeout
|
||||
{Boot menu timeout: %d\n}
|
||||
|
||||
message defbootselopt
|
||||
{Default boot menu action: }
|
||||
|
||||
message defbootseloptactive
|
||||
{boot the first active partition.}
|
||||
|
||||
message defbootseloptpart
|
||||
{boot off partition %d.\n}
|
||||
|
||||
message defbootseloptdisk
|
||||
{boot off harddisk %d.\n}
|
||||
|
||||
message bootselitemname
|
||||
{Enter name for menu item}
|
||||
|
||||
message bootseltimeoutval
|
||||
{Timeout value in seconds (0-3600)}
|
||||
|
||||
message bootselheader
|
||||
{Number Type Menu entry\n}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mbr.c,v 1.14 1999/04/14 16:00:42 bouyer Exp $ */
|
||||
/* $NetBSD: mbr.c,v 1.15 1999/05/02 13:07:15 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -279,8 +279,6 @@ edit_mbr(partition)
|
|||
}
|
||||
} while (yesno && (numbsd != 1 || overlap));
|
||||
|
||||
if (activepart != -1)
|
||||
part[activepart].mbrp_flag = 0x80;
|
||||
|
||||
if (numbsd == 0) {
|
||||
msg_display(MSG_nobsdpart);
|
||||
|
@ -292,6 +290,21 @@ edit_mbr(partition)
|
|||
msg_display(MSG_multbsdpart, bsdpart);
|
||||
process_menu(MENU_ok);
|
||||
}
|
||||
|
||||
if (activepart == -1) {
|
||||
msg_display(MSG_noactivepart);
|
||||
process_menu(MENU_yesno);
|
||||
if (yesno)
|
||||
part[bsdpart].mbrp_flag = 0x80;
|
||||
} else
|
||||
part[activepart].mbrp_flag = 0x80;
|
||||
|
||||
if (bsdpart == freebsdpart) {
|
||||
msg_display(MSG_upgradeparttype);
|
||||
process_menu(MENU_yesno);
|
||||
if (yesno)
|
||||
part[bsdpart].mbrp_typ = dosptyp_nbsd;
|
||||
}
|
||||
|
||||
ptstart = part[bsdpart].mbrp_start;
|
||||
ptsize = part[bsdpart].mbrp_size;
|
||||
|
@ -331,13 +344,25 @@ partsoverlap(part, i, j)
|
|||
(part[i].mbrp_start == part[j].mbrp_start);
|
||||
}
|
||||
|
||||
char *
|
||||
get_partname(i)
|
||||
int i;
|
||||
{
|
||||
int j;
|
||||
|
||||
for (j = 0; part_ids[j].id != -1 &&
|
||||
part_ids[j].id != part[i].mbrp_typ; j++);
|
||||
|
||||
return part_ids[j].name;
|
||||
}
|
||||
|
||||
void
|
||||
disp_cur_part(part, sel, disp)
|
||||
struct mbr_partition *part;
|
||||
int sel;
|
||||
int disp;
|
||||
{
|
||||
int i, j, start, stop, rsize, rend;
|
||||
int i, start, stop, rsize, rend;
|
||||
|
||||
if (disp < 0)
|
||||
start = 0, stop = 4;
|
||||
|
@ -359,9 +384,7 @@ disp_cur_part(part, sel, disp)
|
|||
msg_printf_add("%d %12d%12d%12d ", i,
|
||||
part[i].mbrp_start / sizemult, rsize, rend);
|
||||
}
|
||||
for (j = 0; part_ids[j].id != -1 &&
|
||||
part_ids[j].id != part[i].mbrp_typ; j++);
|
||||
msg_printf_add("%s\n", part_ids[j].name);
|
||||
msg_printf_add("%s\n", get_partname(i));
|
||||
if (sel == i)
|
||||
msg_standend();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: mbr.h,v 1.5 1999/04/05 06:59:36 simonb Exp $ */
|
||||
/* $NetBSD: mbr.h,v 1.6 1999/05/02 13:07:15 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997, 1988 Piermont Information Systems Inc.
|
||||
|
@ -85,3 +85,4 @@ int md_bios_info __P((char *));
|
|||
void set_bios_geom __P((int, int, int));
|
||||
int otherpart __P((int));
|
||||
int ourpart __P((int));
|
||||
char *get_partname __P((int));
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: msg.mi.eng,v 1.40 1999/04/13 20:17:47 bouyer Exp $ */
|
||||
/* $NetBSD: msg.mi.eng,v 1.41 1999/05/02 13:07:15 fvdl Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 1997 Piermont Information Systems Inc.
|
||||
|
@ -713,3 +713,12 @@ message cmdfail
|
|||
{Command
|
||||
%s
|
||||
failed. I can't continue.}
|
||||
|
||||
message noactivepart
|
||||
{You have not marked a partition active. This may cause your system to not
|
||||
start up properly. Should the NetBSD partition of the disk be marked active?}
|
||||
|
||||
message upgradeparttype
|
||||
{The only suitable partition that was found for NetBSD installation is of
|
||||
the old NetBSD/386BSD/FreeBSD partition type. Do you want to change the type
|
||||
of this partition to the new NetBSD-only partition type?}
|
||||
|
|
Loading…
Reference in New Issue