blueswir1 | 79383c9 | 2008-08-30 09:51:20 +0000 | [diff] [blame] | 1 | #ifndef HW_ISA_H |
| 2 | #define HW_ISA_H |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 3 | |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 4 | /* ISA bus */ |
| 5 | |
Isaku Yamahata | 3299397 | 2009-07-02 19:32:06 +0900 | [diff] [blame] | 6 | #include "ioport.h" |
Avi Kivity | af956ca | 2011-08-08 16:09:21 +0300 | [diff] [blame] | 7 | #include "memory.h" |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 8 | #include "qdev.h" |
| 9 | |
Jan Kiszka | b881fbe | 2011-10-07 09:19:35 +0200 | [diff] [blame] | 10 | #define ISA_NUM_IRQS 16 |
| 11 | |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 12 | typedef struct ISADevice ISADevice; |
| 13 | typedef struct ISADeviceInfo ISADeviceInfo; |
| 14 | |
Hervé Poussineau | d1a1be1 | 2011-12-15 22:09:52 +0100 | [diff] [blame] | 15 | struct ISABus { |
| 16 | BusState qbus; |
| 17 | MemoryRegion *address_space_io; |
| 18 | qemu_irq *irqs; |
| 19 | }; |
| 20 | |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 21 | struct ISADevice { |
| 22 | DeviceState qdev; |
Gerd Hoffmann | 2091ba2 | 2009-08-14 11:36:14 +0200 | [diff] [blame] | 23 | uint32_t isairq[2]; |
Richard Henderson | 78e2059 | 2011-08-10 15:28:12 -0700 | [diff] [blame] | 24 | int nirqs; |
Richard Henderson | ebf47c2 | 2011-08-15 11:59:09 -0700 | [diff] [blame] | 25 | int ioport_id; |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 26 | }; |
| 27 | |
Gerd Hoffmann | 81a322d | 2009-08-14 10:36:05 +0200 | [diff] [blame] | 28 | typedef int (*isa_qdev_initfn)(ISADevice *dev); |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 29 | struct ISADeviceInfo { |
| 30 | DeviceInfo qdev; |
| 31 | isa_qdev_initfn init; |
| 32 | }; |
| 33 | |
Richard Henderson | c2d0d01 | 2011-08-10 15:28:11 -0700 | [diff] [blame] | 34 | ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space_io); |
Hervé Poussineau | 48a18b3 | 2011-12-15 22:09:51 +0100 | [diff] [blame] | 35 | void isa_bus_irqs(ISABus *bus, qemu_irq *irqs); |
| 36 | qemu_irq isa_get_irq(ISADevice *dev, int isairq); |
Gerd Hoffmann | 2e15e23 | 2009-09-10 11:43:27 +0200 | [diff] [blame] | 37 | void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq); |
Gerd Hoffmann | f915a11 | 2009-07-31 12:30:14 +0200 | [diff] [blame] | 38 | void isa_qdev_register(ISADeviceInfo *info); |
Avi Kivity | c839ade | 2011-08-15 17:17:35 +0300 | [diff] [blame] | 39 | MemoryRegion *isa_address_space(ISADevice *dev); |
Hervé Poussineau | 48a18b3 | 2011-12-15 22:09:51 +0100 | [diff] [blame] | 40 | ISADevice *isa_create(ISABus *bus, const char *name); |
| 41 | ISADevice *isa_try_create(ISABus *bus, const char *name); |
| 42 | ISADevice *isa_create_simple(ISABus *bus, const char *name); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 43 | |
Avi Kivity | d750073 | 2011-09-26 14:52:44 +0300 | [diff] [blame] | 44 | /** |
| 45 | * isa_register_ioport: Install an I/O port region on the ISA bus. |
| 46 | * |
| 47 | * Register an I/O port region via memory_region_add_subregion |
| 48 | * inside the ISA I/O address space. |
| 49 | * |
| 50 | * @dev: the ISADevice against which these are registered; may be NULL. |
| 51 | * @io: the #MemoryRegion being registered. |
| 52 | * @start: the base I/O port. |
| 53 | */ |
| 54 | void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start); |
| 55 | |
| 56 | /** |
| 57 | * isa_register_portio_list: Initialize a set of ISA io ports |
| 58 | * |
| 59 | * Several ISA devices have many dis-joint I/O ports. Worse, these I/O |
| 60 | * ports can be interleaved with I/O ports from other devices. This |
| 61 | * function makes it easy to create multiple MemoryRegions for a single |
| 62 | * device and use the legacy portio routines. |
| 63 | * |
| 64 | * @dev: the ISADevice against which these are registered; may be NULL. |
| 65 | * @start: the base I/O port against which the portio->offset is applied. |
| 66 | * @portio: the ports, sorted by offset. |
| 67 | * @opaque: passed into the old_portio callbacks. |
| 68 | * @name: passed into memory_region_init_io. |
| 69 | */ |
| 70 | void isa_register_portio_list(ISADevice *dev, uint16_t start, |
| 71 | const MemoryRegionPortio *portio, |
| 72 | void *opaque, const char *name); |
| 73 | |
Anthony Liguori | c227f09 | 2009-10-01 16:12:16 -0500 | [diff] [blame] | 74 | extern target_phys_addr_t isa_mem_base; |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 75 | |
Avi Kivity | af956ca | 2011-08-08 16:09:21 +0300 | [diff] [blame] | 76 | void isa_mmio_setup(MemoryRegion *mr, target_phys_addr_t size); |
Alexander Graf | 968d683 | 2010-12-08 12:05:49 +0100 | [diff] [blame] | 77 | void isa_mmio_init(target_phys_addr_t base, target_phys_addr_t size); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 78 | |
| 79 | /* dma.c */ |
| 80 | int DMA_get_channel_mode (int nchan); |
| 81 | int DMA_read_memory (int nchan, void *buf, int pos, int size); |
| 82 | int DMA_write_memory (int nchan, void *buf, int pos, int size); |
| 83 | void DMA_hold_DREQ (int nchan); |
| 84 | void DMA_release_DREQ (int nchan); |
| 85 | void DMA_schedule(int nchan); |
Blue Swirl | 4556bd8 | 2010-05-22 08:00:52 +0000 | [diff] [blame] | 86 | void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit); |
pbrook | 87ecb68 | 2007-11-17 17:14:51 +0000 | [diff] [blame] | 87 | void DMA_register_channel (int nchan, |
| 88 | DMA_transfer_handler transfer_handler, |
| 89 | void *opaque); |
blueswir1 | 79383c9 | 2008-08-30 09:51:20 +0000 | [diff] [blame] | 90 | #endif |