Hello, experts and users,

 

I thought I need to understand the basic qemu object model.

This is from the ethernet controller hw/net/smc91c111.c  (version 5.1.0).

void smc91c111_init(NICInfo *nd, uint32_t base, qemu_irq irq)

{

    DeviceState *dev;

    SysBusDevice *s;

 

    qemu_check_nic_model(nd, "smc91c111");

    dev = qdev_new(TYPE_SMC91C111);

    qdev_set_nic_properties(dev, nd);

    s = SYS_BUS_DEVICE(dev); 

    sysbus_realize_and_unref(s, &error_fatal);

    sysbus_mmio_map(s, 0, base);

    sysbus_connect_irq(s, 0, irq);

}

The sysbus_mmio_map function checks if the given mmio range number (here 0)
is between 0 and num_mmios of the SyBusDevice.

But when is the num_mmios value inside the struct SysBusDevice determined? I
couldn't follow it up.

And SysBusDevice includes DeviceState, then does the s = SYS_BUS_DEVICE(dev)
statement allocates the SysBusDevice on memory?

Any comment will be deeply appreciated.

Thanks!

 

Chan Kim

 

Reply via email to