Author: kib
Date: Mon Jun 25 11:01:12 2018
New Revision: 335632
URL: https://svnweb.freebsd.org/changeset/base/335632
Log:
Provide a helper function acpi_get_fadt_bootflags() to fetch the FADT
x86 boot flags.
Reviewed by: royger
Sponsored by: The FreeBSD Foundation
Differential revision:https://reviews.freebsd.org/D16004
MFC after:1 week
Modified:
head/sys/dev/vt/hw/vga/vt_vga.c
head/sys/x86/include/x86_var.h
head/sys/x86/isa/atrtc.c
head/sys/x86/x86/cpu_machdep.c
Modified: head/sys/dev/vt/hw/vga/vt_vga.c
==
--- head/sys/dev/vt/hw/vga/vt_vga.c Mon Jun 25 10:52:41 2018
(r335631)
+++ head/sys/dev/vt/hw/vga/vt_vga.c Mon Jun 25 11:01:12 2018
(r335632)
@@ -48,9 +48,8 @@ __FBSDID("$FreeBSD$");
#include
#include
-
-#if ((defined(__amd64__) || defined(__i386__)) && defined(DEV_ACPI))
-#include
+#if defined(__amd64__) || defined(__i386__)
+#include
#endif
struct vga_softc {
@@ -1213,36 +1212,18 @@ vga_initialize(struct vt_device *vd, int textmode)
static bool
vga_acpi_disabled(void)
{
-#if ((defined(__amd64__) || defined(__i386__)) && defined(DEV_ACPI))
- ACPI_TABLE_FADT *fadt;
- vm_paddr_t physaddr;
+#if (defined(__amd64__) || defined(__i386__)
uint16_t flags;
int ignore;
ignore = 0;
TUNABLE_INT_FETCH("hw.vga.acpi_ignore_no_vga", );
-
- if (ignore)
- return (false);
-
- physaddr = acpi_find_table(ACPI_SIG_FADT);
- if (physaddr == 0)
- return (false);
-
- fadt = acpi_map_table(physaddr, ACPI_SIG_FADT);
- if (fadt == NULL) {
- printf("vt_vga: unable to map FADT ACPI table\n");
- return (false);
- }
-
- flags = fadt->BootFlags;
- acpi_unmap_table(fadt);
-
- if (flags & ACPI_FADT_NO_VGA)
- return (true);
-#endif
-
+ if (ignore || !acpi_get_fadt_bootflags())
+ return (false);
+ return ((flags & ACPI_FADT_NO_VGA) != 0);
+#else
return (false);
+#endif
}
static int
Modified: head/sys/x86/include/x86_var.h
==
--- head/sys/x86/include/x86_var.h Mon Jun 25 10:52:41 2018
(r335631)
+++ head/sys/x86/include/x86_var.h Mon Jun 25 11:01:12 2018
(r335632)
@@ -116,6 +116,7 @@ cpu_getmaxphyaddr(void)
#endif
}
+bool acpi_get_fadt_bootflags(uint16_t *flagsp);
void *alloc_fpusave(int flags);
void busdma_swi(void);
bool cpu_mwait_usable(void);
Modified: head/sys/x86/isa/atrtc.c
==
--- head/sys/x86/isa/atrtc.cMon Jun 25 10:52:41 2018(r335631)
+++ head/sys/x86/isa/atrtc.cMon Jun 25 11:01:12 2018(r335632)
@@ -32,7 +32,6 @@
#include
__FBSDID("$FreeBSD$");
-#include "opt_acpi.h"
#include "opt_isa.h"
#include
@@ -55,10 +54,8 @@ __FBSDID("$FreeBSD$");
#endif
#include
#include "clock_if.h"
-
-#ifdef DEV_ACPI
#include
-#endif
+#include
/*
* atrtc_lock protects low-level access to individual hardware registers.
@@ -261,29 +258,12 @@ static struct isa_pnp_id atrtc_ids[] = {
static bool
atrtc_acpi_disabled(void)
{
-#ifdef DEV_ACPI
- ACPI_TABLE_FADT *fadt;
- vm_paddr_t physaddr;
uint16_t flags;
- physaddr = acpi_find_table(ACPI_SIG_FADT);
- if (physaddr == 0)
+ if (!acpi_get_fadt_bootflags())
return (false);
-
- fadt = acpi_map_table(physaddr, ACPI_SIG_FADT);
- if (fadt == NULL) {
- printf("at_rtc: unable to map FADT ACPI table\n");
- return (false);
- }
-
- flags = fadt->BootFlags;
- acpi_unmap_table(fadt);
-
- if (flags & ACPI_FADT_NO_CMOS_RTC)
+ return ((flags & ACPI_FADT_NO_CMOS_RTC) != 0);
return (true);
-#endif
-
- return (false);
}
static int
Modified: head/sys/x86/x86/cpu_machdep.c
==
--- head/sys/x86/x86/cpu_machdep.c Mon Jun 25 10:52:41 2018
(r335631)
+++ head/sys/x86/x86/cpu_machdep.c Mon Jun 25 11:01:12 2018
(r335632)
@@ -41,6 +41,7 @@
#include
__FBSDID("$FreeBSD$");
+#include "opt_acpi.h"
#include "opt_atpic.h"
#include "opt_cpu.h"
#include "opt_ddb.h"
@@ -98,6 +99,8 @@ __FBSDID("$FreeBSD$");
#include
+#include
+
#defineSTATE_RUNNING 0x0
#defineSTATE_MWAIT 0x1
#defineSTATE_SLEEPING 0x2
@@ -930,3 +933,23 @@ restore_wp(bool old_wp)
load_cr0(rcr0() | CR0_WP);
}
+bool
+acpi_get_fadt_bootflags(uint16_t *flagsp)
+{
+#ifdef DEV_ACPI
+ ACPI_TABLE_FADT *fadt;
+ vm_paddr_t physaddr;
+
+ physaddr = acpi_find_table(ACPI_SIG_FADT);
+ if (physaddr == 0)
+ return (false);
+ fadt =