pci_machdep.c revision 1.10 1 /* $NetBSD: pci_machdep.c,v 1.10 1997/04/07 23:40:45 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> /* Config options headers */
35 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
36
37 __KERNEL_RCSID(0, "$NetBSD: pci_machdep.c,v 1.10 1997/04/07 23:40:45 cgd Exp $");
38
39 #include <sys/types.h>
40 #include <sys/param.h>
41 #include <sys/time.h>
42 #include <sys/systm.h>
43 #include <sys/errno.h>
44 #include <sys/device.h>
45 #include <vm/vm.h>
46
47 #include <dev/isa/isavar.h>
48 #include <dev/pci/pcireg.h>
49 #include <dev/pci/pcivar.h>
50 #include <dev/pci/pcidevs.h>
51
52 #include "vga_pci.h"
53 #if NVGA_PCI
54 #include <alpha/pci/vga_pcivar.h>
55 #endif
56
57 #include "tga.h"
58 #if NTGA
59 #include <alpha/pci/tgavar.h>
60 #endif
61
62 void
63 pci_display_console(iot, memt, pc, bus, device, function)
64 bus_space_tag_t iot, memt;
65 pci_chipset_tag_t pc;
66 int bus, device, function;
67 {
68 pcitag_t tag;
69 pcireg_t id, class;
70 int match, nmatch;
71 void (*fn) __P((bus_space_tag_t, bus_space_tag_t, pci_chipset_tag_t,
72 int, int, int));
73
74 tag = pci_make_tag(pc, bus, device, function);
75 id = pci_conf_read(pc, tag, PCI_ID_REG);
76 if (id == 0 || id == 0xffffffff)
77 panic("pci_display_console: no device at %d/%d/%d",
78 bus, device, function);
79 class = pci_conf_read(pc, tag, PCI_CLASS_REG);
80
81 nmatch = match = 0; /* XXX really only if we've got FBs configured */
82 fn = NULL;
83
84 #if NVGA_PCI
85 nmatch = DEVICE_IS_VGA_PCI(class, id);
86 if (nmatch > match) {
87 match = nmatch;
88 fn = vga_pci_console;
89 }
90 #endif
91 #if NTGA
92 nmatch = DEVICE_IS_TGA(class, id);
93 if (nmatch > match) {
94 match = nmatch;
95 fn = tga_console;
96 }
97 #endif
98
99 if (fn != NULL)
100 (*fn)(iot, memt, pc, bus, device, function);
101 else
102 panic("pci_display_console: unconfigured device at %d/%d/%d",
103 bus, device, function);
104 }
105