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