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
[]) {
34 .info
= &qdev_prop_hex32
,
35 .offset
= offsetof(ISADevice
, iobase
[0]),
36 .defval
= (uint32_t[]) { -1 },
39 .info
= &qdev_prop_hex32
,
40 .offset
= offsetof(ISADevice
, iobase
[1]),
41 .defval
= (uint32_t[]) { -1 },
47 ISABus
*isa_bus_new(DeviceState
*dev
)
50 fprintf(stderr
, "Can't create a second ISA bus\n");
54 isabus
= FROM_QBUS(ISABus
, qbus_create(&isa_bus_info
, dev
, NULL
));
58 void isa_connect_irq(ISADevice
*dev
, int n
, qemu_irq irq
)
60 assert(n
>= 0 && n
< dev
->nirqs
);
65 void isa_init_irq(ISADevice
*dev
, qemu_irq
*p
)
67 assert(dev
->nirqs
< ARRAY_SIZE(dev
->irqs
));
68 dev
->irqs
[dev
->nirqs
] = p
;
72 static void isa_qdev_init(DeviceState
*qdev
, DeviceInfo
*base
)
74 ISADevice
*dev
= DO_UPCAST(ISADevice
, qdev
, qdev
);
75 ISADeviceInfo
*info
= DO_UPCAST(ISADeviceInfo
, qdev
, base
);
80 void isa_qdev_register(ISADeviceInfo
*info
)
82 info
->qdev
.init
= isa_qdev_init
;
83 info
->qdev
.bus_info
= &isa_bus_info
;
84 qdev_register(&info
->qdev
);
87 ISADevice
*isa_create_simple(const char *name
, uint32_t iobase
, uint32_t iobase2
)
93 fprintf(stderr
, "Tried to create isa device %s with no isa bus present.\n", name
);
96 dev
= qdev_create(&isabus
->qbus
, name
);
97 isa
= DO_UPCAST(ISADevice
, qdev
, dev
);
98 isa
->iobase
[0] = iobase
;
99 isa
->iobase
[1] = iobase2
;