Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86 Factor device_isa_register() and device_pci_reg...



details:   https://anonhg.NetBSD.org/src/rev/084685be539b
branches:  trunk
changeset: 770493:084685be539b
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Tue Oct 18 23:43:36 2011 +0000

description:
Factor device_isa_register() and device_pci_register() out of
device_register() and stick the new routines into isa_machdep.c and
pci_machdep.c, respectively.

diffstat:

 sys/arch/x86/isa/isa_machdep.c  |   53 +++++++-
 sys/arch/x86/pci/pci_machdep.c  |  240 ++++++++++++++++++++++++++++++++++-
 sys/arch/x86/x86/x86_autoconf.c |  272 +--------------------------------------
 3 files changed, 299 insertions(+), 266 deletions(-)

diffs (truncated from 676 to 300 lines):

diff -r b0ec910bb7be -r 084685be539b sys/arch/x86/isa/isa_machdep.c
--- a/sys/arch/x86/isa/isa_machdep.c    Tue Oct 18 23:43:06 2011 +0000
+++ b/sys/arch/x86/isa/isa_machdep.c    Tue Oct 18 23:43:36 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: isa_machdep.c,v 1.30 2011/09/01 15:10:31 christos Exp $        */
+/*     $NetBSD: isa_machdep.c,v 1.31 2011/10/18 23:43:36 dyoung Exp $  */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.30 2011/09/01 15:10:31 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: isa_machdep.c,v 1.31 2011/10/18 23:43:36 dyoung Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -80,12 +80,16 @@
 #include <machine/bus_private.h>
 #include <machine/pio.h>
 #include <machine/cpufunc.h>
+#include <machine/autoconf.h>
+#include <machine/bootinfo.h>
 
 #include <dev/isa/isareg.h>
 #include <dev/isa/isavar.h>
 
 #include <uvm/uvm_extern.h>
 
+#include "acpica.h"
+#include "opt_acpi.h"
 #include "ioapic.h"
 
 #if NIOAPIC > 0
@@ -335,3 +339,48 @@
                *cookieflagsp |= X86_DMA_MIGHT_NEED_BOUNCE;
        return 0;
 }
+
+device_t
+device_isa_register(device_t dev, void *aux)
+{
+
+       /*
+        * Handle network interfaces here, the attachment information is
+        * not available driver-independently later.
+        *
+        * For disks, there is nothing useful available at attach time.
+        */
+       if (device_class(dev) == DV_IFNET) {
+               struct btinfo_netif *bin = lookup_bootinfo(BTINFO_NETIF);
+               if (bin == NULL)
+                       return NULL;
+
+               /*
+                * We don't check the driver name against the device name
+                * passed by the boot ROM.  The ROM should stay usable if
+                * the driver becomes obsolete.  The physical attachment
+                * information (checked below) must be sufficient to
+                * idenfity the device.
+                */
+               if (bin->bus == BI_BUS_ISA &&
+                   device_is_a(device_parent(dev), "isa")) {
+                       struct isa_attach_args *iaa = aux;
+
+                       /* Compare IO base address */
+                       /* XXXJRT What about multiple IO addrs? */
+                       if (iaa->ia_nio > 0 &&
+                           bin->addr.iobase == iaa->ia_io[0].ir_addr)
+                               return dev;
+               }
+       }
+#if NACPICA > 0
+#if notyet
+       if (device_is_a(dev, "isa") && acpi_active) {
+               if (!(AcpiGbl_FADT.BootFlags & ACPI_FADT_LEGACY_DEVICES))
+                       prop_dictionary_set_bool(device_properties(dev),
+                           "no-legacy-devices", true);
+       }
+#endif
+#endif /* NACPICA > 0 */
+       return NULL;
+}
diff -r b0ec910bb7be -r 084685be539b sys/arch/x86/pci/pci_machdep.c
--- a/sys/arch/x86/pci/pci_machdep.c    Tue Oct 18 23:43:06 2011 +0000
+++ b/sys/arch/x86/pci/pci_machdep.c    Tue Oct 18 23:43:36 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pci_machdep.c,v 1.51 2011/09/13 17:58:42 dyoung Exp $  */
+/*     $NetBSD: pci_machdep.c,v 1.52 2011/10/18 23:43:36 dyoung Exp $  */
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.51 2011/09/13 17:58:42 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.52 2011/10/18 23:43:36 dyoung Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -98,10 +98,34 @@
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pccbbreg.h>
 #include <dev/pci/pcidevs.h>
+#include <dev/pci/genfb_pcivar.h>
+
+#include <dev/wsfb/genfbvar.h>
+#include <arch/x86/include/genfb_machdep.h>
+#include <dev/ic/vgareg.h>
 
 #include "acpica.h"
+#include "genfb.h"
+#include "isa.h"
+#include "opt_acpi.h"
+#include "opt_ddb.h"
 #include "opt_mpbios.h"
-#include "opt_acpi.h"
+#include "opt_vga.h"
+#include "pci.h"
+#include "wsdisplay.h"
+
+#ifdef DDB
+#include <machine/db_machdep.h>
+#include <ddb/db_sym.h>
+#include <ddb/db_extern.h>
+#endif
+
+#ifdef VGA_POST
+#include <x86/vga_post.h>
+#endif
+
+#include <machine/autoconf.h>
+#include <machine/bootinfo.h>
 
 #ifdef MPBIOS
 #include <machine/mpbiosvar.h>
@@ -221,6 +245,18 @@
 
 static struct pci_conf_lock * const cl = &cl0;
 
