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