From 881682da6dc9e7879f9fbff8076617652150f702 Mon Sep 17 00:00:00 2001 From: nwhitehorn Date: Sat, 26 Apr 2014 16:55:38 +0000 Subject: 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. --- usr.sbin/bsdinstall/partedit/partedit_x86.c | 64 +++++++++++++++++++++++++---- 1 file changed, 55 insertions(+), 9 deletions(-) (limited to 'usr.sbin/bsdinstall/partedit/partedit_x86.c') diff --git a/usr.sbin/bsdinstall/partedit/partedit_x86.c b/usr.sbin/bsdinstall/partedit/partedit_x86.c index a03a7a7..c9eda5d 100644 --- a/usr.sbin/bsdinstall/partedit/partedit_x86.c +++ b/usr.sbin/bsdinstall/partedit/partedit_x86.c @@ -26,10 +26,15 @@ * $FreeBSD$ */ +#include +#include #include #include "partedit.h" +static char platform[255] = "BIOS"; /* XXX once sysctl exists, make this an empty string */ +static const char *platform_sysctl = "hw.platform"; + 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, "EFI") == 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, "EFI") == 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, "EFI") == 0) + return ("/boot/boot1.efifat"); + else + return ("/boot/gptboot"); + } /* No partcode except for GPT */ return (NULL); -- cgit v1.1