From 93305d7b62a5480b539cc4a5f5bfd8c98a2b759a Mon Sep 17 00:00:00 2001 From: jmcneill Date: Tue, 20 Jun 2006 22:36:58 +0000 Subject: [PATCH] Make resetting the video BIOS in the ACPI wakecode optional. It can be configured via sysctl machdep.acpi_vbios_reset. Defaults to 1 -- reset vbios on resume. --- sys/arch/i386/acpi/acpi_wakecode.S | 11 ++++--- sys/arch/i386/acpi/acpi_wakeup.c | 49 ++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 6 deletions(-) diff --git a/sys/arch/i386/acpi/acpi_wakecode.S b/sys/arch/i386/acpi/acpi_wakecode.S index 6d952b30bb55..55cb19cd1fe1 100644 --- a/sys/arch/i386/acpi/acpi_wakecode.S +++ b/sys/arch/i386/acpi/acpi_wakecode.S @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakecode.S,v 1.7 2006/06/17 17:11:53 jmcneill Exp $ */ +/* $NetBSD: acpi_wakecode.S,v 1.8 2006/06/20 22:36:58 jmcneill Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -96,16 +96,18 @@ wakeup_16: call beepon - /* The following needs to be configurable */ -/*#ifdef notyet*/ + /* Only reset the VBIOS if machdep.acpi_vbios_reset=1 */ + cmpb $1,vbios_reset + jne novbiosreset + /* Kick the VBIOS. */ lcall $0xc000,$3 movw %cs,%ax movw %ax,%ds movw %ax,%ss +novbiosreset: -/*#endif*/ call beepoff /* Get physical address of the code */ @@ -251,3 +253,4 @@ previous_fs: .word 0 previous_gs: .word 0 previous_ss: .word 0 where_to_recover: .long 0 +vbios_reset: .byte 0 diff --git a/sys/arch/i386/acpi/acpi_wakeup.c b/sys/arch/i386/acpi/acpi_wakeup.c index f6382fa4456c..7f18439412d8 100644 --- a/sys/arch/i386/acpi/acpi_wakeup.c +++ b/sys/arch/i386/acpi/acpi_wakeup.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_wakeup.c,v 1.26 2006/06/19 02:33:19 jmcneill Exp $ */ +/* $NetBSD: acpi_wakeup.c,v 1.27 2006/06/20 22:36:58 jmcneill Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.26 2006/06/19 02:33:19 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.27 2006/06/20 22:36:58 jmcneill Exp $"); /*- * Copyright (c) 2001 Takanori Watanabe @@ -73,6 +73,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.26 2006/06/19 02:33:19 jmcneill Ex #include #include #include +#include #include #include @@ -98,6 +99,10 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_wakeup.c,v 1.26 2006/06/19 02:33:19 jmcneill Ex static paddr_t phys_wakeup = 0; +static int acpi_md_node = CTL_EOL; +static int acpi_md_vbios_reset = 1; + +static int sysctl_md_acpi_vbios_reset(SYSCTLFN_ARGS); uint32_t acpi_md_get_npages_of_wakecode(void) @@ -357,6 +362,8 @@ acpi_md_sleep(int state) p_gdt->rd_limit = r_gdt.rd_limit; p_gdt->rd_base = vtophys(r_gdt.rd_base); + WAKECODE_FIXUP(vbios_reset, uint8_t, acpi_md_vbios_reset); + WAKECODE_FIXUP(previous_cr0, uint32_t, r_cr0); WAKECODE_FIXUP(previous_cr2, uint32_t, r_cr2); WAKECODE_FIXUP(previous_cr4, uint32_t, r_cr4); @@ -458,3 +465,41 @@ out: #undef WAKECODE_FIXUP #undef WAKECODE_BCOPY } + +SYSCTL_SETUP(sysctl_md_acpi_setup, "acpi i386 sysctl setup") +{ + const struct sysctlnode *node; + const struct sysctlnode *ssnode; + + if (sysctl_createv(NULL, 0, NULL, &node, CTLFLAG_PERMANENT, + CTLTYPE_NODE, "machdep", NULL, NULL, 0, NULL, 0, CTL_MACHDEP, + CTL_EOL) != 0) + return; + if (sysctl_createv(NULL, 0, &node, &ssnode, CTLFLAG_READWRITE, + CTLTYPE_INT, "acpi_vbios_reset", NULL, sysctl_md_acpi_vbios_reset, + 0, NULL, 0, CTL_CREATE, CTL_EOL) != 0) + return; + + acpi_md_node = node->sysctl_num; +} + +static int +sysctl_md_acpi_vbios_reset(SYSCTLFN_ARGS) +{ + int error, t; + struct sysctlnode node; + + node = *rnode; + t = acpi_md_vbios_reset; + node.sysctl_data = &t; + error = sysctl_lookup(SYSCTLFN_CALL(&node)); + if (error || newp == NULL) + return error; + + if (t < 0 || t > 1) + return EINVAL; + + acpi_md_vbios_reset = t; + + return 0; +}