svn commit: r264978 - head/usr.sbin/bsdinstall/partedit
Nathan Whitehorn
nwhitehorn at FreeBSD.org
Sat Apr 26 16:55:40 UTC 2014
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 <sys/types.h>
+#include <sys/sysctl.h>
#include <string.h>
#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);
More information about the svn-src-all
mailing list