pci_machdep.h revision 1.25 1 /* $NetBSD: pci_machdep.h,v 1.25 2025/03/09 01:06:42 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 #define _PCI_HAVE_DMA64
40
41 /*
42 * Types provided to machine-independent PCI code
43 */
44 typedef struct alpha_pci_chipset *pci_chipset_tag_t;
45 typedef u_long pcitag_t;
46 typedef struct {
47 u_long value;
48 } pci_intr_handle_t;
49
50 /*
51 * Forward declarations.
52 */
53 struct pci_attach_args;
54 struct alpha_shared_intr;
55
56 /*
57 * alpha-specific PCI structure and type definitions.
58 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
59 */
60 struct alpha_pci_chipset {
61 void *pc_conf_v;
62 void (*pc_attach_hook)(device_t, device_t,
63 struct pcibus_attach_args *);
64 int (*pc_bus_maxdevs)(void *, int);
65 pcitag_t (*pc_make_tag)(void *, int, int, int);
66 void (*pc_decompose_tag)(void *, pcitag_t, int *,
67 int *, int *);
68 pcireg_t (*pc_conf_read)(void *, pcitag_t, int);
69 void (*pc_conf_write)(void *, pcitag_t, int, pcireg_t);
70
71 void *pc_intr_v;
72 int (*pc_intr_map)(const struct pci_attach_args *,
73 pci_intr_handle_t *);
74 const char *(*pc_intr_string)(pci_chipset_tag_t,
75 pci_intr_handle_t, char *, size_t);
76 const struct evcnt *(*pc_intr_evcnt)(pci_chipset_tag_t,
77 pci_intr_handle_t);
78 void *(*pc_intr_establish)(pci_chipset_tag_t,
79 pci_intr_handle_t, int, int (*)(void *), void *);
80 void (*pc_intr_disestablish)(pci_chipset_tag_t, void *);
81
82 void *(*pc_pciide_compat_intr_establish)(device_t,
83 const struct pci_attach_args *, int,
84 int (*)(void *), void *);
85
86 struct alpha_shared_intr *pc_shared_intrs;
87 const char *pc_intr_desc;
88 u_long pc_vecbase;
89 u_int pc_nirq;
90
91 u_long pc_eligible_cpus;
92
93 void (*pc_intr_enable)(pci_chipset_tag_t, int);
94 void (*pc_intr_disable)(pci_chipset_tag_t, int);
95 void (*pc_intr_set_affinity)(pci_chipset_tag_t, int,
96 struct cpu_info *);
97 };
98
99 struct alpha_pci_intr_impl {
100 uint64_t systype;
101 void (*intr_init)(void *, bus_space_tag_t, bus_space_tag_t,
102 pci_chipset_tag_t);
103 };
104
105 #define ALPHA_PCI_INTR_INIT(_st_, _fn_) \
106 static const struct alpha_pci_intr_impl __CONCAT(intr_impl_st_,_st_) = {\
107 .systype = (_st_), .intr_init = (_fn_), \
108 }; \
109 __link_set_add_rodata(alpha_pci_intr_impls, __CONCAT(intr_impl_st_,_st_));
110
111 /*
112 * Functions provided to machine-independent PCI code.
113 */
114 void pci_attach_hook(device_t, device_t, struct pcibus_attach_args *);
115 int pci_bus_maxdevs(pci_chipset_tag_t, int);
116 pcitag_t pci_make_tag(pci_chipset_tag_t, int, int, int);
117 void pci_decompose_tag(pci_chipset_tag_t, pcitag_t, int *, int *, int *);
118 pcireg_t pci_conf_read(pci_chipset_tag_t, pcitag_t, int);
119 void pci_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
120
121 int pci_intr_map(const struct pci_attach_args *, pci_intr_handle_t *);
122 const char *pci_intr_string(pci_chipset_tag_t, pci_intr_handle_t,
123 char *, size_t);
124 const struct evcnt *pci_intr_evcnt(pci_chipset_tag_t, pci_intr_handle_t);
125 void *pci_intr_establish(pci_chipset_tag_t, pci_intr_handle_t, int,
126 int (*)(void *), void *);
127 void pci_intr_disestablish(pci_chipset_tag_t, void *);
128
129 /*
130 * alpha-specific PCI functions.
131 * NOT TO BE USED DIRECTLY BY MACHINE INDEPENDENT CODE.
132 */
133 void pci_consinit(pci_chipset_tag_t, bus_space_tag_t, bus_space_tag_t,
134 bus_space_tag_t, bus_space_tag_t);
135 void pci_display_console(bus_space_tag_t, bus_space_tag_t,
136 pci_chipset_tag_t, int, int, int);
137 void pci_find_bootdev(device_t, device_t, void *);
138 void device_pci_register(device_t, void *);
139
140 void alpha_pci_intr_init(void *, bus_space_tag_t, bus_space_tag_t,
141 pci_chipset_tag_t);
142 void alpha_pci_intr_alloc(pci_chipset_tag_t, unsigned int);
143
144 int alpha_pci_generic_intr_map(const struct pci_attach_args *,
145 pci_intr_handle_t *);
146 const char *alpha_pci_generic_intr_string(pci_chipset_tag_t,
147 pci_intr_handle_t, char *, size_t);
148 const struct evcnt *alpha_pci_generic_intr_evcnt(pci_chipset_tag_t,
149 pci_intr_handle_t);
150 void *alpha_pci_generic_intr_establish(pci_chipset_tag_t,
151 pci_intr_handle_t, int, int (*)(void *), void *);
152 void alpha_pci_generic_intr_disestablish(pci_chipset_tag_t, void *);
153 void alpha_pci_generic_iointr(void *, unsigned long);
154
155 void alpha_pci_generic_intr_redistribute(pci_chipset_tag_t);
156
157 void alpha_pci_intr_handle_init(pci_intr_handle_t *, u_int, u_int);
158 void alpha_pci_intr_handle_set_irq(pci_intr_handle_t *, u_int);
159 u_int alpha_pci_intr_handle_get_irq(const pci_intr_handle_t *);
160 void alpha_pci_intr_handle_set_flags(pci_intr_handle_t *, u_int);
161 u_int alpha_pci_intr_handle_get_flags(const pci_intr_handle_t *);
162
163 #endif /* _ALPHA_PCI_MACHDEP_H_ */
164