svn commit: r268256 - in head: sbin/geom/class/part sys/geom/part sys/sys usr.sbin/bsdinstall/partedit

Nathan Whitehorn nwhitehorn at FreeBSD.org
Fri Jul 4 15:55:34 UTC 2014


Author: nwhitehorn
Date: Fri Jul  4 15:55:32 2014
New Revision: 268256
URL: http://svnweb.freebsd.org/changeset/base/268256

Log:
  After EFI support was added to the installer, it needed to allow boot
  partitions of types other than "freebsd-boot" (in particular, "efi").
  This allows the removal of some nasty hacks for supporting PowerPC systems,
  in particular aliasing freebsd-boot to apple-boot on APM and an IBM-specific
  code on MBR.
  
  This changes the installer to use the correct names, which also breaks a
  degeneracy in the meaning of "freebsd-boot" that allows the addition
  of support for some newer IBM systems that can boot from GPT in addition to
  MBR. Since I have no idea how to detect which those systems are, leave
  the default on IBM PPC systems as MBR for now.

Modified:
  head/sbin/geom/class/part/gpart.8
  head/sys/geom/part/g_part.c
  head/sys/geom/part/g_part.h
  head/sys/geom/part/g_part_apm.c
  head/sys/geom/part/g_part_gpt.c
  head/sys/geom/part/g_part_mbr.c
  head/sys/sys/gpt.h
  head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c

Modified: head/sbin/geom/class/part/gpart.8
==============================================================================
--- head/sbin/geom/class/part/gpart.8	Fri Jul  4 15:09:56 2014	(r268255)
+++ head/sbin/geom/class/part/gpart.8	Fri Jul  4 15:55:32 2014	(r268256)
@@ -553,6 +553,16 @@ for partition types that do not have sym
 Symbolic names currently understood and used by
 .Fx are:
 .Bl -tag -width ".Cm dragonfly-disklabel64"
+.It Cm apple-boot
+The system partition dedicated to storing boot loaders on some Apple
+systems.
+The scheme-specific types are
+.Qq Li "!171"
+for MBR,
+.Qq Li "!Apple_Bootstrap"
+for APM, and
+.Qq Li "!426f6f74-0000-11aa-aa11-00306543ecac"
+for GPT.
 .It Cm bios-boot
 The system partition dedicated to second stage of the boot loader program.
 Usually it is used by the GRUB 2 loader for GPT partitioning schemes.
@@ -823,6 +833,14 @@ A partition that contains a NTFS or exFA
 The scheme-specific type is
 .Qq Li "!7"
 for MBR.
+.It Cm prep-boot
+The system partition dedicated to storing boot loaders on some PowerPC systems,
+notably those made by IBM.
+The scheme-specific types are
+.Qq Li "!65"
+for MBR and
+.Qq Li "!0x9e1a2d38-c612-4316-aa26-8b49521e5a8b"
+for GPT.
 .It Cm vmware-vmfs
 A partition that contains a VMware File System (VMFS).
 The scheme-specific types are
@@ -1018,7 +1036,7 @@ Instead, the 800 KBytes bootstrap code i
 should be written with the
 .Cm gpart bootcode
 command to a partition of type
-.Cm freebsd-boot ,
+.Cm apple-boot ,
 which should also be 800 KB in size.
 .Sh OPERATIONAL FLAGS
 Actions other than the

Modified: head/sys/geom/part/g_part.c
==============================================================================
--- head/sys/geom/part/g_part.c	Fri Jul  4 15:09:56 2014	(r268255)
+++ head/sys/geom/part/g_part.c	Fri Jul  4 15:55:32 2014	(r268256)
@@ -117,6 +117,7 @@ struct g_part_alias_list {
 	{ "dragonfly-legacy", G_PART_ALIAS_DFBSD_LEGACY },
 	{ "dragonfly-hammer", G_PART_ALIAS_DFBSD_HAMMER },
 	{ "dragonfly-hammer2", G_PART_ALIAS_DFBSD_HAMMER2 },
+	{ "prep-boot", G_PART_ALIAS_PREP_BOOT },
 };
 
 SYSCTL_DECL(_kern_geom);

