From c2272faa06dec2f027c5359529cf8f4f3593c164 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Date: Tue, 13 Mar 2018 09:38:53 +0000 Subject: [PATCH] vt_vga: check if VGA is available from ACPI FADT table On x86 the IA-PC Boot Flags in the FADT can signal whether VGA is available or not. Sponsored by: Citrix systems R&D Reviewed by: marcel Differential revision: https://reviews.freebsd.org/D14397 --- sys/dev/vt/hw/vga/vt_vga.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/sys/dev/vt/hw/vga/vt_vga.c b/sys/dev/vt/hw/vga/vt_vga.c index 502aaca3377..820b6426244 100644 --- a/sys/dev/vt/hw/vga/vt_vga.c +++ b/sys/dev/vt/hw/vga/vt_vga.c @@ -30,6 +30,8 @@ * SUCH DAMAGE. */ +#include "opt_acpi.h" + #include __FBSDID("$FreeBSD$"); @@ -46,6 +48,10 @@ __FBSDID("$FreeBSD$"); #include +#if ((defined(__amd64__) || defined(__i386__)) && defined(DEV_ACPI)) +#include +#endif + struct vga_softc { bus_space_tag_t vga_fb_tag; bus_space_handle_t vga_fb_handle; @@ -1196,11 +1202,39 @@ vga_initialize(struct vt_device *vd, int textmode) return (0); } +static bool +vga_acpi_disabled(void) +{ +#if ((defined(__amd64__) || defined(__i386__)) && defined(DEV_ACPI)) + ACPI_TABLE_FADT *fadt; + vm_paddr_t physaddr; + uint16_t flags; + + 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 + + return (false); +} + static int vga_probe(struct vt_device *vd) { - return (CN_INTERNAL); + return (vga_acpi_disabled() ? CN_DEAD : CN_INTERNAL); } static int