diff options
-rw-r--r-- | Makefile | 24 | ||||
-rw-r--r-- | bl2/bl2_main.c | 10 | ||||
-rw-r--r-- | common/tf_printf.c | 85 | ||||
-rw-r--r-- | docs/porting-guide.md | 12 | ||||
-rw-r--r-- | docs/user-guide.md | 22 | ||||
-rw-r--r-- | include/plat/arm/common/arm_def.h | 4 | ||||
-rw-r--r-- | plat/arm/common/arm_bl2_setup.c | 32 | ||||
-rw-r--r-- | plat/arm/common/arm_bl31_setup.c | 4 |
8 files changed, 101 insertions, 92 deletions
@@ -306,9 +306,9 @@ include lib/cpus/cpu-ops.mk ################################################################################ ifdef EL3_PAYLOAD_BASE - ifdef BL33_BASE - $(warning "BL33_BASE and EL3_PAYLOAD_BASE are incompatible \ - build options. EL3_PAYLOAD_BASE has priority.") + ifdef PRELOADED_BL33_BASE + $(warning "PRELOADED_BL33_BASE and EL3_PAYLOAD_BASE are \ + incompatible build options. EL3_PAYLOAD_BASE has priority.") endif endif @@ -317,9 +317,10 @@ ifeq (${NEED_BL33},yes) $(warning "BL33 image is not needed when option \ BL33_PAYLOAD_BASE is used and won't be added to the FIP file.") endif - ifdef BL33_BASE - $(warning "BL33 image is not needed when option BL33_BASE is \ - used and won't be added to the FIP file.") + ifdef PRELOADED_BL33_BASE + $(warning "BL33 image is not needed when option \ + PRELOADED_BL33_BASE is used and won't be added to the FIP \ + file.") endif endif @@ -342,7 +343,7 @@ ifdef BL2_SOURCES # in the FIP file. NEED_BL33 := no else - ifdef BL33_BASE + ifdef PRELOADED_BL33_BASE # If booting a BL33 preloaded image there is no need of # another one in the FIP file. NEED_BL33 := no @@ -414,6 +415,7 @@ $(eval $(call assert_boolean,PL011_GENERIC_UART)) ################################################################################ $(eval $(call add_define,PLAT_${PLAT})) +$(eval $(call add_define,SPD_${SPD})) $(eval $(call add_define,NS_TIMER_SWITCH)) $(eval $(call add_define,RESET_TO_BL31)) $(eval $(call add_define,CTX_INCLUDE_FPREGS)) @@ -434,10 +436,10 @@ $(eval $(call add_define,PL011_GENERIC_UART)) ifdef EL3_PAYLOAD_BASE $(eval $(call add_define,EL3_PAYLOAD_BASE)) else - # Define the BL33_BASE flag only if it is provided and EL3_PAYLOAD_BASE - # is not defined, as it has priority. - ifdef BL33_BASE - $(eval $(call add_define,BL33_BASE)) + # Define the PRELOADED_BL33_BASE flag only if it is provided and + # EL3_PAYLOAD_BASE is not defined, as it has priority. + ifdef PRELOADED_BL33_BASE + $(eval $(call add_define,PRELOADED_BL33_BASE)) endif endif diff --git a/bl2/bl2_main.c b/bl2/bl2_main.c index 73781dd0..c8fd683c 100644 --- a/bl2/bl2_main.c +++ b/bl2/bl2_main.c @@ -169,7 +169,7 @@ static int load_bl32(bl31_params_t *bl2_to_bl31_params) return e; } -#ifndef BL33_BASE +#ifndef PRELOADED_BL33_BASE /******************************************************************************* * Load the BL33 image. * The bl2_to_bl31_params param will be updated with the relevant BL33 @@ -200,7 +200,7 @@ static int load_bl33(bl31_params_t *bl2_to_bl31_params) return e; } -#endif /* BL33_BASE */ +#endif /* PRELOADED_BL33_BASE */ #endif /* EL3_PAYLOAD_BASE */ @@ -277,13 +277,13 @@ void bl2_main(void) } } -#ifdef BL33_BASE +#ifdef PRELOADED_BL33_BASE /* * In this case, don't load the BL33 image as it's already loaded in * memory. Update BL33 entrypoint information. */ INFO("BL2: Populating the entrypoint info for the preloaded BL33\n"); - bl2_to_bl31_params->bl33_ep_info->pc = BL33_BASE; + bl2_to_bl31_params->bl33_ep_info->pc = PRELOADED_BL33_BASE; bl2_plat_set_bl33_ep_info(NULL, bl2_to_bl31_params->bl33_ep_info); #else e = load_bl33(bl2_to_bl31_params); @@ -291,7 +291,7 @@ void bl2_main(void) ERROR("Failed to load BL33 (%i)\n", e); plat_error_handler(e); } -#endif /* BL33_BASE */ +#endif /* PRELOADED_BL33_BASE */ #endif /* EL3_PAYLOAD_BASE */ diff --git a/common/tf_printf.c b/common/tf_printf.c index 9a7667a5..ad0b90aa 100644 --- a/common/tf_printf.c +++ b/common/tf_printf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2014-2016, ARM Limited and Contributors. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -34,7 +34,22 @@ /*********************************************************** * The tf_printf implementation for all BL stages ***********************************************************/ -static void unsigned_num_print(unsigned long int unum, unsigned int radix) + +#define get_num_va_args(args, lcount) \ + (((lcount) > 1) ? va_arg(args, long long int) : \ + ((lcount) ? va_arg(args, long int) : va_arg(args, int))) + +#define get_unum_va_args(args, lcount) \ + (((lcount) > 1) ? va_arg(args, unsigned long long int) : \ + ((lcount) ? va_arg(args, unsigned long int) : va_arg(args, unsigned int))) + +static void string_print(const char *str) +{ + while (*str) + putchar(*str++); +} + +static void unsigned_num_print(unsigned long long int unum, unsigned int radix) { /* Just need enough space to store 64 bit decimal integer */ unsigned char num_buf[20]; @@ -52,38 +67,34 @@ static void unsigned_num_print(unsigned long int unum, unsigned int radix) putchar(num_buf[i]); } -static void string_print(const char *str) -{ - while (*str) - putchar(*str++); -} - /******************************************************************* * Reduced format print for Trusted firmware. - * The following formats are supported by this print - * %x - 32 bit hexadecimal format - * %llx and %lx -64 bit hexadecimal format + * The following type specifiers are supported by this print + * %x - hexadecimal format * %s - string format - * %d or %i - signed 32 bit decimal format - * %u - unsigned 32 bit decimal format - * %ld and %lld - signed 64 bit decimal format - * %lu and %llu - unsigned 64 bit decimal format + * %d or %i - signed decimal format + * %u - unsigned decimal format * %p - pointer format - * %z - size_t format - * Exits on all other formats. + * + * The following length specifiers are supported by this print + * %l - long int (64-bit on AArch64) + * %ll - long long int (64-bit on AArch64) + * %z - size_t sized integer formats (64 bit on AArch64) + * + * The print exits on all other formats specifiers other than valid + * combinations of the above specifiers. *******************************************************************/ - void tf_printf(const char *fmt, ...) { va_list args; - int bit64; - int64_t num; - uint64_t unum; + int l_count; + long long int num; + unsigned long long int unum; char *str; va_start(args, fmt); while (*fmt) { - bit64 = 0; + l_count = 0; if (*fmt == '%') { fmt++; @@ -92,16 +103,12 @@ loop: switch (*fmt) { case 'i': /* Fall through to next one */ case 'd': - if (bit64) - num = va_arg(args, int64_t); - else - num = va_arg(args, int32_t); - + num = get_num_va_args(args, l_count); if (num < 0) { putchar('-'); - unum = (unsigned long int)-num; + unum = (unsigned long long int)-num; } else - unum = (unsigned long int)num; + unum = (unsigned long long int)num; unsigned_num_print(unum, 10); break; @@ -110,36 +117,28 @@ loop: string_print(str); break; case 'p': - unum = (uint64_t)va_arg(args, void *); - + unum = (uintptr_t)va_arg(args, void *); if (unum) string_print("0x"); unsigned_num_print(unum, 16); break; case 'x': - if (bit64) - unum = va_arg(args, uint64_t); - else - unum = va_arg(args, uint32_t); - + unum = get_unum_va_args(args, l_count); unsigned_num_print(unum, 16); break; case 'z': if (sizeof(size_t) == 8) - bit64 = 1; + l_count = 2; + fmt++; goto loop; case 'l': - bit64 = 1; + l_count++; fmt++; goto loop; case 'u': - if (bit64) - unum = va_arg(args, uint64_t); - else - unum = va_arg(args, uint32_t); - + unum = get_unum_va_args(args, l_count); unsigned_num_print(unum, 10); break; default: diff --git a/docs/porting-guide.md b/docs/porting-guide.md index 3b6e242b..5e148232 100644 --- a/docs/porting-guide.md +++ b/docs/porting-guide.md @@ -1271,8 +1271,8 @@ BL33 image. The meminfo provided by this is used by load_image() to validate whether the BL33 image can be loaded with in the given memory from the given base. -This function isn't needed if either `BL33_BASE` or `EL3_PAYLOAD_BASE` build -options are used. +This function isn't needed if either `PRELOADED_BL33_BASE` or `EL3_PAYLOAD_BASE` +build options are used. ### Function : bl2_plat_flush_bl31_params() [mandatory] @@ -1296,8 +1296,8 @@ entrypoint of that image, which BL31 uses to jump to it. BL2 is responsible for loading the normal world BL33 image (e.g. UEFI). -This function isn't needed if either `BL33_BASE` or `EL3_PAYLOAD_BASE` build -options are used. +This function isn't needed if either `PRELOADED_BL33_BASE` or `EL3_PAYLOAD_BASE` +build options are used. 3.3 FWU Boot Loader Stage 2 (BL2U) @@ -2002,8 +2002,8 @@ build system. By default, this flag is defined `yes` by the build system and `BL33` build option should be supplied as a build option. The platform has the option of excluding the BL33 image in the `fip` image by defining this flag - to `no`. If any of the options `EL3_PAYLOAD_BASE` or `BL33_BASE` are used, - this flag will be set to `no` automatically. + to `no`. If any of the options `EL3_PAYLOAD_BASE` or `PRELOADED_BL33_BASE` + are used, this flag will be set to `no` automatically. 5. C Library ------------- diff --git a/docs/user-guide.md b/docs/user-guide.md index 8d7376d4..e5e28a3f 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -411,11 +411,11 @@ performed. payload. Please refer to the "Booting an EL3 payload" section for more details. -* `BL33_BASE`: This option enables booting a preloaded BL33 image instead of - the normal boot flow. When defined, it must specify the entry point address - for the preloaded BL33 image. This option is incompatible with +* `PRELOADED_BL33_BASE`: This option enables booting a preloaded BL33 image + instead of the normal boot flow. When defined, it must specify the entry + point address for the preloaded BL33 image. This option is incompatible with `EL3_PAYLOAD_BASE`. If both are defined, `EL3_PAYLOAD_BASE` has priority - over `BL33_BASE`. + over `PRELOADED_BL33_BASE`. * `PL011_GENERIC_UART`: Boolean option to indicate the PL011 driver that the underlying hardware is not a full PL011 UART but a minimally compliant @@ -1001,13 +1001,13 @@ code and improve performance in a development environment. When secure world cold boot is complete, Trusted Firmware simply jumps to a BL33 base address provided at build time. -For this option to be used, the `BL33_BASE` build option has to be used when -compiling the Trusted Firmware. For example, the following command will create -a FIP without a BL33 and prepare to jump to a BL33 image loaded at address -0x80000000: +For this option to be used, the `PRELOADED_BL33_BASE` build option has to be +used when compiling the Trusted Firmware. For example, the following command +will create a FIP without a BL33 and prepare to jump to a BL33 image loaded at +address 0x80000000: CROSS_COMPILE=<path-to>/bin/aarch64-linux-gnu- \ - make BL33_BASE=0x80000000 PLAT=fvp all fip + make PRELOADED_BL33_BASE=0x80000000 PLAT=fvp all fip #### Boot of a preloaded bootwrapped kernel image on Base FVP @@ -1029,8 +1029,8 @@ following command: The `-a cluster0.cpu0=<bootwrapped-kernel.elf>` option loads the ELF file. It also sets the PC register to the ELF entry point address, which is not the desired behaviour, so the `--start cluster0.cpu0=0x0` option forces the PC back -to 0x0 (the BL1 entry point address) on CPU #0. The `BL33_BASE` define used when -compiling the FIP must match the ELF entry point. +to 0x0 (the BL1 entry point address) on CPU #0. The `PRELOADED_BL33_BASE` define +used when compiling the FIP must match the ELF entry point. #### Boot of a preloaded bootwrapped kernel image on Juno diff --git a/include/plat/arm/common/arm_def.h b/include/plat/arm/common/arm_def.h index 18fe7180..0b3e66b1 100644 --- a/include/plat/arm/common/arm_def.h +++ b/include/plat/arm/common/arm_def.h @@ -321,6 +321,10 @@ # error "Unsupported ARM_TSP_RAM_LOCATION_ID value" #endif +#ifdef SPD_none +#undef BL32_BASE +#endif /* SPD_none */ + /******************************************************************************* * FWU Images: NS_BL1U, BL2U & NS_BL2U defines. ******************************************************************************/ diff --git a/plat/arm/common/arm_bl2_setup.c b/plat/arm/common/arm_bl2_setup.c index a528830a..681dc8ad 100644 --- a/plat/arm/common/arm_bl2_setup.c +++ b/plat/arm/common/arm_bl2_setup.c @@ -147,14 +147,14 @@ bl31_params_t *bl2_plat_get_bl31_params(void) VERSION_1, 0); /* Fill BL32 related information if it exists */ -#if BL32_BASE +#ifdef BL32_BASE bl2_to_bl31_params->bl32_ep_info = &bl31_params_mem.bl32_ep_info; SET_PARAM_HEAD(bl2_to_bl31_params->bl32_ep_info, PARAM_EP, VERSION_1, 0); bl2_to_bl31_params->bl32_image_info = &bl31_params_mem.bl32_image_info; SET_PARAM_HEAD(bl2_to_bl31_params->bl32_image_info, PARAM_IMAGE_BINARY, VERSION_1, 0); -#endif +#endif /* BL32_BASE */ /* Fill BL33 related information */ bl2_to_bl31_params->bl33_ep_info = &bl31_params_mem.bl33_ep_info; @@ -280,6 +280,7 @@ void bl2_plat_set_bl31_ep_info(image_info_t *bl31_image_info, * the entrypoint of BL32 and set SPSR and security state. * On ARM standard platforms we only set the security state of the entrypoint ******************************************************************************/ +#ifdef BL32_BASE void bl2_plat_set_bl32_ep_info(image_info_t *bl32_image_info, entry_point_info_t *bl32_ep_info) { @@ -288,20 +289,6 @@ void bl2_plat_set_bl32_ep_info(image_info_t *bl32_image_info, } /******************************************************************************* - * Before calling this function BL33 is loaded in memory and its entrypoint - * is set by load_image. This is a placeholder for the platform to change - * the entrypoint of BL33 and set SPSR and security state. - * On ARM standard platforms we only set the security state of the entrypoint - ******************************************************************************/ -void bl2_plat_set_bl33_ep_info(image_info_t *image, - entry_point_info_t *bl33_ep_info) -{ - - SET_SECURITY_STATE(bl33_ep_info->h.attr, NON_SECURE); - bl33_ep_info->spsr = arm_get_spsr_for_bl33_entry(); -} - -/******************************************************************************* * Populate the extents of memory available for loading BL32 ******************************************************************************/ void bl2_plat_get_bl32_meminfo(meminfo_t *bl32_meminfo) @@ -316,7 +303,20 @@ void bl2_plat_get_bl32_meminfo(meminfo_t *bl32_meminfo) bl32_meminfo->free_size = (TSP_SEC_MEM_BASE + TSP_SEC_MEM_SIZE) - BL32_BASE; } +#endif /* BL32_BASE */ +/******************************************************************************* + * Before calling this function BL33 is loaded in memory and its entrypoint + * is set by load_image. This is a placeholder for the platform to change + * the entrypoint of BL33 and set SPSR and security state. + * On ARM standard platforms we only set the security state of the entrypoint + ******************************************************************************/ +void bl2_plat_set_bl33_ep_info(image_info_t *image, + entry_point_info_t *bl33_ep_info) +{ + SET_SECURITY_STATE(bl33_ep_info->h.attr, NON_SECURE); + bl33_ep_info->spsr = arm_get_spsr_for_bl33_entry(); +} /******************************************************************************* * Populate the extents of memory available for loading BL33 diff --git a/plat/arm/common/arm_bl31_setup.c b/plat/arm/common/arm_bl31_setup.c index 5cc8bfb1..8fcfa775 100644 --- a/plat/arm/common/arm_bl31_setup.c +++ b/plat/arm/common/arm_bl31_setup.c @@ -142,7 +142,11 @@ void arm_bl31_early_platform_setup(bl31_params_t *from_bl2, * Tell BL31 where the non-trusted software image * is located and the entry state information */ +#ifdef PRELOADED_BL33_BASE + bl33_image_ep_info.pc = PRELOADED_BL33_BASE; +#else bl33_image_ep_info.pc = plat_get_ns_image_entrypoint(); +#endif /* PRELOADED_BL33_BASE */ bl33_image_ep_info.spsr = arm_get_spsr_for_bl33_entry(); SET_SECURITY_STATE(bl33_image_ep_info.h.attr, NON_SECURE); |