Mon Aug 24 11:35:27 2009 UTC ()
PR# port-i386/41929: genfb and machdep.acpi_vbios_reset=2 interaction

When acpi_vbios_reset=2, invoke vga_post_call followed by vga_post_set_mode
in the genfb pmf resume handler.


(jmcneill)
diff -r1.42 -r1.43 src/sys/arch/x86/x86/x86_autoconf.c

cvs diff -r1.42 -r1.43 src/sys/arch/x86/x86/x86_autoconf.c (expand / switch to unified diff)

--- src/sys/arch/x86/x86/x86_autoconf.c 2009/08/24 11:04:29 1.42
+++ src/sys/arch/x86/x86/x86_autoconf.c 2009/08/24 11:35:27 1.43
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: x86_autoconf.c,v 1.42 2009/08/24 11:04:29 jmcneill Exp $ */ 1/* $NetBSD: x86_autoconf.c,v 1.43 2009/08/24 11:35:27 jmcneill Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1990 The Regents of the University of California. 4 * Copyright (c) 1990 The Regents of the University of California.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * William Jolitz. 8 * William Jolitz.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -25,83 +25,103 @@ @@ -25,83 +25,103 @@
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 * 33 *
34 * @(#)autoconf.c 7.1 (Berkeley) 5/9/91 34 * @(#)autoconf.c 7.1 (Berkeley) 5/9/91
35 */ 35 */
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38__KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.42 2009/08/24 11:04:29 jmcneill Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: x86_autoconf.c,v 1.43 2009/08/24 11:35:27 jmcneill Exp $");
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/systm.h> 41#include <sys/systm.h>
42#include <sys/device.h> 42#include <sys/device.h>
43#include <sys/disklabel.h> 43#include <sys/disklabel.h>
44#include <sys/conf.h> 44#include <sys/conf.h>
45#include <sys/malloc.h> 45#include <sys/malloc.h>
46#include <sys/vnode.h> 46#include <sys/vnode.h>
47#include <sys/fcntl.h> 47#include <sys/fcntl.h>
48#include <sys/disk.h> 48#include <sys/disk.h>
49#include <sys/proc.h> 49#include <sys/proc.h>
50#include <sys/md5.h> 50#include <sys/md5.h>
51#include <sys/kauth.h> 51#include <sys/kauth.h>
52 52
53#include <machine/bootinfo.h> 53#include <machine/bootinfo.h>
54#include <machine/pio.h> 54#include <machine/pio.h>
55 55
 56#include "acpica.h"
56#include "pci.h" 57#include "pci.h"
57#include "genfb.h" 58#include "genfb.h"
58#include "wsdisplay.h" 59#include "wsdisplay.h"
 60#include "opt_vga.h"
59 61
 62#ifdef VGA_POST
 63#include <x86/vga_post.h>
 64#endif
60#include <dev/isa/isavar.h> 65#include <dev/isa/isavar.h>
61#if NPCI > 0 66#if NPCI > 0
62#include <dev/pci/pcivar.h> 67#include <dev/pci/pcivar.h>
63#endif 68#endif
64#include <dev/wsfb/genfbvar.h> 69#include <dev/wsfb/genfbvar.h>
 70#include <dev/pci/genfb_pcivar.h>
65#include <dev/ic/vgareg.h> 71#include <dev/ic/vgareg.h>
66 72
67static struct genfb_colormap_callback gfb_cb; 73static struct genfb_colormap_callback gfb_cb;
68static struct genfb_pmf_callback pmf_cb; 74static struct genfb_pmf_callback pmf_cb;
 75#ifdef VGA_POST
 76static struct vga_post *vga_posth = NULL;
 77#endif
