Browse Source

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
pull/1988/head
Claus Pedersen 2 years ago
committed by André Przywara
parent
commit
885e268304
  1. 1
      drivers/amlogic/crypto/sha_dma.c
  2. 1
      drivers/arm/gic/v3/gic-x00.c
  3. 2
      drivers/arm/gic/v3/gicv3_helpers.c
  4. 2
      drivers/auth/cryptocell/713/cryptocell_crypto.c
  5. 1
      drivers/console/multi_console.c
  6. 1
      drivers/measured_boot/rss/rss_measured_boot.c
  7. 1
      drivers/rpi3/gpio/rpi3_gpio.c
  8. 2
      include/bl32/sp_min/platform_sp_min.h
  9. 1
      include/lib/fconf/fconf.h
  10. 11
      include/lib/libc/assert.h
  11. 1
      include/plat/arm/common/fconf_arm_sp_getter.h
  12. 1
      include/plat/marvell/armada/a8k/common/plat_marvell.h
  13. 1
      lib/el3_runtime/aarch64/context_mgmt.c
  14. 2
      lib/fconf/fconf_dyn_cfg_getter.c
  15. 11
      lib/libc/assert.c
  16. 8
      lib/libc/printf.c
  17. 18
      lib/libc/snprintf.c
  18. 2
      lib/optee/optee_utils.c
  19. 1
      plat/arm/board/fvp/fvp_gicv3.c
  20. 6
      plat/arm/board/juno/include/platform_def.h
  21. 1
      plat/arm/common/arm_bl1_setup.c
  22. 1
      plat/arm/common/arm_dyn_cfg_helpers.c
  23. 1
      plat/arm/common/arm_gicv3.c
  24. 4
      plat/brcm/board/common/cmn_plat_def.h
  25. 1
      plat/common/aarch64/plat_common.c
  26. 1
      plat/common/plat_gicv3.c
  27. 1
      plat/imx/imx8m/imx8m_dyn_cfg_helpers.c
  28. 1
      plat/nxp/common/nv_storage/plat_nv_storage.c
  29. 1
      plat/nxp/soc-ls1046a/ls1046aqds/ddr_init.c
  30. 2
      plat/qemu/qemu/qemu_helpers.c
  31. 2
      plat/xilinx/common/include/plat_startup.h
  32. 1
      services/std_svc/spm/el3_spmc/spmc.h
  33. 1
      services/std_svc/spmd/spmd_private.h

1
drivers/amlogic/crypto/sha_dma.c

@ -8,6 +8,7 @@
#include <assert.h>
#include <crypto/sha_dma.h>
#include <lib/mmio.h>
#include <platform_def.h>
#include "aml_private.h"

1
drivers/arm/gic/v3/gic-x00.c

@ -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>

2
drivers/arm/gic/v3/gicv3_helpers.c

@ -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"

2
drivers/auth/cryptocell/713/cryptocell_crypto.c

@ -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>

1
drivers/console/multi_console.c

@ -5,6 +5,7 @@
*/
#include <assert.h>
#include <stddef.h>
#include <drivers/console.h>

1
drivers/measured_boot/rss/rss_measured_boot.c

@ -5,6 +5,7 @@
*/
#include <assert.h>
#include <stdint.h>
#include <string.h>
#include <common/debug.h>
#include <drivers/auth/crypto_mod.h>

1
drivers/rpi3/gpio/rpi3_gpio.c

@ -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;

2
include/bl32/sp_min/platform_sp_min.h

@ -9,6 +9,8 @@
#include <stdint.h>
#include <common/bl_common.h>
/*******************************************************************************
* Mandatory SP_MIN functions
******************************************************************************/

1
include/lib/fconf/fconf.h

@ -7,6 +7,7 @@
#ifndef FCONF_H
#define FCONF_H
#include <stddef.h>
#include <stdint.h>
/* Public API */

11
include/lib/libc/assert.h

@ -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);

1
include/plat/arm/common/fconf_arm_sp_getter.h

@ -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>

1
include/plat/marvell/armada/a8k/common/plat_marvell.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>

1
lib/el3_runtime/aarch64/context_mgmt.c

@ -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>

2
lib/fconf/fconf_dyn_cfg_getter.c

@ -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)
/*

11
lib/libc/assert.c

@ -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);

8
lib/libc/printf.c

@ -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)

18
lib/libc/snprintf.c

@ -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;

2
lib/optee/optee_utils.c

@ -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

1
plat/arm/board/fvp/fvp_gicv3.c

@ -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>

6
plat/arm/board/juno/include/platform_def.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

1
plat/arm/common/arm_bl1_setup.c

@ -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>

1
plat/arm/common/arm_dyn_cfg_helpers.c

@ -6,6 +6,7 @@
#include <assert.h>
#include <common/debug.h>
#if MEASURED_BOOT
#include <common/desc_image_load.h>
#endif

1
plat/arm/common/arm_gicv3.c

@ -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>

4
plat/brcm/board/common/cmn_plat_def.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.

1
plat/common/aarch64/plat_common.c

@ -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>

1
plat/common/plat_gicv3.c

@ -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>

1
plat/imx/imx8m/imx8m_dyn_cfg_helpers.c

@ -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"

1
plat/nxp/common/nv_storage/plat_nv_storage.c

@ -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>

1
plat/nxp/soc-ls1046a/ls1046aqds/ddr_init.c

@ -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)},

2
plat/qemu/qemu/qemu_helpers.c

@ -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>

2
plat/xilinx/common/include/plat_startup.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,

1
services/std_svc/spm/el3_spmc/spmc.h

@ -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>

1
services/std_svc/spmd/spmd_private.h

@ -7,6 +7,7 @@
#ifndef SPMD_PRIVATE_H
#define SPMD_PRIVATE_H
#include <common/bl_common.h>
#include <context.h>
/*******************************************************************************

Loading…
Cancel
Save