Annotation of sys/arch/i386/pci/pcib.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: pcib.c,v 1.20 2006/09/19 11:06:34 jsg Exp $ */
! 2: /* $NetBSD: pcib.c,v 1.6 1997/06/06 23:29:16 thorpej Exp $ */
! 3:
! 4: /*-
! 5: * Copyright (c) 1996 The NetBSD Foundation, Inc.
! 6: * All rights reserved.
! 7: *
! 8: * This code is derived from software contributed to The NetBSD Foundation
! 9: * by Jason R. Thorpe.
! 10: *
! 11: * Redistribution and use in source and binary forms, with or without
! 12: * modification, are permitted provided that the following conditions
! 13: * are met:
! 14: * 1. Redistributions of source code must retain the above copyright
! 15: * notice, this list of conditions and the following disclaimer.
! 16: * 2. Redistributions in binary form must reproduce the above copyright
! 17: * notice, this list of conditions and the following disclaimer in the
! 18: * documentation and/or other materials provided with the distribution.
! 19: * 3. All advertising materials mentioning features or use of this software
! 20: * must display the following acknowledgement:
! 21: * This product includes software developed by the NetBSD
! 22: * Foundation, Inc. and its contributors.
! 23: * 4. Neither the name of The NetBSD Foundation nor the names of its
! 24: * contributors may be used to endorse or promote products derived
! 25: * from this software without specific prior written permission.
! 26: *
! 27: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
! 28: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
! 29: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! 30: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
! 31: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
! 32: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
! 33: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
! 34: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
! 35: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
! 36: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
! 37: * POSSIBILITY OF SUCH DAMAGE.
! 38: */
! 39:
! 40: #include <sys/param.h>
! 41: #include <sys/systm.h>
! 42: #include <sys/device.h>
! 43:
! 44: #include <machine/bus.h>
! 45: #include <dev/isa/isavar.h>
! 46:
! 47: #include <dev/pci/pcivar.h>
! 48: #include <dev/pci/pcireg.h>
! 49:
! 50: #include <dev/pci/pcidevs.h>
! 51:
! 52: #include "isa.h"
! 53: #include "pcibios.h"
! 54: #if NPCIBIOS > 0
! 55: #include <i386/pci/pcibiosvar.h>
! 56: #endif
! 57:
! 58: int pcibmatch(struct device *, void *, void *);
! 59: void pcibattach(struct device *, struct device *, void *);
! 60: void pcib_callback(struct device *);
! 61: int pcib_print(void *, const char *);
! 62:
! 63: struct cfattach pcib_ca = {
! 64: sizeof(struct device), pcibmatch, pcibattach
! 65: };
! 66:
! 67: struct cfdriver pcib_cd = {
! 68: NULL, "pcib", DV_DULL
! 69: };
! 70:
! 71: int
! 72: pcibmatch(struct device *parent, void *match, void *aux)
! 73: {
! 74: struct pci_attach_args *pa = aux;
! 75:
! 76: switch (PCI_VENDOR(pa->pa_id)) {
! 77: case PCI_VENDOR_INTEL:
! 78: switch (PCI_PRODUCT(pa->pa_id)) {
! 79: case PCI_PRODUCT_INTEL_SIO:
! 80: case PCI_PRODUCT_INTEL_82371MX:
! 81: case PCI_PRODUCT_INTEL_82371AB_ISA:
! 82: case PCI_PRODUCT_INTEL_82440MX_ISA:
! 83: /* The above bridges mis-identify themselves */
! 84: return (1);
! 85: }
! 86: case PCI_VENDOR_SIS:
! 87: switch (PCI_PRODUCT(pa->pa_id)) {
! 88: case PCI_PRODUCT_SIS_85C503:
! 89: /* mis-identifies itself as a miscellaneous prehistoric */
! 90: return (1);
! 91: }
! 92: case PCI_VENDOR_VIATECH:
! 93: switch (PCI_PRODUCT(pa->pa_id)) {
! 94: case PCI_PRODUCT_VIATECH_VT82C686A_SMB:
! 95: /* mis-identifies itself as a ISA bridge */
! 96: return (0);
! 97: }
! 98: }
! 99:
! 100: if (PCI_CLASS(pa->pa_class) == PCI_CLASS_BRIDGE &&
! 101: PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_BRIDGE_ISA)
! 102: return (1);
! 103:
! 104: return (0);
! 105: }
! 106:
! 107: void
! 108: pcibattach(struct device *parent, struct device *self, void *aux)
! 109: {
! 110: /*
! 111: * Cannot attach isa bus now; must postpone for various reasons
! 112: */
! 113: printf("\n");
! 114:
! 115: config_defer(self, pcib_callback);
! 116: }
! 117:
! 118: void
! 119: pcib_callback(struct device *self)
! 120: {
! 121: struct isabus_attach_args iba;
! 122:
! 123: #if NPCIBIOS > 0
! 124: pci_intr_post_fixup();
! 125: #endif
! 126:
! 127: /*
! 128: * Attach the ISA bus behind this bridge.
! 129: */
! 130: memset(&iba, 0, sizeof(iba));
! 131: iba.iba_busname = "isa";
! 132: iba.iba_iot = I386_BUS_SPACE_IO;
! 133: iba.iba_memt = I386_BUS_SPACE_MEM;
! 134: #if NISADMA > 0
! 135: iba.iba_dmat = &isa_bus_dma_tag;
! 136: #endif
! 137: config_found(self, &iba, pcib_print);
! 138: }
! 139:
! 140: int
! 141: pcib_print(void *aux, const char *pnp)
! 142: {
! 143: /* Only ISAs can attach to pcib's; easy. */
! 144: if (pnp)
! 145: printf("isa at %s", pnp);
! 146: return (UNCONF);
! 147: }
CVSweb