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