pci_machdep.h revision 1.20 1 /* $NetBSD: pci_machdep.h,v 1.20 2020/09/26 02:46:27 thorpej Exp $ */
2
3 /*
4 * Copyright (c) 1996 Carnegie-Mellon University.
5 * All rights reserved.
6 *
7 * Author: Chris G. Demetriou
8 *
9 * Permission to use, copy, modify and distribute this software and
10 * its documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation.
14 *
15 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
16 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
17 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
18 *
19 * Carnegie Mellon requests users of this software to return to
20 *
21 * Software Distribution Coordinator or Software.Distribution (at) CS.CMU.EDU
22 * School of Computer Science
23 * Carnegie Mellon University
24 * Pittsburgh PA 15213-3890
25 *
26 * any improvements or extensions that they make and grant Carnegie the
27 * rights to redistribute these changes.
28 */
29
30 #ifndef _ALPHA_PCI_MACHDEP_H_
31 #define _ALPHA_PCI_MACHDEP_H_
32
33 #include <sys/errno.h>
34
35 /*
36 * Machine-specific definitions for PCI autoconfiguration.
37 */
38 #define __HAVE_PCIIDE_MACHDEP_COMPAT_INTR_ESTABLISH
39
40 /*
41 * Types provided to machine-independent PCI code
42 */
43 typedef struct alpha_pci_chipset *pci_chipset_tag_t;
44 typedef u_long pcitag_t;
45 typedef struct {
46 u_long value;
47 } pci_intr_handle_t;
48
49 /*
50 * Forward declarations.
51 */
52 struct pci_attach_args;
53 struct alpha_shared_intr;
54
55 /*
56 * alpha-specific PCI structure and type definitions.
57 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
58 */
59 struct alpha_pci_chipset {
60 void *pc_conf_v;
61 void (*pc_attach_hook)(device_t, device_t,
62 struct pcibus_attach_args *);
63 int (*pc_bus_maxdevs)(void *, int);
64 pcitag_t (*pc_make_tag)(void *, int, int, int);
65 void (*pc_decompose_tag)(void *, pcitag_t, int *,
66 int *, int *);
67 pcireg_t (*pc_conf_read)(void *, pcitag_t, int);
68 void (*pc_conf_write)(void *, pcitag_t, int, pcireg_t);
69
70 void *pc_intr_v;
71 int (*pc_intr_map)(const struct pci_attach_args *,
72 pci_intr_handle_t *);
73 const char *(*pc_intr_string)(pci_chipset_tag_t,
74 pci_intr_handle_t, char *, size_t);
75 const struct evcnt *(*pc_intr_evcnt)(pci_chipset_tag_t,
76 pci_intr_handle_t);
77 void *(*pc_intr_establish)(pci_chipset_tag_t,
78 pci_intr_handle_t, int, int (*)(void *), void *);
79 void (*pc_intr_disestablish)(pci_chipset_tag_t, void *);
80
81 void *(*pc_pciide_compat_intr_establish)(device_t,
82 const struct pci_attach_args *, int,
83 int (*)(void *), void *);
84
85 struct alpha_shared_intr *pc_shared_intrs;
86 const char *pc_intr_desc;
87 u_long pc_vecbase;
88 u_int pc_nirq;
89
90 u_long pc_eligible_cpus;
91
92 void (*pc_intr_enable)(pci_chipset_tag_t, int);
93 void (*pc_intr_disable)(pci_chipset_tag_t, int);
94 void (*pc_intr_set_affinity)(pci_chipset_tag_t, int,
95 struct cpu_info *);
96 };
97
98 /*
99 * Functions provided to machine-independent PCI code.
100 */
101 void pci_attach_hook(device_t, device_t, struct pcibus_attach_args *);
102 int pci_bus_maxdevs(pci_chipset_tag_t, int);
103 pcitag_t pci_make_tag(pci_chipset_tag_t, int, int, int);
104 void pci_decompose_tag(pci_chipset_tag_t, pcitag_t, int *, int *, int *);
105 pcireg_t pci_conf_read(pci_chipset_tag_t, pcitag_t, int);
106 void pci_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
107
108 int pci_intr_map(const struct pci_attach_args *, pci_intr_handle_t *);
109 const char *pci_intr_string(pci_chipset_tag_t, pci_intr_handle_t,
110 char *, size_t);
111 const struct evcnt *pci_intr_evcnt(pci_chipset_tag_t, pci_intr_handle_t);
112 void *pci_intr_establish(pci_chipset_tag_t, pci_intr_handle_t, int,
113 int (*)(void *), void *);
114 void pci_intr_disestablish(pci_chipset_tag_t, void *);
115
116 /*
117 * alpha-specific PCI functions.
118 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
119 */
120 void pci_display_console(bus_space_tag_t, bus_space_tag_t,
121 pci_chipset_tag_t, int, int, int);
122 void device_pci_register(device_t, void *);
123
124 int alpha_pci_generic_intr_map(const struct pci_attach_args *,
125 pci_intr_handle_t *);
126 const char *alpha_pci_generic_intr_string(pci_chipset_tag_t,
127 pci_intr_handle_t, char *, size_t);
128 const struct evcnt *alpha_pci_generic_intr_evcnt(pci_chipset_tag_t,
129 pci_intr_handle_t);
130 void *alpha_pci_generic_intr_establish(pci_chipset_tag_t,
131 pci_intr_handle_t, int, int (*)(void *), void *);
132 void alpha_pci_generic_intr_disestablish(pci_chipset_tag_t, void *);
133 void alpha_pci_generic_iointr(void *, unsigned long);
134
135 void alpha_pci_intr_handle_init(pci_intr_handle_t *, u_int, u_int);
136 void alpha_pci_intr_handle_set_irq(pci_intr_handle_t *, u_int);
137 u_int alpha_pci_intr_handle_get_irq(const pci_intr_handle_t *);
138 void alpha_pci_intr_handle_set_flags(pci_intr_handle_t *, u_int);
139 u_int alpha_pci_intr_handle_get_flags(const pci_intr_handle_t *);
140
141 #endif /* _ALPHA_PCI_MACHDEP_H_ */
142