alpha_pci.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * QEMU Alpha PCI support functions.
  3. *
  4. * Some of this isn't very Alpha specific at all.
  5. *
  6. * ??? Sparse memory access not implemented.
  7. */
  8. #include "config.h"
  9. #include "alpha_sys.h"
  10. #include "qemu/log.h"
  11. #include "sysemu/sysemu.h"
  12. /* PCI IO reads/writes, to byte-word addressable memory. */
  13. /* ??? Doesn't handle multiple PCI busses. */
  14. static uint64_t bw_io_read(void *opaque, hwaddr addr, unsigned size)
  15. {
  16. switch (size) {
  17. case 1:
  18. return cpu_inb(addr);
  19. case 2:
  20. return cpu_inw(addr);
  21. case 4:
  22. return cpu_inl(addr);
  23. }
  24. abort();
  25. }
  26. static void bw_io_write(void *opaque, hwaddr addr,
  27. uint64_t val, unsigned size)
  28. {
  29. switch (size) {
  30. case 1:
  31. cpu_outb(addr, val);
  32. break;
  33. case 2:
  34. cpu_outw(addr, val);
  35. break;
  36. case 4:
  37. cpu_outl(addr, val);
  38. break;
  39. default:
  40. abort();
  41. }
  42. }
  43. const MemoryRegionOps alpha_pci_bw_io_ops = {
  44. .read = bw_io_read,
  45. .write = bw_io_write,
  46. .endianness = DEVICE_LITTLE_ENDIAN,
  47. .impl = {
  48. .min_access_size = 1,
  49. .max_access_size = 4,
  50. },
  51. };
  52. /* PCI config space reads/writes, to byte-word addressable memory. */
  53. static uint64_t bw_conf1_read(void *opaque, hwaddr addr,
  54. unsigned size)
  55. {
  56. PCIBus *b = opaque;
  57. return pci_data_read(b, addr, size);
  58. }
  59. static void bw_conf1_write(void *opaque, hwaddr addr,
  60. uint64_t val, unsigned size)
  61. {
  62. PCIBus *b = opaque;
  63. pci_data_write(b, addr, val, size);
  64. }
  65. const MemoryRegionOps alpha_pci_conf1_ops = {
  66. .read = bw_conf1_read,
  67. .write = bw_conf1_write,
  68. .endianness = DEVICE_LITTLE_ENDIAN,
  69. .impl = {
  70. .min_access_size = 1,
  71. .max_access_size = 4,
  72. },
  73. };
  74. /* PCI/EISA Interrupt Acknowledge Cycle. */
  75. static uint64_t iack_read(void *opaque, hwaddr addr, unsigned size)
  76. {
  77. return pic_read_irq(isa_pic);
  78. }
  79. static void special_write(void *opaque, hwaddr addr,
  80. uint64_t val, unsigned size)
  81. {
  82. qemu_log("pci: special write cycle");
  83. }
  84. const MemoryRegionOps alpha_pci_iack_ops = {
  85. .read = iack_read,
  86. .write = special_write,
  87. .endianness = DEVICE_LITTLE_ENDIAN,
  88. .valid = {
  89. .min_access_size = 4,
  90. .max_access_size = 4,
  91. },
  92. .impl = {
  93. .min_access_size = 4,
  94. .max_access_size = 4,
  95. },
  96. };