diff options
Diffstat (limited to 'sys/arch/alpha/pci/pci_machdep.c')
-rw-r--r-- | sys/arch/alpha/pci/pci_machdep.c | 258 |
1 files changed, 53 insertions, 205 deletions
diff --git a/sys/arch/alpha/pci/pci_machdep.c b/sys/arch/alpha/pci/pci_machdep.c index bacb5273362..02eb57caeaa 100644 --- a/sys/arch/alpha/pci/pci_machdep.c +++ b/sys/arch/alpha/pci/pci_machdep.c @@ -1,32 +1,30 @@ -/* $NetBSD: pci_machdep.c,v 1.2 1995/08/03 00:33:58 cgd Exp $ */ +/* $NetBSD: pci_machdep.c,v 1.3 1995/11/23 02:38:07 cgd Exp $ */ /* - * Copyright (c) 1994 Charles Hannum. All rights reserved. + * Copyright (c) 1995 Carnegie-Mellon University. + * All rights reserved. * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Charles Hannum. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. + * 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 * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * 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. */ /* @@ -43,206 +41,56 @@ #include <vm/vm.h> #include <dev/isa/isavar.h> -#include <dev/pci/pcivar.h> #include <dev/pci/pcireg.h> +#include <dev/pci/pcivar.h> #include <dev/pci/pcidevs.h> -#include <alpha/pci/pci_chipset.h> #include "pcivga.h" -#include "tga.h" - -int pcimatch __P((struct device *, void *, void *)); -void pciattach __P((struct device *, struct device *, void *)); - -struct cfdriver pcicd = { - NULL, "pci", pcimatch, pciattach, DV_DULL, sizeof(struct device) -}; - -int -pcimatch(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - - return 1; -} - -void -pciattach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - - printf("\n"); - (*pci_cs_fcns->cs_setup)(); - (*pci_cfg_fcns->cfg_attach)(parent, self, aux); -} - -pcitag_t -pci_make_tag(bus, device, function) - int bus, device, function; -{ - - return (*pci_cs_fcns->cs_make_tag)(bus, device, function); -} - -pcireg_t -pci_conf_read(tag, offset) - pcitag_t tag; - int offset; /* XXX */ -{ - - return (*pci_cs_fcns->cs_conf_read)(tag, offset); -} - -void -pci_conf_write(tag, offset, data) - pcitag_t tag; - int offset; /* XXX */ - pcireg_t data; -{ - - (*pci_cs_fcns->cs_conf_write)(tag, offset, data); -} - -int -pci_map_io(tag, reg, iobasep) - pcitag_t tag; - int reg; - int *iobasep; -{ - - return (*pci_cs_fcns->cs_map_io)(tag, reg, iobasep); -} - -int -pci_map_mem(tag, reg, vap, pap) - pcitag_t tag; - int reg; - vm_offset_t *vap, *pap; -{ - - return (*pci_cs_fcns->cs_map_mem)(tag, reg, vap, pap); -} - -int -pcidma_map(addr, size, mappings) - caddr_t addr; - vm_size_t size; - vm_offset_t *mappings; -{ - - return (*pci_cs_fcns->cs_pcidma_map)(addr, size, mappings); -} - -void -pcidma_unmap(addr, size, nmappings, mappings) - caddr_t addr; - vm_size_t size; - int nmappings; - vm_offset_t *mappings; -{ - - (*pci_cs_fcns->cs_pcidma_unmap)(addr, size, nmappings, mappings); -} - -void * -pci_map_int(tag, level, func, arg) - pcitag_t tag; - pci_intrlevel level; - int (*func) __P((void *)); - void *arg; -{ - pcireg_t data; - int pin; - - data = pci_conf_read(tag, PCI_INTERRUPT_REG); - - pin = PCI_INTERRUPT_PIN(data); - - if (pin == 0) { - /* No IRQ used. */ - return 0; - } - - if (pin > 4) { - printf("pci_map_int: bad interrupt pin %d\n", pin); - return NULL; - } - - return (*pci_cfg_fcns->cfg_map_int)(tag, level, func, arg, pin); -} - -isa_intrlevel -pcilevel_to_isa(level) - pci_intrlevel level; -{ - - switch (level) { - case PCI_IPL_NONE: - return (ISA_IPL_NONE); - - case PCI_IPL_BIO: - return (ISA_IPL_BIO); - - case PCI_IPL_NET: - return (ISA_IPL_NET); - - case PCI_IPL_TTY: - return (ISA_IPL_TTY); - - case PCI_IPL_CLOCK: - return (ISA_IPL_CLOCK); +#if NPCIVGA +#include <alpha/pci/pcivgavar.h> +#endif - default: - panic("pcilevel_to_isa: unknown level %d\n", level); - } -} +#include "tga.h" +#if NTGA +#include <alpha/pci/tgavar.h> +#endif void -pci_display_console(bus, device, function) - int bus, device, function; +pci_display_console(pcf, pcfa, pmf, pmfa, ppf, ppfa, bus, device, function) + __const struct pci_conf_fns *pcf; + __const struct pci_mem_fns *pmf; + __const struct pci_pio_fns *ppf; + void *pcfa, *pmfa, *ppfa; + pci_bus_t bus; + pci_device_t device; + pci_function_t function; { - pcitag_t tag; - pcireg_t id, class; - - /* XXX */ - tag = pci_make_tag(bus, device, function); + pci_conftag_t tag; + pci_confreg_t id, class; - id = pci_conf_read(tag, PCI_ID_REG); + tag = PCI_MAKE_TAG(bus, device, function); + id = PCI_CONF_READ(pcf, pcfa, tag, PCI_ID_REG); if (id == 0 || id == 0xffffffff) panic("pci_display_console: no device at %d/%d/%d", bus, device, function); - class = pci_conf_read(tag, PCI_CLASS_REG); - - if (PCI_CLASS(class) != PCI_CLASS_DISPLAY && - !(PCI_CLASS(class) == PCI_CLASS_PREHISTORIC && - PCI_SUBCLASS(class) == PCI_SUBCLASS_PREHISTORIC_VGA)) - panic("pci_display_console: device at %d/%d/%d not a display", - bus, device, function); + class = PCI_CONF_READ(pcf, pcfa, tag, PCI_CLASS_REG); - if ((PCI_CLASS(class) == PCI_CLASS_DISPLAY && - PCI_SUBCLASS(class) == PCI_SUBCLASS_DISPLAY_VGA) || - (PCI_CLASS(class) == PCI_CLASS_PREHISTORIC && - PCI_SUBCLASS(class) == PCI_SUBCLASS_PREHISTORIC_VGA)) { #if NPCIVGA - pcivga_console(bus, device, function); -#else - panic("pci_display_console: pcivga is console, not configured"); -#endif + if (DEVICE_IS_PCIVGA(class, id)) { + pcivga_console(pcf, pcfa, pmf, pmfa, ppf, ppfa, bus, + device, function); return; } +#endif - if (PCI_VENDOR(id) == PCI_VENDOR_DEC && - PCI_PRODUCT(id) == PCI_PRODUCT_DEC_21030) { #if NTGA - tga_console(bus, device, function); -#else - panic("pci_display_console: tga is console, not configured"); -#endif + if (DEVICE_IS_TGA(class, id)) { + tga_console(pcf, pcfa, pmf, pmfa, ppf, ppfa, bus, + device, function); return; } +#endif - panic("pci_display_console: unsupported device at %d/%d/%d", + panic("pci_display_console: unconfigured device at %d/%d/%d", bus, device, function); } |