+#if NGENFB > 0 && NACPICA > 0 && defined(VGA_POST)
+extern int acpi_md_vbios_reset;
+extern int acpi_md_vesa_modenum;
+#endif
+
+static struct genfb_colormap_callback gfb_cb;
+static struct genfb_pmf_callback pmf_cb;
+static struct genfb_mode_callback mode_cb;
+#ifdef VGA_POST
+static struct vga_post *vga_posth = NULL;
+#endif
+
 static void
 pci_conf_lock(struct pci_conf_lock *ocl, uint32_t sel)
 {
@@ -801,3 +837,201 @@
        kmem_free(pc, sizeof(struct pci_chipset_tag));
        return EINVAL;
 }
+
+static void
+x86_genfb_set_mapreg(void *opaque, int index, int r, int g, int b)
+{
+       outb(0x3c0 + VGA_DAC_ADDRW, index);
+       outb(0x3c0 + VGA_DAC_PALETTE, (uint8_t)r >> 2);
+       outb(0x3c0 + VGA_DAC_PALETTE, (uint8_t)g >> 2);
+       outb(0x3c0 + VGA_DAC_PALETTE, (uint8_t)b >> 2);
+}
+
+static bool
+x86_genfb_setmode(struct genfb_softc *sc, int newmode)
+{
+#if NGENFB > 0
+       static int curmode = WSDISPLAYIO_MODE_EMUL;
+
+       switch (newmode) {
+       case WSDISPLAYIO_MODE_EMUL:
+               x86_genfb_mtrr_init(sc->sc_fboffset,
+                   sc->sc_height * sc->sc_stride);
+#if NACPICA > 0 && defined(VGA_POST)
+               if (curmode != newmode) {
+                       if (vga_posth != NULL && acpi_md_vesa_modenum != 0) {
+                               vga_post_set_vbe(vga_posth,
+                                   acpi_md_vesa_modenum);
+                       }
+               }
+#endif
+               break;
+       }
+
+       curmode = newmode;
+#endif
+       return true;
+}
+
+static bool
+x86_genfb_suspend(device_t dev, const pmf_qual_t *qual)
+{
+       return true;
+}
+
+static bool
+x86_genfb_resume(device_t dev, const pmf_qual_t *qual)
+{
+#if NGENFB > 0
+       struct pci_genfb_softc *psc = device_private(dev);
+
+#if NACPICA > 0 && defined(VGA_POST)
+       if (vga_posth != NULL && acpi_md_vbios_reset == 2) {
+               vga_post_call(vga_posth);
+               if (acpi_md_vesa_modenum != 0)
+                       vga_post_set_vbe(vga_posth, acpi_md_vesa_modenum);
+       }
+#endif
+       genfb_restore_palette(&psc->sc_gen);
+#endif
+
+       return true;
+}
+
+device_t
+device_pci_register(device_t dev, void *aux)
+{
+       static bool found_console = false;
+
+       device_pci_props_register(dev, aux);
+
+       /*
+        * Handle network interfaces here, the attachment information is
+        * not available driver-independently later.
+        *
+        * For disks, there is nothing useful available at attach time.
+        */
+       if (device_class(dev) == DV_IFNET) {
+               struct btinfo_netif *bin = lookup_bootinfo(BTINFO_NETIF);
+               if (bin == NULL)
+                       return NULL;
+
+               /*
+                * We don't check the driver name against the device name
+                * passed by the boot ROM.  The ROM should stay usable if
+                * the driver becomes obsolete.  The physical attachment
+                * information (checked below) must be sufficient to
+                * idenfity the device.
+                */
+               if (bin->bus == BI_BUS_PCI &&
+                   device_is_a(device_parent(dev), "pci")) {
+                       struct pci_attach_args *paa = aux;
+                       int b, d, f;
+
+                       /*
+                        * Calculate BIOS representation of:
+                        *
+                        *      <bus,device,function>
+                        *
+                        * and compare.
+                        */
+                       pci_decompose_tag(paa->pa_pc, paa->pa_tag, &b, &d, &f);
+                       if (bin->addr.tag == ((b << 8) | (d << 3) | f))
+                               return dev;
+               }
+       }
+       if (device_parent(dev) && device_is_a(device_parent(dev), "pci") &&
+           found_console == false) {
+               struct btinfo_framebuffer *fbinfo;
+               struct pci_attach_args *pa = aux;
+               prop_dictionary_t dict;
+
+               if (PCI_CLASS(pa->pa_class) == PCI_CLASS_DISPLAY) {
+#if NWSDISPLAY > 0 && NGENFB > 0
+                       extern struct vcons_screen x86_genfb_console_screen;
+                       struct rasops_info *ri;
+
+                       ri = &x86_genfb_console_screen.scr_ri;
+#endif
+
+                       fbinfo = lookup_bootinfo(BTINFO_FRAMEBUFFER);
+                       dict = device_properties(dev);
+                       /*
+                        * framebuffer drivers other than genfb can work
+                        * without the address property
+                        */
+                       if (fbinfo != NULL) {
+                               if (fbinfo->physaddr != 0) {
+                               prop_dictionary_set_uint32(dict, "width",
+                                   fbinfo->width);
+                               prop_dictionary_set_uint32(dict, "height",
+                                   fbinfo->height);
+                               prop_dictionary_set_uint8(dict, "depth",
+                                   fbinfo->depth);
+                               prop_dictionary_set_uint16(dict, "linebytes",
+                                   fbinfo->stride);
+
+                               prop_dictionary_set_uint64(dict, "address",
+                                   fbinfo->physaddr);
+#if NWSDISPLAY > 0 && NGENFB > 0
+                               if (ri->ri_bits != NULL) {
+                                       prop_dictionary_set_uint64(dict,



Home | Main Index | Thread Index | Old Index