qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Re: [Qemu-commits] [COMMIT ee6847d] qdev: rework devic


From: Blue Swirl
Subject: Re: [Qemu-devel] Re: [Qemu-commits] [COMMIT ee6847d] qdev: rework device properties.
Date: Fri, 17 Jul 2009 13:13:09 +0300

On Fri, Jul 17, 2009 at 1:05 PM, Filip Navara<address@hidden> wrote:
> On Fri, Jul 17, 2009 at 11:39 AM, Blue Swirl<address@hidden> wrote:
>> On Fri, Jul 17, 2009 at 2:12 AM, Anthony Liguori<address@hidden> wrote:
>>> From: Gerd Hoffmann <address@hidden>
>>>
>>> This patch is a major overhaul of the device properties.  The properties
>>> are saved directly in the device state struct now, the linked list of
>>> property values is gone.
>>
>>>     .qdev.name  = "fdc",
>>>     .qdev.size  = sizeof(fdctrl_t),
>>> -    .qdev.props = (DevicePropList[]) {
>>> -        {.name = "io_base", .type = PROP_TYPE_INT},
>>> -        {.name = "strict_io", .type = PROP_TYPE_INT},
>>> -        {.name = "mem_mapped", .type = PROP_TYPE_INT},
>>> -        {.name = "sun4m", .type = PROP_TYPE_INT},
>>> -        {.name = NULL}
>>> +    .qdev.props = (Property[]) {
>>> +        {
>>> +            .name = "io_base",
>>> +            .info = &qdev_prop_uint32,
>>> +            .offset = offsetof(fdctrl_t, io_base),
>>> +        },
>>
>> This is broken, on SS-600MP, SS-10 and SS-20 fdc is located above 4G.
>> The correct type is target_phys_addr_t. I'll fix this.
>>
>>> +typedef struct RamDevice
>>> +{
>>> +    SysBusDevice busdev;
>>> +    uint32_t size;
>>> +} RamDevice;
>>> +
>>>  /* System RAM */
>>>  static void ram_init1(SysBusDevice *dev)
>>>  {
>>>     ram_addr_t RAM_size, ram_offset;
>>> +    RamDevice *d = FROM_SYSBUS(RamDevice, dev);
>>>
>>> -    RAM_size = qdev_get_prop_int(&dev->qdev, "size", 0);
>>> +    RAM_size = d->size;
>>>
>>>     ram_offset = qemu_ram_alloc(RAM_size);
>>>     sysbus_init_mmio(dev, RAM_size, ram_offset);
>>> @@ -496,6 +499,7 @@ static void ram_init(target_phys_addr_t addr, 
>>> ram_addr_t RAM_size,
>>>  {
>>>     DeviceState *dev;
>>>     SysBusDevice *s;
>>> +    RamDevice *d;
>>>
>>>     /* allocate RAM */
>>>     if ((uint64_t)RAM_size > max_mem) {
>>> @@ -506,20 +510,26 @@ static void ram_init(target_phys_addr_t addr, 
>>> ram_addr_t RAM_size,
>>>         exit(1);
>>>     }
>>>     dev = qdev_create(NULL, "memory");
>>> -    qdev_set_prop_int(dev, "size", RAM_size);
>>>     qdev_init(dev);
>>>     s = sysbus_from_qdev(dev);
>>>
>>> +    d = FROM_SYSBUS(RamDevice, s);
>>> +    d->size = RAM_size;
>>> +
>>>     sysbus_mmio_map(s, 0, addr);
>>>  }
>>
>> This is completely hosed because of the wrong order of setting
>> d->size. Now qemu_ram_alloc gets passed a zero.
>
> Move the qdev_init(dev); call after the setting of d->size.

Thanks, this fixes the zero memory size.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]