mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-18 10:34:19 +00:00
Merge pull request #1510 from robertovargas-arm/romlib
Add support for moving libraries to ROM
This commit is contained in:
commit
3ba9295715
76 changed files with 642 additions and 140 deletions
29
Makefile
29
Makefile
|
@ -45,7 +45,7 @@ CHECKCODE_ARGS := --no-patch
|
|||
# Do not check the coding style on imported library files or documentation files
|
||||
INC_LIB_DIRS_TO_CHECK := $(sort $(filter-out \
|
||||
include/lib/libfdt \
|
||||
include/lib/stdlib, \
|
||||
include/lib/libc, \
|
||||
$(wildcard include/lib/*)))
|
||||
INC_DIRS_TO_CHECK := $(sort $(filter-out \
|
||||
include/lib, \
|
||||
|
@ -53,7 +53,7 @@ INC_DIRS_TO_CHECK := $(sort $(filter-out \
|
|||
LIB_DIRS_TO_CHECK := $(sort $(filter-out \
|
||||
lib/compiler-rt \
|
||||
lib/libfdt% \
|
||||
lib/stdlib, \
|
||||
lib/libc, \
|
||||
$(wildcard lib/*)))
|
||||
ROOT_DIRS_TO_CHECK := $(sort $(filter-out \
|
||||
lib \
|
||||
|
@ -172,7 +172,7 @@ TF_CFLAGS_aarch64 += -mgeneral-regs-only -mstrict-align
|
|||
ASFLAGS_aarch32 = $(march32-directive)
|
||||
ASFLAGS_aarch64 = -march=armv8-a
|
||||
|
||||
CPPFLAGS = ${DEFINES} ${INCLUDES} -nostdinc \
|
||||
CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
|
||||
-Wmissing-include-dirs -Werror
|
||||
ASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \
|
||||
-D__ASSEMBLY__ -ffreestanding \
|
||||
|
@ -198,7 +198,7 @@ DTC_FLAGS += -I dts -O dtb
|
|||
# Common sources and include directories
|
||||
################################################################################
|
||||
include lib/compiler-rt/compiler-rt.mk
|
||||
include lib/stdlib/stdlib.mk
|
||||
include lib/libc/libc.mk
|
||||
|
||||
BL_COMMON_SOURCES += common/bl_common.c \
|
||||
common/tf_log.c \
|
||||
|
@ -211,8 +211,7 @@ BL_COMMON_SOURCES += common/bl_common.c \
|
|||
plat/common/plat_log_common.c \
|
||||
plat/common/${ARCH}/plat_common.c \
|
||||
plat/common/${ARCH}/platform_helpers.S \
|
||||
${COMPILER_RT_SRCS} \
|
||||
${STDLIB_SRCS}
|
||||
${COMPILER_RT_SRCS}
|
||||
|
||||
INCLUDES += -Iinclude \
|
||||
-Iinclude/bl1 \
|
||||
|
@ -506,6 +505,9 @@ CRTTOOL ?= ${CRTTOOLPATH}/cert_create${BIN_EXT}
|
|||
FIPTOOLPATH ?= tools/fiptool
|
||||
FIPTOOL ?= ${FIPTOOLPATH}/fiptool${BIN_EXT}
|
||||
|
||||
# Variables for use with ROMLIB
|
||||
ROMLIBPATH ?= lib/romlib
|
||||
|
||||
################################################################################
|
||||
# Include BL specific makefiles
|
||||
################################################################################
|
||||
|
@ -574,6 +576,7 @@ $(eval $(call assert_boolean,SEPARATE_CODE_AND_RODATA))
|
|||
$(eval $(call assert_boolean,SPIN_ON_BL1_EXIT))
|
||||
$(eval $(call assert_boolean,TRUSTED_BOARD_BOOT))
|
||||
$(eval $(call assert_boolean,USE_COHERENT_MEM))
|
||||
$(eval $(call assert_boolean,USE_ROMLIB))
|
||||
$(eval $(call assert_boolean,USE_TBBR_DEFS))
|
||||
$(eval $(call assert_boolean,WARMBOOT_ENABLE_DCACHE_EARLY))
|
||||
$(eval $(call assert_boolean,BL2_AT_EL3))
|
||||
|
@ -626,6 +629,7 @@ $(eval $(call add_define,SPD_${SPD}))
|
|||
$(eval $(call add_define,SPIN_ON_BL1_EXIT))
|
||||
$(eval $(call add_define,TRUSTED_BOARD_BOOT))
|
||||
$(eval $(call add_define,USE_COHERENT_MEM))
|
||||
$(eval $(call add_define,USE_ROMLIB))
|
||||
$(eval $(call add_define,USE_TBBR_DEFS))
|
||||
$(eval $(call add_define,WARMBOOT_ENABLE_DCACHE_EARLY))
|
||||
$(eval $(call add_define,BL2_AT_EL3))
|
||||
|
@ -670,6 +674,9 @@ ifeq (${ERROR_DEPRECATED},0)
|
|||
CPPFLAGS += -Wno-error=deprecated-declarations -Wno-error=cpp
|
||||
endif
|
||||
|
||||
$(eval $(call MAKE_LIB_DIRS))
|
||||
$(eval $(call MAKE_LIB,c))
|
||||
|
||||
# Expand build macros for the different images
|
||||
ifeq (${NEED_BL1},yes)
|
||||
$(eval $(call MAKE_BL,1))
|
||||
|
@ -734,6 +741,7 @@ clean:
|
|||
$(call SHELL_REMOVE_DIR,${BUILD_PLAT})
|
||||
${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
|
||||
${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
|
||||
${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
|
||||
|
||||
realclean distclean:
|
||||
@echo " REALCLEAN"
|
||||
|
@ -741,11 +749,12 @@ realclean distclean:
|
|||
$(call SHELL_DELETE_ALL, ${CURDIR}/cscope.*)
|
||||
${Q}${MAKE} --no-print-directory -C ${FIPTOOLPATH} clean
|
||||
${Q}${MAKE} PLAT=${PLAT} --no-print-directory -C ${CRTTOOLPATH} clean
|
||||
${Q}${MAKE} --no-print-directory -C ${ROMLIBPATH} clean
|
||||
|
||||
checkcodebase: locate-checkpatch
|
||||
@echo " CHECKING STYLE"
|
||||
@if test -d .git ; then \
|
||||
git ls-files | grep -E -v 'libfdt|stdlib|docs|\.md' | \
|
||||
git ls-files | grep -E -v 'libfdt|libc|docs|\.md' | \
|
||||
while read GIT_FILE ; \
|
||||
do ${CHECKPATCH} ${CHECKCODE_ARGS} -f $$GIT_FILE ; \
|
||||
done ; \
|
||||
|
@ -753,7 +762,7 @@ checkcodebase: locate-checkpatch
|
|||
find . -type f -not -iwholename "*.git*" \
|
||||
-not -iwholename "*build*" \
|
||||
-not -iwholename "*libfdt*" \
|
||||
-not -iwholename "*stdlib*" \
|
||||
-not -iwholename "*libc*" \
|
||||
-not -iwholename "*docs*" \
|
||||
-not -iwholename "*.md" \
|
||||
-exec ${CHECKPATCH} ${CHECKCODE_ARGS} -f {} \; ; \
|
||||
|
@ -819,6 +828,10 @@ fwu_fip: ${BUILD_PLAT}/${FWU_FIP_NAME}
|
|||
${FIPTOOL}:
|
||||
${Q}${MAKE} CPPFLAGS="-DVERSION='\"${VERSION_STRING}\"'" --no-print-directory -C ${FIPTOOLPATH}
|
||||
|
||||
.PHONY: libraries
|
||||
romlib.bin: libraries
|
||||
${Q}${MAKE} BUILD_PLAT=${BUILD_PLAT} INCLUDES='${INCLUDES}' DEFINES='${DEFINES}' --no-print-directory -C ${ROMLIBPATH} all
|
||||
|
||||
cscope:
|
||||
@echo " CSCOPE"
|
||||
${Q}find ${CURDIR} -name "*.[chsS]" > cscope.files
|
||||
|
|
|
@ -14,9 +14,7 @@ BL1_SOURCES += bl1/bl1_main.c \
|
|||
lib/el3_runtime/${ARCH}/context_mgmt.c \
|
||||
plat/common/plat_bl1_common.c \
|
||||
plat/common/${ARCH}/platform_up_stack.S \
|
||||
${MBEDTLS_COMMON_SOURCES} \
|
||||
${MBEDTLS_CRYPTO_SOURCES} \
|
||||
${MBEDTLS_X509_SOURCES}
|
||||
${MBEDTLS_SOURCES}
|
||||
|
||||
ifeq (${ARCH},aarch64)
|
||||
BL1_SOURCES += lib/el3_runtime/aarch64/context.S
|
||||
|
|
|
@ -8,9 +8,7 @@ BL2_SOURCES += bl2/bl2_main.c \
|
|||
bl2/${ARCH}/bl2_arch_setup.c \
|
||||
lib/locks/exclusive/${ARCH}/spinlock.S \
|
||||
plat/common/${ARCH}/platform_up_stack.S \
|
||||
${MBEDTLS_COMMON_SOURCES} \
|
||||
${MBEDTLS_CRYPTO_SOURCES} \
|
||||
${MBEDTLS_X509_SOURCES}
|
||||
${MBEDTLS_SOURCES}
|
||||
|
||||
ifeq (${ARCH},aarch64)
|
||||
BL2_SOURCES += common/aarch64/early_exceptions.S
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include <platform_def.h>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* This function is responsible to:
|
||||
* Load SCP_BL2U if platform has defined SCP_BL2U_BASE
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <debug.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* mbed TLS headers */
|
||||
#include <mbedtls/memory_buffer_alloc.h>
|
||||
|
@ -23,6 +24,12 @@
|
|||
#endif
|
||||
static unsigned char heap[MBEDTLS_HEAP_SIZE];
|
||||
|
||||
static void cleanup(void)
|
||||
{
|
||||
ERROR("EXIT from BL2\n");
|
||||
panic();
|
||||
}
|
||||
|
||||
/*
|
||||
* mbed TLS initialization function
|
||||
*/
|
||||
|
@ -31,6 +38,9 @@ void mbedtls_init(void)
|
|||
static int ready;
|
||||
|
||||
if (!ready) {
|
||||
if (atexit(cleanup))
|
||||
panic();
|
||||
|
||||
/* Initialize the mbed TLS heap */
|
||||
mbedtls_memory_buffer_alloc_init(heap, MBEDTLS_HEAP_SIZE);
|
||||
|
||||
|
|
|
@ -13,22 +13,86 @@ ifeq (${MBEDTLS_DIR},)
|
|||
$(error Error: MBEDTLS_DIR not set)
|
||||
endif
|
||||
|
||||
INCLUDES += -I${MBEDTLS_DIR}/include \
|
||||
-Iinclude/drivers/auth/mbedtls
|
||||
MBEDTLS_INC = -I${MBEDTLS_DIR}/include
|
||||
INCLUDES += -Iinclude/drivers/auth/mbedtls
|
||||
|
||||
# Specify mbed TLS configuration file
|
||||
MBEDTLS_CONFIG_FILE := "<mbedtls_config.h>"
|
||||
$(eval $(call add_define,MBEDTLS_CONFIG_FILE))
|
||||
|
||||
MBEDTLS_COMMON_SOURCES := drivers/auth/mbedtls/mbedtls_common.c \
|
||||
$(addprefix ${MBEDTLS_DIR}/library/, \
|
||||
asn1parse.c \
|
||||
asn1write.c \
|
||||
memory_buffer_alloc.c \
|
||||
oid.c \
|
||||
platform.c \
|
||||
platform_util.c \
|
||||
rsa_internal.c \
|
||||
)
|
||||
MBEDTLS_SOURCES += drivers/auth/mbedtls/mbedtls_common.c
|
||||
|
||||
|
||||
LIBMBEDTLS_SRCS := $(addprefix ${MBEDTLS_DIR}/library/, \
|
||||
asn1parse.c \
|
||||
asn1write.c \
|
||||
memory_buffer_alloc.c \
|
||||
oid.c \
|
||||
platform.c \
|
||||
platform_util.c \
|
||||
bignum.c \
|
||||
md.c \
|
||||
md_wrap.c \
|
||||
pk.c \
|
||||
pk_wrap.c \
|
||||
pkparse.c \
|
||||
pkwrite.c \
|
||||
sha256.c \
|
||||
sha512.c \
|
||||
ecdsa.c \
|
||||
ecp_curves.c \
|
||||
ecp.c \
|
||||
rsa.c \
|
||||
rsa_internal.c \
|
||||
x509.c \
|
||||
x509_crt.c \
|
||||
)
|
||||
|
||||
# The platform may define the variable 'TF_MBEDTLS_KEY_ALG' to select the key
|
||||
# algorithm to use. If the variable is not defined, select it based on algorithm
|
||||
# used for key generation `KEY_ALG`. If `KEY_ALG` is not defined or is
|
||||
# defined to `rsa`/`rsa_1_5`, then set the variable to `rsa`.
|
||||
ifeq (${TF_MBEDTLS_KEY_ALG},)
|
||||
ifeq (${KEY_ALG}, ecdsa)
|
||||
TF_MBEDTLS_KEY_ALG := ecdsa
|
||||
else
|
||||
TF_MBEDTLS_KEY_ALG := rsa
|
||||
endif
|
||||
endif
|
||||
|
||||
# If MBEDTLS_KEY_ALG build flag is defined use it to set TF_MBEDTLS_KEY_ALG for
|
||||
# backward compatibility
|
||||
ifdef MBEDTLS_KEY_ALG
|
||||
ifeq (${ERROR_DEPRECATED},1)
|
||||
$(error "MBEDTLS_KEY_ALG is deprecated. Please use the new build flag TF_MBEDTLS_KEY_ALG")
|
||||
endif
|
||||
$(warning "MBEDTLS_KEY_ALG is deprecated. Please use the new build flag TF_MBEDTLS_KEY_ALG")
|
||||
TF_MBEDTLS_KEY_ALG := ${MBEDTLS_KEY_ALG}
|
||||
endif
|
||||
|
||||
ifeq (${HASH_ALG}, sha384)
|
||||
TF_MBEDTLS_HASH_ALG_ID := TF_MBEDTLS_SHA384
|
||||
else ifeq (${HASH_ALG}, sha512)
|
||||
TF_MBEDTLS_HASH_ALG_ID := TF_MBEDTLS_SHA512
|
||||
else
|
||||
TF_MBEDTLS_HASH_ALG_ID := TF_MBEDTLS_SHA256
|
||||
endif
|
||||
|
||||
ifeq (${TF_MBEDTLS_KEY_ALG},ecdsa)
|
||||
TF_MBEDTLS_KEY_ALG_ID := TF_MBEDTLS_ECDSA
|
||||
else ifeq (${TF_MBEDTLS_KEY_ALG},rsa)
|
||||
TF_MBEDTLS_KEY_ALG_ID := TF_MBEDTLS_RSA
|
||||
else ifeq (${TF_MBEDTLS_KEY_ALG},rsa+ecdsa)
|
||||
TF_MBEDTLS_KEY_ALG_ID := TF_MBEDTLS_RSA_AND_ECDSA
|
||||
else
|
||||
$(error "TF_MBEDTLS_KEY_ALG=${TF_MBEDTLS_KEY_ALG} not supported on mbed TLS")
|
||||
endif
|
||||
|
||||
# Needs to be set to drive mbed TLS configuration correctly
|
||||
$(eval $(call add_define,TF_MBEDTLS_KEY_ALG_ID))
|
||||
$(eval $(call add_define,TF_MBEDTLS_HASH_ALG_ID))
|
||||
|
||||
|
||||
$(eval $(call MAKE_LIB,mbedtls))
|
||||
|
||||
endif
|
||||
|
|
|
@ -6,86 +6,6 @@
|
|||
|
||||
include drivers/auth/mbedtls/mbedtls_common.mk
|
||||
|
||||
# The platform may define the variable 'TF_MBEDTLS_KEY_ALG' to select the key
|
||||
# algorithm to use. If the variable is not defined, select it based on algorithm
|
||||
# used for key generation `KEY_ALG`. If `KEY_ALG` is not defined or is
|
||||
# defined to `rsa`/`rsa_1_5`, then set the variable to `rsa`.
|
||||
ifeq (${TF_MBEDTLS_KEY_ALG},)
|
||||
ifeq (${KEY_ALG}, ecdsa)
|
||||
TF_MBEDTLS_KEY_ALG := ecdsa
|
||||
else
|
||||
TF_MBEDTLS_KEY_ALG := rsa
|
||||
endif
|
||||
endif
|
||||
MBEDTLS_SOURCES += drivers/auth/mbedtls/mbedtls_crypto.c
|
||||
|
||||
# If MBEDTLS_KEY_ALG build flag is defined use it to set TF_MBEDTLS_KEY_ALG for
|
||||
# backward compatibility
|
||||
ifdef MBEDTLS_KEY_ALG
|
||||
ifeq (${ERROR_DEPRECATED},1)
|
||||
$(error "MBEDTLS_KEY_ALG is deprecated. Please use the new build flag TF_MBEDTLS_KEY_ALG")
|
||||
endif
|
||||
$(warning "MBEDTLS_KEY_ALG is deprecated. Please use the new build flag TF_MBEDTLS_KEY_ALG")
|
||||
TF_MBEDTLS_KEY_ALG := ${MBEDTLS_KEY_ALG}
|
||||
endif
|
||||
|
||||
MBEDTLS_CRYPTO_SOURCES := drivers/auth/mbedtls/mbedtls_crypto.c \
|
||||
$(addprefix ${MBEDTLS_DIR}/library/, \
|
||||
bignum.c \
|
||||
md.c \
|
||||
md_wrap.c \
|
||||
pk.c \
|
||||
pk_wrap.c \
|
||||
pkparse.c \
|
||||
pkwrite.c \
|
||||
)
|
||||
|
||||
ifeq (${HASH_ALG}, sha384)
|
||||
MBEDTLS_CRYPTO_SOURCES += \
|
||||
$(addprefix ${MBEDTLS_DIR}/library/, \
|
||||
sha256.c \
|
||||
sha512.c \
|
||||
)
|
||||
TF_MBEDTLS_HASH_ALG_ID := TF_MBEDTLS_SHA384
|
||||
else ifeq (${HASH_ALG}, sha512)
|
||||
MBEDTLS_CRYPTO_SOURCES += \
|
||||
$(addprefix ${MBEDTLS_DIR}/library/, \
|
||||
sha256.c \
|
||||
sha512.c \
|
||||
)
|
||||
TF_MBEDTLS_HASH_ALG_ID := TF_MBEDTLS_SHA512
|
||||
else
|
||||
MBEDTLS_CRYPTO_SOURCES += \
|
||||
$(addprefix ${MBEDTLS_DIR}/library/, \
|
||||
sha256.c \
|
||||
)
|
||||
TF_MBEDTLS_HASH_ALG_ID := TF_MBEDTLS_SHA256
|
||||
endif
|
||||
|
||||
# Key algorithm specific files
|
||||
MBEDTLS_ECDSA_CRYPTO_SOURCES += $(addprefix ${MBEDTLS_DIR}/library/, \
|
||||
ecdsa.c \
|
||||
ecp_curves.c \
|
||||
ecp.c \
|
||||
)
|
||||
|
||||
MBEDTLS_RSA_CRYPTO_SOURCES += $(addprefix ${MBEDTLS_DIR}/library/, \
|
||||
rsa.c \
|
||||
)
|
||||
|
||||
ifeq (${TF_MBEDTLS_KEY_ALG},ecdsa)
|
||||
MBEDTLS_CRYPTO_SOURCES += $(MBEDTLS_ECDSA_CRYPTO_SOURCES)
|
||||
TF_MBEDTLS_KEY_ALG_ID := TF_MBEDTLS_ECDSA
|
||||
else ifeq (${TF_MBEDTLS_KEY_ALG},rsa)
|
||||
MBEDTLS_CRYPTO_SOURCES += $(MBEDTLS_RSA_CRYPTO_SOURCES)
|
||||
TF_MBEDTLS_KEY_ALG_ID := TF_MBEDTLS_RSA
|
||||
else ifeq (${TF_MBEDTLS_KEY_ALG},rsa+ecdsa)
|
||||
MBEDTLS_CRYPTO_SOURCES += $(MBEDTLS_ECDSA_CRYPTO_SOURCES)
|
||||
MBEDTLS_CRYPTO_SOURCES += $(MBEDTLS_RSA_CRYPTO_SOURCES)
|
||||
TF_MBEDTLS_KEY_ALG_ID := TF_MBEDTLS_RSA_AND_ECDSA
|
||||
else
|
||||
$(error "TF_MBEDTLS_KEY_ALG=${TF_MBEDTLS_KEY_ALG} not supported on mbed TLS")
|
||||
endif
|
||||
|
||||
# Needs to be set to drive mbed TLS configuration correctly
|
||||
$(eval $(call add_define,TF_MBEDTLS_KEY_ALG_ID))
|
||||
$(eval $(call add_define,TF_MBEDTLS_HASH_ALG_ID))
|
||||
|
|
|
@ -6,8 +6,4 @@
|
|||
|
||||
include drivers/auth/mbedtls/mbedtls_common.mk
|
||||
|
||||
MBEDTLS_X509_SOURCES := drivers/auth/mbedtls/mbedtls_x509_parser.c \
|
||||
$(addprefix ${MBEDTLS_DIR}/library/, \
|
||||
x509.c \
|
||||
x509_crt.c \
|
||||
)
|
||||
MBEDTLS_SOURCES += drivers/auth/mbedtls/mbedtls_x509_parser.c
|
||||
|
|
15
include/common/romlib.h
Normal file
15
include/common/romlib.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef ROMLIB_H_
|
||||
|
||||
#define ROMLIB_MAJOR 0
|
||||
#define ROMLIB_MINOR 1
|
||||
#define ROMLIB_VERSION ((ROMLIB_MAJOR << 8) | ROMLIB_MINOR)
|
||||
|
||||
int rom_lib_init(int version);
|
||||
|
||||
#endif
|
|
@ -71,9 +71,12 @@
|
|||
#elif defined(IMAGE_BL32)
|
||||
# define PLAT_ARM_MMAP_ENTRIES 8
|
||||
# define MAX_XLAT_TABLES 5
|
||||
#else
|
||||
#elif !USE_ROMLIB
|
||||
# define PLAT_ARM_MMAP_ENTRIES 11
|
||||
# define MAX_XLAT_TABLES 5
|
||||
#else
|
||||
# define PLAT_ARM_MMAP_ENTRIES 12
|
||||
# define MAX_XLAT_TABLES 6
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -82,6 +85,18 @@
|
|||
*/
|
||||
#define PLAT_ARM_MAX_BL1_RW_SIZE 0xB000
|
||||
|
||||
/*
|
||||
* PLAT_ARM_MAX_ROMLIB_RW_SIZE is define to use a full page
|
||||
*/
|
||||
|
||||
#if USE_ROMLIB
|
||||
#define PLAT_ARM_MAX_ROMLIB_RW_SIZE 0x1000
|
||||
#define PLAT_ARM_MAX_ROMLIB_RO_SIZE 0xe000
|
||||
#else
|
||||
#define PLAT_ARM_MAX_ROMLIB_RW_SIZE 0
|
||||
#define PLAT_ARM_MAX_ROMLIB_RO_SIZE 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PLAT_ARM_MAX_BL2_SIZE is calculated using the current BL2 debug size plus a
|
||||
* little space for growth.
|
||||
|
|
|
@ -268,6 +268,17 @@
|
|||
- BL_COHERENT_RAM_BASE, \
|
||||
MT_DEVICE | MT_RW | MT_SECURE)
|
||||
#endif
|
||||
#if USE_ROMLIB
|
||||
#define ARM_MAP_ROMLIB_CODE MAP_REGION_FLAT( \
|
||||
ROMLIB_RO_BASE, \
|
||||
ROMLIB_RO_LIMIT - ROMLIB_RO_BASE,\
|
||||
MT_CODE | MT_SECURE)
|
||||
|
||||
#define ARM_MAP_ROMLIB_DATA MAP_REGION_FLAT( \
|
||||
ROMLIB_RW_BASE, \
|
||||
ROMLIB_RW_END - ROMLIB_RW_BASE,\
|
||||
MT_MEMORY | MT_RW | MT_SECURE)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The max number of regions like RO(code), coherent and data required by
|
||||
|
@ -346,14 +357,23 @@
|
|||
******************************************************************************/
|
||||
#define BL1_RO_BASE PLAT_ARM_TRUSTED_ROM_BASE
|
||||
#define BL1_RO_LIMIT (PLAT_ARM_TRUSTED_ROM_BASE \
|
||||
+ PLAT_ARM_TRUSTED_ROM_SIZE)
|
||||
+ (PLAT_ARM_TRUSTED_ROM_SIZE - \
|
||||
PLAT_ARM_MAX_ROMLIB_RO_SIZE))
|
||||
/*
|
||||
* Put BL1 RW at the top of the Trusted SRAM.
|
||||
*/
|
||||
#define BL1_RW_BASE (ARM_BL_RAM_BASE + \
|
||||
ARM_BL_RAM_SIZE - \
|
||||
PLAT_ARM_MAX_BL1_RW_SIZE)
|
||||
#define BL1_RW_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
|
||||
(PLAT_ARM_MAX_BL1_RW_SIZE +\
|
||||
PLAT_ARM_MAX_ROMLIB_RW_SIZE))
|
||||
#define BL1_RW_LIMIT (ARM_BL_RAM_BASE + \
|
||||
(ARM_BL_RAM_SIZE - PLAT_ARM_MAX_ROMLIB_RW_SIZE))
|
||||
|
||||
#define ROMLIB_RO_BASE BL1_RO_LIMIT
|
||||
#define ROMLIB_RO_LIMIT (PLAT_ARM_TRUSTED_ROM_BASE + PLAT_ARM_TRUSTED_ROM_SIZE)
|
||||
|
||||
#define ROMLIB_RW_BASE (BL1_RW_BASE + PLAT_ARM_MAX_BL1_RW_SIZE)
|
||||
#define ROMLIB_RW_END (ROMLIB_RW_BASE + PLAT_ARM_MAX_ROMLIB_RW_SIZE)
|
||||
|
||||
/*******************************************************************************
|
||||
* BL2 specific defines.
|
||||
|
|
|
@ -72,6 +72,8 @@ typedef struct arm_tzc_regions_info {
|
|||
void arm_setup_page_tables(const mmap_region_t bl_regions[],
|
||||
const mmap_region_t plat_regions[]);
|
||||
|
||||
void arm_setup_romlib(void);
|
||||
|
||||
#if defined(IMAGE_BL31) || (defined(AARCH32) && defined(IMAGE_BL32))
|
||||
/*
|
||||
* Use this macro to instantiate lock before it is used in below
|
||||
|
|
26
lib/libc/exit.c
Normal file
26
lib/libc/exit.c
Normal file
|
@ -0,0 +1,26 @@
|
|||
/*
|
||||
* Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
static void (*exitfun)(void);
|
||||
|
||||
void exit(int status)
|
||||
{
|
||||
if (exitfun)
|
||||
(*exitfun)();
|
||||
for (;;)
|
||||
;
|
||||
}
|
||||
|
||||
int atexit(void (*fun)(void))
|
||||
{
|
||||
if (exitfun)
|
||||
return -1;
|
||||
exitfun = fun;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -4,7 +4,7 @@
|
|||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
STDLIB_SRCS := $(addprefix lib/stdlib/, \
|
||||
LIBC_SRCS := $(addprefix lib/libc/, \
|
||||
abort.c \
|
||||
assert.c \
|
||||
exit.c \
|
||||
|
@ -21,5 +21,5 @@ STDLIB_SRCS := $(addprefix lib/stdlib/, \
|
|||
subr_prf.c \
|
||||
timingsafe_bcmp.c)
|
||||
|
||||
INCLUDES += -Iinclude/lib/stdlib \
|
||||
-Iinclude/lib/stdlib/sys
|
||||
INCLUDES += -Iinclude/lib/libc \
|
||||
-Iinclude/lib/libc/sys
|
|
@ -15,3 +15,5 @@ LIBFDT_SRCS := $(addprefix lib/libfdt/, \
|
|||
fdt_wip.c) \
|
||||
|
||||
INCLUDES += -Iinclude/lib/libfdt
|
||||
|
||||
$(eval $(call MAKE_LIB,fdt))
|
||||
|
|
71
lib/romlib/Makefile
Normal file
71
lib/romlib/Makefile
Normal file
|
@ -0,0 +1,71 @@
|
|||
#
|
||||
# Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
AS = $(CROSS_COMPILE)as
|
||||
LD = $(CROSS_COMPILE)ld
|
||||
OC = $(CROSS_COMPILE)objcopy
|
||||
CPP = $(CROSS_COMPILE)cpp
|
||||
BUILD_DIR = ../../$(BUILD_PLAT)/romlib
|
||||
LIB_DIR = ../../$(BUILD_PLAT)/lib
|
||||
WRAPPER_DIR = ../../$(BUILD_PLAT)/libwrapper
|
||||
LIBS = -lmbedtls -lfdt -lc
|
||||
INC = $(INCLUDES:-I%=-I../../%)
|
||||
PPFLAGS = $(INC) $(DEFINES) -P -D__ASSEMBLY__ -D__LINKER__ -MD -MP -MT $(BUILD_DIR)/romlib.ld
|
||||
OBJS = $(BUILD_DIR)/jmptbl.o $(BUILD_DIR)/init.o
|
||||
|
||||
V ?= 0
|
||||
ifeq ($(V),0)
|
||||
Q := @
|
||||
else
|
||||
Q :=
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG),1)
|
||||
CFLAGS := -g
|
||||
LDFLAGS := -g
|
||||
endif
|
||||
|
||||
|
||||
.PHONY: all clean distclean
|
||||
|
||||
all: $(BUILD_DIR)/romlib.bin $(LIB_DIR)/libwrappers.a
|
||||
|
||||
%.o: %.s
|
||||
@echo " AS $@"
|
||||
$(Q)$(AS) $(ASFLAGS) -o $@ $<
|
||||
|
||||
$(BUILD_DIR)/%.o: %.s
|
||||
@echo " AS $@"
|
||||
$(Q)$(AS) $(ASFLAGS) -o $@ $<
|
||||
|
||||
$(BUILD_DIR)/romlib.ld: romlib.ld.S
|
||||
@echo " PP $@"
|
||||
$(Q)$(CPP) $(PPFLAGS) -o $@ romlib.ld.S
|
||||
|
||||
$(BUILD_DIR)/romlib.elf: $(OBJS) $(BUILD_DIR)/romlib.ld
|
||||
@echo " LD $@"
|
||||
$(Q)$(LD) -T $(BUILD_DIR)/romlib.ld -L$(LIB_DIR) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
|
||||
|
||||
$(BUILD_DIR)/romlib.bin: $(BUILD_DIR)/romlib.elf
|
||||
@echo " BIN $@"
|
||||
$(Q)$(OC) -O binary $(BUILD_DIR)/romlib.elf $@
|
||||
|
||||
$(WRAPPER_DIR)/jmpvar.s: $(BUILD_DIR)/romlib.elf
|
||||
@echo " VAR $@"
|
||||
$(Q)./genvar.sh -o $@ $(BUILD_DIR)/romlib.elf
|
||||
|
||||
$(LIB_DIR)/libwrappers.a: jmptbl.i $(WRAPPER_DIR)/jmpvar.o
|
||||
@echo " AR $@"
|
||||
$(Q)./genwrappers.sh -b $(WRAPPER_DIR) -o $@ jmptbl.i
|
||||
|
||||
$(BUILD_DIR)/jmptbl.s: jmptbl.i
|
||||
@echo " TBL $@"
|
||||
$(Q)./gentbl.sh -o $@ jmptbl.i
|
||||
|
||||
clean:
|
||||
@rm -f $(BUILD_DIR)/*
|
||||
|
||||
-include $(BUILD_DIR)/romlib.d
|
40
lib/romlib/gentbl.sh
Executable file
40
lib/romlib/gentbl.sh
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/sh
|
||||
# Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
set -e
|
||||
|
||||
output=jmptbl.s
|
||||
|
||||
for i
|
||||
do
|
||||
case $i in
|
||||
-o)
|
||||
output=$2
|
||||
shift 2
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-*)
|
||||
echo usage: gentbl.sh [-o output] file ... >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
tmp=`mktemp`
|
||||
trap "rm -f $tmp" EXIT INT QUIT
|
||||
|
||||
rm -f $output
|
||||
|
||||
awk -v OFS="\n" '
|
||||
BEGIN {print "\t.text",
|
||||
"\t.globl\tjmptbl",
|
||||
"jmptbl:"}
|
||||
{sub(/[:blank:]*#.*/,"")}
|
||||
!/^$/ {print "\tb\t" $3}' "$@" > $tmp
|
||||
|
||||
mv $tmp $output
|
36
lib/romlib/genvar.sh
Executable file
36
lib/romlib/genvar.sh
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/bin/sh
|
||||
# Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
set -e
|
||||
|
||||
output=jmpvar.s
|
||||
for i
|
||||
do
|
||||
case $i in
|
||||
-o)
|
||||
output=$2
|
||||
shift 2
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-*)
|
||||
echo usage: genvar.sh [-o output] file... >&2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
tmp=`mktemp`
|
||||
trap "rm -f $tmp" EXIT INT QUIT
|
||||
|
||||
nm -a "$@" |
|
||||
awk -v OFS="\n" '
|
||||
$3 == ".text" {print "\t.data",
|
||||
"\t.globl\tjmptbl",
|
||||
"\t.align\t4",
|
||||
"jmptbl:\t.quad\t0x" $1}' > $tmp
|
||||
|
||||
mv $tmp $output
|
52
lib/romlib/genwrappers.sh
Executable file
52
lib/romlib/genwrappers.sh
Executable file
|
@ -0,0 +1,52 @@
|
|||
#!/bin/sh
|
||||
# Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
set -e
|
||||
|
||||
build=.
|
||||
out=output.a
|
||||
|
||||
for i
|
||||
do
|
||||
case $i in
|
||||
-o)
|
||||
out=$2
|
||||
shift 2
|
||||
;;
|
||||
-b)
|
||||
build=$2
|
||||
shift 2
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
-*)
|
||||
echo usage: genwrappers.sh [-o output] [-b dir] file ... >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
awk '{sub(/[:blank:]*#.*/,"")}
|
||||
!/^$/ {print $1*4, $2, $3}' "$@" |
|
||||
while read idx lib sym
|
||||
do
|
||||
file=$build/${lib}_$sym
|
||||
|
||||
cat <<EOF > $file.s
|
||||
.globl $sym
|
||||
$sym:
|
||||
ldr x17, =jmptbl
|
||||
ldr x17, [x17]
|
||||
mov x16, $idx
|
||||
add x16, x16, x17
|
||||
br x16
|
||||
EOF
|
||||
|
||||
${CROSS_COMPILE}as -o $file.o $file.s
|
||||
done
|
||||
|
||||
${CROSS_COMPILE}ar -rc $out $build/*.o
|
30
lib/romlib/init.s
Normal file
30
lib/romlib/init.s
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
.globl rom_lib_init
|
||||
.extern __DATA_RAM_START__, __DATA_ROM_START__, __DATA_SIZE__
|
||||
.extern memset, memcpy
|
||||
|
||||
rom_lib_init:
|
||||
cmp w0, #1
|
||||
mov w0, #0
|
||||
b.le 1f
|
||||
ret
|
||||
|
||||
1: stp x29, x30, [sp, #-16]!
|
||||
adrp x0, __DATA_RAM_START__
|
||||
ldr x1,= __DATA_ROM_START__
|
||||
ldr x2, =__DATA_SIZE__
|
||||
bl memcpy
|
||||
|
||||
ldr x0, =__BSS_START__
|
||||
mov x1, #0
|
||||
ldr x2, =__BSS_SIZE__
|
||||
bl memset
|
||||
ldp x29, x30, [sp], #16
|
||||
|
||||
mov w0, #1
|
||||
ret
|
35
lib/romlib/jmptbl.i
Normal file
35
lib/romlib/jmptbl.i
Normal file
|
@ -0,0 +1,35 @@
|
|||
#
|
||||
# Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
#
|
||||
|
||||
0 rom rom_lib_init
|
||||
1 fdt fdt_getprop_namelen
|
||||
2 fdt fdt_setprop_inplace
|
||||
3 fdt fdt_check_header
|
||||
4 fdt fdt_node_offset_by_compatible
|
||||
5 mbedtls mbedtls_asn1_get_alg
|
||||
6 mbedtls mbedtls_asn1_get_alg_null
|
||||
7 mbedtls mbedtls_asn1_get_bitstring_null
|
||||
8 mbedtls mbedtls_asn1_get_bool
|
||||
9 mbedtls mbedtls_asn1_get_int
|
||||
10 mbedtls mbedtls_asn1_get_tag
|
||||
11 mbedtls mbedtls_free
|
||||
12 mbedtls mbedtls_md
|
||||
13 mbedtls mbedtls_md_get_size
|
||||
14 mbedtls mbedtls_memory_buffer_alloc_init
|
||||
15 mbedtls mbedtls_oid_get_md_alg
|
||||
16 mbedtls mbedtls_oid_get_numeric_string
|
||||
17 mbedtls mbedtls_oid_get_pk_alg
|
||||
18 mbedtls mbedtls_oid_get_sig_alg
|
||||
19 mbedtls mbedtls_pk_free
|
||||
20 mbedtls mbedtls_pk_init
|
||||
21 mbedtls mbedtls_pk_parse_subpubkey
|
||||
22 mbedtls mbedtls_pk_verify_ext
|
||||
23 mbedtls mbedtls_platform_set_snprintf
|
||||
24 mbedtls mbedtls_x509_get_rsassa_pss_params
|
||||
25 mbedtls mbedtls_x509_get_sig_alg
|
||||
26 mbedtls mbedtls_md_info_from_type
|
||||
27 c exit
|
||||
28 c atexit
|
44
lib/romlib/romlib.ld.S
Normal file
44
lib/romlib/romlib.ld.S
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <platform_def.h>
|
||||
#include <xlat_tables_defs.h>
|
||||
|
||||
MEMORY {
|
||||
ROM (rx): ORIGIN = ROMLIB_RO_BASE, LENGTH = ROMLIB_RO_LIMIT - ROMLIB_RO_BASE
|
||||
RAM (rwx): ORIGIN = ROMLIB_RW_BASE, LENGTH = ROMLIB_RW_END - ROMLIB_RW_BASE
|
||||
}
|
||||
|
||||
OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
|
||||
OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
|
||||
ENTRY(jmptbl)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
. = ROMLIB_RO_BASE;
|
||||
.text : {
|
||||
*jmptbl.o(.text)
|
||||
*(.text*)
|
||||
*(.rodata*)
|
||||
} >ROM
|
||||
|
||||
__DATA_ROM_START__ = LOADADDR(.data);
|
||||
|
||||
.data : {
|
||||
__DATA_RAM_START__ = .;
|
||||
*(.data*)
|
||||
__DATA_RAM_END__ = .;
|
||||
} >RAM AT>ROM
|
||||
|
||||
__DATA_SIZE__ = SIZEOF(.data);
|
||||
|
||||
.bss : {
|
||||
__BSS_START__ = .;
|
||||
*(.bss*)
|
||||
__BSS_END__ = .;
|
||||
} >RAM
|
||||
__BSS_SIZE__ = SIZEOF(.bss);
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include <debug.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
void exit(int v)
|
||||
{
|
||||
ERROR("EXIT\n");
|
||||
panic();
|
||||
}
|
|
@ -189,6 +189,24 @@ GZIP_SUFFIX := .gz
|
|||
|
||||
MAKE_DEP = -Wp,-MD,$(DEP) -MT $$@ -MP
|
||||
|
||||
|
||||
# MAKE_C_LIB builds a C source file and generates the dependency file
|
||||
# $(1) = output directory
|
||||
# $(2) = source file (%.c)
|
||||
# $(3) = library name
|
||||
define MAKE_C_LIB
|
||||
$(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2))))
|
||||
$(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
|
||||
|
||||
$(OBJ): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | lib$(3)_dirs
|
||||
@echo " CC $$<"
|
||||
$$(Q)$$(CC) $$(TF_CFLAGS) $$(CFLAGS) $(MAKE_DEP) -c $$< -o $$@
|
||||
|
||||
-include $(DEP)
|
||||
|
||||
endef
|
||||
|
||||
|
||||
# MAKE_C builds a C source file and generates the dependency file
|
||||
# $(1) = output directory
|
||||
# $(2) = source file (%.c)
|
||||
|
@ -243,6 +261,18 @@ $(1): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | bl$(3)_dirs
|
|||
|
||||
endef
|
||||
|
||||
# MAKE_LIB_OBJS builds both C source files
|
||||
# $(1) = output directory
|
||||
# $(2) = list of source files
|
||||
# $(3) = name of the library
|
||||
define MAKE_LIB_OBJS
|
||||
$(eval C_OBJS := $(filter %.c,$(2)))
|
||||
$(eval REMAIN := $(filter-out %.c,$(2)))
|
||||
$(eval $(foreach obj,$(C_OBJS),$(call MAKE_C_LIB,$(1),$(obj),$(3))))
|
||||
|
||||
$(and $(REMAIN),$(error Unexpected source files present: $(REMAIN)))
|
||||
endef
|
||||
|
||||
|
||||
# MAKE_OBJS builds both C and assembly source files
|
||||
# $(1) = output directory
|
||||
|
@ -274,6 +304,49 @@ endef
|
|||
# This must be set to a C string (including quotes where applicable).
|
||||
BUILD_MESSAGE_TIMESTAMP ?= __TIME__", "__DATE__
|
||||
|
||||
.PHONY: libraries
|
||||
|
||||
# MAKE_LIB_DIRS macro defines the target for the directory where
|
||||
# libraries are created
|
||||
define MAKE_LIB_DIRS
|
||||
$(eval LIB_DIR := ${BUILD_PLAT}/lib)
|
||||
$(eval ROMLIB_DIR := ${BUILD_PLAT}/romlib)
|
||||
$(eval LIBWRAPPER_DIR := ${BUILD_PLAT}/libwrapper)
|
||||
$(eval $(call MAKE_PREREQ_DIR,${LIB_DIR},${BUILD_PLAT}))
|
||||
$(eval $(call MAKE_PREREQ_DIR,${ROMLIB_DIR},${BUILD_PLAT}))
|
||||
$(eval $(call MAKE_PREREQ_DIR,${LIBWRAPPER_DIR},${BUILD_PLAT}))
|
||||
endef
|
||||
|
||||
# MAKE_LIB macro defines the targets and options to build each BL image.
|
||||
# Arguments:
|
||||
# $(1) = Library name
|
||||
define MAKE_LIB
|
||||
$(eval BUILD_DIR := ${BUILD_PLAT}/lib$(1))
|
||||
$(eval LIB_DIR := ${BUILD_PLAT}/lib)
|
||||
$(eval ROMLIB_DIR := ${BUILD_PLAT}/romlib)
|
||||
$(eval SOURCES := $(LIB$(call uppercase,$(1))_SRCS))
|
||||
$(eval OBJS := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES))))
|
||||
|
||||
$(eval $(call MAKE_PREREQ_DIR,${BUILD_DIR},${BUILD_PLAT}))
|
||||
$(eval $(call MAKE_LIB_OBJS,$(BUILD_DIR),$(SOURCES),$(1)))
|
||||
|
||||
.PHONY : lib${1}_dirs
|
||||
lib${1}_dirs: | ${BUILD_DIR} ${LIB_DIR} ${ROMLIB_DIR} ${LIBWRAPPER_DIR}
|
||||
libraries: ${LIB_DIR}/lib$(1).a
|
||||
LDPATHS = -L${LIB_DIR}
|
||||
LDLIBS += -l$(1)
|
||||
|
||||
ifeq ($(USE_ROMLIB),1)
|
||||
LDLIBS := -lwrappers -lc
|
||||
endif
|
||||
|
||||
all: ${LIB_DIR}/lib$(1).a
|
||||
|
||||
${LIB_DIR}/lib$(1).a: $(OBJS)
|
||||
@echo " AR $$@"
|
||||
$$(Q)$$(AR) cr $$@ $$?
|
||||
endef
|
||||
|
||||
# MAKE_BL macro defines the targets and options to build each BL image.
|
||||
# Arguments:
|
||||
# $(1) = BL stage (2, 2u, 30, 31, 32, 33)
|
||||
|
@ -313,7 +386,11 @@ bl${1}_dirs: | ${OBJ_DIRS}
|
|||
$(eval $(call MAKE_OBJS,$(BUILD_DIR),$(SOURCES),$(1)))
|
||||
$(eval $(call MAKE_LD,$(LINKERFILE),$(BL_LINKERFILE),$(1)))
|
||||
|
||||
$(ELF): $(OBJS) $(LINKERFILE) | bl$(1)_dirs $(BL_LIBS)
|
||||
ifeq ($(USE_ROMLIB),1)
|
||||
$(ELF): romlib.bin
|
||||
endif
|
||||
|
||||
$(ELF): $(OBJS) $(LINKERFILE) | bl$(1)_dirs libraries $(BL_LIBS)
|
||||
@echo " LD $$@"
|
||||
ifdef MAKE_BUILD_STRINGS
|
||||
$(call MAKE_BUILD_STRINGS, $(BUILD_DIR)/build_message.o)
|
||||
|
@ -323,7 +400,8 @@ else
|
|||
$$(CC) $$(TF_CFLAGS) $$(CFLAGS) -xc -c - -o $(BUILD_DIR)/build_message.o
|
||||
endif
|
||||
$$(Q)$$(LD) -o $$@ $$(TF_LDFLAGS) $$(LDFLAGS) -Map=$(MAPFILE) \
|
||||
--script $(LINKERFILE) $(BUILD_DIR)/build_message.o $(OBJS) $(LDLIBS) $(BL_LIBS)
|
||||
--script $(LINKERFILE) $(BUILD_DIR)/build_message.o \
|
||||
$(OBJS) $(LDPATHS) $(LDLIBS) $(BL_LIBS)
|
||||
|
||||
$(DUMP): $(ELF)
|
||||
@echo " OD $$@"
|
||||
|
|
|
@ -166,6 +166,9 @@ TRUSTED_BOARD_BOOT := 0
|
|||
# Build option to choose whether Trusted firmware uses Coherent memory or not.
|
||||
USE_COHERENT_MEM := 1
|
||||
|
||||
# Build option to choose wheter Trusted firmware uses library at ROM
|
||||
USE_ROMLIB := 0
|
||||
|
||||
# Use tbbr_oid.h instead of platform_oid.h
|
||||
USE_TBBR_DEFS = $(ERROR_DEPRECATED)
|
||||
|
||||
|
|
|
@ -67,6 +67,8 @@
|
|||
* in debug mode. We can test TBB on Juno bypassing the ROM and using 128 KB of
|
||||
* flash
|
||||
*/
|
||||
#define PLAT_ARM_MAX_ROMLIB_RO_SIZE 0
|
||||
|
||||
#if TRUSTED_BOARD_BOOT
|
||||
#define PLAT_ARM_TRUSTED_ROM_SIZE 0x00020000
|
||||
#else
|
||||
|
@ -122,6 +124,15 @@
|
|||
# define PLAT_ARM_MAX_BL1_RW_SIZE 0x6000
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PLAT_ARM_MAX_ROMLIB_RW_SIZE is define to use a full page
|
||||
*/
|
||||
#if USE_ROMLIB
|
||||
#define PLAT_ARM_MAX_ROMLIB_RW_SIZE 0x1000
|
||||
#else
|
||||
#define PLAT_ARM_MAX_ROMLIB_RW_SIZE 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PLAT_ARM_MAX_BL2_SIZE is calculated using the current BL2 debug size plus a
|
||||
* little space for growth.
|
||||
|
|
|
@ -117,6 +117,10 @@ void arm_bl1_plat_arch_setup(void)
|
|||
const mmap_region_t bl_regions[] = {
|
||||
MAP_BL1_TOTAL,
|
||||
MAP_BL1_RO,
|
||||
#if USE_ROMLIB
|
||||
ARM_MAP_ROMLIB_CODE,
|
||||
ARM_MAP_ROMLIB_DATA,
|
||||
#endif
|
||||
{0}
|
||||
};
|
||||
|
||||
|
@ -126,6 +130,8 @@ void arm_bl1_plat_arch_setup(void)
|
|||
#else
|
||||
enable_mmu_el3(0);
|
||||
#endif /* AARCH32 */
|
||||
|
||||
arm_setup_romlib();
|
||||
}
|
||||
|
||||
void bl1_plat_arch_setup(void)
|
||||
|
|
|
@ -246,6 +246,10 @@ void arm_bl2_plat_arch_setup(void)
|
|||
const mmap_region_t bl_regions[] = {
|
||||
MAP_BL2_TOTAL,
|
||||
ARM_MAP_BL_RO,
|
||||
#if USE_ROMLIB
|
||||
ARM_MAP_ROMLIB_CODE,
|
||||
ARM_MAP_ROMLIB_DATA,
|
||||
#endif
|
||||
{0}
|
||||
};
|
||||
|
||||
|
@ -256,6 +260,8 @@ void arm_bl2_plat_arch_setup(void)
|
|||
#else
|
||||
enable_mmu_el1(0);
|
||||
#endif
|
||||
|
||||
arm_setup_romlib();
|
||||
}
|
||||
|
||||
void bl2_plat_arch_setup(void)
|
||||
|
|
|
@ -73,6 +73,10 @@ void arm_bl2u_plat_arch_setup(void)
|
|||
const mmap_region_t bl_regions[] = {
|
||||
MAP_BL2U_TOTAL,
|
||||
ARM_MAP_BL_RO,
|
||||
#if USE_ROMLIB
|
||||
ARM_MAP_ROMLIB_CODE,
|
||||
ARM_MAP_ROMLIB_DATA,
|
||||
#endif
|
||||
{0}
|
||||
};
|
||||
|
||||
|
@ -83,6 +87,7 @@ void arm_bl2u_plat_arch_setup(void)
|
|||
#else
|
||||
enable_mmu_el1(0);
|
||||
#endif
|
||||
arm_setup_romlib();
|
||||
}
|
||||
|
||||
void bl2u_plat_arch_setup(void)
|
||||
|
|
|
@ -285,9 +285,18 @@ void bl31_plat_runtime_setup(void)
|
|||
void arm_bl31_plat_arch_setup(void)
|
||||
{
|
||||
|
||||
#define ARM_MAP_BL_ROMLIB MAP_REGION_FLAT( \
|
||||
BL31_BASE, \
|
||||
BL31_END - BL31_BASE, \
|
||||
MT_MEMORY | MT_RW | MT_SECURE)
|
||||
|
||||
const mmap_region_t bl_regions[] = {
|
||||
MAP_BL31_TOTAL,
|
||||
ARM_MAP_BL_RO,
|
||||
#if USE_ROMLIB
|
||||
ARM_MAP_ROMLIB_CODE,
|
||||
ARM_MAP_ROMLIB_DATA,
|
||||
#endif
|
||||
#if USE_COHERENT_MEM
|
||||
ARM_MAP_BL_COHERENT_RAM,
|
||||
#endif
|
||||
|
@ -297,6 +306,8 @@ void arm_bl31_plat_arch_setup(void)
|
|||
arm_setup_page_tables(bl_regions, plat_arm_get_mmap());
|
||||
|
||||
enable_mmu_el3(0);
|
||||
|
||||
arm_setup_romlib();
|
||||
}
|
||||
|
||||
void bl31_plat_arch_setup(void)
|
||||
|
|
|
@ -10,8 +10,9 @@
|
|||
#include <debug.h>
|
||||
#include <mmio.h>
|
||||
#include <plat_arm.h>
|
||||
#include <platform_def.h>
|
||||
#include <platform.h>
|
||||
#include <platform_def.h>
|
||||
#include <romlib.h>
|
||||
#include <secure_partition.h>
|
||||
|
||||
/* Weak definitions may be overridden in specific ARM standard platform */
|
||||
|
@ -24,6 +25,15 @@
|
|||
#pragma weak plat_get_syscnt_freq2
|
||||
#endif
|
||||
|
||||
|
||||
void arm_setup_romlib(void)
|
||||
{
|
||||
#if USE_ROMLIB
|
||||
if (!rom_lib_init(ROMLIB_VERSION))
|
||||
panic();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up the page tables for the generic and platform-specific memory regions.
|
||||
* The size of the Trusted SRAM seen by the BL image must be specified as well
|
||||
|
|
|
@ -185,8 +185,7 @@ include lib/libfdt/libfdt.mk
|
|||
|
||||
DYN_CFG_SOURCES += plat/arm/common/arm_dyn_cfg.c \
|
||||
plat/arm/common/arm_dyn_cfg_helpers.c \
|
||||
common/fdt_wrappers.c \
|
||||
${LIBFDT_SRCS}
|
||||
common/fdt_wrappers.c
|
||||
|
||||
BL1_SOURCES += ${DYN_CFG_SOURCES}
|
||||
BL2_SOURCES += ${DYN_CFG_SOURCES}
|
||||
|
|
|
@ -132,8 +132,7 @@ BL2_SOURCES += drivers/io/io_semihosting.c \
|
|||
plat/qemu/qemu_io_storage.c \
|
||||
plat/qemu/${ARCH}/plat_helpers.S \
|
||||
plat/qemu/qemu_bl2_setup.c \
|
||||
plat/qemu/dt.c \
|
||||
$(LIBFDT_SRCS)
|
||||
plat/qemu/dt.c
|
||||
ifeq (${LOAD_IMAGE_V2},1)
|
||||
BL2_SOURCES += plat/qemu/qemu_bl2_mem_params_desc.c \
|
||||
plat/qemu/qemu_image_load.c \
|
||||
|
|
Loading…
Add table
Reference in a new issue