1 | // SPDX-License-Identifier: GPL-2.0 |
2 | /* |
3 | * linux/arch/alpha/kernel/pci-noop.c |
4 | * |
5 | * Stub PCI interfaces for Jensen-specific kernels. |
6 | */ |
7 | |
8 | #include <linux/pci.h> |
9 | #include <linux/init.h> |
10 | #include <linux/memblock.h> |
11 | #include <linux/gfp.h> |
12 | #include <linux/capability.h> |
13 | #include <linux/mm.h> |
14 | #include <linux/errno.h> |
15 | #include <linux/sched.h> |
16 | #include <linux/dma-mapping.h> |
17 | #include <linux/scatterlist.h> |
18 | #include <linux/syscalls.h> |
19 | |
20 | #include "proto.h" |
21 | |
22 | |
23 | /* |
24 | * The PCI controller list. |
25 | */ |
26 | |
27 | struct pci_controller *hose_head, **hose_tail = &hose_head; |
28 | struct pci_controller *pci_isa_hose; |
29 | |
30 | |
31 | struct pci_controller * __init |
32 | alloc_pci_controller(void) |
33 | { |
34 | struct pci_controller *hose; |
35 | |
36 | hose = memblock_alloc(sizeof(*hose), SMP_CACHE_BYTES); |
37 | if (!hose) |
38 | panic("%s: Failed to allocate %zu bytes\n" , __func__, |
39 | sizeof(*hose)); |
40 | |
41 | *hose_tail = hose; |
42 | hose_tail = &hose->next; |
43 | |
44 | return hose; |
45 | } |
46 | |
47 | struct resource * __init |
48 | alloc_resource(void) |
49 | { |
50 | void *ptr = memblock_alloc(size: sizeof(struct resource), SMP_CACHE_BYTES); |
51 | |
52 | if (!ptr) |
53 | panic(fmt: "%s: Failed to allocate %zu bytes\n" , __func__, |
54 | sizeof(struct resource)); |
55 | |
56 | return ptr; |
57 | } |
58 | |
59 | SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus, |
60 | unsigned long, dfn) |
61 | { |
62 | struct pci_controller *hose; |
63 | |
64 | /* from hose or from bus.devfn */ |
65 | if (which & IOBASE_FROM_HOSE) { |
66 | for (hose = hose_head; hose; hose = hose->next) |
67 | if (hose->index == bus) |
68 | break; |
69 | if (!hose) |
70 | return -ENODEV; |
71 | } else { |
72 | /* Special hook for ISA access. */ |
73 | if (bus == 0 && dfn == 0) |
74 | hose = pci_isa_hose; |
75 | else |
76 | return -ENODEV; |
77 | } |
78 | |
79 | switch (which & ~IOBASE_FROM_HOSE) { |
80 | case IOBASE_HOSE: |
81 | return hose->index; |
82 | case IOBASE_SPARSE_MEM: |
83 | return hose->sparse_mem_base; |
84 | case IOBASE_DENSE_MEM: |
85 | return hose->dense_mem_base; |
86 | case IOBASE_SPARSE_IO: |
87 | return hose->sparse_io_base; |
88 | case IOBASE_DENSE_IO: |
89 | return hose->dense_io_base; |
90 | case IOBASE_ROOT_BUS: |
91 | return hose->bus->number; |
92 | } |
93 | |
94 | return -EOPNOTSUPP; |
95 | } |
96 | |
97 | SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn, |
98 | unsigned long, off, unsigned long, len, void __user *, buf) |
99 | { |
100 | if (!capable(CAP_SYS_ADMIN)) |
101 | return -EPERM; |
102 | else |
103 | return -ENODEV; |
104 | } |
105 | |
106 | SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn, |
107 | unsigned long, off, unsigned long, len, void __user *, buf) |
108 | { |
109 | if (!capable(CAP_SYS_ADMIN)) |
110 | return -EPERM; |
111 | else |
112 | return -ENODEV; |
113 | } |
114 | |