From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ACAB7C433F5 for ; Mon, 17 Jan 2022 16:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=671DzWklnIAeNTAz6nc7BqpAxxF8/JpZgmFwA2vDKEs=; b=xu5CW61s9HeE1T DHWKTN6PwhVfBPvl1zXkLb6Yow9uqCZx+qgPSR1Vs6ujOf74Wkh6li/zVKFXwSU435geO64M4HMmY 5miK7eLjx3myW4TuPXE+zpz/k9S5++R08urIAXSKJ2BzKMLkWpCjbQKjerYG4IUeHzGwz5m+yjDiD fHgRgCPmyylz/XfdRoi+g4pBakb8cmohennZ/wvHSWiCW8SPwfumWl3Q2DXdfzJBN/LzYxbsdCs4/ 1QSPLs+DOSNiNv8vF1mqUZicCwiGBMW/7HulnCCiY7aecyEsxNIdV5gI3hF2UypptozEAVVRQBJXQ 3BZrbWPhxMcHOEFzLGqw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9Umq-00FZuY-LF; Mon, 17 Jan 2022 16:23:16 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n9Umk-00FZtY-WF for linux-arm-kernel@lists.infradead.org; Mon, 17 Jan 2022 16:23:12 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 626BE6D; Mon, 17 Jan 2022 08:23:09 -0800 (PST) Received: from donnerap.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7A9CD3F766; Mon, 17 Jan 2022 08:23:08 -0800 (PST) Date: Mon, 17 Jan 2022 16:23:05 +0000 From: Andre Przywara To: Mark Rutland Cc: linux-arm-kernel@lists.infradead.org, Jaxson.Han@arm.com, robin.murphy@arm.com, vladimir.murzin@arm.com, Wei.Chen@arm.com Subject: Re: [bootwrapper PATCH v2 07/13] Rework common init C code Message-ID: <20220117162305.043cb2b3@donnerap.cambridge.arm.com> In-Reply-To: <20220114105653.3003399-8-mark.rutland@arm.com> References: <20220114105653.3003399-1-mark.rutland@arm.com> <20220114105653.3003399-8-mark.rutland@arm.com> Organization: ARM X-Mailer: Claws Mail 3.17.5 (GTK+ 2.24.32; aarch64-unknown-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220117_082311_180987_78E22271 X-CRM114-Status: GOOD ( 27.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, 14 Jan 2022 10:56:47 +0000 Mark Rutland wrote: > In init_platform() we initialize a UART and announce the presence of the > bootwrapper to the world. We do this relatively late in the boot-flow, > and prior to this will silently ignore errors (e.g. in gic_secure_init). > > To make it possible to provide improved diagnostics, and to allow us to > move more initialization into C, this patch reworks the init code to > call a C function earlier, where we can announce the presence of the > boot-wrapper and perform other initialization. > > In subsequent patches this will be expanded with more CPU > initialization. > > Signed-off-by: Mark Rutland Reviewed-by: Andre Przywara Cheers, Andre > --- > Makefile.am | 2 +- > arch/aarch32/boot.S | 5 +++++ > arch/aarch64/boot.S | 4 ++++ > common/boot.c | 4 ---- > common/init.c | 24 ++++++++++++++++++++++++ > common/platform.c | 12 +++++++----- > include/platform.h | 17 +++++++++++++++++ > 7 files changed, 58 insertions(+), 10 deletions(-) > create mode 100644 common/init.c > create mode 100644 include/platform.h > > diff --git a/Makefile.am b/Makefile.am > index f941b07..0651c38 100644 > --- a/Makefile.am > +++ b/Makefile.am > @@ -34,7 +34,7 @@ endif > PSCI_CPU_OFF := 0x84000002 > > COMMON_SRC := common/ > -COMMON_OBJ := boot.o bakery_lock.o platform.o lib.o > +COMMON_OBJ := boot.o bakery_lock.o platform.o lib.o init.o > > ARCH_OBJ := boot.o stack.o utils.o > > diff --git a/arch/aarch32/boot.S b/arch/aarch32/boot.S > index 00c432d..ee073ea 100644 > --- a/arch/aarch32/boot.S > +++ b/arch/aarch32/boot.S > @@ -48,6 +48,9 @@ ASM_FUNC(_start) > mov r0, #1 > ldr r1, =flag_no_el3 > str r0, [r1] > + > + bl cpu_init_bootwrapper > + > b start_no_el3 > > _switch_monitor: > @@ -71,6 +74,8 @@ _monitor: > ldr r0, =COUNTER_FREQ > mcr p15, 0, r0, c14, c0, 0 @ CNTFRQ > > + bl cpu_init_bootwrapper > + > bl gic_secure_init > > /* Initialise boot method */ > diff --git a/arch/aarch64/boot.S b/arch/aarch64/boot.S > index 45a0367..17b4a75 100644 > --- a/arch/aarch64/boot.S > +++ b/arch/aarch64/boot.S > @@ -141,6 +141,8 @@ reset_at_el3: > b.eq err_invalid_id > bl setup_stack > > + bl cpu_init_bootwrapper > + > bl gic_secure_init > > b start_el3 > @@ -181,6 +183,8 @@ reset_no_el3: > ldr x1, =flag_no_el3 > str w0, [x1] > > + bl cpu_init_bootwrapper > + > b start_no_el3 > > err_invalid_id: > diff --git a/common/boot.c b/common/boot.c > index c74d34c..29d53a4 100644 > --- a/common/boot.c > +++ b/common/boot.c > @@ -12,8 +12,6 @@ > extern unsigned long entrypoint; > extern unsigned long dtb; > > -void init_platform(void); > - > void __noreturn jump_kernel(unsigned long address, > unsigned long a0, > unsigned long a1, > @@ -62,8 +60,6 @@ void __noreturn first_spin(unsigned int cpu, unsigned long *mbox, > unsigned long invalid) > { > if (cpu == 0) { > - init_platform(); > - > *mbox = (unsigned long)&entrypoint; > sevl(); > spin(mbox, invalid, 1); > diff --git a/common/init.c b/common/init.c > new file mode 100644 > index 0000000..9c471c9 > --- /dev/null > +++ b/common/init.c > @@ -0,0 +1,24 @@ > +/* > + * init.c - common boot-wrapper initialization > + * > + * Copyright (C) 2021 ARM Limited. All rights reserved. > + * > + * Use of this source code is governed by a BSD-style license that can be > + * found in the LICENSE.txt file. > + */ > +#include > +#include > + > +static void announce_bootwrapper(void) > +{ > + print_string("Boot-wrapper v0.2\r\n\r\n"); > +} > + > +void cpu_init_bootwrapper(void) > +{ > + if (this_cpu_logical_id() == 0) { > + init_uart(); > + announce_bootwrapper(); > + init_platform(); > + } > +} > diff --git a/common/platform.c b/common/platform.c > index d11f568..47bf547 100644 > --- a/common/platform.c > +++ b/common/platform.c > @@ -1,5 +1,5 @@ > /* > - * platform.c - code to initialise everything required when first booting. > + * platform.c - Platform initialization and I/O. > * > * Copyright (C) 2015 ARM Limited. All rights reserved. > * > @@ -7,6 +7,7 @@ > * found in the LICENSE.txt file. > */ > > +#include > #include > > #include > @@ -30,7 +31,7 @@ > #define V2M_SYS(reg) ((void *)SYSREGS_BASE + V2M_SYS_##reg) > #endif > > -static void print_string(const char *str) > +void print_string(const char *str) > { > uint32_t flags; > > @@ -47,7 +48,7 @@ static void print_string(const char *str) > } > } > > -void init_platform(void) > +void init_uart(void) > { > /* > * UART initialisation (38400 8N1) > @@ -58,9 +59,10 @@ void init_platform(void) > raw_writel(0x70, PL011(UART_LCR_H)); > /* Enable the UART, TXen and RXen */ > raw_writel(0x301, PL011(UARTCR)); > +} > > - print_string("Boot-wrapper v0.2\r\n\r\n"); > - > +void init_platform(void) > +{ > #ifdef SYSREGS_BASE > /* > * CLCD output site MB > diff --git a/include/platform.h b/include/platform.h > new file mode 100644 > index 0000000..e5248e1 > --- /dev/null > +++ b/include/platform.h > @@ -0,0 +1,17 @@ > +/* > + * include/platform.h - Platform initialization and I/O. > + * > + * Copyright (C) 2021 ARM Limited. All rights reserved. > + * > + * Use of this source code is governed by a BSD-style license that can be > + * found in the LICENSE.txt file. > + */ > +#ifndef __PLATFORM_H > +#define __PLATFORM_H > + > +void print_string(const char *str); > +void init_uart(void); > + > +void init_platform(void); > + > +#endif /* __PLATFORM_H */ _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel