alpha_pci.c 3.0 KB

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