alpha_pci.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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.h"
  12. #include "vmware_vga.h"
  13. /* PCI IO reads/writes, to byte-word addressable memory. */
  14. /* ??? Doesn't handle multiple PCI busses. */
  15. static uint64_t bw_io_read(void *opaque, target_phys_addr_t addr, unsigned size)
  16. {
  17. switch (size) {
  18. case 1:
  19. return cpu_inb(addr);
  20. case 2:
  21. return cpu_inw(addr);
  22. case 4:
  23. return cpu_inl(addr);
  24. }
  25. abort();
  26. }
  27. static void bw_io_write(void *opaque, target_phys_addr_t addr,
  28. uint64_t val, unsigned size)
  29. {
  30. switch (size) {
  31. case 1:
  32. cpu_outb(addr, val);
  33. break;
  34. case 2:
  35. cpu_outw(addr, val);
  36. break;
  37. case 4:
  38. cpu_outl(addr, val);
  39. break;
  40. default:
  41. abort();
  42. }
  43. }
  44. const MemoryRegionOps alpha_pci_bw_io_ops = {
  45. .read = bw_io_read,
  46. .write = bw_io_write,
  47. .endianness = DEVICE_LITTLE_ENDIAN,
  48. .impl = {
  49. .min_access_size = 1,
  50. .max_access_size = 4,
  51. },
  52. };
  53. /* PCI config space reads/writes, to byte-word addressable memory. */
  54. static uint64_t bw_conf1_read(void *opaque, target_phys_addr_t addr,
  55. unsigned size)
  56. {
  57. PCIBus *b = opaque;
  58. return pci_data_read(b, addr, size);
  59. }
  60. static void bw_conf1_write(void *opaque, target_phys_addr_t addr,
  61. uint64_t val, unsigned size)
  62. {
  63. PCIBus *b = opaque;
  64. pci_data_write(b, addr, val, size);
  65. }
  66. const MemoryRegionOps alpha_pci_conf1_ops = {
  67. .read = bw_conf1_read,
  68. .write = bw_conf1_write,
  69. .endianness = DEVICE_LITTLE_ENDIAN,
  70. .impl = {
  71. .min_access_size = 1,
  72. .max_access_size = 4,
  73. },
  74. };
  75. /* PCI/EISA Interrupt Acknowledge Cycle. */
  76. static uint64_t iack_read(void *opaque, target_phys_addr_t addr, unsigned size)
  77. {
  78. return pic_read_irq(isa_pic);
  79. }
  80. static void special_write(void *opaque, target_phys_addr_t addr,
  81. uint64_t val, unsigned size)
  82. {
  83. qemu_log("pci: special write cycle");
  84. }
  85. const MemoryRegionOps alpha_pci_iack_ops = {
  86. .read = iack_read,
  87. .write = special_write,
  88. .endianness = DEVICE_LITTLE_ENDIAN,
  89. .valid = {
  90. .min_access_size = 4,
  91. .max_access_size = 4,
  92. },
  93. .impl = {
  94. .min_access_size = 4,
  95. .max_access_size = 4,
  96. },
  97. };
  98. void alpha_pci_vga_setup(PCIBus *pci_bus)
  99. {
  100. switch (vga_interface_type) {
  101. #ifdef CONFIG_SPICE
  102. case VGA_QXL:
  103. pci_create_simple(pci_bus, -1, "qxl-vga");
  104. return;
  105. #endif
  106. case VGA_CIRRUS:
  107. pci_cirrus_vga_init(pci_bus);
  108. return;
  109. case VGA_VMWARE:
  110. if (pci_vmsvga_init(pci_bus)) {
  111. return;
  112. }
  113. break;
  114. }
  115. /* If VGA is enabled at all, and one of the above didn't work, then
  116. fallback to Standard VGA. */
  117. if (vga_interface_type != VGA_NONE) {
  118. pci_vga_init(pci_bus);
  119. }
  120. }