From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:43318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaQXL-00083u-9k for qemu-devel@nongnu.org; Tue, 13 Dec 2011 06:28:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RaQXG-0007J9-6C for qemu-devel@nongnu.org; Tue, 13 Dec 2011 06:28:43 -0500 Received: from mail-qy0-f173.google.com ([209.85.216.173]:53566) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RaQXG-0007It-0m for qemu-devel@nongnu.org; Tue, 13 Dec 2011 06:28:38 -0500 Received: by qcsd15 with SMTP id d15so5101536qcs.4 for ; Tue, 13 Dec 2011 03:28:37 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <1323672206-11891-8-git-send-email-e.voevodin@samsung.com> References: <1323672206-11891-1-git-send-email-e.voevodin@samsung.com> <1323672206-11891-8-git-send-email-e.voevodin@samsung.com> Date: Tue, 13 Dec 2011 11:28:36 +0000 Message-ID: From: Peter Maydell Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 07/14] hw/arm_boot.c: Add new secondary CPU bootloader. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Evgeny Voevodin Cc: m.kozlov@samsung.com, qemu-devel@nongnu.org, d.solodkiy@samsung.com On 12 December 2011 06:43, Evgeny Voevodin wrote: > Secondary CPU bootloader enables interrupt and issues wfi until start add= ress > is written to system controller. The position where to find this start > address is hardcoded to 0x10000030. This commit adds new bootloader for > secondary CPU which allows a target board to cpecify a position where > to find start address. If target board doesn't specify start address then > default 0x10000030 is used This commit message isn't quite right. We aren't adding a new bootloader, we're modifying the existing one. > > Signed-off-by: Evgeny Voevodin > --- > =C2=A0hw/arm-misc.h | =C2=A0 =C2=A01 + > =C2=A0hw/arm_boot.c | =C2=A0 22 +++++++++++++++------- > =C2=A02 files changed, 16 insertions(+), 7 deletions(-) > > diff --git a/hw/arm-misc.h b/hw/arm-misc.h > index af403a1..6e8ae6b 100644 > --- a/hw/arm-misc.h > +++ b/hw/arm-misc.h > @@ -31,6 +31,7 @@ struct arm_boot_info { > =C2=A0 =C2=A0 const char *initrd_filename; > =C2=A0 =C2=A0 target_phys_addr_t loader_start; > =C2=A0 =C2=A0 target_phys_addr_t smp_loader_start; > + =C2=A0 =C2=A0target_phys_addr_t smp_bootreg_addr; > =C2=A0 =C2=A0 target_phys_addr_t smp_priv_base; > =C2=A0 =C2=A0 int nb_cpus; > =C2=A0 =C2=A0 int board_id; > diff --git a/hw/arm_boot.c b/hw/arm_boot.c > index 215d5de..ecaac22 100644 > --- a/hw/arm_boot.c > +++ b/hw/arm_boot.c > @@ -31,17 +31,17 @@ static uint32_t bootloader[] =3D { > =C2=A0/* Entry point for secondary CPUs. =C2=A0Enable interrupt controlle= r and > =C2=A0 =C2=A0Issue WFI until start address is written to system controlle= r. =C2=A0*/ > =C2=A0static uint32_t smpboot[] =3D { > - =C2=A00xe59f0020, /* ldr =C2=A0 =C2=A0 r0, privbase */ > - =C2=A00xe3a01001, /* mov =C2=A0 =C2=A0 r1, #1 */ > - =C2=A00xe5801100, /* str =C2=A0 =C2=A0 r1, [r0, #0x100] */ > - =C2=A00xe3a00201, /* mov =C2=A0 =C2=A0 r0, #0x10000000 */ > - =C2=A00xe3800030, /* orr =C2=A0 =C2=A0 r0, #0x30 */ > + =C2=A00xe59f201c, /* ldr r2, privbase */ > + =C2=A00xe59f001c, /* ldr r0, startaddr */ > + =C2=A00xe3a01001, /* mov r1, #1 */ > + =C2=A00xe5821100, /* str r1, [r2, #256] */ > =C2=A0 0xe320f003, /* wfi */ > =C2=A0 0xe5901000, /* ldr =C2=A0 =C2=A0 r1, [r0] */ > =C2=A0 0xe1110001, /* tst =C2=A0 =C2=A0 r1, r1 */ > =C2=A0 0x0afffffb, /* beq =C2=A0 =C2=A0 */ > =C2=A0 0xe12fff11, /* bx =C2=A0 =C2=A0 =C2=A0r1 */ > - =C2=A00 /* privbase: Private memory region base address. =C2=A0*/ > + =C2=A00, =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0/* privbase: Private memory = region base address. =C2=A0*/ > + =C2=A00 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 /* bootreg: Boot register ad= dress is hold here */ "held" > =C2=A0}; > > =C2=A0#define WRITE_WORD(p, value) do { \ > @@ -179,6 +179,7 @@ static void do_cpu_reset(void *opaque) > =C2=A0{ > =C2=A0 =C2=A0 CPUState *env =3D opaque; > =C2=A0 =C2=A0 const struct arm_boot_info *info =3D env->boot_info; > + =C2=A0 =C2=A0uint8_t smp_bootreg_addr[4] =3D {0}; > > =C2=A0 =C2=A0 cpu_reset(env); > =C2=A0 =C2=A0 if (info) { > @@ -197,6 +198,8 @@ static void do_cpu_reset(void *opaque) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 info->loader_start); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 } > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 } else { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cpu_physical_mem= ory_rw(info->smp_bootreg_addr, smp_bootreg_addr, > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0sizeof(smp_bootreg_addr), 1); Any reason not to use WRITE_WORD() ? > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 env->regs[15] =3D= info->smp_loader_start; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 } > =C2=A0 =C2=A0 =C2=A0 =C2=A0 } > @@ -262,6 +265,7 @@ void arm_load_kernel(CPUState *env, struct arm_boot_i= nfo *info) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 } else { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 initrd_size =3D 0; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 } > + > =C2=A0 =C2=A0 =C2=A0 =C2=A0 bootloader[1] |=3D info->board_id & 0xff; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 bootloader[2] |=3D (info->board_id >> 8) & 0x= ff; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 bootloader[5] =3D info->loader_start + KERNEL= _ARGS_ADDR; Stray whitespace change, please remove from patch. > @@ -272,7 +276,11 @@ void arm_load_kernel(CPUState *env, struct arm_boot_= info *info) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 rom_add_blob_fixed("bootloader", bootloader, = sizeof(bootloader), > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0info->loader_start); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (info->nb_cpus > 1) { > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0smpboot[10] =3D info->smp_priv= _base; > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (!info->smp_bootreg_addr) { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0info->smp_bootre= g_addr =3D 0x10000030; > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0smpboot[(sizeof(smpboot) - 8)/= 4] =3D info->smp_priv_base; > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0smpboot[(sizeof(smpboot) - 4)/= 4] =3D info->smp_bootreg_addr; smpboot[ARRAY_SIZE(smpboot) - 1] =3D ... > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for (n =3D 0; n < sizeof(smpboo= t) / 4; n++) { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 smpboot[n] =3D ts= wap32(smpboot[n]); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 } > -- > 1.7.4.1 -- PMM