NUBUS_SLOT_NB);
}
+static bool nubus_check_address(BusState *bus, DeviceState *dev, Error **errp)
+{
+ NubusDevice *nd = NUBUS_DEVICE(dev);
+ NubusBus *nubus = NUBUS_BUS(bus);
+
+ if (nd->slot == -1) {
+ /* No slot specified, find first available free slot */
+ int s = ctz32(nubus->slot_available_mask);
+ if (s != 32) {
+ nd->slot = s;
+ } else {
+ error_setg(errp, "Cannot register nubus card, no free slot "
+ "available");
+ return false;
+ }
+ } else {
+ /* Slot specified, make sure the slot is available */
+ if (!(nubus->slot_available_mask & BIT(nd->slot))) {
+ error_setg(errp, "Cannot register nubus card, slot %d is "
+ "unavailable or already occupied", nd->slot);
+ return false;
+ }
+ }
+
+ nubus->slot_available_mask &= ~BIT(nd->slot);
+ return true;
+}
+
static void nubus_class_init(ObjectClass *oc, void *data)
{
BusClass *bc = BUS_CLASS(oc);
bc->realize = nubus_realize;
+ bc->check_address = nubus_check_address;
}
static const TypeInfo nubus_bus_info = {