Date: Mon, 25 Jun 2018 11:01:12 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r335632 - in head/sys: dev/vt/hw/vga x86/include x86/isa x86/x86 Message-ID: <201806251101.w5PB1CH0008674@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <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 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.c Mon Jun 25 10:52:41 2018 (r335631) +++ head/sys/x86/isa/atrtc.c Mon Jun 25 11:01:12 2018 (r335632) @@ -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 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 <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 +}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806251101.w5PB1CH0008674>