aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanh-arm <dan.handley@arm.com>2015-12-09 19:03:06 +0000
committerdanh-arm <dan.handley@arm.com>2015-12-09 19:03:06 +0000
commit7ee2b8b3f8d610bf4f0e261ebaf3bd24afc1eea2 (patch)
tree7b20cd6a7200f021d5864bf665ea31c482559fd4
parentab5a53ef0f2f4f19f59a28738ae00c6bb5975d21 (diff)
parent080225dacd7c1e11c53756ec66d72d3573d1a70d (diff)
downloadarm-trusted-firmware-7ee2b8b3f8d610bf4f0e261ebaf3bd24afc1eea2.tar.gz
Merge pull request #462 from soby-mathew/sm/runtime_console
Enable BL31 to configure a runtime console
-rw-r--r--bl31/bl31_main.c8
-rw-r--r--docs/porting-guide.md15
-rw-r--r--drivers/console/console.S15
-rw-r--r--include/drivers/console.h1
-rw-r--r--include/plat/arm/board/common/board_css_def.h7
-rw-r--r--include/plat/arm/common/plat_arm.h1
-rw-r--r--include/plat/common/platform.h1
-rw-r--r--plat/arm/board/fvp/include/platform_def.h7
-rw-r--r--plat/arm/common/arm_bl31_setup.c16
-rw-r--r--plat/arm/common/arm_pm.c2
-rw-r--r--plat/common/aarch64/plat_common.c13
11 files changed, 79 insertions, 7 deletions
diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c
index 9abc395bf..f22e6121c 100644
--- a/bl31/bl31_main.c
+++ b/bl31/bl31_main.c
@@ -77,7 +77,7 @@ void bl31_main(void)
/* Perform remaining generic architectural setup from EL3 */
bl31_arch_setup();
- /* Perform platform setup in BL1 */
+ /* Perform platform setup in BL31 */
bl31_platform_setup();
/* Initialise helper libraries */
@@ -109,6 +109,12 @@ void bl31_main(void)
* corresponding to the desired security state after the next ERET.
*/
bl31_prepare_next_image_entry();
+
+ /*
+ * Perform any platform specific runtime setup prior to cold boot exit
+ * from BL31
+ */
+ bl31_plat_runtime_setup();
}
/*******************************************************************************
diff --git a/docs/porting-guide.md b/docs/porting-guide.md
index e5b4a9c78..ba550f046 100644
--- a/docs/porting-guide.md
+++ b/docs/porting-guide.md
@@ -1172,6 +1172,21 @@ In ARM standard platforms, this function does the following:
* Detects the system topology.
+### Function : bl31_plat_runtime_setup() [optional]
+
+ Argument : void
+ Return : void
+
+The purpose of this function is allow the platform to perform any BL31 runtime
+setup just prior to BL31 exit during cold boot. The default weak
+implementation of this function will invoke `console_uninit()` which will
+suppress any BL31 runtime logs.
+
+In ARM Standard platforms, this function will initialize the BL31 runtime
+console which will cause all further BL31 logs to be output to the
+runtime console.
+
+
### Function : bl31_get_next_image_info() [mandatory]
Argument : unsigned int
diff --git a/drivers/console/console.S b/drivers/console/console.S
index d966f0d36..40a6db9f4 100644
--- a/drivers/console/console.S
+++ b/drivers/console/console.S
@@ -30,6 +30,7 @@
#include <asm_macros.S>
.globl console_init
+ .globl console_uninit
.globl console_putc
.globl console_getc
@@ -66,6 +67,20 @@ init_fail:
ret
endfunc console_init
+ /* -----------------------------------------------
+ * void console_uninit(void)
+ * Function to finish the use of console driver.
+ * It sets the console_base as NULL so that any
+ * further invocation of `console_putc` or
+ * `console_getc` APIs would return error.
+ * -----------------------------------------------
+ */
+func console_uninit
+ mov x0, #0
+ adrp x3, console_base
+ str x0, [x3, :lo12:console_base]
+endfunc console_uninit
+
/* ---------------------------------------------
* int console_putc(int c)
* Function to output a character over the
diff --git a/include/drivers/console.h b/include/drivers/console.h
index d374157bd..69ad0bd74 100644
--- a/include/drivers/console.h
+++ b/include/drivers/console.h
@@ -35,6 +35,7 @@
int console_init(uintptr_t base_addr,
unsigned int uart_clk, unsigned int baud_rate);
+void console_uninit(void);
int console_putc(int c);
int console_getc(void);
diff --git a/include/plat/arm/board/common/board_css_def.h b/include/plat/arm/board/common/board_css_def.h
index 2e32b41c5..975f1fc55 100644
--- a/include/plat/arm/board/common/board_css_def.h
+++ b/include/plat/arm/board/common/board_css_def.h
@@ -74,8 +74,11 @@
#define PLAT_ARM_BOOT_UART_BASE SOC_CSS_UART0_BASE
#define PLAT_ARM_BOOT_UART_CLK_IN_HZ SOC_CSS_UART0_CLK_IN_HZ
-#define PLAT_ARM_CRASH_UART_BASE SOC_CSS_UART1_BASE
-#define PLAT_ARM_CRASH_UART_CLK_IN_HZ SOC_CSS_UART1_CLK_IN_HZ
+#define PLAT_ARM_BL31_RUN_UART_BASE SOC_CSS_UART1_BASE
+#define PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ SOC_CSS_UART1_CLK_IN_HZ
+
+#define PLAT_ARM_CRASH_UART_BASE PLAT_ARM_BL31_RUN_UART_BASE
+#define PLAT_ARM_CRASH_UART_CLK_IN_HZ PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ
#define PLAT_ARM_TSP_UART_BASE V2M_IOFPGA_UART0_BASE
#define PLAT_ARM_TSP_UART_CLK_IN_HZ V2M_IOFPGA_UART0_CLK_IN_HZ
diff --git a/include/plat/arm/common/plat_arm.h b/include/plat/arm/common/plat_arm.h
index bcb2e2b8a..32c062d1f 100644
--- a/include/plat/arm/common/plat_arm.h
+++ b/include/plat/arm/common/plat_arm.h
@@ -175,6 +175,7 @@ void arm_bl2u_plat_arch_setup(void);
void arm_bl31_early_platform_setup(bl31_params_t *from_bl2,
void *plat_params_from_bl2);
void arm_bl31_platform_setup(void);
+void arm_bl31_plat_runtime_setup(void);
void arm_bl31_plat_arch_setup(void);
/* TSP utility functions */
diff --git a/include/plat/common/platform.h b/include/plat/common/platform.h
index 9fbc17211..b3213b8f3 100644
--- a/include/plat/common/platform.h
+++ b/include/plat/common/platform.h
@@ -216,6 +216,7 @@ void bl31_early_platform_setup(struct bl31_params *from_bl2,
void *plat_params_from_bl2);
void bl31_plat_arch_setup(void);
void bl31_platform_setup(void);
+void bl31_plat_runtime_setup(void);
struct entry_point_info *bl31_plat_get_next_image_ep_info(uint32_t type);
/*******************************************************************************
diff --git a/plat/arm/board/fvp/include/platform_def.h b/plat/arm/board/fvp/include/platform_def.h
index 9cb88de5c..e93418dc1 100644
--- a/plat/arm/board/fvp/include/platform_def.h
+++ b/plat/arm/board/fvp/include/platform_def.h
@@ -78,8 +78,11 @@
#define PLAT_ARM_BOOT_UART_BASE V2M_IOFPGA_UART0_BASE
#define PLAT_ARM_BOOT_UART_CLK_IN_HZ V2M_IOFPGA_UART0_CLK_IN_HZ
-#define PLAT_ARM_CRASH_UART_BASE V2M_IOFPGA_UART1_BASE
-#define PLAT_ARM_CRASH_UART_CLK_IN_HZ V2M_IOFPGA_UART1_CLK_IN_HZ
+#define PLAT_ARM_BL31_RUN_UART_BASE V2M_IOFPGA_UART1_BASE
+#define PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ V2M_IOFPGA_UART1_CLK_IN_HZ
+
+#define PLAT_ARM_CRASH_UART_BASE PLAT_ARM_BL31_RUN_UART_BASE
+#define PLAT_ARM_CRASH_UART_CLK_IN_HZ PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ
#define PLAT_ARM_TSP_UART_BASE V2M_IOFPGA_UART2_BASE
#define PLAT_ARM_TSP_UART_CLK_IN_HZ V2M_IOFPGA_UART2_CLK_IN_HZ
diff --git a/plat/arm/common/arm_bl31_setup.c b/plat/arm/common/arm_bl31_setup.c
index 50b98c700..a7c2f7dff 100644
--- a/plat/arm/common/arm_bl31_setup.c
+++ b/plat/arm/common/arm_bl31_setup.c
@@ -223,11 +223,27 @@ void arm_bl31_platform_setup(void)
plat_arm_pwrc_setup();
}
+/*******************************************************************************
+ * Perform any BL3-1 platform runtime setup prior to BL3-1 exit common to ARM
+ * standard platforms
+ ******************************************************************************/
+void arm_bl31_plat_runtime_setup(void)
+{
+ /* Initialize the runtime console */
+ console_init(PLAT_ARM_BL31_RUN_UART_BASE, PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ,
+ ARM_CONSOLE_BAUDRATE);
+}
+
void bl31_platform_setup(void)
{
arm_bl31_platform_setup();
}
+void bl31_plat_runtime_setup(void)
+{
+ arm_bl31_plat_runtime_setup();
+}
+
/*******************************************************************************
* Perform the very early platform specific architectural setup here. At the
* moment this is only intializes the mmu in a quick and dirty way.
diff --git a/plat/arm/common/arm_pm.c b/plat/arm/common/arm_pm.c
index bd5820b55..2ddc58334 100644
--- a/plat/arm/common/arm_pm.c
+++ b/plat/arm/common/arm_pm.c
@@ -158,7 +158,7 @@ int arm_validate_ns_entrypoint(uintptr_t entrypoint)
*****************************************************************************/
void arm_system_pwr_domain_resume(void)
{
- console_init(PLAT_ARM_BOOT_UART_BASE, PLAT_ARM_BOOT_UART_CLK_IN_HZ,
+ console_init(PLAT_ARM_BL31_RUN_UART_BASE, PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ,
ARM_CONSOLE_BAUDRATE);
/* Assert system power domain is available on the platform */
diff --git a/plat/common/aarch64/plat_common.c b/plat/common/aarch64/plat_common.c
index a6a847655..9070c613c 100644
--- a/plat/common/aarch64/plat_common.c
+++ b/plat/common/aarch64/plat_common.c
@@ -28,16 +28,18 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <assert.h>
+#include <console.h>
#include <platform.h>
#include <xlat_tables.h>
/*
- * The following 2 platform setup functions are weakly defined. They
+ * The following platform setup functions are weakly defined. They
* provide typical implementations that may be re-used by multiple
* platforms but may also be overridden by a platform if required.
*/
#pragma weak bl31_plat_enable_mmu
#pragma weak bl32_plat_enable_mmu
+#pragma weak bl31_plat_runtime_setup
void bl31_plat_enable_mmu(uint32_t flags)
{
@@ -49,6 +51,15 @@ void bl32_plat_enable_mmu(uint32_t flags)
enable_mmu_el1(flags);
}
+void bl31_plat_runtime_setup(void)
+{
+ /*
+ * Finish the use of console driver in BL31 so that any runtime logs
+ * from BL31 will be suppressed.
+ */
+ console_uninit();
+}
+
#if !ENABLE_PLAT_COMPAT
/*
* Helper function for platform_get_pos() when platform compatibility is