Unverified Commit 3ba92957 authored by Dimitris Papastamos's avatar Dimitris Papastamos Committed by GitHub
Browse files

Merge pull request #1510 from robertovargas-arm/romlib

Add support for moving libraries to ROM
parents 0983b8b1 1eb735d7
...@@ -72,6 +72,8 @@ typedef struct arm_tzc_regions_info { ...@@ -72,6 +72,8 @@ typedef struct arm_tzc_regions_info {
void arm_setup_page_tables(const mmap_region_t bl_regions[], void arm_setup_page_tables(const mmap_region_t bl_regions[],
const mmap_region_t plat_regions[]); const mmap_region_t plat_regions[]);
void arm_setup_romlib(void);
#if defined(IMAGE_BL31) || (defined(AARCH32) && defined(IMAGE_BL32)) #if defined(IMAGE_BL31) || (defined(AARCH32) && defined(IMAGE_BL32))
/* /*
* Use this macro to instantiate lock before it is used in below * Use this macro to instantiate lock before it is used in below
......
...@@ -4,11 +4,23 @@ ...@@ -4,11 +4,23 @@
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
#include <debug.h>
#include <stdlib.h> #include <stdlib.h>
void exit(int v) static void (*exitfun)(void);
void exit(int status)
{ {
ERROR("EXIT\n"); if (exitfun)
panic(); (*exitfun)();
for (;;)
;
}
int atexit(void (*fun)(void))
{
if (exitfun)
return -1;
exitfun = fun;
return 0;
} }
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# SPDX-License-Identifier: BSD-3-Clause # SPDX-License-Identifier: BSD-3-Clause
# #
STDLIB_SRCS := $(addprefix lib/stdlib/, \ LIBC_SRCS := $(addprefix lib/libc/, \
abort.c \ abort.c \
assert.c \ assert.c \
exit.c \ exit.c \
...@@ -21,5 +21,5 @@ STDLIB_SRCS := $(addprefix lib/stdlib/, \ ...@@ -21,5 +21,5 @@ STDLIB_SRCS := $(addprefix lib/stdlib/, \
subr_prf.c \ subr_prf.c \
timingsafe_bcmp.c) timingsafe_bcmp.c)
INCLUDES += -Iinclude/lib/stdlib \ INCLUDES += -Iinclude/lib/libc \
-Iinclude/lib/stdlib/sys -Iinclude/lib/libc/sys
...@@ -15,3 +15,5 @@ LIBFDT_SRCS := $(addprefix lib/libfdt/, \ ...@@ -15,3 +15,5 @@ LIBFDT_SRCS := $(addprefix lib/libfdt/, \
fdt_wip.c) \ fdt_wip.c) \
INCLUDES += -Iinclude/lib/libfdt INCLUDES += -Iinclude/lib/libfdt
$(eval $(call MAKE_LIB,fdt))
#
# 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
#!/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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment