1#ifndef HW_ISA_H
2#define HW_ISA_H
3
4
5
6#include "exec/ioport.h"
7#include "exec/memory.h"
8#include "hw/qdev.h"
9
10#define ISA_NUM_IRQS 16
11
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)
19
20#define TYPE_ISA_BUS "ISA"
21#define ISA_BUS(obj) OBJECT_CHECK(ISABus, (obj), TYPE_ISA_BUS)
22
23#define TYPE_APPLE_SMC "isa-applesmc"
24#define APPLESMC_MAX_DATA_LENGTH 32
25#define APPLESMC_PROP_IO_BASE "iobase"
26
27static inline uint16_t applesmc_port(void)
28{
29 Object *obj = object_resolve_path_type("", TYPE_APPLE_SMC, NULL);
30
31 if (obj) {
32 return object_property_get_int(obj, APPLESMC_PROP_IO_BASE, NULL);
33 }
34 return 0;
35}
36
37typedef struct ISADeviceClass {
38 DeviceClass parent_class;
39} ISADeviceClass;
40
41struct ISABus {
42
43 BusState parent_obj;
44
45
46 MemoryRegion *address_space;
47 MemoryRegion *address_space_io;
48 qemu_irq *irqs;
49};
50
51struct ISADevice {
52
53 DeviceState parent_obj;
54
55
56 uint32_t isairq[2];
57 int nirqs;
58 int ioport_id;
59};
60
61ISABus *isa_bus_new(DeviceState *dev, MemoryRegion *address_space,
62 MemoryRegion *address_space_io);
63void isa_bus_irqs(ISABus *bus, qemu_irq *irqs);
64qemu_irq isa_get_irq(ISADevice *dev, int isairq);
65void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
66MemoryRegion *isa_address_space(ISADevice *dev);
67MemoryRegion *isa_address_space_io(ISADevice *dev);
68ISADevice *isa_create(ISABus *bus, const char *name);
69ISADevice *isa_try_create(ISABus *bus, const char *name);
70ISADevice *isa_create_simple(ISABus *bus, const char *name);
71
72ISADevice *isa_vga_init(ISABus *bus);
73
74
75
76
77
78
79
80
81
82
83
84void isa_register_ioport(ISADevice *dev, MemoryRegion *io, uint16_t start);
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100void isa_register_portio_list(ISADevice *dev, uint16_t start,
101 const MemoryRegionPortio *portio,
102 void *opaque, const char *name);
103
104static inline ISABus *isa_bus_from_device(ISADevice *d)
105{
106 return ISA_BUS(qdev_get_parent_bus(DEVICE(d)));
107}
108
109
110int DMA_get_channel_mode (int nchan);
111int DMA_read_memory (int nchan, void *buf, int pos, int size);
112int DMA_write_memory (int nchan, void *buf, int pos, int size);
113void DMA_hold_DREQ (int nchan);
114void DMA_release_DREQ (int nchan);
115void DMA_schedule(int nchan);
116void DMA_init(int high_page_enable, qemu_irq *cpu_request_exit);
117void DMA_register_channel (int nchan,
118 DMA_transfer_handler transfer_handler,
119 void *opaque);
120#endif
121