macio.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * PowerMac MacIO device emulation
  3. *
  4. * Copyright (c) 2005-2007 Fabrice Bellard
  5. * Copyright (c) 2007 Jocelyn Mayer
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a copy
  8. * of this software and associated documentation files (the "Software"), to deal
  9. * in the Software without restriction, including without limitation the rights
  10. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  11. * copies of the Software, and to permit persons to whom the Software is
  12. * furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included in
  15. * all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  20. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. * THE SOFTWARE.
  24. */
  25. #ifndef MACIO_H
  26. #define MACIO_H
  27. #include "hw/char/escc.h"
  28. #include "hw/pci/pci_device.h"
  29. #include "hw/ide/internal.h"
  30. #include "hw/intc/heathrow_pic.h"
  31. #include "hw/misc/macio/cuda.h"
  32. #include "hw/misc/macio/gpio.h"
  33. #include "hw/misc/macio/pmu.h"
  34. #include "hw/nvram/mac_nvram.h"
  35. #include "hw/ppc/mac_dbdma.h"
  36. #include "hw/ppc/openpic.h"
  37. #include "qom/object.h"
  38. /* Old World IRQs */
  39. #define OLDWORLD_CUDA_IRQ 0x12
  40. #define OLDWORLD_ESCCB_IRQ 0x10
  41. #define OLDWORLD_ESCCA_IRQ 0xf
  42. #define OLDWORLD_IDE0_IRQ 0xd
  43. #define OLDWORLD_IDE0_DMA_IRQ 0x2
  44. #define OLDWORLD_IDE1_IRQ 0xe
  45. #define OLDWORLD_IDE1_DMA_IRQ 0x3
  46. /* New World IRQs */
  47. #define NEWWORLD_CUDA_IRQ 0x19
  48. #define NEWWORLD_PMU_IRQ 0x19
  49. #define NEWWORLD_ESCCB_IRQ 0x24
  50. #define NEWWORLD_ESCCA_IRQ 0x25
  51. #define NEWWORLD_IDE0_IRQ 0xd
  52. #define NEWWORLD_IDE0_DMA_IRQ 0x2
  53. #define NEWWORLD_IDE1_IRQ 0xe
  54. #define NEWWORLD_IDE1_DMA_IRQ 0x3
  55. #define NEWWORLD_EXTING_GPIO1 0x2f
  56. #define NEWWORLD_EXTING_GPIO9 0x37
  57. /* MacIO virtual bus */
  58. #define TYPE_MACIO_BUS "macio-bus"
  59. OBJECT_DECLARE_SIMPLE_TYPE(MacIOBusState, MACIO_BUS)
  60. struct MacIOBusState {
  61. /*< private >*/
  62. BusState parent_obj;
  63. };
  64. /* MacIO IDE */
  65. #define TYPE_MACIO_IDE "macio-ide"
  66. OBJECT_DECLARE_SIMPLE_TYPE(MACIOIDEState, MACIO_IDE)
  67. struct MACIOIDEState {
  68. /*< private >*/
  69. SysBusDevice parent_obj;
  70. /*< public >*/
  71. uint32_t addr;
  72. uint32_t channel;
  73. qemu_irq real_ide_irq;
  74. qemu_irq real_dma_irq;
  75. qemu_irq ide_irq;
  76. qemu_irq dma_irq;
  77. MemoryRegion mem;
  78. IDEBus bus;
  79. IDEDMA dma;
  80. void *dbdma;
  81. bool dma_active;
  82. uint32_t timing_reg;
  83. uint32_t irq_reg;
  84. };
  85. void macio_ide_init_drives(MACIOIDEState *ide, DriveInfo **hd_table);
  86. void macio_ide_register_dma(MACIOIDEState *ide);
  87. #define TYPE_MACIO "macio"
  88. OBJECT_DECLARE_SIMPLE_TYPE(MacIOState, MACIO)
  89. struct MacIOState {
  90. /*< private >*/
  91. PCIDevice parent;
  92. /*< public >*/
  93. MacIOBusState macio_bus;
  94. MemoryRegion bar;
  95. CUDAState cuda;
  96. PMUState pmu;
  97. DBDMAState dbdma;
  98. ESCCState escc;
  99. uint64_t frequency;
  100. };
  101. #define TYPE_OLDWORLD_MACIO "macio-oldworld"
  102. OBJECT_DECLARE_SIMPLE_TYPE(OldWorldMacIOState, OLDWORLD_MACIO)
  103. struct OldWorldMacIOState {
  104. /*< private >*/
  105. MacIOState parent_obj;
  106. /*< public >*/
  107. HeathrowState pic;
  108. MacIONVRAMState nvram;
  109. MACIOIDEState ide[2];
  110. };
  111. #define TYPE_NEWWORLD_MACIO "macio-newworld"
  112. OBJECT_DECLARE_SIMPLE_TYPE(NewWorldMacIOState, NEWWORLD_MACIO)
  113. struct NewWorldMacIOState {
  114. /*< private >*/
  115. MacIOState parent_obj;
  116. /*< public >*/
  117. bool has_pmu;
  118. bool has_adb;
  119. OpenPICState pic;
  120. MACIOIDEState ide[2];
  121. MacIOGPIOState gpio;
  122. };
  123. #endif /* MACIO_H */