From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MRkK1-0006eF-VT for qemu-devel@nongnu.org; Fri, 17 Jul 2009 06:05:46 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MRkJx-0006cO-Bi for qemu-devel@nongnu.org; Fri, 17 Jul 2009 06:05:45 -0400 Received: from [199.232.76.173] (port=50974 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MRkJx-0006cI-3v for qemu-devel@nongnu.org; Fri, 17 Jul 2009 06:05:41 -0400 Received: from mail-ew0-f217.google.com ([209.85.219.217]:64218) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MRkJw-0003iR-J1 for qemu-devel@nongnu.org; Fri, 17 Jul 2009 06:05:40 -0400 Received: by ewy17 with SMTP id 17so528534ewy.34 for ; Fri, 17 Jul 2009 03:05:39 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <200907162312.n6GNCidA022228@d01av03.pok.ibm.com> Date: Fri, 17 Jul 2009 12:05:39 +0200 Message-ID: <5b31733c0907170305l50f5f7ecteadf3d4a057e8f95@mail.gmail.com> Subject: Re: [Qemu-devel] Re: [Qemu-commits] [COMMIT ee6847d] qdev: rework device properties. From: Filip Navara Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: Anthony Liguori , Gerd Hoffmann , qemu-devel On Fri, Jul 17, 2009 at 11:39 AM, Blue Swirl wrote: > On Fri, Jul 17, 2009 at 2:12 AM, Anthony Liguori wro= te: >> From: Gerd Hoffmann >> >> This patch is a major overhaul of the device properties. =A0The properti= es >> are saved directly in the device state struct now, the linked list of >> property values is gone. > >> =A0 =A0 .qdev.name =A0=3D "fdc", >> =A0 =A0 .qdev.size =A0=3D sizeof(fdctrl_t), >> - =A0 =A0.qdev.props =3D (DevicePropList[]) { >> - =A0 =A0 =A0 =A0{.name =3D "io_base", .type =3D PROP_TYPE_INT}, >> - =A0 =A0 =A0 =A0{.name =3D "strict_io", .type =3D PROP_TYPE_INT}, >> - =A0 =A0 =A0 =A0{.name =3D "mem_mapped", .type =3D PROP_TYPE_INT}, >> - =A0 =A0 =A0 =A0{.name =3D "sun4m", .type =3D PROP_TYPE_INT}, >> - =A0 =A0 =A0 =A0{.name =3D NULL} >> + =A0 =A0.qdev.props =3D (Property[]) { >> + =A0 =A0 =A0 =A0{ >> + =A0 =A0 =A0 =A0 =A0 =A0.name =3D "io_base", >> + =A0 =A0 =A0 =A0 =A0 =A0.info =3D &qdev_prop_uint32, >> + =A0 =A0 =A0 =A0 =A0 =A0.offset =3D offsetof(fdctrl_t, io_base), >> + =A0 =A0 =A0 =A0}, > > 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 >> +{ >> + =A0 =A0SysBusDevice busdev; >> + =A0 =A0uint32_t size; >> +} RamDevice; >> + >> =A0/* System RAM */ >> =A0static void ram_init1(SysBusDevice *dev) >> =A0{ >> =A0 =A0 ram_addr_t RAM_size, ram_offset; >> + =A0 =A0RamDevice *d =3D FROM_SYSBUS(RamDevice, dev); >> >> - =A0 =A0RAM_size =3D qdev_get_prop_int(&dev->qdev, "size", 0); >> + =A0 =A0RAM_size =3D d->size; >> >> =A0 =A0 ram_offset =3D qemu_ram_alloc(RAM_size); >> =A0 =A0 sysbus_init_mmio(dev, RAM_size, ram_offset); >> @@ -496,6 +499,7 @@ static void ram_init(target_phys_addr_t addr, ram_ad= dr_t RAM_size, >> =A0{ >> =A0 =A0 DeviceState *dev; >> =A0 =A0 SysBusDevice *s; >> + =A0 =A0RamDevice *d; >> >> =A0 =A0 /* allocate RAM */ >> =A0 =A0 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, >> =A0 =A0 =A0 =A0 exit(1); >> =A0 =A0 } >> =A0 =A0 dev =3D qdev_create(NULL, "memory"); >> - =A0 =A0qdev_set_prop_int(dev, "size", RAM_size); >> =A0 =A0 qdev_init(dev); >> =A0 =A0 s =3D sysbus_from_qdev(dev); >> >> + =A0 =A0d =3D FROM_SYSBUS(RamDevice, s); >> + =A0 =A0d->size =3D RAM_size; >> + >> =A0 =A0 sysbus_mmio_map(s, 0, addr); >> =A0} > > 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. F.