pci_machdep.h revision 1.12.18.1 1 1.12.18.1 minoura /* $NetBSD: pci_machdep.h,v 1.12.18.1 2000/06/22 17:00:33 minoura Exp $ */
2 1.2 cgd
3 1.1 mycroft /*
4 1.5 cgd * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved.
5 1.11 mycroft * Copyright (c) 1994 Charles M. Hannum. All rights reserved.
6 1.1 mycroft *
7 1.1 mycroft * Redistribution and use in source and binary forms, with or without
8 1.1 mycroft * modification, are permitted provided that the following conditions
9 1.1 mycroft * are met:
10 1.1 mycroft * 1. Redistributions of source code must retain the above copyright
11 1.1 mycroft * notice, this list of conditions and the following disclaimer.
12 1.1 mycroft * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 mycroft * notice, this list of conditions and the following disclaimer in the
14 1.1 mycroft * documentation and/or other materials provided with the distribution.
15 1.1 mycroft * 3. All advertising materials mentioning features or use of this software
16 1.1 mycroft * must display the following acknowledgement:
17 1.11 mycroft * This product includes software developed by Charles M. Hannum.
18 1.1 mycroft * 4. The name of the author may not be used to endorse or promote products
19 1.1 mycroft * derived from this software without specific prior written permission.
20 1.1 mycroft *
21 1.1 mycroft * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.1 mycroft * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1 mycroft * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1 mycroft * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1 mycroft * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1 mycroft * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1 mycroft * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1 mycroft * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1 mycroft * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1 mycroft * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1 mycroft */
32 1.1 mycroft
33 1.1 mycroft /*
34 1.1 mycroft * Machine-specific definitions for PCI autoconfiguration.
35 1.1 mycroft */
36 1.8 thorpej
37 1.8 thorpej /*
38 1.8 thorpej * Many i386 PCI systems only work properly with I/O mapped space, in
39 1.8 thorpej * particular, buses behind PCI-PCI bridges may not have memory
40 1.8 thorpej * space mapped at all. For this reason, tell drivers that have
41 1.8 thorpej * a choice that we "prefer" I/O space.
42 1.8 thorpej */
43 1.8 thorpej #define PCI_PREFER_IOSPACE
44 1.1 mycroft
45 1.1 mycroft /*
46 1.5 cgd * i386-specific PCI structure and type definitions.
47 1.5 cgd * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
48 1.5 cgd *
49 1.1 mycroft * Configuration tag; created from a {bus,device,function} triplet by
50 1.1 mycroft * pci_make_tag(), and passed to pci_conf_read() and pci_conf_write().
51 1.1 mycroft * We could instead always pass the {bus,device,function} triplet to
52 1.1 mycroft * the read and write routines, but this would cause extra overhead.
53 1.1 mycroft *
54 1.5 cgd * Mode 2 is historical and deprecated by the Revision 2.0 specification.
55 1.1 mycroft */
56 1.5 cgd union i386_pci_tag_u {
57 1.5 cgd u_int32_t mode1;
58 1.1 mycroft struct {
59 1.5 cgd u_int16_t port;
60 1.5 cgd u_int8_t enable;
61 1.5 cgd u_int8_t forward;
62 1.1 mycroft } mode2;
63 1.5 cgd };
64 1.7 thorpej
65 1.7 thorpej extern struct i386_bus_dma_tag pci_bus_dma_tag;
66 1.1 mycroft
67 1.1 mycroft /*
68 1.5 cgd * Types provided to machine-independent PCI code
69 1.1 mycroft */
70 1.5 cgd typedef void *pci_chipset_tag_t;
71 1.5 cgd typedef union i386_pci_tag_u pcitag_t;
72 1.5 cgd typedef int pci_intr_handle_t;
73 1.1 mycroft
74 1.4 cgd /*
75 1.5 cgd * i386-specific PCI variables and functions.
76 1.5 cgd * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
77 1.4 cgd */
78 1.5 cgd extern int pci_mode;
79 1.12.18.1 minoura int pci_mode_detect(void);
80 1.12.18.1 minoura int pci_bus_flags(void);
81 1.4 cgd
82 1.4 cgd /*
83 1.5 cgd * Functions provided to machine-independent PCI code.
84 1.4 cgd */
85 1.12.18.1 minoura void pci_attach_hook(struct device *, struct device *,
86 1.12.18.1 minoura struct pcibus_attach_args *);
87 1.12.18.1 minoura int pci_bus_maxdevs(pci_chipset_tag_t, int);
88 1.12.18.1 minoura pcitag_t pci_make_tag(pci_chipset_tag_t, int, int, int);
89 1.12.18.1 minoura void pci_decompose_tag(pci_chipset_tag_t, pcitag_t,
90 1.12.18.1 minoura int *, int *, int *);
91 1.12.18.1 minoura pcireg_t pci_conf_read(pci_chipset_tag_t, pcitag_t, int);
92 1.12.18.1 minoura void pci_conf_write(pci_chipset_tag_t, pcitag_t, int,
93 1.12.18.1 minoura pcireg_t);
94 1.12.18.1 minoura int pci_intr_map(pci_chipset_tag_t, pcitag_t, int, int,
95 1.12.18.1 minoura pci_intr_handle_t *);
96 1.12.18.1 minoura const char *pci_intr_string(pci_chipset_tag_t, pci_intr_handle_t);
97 1.12.18.1 minoura const struct evcnt *pci_intr_evcnt(pci_chipset_tag_t, pci_intr_handle_t);
98 1.12.18.1 minoura void *pci_intr_establish(pci_chipset_tag_t, pci_intr_handle_t,
99 1.12.18.1 minoura int, int (*)(void *), void *);
100 1.12.18.1 minoura void pci_intr_disestablish(pci_chipset_tag_t, void *);
101