Revision 2091ba23 hw/isa-bus.c

b/hw/isa-bus.c
18 18
 */
19 19
#include "hw.h"
20 20
#include "sysemu.h"
21
#include "monitor.h"
22
#include "sysbus.h"
21 23
#include "isa.h"
22 24

  
23 25
struct ISABus {
24 26
    BusState qbus;
27
    qemu_irq *irqs;
28
    uint32_t assigned;
25 29
};
26 30
static ISABus *isabus;
27 31

  
32
static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent);
33

  
28 34
static struct BusInfo isa_bus_info = {
29
    .name  = "ISA",
30
    .size  = sizeof(ISABus),
31
    .props = (Property[]) {
35
    .name      = "ISA",
36
    .size      = sizeof(ISABus),
37
    .print_dev = isabus_dev_print,
38
    .props     = (Property[]) {
32 39
        DEFINE_PROP_HEX32("iobase",  ISADevice, iobase[0], -1),
33 40
        DEFINE_PROP_HEX32("iobase2", ISADevice, iobase[1], -1),
34 41
        DEFINE_PROP_END_OF_LIST(),
......
41 48
        fprintf(stderr, "Can't create a second ISA bus\n");
42 49
        return NULL;
43 50
    }
51
    if (NULL == dev) {
52
        dev = qdev_create(NULL, "isabus-bridge");
53
        qdev_init(dev);
54
    }
44 55

  
45 56
    isabus = FROM_QBUS(ISABus, qbus_create(&isa_bus_info, dev, NULL));
46 57
    return isabus;
47 58
}
48 59

  
49
void isa_connect_irq(ISADevice *dev, int n, qemu_irq irq)
60
void isa_bus_irqs(qemu_irq *irqs)
50 61
{
51
    assert(n >= 0 && n < dev->nirqs);
52
    if (dev->irqs[n])
53
        *dev->irqs[n] = irq;
62
    isabus->irqs = irqs;
63
}
64

  
65
void isa_connect_irq(ISADevice *dev, int devnr, int isairq)
66
{
67
    assert(devnr >= 0 && devnr < dev->nirqs);
68
    if (isabus->assigned & (1 << isairq)) {
69
        fprintf(stderr, "isa irq %d already assigned\n", isairq);
70
        exit(1);
71
    }
72
    if (dev->irqs[devnr]) {
73
        isabus->assigned |= (1 << isairq);
74
        dev->isairq[devnr] = isairq;
75
        *dev->irqs[devnr] = isabus->irqs[isairq];
76
    }
54 77
}
55 78

  
56 79
void isa_init_irq(ISADevice *dev, qemu_irq *p)
......
65 88
    ISADevice *dev = DO_UPCAST(ISADevice, qdev, qdev);
66 89
    ISADeviceInfo *info = DO_UPCAST(ISADeviceInfo, qdev, base);
67 90

  
91
    dev->isairq[0] = -1;
92
    dev->isairq[1] = -1;
68 93
    info->init(dev);
69 94
}
70 95

  
......
91 116
    qdev_init(dev);
92 117
    return isa;
93 118
}
119

  
120
static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent)
121
{
122
    ISADevice *d = DO_UPCAST(ISADevice, qdev, dev);
123

  
124
    if (d->isairq[1] != -1) {
125
        monitor_printf(mon, "%*sisa irqs %d,%d\n", indent, "",
126
                       d->isairq[0], d->isairq[1]);
127
    } else if (d->isairq[0] != -1) {
128
        monitor_printf(mon, "%*sisa irq %d\n", indent, "",
129
                       d->isairq[0]);
130
    }
131
}
132

  
133
static void isabus_bridge_init(SysBusDevice *dev)
134
{
135
    /* nothing */
136
}
137

  
138
static SysBusDeviceInfo isabus_bridge_info = {
139
    .init = isabus_bridge_init,
140
    .qdev.name  = "isabus-bridge",
141
    .qdev.size  = sizeof(SysBusDevice),
142
};
143

  
144
static void isabus_register_devices(void)
145
{
146
    sysbus_register_withprop(&isabus_bridge_info);
147
}
148

  
149
device_init(isabus_register_devices)

Also available in: Unified diff