Index: distrib/macppc/floppies/ramdisk/Makefile =================================================================== RCS file: /cvsroot/src/distrib/macppc/floppies/ramdisk/Makefile,v retrieving revision 1.32 diff -u -r1.32 Makefile --- distrib/macppc/floppies/ramdisk/Makefile 10 May 2007 23:22:30 -0000 1.32 +++ distrib/macppc/floppies/ramdisk/Makefile 9 Dec 2009 11:05:48 -0000 @@ -20,7 +20,8 @@ dot.profile termcap.src \ ${DESTDIR}/usr/mdec/ofwboot ${DESTDIR}/usr/mdec/bootxx \ ${NETBSDSRCDIR}/etc/group ${NETBSDSRCDIR}/etc/master.passwd \ - ${NETBSDSRCDIR}/etc/netconfig ${NETBSDSRCDIR}/etc/protocols \ + ${NETBSDSRCDIR}/etc/netconfig \ + ${NETBSDSRCDIR}/distrib/common/protocols \ ${NETBSDSRCDIR}/distrib/common/services SMALLPROG_INET6=1 Index: distrib/macppc/floppies/ramdisk/list =================================================================== RCS file: /cvsroot/src/distrib/macppc/floppies/ramdisk/list,v retrieving revision 1.29 diff -u -r1.29 list --- distrib/macppc/floppies/ramdisk/list 6 May 2008 15:32:06 -0000 1.29 +++ distrib/macppc/floppies/ramdisk/list 9 Dec 2009 11:05:48 -0000 @@ -72,14 +72,14 @@ LIBS libhack.o -ledit -lutil -lcurses -ltermcap -lrmt -ll -lm -lz -lprop COPY ${DESTDIR}/usr/mdec/bootxx usr/mdec/bootxx -COPY ${DESTDIR}/usr/mdec/mbr usr/mdec/mbr -COPY ${DESTDIR}/usr/mdec/ofwboot usr/mdec/ofwboot +#COPY ${DESTDIR}/usr/mdec/ofwboot usr/mdec/ofwboot +COPY ${DESTDIR}/usr/mdec/ofwboot.xcf usr/mdec/ofwboot.xcf # various files that we need in /etc for the install COPY ${NETBSDSRCDIR}/etc/group etc/group COPY ${NETBSDSRCDIR}/etc/master.passwd etc/master.passwd COPY ${NETBSDSRCDIR}/etc/netconfig etc/netconfig -COPY ${NETBSDSRCDIR}/etc/protocols etc/protocols +COPY ${NETBSDSRCDIR}/distrib/common/protocols etc/protocols COPY ${NETBSDSRCDIR}/distrib/common/services etc/services # and the common installation tools Index: distrib/utils/sysinst/arch/macppc/Makefile =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/arch/macppc/Makefile,v retrieving revision 1.8 diff -u -r1.8 Makefile --- distrib/utils/sysinst/arch/macppc/Makefile 19 Feb 2005 17:00:39 -0000 1.8 +++ distrib/utils/sysinst/arch/macppc/Makefile 9 Dec 2009 11:05:50 -0000 @@ -3,4 +3,7 @@ # Makefile for macppc # +MENUS_MD= menus.md.${SYSINSTLANG} menus.mbr +MSG_MD= msg.md.${SYSINSTLANG} msg.mbr.${SYSINSTLANG} + .include "../../Makefile.inc" Index: distrib/utils/sysinst/arch/macppc/md.c =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/arch/macppc/md.c,v retrieving revision 1.40 diff -u -r1.40 md.c --- distrib/utils/sysinst/arch/macppc/md.c 7 Oct 2008 09:58:15 -0000 1.40 +++ distrib/utils/sysinst/arch/macppc/md.c 9 Dec 2009 11:05:50 -0000 @@ -54,6 +54,12 @@ #include "msg_defs.h" #include "menu_defs.h" +/* + * OpenFirmware 3 only reognizes FAT and HFS, so we use a FAT partition + * to store our bootloader. + */ +static int nobootfs = 0; + int md_get_info(void) { @@ -93,7 +99,13 @@ if (disklabel.d_secperunit > dlsize) dlsize = disklabel.d_secperunit; +#if 1 + read_mbr(diskdev, &mbr); + md_bios_info(diskdev); + return edit_mbr(&mbr); +#else return 1; +#endif } /* @@ -102,6 +114,15 @@ int md_pre_disklabel(void) { + + msg_display(MSG_dofdisk); + + /* write edited MBR onto disk. */ + if (write_mbr(diskdev, &mbr, 1) != 0) { + msg_display(MSG_wmbrfail); + process_menu(MENU_ok, NULL); + return 1; + } return 0; } @@ -128,6 +149,37 @@ { const char *bootfile = "/boot"; + /* + * XXX + * Only OpenFirmware version 1 and 2 machines need installboot(8) + * and it uses a faked Apple partition map with the primary bootxx. + * installboot(8) assumes that root partition is at the beginning of + * the disk and put a faked Apple partition map at the top of + * the partition, so it won't work if root partition has some + * offset from physical block 0 where the Apple driver descriptor + * map resides on. + * + * On OpenFirmware version 3 machines, the strategy used on OF1/2 + * machines doesn't work (they don't recognize boot code info + * in Apple partition map entries) and they need to have + * an extra native partition (HFS or MSDOSFS) which can be + * recognized by the newer firmware to put a loadable bootloader. + * installboot(8) against partition `a' on such machines might + * corrupt existing disklabel or a valid Apple partition map. + * + * Currently there is no way to see OF version on running machine + * yet, so assume partition a has some offset on OF3 machines + * and don't try installboot(8) in that case. + */ + if (bsdlabel[PART_A].pi_offset != 0) { + if (!nobootfs) { + msg_display(msg_string(MSG_copybootloader), diskdev); + cp_to_target("/usr/mdec/ofwboot.xcf", + PART_BOOT_FAT_PI_MOUNT); + } + return 0; + } + printf (msg_string(MSG_dobootblks), diskdev); cp_to_target("/usr/mdec/ofwboot", bootfile); sync(); @@ -148,13 +200,151 @@ int md_make_bsd_partitions(void) { - return make_bsd_partitions(); + + int i; + int part; + int maxpart = getmaxpartitions(); + int partstart; + int part_raw, part_bsd; + int ptend; + int no_swap = 0; + partinfo *p; + + /* + * Initialize global variables that track space used on this disk. + * Standard 4.4BSD 8-partition labels always cover whole disk. + */ + if (ptsize == 0) + ptsize = dlsize - ptstart; + if (dlsize == 0) + dlsize = ptstart + ptsize; + + partstart = ptstart; + ptend = ptstart + ptsize; + + /* Ask for layout type -- standard or special */ + msg_display(MSG_layout, + ptsize / (MEG / sectorsize), + DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE, + DEFROOTSIZE + DEFSWAPSIZE + DEFUSRSIZE + XNEEDMB); + + process_menu(MENU_layout, NULL); + + /* Set so we use the 'real' geometry for rounding, input in MB */ + current_cylsize = dlcylsize; + set_sizemultname_meg(); + + /* Build standard partitions */ + memset(&bsdlabel, 0, sizeof bsdlabel); + + /* Set initial partition types to unused */ + for (part = 0 ; part < maxpart ; ++part) + bsdlabel[part].pi_fstype = FS_UNUSED; + + /* Whole disk partition */ + part_raw = getrawpartition(); + if (part_raw == -1) + part_raw = PART_C; /* for sanity... */ + bsdlabel[part_raw].pi_offset = 0; + bsdlabel[part_raw].pi_size = dlsize; + + if (part_raw == PART_D) { + /* Probably a system that expects an i386 style mbr */ + part_bsd = PART_C; + bsdlabel[PART_C].pi_offset = ptstart; + bsdlabel[PART_C].pi_size = ptsize; + } else { + part_bsd = part_raw; + } + + if (bootsize != 0) { + bsdlabel[PART_BOOT_FAT].pi_fstype = FS_MSDOS; + bsdlabel[PART_BOOT_FAT].pi_size = bootsize; + bsdlabel[PART_BOOT_FAT].pi_offset = bootstart; + bsdlabel[PART_BOOT_FAT].pi_flags |= PART_BOOT_FAT_PI_FLAGS; + strlcpy(bsdlabel[PART_BOOT_FAT].pi_mount, + PART_BOOT_FAT_PI_MOUNT, + sizeof bsdlabel[PART_BOOT_FAT].pi_mount); + } + +#ifdef PART_REST + bsdlabel[PART_REST].pi_offset = 0; + bsdlabel[PART_REST].pi_size = ptstart; +#endif + + /* + * Save any partitions that are outside the area we are + * going to use. + * In particular this saves details of the other MBR + * partitions on a multiboot i386 system. + */ + for (i = maxpart; i--;) { + if (bsdlabel[i].pi_size != 0) + /* Don't overwrite special partitions */ + continue; + p = &oldlabel[i]; + if (p->pi_fstype == FS_UNUSED || p->pi_size == 0) + continue; + if (layoutkind == 4) { + if (PI_ISBSDFS(p)) + p->pi_flags |= PIF_MOUNT; + } else { + if (p->pi_offset < ptstart + ptsize && + p->pi_offset + p->pi_size > ptstart) + /* Not outside area we are allocating */ + continue; + if (p->pi_fstype == FS_SWAP) + no_swap = 1; + } + bsdlabel[i] = oldlabel[i]; + } + + if (layoutkind == 4) { + /* XXX Check we have a sensible layout */ + ; + } else + get_ptn_sizes(partstart, ptend - partstart, no_swap); + + /* + * OK, we have a partition table. Give the user the chance to + * edit it and verify it's OK, or abort altogether. + */ + edit_check: + if (edit_and_check_label(bsdlabel, maxpart, part_raw, part_bsd) == 0) { + msg_display(MSG_abort); + return 0; + } + if (md_check_partitions() == 0) + goto edit_check; + + /* Disk name */ + msg_prompt(MSG_packname, bsddiskname, bsddiskname, sizeof bsddiskname); + + /* save label to disk for MI code to update. */ + (void)savenewlabel(bsdlabel, maxpart); + + /* Everything looks OK. */ + return 1; } int md_check_partitions(void) { - return 1; + int part; + + /* + * we need to find a boot partition, otherwise we can't write our + * bootloader. We make the assumption that the user hasn't done + * something stupid, like move it away from the MBR partition. + */ + for (part = PART_A; part < MAXPARTITIONS; part++) + if (bsdlabel[part].pi_fstype == FS_MSDOS) { + return 1; + } + + msg_display(MSG_nobootpartdisklabel); + process_menu(MENU_ok, NULL); + return 0; } /* Upgrade support */ @@ -182,9 +372,49 @@ int md_pre_update(void) { + struct mbr_partition *part; + mbr_info_t *ext; + int i; + + if (get_ramsize() <= 32) + set_swap(diskdev, NULL); + + read_mbr(diskdev, &mbr); + /* do a sanity check of the partition table */ + for (ext = &mbr; ext; ext = ext->extended) { + part = ext->mbr.mbr_parts; + for (i = 0; i < MBR_PART_COUNT; part++, i++) { + if (part->mbrp_type != MBR_PTYPE_FAT12 && + part->mbrp_type != MBR_PTYPE_FAT16B) + continue; + if (part->mbrp_size < (MIN_FAT_BOOT / 512)) { + msg_display(MSG_boottoosmall); + msg_display_add(MSG_nobootpart, 0); + process_menu(MENU_yesno, NULL); + if (!yesno) + return 0; + nobootfs = 1; + } + } + } + if (md_check_partitions() == 0) + nobootfs = 1; return 1; } +int +md_bios_info(char *dev) +{ + int cyl, head, sec; + + msg_display(MSG_nobiosgeom, dlcyl, dlhead, dlsec); + if (guess_biosgeom_from_mbr(&mbr, &cyl, &head, &sec) >= 0) + msg_display_add(MSG_biosguess, cyl, head, sec); + set_bios_geom(cyl, head, sec); + + return 0; +} + void md_init(void) { @@ -199,5 +429,77 @@ int md_post_extract(void) { + return 0; } + +int +md_check_mbr(mbr_info_t *mbri) +{ + mbr_info_t *ext; + struct mbr_partition *part; + int i; + + for (ext = mbri; ext; ext = ext->extended) { + part = ext->mbr.mbr_parts; + for (i = 0; i < MBR_PART_COUNT; part++, i++) { + if (part->mbrp_type == MBR_PTYPE_FAT12 || + part->mbrp_type == MBR_PTYPE_FAT16B) { + bootstart = part->mbrp_start; + bootsize = part->mbrp_size; + break; + } + } + } + if (bootsize < (MIN_FAT_BOOT / 512)) { + msg_display(MSG_boottoosmall); + msg_display_add(MSG_reeditpart, 0); + process_menu(MENU_yesno, NULL); + if (!yesno) + return 0; + return 1; + } + if (bootstart == 0 || bootsize == 0) { + msg_display(MSG_nobootpart); + msg_display_add(MSG_reeditpart, 0); + process_menu(MENU_yesno, NULL); + if (!yesno) + return 0; + return 1; + } + return 2; +} + +int +md_mbr_use_wholedisk(mbr_info_t *mbri) +{ + struct mbr_sector *mbrs = &mbri->mbr; + mbr_info_t *ext; + struct mbr_partition *part; + + part = &mbrs->mbr_parts[0]; + /* Set the partition information for full disk usage. */ + while ((ext = mbri->extended)) { + mbri->extended = ext->extended; + free(ext); + } + memset(part, 0, MBR_PART_COUNT * sizeof *part); +#ifdef BOOTSEL + memset(&mbri->mbrb, 0, sizeof mbri->mbrb); +#endif + part[0].mbrp_type = MBR_PTYPE_FAT12; + part[0].mbrp_size = FAT_BOOT_SIZE / 512; + part[0].mbrp_start = bsec; + part[0].mbrp_flag = MBR_PFLAG_ACTIVE; + + part[1].mbrp_type = MBR_PTYPE_NETBSD; + part[1].mbrp_size = dlsize - (bsec + FAT_BOOT_SIZE / 512); + part[1].mbrp_start = bsec + FAT_BOOT_SIZE / 512; + part[1].mbrp_flag = 0; + + ptstart = part[1].mbrp_start; + ptsize = part[1].mbrp_size; + bootstart = part[0].mbrp_start; + bootsize = part[0].mbrp_size; + return 1; +} Index: distrib/utils/sysinst/arch/macppc/md.h =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/arch/macppc/md.h,v retrieving revision 1.16 diff -u -r1.16 md.h --- distrib/utils/sysinst/arch/macppc/md.h 26 Feb 2006 10:25:53 -0000 1.16 +++ distrib/utils/sysinst/arch/macppc/md.h 9 Dec 2009 11:05:50 -0000 @@ -39,17 +39,35 @@ /* md.h -- Machine specific definitions for the macppc */ +/* OpenFirmware 3 machines use MBR partition to boot from FAT partition */ +#include "mbr.h" + /* Constants and defines */ +#define FAT_BOOT_SIZE (1 * 1024 * 1024) /* 1MB */ +#define MIN_FAT_BOOT (1 * 1024 * 1024) /* 1MB minimum */ /* * Symbolic names for disk partitions. */ #define PART_ROOT PART_A #define PART_RAW PART_C +#define PART_BOOT_FAT PART_D #define PART_USR PART_G +/* We want the boot MSDOS partition mounted on /boot */ +#define USE_NEWFS_MSDOS +#define PART_BOOT_FAT_PI_FLAGS (PIF_NEWFS|PIF_MOUNT) +#define PART_BOOT_FAT_PI_MOUNT "/boot" + +/* default partition size */ +#define DEFSWAPRAM 128 /* Assume at least this RAM for swap calc */ +#define DEFSWAPSIZE 128 /* Default swap size */ +#define DEFROOTSIZE 256 /* Default root size, if created */ +#define DEFVARSIZE 256 /* Default /var size, if created */ +#define DEFUSRSIZE 1024 /* Default /usr size, if created */ + /* Megs required for a full X installation. */ -#define XNEEDMB 35 /* XXXTHORPEJ */ +#define XNEEDMB 100 /* * Default filesets to fetch and install during installation Index: distrib/utils/sysinst/arch/macppc/msg.md.de =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/arch/macppc/msg.md.de,v retrieving revision 1.4 diff -u -r1.4 msg.md.de --- distrib/utils/sysinst/arch/macppc/msg.md.de 2 Feb 2008 04:51:38 -0000 1.4 +++ distrib/utils/sysinst/arch/macppc/msg.md.de 9 Dec 2009 11:05:50 -0000 @@ -50,6 +50,28 @@ {Installiere die Bootblöcke auf %s ... } +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 nobootpart +{There is no FAT16 MS-DOS partition in the MBR partition table.} + +message boottoosmall +{The MS-DOS FAT16 partition to install the native bootloader is too small. +It needs to be at least 1MB in size.} + +message nobootpartdisklabel +{There is no boot partition in the disklabel. The boot partition should +match the boot partition you set up in the MBR partition table.} + +message copybootloader +{Copying bootloader into the MS-DOS FAT partition on %s... +} + message set_kernel_1 {Kernel (GENERIC)} Index: distrib/utils/sysinst/arch/macppc/msg.md.en =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/arch/macppc/msg.md.en,v retrieving revision 1.8 diff -u -r1.8 msg.md.en --- distrib/utils/sysinst/arch/macppc/msg.md.en 2 Feb 2008 04:51:39 -0000 1.8 +++ distrib/utils/sysinst/arch/macppc/msg.md.en 9 Dec 2009 11:05:50 -0000 @@ -49,6 +49,27 @@ {Installing boot blocks on %s.... } +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 nobootpart +{There is no FAT16 MS-DOS partition in the MBR partition table.} + +message boottoosmall +{The MS-DOS FAT16 partition to install the native bootloader is too small. +It needs to be at least 1MB in size.} + +message nobootpartdisklabel +{There is no boot partition in the disklabel. The boot partition should +match the boot partition you set up in the MBR partition table.} + +message copybootloader +{Copying bootloader into the MS-DOS FAT partition on %s... +} + message set_kernel_1 {Kernel (GENERIC)} - Index: distrib/utils/sysinst/arch/macppc/msg.md.es =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/arch/macppc/msg.md.es,v retrieving revision 1.3 diff -u -r1.3 msg.md.es --- distrib/utils/sysinst/arch/macppc/msg.md.es 2 Feb 2008 04:51:39 -0000 1.3 +++ distrib/utils/sysinst/arch/macppc/msg.md.es 9 Dec 2009 11:05:50 -0000 @@ -49,6 +49,28 @@ {Instalando bloques de arranque en %s.... } +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 nobootpart +{There is no FAT16 MS-DOS partition in the MBR partition table.} + +message boottoosmall +{The MS-DOS FAT16 partition to install the native bootloader is too small. +It needs to be at least 1MB in size.} + +message nobootpartdisklabel +{There is no boot partition in the disklabel. The boot partition should +match the boot partition you set up in the MBR partition table.} + +message copybootloader +{Copying bootloader into the MS-DOS FAT partition on %s... +} + message set_kernel_1 {Núcleo (GENERIC)} Index: distrib/utils/sysinst/arch/macppc/msg.md.fr =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/arch/macppc/msg.md.fr,v retrieving revision 1.8 diff -u -r1.8 msg.md.fr --- distrib/utils/sysinst/arch/macppc/msg.md.fr 2 Feb 2008 04:51:40 -0000 1.8 +++ distrib/utils/sysinst/arch/macppc/msg.md.fr 9 Dec 2009 11:05:50 -0000 @@ -48,6 +48,28 @@ {Installation du block de démarrage sur %s ... } +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 nobootpart +{There is no FAT16 MS-DOS partition in the MBR partition table.} + +message boottoosmall +{The MS-DOS FAT16 partition to install the native bootloader is too small. +It needs to be at least 1MB in size.} + +message nobootpartdisklabel +{There is no boot partition in the disklabel. The boot partition should +match the boot partition you set up in the MBR partition table.} + +message copybootloader +{Copying bootloader into the MS-DOS FAT partition on %s... +} + message set_kernel_1 {Kernel (GENERIC)} Index: distrib/utils/sysinst/arch/macppc/msg.md.pl =================================================================== RCS file: /cvsroot/src/distrib/utils/sysinst/arch/macppc/msg.md.pl,v retrieving revision 1.5 diff -u -r1.5 msg.md.pl --- distrib/utils/sysinst/arch/macppc/msg.md.pl 2 Feb 2008 04:51:40 -0000 1.5 +++ distrib/utils/sysinst/arch/macppc/msg.md.pl 9 Dec 2009 11:05:50 -0000 @@ -51,6 +51,28 @@ {Instalowanie bootblokow na %s.... } +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 nobootpart +{There is no FAT16 MS-DOS partition in the MBR partition table.} + +message boottoosmall +{The MS-DOS FAT16 partition to install the native bootloader is too small. +It needs to be at least 1MB in size.} + +message nobootpartdisklabel +{There is no boot partition in the disklabel. The boot partition should +match the boot partition you set up in the MBR partition table.} + +message copybootloader +{Copying bootloader into the MS-DOS FAT partition on %s... +} + message set_kernel_1 {Kernel (GENERIC)} Index: sbin/newfs_msdos/newfs_msdos.c =================================================================== RCS file: /cvsroot/src/sbin/newfs_msdos/newfs_msdos.c,v retrieving revision 1.27.2.2 diff -u -r1.27.2.2 newfs_msdos.c --- sbin/newfs_msdos/newfs_msdos.c 2 Feb 2009 20:52:42 -0000 1.27.2.2 +++ sbin/newfs_msdos/newfs_msdos.c 9 Dec 2009 11:06:31 -0000 @@ -800,7 +800,7 @@ if (!bpb->hds) bpb->hds = ckgeom(fname, geo.dg_ntracks, "drive heads"); if (!bpb->bsec) - bpb->bsec = geo.dg_secperunit; + bpb->bsec = dkw.dkw_size; } } Index: sys/arch/powerpc/oea/ofw_autoconf.c =================================================================== RCS file: /cvsroot/src/sys/arch/powerpc/oea/ofw_autoconf.c,v retrieving revision 1.8 diff -u -r1.8 ofw_autoconf.c --- sys/arch/powerpc/oea/ofw_autoconf.c 25 Sep 2008 14:44:51 -0000 1.8 +++ sys/arch/powerpc/oea/ofw_autoconf.c 9 Dec 2009 11:06:40 -0000 @@ -322,8 +322,10 @@ if (addr != sa->sa_periph->periph_target) return; } else if (device_is_a(device_parent(device_parent(dev)), "pciide") || - device_is_a(device_parent(device_parent(dev)), "viaide") || - device_is_a(device_parent(device_parent(dev)), "slide")) { + device_is_a(device_parent(device_parent(dev)), "acardide") || + device_is_a(device_parent(device_parent(dev)), "cmdide") || + device_is_a(device_parent(device_parent(dev)), "slide") || + device_is_a(device_parent(device_parent(dev)), "viaide")) { struct ata_device *adev = aux; if (addr != adev->adev_channel ||