pci-noop.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. #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. #include <linux/syscalls.h>
  18. #include "proto.h"
  19. /*
  20. * The PCI controller list.
  21. */
  22. struct pci_controller *hose_head, **hose_tail = &hose_head;
  23. struct pci_controller *pci_isa_hose;
  24. struct pci_controller * __init
  25. alloc_pci_controller(void)
  26. {
  27. struct pci_controller *hose;
  28. hose = alloc_bootmem(sizeof(*hose));
  29. *hose_tail = hose;
  30. hose_tail = &hose->next;
  31. return hose;
  32. }
  33. struct resource * __init
  34. alloc_resource(void)
  35. {
  36. return alloc_bootmem(sizeof(struct resource));
  37. }
  38. SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus,
  39. unsigned long, dfn)
  40. {
  41. struct pci_controller *hose;
  42. /* from hose or from bus.devfn */
  43. if (which & IOBASE_FROM_HOSE) {
  44. for (hose = hose_head; hose; hose = hose->next)
  45. if (hose->index == bus)
  46. break;
  47. if (!hose)
  48. return -ENODEV;
  49. } else {
  50. /* Special hook for ISA access. */
  51. if (bus == 0 && dfn == 0)
  52. hose = pci_isa_hose;
  53. else
  54. return -ENODEV;
  55. }
  56. switch (which & ~IOBASE_FROM_HOSE) {
  57. case IOBASE_HOSE:
  58. return hose->index;
  59. case IOBASE_SPARSE_MEM:
  60. return hose->sparse_mem_base;
  61. case IOBASE_DENSE_MEM:
  62. return hose->dense_mem_base;
  63. case IOBASE_SPARSE_IO:
  64. return hose->sparse_io_base;
  65. case IOBASE_DENSE_IO:
  66. return hose->dense_io_base;
  67. case IOBASE_ROOT_BUS:
  68. return hose->bus->number;
  69. }
  70. return -EOPNOTSUPP;
  71. }
  72. SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn,
  73. unsigned long, off, unsigned long, len, void __user *, buf)
  74. {
  75. if (!capable(CAP_SYS_ADMIN))
  76. return -EPERM;
  77. else
  78. return -ENODEV;
  79. }
  80. SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn,
  81. unsigned long, off, unsigned long, len, void __user *, buf)
  82. {
  83. if (!capable(CAP_SYS_ADMIN))
  84. return -EPERM;
  85. else
  86. return -ENODEV;
  87. }