Page MenuHomeFreeBSD

D31955.id95141.diff
No OneTemporary

D31955.id95141.diff

Index: sys/amd64/amd64/machdep.c
===================================================================
--- sys/amd64/amd64/machdep.c
+++ sys/amd64/amd64/machdep.c
@@ -1176,11 +1176,11 @@
if (efihdr != NULL) {
add_efi_map_entries(efihdr, physmap, physmap_idx);
- strlcpy(bootmethod, "UEFI", sizeof(bootmethod));
+ firmware_type = FW_UEFI;
} else {
size = *((u_int32_t *)smap - 1);
bios_add_smap_entries(smap, size, physmap, physmap_idx);
- strlcpy(bootmethod, "BIOS", sizeof(bootmethod));
+ firmware_type = FW_BIOS;
}
}
Index: sys/arm64/acpica/acpi_machdep.c
===================================================================
--- sys/arm64/acpica/acpi_machdep.c
+++ sys/arm64/acpica/acpi_machdep.c
@@ -234,7 +234,7 @@
{
/* Only parse ACPI tables when booting via ACPI */
- if (arm64_bus_method != ARM64_BUS_ACPI)
+ if (firmware_type != FW_UEFI)
return;
acpi_pxm_init(MAXCPU, get_physaddr_max());
Index: sys/arm64/arm64/machdep.c
===================================================================
--- sys/arm64/arm64/machdep.c
+++ sys/arm64/arm64/machdep.c
@@ -103,7 +103,7 @@
static void get_fpcontext(struct thread *td, mcontext_t *mcp);
static void set_fpcontext(struct thread *td, mcontext_t *mcp);
-enum arm64_bus arm64_bus_method = ARM64_BUS_NONE;
+enum firmware_types firmware_type = FW_NONE;
struct pcpu __pcpu[MAXCPU];
@@ -1199,13 +1199,13 @@
if (has_acpi &&
strncmp(order, "acpi", 4) == 0 &&
(order[4] == ',' || order[4] == '\0')) {
- arm64_bus_method = ARM64_BUS_ACPI;
+ firmware_type = FW_UEFI;
break;
}
if (has_fdt &&
strncmp(order, "fdt", 3) == 0 &&
(order[3] == ',' || order[3] == '\0')) {
- arm64_bus_method = ARM64_BUS_FDT;
+ firmware_type = FW_DEVTREE;
break;
}
order = strchr(order, ',');
@@ -1213,15 +1213,15 @@
freeenv(env);
/* If we set the bus method it is valid */
- if (arm64_bus_method != ARM64_BUS_NONE)
+ if (firmware_type != FW_NONE)
return (true);
}
/* If no order or an invalid order was set use the default */
- if (arm64_bus_method == ARM64_BUS_NONE) {
+ if (firmware_type == FW_NONE) {
if (has_fdt)
- arm64_bus_method = ARM64_BUS_FDT;
+ firmware_type = FW_DEVTREE;
else if (has_acpi)
- arm64_bus_method = ARM64_BUS_ACPI;
+ firmware_type = FW_UEFI;
}
/*
@@ -1423,7 +1423,7 @@
strlcpy(kernelname, env, sizeof(kernelname));
#ifdef FDT
- if (arm64_bus_method == ARM64_BUS_FDT) {
+ if (firmware_type == FW_DEVTREE) {
root = OF_finddevice("/");
if (OF_getprop(root, "freebsd,dts-version", dts_version, sizeof(dts_version)) > 0) {
if (strcmp(LINUX_DTS_VERSION, dts_version) != 0)
Index: sys/arm64/arm64/mp_machdep.c
===================================================================
--- sys/arm64/arm64/mp_machdep.c
+++ sys/arm64/arm64/mp_machdep.c
@@ -669,15 +669,15 @@
CPU_SET(0, &all_cpus);
__pcpu[0].pc_mpidr = READ_SPECIALREG(mpidr_el1) & CPU_AFF_MASK;
- switch(arm64_bus_method) {
+ switch(firmware_type) {
#ifdef DEV_ACPI
- case ARM64_BUS_ACPI:
+ case FW_UEFI:
mp_quirks = MP_QUIRK_CPULIST;
cpu_init_acpi();
break;
#endif
#ifdef FDT
- case ARM64_BUS_FDT:
+ case FW_DEVTREE:
cpu_init_fdt();
break;
#endif
@@ -744,9 +744,9 @@
mp_ncpus = 1;
mp_maxid = 0;
- switch(arm64_bus_method) {
+ switch(firmware_type) {
#ifdef DEV_ACPI
- case ARM64_BUS_ACPI:
+ case FW_UEFI:
cores = cpu_count_acpi();
if (cores > 0) {
cores = MIN(cores, MAXCPU);
@@ -759,7 +759,7 @@
break;
#endif
#ifdef FDT
- case ARM64_BUS_FDT:
+ case FW_DEVTREE:
cores = ofw_cpu_early_foreach(NULL, false);
if (cores > 0) {
cores = MIN(cores, MAXCPU);
Index: sys/arm64/arm64/nexus.c
===================================================================
--- sys/arm64/arm64/nexus.c
+++ sys/arm64/arm64/nexus.c
@@ -493,7 +493,7 @@
nexus_fdt_probe(device_t dev)
{
- if (arm64_bus_method != ARM64_BUS_FDT)
+ if (firmware_type != FW_DEVTREE)
return (ENXIO);
device_quiet(dev);
@@ -554,7 +554,7 @@
nexus_acpi_probe(device_t dev)
{
- if (arm64_bus_method != ARM64_BUS_ACPI || acpi_identify() != 0)
+ if (firmware_type != FW_UEFI || acpi_identify() != 0)
return (ENXIO);
device_quiet(dev);
Index: sys/arm64/include/machdep.h
===================================================================
--- sys/arm64/include/machdep.h
+++ sys/arm64/include/machdep.h
@@ -42,14 +42,6 @@
int pad;
};
-enum arm64_bus {
- ARM64_BUS_NONE,
- ARM64_BUS_FDT,
- ARM64_BUS_ACPI,
-};
-
-extern enum arm64_bus arm64_bus_method;
-
void dbg_init(void);
bool has_hyp(void);
void initarm(struct arm64_bootparams *);
Index: sys/dev/psci/psci.c
===================================================================
--- sys/dev/psci/psci.c
+++ sys/dev/psci/psci.c
@@ -89,8 +89,8 @@
#define USE_ACPI 0
#define USE_FDT 1
#elif defined(__aarch64__)
-#define USE_ACPI (arm64_bus_method == ARM64_BUS_ACPI)
-#define USE_FDT (arm64_bus_method == ARM64_BUS_FDT)
+#define USE_ACPI (firmware_type == FW_UEFI)
+#define USE_FDT (firmware_type == FW_DEVTREE)
#else
#error Unknown architecture
#endif
Index: sys/dev/uart/uart_dev_pl011.c
===================================================================
--- sys/dev/uart/uart_dev_pl011.c
+++ sys/dev/uart/uart_dev_pl011.c
@@ -59,7 +59,7 @@
#include <sys/kdb.h>
#ifdef __aarch64__
-#define IS_FDT (arm64_bus_method == ARM64_BUS_FDT)
+#define IS_FDT (firmware_type == FW_DEVTREE)
#elif defined(FDT)
#define IS_FDT 1
#else
Index: sys/dev/xen/efi/pvefi.c
===================================================================
--- sys/dev/xen/efi/pvefi.c
+++ sys/dev/xen/efi/pvefi.c
@@ -43,8 +43,6 @@
#include <xen/interface/platform.h>
-extern char bootmethod[16];
-
static int
rt_ok(void)
{
@@ -224,7 +222,7 @@
rt_disabled = 0;
TUNABLE_INT_FETCH("efi.rt.disabled", &rt_disabled);
- if (!xen_initial_domain() || strcmp("UEFI", bootmethod) != 0 ||
+ if (!xen_initial_domain() || firmware_type != FW_UEFI ||
rt_disabled == 1)
return (0);
Index: sys/i386/i386/machdep.c
===================================================================
--- sys/i386/i386/machdep.c
+++ sys/i386/i386/machdep.c
@@ -2350,7 +2350,7 @@
init_param1();
/* Set bootmethod to BIOS: it's the only supported on i386. */
- strlcpy(bootmethod, "BIOS", sizeof(bootmethod));
+ firmware_type = FW_BIOS;
/*
* Make gdt memory segments. All segments cover the full 4GB
Index: sys/sys/systm.h
===================================================================
--- sys/sys/systm.h
+++ sys/sys/systm.h
@@ -70,6 +70,15 @@
extern int boothowto; /* reboot flags, from console subsystem */
extern int bootverbose; /* nonzero to print verbose messages */
+extern enum firmware_types {
+ FW_NONE = 0,
+ FW_UEFI,
+ FW_DEVTREE,
+ FW_BIOS,
+ FW_HYPER,
+ FW_LAST
+} firmware_type;
+
extern int maxusers; /* system tune hint */
extern int ngroups_max; /* max # of supplemental groups */
extern int vm_guest; /* Running as virtual machine guest? */
Index: sys/x86/include/x86_var.h
===================================================================
--- sys/x86/include/x86_var.h
+++ sys/x86/include/x86_var.h
@@ -95,7 +95,6 @@
extern int cpu_flush_rsb_ctxsw;
extern int x86_rngds_mitg_enable;
extern int cpu_amdc1e_bug;
-extern char bootmethod[16];
struct pcb;
struct thread;
Index: sys/x86/x86/cpu_machdep.c
===================================================================
--- sys/x86/x86/cpu_machdep.c
+++ sys/x86/x86/cpu_machdep.c
@@ -113,10 +113,30 @@
static volatile u_int cpu_reset_proxy_active;
#endif
-char bootmethod[16];
+static char bootmethod[16];
SYSCTL_STRING(_machdep, OID_AUTO, bootmethod, CTLFLAG_RD, bootmethod, 0,
"System firmware boot method");
+enum firmware_types firmware_type = FW_NONE;
+
+/*
+ * Set the sysctl bootmethod for compatibility
+ */
+static void set_bootmethod(const void *unused __unused)
+{
+ const char *const types[] = {
+ [FW_UEFI] = "UEFI",
+ [FW_BIOS] = "BIOS",
+ };
+ const char *val = "unknown";
+
+ if (firmware_type < nitems(types) && types[firmware_type] != NULL)
+ val = types[firmware_type];
+
+ strlcpy(bootmethod, val, sizeof(bootmethod));
+}
+C_SYSINIT(set_bootmethod, SI_SUB_LAST, SI_ORDER_SECOND, set_bootmethod, NULL);
+
struct msr_op_arg {
u_int msr;
int op;
Index: sys/x86/xen/pv.c
===================================================================
--- sys/x86/xen/pv.c
+++ sys/x86/xen/pv.c
@@ -365,9 +365,9 @@
xen_pvh_set_env(envp, reject_option);
if (MD_FETCH(kmdp, MODINFOMD_EFI_MAP, void *) != NULL)
- strlcpy(bootmethod, "UEFI", sizeof(bootmethod));
+ firmware_type = FW_UEFI;
else
- strlcpy(bootmethod, "BIOS", sizeof(bootmethod));
+ firmware_type = FW_BIOS;
} else {
/* Parse the extra boot information given by Xen */
if (start_info->cmdline_paddr != 0)
@@ -375,7 +375,7 @@
(char *)(start_info->cmdline_paddr + KERNBASE),
",");
kmdp = NULL;
- strlcpy(bootmethod, "XEN", sizeof(bootmethod));
+ firmware_type = FW_HYPER;
}
boothowto |= boot_env_to_howto();

File Metadata

Mime Type
text/plain
Expires
Mon, Oct 27, 4:54 AM (7 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
24271805
Default Alt Text
D31955.id95141.diff (8 KB)

Event Timeline