Home | History | Annotate | Line # | Download | only in pci
pci_machdep.c revision 1.5
      1 /*	$NetBSD: pci_machdep.c,v 1.5 1996/04/12 06:08:49 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 <sys/types.h>
     35 #include <sys/param.h>
     36 #include <sys/time.h>
     37 #include <sys/systm.h>
     38 #include <sys/errno.h>
     39 #include <sys/device.h>
     40 #include <vm/vm.h>
     41 
     42 #include <dev/isa/isavar.h>
     43 #include <dev/pci/pcireg.h>
     44 #include <dev/pci/pcivar.h>
     45 #include <dev/pci/pcidevs.h>
     46 
     47 #include "pcivga.h"
     48 #if NPCIVGA
     49 #include <alpha/pci/pcivgavar.h>
     50 #endif
     51 
     52 #include "tga.h"
     53 #if NTGA
     54 #include <alpha/pci/tgavar.h>
     55 #endif
     56 
     57 void
     58 pci_display_console(bc, pc, bus, device, function)
     59 	bus_chipset_tag_t bc;
     60 	pci_chipset_tag_t pc;
     61 	int bus, device, function;
     62 {
     63 	pcitag_t tag;
     64 	pcireg_t id, class;
     65 	int match, nmatch;
     66 	void (*fn) __P((bus_chipset_tag_t, pci_chipset_tag_t, int, int, int));
     67 
     68 	tag = pci_make_tag(pc, bus, device, function);
     69 	id = pci_conf_read(pc, tag, PCI_ID_REG);
     70 	if (id == 0 || id == 0xffffffff)
     71 		panic("pci_display_console: no device at %d/%d/%d",
     72 		    bus, device, function);
     73 	class = pci_conf_read(pc, tag, PCI_CLASS_REG);
     74 
     75 	match = 0;
     76 	fn = NULL;
     77 
     78 #if NPCIVGA
     79 	nmatch = DEVICE_IS_PCIVGA(class, id);
     80 	if (nmatch > match) {
     81 		match = nmatch;
     82 		fn = pcivga_console;
     83 	}
     84 #endif
     85 #if NTGA
     86 	nmatch = DEVICE_IS_TGA(class, id);
     87 	if (nmatch > match) {
     88 		match = nmatch;
     89 		fn = tga_console;
     90 	}
     91 #endif
     92 
     93 	if (fn != NULL)
     94 		(*fn)(bc, pc, bus, device, function);
     95 	else
     96 		panic("pci_display_console: unconfigured device at %d/%d/%d",
     97 		    bus, device, function);
     98 }
     99