diff options
author | emaste <emaste@FreeBSD.org> | 2014-09-15 17:49:46 +0000 |
---|---|---|
committer | emaste <emaste@FreeBSD.org> | 2014-09-15 17:49:46 +0000 |
commit | 37dd226a2e5a8eb6fbf87a2ae6343413e4596b7e (patch) | |
tree | 6ec3d0a2e44e9d444b5d48068aa88b7d15d4a4e1 /usr.sbin/bsdinstall | |
parent | 11d930cebb6b8779359f2502378057ee9a3dc214 (diff) | |
download | FreeBSD-src-37dd226a2e5a8eb6fbf87a2ae6343413e4596b7e.zip FreeBSD-src-37dd226a2e5a8eb6fbf87a2ae6343413e4596b7e.tar.gz |
MFC EFI support for the installer
r264978 (nwhitehorn):
Add EFI support to the installer. This requires that the kernel
provide a sysctl to determine what firmware is in use. This sysctl
does not exist yet, so the following blocks are in front of the
wheels:
- I've provisionally called this "hw.platform" after the equivalent
thing on PPC
- The logic to check the sysctl is short-circuited to always choose
BIOS. There's a comment in the top of the file about how to turn
this off.
If IA64 acquired a boot1.efifat-like thing (probably with very few
modifications), the same code could be adapted there.
r265016 (nwhitehorn):
Finish connecting up installer UEFI support. If the kernel was
booted using EFI, set up the disks for an EFI system. If booted from
BIOS/CSM, set up for BIOS.
r268256 (nwhitehorn):
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.
Approved by: re
PR: 193658
Relnotes: Yes
Diffstat (limited to 'usr.sbin/bsdinstall')
-rw-r--r-- | usr.sbin/bsdinstall/partedit/gpart_ops.c | 9 | ||||
-rw-r--r-- | usr.sbin/bsdinstall/partedit/partedit.h | 9 | ||||
-rw-r--r-- | usr.sbin/bsdinstall/partedit/partedit_generic.c | 5 | ||||
-rw-r--r-- | usr.sbin/bsdinstall/partedit/partedit_pc98.c | 5 | ||||
-rw-r--r-- | usr.sbin/bsdinstall/partedit/partedit_powerpc.c | 30 | ||||
-rw-r--r-- | usr.sbin/bsdinstall/partedit/partedit_sparc64.c | 5 | ||||
-rw-r--r-- | usr.sbin/bsdinstall/partedit/partedit_x86.c | 64 |
7 files changed, 108 insertions, 19 deletions
diff --git a/usr.sbin/bsdinstall/partedit/gpart_ops.c b/usr.sbin/bsdinstall/partedit/gpart_ops.c index 289ac98..27feb57 100644 --- a/usr.sbin/bsdinstall/partedit/gpart_ops.c +++ b/usr.sbin/bsdinstall/partedit/gpart_ops.c @@ -584,7 +584,7 @@ set_default_part_metadata(const char *name, const char *scheme, if (strcmp(type, "freebsd-swap") == 0) mountpoint = "none"; - if (strcmp(type, "freebsd-boot") == 0) + if (strcmp(type, bootpart_type(scheme)) == 0) md->bootcode = 1; /* VTOC8 needs partcode in UFS partitions */ @@ -949,7 +949,8 @@ addpartform: LIST_FOREACH(gc, &pp->lg_config, lg_config) if (strcmp(gc->lg_name, "type") == 0) break; - if (gc != NULL && strcmp(gc->lg_val, "freebsd-boot") == 0) + if (gc != NULL && strcmp(gc->lg_val, + bootpart_type(scheme)) == 0) break; } @@ -971,7 +972,7 @@ addpartform: gctl_ro_param(r, "arg0", -1, geom->lg_name); gctl_ro_param(r, "flags", -1, GPART_FLAGS); gctl_ro_param(r, "verb", -1, "add"); - gctl_ro_param(r, "type", -1, "freebsd-boot"); + gctl_ro_param(r, "type", -1, bootpart_type(scheme)); snprintf(sizestr, sizeof(sizestr), "%jd", bootpart_size(scheme) / sector); gctl_ro_param(r, "size", -1, sizestr); @@ -1031,7 +1032,7 @@ addpartform: gctl_issue(r); /* Error usually expected and non-fatal */ gctl_free(r); - if (strcmp(items[0].text, "freebsd-boot") == 0) + if (strcmp(items[0].text, bootpart_type(scheme)) == 0) get_part_metadata(newpartname, 1)->bootcode = 1; else if (strcmp(items[0].text, "freebsd") == 0) gpart_partition(newpartname, "BSD"); diff --git a/usr.sbin/bsdinstall/partedit/partedit.h b/usr.sbin/bsdinstall/partedit/partedit.h index 121e3a2..32e3a36 100644 --- a/usr.sbin/bsdinstall/partedit/partedit.h +++ b/usr.sbin/bsdinstall/partedit/partedit.h @@ -74,9 +74,10 @@ void set_default_part_metadata(const char *name, const char *scheme, /* machine-dependent bootability checks */ const char *default_scheme(void); -int is_scheme_bootable(const char *part_type); -size_t bootpart_size(const char *part_type); -const char *bootcode_path(const char *part_type); -const char *partcode_path(const char *part_type); +int is_scheme_bootable(const char *scheme); +size_t bootpart_size(const char *scheme); +const char *bootpart_type(const char *scheme); +const char *bootcode_path(const char *scheme); +const char *partcode_path(const char *scheme); #endif diff --git a/usr.sbin/bsdinstall/partedit/partedit_generic.c b/usr.sbin/bsdinstall/partedit/partedit_generic.c index 96faafa..8498a78 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_generic.c +++ b/usr.sbin/bsdinstall/partedit/partedit_generic.c @@ -58,6 +58,11 @@ bootpart_size(const char *part_type) { } const char * +bootpart_type(const char *scheme) { + return ("freebsd-boot"); +} + +const char * bootcode_path(const char *part_type) { return (NULL); } diff --git a/usr.sbin/bsdinstall/partedit/partedit_pc98.c b/usr.sbin/bsdinstall/partedit/partedit_pc98.c index ec438f6..dd075a1 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_pc98.c +++ b/usr.sbin/bsdinstall/partedit/partedit_pc98.c @@ -52,6 +52,11 @@ bootpart_size(const char *part_type) { } const char * +bootpart_type(const char *scheme) { + return ("freebsd-boot"); +} + +const char * bootcode_path(const char *part_type) { if (strcmp(part_type, "PC98") == 0) return ("/boot/pc98boot"); diff --git a/usr.sbin/bsdinstall/partedit/partedit_powerpc.c b/usr.sbin/bsdinstall/partedit/partedit_powerpc.c index 06129c7..77c682a 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,21 +69,46 @@ 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"); +} + +const char * bootcode_path(const char *part_type) { return (NULL); } 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); } diff --git a/usr.sbin/bsdinstall/partedit/partedit_sparc64.c b/usr.sbin/bsdinstall/partedit/partedit_sparc64.c index b8ee052..8232c55 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_sparc64.c +++ b/usr.sbin/bsdinstall/partedit/partedit_sparc64.c @@ -50,6 +50,11 @@ bootpart_size(const char *part_type) { } const char * +bootpart_type(const char *scheme) { + return ("freebsd-boot"); +} + +const char * bootcode_path(const char *part_type) { return (NULL); } diff --git a/usr.sbin/bsdinstall/partedit/partedit_x86.c b/usr.sbin/bsdinstall/partedit/partedit_x86.c index a03a7a7..156674b 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_x86.c +++ b/usr.sbin/bsdinstall/partedit/partedit_x86.c @@ -26,10 +26,15 @@ * $FreeBSD$ */ +#include <sys/types.h> +#include <sys/sysctl.h> #include <string.h> #include "partedit.h" +static char platform[255] = ""; +static const char *platform_sysctl = "machdep.bootmethod"; + const char * default_scheme(void) { return ("GPT"); @@ -37,27 +42,60 @@ default_scheme(void) { int is_scheme_bootable(const char *part_type) { - if (strcmp(part_type, "BSD") == 0) - return (1); + size_t platlen = sizeof(platform); + if (strlen(platform) == 0) + sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); + if (strcmp(part_type, "GPT") == 0) return (1); - if (strcmp(part_type, "MBR") == 0) - return (1); + if (strcmp(platform, "BIOS") == 0) { + if (strcmp(part_type, "BSD") == 0) + return (1); + if (strcmp(part_type, "MBR") == 0) + return (1); + } return (0); } size_t -bootpart_size(const char *part_type) { - if (strcmp(part_type, "GPT") == 0) - return (64*1024); +bootpart_size(const char *scheme) { + size_t platlen = sizeof(platform); + if (strlen(platform) == 0) + sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); /* No partcode except for GPT */ + if (strcmp(scheme, "GPT") != 0) + return (0); + + if (strcmp(platform, "BIOS") == 0) + return (64*1024); + else + return (800*1024); + return (0); } const char * +bootpart_type(const char *scheme) { + size_t platlen = sizeof(platform); + if (strlen(platform) == 0) + sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); + + if (strcmp(platform, "UEFI") == 0) + return ("efi"); + + return ("freebsd-boot"); +} + +const char * bootcode_path(const char *part_type) { + size_t platlen = sizeof(platform); + if (strlen(platform) == 0) + sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); + if (strcmp(platform, "UEFI") == 0) + return (NULL); + if (strcmp(part_type, "GPT") == 0) return ("/boot/pmbr"); if (strcmp(part_type, "MBR") == 0) @@ -70,8 +108,16 @@ bootcode_path(const char *part_type) { const char * partcode_path(const char *part_type) { - if (strcmp(part_type, "GPT") == 0) - return ("/boot/gptboot"); + size_t platlen = sizeof(platform); + if (strlen(platform) == 0) + sysctlbyname(platform_sysctl, platform, &platlen, NULL, -1); + + if (strcmp(part_type, "GPT") == 0) { + if (strcmp(platform, "UEFI") == 0) + return ("/boot/boot1.efifat"); + else + return ("/boot/gptboot"); + } /* No partcode except for GPT */ return (NULL); |