Modified: head/sys/geom/part/g_part.h
==============================================================================
--- head/sys/geom/part/g_part.h	Fri Jul  4 15:09:56 2014	(r268255)
+++ head/sys/geom/part/g_part.h	Fri Jul  4 15:55:32 2014	(r268256)
@@ -84,6 +84,7 @@ enum g_part_alias {
 	G_PART_ALIAS_DFBSD_LEGACY,	/* A DfBSD legacy partition entry */
 	G_PART_ALIAS_DFBSD_HAMMER,	/* A DfBSD HAMMER FS partition entry */
 	G_PART_ALIAS_DFBSD_HAMMER2,	/* A DfBSD HAMMER2 FS partition entry */
+	G_PART_ALIAS_PREP_BOOT,		/* A PREP/CHRP boot partition entry. */
 	/* Keep the following last */
 	G_PART_ALIAS_COUNT
 };

Modified: head/sys/geom/part/g_part_apm.c
==============================================================================
--- head/sys/geom/part/g_part_apm.c	Fri Jul  4 15:09:56 2014	(r268255)
+++ head/sys/geom/part/g_part_apm.c	Fri Jul  4 15:55:32 2014	(r268256)
@@ -149,11 +149,6 @@ apm_parse_type(const char *type, char *b
 		strcpy(buf, APM_ENT_TYPE_APPLE_UFS);
 		return (0);
 	}
