6 #include "exec/memory.h"
7 #include "exec/ioport.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
);
32 return object_property_get_uint(obj
, APPLESMC_PROP_IO_BASE
, NULL
);
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)
44 INTERFACE_CHECK(IsaDma, (obj), TYPE_ISADMA)
51 ISADMA_TRANSFER_VERIFY
,
53 ISADMA_TRANSFER_WRITE
,
54 ISADMA_TRANSFER_ILLEGAL
,
57 typedef int (*IsaDmaTransferHandler
)(void *opaque
, int nchan
, int pos
,
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
,
75 typedef struct ISADeviceClass
{
76 DeviceClass parent_class
;
84 MemoryRegion
*address_space
;
85 MemoryRegion
*address_space_io
;
92 DeviceState parent_obj
;
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_connect_gpio_out(ISADevice
*isadev
, int gpioirq
, int isairq
);
106 void isa_bus_dma(ISABus
*bus
, IsaDma
*dma8
, IsaDma
*dma16
);
107 IsaDma
*isa_get_dma(ISABus
*bus
, int nchan
);
108 MemoryRegion
*isa_address_space(ISADevice
*dev
);
109 MemoryRegion
*isa_address_space_io(ISADevice
*dev
);
110 ISADevice
*isa_create(ISABus
*bus
, const char *name
);
111 ISADevice
*isa_try_create(ISABus
*bus
, const char *name
);
112 ISADevice
*isa_create_simple(ISABus
*bus
, const char *name
);
114 ISADevice
*isa_vga_init(ISABus
*bus
);
117 * isa_register_ioport: Install an I/O port region on the ISA bus.
119 * Register an I/O port region via memory_region_add_subregion
120 * inside the ISA I/O address space.
122 * @dev: the ISADevice against which these are registered; may be NULL.
123 * @io: the #MemoryRegion being registered.
124 * @start: the base I/O port.
126 void isa_register_ioport(ISADevice
*dev
, MemoryRegion
*io
, uint16_t start
);
129 * isa_register_portio_list: Initialize a set of ISA io ports
131 * Several ISA devices have many dis-joint I/O ports. Worse, these I/O
132 * ports can be interleaved with I/O ports from other devices. This
133 * function makes it easy to create multiple MemoryRegions for a single
134 * device and use the legacy portio routines.
136 * @dev: the ISADevice against which these are registered; may be NULL.
137 * @piolist: the PortioList associated with the io ports
138 * @start: the base I/O port against which the portio->offset is applied.
139 * @portio: the ports, sorted by offset.
140 * @opaque: passed into the portio callbacks.
141 * @name: passed into memory_region_init_io.
143 void isa_register_portio_list(ISADevice
*dev
,
146 const MemoryRegionPortio
*portio
,
147 void *opaque
, const char *name
);
149 static inline ISABus
*isa_bus_from_device(ISADevice
*d
)
151 return ISA_BUS(qdev_get_parent_bus(DEVICE(d
)));
155 void DMA_init(ISABus
*bus
, int high_page_enable
);