isa.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #ifndef HW_ISA_H
  2. #define HW_ISA_H
  3. /* ISA bus */
  4. #include "ioport.h"
  5. #include "memory.h"
  6. #include "qdev.h"
  7. #define ISA_NUM_IRQS 16
  8. #define TYPE_ISA_DEVICE "isa-device"
  9. #define ISA_DEVICE(obj) \
  10. OBJECT_CHECK(ISADevice, (obj), TYPE_ISA_DEVICE)
  11. #define ISA_DEVICE_CLASS(klass) \
  12. OBJECT_CLASS_CHECK(ISADeviceClass, (klass), TYPE_ISA_DEVICE)
  13. #define ISA_DEVICE_GET_CLASS(obj) \
  14. OBJECT_GET_CLASS(ISADeviceClass, (obj), TYPE_ISA_DEVICE)
  15. #define TYPE_ISA_BUS "ISA"
  16. #define ISA_BUS(obj) OBJECT_CHECK(ISABus, (obj), TYPE_ISA_BUS)
  17. typedef struct ISADeviceClass {
  18. DeviceClass parent_class;
  19. int (*init)(ISADevice *dev);
  20. } ISADeviceClass;
  21. struct ISABus {
  22. BusState qbus;
  23. MemoryRegion *address_space_io;
  24. qemu_irq *irqs;
  25. };
  26. struct ISADevice {
  27. DeviceState qdev;
  28. uint32_t isairq[2];
  29. int nirqs;
  30. int ioport_id;
  31. };
  32. ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io);
  33. void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
  34. qemu_irq isa_get_irq(ISADevice *dev, int isairq);
  35. void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
  36. MemoryRegion *isa_address_space(ISADevice *dev);
  37. ISADevice *isa_create(ISABus *bus, const char *name);
  38. ISADevice *isa_try_create(ISABus *bus, const char *name);
  39. ISADevice *isa_create_simple(ISABus *bus, const char *name);
  40. /**
  41. * isa_register_ioport: Install an I/O port region on the ISA bus.
  42. *
  43. * Register an I/O port region via memory_region_add_subregion
  44. * inside the ISA I/O address space.
  45. *
  46. * @dev: the ISADevice against which these are registered; may be NULL.
  47. * @io: the #MemoryRegion being registered.
  48. * @start: the base I/O port.
  49. */
  50. void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start);
  51. /**
  52. * isa_register_portio_list: Initialize a set of ISA io ports
  53. *
  54. * Several ISA devices have many dis-joint I/O ports. Worse, these I/O
  55. * ports can be interleaved with I/O ports from other devices. This
  56. * function makes it easy to create multiple MemoryRegions for a single
  57. * device and use the legacy portio routines.
  58. *
  59. * @dev: the ISADevice against which these are registered; may be NULL.
  60. * @start: the base I/O port against which the portio->offset is applied.
  61. * @portio: the ports, sorted by offset.
  62. * @opaque: passed into the old_portio callbacks.
  63. * @name: passed into memory_region_init_io.
  64. */
  65. void isa_register_portio_list(ISADevice *dev, uint16_t start,
  66. const MemoryRegionPortio *portio,
  67. void *opaque, const char *name);
  68. static inline ISABus *isa_bus_from_device(ISADevice *d)
  69. {
  70. return DO_UPCAST(ISABus, qbus, d->qdev.parent_bus);
  71. }
  72. extern target_phys_addr_t isa_mem_base;
  73. void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size);
  74. void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size);
  75. /* dma.c */
  76. int DMA_get_channel_mode (int nchan);
  77. int DMA_read_memory (int nchan, void *buf, int pos, int size);
  78. int DMA_write_memory (int nchan, void *buf, int pos, int size);
  79. void DMA_hold_DREQ (int nchan);
  80. void DMA_release_DREQ (int nchan);
  81. void DMA_schedule(int nchan);
  82. void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit);
  83. void DMA_register_channel (int nchan,
  84. DMA_transfer_handler transfer_handler,
  85. void *opaque);
  86. #endif