mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-16 09:34:18 +00:00
refactor(libc): clean up dependencies in libc
- Removing platform dependencies from libc modules. - Replacing panicking with actual error handling. - Debug macros are included indirectly from assert.h. Removing "platform_def.h" from assert.h and adding "common/debug.h" where the macros are used. - Removing hack for fixing PLAT_LOG_LEVEL_ASSERT to 40. Instead removing assert with expression, as this does not provide additional information. Signed-off-by: Claus Pedersen <claustbp@google.com> Change-Id: Icc201ea7b63c1277e423c1cfd13fd6816c2bc568
This commit is contained in:
parent
93910a7487
commit
885e268304
33 changed files with 51 additions and 41 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <assert.h>
|
||||
#include <crypto/sha_dma.h>
|
||||
#include <lib/mmio.h>
|
||||
#include <platform_def.h>
|
||||
|
||||
#include "aml_private.h"
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <assert.h>
|
||||
|
||||
#include <arch_helpers.h>
|
||||
#include <common/debug.h>
|
||||
#include <drivers/arm/arm_gicv3_common.h>
|
||||
#include <drivers/arm/gicv3.h>
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include <common/interrupt_props.h>
|
||||
#include <drivers/arm/gic_common.h>
|
||||
|
||||
#include <platform_def.h>
|
||||
|
||||
#include "../common/gic_common_private.h"
|
||||
#include "gicv3_private.h"
|
||||
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <platform_def.h>
|
||||
|
||||
#include <drivers/arm/cryptocell/713/bsv_api.h>
|
||||
#include <drivers/arm/cryptocell/713/bsv_crypto_asym_api.h>
|
||||
#include <drivers/auth/crypto_mod.h>
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include <drivers/console.h>
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
#include <assert.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <common/debug.h>
|
||||
#include <drivers/auth/crypto_mod.h>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <lib/mmio.h>
|
||||
#include <drivers/delay_timer.h>
|
||||
#include <drivers/rpi3/gpio/rpi3_gpio.h>
|
||||
#include <platform_def.h>
|
||||
|
||||
static uintptr_t reg_base;
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <common/bl_common.h>
|
||||
|
||||
/*******************************************************************************
|
||||
* Mandatory SP_MIN functions
|
||||
******************************************************************************/
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef FCONF_H
|
||||
#define FCONF_H
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* Public API */
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
|
||||
#include <cdefs.h>
|
||||
|
||||
#include <platform_def.h>
|
||||
|
||||
#include <common/debug.h>
|
||||
|
||||
#ifndef PLAT_LOG_LEVEL_ASSERT
|
||||
|
@ -18,9 +16,7 @@
|
|||
#endif
|
||||
|
||||
#if ENABLE_ASSERTIONS
|
||||
# if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
|
||||
# define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e))
|
||||
# elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
|
||||
# if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
|
||||
# define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__))
|
||||
# else
|
||||
# define assert(e) ((e) ? (void)0 : __assert())
|
||||
|
@ -29,10 +25,7 @@
|
|||
#define assert(e) ((void)0)
|
||||
#endif /* ENABLE_ASSERTIONS */
|
||||
|
||||
#if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
|
||||
void __dead2 __assert(const char *file, unsigned int line,
|
||||
const char *assertion);
|
||||
#elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
|
||||
#if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
|
||||
void __dead2 __assert(const char *file, unsigned int line);
|
||||
#else
|
||||
void __dead2 __assert(void);
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef FCONF_ARM_SP_GETTER_H
|
||||
#define FCONF_ARM_SP_GETTER_H
|
||||
|
||||
#include <common/tbbr/tbbr_img_def.h>
|
||||
#include <lib/fconf/fconf.h>
|
||||
#include <tools_share/uuid.h>
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <common/bl_common.h>
|
||||
#include <lib/cassert.h>
|
||||
#include <lib/el3_runtime/cpu_data.h>
|
||||
#include <lib/utils.h>
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <arch_features.h>
|
||||
#include <bl31/interrupt_mgmt.h>
|
||||
#include <common/bl_common.h>
|
||||
#include <common/debug.h>
|
||||
#include <context.h>
|
||||
#include <drivers/arm/gicv3.h>
|
||||
#include <lib/el3_runtime/context_mgmt.h>
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
#include <lib/object_pool.h>
|
||||
#include <libfdt.h>
|
||||
|
||||
#include <platform_def.h>
|
||||
|
||||
/* We currently use FW, TB_FW, SOC_FW, TOS_FW, NT_FW and HW configs */
|
||||
#define MAX_DTB_INFO U(6)
|
||||
/*
|
||||
|
|
|
@ -17,16 +17,7 @@
|
|||
* LOG_LEVEL_INFO, which is the default value for builds with DEBUG=1.
|
||||
*/
|
||||
|
||||
#if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_VERBOSE
|
||||
void __dead2 __assert(const char *file, unsigned int line,
|
||||
const char *assertion)
|
||||
{
|
||||
printf("ASSERT: %s:%u:%s\n", file, line, assertion);
|
||||
backtrace("assert");
|
||||
console_flush();
|
||||
plat_panic_handler();
|
||||
}
|
||||
#elif PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
|
||||
#if PLAT_LOG_LEVEL_ASSERT >= LOG_LEVEL_INFO
|
||||
void __dead2 __assert(const char *file, unsigned int line)
|
||||
{
|
||||
printf("ASSERT: %s:%u\n", file, line);
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <common/debug.h>
|
||||
|
||||
#define get_num_va_args(_args, _lcount) \
|
||||
(((_lcount) > 1) ? va_arg(_args, long long int) : \
|
||||
(((_lcount) == 1) ? va_arg(_args, long int) : \
|
||||
|
@ -43,6 +41,12 @@ static int unsigned_num_print(unsigned long long int unum, unsigned int radix,
|
|||
int i = 0, count = 0;
|
||||
unsigned int rem;
|
||||
|
||||
/* num_buf is only large enough for radix >= 10 */
|
||||
if (radix < 10) {
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
do {
|
||||
rem = unum % radix;
|
||||
if (rem < 0xa)
|
||||
|
|
|
@ -6,11 +6,10 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <common/debug.h>
|
||||
#include <plat/common/platform.h>
|
||||
|
||||
#define get_num_va_args(_args, _lcount) \
|
||||
(((_lcount) > 1) ? va_arg(_args, long long int) : \
|
||||
(((_lcount) == 1) ? va_arg(_args, long int) : \
|
||||
|
@ -51,10 +50,10 @@ static void unsigned_num_print(char **s, size_t n, size_t *chars_printed,
|
|||
unsigned int rem;
|
||||
char ascii_a = capitalise ? 'A' : 'a';
|
||||
|
||||
/* num_buf is only large enough for radix >= 10 */
|
||||
if (radix < 10) {
|
||||
ERROR("snprintf: unsupported radix '%u'.", radix);
|
||||
plat_panic_handler();
|
||||
assert(0); /* Unreachable */
|
||||
assert(0);
|
||||
return;
|
||||
}
|
||||
|
||||
do {
|
||||
|
@ -218,11 +217,8 @@ loop:
|
|||
break;
|
||||
|
||||
default:
|
||||
/* Panic on any other format specifier. */
|
||||
ERROR("snprintf: specifier with ASCII code '%d' not supported.",
|
||||
*fmt);
|
||||
plat_panic_handler();
|
||||
assert(0); /* Unreachable */
|
||||
CHECK_AND_PUT_CHAR(s, n, chars_printed, '%');
|
||||
CHECK_AND_PUT_CHAR(s, n, chars_printed, *fmt);
|
||||
}
|
||||
fmt++;
|
||||
continue;
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include <common/debug.h>
|
||||
#include <lib/optee_utils.h>
|
||||
|
||||
#include <platform_def.h>
|
||||
|
||||
/*
|
||||
* load_addr_hi and load_addr_lo: image load address.
|
||||
* image_id: 0 - pager, 1 - paged
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <assert.h>
|
||||
#include <platform_def.h>
|
||||
|
||||
#include <common/debug.h>
|
||||
#include <common/interrupt_props.h>
|
||||
#include <drivers/arm/gicv3.h>
|
||||
#include <fconf_hw_config_getter.h>
|
||||
|
|
|
@ -196,12 +196,6 @@
|
|||
# define PLATFORM_STACK_SIZE UL(0x440)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Since free SRAM space is scant, enable the ASSERTION message size
|
||||
* optimization by fixing the PLAT_LOG_LEVEL_ASSERT to LOG_LEVEL_INFO (40).
|
||||
*/
|
||||
#define PLAT_LOG_LEVEL_ASSERT 40
|
||||
|
||||
/* CCI related constants */
|
||||
#define PLAT_ARM_CCI_BASE UL(0x2c090000)
|
||||
#define PLAT_ARM_CCI_CLUSTER0_SL_IFACE_IX 4
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <arch.h>
|
||||
#include <bl1/bl1.h>
|
||||
#include <common/bl_common.h>
|
||||
#include <common/debug.h>
|
||||
#include <lib/fconf/fconf.h>
|
||||
#include <lib/fconf/fconf_dyn_cfg_getter.h>
|
||||
#include <lib/utils.h>
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <assert.h>
|
||||
|
||||
#include <common/debug.h>
|
||||
#if MEASURED_BOOT
|
||||
#include <common/desc_image_load.h>
|
||||
#endif
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <assert.h>
|
||||
#include <platform_def.h>
|
||||
|
||||
#include <common/debug.h>
|
||||
#include <common/interrupt_props.h>
|
||||
#include <drivers/arm/gicv3.h>
|
||||
#include <lib/utils.h>
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define CMN_PLAT_DEF_H
|
||||
|
||||
#include <bcm_elog.h>
|
||||
#include <platform_def.h>
|
||||
|
||||
#ifndef GET_LOG_LEVEL
|
||||
#define GET_LOG_LEVEL() LOG_LEVEL
|
||||
|
@ -57,9 +58,6 @@
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
/* Print file and line number on assert */
|
||||
#define PLAT_LOG_LEVEL_ASSERT LOG_LEVEL_INFO
|
||||
|
||||
/*
|
||||
* The number of regions like RO(code), coherent and data required by
|
||||
* different BL stages which need to be mapped in the MMU.
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include <arch_helpers.h>
|
||||
#include <common/debug.h>
|
||||
#include <drivers/console.h>
|
||||
#if RAS_EXTENSION
|
||||
#include <lib/extensions/ras.h>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <arch_helpers.h>
|
||||
#include <common/bl_common.h>
|
||||
#include <common/debug.h>
|
||||
#include <bl31/interrupt_mgmt.h>
|
||||
#include <drivers/arm/gic_common.h>
|
||||
#include <drivers/arm/gicv3.h>
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#endif
|
||||
#include <common/fdt_wrappers.h>
|
||||
#include <libfdt.h>
|
||||
#include <platform_def.h>
|
||||
|
||||
#define DTB_PROP_HW_LOG_ADDR "tpm_event_log_addr"
|
||||
#define DTB_PROP_HW_LOG_SIZE "tpm_event_log_size"
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <platform_def.h>
|
||||
#include <common/debug.h>
|
||||
#ifndef NXP_COINED_BB
|
||||
#include <flash_info.h>
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include <lib/utils.h>
|
||||
|
||||
#include <errata.h>
|
||||
#include "platform_def.h"
|
||||
|
||||
static const struct rc_timing rce[] = {
|
||||
{U(1600), U(8), U(7)},
|
||||
|
|
|
@ -6,10 +6,12 @@
|
|||
|
||||
#include <assert.h>
|
||||
|
||||
#include <common/bl_common.h>
|
||||
#if MEASURED_BOOT
|
||||
#include <common/desc_image_load.h>
|
||||
#endif
|
||||
#include <common/fdt_wrappers.h>
|
||||
#include <platform_def.h>
|
||||
|
||||
#include <libfdt.h>
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#ifndef PLAT_STARTUP_H
|
||||
#define PLAT_STARTUP_H
|
||||
|
||||
#include <common/bl_common.h>
|
||||
|
||||
/* For FSBL handover */
|
||||
enum fsbl_handoff {
|
||||
FSBL_HANDOFF_SUCCESS = 0,
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <common/bl_common.h>
|
||||
#include <lib/psci/psci.h>
|
||||
#include <lib/spinlock.h>
|
||||
#include <services/el3_spmc_logical_sp.h>
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#ifndef SPMD_PRIVATE_H
|
||||
#define SPMD_PRIVATE_H
|
||||
|
||||
#include <common/bl_common.h>
|
||||
#include <context.h>
|
||||
|
||||
/*******************************************************************************
|
||||
|
|
Loading…
Add table
Reference in a new issue