1 #include <sys/cdefs.h> 2 __KERNEL_RCSID(0, "$NetBSD: pci_stub.c,v 1.6 2016/11/25 12:10:59 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 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 (pih == NULL) 94 return ENOMEM; 95 96 if (pci_intr_map(pa, pih)) { 97 kmem_free(pih, sizeof(*pih)); 98 return EINVAL; 99 } 100 101 *ihp = pih; 102 return 0; 103 } 104 105 int 106 pci_msi_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **ihps, 107 int *count) 108 { 109 110 return EOPNOTSUPP; 111 } 112 113 int 114 pci_msi_alloc_exact(const struct pci_attach_args *pa, pci_intr_handle_t **ihps, 115 int count) 116 { 117 118 return EOPNOTSUPP; 119 } 120 121 int 122 pci_msix_alloc(const struct pci_attach_args *pa, pci_intr_handle_t **ihps, 123 int *count) 124 { 125 126 return EOPNOTSUPP; 127 } 128 129 int 130 pci_msix_alloc_exact(const struct pci_attach_args *pa, pci_intr_handle_t **ihps, 131 int count) 132 { 133 134 return EOPNOTSUPP; 135 } 136 137 int 138 pci_msix_alloc_map(const struct pci_attach_args *pa, pci_intr_handle_t **ihps, 139 u_int *table_indexes, int count) 140 { 141 142 return EOPNOTSUPP; 143 } 144 #endif /* __HAVE_PCI_MSI_MSIX */ 145