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 typedef struct ISADeviceClass { 24 DeviceClass parent_class; 25 } ISADeviceClass; 26 27 struct ISABus { 28 /*< private >*/ 29 BusState parent_obj; 30 /*< public >*/ 31 32 MemoryRegion *address_space_io; 33 qemu_irq *irqs; 34 }; 35 36 struct ISADevice { 37 /*< private >*/ 38 DeviceState parent_obj; 39 /*< public >*/ 40 41 uint32_t isairq[2]; 42 int nirqs; 43 int ioport_id; 44 }; 45 46 ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io); 47 void isa_bus_irqs(ISABus *bus, qemu_irq *irqs); 48 qemu_irq isa_get_irq(ISADevice *dev, int isairq); 49 void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq); 50 MemoryRegion *isa_address_space(ISADevice *dev); 51 MemoryRegion *isa_address_space_io(ISADevice *dev); 52 ISADevice *isa_create(ISABus *bus, const char *name); 53 ISADevice *isa_try_create(ISABus *bus, const char *name); 54 ISADevice *isa_create_simple(ISABus *bus, const char *name); 55 56 ISADevice *isa_vga_init(ISABus *bus); 57 58 /** 59 * isa_register_ioport: Install an I/O port region on the ISA bus. 60 * 61 * Register an I/O port region via memory_region_add_subregion 62 * inside the ISA I/O address space. 63 * 64 * @dev: the ISADevice against which these are registered; may be NULL. 65 * @io: the #MemoryRegion being registered. 66 * @start: the base I/O port. 67 */ 68 void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start); 69 70 /** 71 * isa_register_portio_list: Initialize a set of ISA io ports 72 * 73 * Several ISA devices have many dis-joint I/O ports. Worse, these I/O 74 * ports can be interleaved with I/O ports from other devices. This 75 * function makes it easy to create multiple MemoryRegions for a single 76 * device and use the legacy portio routines. 77 * 78 * @dev: the ISADevice against which these are registered; may be NULL. 79 * @start: the base I/O port against which the portio->offset is applied. 80 * @portio: the ports, sorted by offset. 81 * @opaque: passed into the portio callbacks. 82 * @name: passed into memory_region_init_io. 83 */ 84 void isa_register_portio_list(ISADevice *dev, uint16_t start, 85 const MemoryRegionPortio *portio, 86 void *opaque, const char *name); 87 88 static inline ISABus *isa_bus_from_device(ISADevice *d) 89 { 90 return ISA_BUS(qdev_get_parent_bus(DEVICE(d))); 91 } 92 93 extern hwaddr isa_mem_base; 94 95 /* dma.c */ 96 int DMA_get_channel_mode (int nchan); 97 int DMA_read_memory (int nchan, void *buf, int pos, int size); 98 int DMA_write_memory (int nchan, void *buf, int pos, int size); 99 void DMA_hold_DREQ (int nchan); 100 void DMA_release_DREQ (int nchan); 101 void DMA_schedule(int nchan); 102 void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit); 103 void DMA_register_channel (int nchan, 104 DMA_transfer_handler transfer_handler, 105 void *opaque); 106 #endif 107