tcg: Remove needless CPUState::current_tb
[qemu/ar7.git] / include / hw / isa / isa.h
blobffb2ea7cdf8b5960f33040e66a2bfa66b06d5597
1 #ifndef HW_ISA_H
2 #define HW_ISA_H
4 /* ISA bus */
6 #include "exec/ioport.h"
7 #include "exec/memory.h"
8 #include "hw/qdev.h"
10 #define ISA_NUM_IRQS 16
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)
20 #define TYPE_ISA_BUS "ISA"
21 #define ISA_BUS(obj) OBJECT_CHECK(ISABus, (obj), TYPE_ISA_BUS)
23 #define TYPE_APPLE_SMC "isa-applesmc"
24 #define APPLESMC_MAX_DATA_LENGTH 32
25 #define APPLESMC_PROP_IO_BASE "iobase"
27 static inline uint16_t applesmc_port(void)
29 Object *obj = object_resolve_path_type("", TYPE_APPLE_SMC, NULL);
31 if (obj) {
32 return object_property_get_int(obj, APPLESMC_PROP_IO_BASE, NULL);
34 return 0;
37 #define TYPE_ISADMA "isa-dma"
39 #define ISADMA_CLASS(klass) \
40 OBJECT_CLASS_CHECK(IsaDmaClass, (klass), TYPE_ISADMA)
41 #define ISADMA_GET_CLASS(obj) \
42 OBJECT_GET_CLASS(IsaDmaClass, (obj), TYPE_ISADMA)
43 #define ISADMA(obj) \
44 INTERFACE_CHECK(IsaDma, (obj), TYPE_ISADMA)
46 struct IsaDma {
47 Object parent;
50 typedef enum {
51 ISADMA_TRANSFER_VERIFY,
52 ISADMA_TRANSFER_READ,
53 ISADMA_TRANSFER_WRITE,
54 ISADMA_TRANSFER_ILLEGAL,
55 } IsaDmaTransferMode;
57 typedef int (*IsaDmaTransferHandler)(void *opaque, int nchan, int pos,
58 int size);
60 typedef struct IsaDmaClass {
61 InterfaceClass parent;
63 IsaDmaTransferMode (*get_transfer_mode)(IsaDma *obj, int nchan);
64 bool (*has_autoinitialization)(IsaDma *obj, int nchan);
65 int (*read_memory)(IsaDma *obj, int nchan, void *buf, int pos, int len);
66 int (*write_memory)(IsaDma *obj, int nchan, void *buf, int pos, int len);
67 void (*hold_DREQ)(IsaDma *obj, int nchan);
68 void (*release_DREQ)(IsaDma *obj, int nchan);
69 void (*schedule)(IsaDma *obj);
70 void (*register_channel)(IsaDma *obj, int nchan,
71 IsaDmaTransferHandler transfer_handler,
72 void *opaque);
73 } IsaDmaClass;
75 typedef struct ISADeviceClass {
76 DeviceClass parent_class;
77 } ISADeviceClass;
79 struct ISABus {
80 /*< private >*/
81 BusState parent_obj;
82 /*< public >*/
84 MemoryRegion *address_space;
85 MemoryRegion *address_space_io;
86 qemu_irq *irqs;
87 IsaDma *dma[2];
90 struct ISADevice {
91 /*< private >*/
92 DeviceState parent_obj;
93 /*< public >*/
95 uint32_t isairq[2];
96 int nirqs;
97 int ioport_id;
100 ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space,
101 MemoryRegion *address_space_io, Error **errp);
102 void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
103 qemu_irq isa_get_irq(ISADevice *dev, int isairq);
104 void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
105 void isa_bus_dma(ISABus *bus, IsaDma *dma8, IsaDma *dma16);
106 IsaDma *isa_get_dma(ISABus *bus, int nchan);
107 MemoryRegion *isa_address_space(ISADevice *dev);
108 MemoryRegion *isa_address_space_io(ISADevice *dev);
109 ISADevice *isa_create(ISABus *bus, const char *name);
110 ISADevice *isa_try_create(ISABus *bus, const char *name);
111 ISADevice *isa_create_simple(ISABus *bus, const char *name);
113 ISADevice *isa_vga_init(ISABus *bus);
116 * isa_register_ioport: Install an I/O port region on the ISA bus.
118 * Register an I/O port region via memory_region_add_subregion
119 * inside the ISA I/O address space.
121 * @dev: the ISADevice against which these are registered; may be NULL.
122 * @io: the #MemoryRegion being registered.
123 * @start: the base I/O port.
125 void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start);
128 * isa_register_portio_list: Initialize a set of ISA io ports
130 * Several ISA devices have many dis-joint I/O ports. Worse, these I/O
131 * ports can be interleaved with I/O ports from other devices. This
132 * function makes it easy to create multiple MemoryRegions for a single
133 * device and use the legacy portio routines.
135 * @dev: the ISADevice against which these are registered; may be NULL.
136 * @start: the base I/O port against which the portio->offset is applied.
137 * @portio: the ports, sorted by offset.
138 * @opaque: passed into the portio callbacks.
139 * @name: passed into memory_region_init_io.
141 void isa_register_portio_list(ISADevice *dev, uint16_t start,
142 const MemoryRegionPortio *portio,
143 void *opaque, const char *name);
145 static inline ISABus *isa_bus_from_device(ISADevice *d)
147 return ISA_BUS(qdev_get_parent_bus(DEVICE(d)));
150 /* i8257.c */
151 void DMA_init(ISABus *bus, int high_page_enable);
152 #endif