pci-noop.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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/memblock.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 = memblock_alloc(sizeof(*hose), SMP_CACHE_BYTES);
  29. if (!hose)
  30. panic("%s: Failed to allocate %zu bytes\n", __func__,
  31. sizeof(*hose));
  32. *hose_tail = hose;
  33. hose_tail = &hose->next;
  34. return hose;
  35. }
  36. struct resource * __init
  37. alloc_resource(void)
  38. {
  39. void *ptr = memblock_alloc(sizeof(struct resource), SMP_CACHE_BYTES);
  40. if (!ptr)
  41. panic("%s: Failed to allocate %zu bytes\n", __func__,
  42. sizeof(struct resource));
  43. return ptr;
  44. }
  45. SYSCALL_DEFINE3(pciconfig_iobase, long, which, unsigned long, bus,
  46. unsigned long, dfn)
  47. {
  48. struct pci_controller *hose;
  49. /* from hose or from bus.devfn */
  50. if (which & IOBASE_FROM_HOSE) {
  51. for (hose = hose_head; hose; hose = hose->next)
  52. if (hose->index == bus)
  53. break;
  54. if (!hose)
  55. return -ENODEV;
  56. } else {
  57. /* Special hook for ISA access. */
  58. if (bus == 0 && dfn == 0)
  59. hose = pci_isa_hose;
  60. else
  61. return -ENODEV;
  62. }
  63. switch (which & ~IOBASE_FROM_HOSE) {
  64. case IOBASE_HOSE:
  65. return hose->index;
  66. case IOBASE_SPARSE_MEM:
  67. return hose->sparse_mem_base;
  68. case IOBASE_DENSE_MEM:
  69. return hose->dense_mem_base;
  70. case IOBASE_SPARSE_IO:
  71. return hose->sparse_io_base;
  72. case IOBASE_DENSE_IO:
  73. return hose->dense_io_base;
  74. case IOBASE_ROOT_BUS:
  75. return hose->bus->number;
  76. }
  77. return -EOPNOTSUPP;
  78. }
  79. SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn,
  80. unsigned long, off, unsigned long, len, void __user *, buf)
  81. {
  82. if (!capable(CAP_SYS_ADMIN))
  83. return -EPERM;
  84. else
  85. return -ENODEV;
  86. }
  87. SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn,
  88. unsigned long, off, unsigned long, len, void __user *, buf)
  89. {
  90. if (!capable(CAP_SYS_ADMIN))
  91. return -EPERM;
  92. else
  93. return -ENODEV;
  94. }