Annotation of sys/arch/amd64/pci/pcib.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: pcib.c,v 1.2 2007/01/15 23:19:05 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:
54: int pcibmatch(struct device *, void *, void *);
55: void pcibattach(struct device *, struct device *, void *);
56: void pcib_callback(struct device *);
57: int pcib_print(void *, const char *);
58:
59: struct cfattach pcib_ca = {
60: sizeof(struct device), pcibmatch, pcibattach
61: };
62:
63: struct cfdriver pcib_cd = {
64: NULL, "pcib", DV_DULL
65: };
66:
67: int
68: pcibmatch(struct device *parent, void *match, void *aux)
69: {
70: struct pci_attach_args *pa = aux;
71:
72: switch (PCI_VENDOR(pa->pa_id)) {
73: case PCI_VENDOR_INTEL:
74: switch (PCI_PRODUCT(pa->pa_id)) {
75: case PCI_PRODUCT_INTEL_SIO:
76: case PCI_PRODUCT_INTEL_82371MX:
77: case PCI_PRODUCT_INTEL_82371AB_ISA:
78: case PCI_PRODUCT_INTEL_82440MX_ISA:
79: /* The above bridges mis-identify themselves */
80: return (1);
81: }
82: case PCI_VENDOR_SIS:
83: switch (PCI_PRODUCT(pa->pa_id)) {
84: case PCI_PRODUCT_SIS_85C503:
85: /* mis-identifies itself as a miscellaneous prehistoric */
86: return (1);
87: }
88: case PCI_VENDOR_VIATECH:
89: switch (PCI_PRODUCT(pa->pa_id)) {
90: case PCI_PRODUCT_VIATECH_VT82C686A_SMB:
91: /* mis-identifies itself as a ISA bridge */
92: return (0);
93: }
94: }
95:
96: if (PCI_CLASS(pa->pa_class) == PCI_CLASS_BRIDGE &&
97: PCI_SUBCLASS(pa->pa_class) == PCI_SUBCLASS_BRIDGE_ISA)
98: return (1);
99:
100: return (0);
101: }
102:
103: void
104: pcibattach(struct device *parent, struct device *self, void *aux)
105: {
106: /*
107: * Cannot attach isa bus now; must postpone for various reasons
108: */
109: printf("\n");
110:
111: config_defer(self, pcib_callback);
112: }
113:
114: void
115: pcib_callback(struct device *self)
116: {
117: struct isabus_attach_args iba;
118:
119: /*
120: * Attach the ISA bus behind this bridge.
121: */
122: memset(&iba, 0, sizeof(iba));
123: iba.iba_busname = "isa";
124: iba.iba_iot = X86_BUS_SPACE_IO;
125: iba.iba_memt = X86_BUS_SPACE_MEM;
126: #if NISADMA > 0
127: iba.iba_dmat = &isa_bus_dma_tag;
128: #endif
129: config_found(self, &iba, pcib_print);
130: }
131:
132: int
133: pcib_print(void *aux, const char *pnp)
134: {
135: /* Only ISAs can attach to pcib's; easy. */
136: if (pnp)
137: printf("isa at %s", pnp);
138: return (UNCONF);
139: }
CVSweb