From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=47080 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PpMQA-0003TF-Rh for qemu-devel@nongnu.org; Tue, 15 Feb 2011 10:02:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PpMQ9-0007SN-J3 for qemu-devel@nongnu.org; Tue, 15 Feb 2011 10:02:30 -0500 Received: from mail-wy0-f173.google.com ([74.125.82.173]:58176) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PpMQ9-0007Rq-Ac for qemu-devel@nongnu.org; Tue, 15 Feb 2011 10:02:29 -0500 Received: by wyg36 with SMTP id 36so257425wyg.4 for ; Tue, 15 Feb 2011 07:02:27 -0800 (PST) MIME-Version: 1.0 Sender: vincent@palatin.fr In-Reply-To: <20110215143017.GF19666@os.inf.tu-dresden.de> References: <20110215104852.GB19666@os.inf.tu-dresden.de> <20110215131245.GE19666@os.inf.tu-dresden.de> <20110215143017.GF19666@os.inf.tu-dresden.de> From: Vincent Palatin Date: Tue, 15 Feb 2011 10:02:05 -0500 Message-ID: Subject: Re: [Qemu-devel] [PATCH 1/3] target-arm: Setup smpboot code in all setups 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: Adam Lackorzynski Cc: Peter Maydell , qemu-devel@nongnu.org Hi Adam, >> Moving in the right direction, but it would be cleaner if the secondary >> CPU reset was handled inside arm_boot.c, I think (there is a TODO >> in that file to that effect). Then we could get rid of the cpu reset >> hook from realview.c. > > Like the following? This assumes that all the ARM SMP platforms are booting their secondary CPU the same way as the emulated Realview. For example, I'm currently writing a Tegra2 (dual A9) SoC emulation and the second CPU is halted when the platform starts and I cannot re-use the current smpboot firmware chunk. My current workaround is to use "info->nb_cpus =3D 1" and do the init in the board code. Forcing the reset function will probably not help. > =A0Subject: [PATCH] target-arm: Integrate secondary CPU reset in arm_boot > > Integrate secondary CPU reset into arm_boot, removing it from realview.c. > On non-Linux systems secondary CPUs start with the same entry as the boot > CPU. > > Signed-off-by: Adam Lackorzynski > --- > =A0hw/arm_boot.c | =A0 23 +++++++++++++++-------- > =A0hw/realview.c | =A0 14 -------------- > =A02 files changed, 15 insertions(+), 22 deletions(-) > > diff --git a/hw/arm_boot.c b/hw/arm_boot.c > index 620550b..41e99d1 100644 > --- a/hw/arm_boot.c > +++ b/hw/arm_boot.c > @@ -175,7 +175,7 @@ static void set_kernel_args_old(struct arm_boot_info = *info, > =A0 =A0 } > =A0} > > -static void main_cpu_reset(void *opaque) > +static void do_cpu_reset(void *opaque) > =A0{ > =A0 =A0 CPUState *env =3D opaque; > =A0 =A0 struct arm_boot_info *info =3D env->boot_info; > @@ -187,16 +187,20 @@ static void main_cpu_reset(void *opaque) > =A0 =A0 =A0 =A0 =A0 =A0 env->regs[15] =3D info->entry & 0xfffffffe; > =A0 =A0 =A0 =A0 =A0 =A0 env->thumb =3D info->entry & 1; > =A0 =A0 =A0 =A0 } else { > - =A0 =A0 =A0 =A0 =A0 =A0env->regs[15] =3D info->loader_start; > - =A0 =A0 =A0 =A0 =A0 =A0if (old_param) { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0set_kernel_args_old(info, info->initrd_s= ize, > + =A0 =A0 =A0 =A0 =A0 =A0if (env =3D=3D first_cpu) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0env->regs[15] =3D info->loader_start; > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if (old_param) { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0set_kernel_args_old(info, info->= initrd_size, > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0info->loader_start); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} else { > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0set_kernel_args(info, info->init= rd_size, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 i= nfo->loader_start); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0 =A0 =A0 } else { > - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0set_kernel_args(info, info->initrd_size,= info->loader_start); > + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0env->regs[15] =3D info->smp_loader_start= ; > =A0 =A0 =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 } > =A0 =A0 } > - =A0 =A0/* TODO: =A0Reset secondary CPUs. =A0*/ > =A0} > > =A0void arm_load_kernel(CPUState *env, struct arm_boot_info *info) > @@ -217,7 +221,6 @@ void arm_load_kernel(CPUState *env, struct arm_boot_i= nfo *info) > > =A0 =A0 if (info->nb_cpus =3D=3D 0) > =A0 =A0 =A0 =A0 info->nb_cpus =3D 1; > - =A0 =A0env->boot_info =3D info; > > =A0#ifdef TARGET_WORDS_BIGENDIAN > =A0 =A0 big_endian =3D 1; > @@ -279,5 +282,9 @@ void arm_load_kernel(CPUState *env, struct arm_boot_i= nfo *info) > =A0 =A0 =A0 =A0 info->initrd_size =3D initrd_size; > =A0 =A0 } > =A0 =A0 info->is_linux =3D is_linux; > - =A0 =A0qemu_register_reset(main_cpu_reset, env); > + > + =A0 =A0for (; env; env =3D env->next_cpu) { > + =A0 =A0 =A0 =A0env->boot_info =3D info; > + =A0 =A0 =A0 =A0qemu_register_reset(do_cpu_reset, env); > + =A0 =A0} > =A0} > diff --git a/hw/realview.c b/hw/realview.c > index 6eb6c6a..fae444a 100644 > --- a/hw/realview.c > +++ b/hw/realview.c > @@ -104,17 +104,6 @@ static struct arm_boot_info realview_binfo =3D { > =A0 =A0 .smp_loader_start =3D SMP_BOOT_ADDR, > =A0}; > > -static void secondary_cpu_reset(void *opaque) > -{ > - =A0CPUState *env =3D opaque; > - > - =A0cpu_reset(env); > - =A0/* Set entry point for secondary CPUs. =A0This assumes we're using > - =A0 =A0 the init code from arm_boot.c. =A0Real hardware resets all CPUs > - =A0 =A0 the same. =A0*/ > - =A0env->regs[15] =3D SMP_BOOT_ADDR; > -} > - > =A0/* The following two lists must be consistent. =A0*/ > =A0enum realview_board_type { > =A0 =A0 BOARD_EB, > @@ -176,9 +165,6 @@ static void realview_init(ram_addr_t ram_size, > =A0 =A0 =A0 =A0 } > =A0 =A0 =A0 =A0 irqp =3D arm_pic_init_cpu(env); > =A0 =A0 =A0 =A0 cpu_irq[n] =3D irqp[ARM_PIC_CPU_IRQ]; > - =A0 =A0 =A0 =A0if (n > 0) { > - =A0 =A0 =A0 =A0 =A0 =A0qemu_register_reset(secondary_cpu_reset, env); > - =A0 =A0 =A0 =A0} > =A0 =A0 } > =A0 =A0 if (arm_feature(env, ARM_FEATURE_V7)) { > =A0 =A0 =A0 =A0 if (is_mpcore) { > -- > 1.7.2.3 --=20 Vincent