1 /* 2 * linux/arch/alpha/kernel/pci-noop.c 3 * 4 * Stub PCI interfaces for Jensen-specific kernels. 5 */ 6 7 #include <linux/pci.h> 8 #include <linux/init.h> 9 #include <linux/bootmem.h> 10 #include <linux/gfp.h> 11 #include <linux/capability.h> 12 #include <linux/mm.h> 13 #include <linux/errno.h> 14 #include <linux/sched.h> 15 #include <linux/dma-mapping.h> 16 #include <linux/scatterlist.h> 17 18 #include "proto.h" 19 20 21 /* 22 * The PCI controller list. 23 */ 24 25 struct pci_controller *hose_head, **hose_tail = &hose_head; 26 struct pci_controller *pci_isa_hose; 27 28 29 struct pci_controller * __init 30 alloc_pci_controller(void) 31 { 32 struct pci_controller *hose; 33 34 hose = alloc_bootmem(sizeof(*hose)); 35 36 *hose_tail = hose; 37 hose_tail = &hose->next; 38 39 return hose; 40 } 41 42 struct resource * __init 43 alloc_resource(void) 44 { 45 return alloc_bootmem(sizeof(struct resource)); 46 } 47 48 asmlinkage long 49 sys_pciconfig_iobase(long which, unsigned long bus, unsigned long dfn) 50 { 51 struct pci_controller *hose; 52 53 /* from hose or from bus.devfn */ 54 if (which & IOBASE_FROM_HOSE) { 55 for (hose = hose_head; hose; hose = hose->next) 56 if (hose->index == bus) 57 break; 58 if (!hose) 59 return -ENODEV; 60 } else { 61 /* Special hook for ISA access. */ 62 if (bus == 0 && dfn == 0) 63 hose = pci_isa_hose; 64 else 65 return -ENODEV; 66 } 67 68 switch (which & ~IOBASE_FROM_HOSE) { 69 case IOBASE_HOSE: 70 return hose->index; 71 case IOBASE_SPARSE_MEM: 72 return hose->sparse_mem_base; 73 case IOBASE_DENSE_MEM: 74 return hose->dense_mem_base; 75 case IOBASE_SPARSE_IO: 76 return hose->sparse_io_base; 77 case IOBASE_DENSE_IO: 78 return hose->dense_io_base; 79 case IOBASE_ROOT_BUS: 80 return hose->bus->number; 81 } 82 83 return -EOPNOTSUPP; 84 } 85 86 asmlinkage long 87 sys_pciconfig_read(unsigned long bus, unsigned long dfn, 88 unsigned long off, unsigned long len, void *buf) 89 { 90 if (!capable(CAP_SYS_ADMIN)) 91 return -EPERM; 92 else 93 return -ENODEV; 94 } 95 96 asmlinkage long 97 sys_pciconfig_write(unsigned long bus, unsigned long dfn, 98 unsigned long off, unsigned long len, void *buf) 99 { 100 if (!capable(CAP_SYS_ADMIN)) 101 return -EPERM; 102 else 103 return -ENODEV; 104 } 105 106 static void *alpha_noop_alloc_coherent(struct device *dev, size_t size, 107 dma_addr_t *dma_handle, gfp_t gfp, 108 unsigned long attrs) 109 { 110 void *ret; 111 112 if (!dev || *dev->dma_mask >= 0xffffffffUL) 113 gfp &= ~GFP_DMA; 114 ret = (void *)__get_free_pages(gfp, get_order(size)); 115 if (ret) { 116 memset(ret, 0, size); 117 *dma_handle = virt_to_phys(ret); 118 } 119 return ret; 120 } 121 122 static int alpha_noop_supported(struct device *dev, u64 mask) 123 { 124 return mask < 0x00ffffffUL ? 0 : 1; 125 } 126 127 const struct dma_map_ops alpha_noop_ops = { 128 .alloc = alpha_noop_alloc_coherent, 129 .free = dma_noop_free_coherent, 130 .map_page = dma_noop_map_page, 131 .map_sg = dma_noop_map_sg, 132 .mapping_error = dma_noop_mapping_error, 133 .dma_supported = alpha_noop_supported, 134 }; 135 136 const struct dma_map_ops *dma_ops = &alpha_noop_ops; 137 EXPORT_SYMBOL(dma_ops); 138