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
;
89 ISABus
*isa_bus_new(DeviceState
*dev
, MemoryRegion
*address_space
,
90 MemoryRegion
*address_space_io
, Error
**errp
);
91 void isa_bus_irqs(ISABus
*bus
, qemu_irq
*irqs
);
92 qemu_irq
isa_get_irq(ISADevice
*dev
, unsigned isairq
);
93 void isa_connect_gpio_out(ISADevice
*isadev
, int gpioirq
, unsigned isairq
);
94 void isa_bus_dma(ISABus
*bus
, IsaDma
*dma8
, IsaDma
*dma16
);
95 IsaDma
*isa_get_dma(ISABus
*bus
, int nchan
);
96 MemoryRegion
*isa_address_space(ISADevice
*dev
);
97 MemoryRegion
*isa_address_space_io(ISADevice
*dev
);
98 ISADevice
*isa_new(const char *name
);
99 ISADevice
*isa_try_new(const char *name
);
100 bool isa_realize_and_unref(ISADevice
*dev
, ISABus
*bus
, Error
**errp
);
101 ISADevice
*isa_create_simple(ISABus
*bus
, const char *name
);
103 ISADevice
*isa_vga_init(ISABus
*bus
);
104 void isa_build_aml(ISABus
*bus
, Aml
*scope
);
107 * isa_register_ioport: Install an I/O port region on the ISA bus.
109 * Register an I/O port region via memory_region_add_subregion
110 * inside the ISA I/O address space.
112 * @dev: the ISADevice against which these are registered; may be NULL.
113 * @io: the #MemoryRegion being registered.
114 * @start: the base I/O port.
116 void isa_register_ioport(ISADevice
*dev
, MemoryRegion
*io
, uint16_t start
);
119 * isa_register_portio_list: Initialize a set of ISA io ports
121 * Several ISA devices have many dis-joint I/O ports. Worse, these I/O
122 * ports can be interleaved with I/O ports from other devices. This
123 * function makes it easy to create multiple MemoryRegions for a single
124 * device and use the legacy portio routines.
126 * @dev: the ISADevice against which these are registered; may be NULL.
127 * @piolist: the PortioList associated with the io ports
128 * @start: the base I/O port against which the portio->offset is applied.
129 * @portio: the ports, sorted by offset.
130 * @opaque: passed into the portio callbacks.
131 * @name: passed into memory_region_init_io.
133 * Returns: 0 on success, negative error code otherwise (e.g. if the
134 * ISA bus is not available)
136 int isa_register_portio_list(ISADevice
*dev
,
139 const MemoryRegionPortio
*portio
,
140 void *opaque
, const char *name
);
142 static inline ISABus
*isa_bus_from_device(ISADevice
*d
)
144 return ISA_BUS(qdev_get_parent_bus(DEVICE(d
)));
147 #define TYPE_PIIX4_PCI_DEVICE "piix4-isa"