Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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> |
Randy Dunlap | a941564 | 2006-01-11 12:17:48 -0800 | [diff] [blame] | 10 | #include <linux/capability.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/mm.h> |
| 12 | #include <linux/errno.h> |
| 13 | #include <linux/sched.h> |
| 14 | #include <linux/dma-mapping.h> |
| 15 | |
| 16 | #include "proto.h" |
| 17 | |
| 18 | |
| 19 | /* |
| 20 | * The PCI controller list. |
| 21 | */ |
| 22 | |
| 23 | struct pci_controller *hose_head, **hose_tail = &hose_head; |
| 24 | struct pci_controller *pci_isa_hose; |
| 25 | |
| 26 | |
| 27 | struct pci_controller * __init |
| 28 | alloc_pci_controller(void) |
| 29 | { |
| 30 | struct pci_controller *hose; |
| 31 | |
| 32 | hose = alloc_bootmem(sizeof(*hose)); |
| 33 | |
| 34 | *hose_tail = hose; |
| 35 | hose_tail = &hose->next; |
| 36 | |
| 37 | return hose; |
| 38 | } |
| 39 | |
| 40 | struct resource * __init |
| 41 | alloc_resource(void) |
| 42 | { |
| 43 | struct resource *res; |
| 44 | |
| 45 | res = alloc_bootmem(sizeof(*res)); |
| 46 | |
| 47 | return res; |
| 48 | } |
| 49 | |
| 50 | asmlinkage long |
| 51 | sys_pciconfig_iobase(long which, unsigned long bus, unsigned long dfn) |
| 52 | { |
| 53 | struct pci_controller *hose; |
| 54 | |
| 55 | /* from hose or from bus.devfn */ |
| 56 | if (which & IOBASE_FROM_HOSE) { |
| 57 | for (hose = hose_head; hose; hose = hose->next) |
| 58 | if (hose->index == bus) |
| 59 | break; |
| 60 | if (!hose) |
| 61 | return -ENODEV; |
| 62 | } else { |
| 63 | /* Special hook for ISA access. */ |
| 64 | if (bus == 0 && dfn == 0) |
| 65 | hose = pci_isa_hose; |
| 66 | else |
| 67 | return -ENODEV; |
| 68 | } |
| 69 | |
| 70 | switch (which & ~IOBASE_FROM_HOSE) { |
| 71 | case IOBASE_HOSE: |
| 72 | return hose->index; |
| 73 | case IOBASE_SPARSE_MEM: |
| 74 | return hose->sparse_mem_base; |
| 75 | case IOBASE_DENSE_MEM: |
| 76 | return hose->dense_mem_base; |
| 77 | case IOBASE_SPARSE_IO: |
| 78 | return hose->sparse_io_base; |
| 79 | case IOBASE_DENSE_IO: |
| 80 | return hose->dense_io_base; |
| 81 | case IOBASE_ROOT_BUS: |
| 82 | return hose->bus->number; |
| 83 | } |
| 84 | |
| 85 | return -EOPNOTSUPP; |
| 86 | } |
| 87 | |
| 88 | asmlinkage long |
| 89 | sys_pciconfig_read(unsigned long bus, unsigned long dfn, |
| 90 | unsigned long off, unsigned long len, void *buf) |
| 91 | { |
| 92 | if (!capable(CAP_SYS_ADMIN)) |
| 93 | return -EPERM; |
| 94 | else |
| 95 | return -ENODEV; |
| 96 | } |
| 97 | |
| 98 | asmlinkage long |
| 99 | sys_pciconfig_write(unsigned long bus, unsigned long dfn, |
| 100 | unsigned long off, unsigned long len, void *buf) |
| 101 | { |
| 102 | if (!capable(CAP_SYS_ADMIN)) |
| 103 | return -EPERM; |
| 104 | else |
| 105 | return -ENODEV; |
| 106 | } |
| 107 | |
| 108 | /* Stubs for the routines in pci_iommu.c: */ |
| 109 | |
| 110 | void * |
| 111 | pci_alloc_consistent(struct pci_dev *pdev, size_t size, dma_addr_t *dma_addrp) |
| 112 | { |
| 113 | return NULL; |
| 114 | } |
| 115 | |
| 116 | void |
| 117 | pci_free_consistent(struct pci_dev *pdev, size_t size, void *cpu_addr, |
| 118 | dma_addr_t dma_addr) |
| 119 | { |
| 120 | } |
| 121 | |
| 122 | dma_addr_t |
| 123 | pci_map_single(struct pci_dev *pdev, void *cpu_addr, size_t size, |
| 124 | int direction) |
| 125 | { |
| 126 | return (dma_addr_t) 0; |
| 127 | } |
| 128 | |
| 129 | void |
| 130 | pci_unmap_single(struct pci_dev *pdev, dma_addr_t dma_addr, size_t size, |
| 131 | int direction) |
| 132 | { |
| 133 | } |
| 134 | |
| 135 | int |
| 136 | pci_map_sg(struct pci_dev *pdev, struct scatterlist *sg, int nents, |
| 137 | int direction) |
| 138 | { |
| 139 | return 0; |
| 140 | } |
| 141 | |
| 142 | void |
| 143 | pci_unmap_sg(struct pci_dev *pdev, struct scatterlist *sg, int nents, |
| 144 | int direction) |
| 145 | { |
| 146 | } |
| 147 | |
| 148 | int |
| 149 | pci_dma_supported(struct pci_dev *hwdev, dma_addr_t mask) |
| 150 | { |
| 151 | return 0; |
| 152 | } |
| 153 | |
| 154 | /* Generic DMA mapping functions: */ |
| 155 | |
| 156 | void * |
| 157 | dma_alloc_coherent(struct device *dev, size_t size, |
Al Viro | 55c5d74 | 2005-10-21 03:21:08 -0400 | [diff] [blame] | 158 | dma_addr_t *dma_handle, gfp_t gfp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | { |
| 160 | void *ret; |
| 161 | |
| 162 | if (!dev || *dev->dma_mask >= 0xffffffffUL) |
| 163 | gfp &= ~GFP_DMA; |
| 164 | ret = (void *)__get_free_pages(gfp, get_order(size)); |
| 165 | if (ret) { |
| 166 | memset(ret, 0, size); |
| 167 | *dma_handle = virt_to_bus(ret); |
| 168 | } |
| 169 | return ret; |
| 170 | } |
| 171 | |
| 172 | EXPORT_SYMBOL(dma_alloc_coherent); |
| 173 | |
| 174 | int |
| 175 | dma_map_sg(struct device *dev, struct scatterlist *sg, int nents, |
| 176 | enum dma_data_direction direction) |
| 177 | { |
| 178 | int i; |
| 179 | |
| 180 | for (i = 0; i < nents; i++ ) { |
| 181 | void *va; |
| 182 | |
| 183 | BUG_ON(!sg[i].page); |
| 184 | va = page_address(sg[i].page) + sg[i].offset; |
| 185 | sg_dma_address(sg + i) = (dma_addr_t)virt_to_bus(va); |
| 186 | sg_dma_len(sg + i) = sg[i].length; |
| 187 | } |
| 188 | |
| 189 | return nents; |
| 190 | } |
| 191 | |
| 192 | EXPORT_SYMBOL(dma_map_sg); |
| 193 | |
| 194 | int |
| 195 | dma_set_mask(struct device *dev, u64 mask) |
| 196 | { |
| 197 | if (!dev->dma_mask || !dma_supported(dev, mask)) |
| 198 | return -EIO; |
| 199 | |
| 200 | *dev->dma_mask = mask; |
| 201 | |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen) |
| 206 | { |
| 207 | return NULL; |
| 208 | } |
| 209 | |
| 210 | void pci_iounmap(struct pci_dev *dev, void __iomem * addr) |
| 211 | { |
| 212 | } |
| 213 | |
| 214 | EXPORT_SYMBOL(pci_iomap); |
| 215 | EXPORT_SYMBOL(pci_iounmap); |