Received: from eggs.gnu.org ([2001:4830:134:3::10]:53754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF83O-0000vY-Ee for qemu-devel@nongnu.org; Thu, 29 Aug 2013 15:38:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VF83K-00078a-8J for qemu-devel@nongnu.org; Thu, 29 Aug 2013 15:38:50 -0400 Received: from mail-la0-x235.google.com ([2a00:1450:4010:c03::235]:49192) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VF83J-00078N-Qi for qemu-devel@nongnu.org; Thu, 29 Aug 2013 15:38:46 -0400 Received: by mail-la0-f53.google.com with SMTP id el20so753530lab.26 for ; Thu, 29 Aug 2013 12:38:44 -0700 (PDT) Date: Thu, 29 Aug 2013 23:36:23 +0400 From: Antony Pavlov Message-Id: <20130829233623.b05e3fe616e160dff7fa5a50@gmail.com> In-Reply-To: <521F3B6C.6040207@suse.de> References: <1377768833-11400-1-git-send-email-antonynpavlov@gmail.com> <1377768833-11400-3-git-send-email-antonynpavlov@gmail.com> <521F3B6C.6040207@suse.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC 2/5] hw/arm: add very initial support for Canon DIGIC SoC List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Andreas =?ISO-8859-1?Q?F=E4rber?= Cc: Alex Dumitrache , Peter Crosthwaite , Giovanni Condello , g3gg0 , Peter Maydell , qemu-devel@nongnu.org, Paul Brook , Paolo Bonzini On Thu, 29 Aug 2013 14:15:40 +0200 Andreas F=E4rber wrote: > Am 29.08.2013 11:33, schrieb Antony Pavlov: > > DIGIC is Canon Inc.'s name for a family of SoC > > for digital cameras and camcorders. > >=20 > > There is no publicly available specification for > > DIGIC chips. All information about DIGIC chip > > internals is based on reverse engineering efforts > > made by CHDK (http://chdk.wikia.com) and > > Magic Lantern (http://www.magiclantern.fm) projects > > contributors. > >=20 > > Also this patch adds initial support for Canon > > PowerShot A1100 IS compact camera. > >=20 > > Signed-off-by: Antony Pavlov > > --- > > default-configs/arm-softmmu.mak | 1 + > > hw/arm/Makefile.objs | 2 +- > > hw/arm/digic.c | 85 +++++++++++++++++++++++++++++++++= ++++++++ > > 3 files changed, 87 insertions(+), 1 deletion(-) > > create mode 100644 hw/arm/digic.c > >=20 > > diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-soft= mmu.mak > > index ac0815d..0d1d783 100644 > > --- a/default-configs/arm-softmmu.mak > > +++ b/default-configs/arm-softmmu.mak > > @@ -63,6 +63,7 @@ CONFIG_FRAMEBUFFER=3Dy > > CONFIG_XILINX_SPIPS=3Dy > > =20 > > CONFIG_A9SCU=3Dy > > +CONFIG_DIGIC=3Dy > > CONFIG_MARVELL_88W8618=3Dy > > CONFIG_OMAP=3Dy > > CONFIG_TSC210X=3Dy > > diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs > > index 3671b42..53d5ffd 100644 > > --- a/hw/arm/Makefile.objs > > +++ b/hw/arm/Makefile.objs > > @@ -1,4 +1,4 @@ > > -obj-y +=3D boot.o collie.o exynos4_boards.o gumstix.o highbank.o > > +obj-y +=3D boot.o collie.o digic.o exynos4_boards.o gumstix.o highbank= .o > > obj-y +=3D integratorcp.o kzm.o mainstone.o musicpal.o nseries.o > > obj-y +=3D omap_sx1.o palm.o realview.o spitz.o stellaris.o > > obj-y +=3D tosa.o versatilepb.o vexpress.o xilinx_zynq.o z2.o > > diff --git a/hw/arm/digic.c b/hw/arm/digic.c > > new file mode 100644 > > index 0000000..3259b38 > > --- /dev/null > > +++ b/hw/arm/digic.c > > @@ -0,0 +1,85 @@ > > +/* > > + * QEMU model of the Canon SoC. > > + * > > + * Copyright (C) 2013 Antony Pavlov > > + * > > + * This model is based on reverse engineering efforts > > + * made by CHDK (http://chdk.wikia.com) and > > + * Magic Lantern (http://www.magiclantern.fm) projects > > + * contributors. > > + * > > + * This library is free software; you can redistribute it and/or > > + * modify it under the terms of the GNU Lesser General Public > > + * License as published by the Free Software Foundation; either > > + * version 2 of the License, or (at your option) any later version. > > + * > > + * This library is distributed in the hope that it will be useful, > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > > + * Lesser General Public License for more details. > > + * > > + * You should have received a copy of the GNU Lesser General Public > > + * License along with this library; if not, see . > > + * > > + */ > > + > > +#include "exec/address-spaces.h" > > +#include "hw/sysbus.h" > > +#include "hw/boards.h" > > + > > +typedef struct { >=20 > structs should not be anonymous, just reuse the typedef name. >=20 > > + ARMCPU *cpu; > > + MemoryRegion ram; > > +} DigicState; > > + > > +typedef struct { > > + hwaddr ram_size; > > +} DigicBoard; > > + > > +static DigicState *digic4_create(void) > > +{ > > + DigicState *s =3D g_new(DigicState, 1); > > + > > + s->cpu =3D cpu_arm_init("arm946e-s"); > > + if (!s->cpu) { > > + fprintf(stderr, "Unable to find CPU definition\n"); > > + exit(1); > > + } > > + > > + return s; > > +} >=20 > Please separate the SoC from the boards by placing them in different > files (and commits). I'm agree. > DigicState should be a QOM type derived from TYPE_DEVICE. Since you're > hardcoding the CPU type, please use object_initialize() to create it > in-place - note we're about to extend that function but rebase will be > trivial. I have just examinied platforms with hardcoded cpu: pxa2xx, exynos4210. They don't use object_initialize(). Is there any significant difference between hardcoded cpu type and variable cpu type with selected default cpu type? I try to find a example of object_initialize() usage for cpu initialisation in repo but I have no success. Can you point me one or explain your design pattern? =20 > > + > > +static void digic4_setup_ram(DigicState *s, hwaddr ram_size) > > +{ > > + memory_region_init_ram(&s->ram, NULL, "ram", ram_size); > > + memory_region_add_subregion(get_system_memory(), 0, &s->ram); > > + vmstate_register_ram_global(&s->ram); > > +} >=20 > Is the RAM on the board or on the SoC? It's in DigicState but > initialized from the board init. If it's on the SoC, then > _add_subregion and _register_ram_global should be in its realizefn. > Otherwise please separate it from the SoC state. It's not a trivial question! See "Digging Into 'DIGIC 4' Image Processor (2)" (http://techon.nikkeibp.co= .jp/english/NEWS_EN/20090218/165866/). The authors removed the upper package with a chemical solution and exposed = the chips. The 'DIGIC 4' contains 3 chips in one package: * processor itself; * 64-Mbit NOR flash memory, the "K8P6415UQB" (note that I have found anoth= er flash K8P3215UQB on my Canon A1100: Manufacturer ID: 0xEC, Device ID: 0x= 7E0301); * 512-Mbit SDRAM, the "K4X51323PE" (just the same 64 M RAM as I see with b= arebox). So we can assume taht these memory chips are inalienable parts of the SoC. But the DSLR cameras has much more memory, they need much memory for serial= shooting. E.g. even rather 8-years old DIGIC2-based Canon 20D has 1 GB (!) of RAM. Another example: DIGIC4-based Canon 600D camera has 32 M of ROM. You can see that all this DSLR extra RAM and ROM can't be located inside DI= GIC4 package! It is necessery to carry out addition tests. > > + > > +static void init_digic4_board(DigicBoard *board) >=20 > digic4_init_board to have a common prefix? >=20 > > +{ > > + DigicState *s =3D digic4_create(); > > + > > + digic4_setup_ram(s, board->ram_size); > > +} > > + > > +static DigicBoard a1100_board =3D { >=20 > canon_a110_board? Please use consistent identifiers either with or > without canon_. >=20 > > + .ram_size =3D 64 * 1024 * 1024, > > +}; > > + > > +static void init_a1100(QEMUMachineInitArgs *args) >=20 > canon_a1100_init? >=20 > > +{ > > + init_digic4_board(&a1100_board); > > +} > > + > > +static QEMUMachine canon_a1100 =3D { > > + .name =3D "canon-a1100", > > + .desc =3D "Canon PowerShot A1100 IS", > > + .init =3D &init_a1100, > > +}; > > + > > +static void digic_machine_init(void) >=20 > Better name this digic_register_machines to avoid confusion with machine > init above. >=20 > > +{ > > + qemu_register_machine(&canon_a1100); > > +} > > +machine_init(digic_machine_init); >=20 > No semicolon after machine_init() please, and please add a white-line > before. Already fixed! --=A0 Best regards, =A0 Antony Pavlov