-	alias = g_part_alias_name(G_PART_ALIAS_FREEBSD_BOOT);
-	if (!strcasecmp(type, alias)) {
-		strcpy(buf, APM_ENT_TYPE_APPLE_BOOT);
-		return (0);
-	}
 	alias = g_part_alias_name(G_PART_ALIAS_FREEBSD);
 	if (!strcasecmp(type, alias)) {
 		strcpy(buf, APM_ENT_TYPE_FREEBSD);

Modified: head/sys/geom/part/g_part_gpt.c
==============================================================================
--- head/sys/geom/part/g_part_gpt.c	Fri Jul  4 15:09:56 2014	(r268255)
+++ head/sys/geom/part/g_part_gpt.c	Fri Jul  4 15:55:32 2014	(r268256)
@@ -190,6 +190,7 @@ static struct uuid gpt_uuid_dfbsd_hammer
 static struct uuid gpt_uuid_dfbsd_hammer2 = GPT_ENT_TYPE_DRAGONFLY_HAMMER2;
 static struct uuid gpt_uuid_dfbsd_label32 = GPT_ENT_TYPE_DRAGONFLY_LABEL32;
 static struct uuid gpt_uuid_dfbsd_label64 = GPT_ENT_TYPE_DRAGONFLY_LABEL64;
+static struct uuid gpt_uuid_prep_boot = GPT_ENT_TYPE_PREP_BOOT;
 
 static struct g_part_uuid_alias {
 	struct uuid *uuid;
@@ -240,6 +241,7 @@ static struct g_part_uuid_alias {
 	{ &gpt_uuid_dfbsd_hammer2,	G_PART_ALIAS_DFBSD_HAMMER2,	 0 },
 	{ &gpt_uuid_dfbsd_label32,	G_PART_ALIAS_DFBSD,		 0xa5 },
 	{ &gpt_uuid_dfbsd_label64,	G_PART_ALIAS_DFBSD64,		 0xa5 },
+	{ &gpt_uuid_prep_boot,		G_PART_ALIAS_PREP_BOOT,		 0x41 },
 	{ NULL, 0, 0 }
 };
 

Modified: head/sys/geom/part/g_part_mbr.c
==============================================================================
--- head/sys/geom/part/g_part_mbr.c	Fri Jul  4 15:09:56 2014	(r268255)
+++ head/sys/geom/part/g_part_mbr.c	Fri Jul  4 15:55:32 2014	(r268256)
@@ -127,7 +127,7 @@ static struct g_part_mbr_alias {
 	{ DOSPTYP_LINUX,	G_PART_ALIAS_LINUX_DATA },
 	{ DOSPTYP_LINLVM,	G_PART_ALIAS_LINUX_LVM },
 	{ DOSPTYP_LINRAID,	G_PART_ALIAS_LINUX_RAID },
-	{ DOSPTYP_PPCBOOT,	G_PART_ALIAS_FREEBSD_BOOT },
+	{ DOSPTYP_PPCBOOT,	G_PART_ALIAS_PREP_BOOT },
 	{ DOSPTYP_VMFS,		G_PART_ALIAS_VMFS },
 	{ DOSPTYP_VMKDIAG,	G_PART_ALIAS_VMKDIAG },
 };

Modified: head/sys/sys/gpt.h
==============================================================================
--- head/sys/sys/gpt.h	Fri Jul  4 15:09:56 2014	(r268255)
+++ head/sys/sys/gpt.h	Fri Jul  4 15:55:32 2014	(r268256)
@@ -91,6 +91,8 @@ struct gpt_ent {
 	{0x516e7cb8,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
 #define	GPT_ENT_TYPE_FREEBSD_ZFS	\
 	{0x516e7cba,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
+#define	GPT_ENT_TYPE_PREP_BOOT		\
+	{0x9e1a2d38,0xc612,0x4316,0xaa,0x26,{0x8b,0x49,0x52,0x1e,0x5a,0x8b}}
 
 /*
  * The following are unused but documented here to avoid reuse.

Modified: head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c
==============================================================================
--- head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c	Fri Jul  4 15:09:56 2014	(r268255)
+++ head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c	Fri Jul  4 15:55:32 2014	(r268256)
@@ -60,7 +60,8 @@ is_scheme_bootable(const char *part_type
 	if (strcmp(platform, "ps3") == 0 && strcmp(part_type, "GPT") == 0)
 		return (1);
 	if (strcmp(platform, "chrp") == 0 &&
-	    (strcmp(part_type, "MBR") == 0 || strcmp(part_type, "BSD") == 0))
+	    (strcmp(part_type, "MBR") == 0 || strcmp(part_type, "BSD") == 0 ||
+	     strcmp(part_type, "GPT") == 0))
 		return (1);
 
 	return (0);
@@ -68,13 +69,28 @@ is_scheme_bootable(const char *part_type
 
 size_t
 bootpart_size(const char *part_type) {
+	size_t platlen = sizeof(platform);
+	if (strlen(platform) == 0)
+		sysctlbyname("hw.platform", platform, &platlen, NULL, -1);
+
 	if (strcmp(part_type, "APM") == 0 || strcmp(part_type, "MBR") == 0)
 		return (800*1024);
+	if (strcmp(platform, "chrp") == 0 && strcmp(part_type, "GPT") == 0)
+		return (800*1024);
 	return (0);
 }
 
 const char *
 bootpart_type(const char *scheme) {
+	size_t platlen = sizeof(platform);
+	if (strlen(platform) == 0)
+		sysctlbyname("hw.platform", platform, &platlen, NULL, -1);
+
+	if (strcmp(platform, "chrp") == 0)
+		return ("prep-boot");
+	if (strcmp(platform, "powermac") == 0)
+		return ("apple-boot");
+
 	return ("freebsd-boot");
 }
 
@@ -85,9 +101,14 @@ bootcode_path(const char *part_type) {
 	
 const char *
 partcode_path(const char *part_type) {
+	size_t platlen = sizeof(platform);
+	if (strlen(platform) == 0)
+		sysctlbyname("hw.platform", platform, &platlen, NULL, -1);
+
 	if (strcmp(part_type, "APM") == 0)
 		return ("/boot/boot1.hfs");
-	if (strcmp(part_type, "MBR") == 0)
+	if (strcmp(part_type, "MBR") == 0 ||
+	    (strcmp(platform, "chrp") == 0 && strcmp(part_type, "GPT") == 0))
 		return ("/boot/boot1.elf");
 	return (NULL);
 }


More information about the svn-src-all mailing list