GNU Linux-libre 4.19.211-gnu1
[releases.git] / arch / alpha / kernel / pci-noop.c
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/bootmem.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 = alloc_bootmem(sizeof(*hose));
37
38         *hose_tail = hose;
39         hose_tail = &hose->next;
40
41         return hose;
42 }
43
44 struct resource * __init
45 alloc_resource(void)
46 {
47         return alloc_bootmem(sizeof(struct resource));
48 }
49
50 SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus,
51                 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 SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn,
89                 unsigned long, off, unsigned long, len, void __user *, buf)
90 {
91         if (!capable(CAP_SYS_ADMIN))
92                 return -EPERM;
93         else
94                 return -ENODEV;
95 }
96
97 SYSCALL_DEFINE5(pciconfig_write, 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 }