]>
git.proxmox.com Git - qemu.git/blob - hw/isa-bus.c
2 * isa bus support for qdev.
4 * Copyright (c) 2009 Gerd Hoffmann <kraxel@redhat.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
26 static ISABus
*isabus
;
28 static struct BusInfo isa_bus_info
= {
30 .size
= sizeof(ISABus
),
31 .props
= (Property
[]) {
32 DEFINE_PROP_HEX32("iobase", ISADevice
, iobase
[0], -1),
33 DEFINE_PROP_HEX32("iobase2", ISADevice
, iobase
[1], -1),
34 DEFINE_PROP_END_OF_LIST(),
38 ISABus
*isa_bus_new(DeviceState
*dev
)
41 fprintf(stderr
, "Can't create a second ISA bus\n");
45 isabus
= FROM_QBUS(ISABus
, qbus_create(&isa_bus_info
, dev
, NULL
));
49 void isa_connect_irq(ISADevice
*dev
, int n
, qemu_irq irq
)
51 assert(n
>= 0 && n
< dev
->nirqs
);
56 void isa_init_irq(ISADevice
*dev
, qemu_irq
*p
)
58 assert(dev
->nirqs
< ARRAY_SIZE(dev
->irqs
));
59 dev
->irqs
[dev
->nirqs
] = p
;
63 static void isa_qdev_init(DeviceState
*qdev
, DeviceInfo
*base
)
65 ISADevice
*dev
= DO_UPCAST(ISADevice
, qdev
, qdev
);
66 ISADeviceInfo
*info
= DO_UPCAST(ISADeviceInfo
, qdev
, base
);
71 void isa_qdev_register(ISADeviceInfo
*info
)
73 info
->qdev
.init
= isa_qdev_init
;
74 info
->qdev
.bus_info
= &isa_bus_info
;
75 qdev_register(&info
->qdev
);
78 ISADevice
*isa_create_simple(const char *name
, uint32_t iobase
, uint32_t iobase2
)
84 fprintf(stderr
, "Tried to create isa device %s with no isa bus present.\n", name
);
87 dev
= qdev_create(&isabus
->qbus
, name
);
88 isa
= DO_UPCAST(ISADevice
, qdev
, dev
);
89 isa
->iobase
[0] = iobase
;
90 isa
->iobase
[1] = iobase2
;