From owner-svn-src-head@FreeBSD.ORG Sat Apr 26 16:55:40 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 8ED4FFE1; Sat, 26 Apr 2014 16:55:40 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6F5931D16; Sat, 26 Apr 2014 16:55:40 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3QGtexp036818; Sat, 26 Apr 2014 16:55:40 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3QGtdMO036810; Sat, 26 Apr 2014 16:55:39 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201404261655.s3QGtdMO036810@svn.freebsd.org> From: Nathan Whitehorn Date: Sat, 26 Apr 2014 16:55:39 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r264978 - head/usr.sbin/bsdinstall/partedit X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Apr 2014 16:55:40 -0000 Author: nwhitehorn Date: Sat Apr 26 16:55:38 2014 New Revision: 264978 URL: http://svnweb.freebsd.org/changeset/base/264978 Log: 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. Modified: head/usr.sbin/bsdinstall/partedit/gpart_ops.c head/usr.sbin/bsdinstall/partedit/partedit.h head/usr.sbin/bsdinstall/partedit/partedit_generic.c head/usr.sbin/bsdinstall/partedit/partedit_pc98.c head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c head/usr.sbin/bsdinstall/partedit/partedit_sparc64.c head/usr.sbin/bsdinstall/partedit/partedit_x86.c Modified: head/usr.sbin/bsdinstall/partedit/gpart_ops.c ============================================================================== --- head/usr.sbin/bsdinstall/partedit/gpart_ops.c Sat Apr 26 16:48:09 2014 (r264977) +++ head/usr.sbin/bsdinstall/partedit/gpart_ops.c Sat Apr 26 16:55:38 2014 (r264978) @@ -584,7 +584,7 @@ set_default_part_metadata(const char *na 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"); Modified: head/usr.sbin/bsdinstall/partedit/partedit.h ============================================================================== --- head/usr.sbin/bsdinstall/partedit/partedit.h Sat Apr 26 16:48:09 2014 (r264977) +++ head/usr.sbin/bsdinstall/partedit/partedit.h Sat Apr 26 16:55:38 2014 (r264978) @@ -74,9 +74,10 @@ void set_default_part_metadata(const cha /* 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 Modified: head/usr.sbin/bsdinstall/partedit/partedit_generic.c ============================================================================== --- head/usr.sbin/bsdinstall/partedit/partedit_generic.c Sat Apr 26 16:48:09 2014 (r264977) +++ head/usr.sbin/bsdinstall/partedit/partedit_generic.c Sat Apr 26 16:55:38 2014 (r264978) @@ -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); } Modified: head/usr.sbin/bsdinstall/partedit/partedit_pc98.c ============================================================================== --- head/usr.sbin/bsdinstall/partedit/partedit_pc98.c Sat Apr 26 16:48:09 2014 (r264977) +++ head/usr.sbin/bsdinstall/partedit/partedit_pc98.c Sat Apr 26 16:55:38 2014 (r264978) @@ -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"); Modified: head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c ============================================================================== --- head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c Sat Apr 26 16:48:09 2014 (r264977) +++ head/usr.sbin/bsdinstall/partedit/partedit_powerpc.c Sat Apr 26 16:55:38 2014 (r264978) @@ -74,6 +74,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); } Modified: head/usr.sbin/bsdinstall/partedit/partedit_sparc64.c ============================================================================== --- head/usr.sbin/bsdinstall/partedit/partedit_sparc64.c Sat Apr 26 16:48:09 2014 (r264977) +++ head/usr.sbin/bsdinstall/partedit/partedit_sparc64.c Sat Apr 26 16:55:38 2014 (r264978) @@ -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); } Modified: head/usr.sbin/bsdinstall/partedit/partedit_x86.c ============================================================================== --- head/usr.sbin/bsdinstall/partedit/partedit_x86.c Sat Apr 26 16:48:09 2014 (r264977) +++ head/usr.sbin/bsdinstall/partedit/partedit_x86.c Sat Apr 26 16:55:38 2014 (r264978) @@ -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);