1996-04-12 10:07:05 +04:00
|
|
|
/* $NetBSD: pci_machdep.c,v 1.5 1996/04/12 06:08:49 cgd Exp $ */
|
1995-06-28 05:24:50 +04:00
|
|
|
|
|
|
|
/*
|
1996-04-12 10:07:05 +04:00
|
|
|
* Copyright (c) 1995, 1996 Carnegie-Mellon University.
|
1995-11-23 05:33:17 +03:00
|
|
|
* All rights reserved.
|
1995-06-28 05:24:50 +04:00
|
|
|
*
|
1995-11-23 05:33:17 +03:00
|
|
|
* Author: Chris G. Demetriou
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify and distribute this software and
|
|
|
|
* its documentation is hereby granted, provided that both the copyright
|
|
|
|
* notice and this permission notice appear in all copies of the
|
|
|
|
* software, derivative works or modified versions, and any portions
|
|
|
|
* thereof, and that both notices appear in supporting documentation.
|
|
|
|
*
|
|
|
|
* CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
|
|
|
|
* CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
|
|
|
|
* FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
|
|
|
|
*
|
|
|
|
* Carnegie Mellon requests users of this software to return to
|
1995-06-28 05:24:50 +04:00
|
|
|
*
|
1995-11-23 05:33:17 +03:00
|
|
|
* Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
|
|
|
|
* School of Computer Science
|
|
|
|
* Carnegie Mellon University
|
|
|
|
* Pittsburgh PA 15213-3890
|
|
|
|
*
|
|
|
|
* any improvements or extensions that they make and grant Carnegie the
|
|
|
|
* rights to redistribute these changes.
|
1995-06-28 05:24:50 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Machine-specific functions for PCI autoconfiguration.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <vm/vm.h>
|
|
|
|
|
|
|
|
#include <dev/isa/isavar.h>
|
|
|
|
#include <dev/pci/pcireg.h>
|
1995-11-23 05:33:17 +03:00
|
|
|
#include <dev/pci/pcivar.h>
|
1995-08-03 04:33:58 +04:00
|
|
|
#include <dev/pci/pcidevs.h>
|
1995-06-28 05:24:50 +04:00
|
|
|
|
1995-08-03 04:33:58 +04:00
|
|
|
#include "pcivga.h"
|
1995-11-23 05:33:17 +03:00
|
|
|
#if NPCIVGA
|
|
|
|
#include <alpha/pci/pcivgavar.h>
|
|
|
|
#endif
|
1995-06-28 05:24:50 +04:00
|
|
|
|
1995-11-23 05:33:17 +03:00
|
|
|
#include "tga.h"
|
|
|
|
#if NTGA
|
|
|
|
#include <alpha/pci/tgavar.h>
|
|
|
|
#endif
|
1995-08-03 04:33:58 +04:00
|
|
|
|
|
|
|
void
|
1996-04-12 08:31:48 +04:00
|
|
|
pci_display_console(bc, pc, bus, device, function)
|
|
|
|
bus_chipset_tag_t bc;
|
|
|
|
pci_chipset_tag_t pc;
|
|
|
|
int bus, device, function;
|
1995-08-03 04:33:58 +04:00
|
|
|
{
|
1996-04-12 08:31:48 +04:00
|
|
|
pcitag_t tag;
|
|
|
|
pcireg_t id, class;
|
|
|
|
int match, nmatch;
|
|
|
|
void (*fn) __P((bus_chipset_tag_t, pci_chipset_tag_t, int, int, int));
|
1995-08-03 04:33:58 +04:00
|
|
|
|
1996-04-12 08:31:48 +04:00
|
|
|
tag = pci_make_tag(pc, bus, device, function);
|
|
|
|
id = pci_conf_read(pc, tag, PCI_ID_REG);
|
1995-08-03 04:33:58 +04:00
|
|
|
if (id == 0 || id == 0xffffffff)
|
|
|
|
panic("pci_display_console: no device at %d/%d/%d",
|
|
|
|
bus, device, function);
|
1996-04-12 08:31:48 +04:00
|
|
|
class = pci_conf_read(pc, tag, PCI_CLASS_REG);
|
|
|
|
|
|
|
|
match = 0;
|
|
|
|
fn = NULL;
|
1995-08-03 04:33:58 +04:00
|
|
|
|
|
|
|
#if NPCIVGA
|
1996-04-12 08:31:48 +04:00
|
|
|
nmatch = DEVICE_IS_PCIVGA(class, id);
|
|
|
|
if (nmatch > match) {
|
|
|
|
match = nmatch;
|
|
|
|
fn = pcivga_console;
|
1995-08-03 04:33:58 +04:00
|
|
|
}
|
1995-11-23 05:33:17 +03:00
|
|
|
#endif
|
1995-08-03 04:33:58 +04:00
|
|
|
#if NTGA
|
1996-04-12 08:31:48 +04:00
|
|
|
nmatch = DEVICE_IS_TGA(class, id);
|
|
|
|
if (nmatch > match) {
|
|
|
|
match = nmatch;
|
|
|
|
fn = tga_console;
|
1995-08-03 04:33:58 +04:00
|
|
|
}
|
1995-11-23 05:33:17 +03:00
|
|
|
#endif
|
1995-08-03 04:33:58 +04:00
|
|
|
|
1996-04-12 08:31:48 +04:00
|
|
|
if (fn != NULL)
|
|
|
|
(*fn)(bc, pc, bus, device, function);
|
|
|
|
else
|
|
|
|
panic("pci_display_console: unconfigured device at %d/%d/%d",
|
1995-08-03 04:33:58 +04:00
|
|
|
bus, device, function);
|
|
|
|
}
|