diff options
author | Dimitris Papastamos <dimitris.papastamos@arm.com> | 2018-03-29 09:59:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-29 09:59:52 +0100 |
commit | e74af2afd0886a1b425757ff348396bffd0a580e (patch) | |
tree | 34de46f0991d30b29e21fbcb0df1bdf38ce14f12 /include | |
parent | 0b7477234a5b9c46eedbdeb69ccec6ccf3872465 (diff) | |
parent | 9f85f9e3796f1c351bbc4c8436dc66d83c140b71 (diff) | |
download | platform_external_arm-trusted-firmware-e74af2afd0886a1b425757ff348396bffd0a580e.tar.gz platform_external_arm-trusted-firmware-e74af2afd0886a1b425757ff348396bffd0a580e.tar.bz2 platform_external_arm-trusted-firmware-e74af2afd0886a1b425757ff348396bffd0a580e.zip |
Merge pull request #1335 from JoelHutton/jh/cleanup_void_pointers
Clean usage of void pointers to access symbols
Diffstat (limited to 'include')
-rw-r--r-- | include/common/bl_common.h | 32 | ||||
-rw-r--r-- | include/common/runtime_svc.h | 4 | ||||
-rw-r--r-- | include/lib/utils_def.h | 19 | ||||
-rw-r--r-- | include/plat/common/common_def.h | 24 | ||||
-rw-r--r-- | include/services/secure_partition.h | 12 |
5 files changed, 46 insertions, 45 deletions
diff --git a/include/common/bl_common.h b/include/common/bl_common.h index 4ef916f53..09a394dd1 100644 --- a/include/common/bl_common.h +++ b/include/common/bl_common.h @@ -64,33 +64,41 @@ #include <types.h> #include <utils_def.h> /* To retain compatibility */ + /* * Declarations of linker defined symbols to help determine memory layout of * BL images */ #if SEPARATE_CODE_AND_RODATA -extern uintptr_t __TEXT_START__; -extern uintptr_t __TEXT_END__; -extern uintptr_t __RODATA_START__; -extern uintptr_t __RODATA_END__; +IMPORT_SYM(unsigned long, __TEXT_START__, BL_CODE_BASE); +IMPORT_SYM(unsigned long, __TEXT_END__, BL_CODE_END); +IMPORT_SYM(unsigned long, __RODATA_START__, BL_RO_DATA_BASE); +IMPORT_SYM(unsigned long, __RODATA_END__, BL_RO_DATA_END); #else -extern uintptr_t __RO_START__; -extern uintptr_t __RO_END__; +IMPORT_SYM(unsigned long, __RO_START__, BL_CODE_BASE); +IMPORT_SYM(unsigned long, __RO_END__, BL_CODE_END); #endif #if defined(IMAGE_BL2) -extern uintptr_t __BL2_END__; +IMPORT_SYM(unsigned long, __BL2_END__, BL2_END); #elif defined(IMAGE_BL2U) -extern uintptr_t __BL2U_END__; +IMPORT_SYM(unsigned long, __BL2U_END__, BL2U_END); #elif defined(IMAGE_BL31) -extern uintptr_t __BL31_END__; +IMPORT_SYM(unsigned long, __BL31_END__, BL31_END); #elif defined(IMAGE_BL32) -extern uintptr_t __BL32_END__; +IMPORT_SYM(unsigned long, __BL32_END__, BL32_END); #endif /* IMAGE_BLX */ +/* + * The next 2 constants identify the extents of the coherent memory region. + * These addresses are used by the MMU setup code and therefore they must be + * page-aligned. It is the responsibility of the linker script to ensure that + * __COHERENT_RAM_START__ and __COHERENT_RAM_END__ linker symbols refer to + * page-aligned addresses. + */ #if USE_COHERENT_MEM -extern uintptr_t __COHERENT_RAM_START__; -extern uintptr_t __COHERENT_RAM_END__; +IMPORT_SYM(unsigned long, __COHERENT_RAM_START__, BL_COHERENT_RAM_BASE); +IMPORT_SYM(unsigned long, __COHERENT_RAM_END__, BL_COHERENT_RAM_END); #endif /******************************************************************************* diff --git a/include/common/runtime_svc.h b/include/common/runtime_svc.h index d12af227e..5d9fa3908 100644 --- a/include/common/runtime_svc.h +++ b/include/common/runtime_svc.h @@ -122,8 +122,8 @@ CASSERT(RT_SVC_DESC_HANDLE == __builtin_offsetof(rt_svc_desc_t, handle), \ void runtime_svc_init(void); uintptr_t handle_runtime_svc(uint32_t smc_fid, void *cookie, void *handle, unsigned int flags); -extern uintptr_t __RT_SVC_DESCS_START__; -extern uintptr_t __RT_SVC_DESCS_END__; +IMPORT_SYM(uintptr_t, __RT_SVC_DESCS_START__, RT_SVC_DESCS_START); +IMPORT_SYM(uintptr_t, __RT_SVC_DESCS_END__, RT_SVC_DESCS_END); void init_crash_reporting(void); extern uint8_t rt_svc_descs_indices[MAX_RT_SVCS]; diff --git a/include/lib/utils_def.h b/include/lib/utils_def.h index 4a5c3e0bc..8abc73c09 100644 --- a/include/lib/utils_def.h +++ b/include/lib/utils_def.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -99,4 +99,21 @@ ((ARM_ARCH_MAJOR > _maj) || \ ((ARM_ARCH_MAJOR == _maj) && (ARM_ARCH_MINOR >= _min))) +/* + * Import an assembly or linker symbol as a C expression with the specified + * type + */ +#define IMPORT_SYM(type, sym, name) \ + extern char sym[];\ + static const __attribute__((unused)) type name = (type) sym; + +/* + * When the symbol is used to hold a pointer, its alignment can be asserted + * with this macro. For example, if there is a linker symbol that is going to + * be used as a 64-bit pointer, the value of the linker symbol must also be + * aligned to 64 bit. This macro makes sure this is the case. + */ +#define ASSERT_SYM_PTR_ALIGN(sym) assert(((size_t)(sym) % __alignof__(*(sym))) == 0) + + #endif /* __UTILS_DEF_H__ */ diff --git a/include/plat/common/common_def.h b/include/plat/common/common_def.h index a841c3dbf..84923b9a7 100644 --- a/include/plat/common/common_def.h +++ b/include/plat/common/common_def.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -74,33 +74,13 @@ * page of it with the right memory attributes. */ #if SEPARATE_CODE_AND_RODATA -#define BL_CODE_BASE (unsigned long)(&__TEXT_START__) -#define BL_CODE_END (unsigned long)(&__TEXT_END__) -#define BL_RO_DATA_BASE (unsigned long)(&__RODATA_START__) -#define BL_RO_DATA_END (unsigned long)(&__RODATA_END__) #define BL1_CODE_END BL_CODE_END -#define BL1_RO_DATA_BASE (unsigned long)(&__RODATA_START__) +#define BL1_RO_DATA_BASE BL_RO_DATA_BASE #define BL1_RO_DATA_END round_up(BL1_ROM_END, PAGE_SIZE) #else -#define BL_CODE_BASE (unsigned long)(&__RO_START__) -#define BL_CODE_END (unsigned long)(&__RO_END__) #define BL_RO_DATA_BASE 0 #define BL_RO_DATA_END 0 - #define BL1_CODE_END round_up(BL1_ROM_END, PAGE_SIZE) -#define BL1_RO_DATA_BASE 0 -#define BL1_RO_DATA_END 0 #endif /* SEPARATE_CODE_AND_RODATA */ - -/* - * The next 2 constants identify the extents of the coherent memory region. - * These addresses are used by the MMU setup code and therefore they must be - * page-aligned. It is the responsibility of the linker script to ensure that - * __COHERENT_RAM_START__ and __COHERENT_RAM_END__ linker symbols refer to - * page-aligned addresses. - */ -#define BL_COHERENT_RAM_BASE (unsigned long)(&__COHERENT_RAM_START__) -#define BL_COHERENT_RAM_END (unsigned long)(&__COHERENT_RAM_END__) - #endif /* __COMMON_DEF_H__ */ diff --git a/include/services/secure_partition.h b/include/services/secure_partition.h index 93df2a137..f68f711be 100644 --- a/include/services/secure_partition.h +++ b/include/services/secure_partition.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -11,15 +11,11 @@ #include <types.h> #include <utils_def.h> -/* Linker symbols */ -extern uintptr_t __SP_IMAGE_XLAT_TABLES_START__; -extern uintptr_t __SP_IMAGE_XLAT_TABLES_END__; +/* Import linker symbols */ +IMPORT_SYM(uintptr_t, __SP_IMAGE_XLAT_TABLES_START__, SP_IMAGE_XLAT_TABLES_START); +IMPORT_SYM(uintptr_t, __SP_IMAGE_XLAT_TABLES_END__, SP_IMAGE_XLAT_TABLES_END); /* Definitions */ -#define SP_IMAGE_XLAT_TABLES_START \ - (uintptr_t)(&__SP_IMAGE_XLAT_TABLES_START__) -#define SP_IMAGE_XLAT_TABLES_END \ - (uintptr_t)(&__SP_IMAGE_XLAT_TABLES_END__) #define SP_IMAGE_XLAT_TABLES_SIZE \ (SP_IMAGE_XLAT_TABLES_END - SP_IMAGE_XLAT_TABLES_START) |