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
This commit is contained in:
Konstantin Belousov 2018-06-25 11:01:12 +00:00
parent 120186ad8c
commit 7705dd4df0
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=335632
4 changed files with 35 additions and 50 deletions

View File

@ -48,9 +48,8 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <machine/bus.h>
#if ((defined(__amd64__) || defined(__i386__)) && defined(DEV_ACPI))
#include <contrib/dev/acpica/include/acpi.h>
#if defined(__amd64__) || defined(__i386__)
#include <machine/md_var.h>
#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", &ignore);
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(&flags))
return (false);
return ((flags & ACPI_FADT_NO_VGA) != 0);
#else
return (false);
#endif
}
static int

View File

@ -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);

View File

@ -32,7 +32,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_acpi.h"
#include "opt_isa.h"
#include <sys/param.h>
@ -55,10 +54,8 @@ __FBSDID("$FreeBSD$");
#endif
#include <machine/intr_machdep.h>
#include "clock_if.h"
#ifdef DEV_ACPI
#include <contrib/dev/acpica/include/acpi.h>
#endif
#include <machine/md_var.h>
/*
* 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(&flags))
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

View File

@ -41,6 +41,7 @@
#include <sys/cdefs.h>
__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 <isa/isareg.h>
#include <contrib/dev/acpica/include/acpi.h>
#define STATE_RUNNING 0x0
#define STATE_MWAIT 0x1
#define STATE_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 = acpi_map_table(physaddr, ACPI_SIG_FADT);
if (fadt == NULL)
return (false);
*flagsp = fadt->BootFlags;
acpi_unmap_table(fadt);
return (true);
#else
return (false);
#endif
}