All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andre Przywara <andre.przywara@arm.com>
To: Mark Rutland <mark.rutland@arm.com>
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
Date: Mon, 17 Jan 2022 16:23:05 +0000	[thread overview]
Message-ID: <20220117162305.043cb2b3@donnerap.cambridge.arm.com> (raw)
In-Reply-To: <20220114105653.3003399-8-mark.rutland@arm.com>

On Fri, 14 Jan 2022 10:56:47 +0000
Mark Rutland <mark.rutland@arm.com> 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 <mark.rutland@arm.com>

Reviewed-by: Andre Przywara <andre.przywara@arm.com>

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 <cpu.h>
> +#include <platform.h>
> +
> +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 <cpu.h>
>  #include <stdint.h>
>  
>  #include <asm/io.h>
> @@ -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

  reply	other threads:[~2022-01-17 16:24 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-14 10:56 [bootwrapper PATCH v2 00/13] Cleanups and improvements Mark Rutland
2022-01-14 10:56 ` [bootwrapper PATCH v2 01/13] Document entry requirements Mark Rutland
2022-01-14 10:56 ` [bootwrapper PATCH v2 02/13] Add bit-field macros Mark Rutland
2022-01-17 12:11   ` Steven Price
2022-01-17 13:28     ` Mark Rutland
2022-01-14 10:56 ` [bootwrapper PATCH v2 03/13] aarch64: add system register accessors Mark Rutland
2022-01-14 15:32   ` Andre Przywara
2022-01-14 10:56 ` [bootwrapper PATCH v2 04/13] aarch32: add coprocessor accessors Mark Rutland
2022-01-14 10:56 ` [bootwrapper PATCH v2 05/13] aarch64: add mov_64 macro Mark Rutland
2022-01-14 15:50   ` Andre Przywara
2022-01-14 10:56 ` [bootwrapper PATCH v2 06/13] aarch64: initialize SCTLR_ELx for the boot-wrapper Mark Rutland
2022-01-14 18:12   ` Andre Przywara
2022-01-17 12:15     ` Mark Rutland
2022-01-17 13:05       ` Mark Rutland
2022-01-18 12:37         ` Andre Przywara
2022-01-25 13:32           ` Mark Rutland
2022-01-19 12:42       ` Mark Rutland
2022-01-14 10:56 ` [bootwrapper PATCH v2 07/13] Rework common init C code Mark Rutland
2022-01-17 16:23   ` Andre Przywara [this message]
2022-01-14 10:56 ` [bootwrapper PATCH v2 08/13] Announce boot-wrapper mode / exception level Mark Rutland
2022-01-17 14:39   ` Andre Przywara
2022-01-17 15:50     ` Mark Rutland
2022-01-14 10:56 ` [bootwrapper PATCH v2 09/13] aarch64: move the bulk of EL3 initialization to C Mark Rutland
2022-01-17 14:31   ` Andre Przywara
2022-01-17 18:08     ` Mark Rutland
2022-01-17 18:31       ` Andre Przywara
2022-01-18 16:50         ` Mark Brown
2022-01-19 15:22           ` Mark Rutland
2022-01-14 10:56 ` [bootwrapper PATCH v2 10/13] aarch32: move the bulk of Secure PL1 " Mark Rutland
2022-01-17 14:52   ` Andre Przywara
2022-01-14 10:56 ` [bootwrapper PATCH v2 11/13] Announce locations of memory objects Mark Rutland
2022-01-14 15:30   ` Andre Przywara
2022-01-14 16:04     ` Robin Murphy
2022-01-14 16:30       ` Mark Rutland
2022-01-14 16:21     ` Mark Rutland
2022-01-17 14:59   ` Andre Przywara
2022-01-14 10:56 ` [bootwrapper PATCH v2 12/13] Rework bootmethod initialization Mark Rutland
2022-01-17 17:43   ` Andre Przywara
2022-01-25 14:00     ` Mark Rutland
2022-01-14 10:56 ` [bootwrapper PATCH v2 13/13] Unify start_el3 & start_no_el3 Mark Rutland
2022-01-17 17:43   ` Andre Przywara
2022-01-14 15:09 ` [bootwrapper PATCH v2 00/13] Cleanups and improvements Andre Przywara
2022-01-14 15:23   ` Mark Rutland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220117162305.043cb2b3@donnerap.cambridge.arm.com \
    --to=andre.przywara@arm.com \
    --cc=Jaxson.Han@arm.com \
    --cc=Wei.Chen@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mark.rutland@arm.com \
    --cc=robin.murphy@arm.com \
    --cc=vladimir.murzin@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.