pci_stub.c revision 1.7 1 #include <sys/cdefs.h>
2 __KERNEL_RCSID(0, "$NetBSD: pci_stub.c,v 1.7 2017/06/01 02:45:11 chs Exp $");
3
4 #ifdef _KERNEL_OPT
5 #include "opt_pci.h"
6 #endif
7
8 #include <sys/param.h>
9 #include <sys/systm.h>
10 #include <sys/kmem.h>
11
12 #include <dev/pci/pcireg.h>
13 #include <dev/pci/pcivar.h>
14 #include <dev/pci/pcidevs.h>
15
16 int default_pci_bus_devorder(pci_chipset_tag_t, int, uint8_t *, int);
17 int default_pci_chipset_tag_create(pci_chipset_tag_t, uint64_t,
18 const struct pci_overrides *, void *, pci_chipset_tag_t *);
19 void default_pci_chipset_tag_destroy(pci_chipset_tag_t);
20
21 __strict_weak_alias(pci_bus_devorder, default_pci_bus_devorder);
22 __strict_weak_alias(pci_chipset_tag_create, default_pci_chipset_tag_create);
23 __strict_weak_alias(pci_chipset_tag_destroy, default_pci_chipset_tag_destroy);
24
25 int
26 default_pci_bus_devorder(pci_chipset_tag_t pc, int bus, uint8_t *devs,
27 int maxdevs)
28 {
29 int i, n;
30
31 n = MIN(pci_bus_maxdevs(pc, bus), maxdevs);
32 for (i = 0; i < n; i++)
33 devs[i] = i;
34
35 return n;
36 }
37
38 void
39 default_pci_chipset_tag_destroy(pci_chipset_tag_t pc)
40 {
41 }
42
43 int
44 default_pci_chipset_tag_create(pci_chipset_tag_t opc, const uint64_t present,
45 const struct pci_overrides *ov, void *ctx, pci_chipset_tag_t *pcp)
46 {
47 return EOPNOTSUPP;
48 }
49
50 #ifndef __HAVE_PCI_MSI_MSIX
51 pci_intr_type_t
52 pci_intr_type(pci_chipset_tag_t pc, pci_intr_handle_t ih)
53 {
54
55 return PCI_INTR_TYPE_INTX;
56 }
57
58 int
59 pci_intr_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **ihps,
60 int *counts, pci_intr_type_t max_type)
61 {
62
63 if (counts != NULL && counts[PCI_INTR_TYPE_INTX] == 0)
64 return EINVAL;
65
66 return pci_intx_alloc(pa, ihps);
67 }
68
69 void
70 pci_intr_release(pci_chipset_tag_t pc, pci_intr_handle_t *pih, int count)
71 {
72
73 kmem_free(pih, sizeof(*pih));
74 }
75
76 void *
77 pci_intr_establish_xname(pci_chipset_tag_t pc, pci_intr_handle_t ih, int level,
78 int (*func)(void *), void *arg, const char *__nouse)
79 {
80
81 return pci_intr_establish(pc, ih, level, func, arg);
82 }
83
84 int
85 pci_intx_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **ihp)
86 {
87 pci_intr_handle_t *pih;
88
89 if (ihp == NULL)
90 return EINVAL;
91
92 pih = kmem_alloc(sizeof(*pih), KM_SLEEP);
93 if (pci_intr_map(pa, pih)) {
94 kmem_free(pih, sizeof(*pih));
95 return EINVAL;
96 }
97
98 *ihp = pih;
99 return 0;
100 }
101
102 int
103 pci_msi_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **ihps,
104 int *count)
105 {
106
107 return EOPNOTSUPP;
108 }
109
110 int
111 pci_msi_alloc_exact(const struct pci_attach_args *pa, pci_intr_handle_t **ihps,
112 int count)
113 {
114
115 return EOPNOTSUPP;
116 }
117
118 int
119 pci_msix_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **ihps,
120 int *count)
121 {
122
123 return EOPNOTSUPP;
124 }
125
126 int
127 pci_msix_alloc_exact(const struct pci_attach_args *pa, pci_intr_handle_t **ihps,
128 int count)
129 {
130
131 return EOPNOTSUPP;
132 }
133
134 int
135 pci_msix_alloc_map(const struct pci_attach_args *pa, pci_intr_handle_t **ihps,
136 u_int *table_indexes, int count)
137 {
138
139 return EOPNOTSUPP;
140 }
141 #endif /* __HAVE_PCI_MSI_MSIX */
142