69 78
70struct disklist *x86_alldisks; 79struct disklist *x86_alldisks;
71int x86_ndisks; 80int x86_ndisks;
72 81
73#if NPCI > 0 82#if NPCI > 0
74static void 83static void
75x86_genfb_set_mapreg(void *opaque, int index, int r, int g, int b) 84x86_genfb_set_mapreg(void *opaque, int index, int r, int g, int b)
76{ 85{
77 outb(0x3c0 + VGA_DAC_ADDRW, index); 86 outb(0x3c0 + VGA_DAC_ADDRW, index);
78 outb(0x3c0 + VGA_DAC_PALETTE, (uint8_t)r >> 2); 87 outb(0x3c0 + VGA_DAC_PALETTE, (uint8_t)r >> 2);
79 outb(0x3c0 + VGA_DAC_PALETTE, (uint8_t)g >> 2); 88 outb(0x3c0 + VGA_DAC_PALETTE, (uint8_t)g >> 2);
80 outb(0x3c0 + VGA_DAC_PALETTE, (uint8_t)b >> 2); 89 outb(0x3c0 + VGA_DAC_PALETTE, (uint8_t)b >> 2);
81} 90}
82 91
83static bool 92static bool
84x86_genfb_suspend(device_t dev PMF_FN_ARGS) 93x86_genfb_suspend(device_t dev PMF_FN_ARGS)
85{ 94{
86 return true; 95 return true;
87} 96}
88 97
89static bool 98static bool
90x86_genfb_resume(device_t dev PMF_FN_ARGS) 99x86_genfb_resume(device_t dev PMF_FN_ARGS)
91{ 100{
92 struct genfb_softc *sc = device_private(dev); 101 struct pci_genfb_softc *psc = device_private(dev);
 102#if NACPICA > 0 && defined(VGA_POST)
 103 extern int acpi_md_vbios_reset;
 104 extern int acpi_md_vesa_modenum;
 105#endif
93 106
94 genfb_restore_palette(sc); 107#if NACPICA > 0 && defined(VGA_POST)
 108 if (vga_posth != NULL && acpi_md_vbios_reset == 2) {
 109 vga_post_call(vga_posth);
 110 if (acpi_md_vesa_modenum != 0)
 111 vga_post_set_vbe(vga_posth, acpi_md_vesa_modenum);
 112 }
 113#endif
 114 genfb_restore_palette(&psc->sc_gen);
95 115
96 return true; 116 return true;
97} 117}
98#endif 118#endif
99 119
100static void 120static void
101handle_wedges(device_t dv, int par) 121handle_wedges(device_t dv, int par)
102{ 122{
103 if (config_handle_wedges(dv, par) == 0) 123 if (config_handle_wedges(dv, par) == 0)
104 return; 124 return;
105 booted_device = dv; 125 booted_device = dv;
106 booted_partition = par; 126 booted_partition = par;
107} 127}
@@ -608,26 +628,30 @@ device_register(device_t dev, void *aux) @@ -608,26 +628,30 @@ device_register(device_t dev, void *aux)
608 prop_dictionary_set_bool(dict, "splash", 628 prop_dictionary_set_bool(dict, "splash",
609 fbinfo->flags & BI_FB_SPLASH ? true : false); 629 fbinfo->flags & BI_FB_SPLASH ? true : false);
610#endif 630#endif
611 if (fbinfo->depth == 8) { 631 if (fbinfo->depth == 8) {
612 gfb_cb.gcc_cookie = NULL; 632 gfb_cb.gcc_cookie = NULL;
613 gfb_cb.gcc_set_mapreg = x86_genfb_set_mapreg; 633 gfb_cb.gcc_set_mapreg = x86_genfb_set_mapreg;
614 prop_dictionary_set_uint64(dict, 634 prop_dictionary_set_uint64(dict,
615 "cmap_callback", (uint64_t)&gfb_cb); 635 "cmap_callback", (uint64_t)&gfb_cb);
616 } 636 }
617 pmf_cb.gpc_suspend = x86_genfb_suspend; 637 pmf_cb.gpc_suspend = x86_genfb_suspend;
618 pmf_cb.gpc_resume = x86_genfb_resume; 638 pmf_cb.gpc_resume = x86_genfb_resume;
619 prop_dictionary_set_uint64(dict, 639 prop_dictionary_set_uint64(dict,
620 "pmf_callback", (uint64_t)&pmf_cb); 640 "pmf_callback", (uint64_t)&pmf_cb);
 641#ifdef VGA_POST
 642 vga_posth = vga_post_init(pa->pa_bus, pa->pa_device,
 643 pa->pa_function);
 644#endif
621 found_console = true; 645 found_console = true;
622 return; 646 return;
623 } 647 }
624 } 648 }
625#endif 649#endif
626 return; 650 return;
627 651
628 found: 652 found:
629 if (booted_device) { 653 if (booted_device) {
630 /* XXX should be a panic() */ 654 /* XXX should be a panic() */
631 printf("WARNING: double match for boot device (%s, %s)\n", 655 printf("WARNING: double match for boot device (%s, %s)\n",
632 device_xname(booted_device), device_xname(dev)); 656 device_xname(booted_device), device_xname(dev));
633 return; 657 return;