From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MRkRY-0000y3-BT for qemu-devel@nongnu.org; Fri, 17 Jul 2009 06:13:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MRkRW-0000wz-LT for qemu-devel@nongnu.org; Fri, 17 Jul 2009 06:13:31 -0400 Received: from [199.232.76.173] (port=47558 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MRkRW-0000wo-E1 for qemu-devel@nongnu.org; Fri, 17 Jul 2009 06:13:30 -0400 Received: from fg-out-1718.google.com ([72.14.220.154]:31987) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MRkRV-0005Ki-Vq for qemu-devel@nongnu.org; Fri, 17 Jul 2009 06:13:30 -0400 Received: by fg-out-1718.google.com with SMTP id l27so124909fgb.8 for ; Fri, 17 Jul 2009 03:13:29 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <5b31733c0907170305l50f5f7ecteadf3d4a057e8f95@mail.gmail.com> References: <200907162312.n6GNCidA022228@d01av03.pok.ibm.com> <5b31733c0907170305l50f5f7ecteadf3d4a057e8f95@mail.gmail.com> From: Blue Swirl Date: Fri, 17 Jul 2009 13:13:09 +0300 Message-ID: Subject: Re: [Qemu-devel] Re: [Qemu-commits] [COMMIT ee6847d] qdev: rework device properties. Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Filip Navara Cc: Anthony Liguori , Gerd Hoffmann , qemu-devel On Fri, Jul 17, 2009 at 1:05 PM, Filip Navara wrote= : > On Fri, Jul 17, 2009 at 11:39 AM, Blue Swirl wrote: >> On Fri, Jul 17, 2009 at 2:12 AM, Anthony Liguori wr= ote: >>> From: Gerd Hoffmann >>> >>> This patch is a major overhaul of the device properties. =C2=A0The prop= erties >>> are saved directly in the device state struct now, the linked list of >>> property values is gone. >> >>> =C2=A0 =C2=A0 .qdev.name =C2=A0=3D "fdc", >>> =C2=A0 =C2=A0 .qdev.size =C2=A0=3D sizeof(fdctrl_t), >>> - =C2=A0 =C2=A0.qdev.props =3D (DevicePropList[]) { >>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0{.name =3D "io_base", .type =3D PROP_TYPE_= INT}, >>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0{.name =3D "strict_io", .type =3D PROP_TYP= E_INT}, >>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0{.name =3D "mem_mapped", .type =3D PROP_TY= PE_INT}, >>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0{.name =3D "sun4m", .type =3D PROP_TYPE_IN= T}, >>> - =C2=A0 =C2=A0 =C2=A0 =C2=A0{.name =3D NULL} >>> + =C2=A0 =C2=A0.qdev.props =3D (Property[]) { >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0{ >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0.name =3D "io_base", >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0.info =3D &qdev_prop_uint32, >>> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0.offset =3D offsetof(fdctrl_= t, io_base), >>> + =C2=A0 =C2=A0 =C2=A0 =C2=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 >>> +{ >>> + =C2=A0 =C2=A0SysBusDevice busdev; >>> + =C2=A0 =C2=A0uint32_t size; >>> +} RamDevice; >>> + >>> =C2=A0/* System RAM */ >>> =C2=A0static void ram_init1(SysBusDevice *dev) >>> =C2=A0{ >>> =C2=A0 =C2=A0 ram_addr_t RAM_size, ram_offset; >>> + =C2=A0 =C2=A0RamDevice *d =3D FROM_SYSBUS(RamDevice, dev); >>> >>> - =C2=A0 =C2=A0RAM_size =3D qdev_get_prop_int(&dev->qdev, "size", 0); >>> + =C2=A0 =C2=A0RAM_size =3D d->size; >>> >>> =C2=A0 =C2=A0 ram_offset =3D qemu_ram_alloc(RAM_size); >>> =C2=A0 =C2=A0 sysbus_init_mmio(dev, RAM_size, ram_offset); >>> @@ -496,6 +499,7 @@ static void ram_init(target_phys_addr_t addr, ram_a= ddr_t RAM_size, >>> =C2=A0{ >>> =C2=A0 =C2=A0 DeviceState *dev; >>> =C2=A0 =C2=A0 SysBusDevice *s; >>> + =C2=A0 =C2=A0RamDevice *d; >>> >>> =C2=A0 =C2=A0 /* allocate RAM */ >>> =C2=A0 =C2=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, >>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 exit(1); >>> =C2=A0 =C2=A0 } >>> =C2=A0 =C2=A0 dev =3D qdev_create(NULL, "memory"); >>> - =C2=A0 =C2=A0qdev_set_prop_int(dev, "size", RAM_size); >>> =C2=A0 =C2=A0 qdev_init(dev); >>> =C2=A0 =C2=A0 s =3D sysbus_from_qdev(dev); >>> >>> + =C2=A0 =C2=A0d =3D FROM_SYSBUS(RamDevice, s); >>> + =C2=A0 =C2=A0d->size =3D RAM_size; >>> + >>> =C2=A0 =C2=A0 sysbus_mmio_map(s, 0, addr); >>> =C2=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. Thanks, this fixes the zero memory size.