6 #include "exec/memory.h"
7 #include "exec/ioport.h"
8 #include "hw/qdev-core.h"
9 #include "qom/object.h"
11 #define ISA_NUM_IRQS 16
13 #define TYPE_ISA_DEVICE "isa-device"
14 OBJECT_DECLARE_TYPE(ISADevice
, ISADeviceClass
, ISA_DEVICE
)
16 #define TYPE_ISA_BUS "ISA"
17 OBJECT_DECLARE_SIMPLE_TYPE(ISABus
, ISA_BUS
)
19 #define TYPE_APPLE_SMC "isa-applesmc"
20 #define APPLESMC_MAX_DATA_LENGTH 32
21 #define APPLESMC_PROP_IO_BASE "iobase"
23 static inline uint16_t applesmc_port(void)
25 Object
*obj
= object_resolve_path_type("", TYPE_APPLE_SMC
, NULL
);
28 return object_property_get_uint(obj
, APPLESMC_PROP_IO_BASE
, NULL
);
33 #define TYPE_ISADMA "isa-dma"
35 typedef struct IsaDmaClass IsaDmaClass
;
36 DECLARE_CLASS_CHECKERS(IsaDmaClass
, ISADMA
,
39 INTERFACE_CHECK(IsaDma, (obj), TYPE_ISADMA)
42 ISADMA_TRANSFER_VERIFY
,
44 ISADMA_TRANSFER_WRITE
,
45 ISADMA_TRANSFER_ILLEGAL
,
48 typedef int (*IsaDmaTransferHandler
)(void *opaque
, int nchan
, int pos
,
52 InterfaceClass parent
;
54 bool (*has_autoinitialization
)(IsaDma
*obj
, int nchan
);
55 int (*read_memory
)(IsaDma
*obj
, int nchan
, void *buf
, int pos
, int len
);
56 int (*write_memory
)(IsaDma
*obj
, int nchan
, void *buf
, int pos
, int len
);
57 void (*hold_DREQ
)(IsaDma
*obj
, int nchan
);
58 void (*release_DREQ
)(IsaDma
*obj
, int nchan
);
59 void (*schedule
)(IsaDma
*obj
);
60 void (*register_channel
)(IsaDma
*obj
, int nchan
,
61 IsaDmaTransferHandler transfer_handler
,
65 struct ISADeviceClass
{
66 DeviceClass parent_class
;
67 void (*build_aml
)(ISADevice
*dev
, Aml
*scope
);
75 MemoryRegion
*address_space
;
76 MemoryRegion
*address_space_io
;
83 DeviceState parent_obj
;
86 int8_t isairq
[2]; /* -1 = unassigned */
91 ISABus
*isa_bus_new(DeviceState
*dev
, MemoryRegion
*address_space
,
92 MemoryRegion
*address_space_io
, Error
**errp
);
93 void isa_bus_irqs(ISABus
*bus
, qemu_irq
*irqs
);
94 qemu_irq
isa_get_irq(ISADevice
*dev
, unsigned isairq
);
95 void isa_init_irq(ISADevice
*dev
, qemu_irq
*p
, unsigned isairq
);
96 void isa_connect_gpio_out(ISADevice
*isadev
, int gpioirq
, unsigned isairq
);
97 void isa_bus_dma(ISABus
*bus
, IsaDma
*dma8
, IsaDma
*dma16
);
98 IsaDma
*isa_get_dma(ISABus
*bus
, int nchan
);
99 MemoryRegion
*isa_address_space(ISADevice
*dev
);
100 MemoryRegion
*isa_address_space_io(ISADevice
*dev
);
101 ISADevice
*isa_new(const char *name
);
102 ISADevice
*isa_try_new(const char *name
);
103 bool isa_realize_and_unref(ISADevice
*dev
, ISABus
*bus
, Error
**errp
);
104 ISADevice
*isa_create_simple(ISABus
*bus
, const char *name
);
106 ISADevice
*isa_vga_init(ISABus
*bus
);
107 void isa_build_aml(ISABus
*bus
, Aml
*scope
);
110 * isa_register_ioport: Install an I/O port region on the ISA bus.
112 * Register an I/O port region via memory_region_add_subregion
113 * inside the ISA I/O address space.
115 * @dev: the ISADevice against which these are registered; may be NULL.
116 * @io: the #MemoryRegion being registered.
117 * @start: the base I/O port.
119 void isa_register_ioport(ISADevice
*dev
, MemoryRegion
*io
, uint16_t start
);
122 * isa_register_portio_list: Initialize a set of ISA io ports
124 * Several ISA devices have many dis-joint I/O ports. Worse, these I/O
125 * ports can be interleaved with I/O ports from other devices. This
126 * function makes it easy to create multiple MemoryRegions for a single
127 * device and use the legacy portio routines.
129 * @dev: the ISADevice against which these are registered; may be NULL.
130 * @piolist: the PortioList associated with the io ports
131 * @start: the base I/O port against which the portio->offset is applied.
132 * @portio: the ports, sorted by offset.
133 * @opaque: passed into the portio callbacks.
134 * @name: passed into memory_region_init_io.
136 * Returns: 0 on success, negative error code otherwise (e.g. if the
137 * ISA bus is not available)
139 int isa_register_portio_list(ISADevice
*dev
,
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 #define TYPE_PIIX4_PCI_DEVICE "piix4-isa"