From 1ee0f089754bd3e36c93a6e86f7f83a03ea4c74f Mon Sep 17 00:00:00 2001 From: Nathan Whitehorn Date: Fri, 4 Jul 2014 15:55:32 +0000 Subject: [PATCH] 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. --- sbin/geom/class/part/gpart.8 | 20 ++++++++++++++- sys/geom/part/g_part.c | 1 + sys/geom/part/g_part.h | 1 + sys/geom/part/g_part_apm.c | 5 ---- sys/geom/part/g_part_gpt.c | 2 ++ sys/geom/part/g_part_mbr.c | 2 +- sys/sys/gpt.h | 2 ++ .../bsdinstall/partedit/partedit_powerpc.c | 25 +++++++++++++++++-- 8 files changed, 49 insertions(+), 9 deletions(-) diff --git a/sbin/geom/class/part/gpart.8 b/sbin/geom/class/part/gpart.8 index 2ae937710da..091dc415a89 100644 --- a/sbin/geom/class/part/gpart.8 +++ b/sbin/geom/class/part/gpart.8 @@ -553,6 +553,16 @@ for partition types that do not have symbolic names. 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 exFAT filesystem. 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 image 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 diff --git a/sys/geom/part/g_part.c b/sys/geom/part/g_part.c index 2a04ba31567..9a1730b0e70 100644 --- a/sys/geom/part/g_part.c +++ b/sys/geom/part/g_part.c @@ -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); diff --git a/sys/geom/part/g_part.h b/sys/geom/part/g_part.h index 06522f50eb3..d2c2d231994 100644 --- a/sys/geom/part/g_part.h +++ b/sys/geom/part/g_part.h @@ -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 }; diff --git a/sys/geom/part/g_part_apm.c b/sys/geom/part/g_part_apm.c index bb79e568156..90357cf047a 100644 --- a/sys/geom/part/g_part_apm.c +++ b/sys/geom/part/g_part_apm.c @@ -149,11 +149,6 @@ apm_parse_type(const char *type, char *buf, size_t bufsz) 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); diff --git a/sys/geom/part/g_part_gpt.c b/sys/geom/part/g_part_gpt.c index b9e6bae1488..5e04d93f29e 100644 --- a/sys/geom/part/g_part_gpt.c +++ b/sys/geom/part/g_part_gpt.c @@ -190,6 +190,7 @@ static struct uuid gpt_uuid_dfbsd_hammer = GPT_ENT_TYPE_DRAGONFLY_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 } }; diff --git a/sys/geom/part/g_part_mbr.c b/sys/geom/part/g_part_mbr.c index 73101ff6929..f2ca6b6443a 100644 --- a/sys/geom/part/g_part_mbr.c +++ b/sys/geom/part/g_part_mbr.c @@ -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 }, }; diff --git a/sys/sys/gpt.h b/sys/sys/gpt.h index ba07206ec3a..ecf75368a23 100644 --- a/sys/sys/gpt.h +++ b/sys/sys/gpt.h @@ -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. diff --git a/usr.sbin/bsdinstall/partedit/partedit_powerpc.c b/usr.sbin/bsdinstall/partedit/partedit_powerpc.c index 4fa2e0530e2..77c682a6b94 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_powerpc.c +++ b/usr.sbin/bsdinstall/partedit/partedit_powerpc.c @@ -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); }