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.
This commit is contained in:
parent
a7fa939bb3
commit
6b446ed5ab
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=264978
@ -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 @@ gpart_create(struct gprovider *pp, char *default_type, char *default_size,
|
||||
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 @@ gpart_create(struct gprovider *pp, char *default_type, char *default_size,
|
||||
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 @@ gpart_create(struct gprovider *pp, char *default_type, char *default_size,
|
||||
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");
|
||||
|
@ -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
|
||||
|
@ -57,6 +57,11 @@ bootpart_size(const char *part_type) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
const char *
|
||||
bootpart_type(const char *scheme) {
|
||||
return ("freebsd-boot");
|
||||
}
|
||||
|
||||
const char *
|
||||
bootcode_path(const char *part_type) {
|
||||
return (NULL);
|
||||
|
@ -51,6 +51,11 @@ bootpart_size(const char *part_type) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
const char *
|
||||
bootpart_type(const char *scheme) {
|
||||
return ("freebsd-boot");
|
||||
}
|
||||
|
||||
const char *
|
||||
bootcode_path(const char *part_type) {
|
||||
if (strcmp(part_type, "PC98") == 0)
|
||||
|
@ -73,6 +73,11 @@ bootpart_size(const char *part_type) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
const char *
|
||||
bootpart_type(const char *scheme) {
|
||||
return ("freebsd-boot");
|
||||
}
|
||||
|
||||
const char *
|
||||
bootcode_path(const char *part_type) {
|
||||
return (NULL);
|
||||
|
@ -49,6 +49,11 @@ bootpart_size(const char *part_type) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
const char *
|
||||
bootpart_type(const char *scheme) {
|
||||
return ("freebsd-boot");
|
||||
}
|
||||
|
||||
const char *
|
||||
bootcode_path(const char *part_type) {
|
||||
return (NULL);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user