Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/distrib/utils/sysinst Change partition type if we're install...



details:   https://anonhg.NetBSD.org/src/rev/65552b1a0165
branches:  trunk
changeset: 472560:65552b1a0165
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Sun May 02 13:07:15 1999 +0000

description:
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.

diffstat:

 distrib/utils/sysinst/arch/i386/md.c         |  116 +++++++++++++++++++++++++-
 distrib/utils/sysinst/arch/i386/md.h         |   25 +++++-
 distrib/utils/sysinst/arch/i386/menus.md.eng |   92 +++++++++++++++++++++-
 distrib/utils/sysinst/arch/i386/msg.md.eng   |   54 ++++++++++++-
 distrib/utils/sysinst/mbr.c                  |   37 ++++++-
 distrib/utils/sysinst/mbr.h                  |    3 +-
 distrib/utils/sysinst/msg.mi.eng             |   11 ++-
 7 files changed, 317 insertions(+), 21 deletions(-)

diffs (truncated from 484 to 300 lines):

diff -r 0033b97e6b78 -r 65552b1a0165 distrib/utils/sysinst/arch/i386/md.c
--- a/distrib/utils/sysinst/arch/i386/md.c      Sun May 02 12:44:34 1999 +0000
+++ b/distrib/utils/sysinst/arch/i386/md.c      Sun May 02 13:07:15 1999 +0000
@@ -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 @@
 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 @@
                    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]);
+
+       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;
+       }
 
-       /*
-        * XXX Check for > 8G, and ask if NetBSD MBR is to be used
-        * if ext13 supported.
-        */
+       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 @@
        /*
         * 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 @@
        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]);
+       }
+}
diff -r 0033b97e6b78 -r 65552b1a0165 distrib/utils/sysinst/arch/i386/md.h
--- a/distrib/utils/sysinst/arch/i386/md.h      Sun May 02 12:44:34 1999 +0000
+++ b/distrib/utils/sysinst/arch/i386/md.h      Sun May 02 13:07:15 1999 +0000
@@ -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 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.
diff -r 0033b97e6b78 -r 65552b1a0165 distrib/utils/sysinst/arch/i386/menus.md.eng
--- a/distrib/utils/sysinst/arch/i386/menus.md.eng      Sun May 02 12:44:34 1999 +0000
+++ b/distrib/utils/sysinst/arch/i386/menus.md.eng      Sun May 02 13:07:15 1999 +0000
@@ -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 @@
                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; };
diff -r 0033b97e6b78 -r 65552b1a0165 distrib/utils/sysinst/arch/i386/msg.md.eng
--- a/distrib/utils/sysinst/arch/i386/msg.md.eng        Sun May 02 12:44:34 1999 +0000



Home | Main Index | Thread Index | Old Index