diff --git a/docs/firmware-design.md b/docs/firmware-design.md index 1f799b6..e92042d 100644 --- a/docs/firmware-design.md +++ b/docs/firmware-design.md @@ -156,7 +156,7 @@ BL1 enables issuing of snoop and DVM (Distributed Virtual Memory) requests from the CCI-400 slave interface corresponding to the cluster that includes the primary CPU. BL1 also initializes UART0 (PL011 console), which enables -access to the `printf` family of functions. The `CNTFRQ_EL0` register is +access to the `printf` family of functions in BL1. The `CNTFRQ_EL0` register is programmed with the base frequency of the system counter, which is retrieved from the first entry in the frequency modes table. The system level implementation of the generic timer is enabled through the memory mapped @@ -218,6 +218,8 @@ to determine whether there is enough space to load the BL3-3 image. A platform defined base address is used to specify the load address for the BL3-1 image. It also defines the extents of memory available for use by the BL3-2 image. +BL2 also initializes UART0 (PL011 console), which enables access to the +`printf` family of functions in BL2 #### BL3-1 (EL3 Runtime Firmware) image load @@ -293,7 +295,8 @@ BL3-1 performs detailed platform initialization, which enables normal world software to function correctly. It also retrieves entrypoint information for the BL3-3 image loaded by BL2 from the platform defined memory address populated -by BL2. +by BL2. BL3-1 also initializes UART0 (PL011 console), which enables +access to the `printf` family of functions in BL3-1 * GICv2 initialization: diff --git a/drivers/console/console.c b/drivers/console/console.c index efe1201..1a684ff 100644 --- a/drivers/console/console.c +++ b/drivers/console/console.c @@ -31,11 +31,19 @@ #include #include #include +#include -static unsigned long uart_base = PL011_BASE; +static unsigned long uart_base; void console_init(unsigned long base_addr) { + /* TODO: assert() internally calls printf() and will result in + * an infinite loop. This needs to be fixed with some kind of + * exception mechanism or early panic support. This also applies + * to the other assert() calls below. + */ + assert(base_addr); + /* Initialise internal base address variable */ uart_base = base_addr; @@ -60,6 +68,8 @@ int console_putc(int c) { + assert(uart_base); + if (c == '\n') console_putc('\r'); @@ -71,6 +81,8 @@ int console_getc(void) { + assert(uart_base); + while ((pl011_read_fr(uart_base) & PL011_UARTFR_RXFE) != 0) ; return pl011_read_dr(uart_base); diff --git a/plat/fvp/bl2_plat_setup.c b/plat/fvp/bl2_plat_setup.c index f0d6e44..4d57ed5 100644 --- a/plat/fvp/bl2_plat_setup.c +++ b/plat/fvp/bl2_plat_setup.c @@ -33,6 +33,7 @@ #include #include #include +#include /******************************************************************************* * Declarations of linker defined symbols which will help us find the layout @@ -110,6 +111,8 @@ /* Initialize the platform config for future decision making */ platform_config_setup(); + console_init(PL011_UART0_BASE); + return; } diff --git a/plat/fvp/bl31_plat_setup.c b/plat/fvp/bl31_plat_setup.c index 1b24687..eb137e0 100644 --- a/plat/fvp/bl31_plat_setup.c +++ b/plat/fvp/bl31_plat_setup.c @@ -32,6 +32,7 @@ #include #include #include +#include /******************************************************************************* * Declarations of linker defined symbols which will help us find the layout @@ -117,6 +118,8 @@ /* Initialize the platform config for future decision making */ platform_config_setup(); + + console_init(PL011_UART0_BASE); } /*******************************************************************************