1 | #include <sys/cdefs.h> |
2 | __KERNEL_RCSID(0, "$NetBSD: pci_stub.c,v 1.5 2016/07/11 06:14:51 knakahara 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 | pci_intr_type_t default_pci_intr_type(pci_chipset_tag_t, pci_intr_handle_t); |
21 | int default_pci_intr_alloc(const struct pci_attach_args *, |
22 | pci_intr_handle_t **, int *, pci_intr_type_t); |
23 | void default_pci_intr_release(pci_chipset_tag_t, pci_intr_handle_t *, int); |
24 | void *default_pci_intr_establish_xname(pci_chipset_tag_t, pci_intr_handle_t, |
25 | int, int (*)(void *), void *, const char *); |
26 | |
27 | __strict_weak_alias(pci_bus_devorder, default_pci_bus_devorder); |
28 | __strict_weak_alias(pci_chipset_tag_create, default_pci_chipset_tag_create); |
29 | __strict_weak_alias(pci_chipset_tag_destroy, default_pci_chipset_tag_destroy); |
30 | |
31 | __strict_weak_alias(pci_intr_type, default_pci_intr_type); |
32 | __strict_weak_alias(pci_intr_alloc, default_pci_intr_alloc); |
33 | __strict_weak_alias(pci_intr_release, default_pci_intr_release); |
34 | __strict_weak_alias(pci_intr_establish_xname, default_pci_intr_establish_xname); |
35 | |
36 | int |
37 | default_pci_bus_devorder(pci_chipset_tag_t pc, int bus, uint8_t *devs, |
38 | int maxdevs) |
39 | { |
40 | int i, n; |
41 | |
42 | n = MIN(pci_bus_maxdevs(pc, bus), maxdevs); |
43 | for (i = 0; i < n; i++) |
44 | devs[i] = i; |
45 | |
46 | return n; |
47 | } |
48 | |
49 | void |
50 | default_pci_chipset_tag_destroy(pci_chipset_tag_t pc) |
51 | { |
52 | } |
53 | |
54 | int |
55 | default_pci_chipset_tag_create(pci_chipset_tag_t opc, const uint64_t present, |
56 | const struct pci_overrides *ov, void *ctx, pci_chipset_tag_t *pcp) |
57 | { |
58 | return EOPNOTSUPP; |
59 | } |
60 | |
61 | pci_intr_type_t |
62 | default_pci_intr_type(pci_chipset_tag_t pc, pci_intr_handle_t ih) |
63 | { |
64 | |
65 | return PCI_INTR_TYPE_INTX; |
66 | } |
67 | |
68 | int |
69 | default_pci_intr_alloc(const struct pci_attach_args *pa, |
70 | pci_intr_handle_t **ihps, int *counts, pci_intr_type_t max_type) |
71 | { |
72 | pci_intr_handle_t *ihp; |
73 | |
74 | if (counts != NULL && counts[PCI_INTR_TYPE_INTX] == 0) |
75 | return EINVAL; |
76 | |
77 | ihp = kmem_alloc(sizeof(*ihp), KM_SLEEP); |
78 | if (ihp == NULL) |
79 | return ENOMEM; |
80 | |
81 | if (pci_intr_map(pa, ihp)) { |
82 | kmem_free(ihp, sizeof(*ihp)); |
83 | return EINVAL; |
84 | } |
85 | |
86 | ihps[0] = ihp; |
87 | return 0; |
88 | } |
89 | |
90 | void |
91 | default_pci_intr_release(pci_chipset_tag_t pc, pci_intr_handle_t *pih, |
92 | int count) |
93 | { |
94 | |
95 | kmem_free(pih, sizeof(*pih)); |
96 | } |
97 | |
98 | void * |
99 | default_pci_intr_establish_xname(pci_chipset_tag_t pc, pci_intr_handle_t ih, |
100 | int level, int (*func)(void *), void *arg, const char *__nouse) |
101 | { |
102 | |
103 | return pci_intr_establish(pc, ih, level, func, arg); |
104 | } |
105 | |