Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F143295904
D31955.id95700.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D31955.id95700.diff
View Options
Index: sys/amd64/acpica/acpi_wakeup.c
===================================================================
--- sys/amd64/acpica/acpi_wakeup.c
+++ sys/amd64/acpica/acpi_wakeup.c
@@ -147,7 +147,7 @@
int cpu;
u_char mpbiosreason;
- if (!efi_boot) {
+ if (firmware_type != FW_UEFI) {
/* save the current value of the warm-start vector */
mpbioswarmvec = *((uint32_t *)WARMBOOT_OFF);
outb(CMOS_REG, BIOS_RESET);
@@ -172,7 +172,7 @@
}
}
- if (!efi_boot) {
+ if (firmware_type != FW_UEFI) {
/* restore the warmstart vector */
*(uint32_t *)WARMBOOT_OFF = mpbioswarmvec;
Index: sys/amd64/amd64/machdep.c
===================================================================
--- sys/amd64/amd64/machdep.c
+++ sys/amd64/amd64/machdep.c
@@ -216,8 +216,6 @@
void (*vmm_resume_p)(void);
-bool efi_boot;
-
static void
cpu_startup(dummy)
void *dummy;
@@ -835,21 +833,20 @@
* ie: an int32_t immediately precedes smap.
*/
- efihdr = (struct efi_map_header *)preload_search_info(kmdp,
- MODINFO_METADATA | MODINFOMD_EFI_MAP);
+ if (firmware_type == FW_UEFI) {
+ efihdr = (struct efi_map_header *)preload_search_info(kmdp,
+ MODINFO_METADATA | MODINFOMD_EFI_MAP);
+ add_efi_map_entries(efihdr, physmap, physmap_idx);
+ return;
+ }
+
smap = (struct bios_smap *)preload_search_info(kmdp,
MODINFO_METADATA | MODINFOMD_SMAP);
- if (efihdr == NULL && smap == NULL)
+ if (smap == NULL)
panic("No BIOS smap or EFI map info from loader!");
- if (efihdr != NULL) {
- add_efi_map_entries(efihdr, physmap, physmap_idx);
- strlcpy(bootmethod, "UEFI", sizeof(bootmethod));
- } else {
- size = *((u_int32_t *)smap - 1);
- bios_add_smap_entries(smap, size, physmap, physmap_idx);
- strlcpy(bootmethod, "BIOS", sizeof(bootmethod));
- }
+ size = *((u_int32_t *)smap - 1);
+ bios_add_smap_entries(smap, size, physmap, physmap_idx);
}
#define PAGES_PER_GB (1024 * 1024 * 1024 / PAGE_SIZE)
@@ -1158,6 +1155,9 @@
#endif
efi_systbl_phys = MD_FETCH(kmdp, MODINFOMD_FW_HANDLE, vm_paddr_t);
+ firmware_type = MD_FETCH(kmdp, MODINFOMD_EFI_MAP, void *) != NULL ?
+ FW_UEFI : FW_BIOS;
+
return (kmdp);
}
@@ -1301,10 +1301,7 @@
kmdp = init_ops.parse_preload_data(modulep);
- efi_boot = preload_search_info(kmdp, MODINFO_METADATA |
- MODINFOMD_EFI_MAP) != NULL;
-
- if (!efi_boot) {
+ if (firmware_type != FW_UEFI) {
/* Tell the bios to warmboot next time */
atomic_store_short((u_short *)0x472, 0x1234);
}
@@ -1460,7 +1457,7 @@
* Once bootblocks have updated, we can test directly for
* efi_systbl != NULL here...
*/
- if (efi_boot)
+ if (firmware_type == FW_UEFI)
vty_set_preferred(VTY_VT);
TUNABLE_INT_FETCH("hw.ibrs_disable", &hw_ibrs_disable);
Index: sys/amd64/amd64/mp_machdep.c
===================================================================
--- sys/amd64/amd64/mp_machdep.c
+++ sys/amd64/amd64/mp_machdep.c
@@ -393,13 +393,13 @@
printf("AP boot address %#lx\n", boot_address);
/* save the current value of the warm-start vector */
- if (!efi_boot)
+ if (firmware_type != FW_UEFI)
mpbioswarmvec = *((u_int32_t *) WARMBOOT_OFF);
outb(CMOS_REG, BIOS_RESET);
mpbiosreason = inb(CMOS_DATA);
/* setup a vector to our boot code */
- if (!efi_boot) {
+ if (firmware_type != FW_UEFI) {
*((volatile u_short *)WARMBOOT_OFF) = WARMBOOT_TARGET;
*((volatile u_short *)WARMBOOT_SEG) = (boot_address >> 4);
}
@@ -446,7 +446,7 @@
/* attempt to start the Application Processor */
if (!start_ap(apic_id, boot_address)) {
/* restore the warmstart vector */
- if (!efi_boot)
+ if (firmware_type != FW_UEFI)
*(u_int32_t *)WARMBOOT_OFF = mpbioswarmvec;
panic("AP #%d (PHY# %d) failed!", cpu, apic_id);
}
@@ -455,7 +455,7 @@
}
/* restore the warmstart vector */
- if (!efi_boot)
+ if (firmware_type != FW_UEFI)
*(u_int32_t *)WARMBOOT_OFF = mpbioswarmvec;
outb(CMOS_REG, BIOS_RESET);
Index: sys/amd64/include/md_var.h
===================================================================
--- sys/amd64/include/md_var.h
+++ sys/amd64/include/md_var.h
@@ -52,8 +52,6 @@
extern vm_paddr_t kernphys;
extern vm_paddr_t KERNend;
-extern bool efi_boot;
-
struct savefpu;
struct sysentvec;
Index: sys/arm64/arm64/machdep.c
===================================================================
--- sys/arm64/arm64/machdep.c
+++ sys/arm64/arm64/machdep.c
@@ -1291,8 +1291,10 @@
/* Load the physical memory ranges */
efihdr = (struct efi_map_header *)preload_search_info(kmdp,
MODINFO_METADATA | MODINFOMD_EFI_MAP);
- if (efihdr != NULL)
+ if (efihdr != NULL) {
add_efi_map_entries(efihdr);
+ firmware_type = FW_UEFI;
+ }
#ifdef FDT
else {
/* Grab physical memory regions information from device tree. */
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/kern/subr_param.c
===================================================================
--- sys/kern/subr_param.c
+++ sys/kern/subr_param.c
@@ -116,6 +116,9 @@
u_long maxssiz; /* max stack size */
u_long sgrowsiz; /* amount to grow stack */
+enum firmware_types
+ firmware_type = FW_NONE; /* firmware which is booting system */
+
SYSCTL_INT(_kern, OID_AUTO, hz, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &hz, 0,
"Number of clock ticks per second");
SYSCTL_INT(_kern, OID_AUTO, nbuf, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &nbuf, 0,
@@ -169,6 +172,27 @@
__DECONST(void *, &vm_guest_sysctl_params), 0, sysctl_enum_proc, "A",
"Virtual machine guest detected?");
+/*
+ * Parameters for the firmware_type enum
+ */
+static const struct sysctl_enum_params bootmethod_sysctl_params = {
+ &firmware_type,
+ FW_LAST,
+ {
+ [FW_BIOS] = "BIOS",
+ [FW_LINUXABI] = "LinuxABI",
+ [FW_NONE] = "",
+ [FW_UEFI] = "UEFI",
+ [FW_XEN] = "XEN",
+ [FW_LAST] = NULL
+ }
+};
+
+SYSCTL_PROC(_machdep, OID_AUTO, bootmethod,
+ CTLFLAG_RD | CTLTYPE_STRING | CTLFLAG_MPSAFE,
+ __DECONST(void *, &bootmethod_sysctl_params), 0, sysctl_enum_proc, "A",
+ "System firmware boot method");
+
/*
* Boot time overrides that are not scaled against main memory
*/
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_BIOS,
+ FW_LINUXABI,
+ FW_XEN,
+ 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,6 @@
static volatile u_int cpu_reset_proxy_active;
#endif
-char bootmethod[16];
-SYSCTL_STRING(_machdep, OID_AUTO, bootmethod, CTLFLAG_RD, bootmethod, 0,
- "System firmware boot method");
-
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_XEN;
}
boothowto |= boot_env_to_howto();
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 29, 2:05 PM (8 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28083694
Default Alt Text
D31955.id95700.diff (8 KB)
Attached To
Mode
D31955: sys: unify boot/firmware variables
Attached
Detach File
Event Timeline
Log In to Comment