Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Arm Trusted Firmware
Commits
da9d1d59
Unverified
Commit
da9d1d59
authored
6 years ago
by
Dimitris Papastamos
Committed by
GitHub
6 years ago
Browse files
Options
Download
Plain Diff
Merge pull request #1372 from antonio-nino-diaz-arm/an/arm-multi-console
Arm platforms: Migrate to multi console driver
parents
885ca54a
2f18aa1f
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
drivers/console/aarch64/multi_console.S
+50
-3
drivers/console/aarch64/multi_console.S
include/drivers/console.h
+9
-4
include/drivers/console.h
include/plat/arm/board/common/board_arm_def.h
+5
-1
include/plat/arm/board/common/board_arm_def.h
include/plat/arm/common/plat_arm.h
+6
-0
include/plat/arm/common/plat_arm.h
plat/arm/common/aarch64/arm_helpers.S
+6
-6
plat/arm/common/aarch64/arm_helpers.S
plat/arm/common/arm_bl1_setup.c
+1
-3
plat/arm/common/arm_bl1_setup.c
plat/arm/common/arm_bl2_el3_setup.c
+2
-4
plat/arm/common/arm_bl2_el3_setup.c
plat/arm/common/arm_bl2_setup.c
+1
-3
plat/arm/common/arm_bl2_setup.c
plat/arm/common/arm_bl2u_setup.c
+2
-3
plat/arm/common/arm_bl2u_setup.c
plat/arm/common/arm_bl31_setup.c
+9
-4
plat/arm/common/arm_bl31_setup.c
plat/arm/common/arm_common.mk
+7
-1
plat/arm/common/arm_common.mk
plat/arm/common/arm_console.c
+85
-0
plat/arm/common/arm_console.c
plat/arm/common/arm_pm.c
+9
-4
plat/arm/common/arm_pm.c
plat/arm/common/tsp/arm_tsp_setup.c
+19
-1
plat/arm/common/tsp/arm_tsp_setup.c
with
211 additions
and
37 deletions
+211
-37
drivers/console/aarch64/multi_console.S
View file @
da9d1d59
/*
*
Copyright
(
c
)
2015
-
201
7
,
ARM
Limited
and
Contributors
.
All
rights
reserved
.
*
Copyright
(
c
)
2015
-
201
8
,
ARM
Limited
and
Contributors
.
All
rights
reserved
.
*
*
SPDX
-
License
-
Identifier
:
BSD
-
3
-
Clause
*/
...
...
@@ -10,7 +10,8 @@
.
globl
console_register
.
globl
console_unregister
.
globl
console_set_scope
.
globl
console_is_registered
.
globl
console_set_scope
.
globl
console_switch_state
.
globl
console_putc
.
globl
console_getc
...
...
@@ -38,13 +39,15 @@
*
persistent
memory
(
e
.
g
.
the
data
section
)
.
*
In
:
x0
-
address
of
console_t
structure
*
Out
:
x0
-
Always
1
(
for
easier
tail
calling
)
*
Clobber
list
:
x0
,
x1
,
x14
*
Clobber
list
:
x0
,
x1
,
x14
,
x15
*
-----------------------------------------------
*/
func
console_register
#if ENABLE_ASSERTIONS
/
*
Assert
that
x0
isn
't a NULL pointer */
cmp
x0
,
#
0
ASM_ASSERT
(
ne
)
/
*
Assert
that
the
struct
isn
't in the stack */
adrp
x1
,
__STACKS_START__
add
x1
,
x1
,
:
lo12
:
__STACKS_START__
cmp
x0
,
x1
...
...
@@ -54,6 +57,14 @@ func console_register
cmp
x0
,
x1
ASM_ASSERT
(
hs
)
not_on_stack
:
/
*
Assert
that
this
struct
isn
't in the list */
mov
x1
,
x0
/*
Preserve
x0
and
x30
*/
mov
x15
,
x30
bl
console_is_registered
cmp
x0
,
#
0
ASM_ASSERT
(
eq
)
mov
x30
,
x15
mov
x0
,
x1
#endif /* ENABLE_ASSERTIONS */
adrp
x14
,
console_list
ldr
x1
,
[
x14
,
:
lo12
:
console_list
]
/*
X1
=
first
struct
in
list
*/
...
...
@@ -73,6 +84,11 @@ endfunc console_register
*
-----------------------------------------------
*/
func
console_unregister
#if ENABLE_ASSERTIONS
/
*
Assert
that
x0
isn
't a NULL pointer */
cmp
x0
,
#
0
ASM_ASSERT
(
ne
)
#endif /* ENABLE_ASSERTIONS */
adrp
x14
,
console_list
add
x14
,
x14
,
:
lo12
:
console_list
/*
X14
=
ptr
to
first
struct
*/
ldr
x1
,
[
x14
]
/*
X1
=
first
struct
*/
...
...
@@ -95,6 +111,37 @@ unregister_not_found:
ret
endfunc
console_unregister
/
*
-----------------------------------------------
*
int
console_is_registered
(
console_t
*
console
)
*
Function
to
detect
if
a
specific
console
is
*
registered
or
not
.
*
In
:
x0
-
address
of
console_t
struct
to
remove
*
Out
:
x0
-
1
if
it
is
registered
,
0
if
not
.
*
Clobber
list
:
x0
,
x14
*
-----------------------------------------------
*/
func
console_is_registered
#if ENABLE_ASSERTIONS
/
*
Assert
that
x0
isn
't a NULL pointer */
cmp
x0
,
#
0
ASM_ASSERT
(
ne
)
#endif /* ENABLE_ASSERTIONS */
adrp
x14
,
console_list
ldr
x14
,
[
x14
,
:
lo12
:
console_list
]
/*
X14
=
first
console
struct
*/
check_registered_loop
:
cbz
x14
,
console_not_registered
/*
Check
if
end
of
list
*/
cmp
x0
,
x14
/*
Check
if
the
pointers
are
different
*/
b.eq
console_registered
ldr
x14
,
[
x14
,
#
CONSOLE_T_NEXT
]
/*
Get
pointer
to
next
struct
*/
b
check_registered_loop
console_not_registered
:
mov
x0
,
#
0
ret
console_registered
:
mov
x0
,
#
1
ret
endfunc
console_is_registered
/
*
-----------------------------------------------
*
void
console_switch_state
(
unsigned
int
new_state
)
*
Function
to
switch
the
current
console
state
.
...
...
This diff is collapsed.
Click to expand it.
include/drivers/console.h
View file @
da9d1d59
...
...
@@ -16,9 +16,9 @@
#define CONSOLE_T_FLUSH (U(4) * REGSZ)
#define CONSOLE_T_DRVDATA (U(5) * REGSZ)
#define CONSOLE_FLAG_BOOT
BIT(
0)
#define CONSOLE_FLAG_RUNTIME
BIT(
1)
#define CONSOLE_FLAG_CRASH
BIT(
2)
#define CONSOLE_FLAG_BOOT
(U(1) <<
0)
#define CONSOLE_FLAG_RUNTIME
(U(1) <<
1)
#define CONSOLE_FLAG_CRASH
(U(1) <<
2)
/* Bits 3 to 7 reserved for additional scopes in future expansion. */
#define CONSOLE_FLAG_SCOPE_MASK ((U(1) << 8) - 1)
/* Bits 8 to 31 reserved for non-scope use in future expansion. */
...
...
@@ -50,7 +50,12 @@ typedef struct console {
*/
/* Remove a single console_t instance from the console list. */
int
console_unregister
(
console_t
*
console
);
/* Set scope mask of a console that determines in what states it is active. */
/* Returns 1 if this console is already registered, 0 if not */
int
console_is_registered
(
console_t
*
console
);
/*
* Set scope mask of a console that determines in what states it is active.
* By default they are registered with (CONSOLE_FLAG_BOOT|CONSOLE_FLAG_CRASH).
*/
void
console_set_scope
(
console_t
*
console
,
unsigned
int
scope
);
/* Switch to a new global console state (CONSOLE_FLAG_BOOT/RUNTIME/CRASH). */
...
...
This diff is collapsed.
Click to expand it.
include/plat/arm/board/common/board_arm_def.h
View file @
da9d1d59
...
...
@@ -94,7 +94,11 @@
* PLAT_ARM_MAX_BL31_SIZE is calculated using the current BL31 debug size plus a
* little space for growth.
*/
#define PLAT_ARM_MAX_BL31_SIZE 0x20000
#if ENABLE_SPM
# define PLAT_ARM_MAX_BL31_SIZE 0x21000
#else
# define PLAT_ARM_MAX_BL31_SIZE 0x20000
#endif
#ifdef AARCH32
/*
...
...
This diff is collapsed.
Click to expand it.
include/plat/arm/common/plat_arm.h
View file @
da9d1d59
...
...
@@ -153,6 +153,12 @@ struct tzc_dmc500_driver_data;
void
arm_tzc_dmc500_setup
(
struct
tzc_dmc500_driver_data
*
plat_driver_data
,
const
arm_tzc_regions_info_t
*
tzc_regions
);
/* Console utility functions */
void
arm_console_boot_init
(
void
);
void
arm_console_boot_end
(
void
);
void
arm_console_runtime_init
(
void
);
void
arm_console_runtime_end
(
void
);
/* Systimer utility function */
void
arm_configure_sys_timer
(
void
);
...
...
This diff is collapsed.
Click to expand it.
plat/arm/common/aarch64/arm_helpers.S
View file @
da9d1d59
...
...
@@ -8,9 +8,9 @@
.
weak
plat_arm_calc_core_pos
.
weak
plat_my_core_pos
.
globl
plat_crash_console_init
.
globl
plat_crash_console_putc
.
globl
plat_crash_console_flush
.
weak
plat_crash_console_init
.
weak
plat_crash_console_putc
.
weak
plat_crash_console_flush
.
globl
platform_mem_init
...
...
@@ -50,7 +50,7 @@ func plat_crash_console_init
mov_imm
x0
,
PLAT_ARM_CRASH_UART_BASE
mov_imm
x1
,
PLAT_ARM_CRASH_UART_CLK_IN_HZ
mov_imm
x2
,
ARM_CONSOLE_BAUDRATE
b
console_core_init
b
console_
pl011_
core_init
endfunc
plat_crash_console_init
/
*
---------------------------------------------
...
...
@@ -62,7 +62,7 @@ endfunc plat_crash_console_init
*/
func
plat_crash_console_putc
mov_imm
x1
,
PLAT_ARM_CRASH_UART_BASE
b
console_core_putc
b
console_
pl011_
core_putc
endfunc
plat_crash_console_putc
/
*
---------------------------------------------
...
...
@@ -75,7 +75,7 @@ endfunc plat_crash_console_putc
*/
func
plat_crash_console_flush
mov_imm
x0
,
PLAT_ARM_CRASH_UART_BASE
b
console_core_flush
b
console_
pl011_
core_flush
endfunc
plat_crash_console_flush
/
*
---------------------------------------------------------------------
...
...
This diff is collapsed.
Click to expand it.
plat/arm/common/arm_bl1_setup.c
View file @
da9d1d59
...
...
@@ -9,7 +9,6 @@
#include <arm_xlat_tables.h>
#include <bl1.h>
#include <bl_common.h>
#include <console.h>
#include <plat_arm.h>
#include <platform.h>
#include <platform_def.h>
...
...
@@ -45,8 +44,7 @@ void arm_bl1_early_platform_setup(void)
#endif
/* Initialize the console to provide early debug support */
console_init
(
PLAT_ARM_BOOT_UART_BASE
,
PLAT_ARM_BOOT_UART_CLK_IN_HZ
,
ARM_CONSOLE_BAUDRATE
);
arm_console_boot_init
();
/* Allow BL1 to see the whole Trusted RAM */
bl1_tzram_layout
.
total_base
=
ARM_BL_RAM_BASE
;
...
...
This diff is collapsed.
Click to expand it.
plat/arm/common/arm_bl2_el3_setup.c
View file @
da9d1d59
/*
* Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2017
-2018
, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <console.h>
#include <generic_delay_timer.h>
#include <plat_arm.h>
#include <platform.h>
...
...
@@ -21,8 +20,7 @@ static meminfo_t bl2_el3_tzram_layout;
void
arm_bl2_el3_early_platform_setup
(
void
)
{
/* Initialize the console to provide early debug support */
console_init
(
PLAT_ARM_BOOT_UART_BASE
,
PLAT_ARM_BOOT_UART_CLK_IN_HZ
,
ARM_CONSOLE_BAUDRATE
);
arm_console_boot_init
();
/*
* Allow BL2 to see the whole Trusted RAM. This is determined
...
...
This diff is collapsed.
Click to expand it.
plat/arm/common/arm_bl2_setup.c
View file @
da9d1d59
...
...
@@ -8,7 +8,6 @@
#include <arm_def.h>
#include <assert.h>
#include <bl_common.h>
#include <console.h>
#include <debug.h>
#include <desc_image_load.h>
#include <generic_delay_timer.h>
...
...
@@ -184,8 +183,7 @@ struct entry_point_info *bl2_plat_get_bl31_ep_info(void)
void
arm_bl2_early_platform_setup
(
uintptr_t
tb_fw_config
,
meminfo_t
*
mem_layout
)
{
/* Initialize the console to provide early debug support */
console_init
(
PLAT_ARM_BOOT_UART_BASE
,
PLAT_ARM_BOOT_UART_CLK_IN_HZ
,
ARM_CONSOLE_BAUDRATE
);
arm_console_boot_init
();
/* Setup the BL2 memory layout */
bl2_tzram_layout
=
*
mem_layout
;
...
...
This diff is collapsed.
Click to expand it.
plat/arm/common/arm_bl2u_setup.c
View file @
da9d1d59
...
...
@@ -7,7 +7,6 @@
#include <arch_helpers.h>
#include <arm_def.h>
#include <bl_common.h>
#include <console.h>
#include <generic_delay_timer.h>
#include <plat_arm.h>
#include <platform_def.h>
...
...
@@ -36,8 +35,8 @@ void bl2u_platform_setup(void)
void
arm_bl2u_early_platform_setup
(
meminfo_t
*
mem_layout
,
void
*
plat_info
)
{
/* Initialize the console to provide early debug support */
console_init
(
PLAT_ARM_BOOT_UART_BASE
,
PLAT_ARM_BOOT_UART_CLK_IN_HZ
,
ARM_CONSOLE_BAUDRATE
);
arm_
console_
boot_
init
(
);
generic_delay_timer_init
();
}
...
...
This diff is collapsed.
Click to expand it.
plat/arm/common/arm_bl31_setup.c
View file @
da9d1d59
...
...
@@ -72,8 +72,7 @@ void arm_bl31_early_platform_setup(bl31_params_t *from_bl2, uintptr_t soc_fw_con
#endif
{
/* Initialize the console to provide early debug support */
console_init
(
PLAT_ARM_BOOT_UART_BASE
,
PLAT_ARM_BOOT_UART_CLK_IN_HZ
,
ARM_CONSOLE_BAUDRATE
);
arm_console_boot_init
();
#if RESET_TO_BL31
/* There are no parameters from BL2 if BL31 is a reset vector */
...
...
@@ -226,12 +225,18 @@ void arm_bl31_platform_setup(void)
/*******************************************************************************
* Perform any BL31 platform runtime setup prior to BL31 exit common to ARM
* standard platforms
* Perform BL31 platform setup
******************************************************************************/
void
arm_bl31_plat_runtime_setup
(
void
)
{
#if MULTI_CONSOLE_API
console_switch_state
(
CONSOLE_FLAG_RUNTIME
);
#else
console_uninit
();
#endif
/* Initialize the runtime console */
console_init
(
PLAT_ARM_BL31_RUN_UART_BASE
,
PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ
,
ARM_CONSOLE_BAUDRATE
);
arm_console_runtime_init
();
}
void
bl31_platform_setup
(
void
)
...
...
This diff is collapsed.
Click to expand it.
plat/arm/common/arm_common.mk
View file @
da9d1d59
...
...
@@ -104,6 +104,11 @@ SEPARATE_CODE_AND_RODATA := 1
# Enable new version of image loading on ARM platforms
LOAD_IMAGE_V2
:=
1
# Use the multi console API, which is only available for AArch64 for now
ifeq
(${ARCH}, aarch64)
MULTI_CONSOLE_API
:=
1
endif
# Use generic OID definition (tbbr_oid.h)
USE_TBBR_DEFS
:=
1
...
...
@@ -120,7 +125,8 @@ PLAT_INCLUDES += -Iinclude/plat/arm/common/aarch64
endif
PLAT_BL_COMMON_SOURCES
+=
plat/arm/common/
${ARCH}
/arm_helpers.S
\
plat/arm/common/arm_common.c
plat/arm/common/arm_common.c
\
plat/arm/common/arm_console.c
ifeq
(${ARM_XLAT_TABLES_LIB_V1}, 1)
PLAT_BL_COMMON_SOURCES
+=
lib/xlat_tables/xlat_tables_common.c
\
...
...
This diff is collapsed.
Click to expand it.
plat/arm/common/arm_console.c
0 → 100644
View file @
da9d1d59
/*
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <assert.h>
#include <console.h>
#include <debug.h>
#include <pl011.h>
#include <plat_arm.h>
#include <platform_def.h>
/*******************************************************************************
* Functions that set up the console
******************************************************************************/
#if MULTI_CONSOLE_API
static
console_pl011_t
arm_boot_console
;
static
console_pl011_t
arm_runtime_console
;
#endif
/* Initialize the console to provide early debug support */
void
arm_console_boot_init
(
void
)
{
#if MULTI_CONSOLE_API
int
rc
=
console_pl011_register
(
PLAT_ARM_BOOT_UART_BASE
,
PLAT_ARM_BOOT_UART_CLK_IN_HZ
,
ARM_CONSOLE_BAUDRATE
,
&
arm_boot_console
);
if
(
rc
==
0
)
{
/*
* The crash console doesn't use the multi console API, it uses
* the core console functions directly. It is safe to call panic
* and let it print debug information.
*/
panic
();
}
console_set_scope
(
&
arm_boot_console
.
console
,
CONSOLE_FLAG_BOOT
);
#else
(
void
)
console_init
(
PLAT_ARM_BOOT_UART_BASE
,
PLAT_ARM_BOOT_UART_CLK_IN_HZ
,
ARM_CONSOLE_BAUDRATE
);
#endif
/* MULTI_CONSOLE_API */
}
void
arm_console_boot_end
(
void
)
{
#if MULTI_CONSOLE_API
(
void
)
console_flush
();
(
void
)
console_unregister
(
&
arm_boot_console
.
console
);
#else
console_uninit
();
#endif
/* MULTI_CONSOLE_API */
}
/* Initialize the runtime console */
void
arm_console_runtime_init
(
void
)
{
#if MULTI_CONSOLE_API
int
rc
=
console_pl011_register
(
PLAT_ARM_BL31_RUN_UART_BASE
,
PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ
,
ARM_CONSOLE_BAUDRATE
,
&
arm_runtime_console
);
if
(
rc
==
0
)
panic
();
console_set_scope
(
&
arm_runtime_console
.
console
,
CONSOLE_FLAG_RUNTIME
);
#else
(
void
)
console_init
(
PLAT_ARM_BL31_RUN_UART_BASE
,
PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ
,
ARM_CONSOLE_BAUDRATE
);
#endif
/* MULTI_CONSOLE_API */
}
void
arm_console_runtime_end
(
void
)
{
#if MULTI_CONSOLE_API
(
void
)
console_flush
();
(
void
)
console_unregister
(
&
arm_runtime_console
.
console
);
#else
console_uninit
();
#endif
/* MULTI_CONSOLE_API */
}
This diff is collapsed.
Click to expand it.
plat/arm/common/arm_pm.c
View file @
da9d1d59
/*
* Copyright (c) 2015-201
7
, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2015-201
8
, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
...
...
@@ -8,7 +8,6 @@
#include <arm_def.h>
#include <arm_gic.h>
#include <assert.h>
#include <console.h>
#include <errno.h>
#include <plat_arm.h>
#include <platform.h>
...
...
@@ -159,6 +158,12 @@ void arm_system_pwr_domain_save(void)
plat_arm_gic_save
();
/*
* Unregister console now so that it is not registered for a second
* time during resume.
*/
arm_console_runtime_end
();
/*
* All the other peripheral which are configured by ARM TF are
* re-initialized on resume from system suspend. Hence we
...
...
@@ -174,8 +179,8 @@ void arm_system_pwr_domain_save(void)
*****************************************************************************/
void
arm_system_pwr_domain_resume
(
void
)
{
console_init
(
PLAT_ARM_BL31_RUN_UART_BASE
,
PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ
,
ARM_CONSOLE_BAUDRATE
);
/* Initialize the console */
arm_console_runtime_init
(
);
/* Assert system power domain is available on the platform */
assert
(
PLAT_MAX_PWR_LVL
>=
ARM_PWR_LVL2
);
...
...
This diff is collapsed.
Click to expand it.
plat/arm/common/tsp/arm_tsp_setup.c
View file @
da9d1d59
/*
* Copyright (c) 2015-201
6
, ARM Limited and Contributors. All rights reserved.
* Copyright (c) 2015-201
8
, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
...
...
@@ -7,6 +7,8 @@
#include <arm_def.h>
#include <bl_common.h>
#include <console.h>
#include <debug.h>
#include <pl011.h>
#include <plat_arm.h>
#include <platform_def.h>
#include <platform_tsp.h>
...
...
@@ -22,14 +24,30 @@
/*******************************************************************************
* Initialize the UART
******************************************************************************/
#if MULTI_CONSOLE_API
static
console_pl011_t
arm_tsp_runtime_console
;
#endif
void
arm_tsp_early_platform_setup
(
void
)
{
#if MULTI_CONSOLE_API
/*
* Initialize a different console than already in use to display
* messages from TSP
*/
int
rc
=
console_pl011_register
(
PLAT_ARM_TSP_UART_BASE
,
PLAT_ARM_TSP_UART_CLK_IN_HZ
,
ARM_CONSOLE_BAUDRATE
,
&
arm_tsp_runtime_console
);
if
(
rc
==
0
)
panic
();
console_set_scope
(
&
arm_tsp_runtime_console
.
console
,
CONSOLE_FLAG_BOOT
|
CONSOLE_FLAG_RUNTIME
);
#else
console_init
(
PLAT_ARM_TSP_UART_BASE
,
PLAT_ARM_TSP_UART_CLK_IN_HZ
,
ARM_CONSOLE_BAUDRATE
);
#endif
/* MULTI_CONSOLE_API */
}
void
tsp_early_platform_setup
(
void
)
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help