Home | History | Annotate | Line # | Download | only in pci
pci_machdep.c revision 1.9
      1 /* $NetBSD: pci_machdep.c,v 1.9 1997/04/07 02:01:27 cgd Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1995, 1996 Carnegie-Mellon University.
      5  * All rights reserved.
      6  *
      7  * Author: Chris G. Demetriou
      8  *
      9  * Permission to use, copy, modify and distribute this software and
     10  * its documentation is hereby granted, provided that both the copyright
     11  * notice and this permission notice appear in all copies of the
     12  * software, derivative works or modified versions, and any portions
     13  * thereof, and that both notices appear in supporting documentation.
     14  *
     15  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18  *
     19  * Carnegie Mellon requests users of this software to return to
     20  *
     21  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22  *  School of Computer Science
     23  *  Carnegie Mellon University
     24  *  Pittsburgh PA 15213-3890
     25  *
     26  * any improvements or extensions that they make and grant Carnegie the
     27  * rights to redistribute these changes.
     28  */
     29 
     30 /*
     31  * Machine-specific functions for PCI autoconfiguration.
     32  */
     33 
     34 #include <machine/options.h>		/* Pull in config options headers */
     35 
     36 #include <sys/types.h>
     37 #include <sys/param.h>
     38 #include <sys/time.h>
     39 #include <sys/systm.h>
     40 #include <sys/errno.h>
     41 #include <sys/device.h>
     42 #include <vm/vm.h>
     43 
     44 #include <dev/isa/isavar.h>
     45 #include <dev/pci/pcireg.h>
     46 #include <dev/pci/pcivar.h>
     47 #include <dev/pci/pcidevs.h>
     48 
     49 #include "vga_pci.h"
     50 #if NVGA_PCI
     51 #include <alpha/pci/vga_pcivar.h>
     52 #endif
     53 
     54 #include "tga.h"
     55 #if NTGA
     56 #include <alpha/pci/tgavar.h>
     57 #endif
     58 
     59 void
     60 pci_display_console(iot, memt, pc, bus, device, function)
     61 	bus_space_tag_t iot, memt;
     62 	pci_chipset_tag_t pc;
     63 	int bus, device, function;
     64 {
     65 	pcitag_t tag;
     66 	pcireg_t id, class;
     67 	int match, nmatch;
     68 	void (*fn) __P((bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t,
     69 	    int, int, int));
     70 
     71 	tag = pci_make_tag(pc, bus, device, function);
     72 	id = pci_conf_read(pc, tag, PCI_ID_REG);
     73 	if (id == 0 || id == 0xffffffff)
     74 		panic("pci_display_console: no device at %d/%d/%d",
     75 		    bus, device, function);
     76 	class = pci_conf_read(pc, tag, PCI_CLASS_REG);
     77 
     78 	nmatch = match = 0; /* XXX really only if we've got FBs configured */
     79 	fn = NULL;
     80 
     81 #if NVGA_PCI
     82 	nmatch = DEVICE_IS_VGA_PCI(class, id);
     83 	if (nmatch > match) {
     84 		match = nmatch;
     85 		fn = vga_pci_console;
     86 	}
     87 #endif
     88 #if NTGA
     89 	nmatch = DEVICE_IS_TGA(class, id);
     90 	if (nmatch > match) {
     91 		match = nmatch;
     92 		fn = tga_console;
     93 	}
     94 #endif
     95 
     96 	if (fn != NULL)
     97 		(*fn)(iot, memt, pc, bus, device, function);
     98 	else
     99 		panic("pci_display_console: unconfigured device at %d/%d/%d",
    100 		    bus, device, function);
    101 }
    102