1 /* 2 * Copyright (c) 2015-2025, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 #ifndef COMMON_DEF_H 7 #define COMMON_DEF_H 8 9 #include <common/bl_common.h> 10 #include <lib/utils_def.h> 11 #include <lib/xlat_tables/xlat_tables_defs.h> 12 13 #include <platform_def.h> 14 15 #ifdef __aarch64__ 16 #define SZ_32 UL(0x00000020) 17 #define SZ_64 UL(0x00000040) 18 #define SZ_128 UL(0x00000080) 19 #define SZ_256 UL(0x00000100) 20 #define SZ_512 UL(0x00000200) 21 22 #define SZ_1K UL(0x00000400) 23 #define SZ_2K UL(0x00000800) 24 #define SZ_4K UL(0x00001000) 25 #define SZ_8K UL(0x00002000) 26 #define SZ_16K UL(0x00004000) 27 #define SZ_32K UL(0x00008000) 28 #define SZ_64K UL(0x00010000) 29 #define SZ_128K UL(0x00020000) 30 #define SZ_256K UL(0x00040000) 31 #define SZ_512K UL(0x00080000) 32 33 #define SZ_1M UL(0x00100000) 34 #define SZ_2M UL(0x00200000) 35 #define SZ_4M UL(0x00400000) 36 #define SZ_8M UL(0x00800000) 37 #define SZ_16M UL(0x01000000) 38 #define SZ_32M UL(0x02000000) 39 #define SZ_64M UL(0x04000000) 40 #define SZ_128M UL(0x08000000) 41 #define SZ_256M UL(0x10000000) 42 #define SZ_512M UL(0x20000000) 43 44 #define SZ_1G UL(0x40000000) 45 #define SZ_2G UL(0x80000000) 46 47 #define SZ_1T UL(0x10000000000) 48 #define SZ_4T UL(0x40000000000) 49 50 #define SZ_1P UL(0x4000000000000) 51 #else /* !__aarch64__ */ 52 #define SZ_32 U(0x00000020) 53 #define SZ_64 U(0x00000040) 54 #define SZ_128 U(0x00000080) 55 #define SZ_256 U(0x00000100) 56 #define SZ_512 U(0x00000200) 57 58 #define SZ_1K U(0x00000400) 59 #define SZ_2K U(0x00000800) 60 #define SZ_4K U(0x00001000) 61 #define SZ_8K U(0x00002000) 62 #define SZ_16K U(0x00004000) 63 #define SZ_32K U(0x00008000) 64 #define SZ_64K U(0x00010000) 65 #define SZ_128K U(0x00020000) 66 #define SZ_256K U(0x00040000) 67 #define SZ_512K U(0x00080000) 68 69 #define SZ_1M U(0x00100000) 70 #define SZ_2M U(0x00200000) 71 #define SZ_4M U(0x00400000) 72 #define SZ_8M U(0x00800000) 73 #define SZ_16M U(0x01000000) 74 #define SZ_32M U(0x02000000) 75 #define SZ_64M U(0x04000000) 76 #define SZ_128M U(0x08000000) 77 #define SZ_256M U(0x10000000) 78 #define SZ_512M U(0x20000000) 79 80 #define SZ_1G U(0x40000000) 81 #define SZ_2G U(0x80000000) 82 #endif /* __aarch64__ */ 83 84 /****************************************************************************** 85 * Required platform porting definitions that are expected to be common to 86 * all platforms 87 *****************************************************************************/ 88 89 /* 90 * Platform binary types for linking 91 */ 92 #ifdef __aarch64__ 93 #define PLATFORM_LINKER_FORMAT "elf64-littleaarch64" 94 #define PLATFORM_LINKER_ARCH aarch64 95 #else 96 #define PLATFORM_LINKER_FORMAT "elf32-littlearm" 97 #define PLATFORM_LINKER_ARCH arm 98 #endif /* __aarch64__ */ 99 100 /* 101 * Generic platform constants 102 */ 103 #define FIRMWARE_WELCOME_STR "Booting Trusted Firmware\n" 104 105 #define BL2_IMAGE_DESC { \ 106 .image_id = BL2_IMAGE_ID, \ 107 SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, \ 108 VERSION_2, image_info_t, 0), \ 109 .image_info.image_base = BL2_BASE, \ 110 .image_info.image_max_size = BL2_LIMIT - BL2_BASE,\ 111 SET_STATIC_PARAM_HEAD(ep_info, PARAM_EP, \ 112 VERSION_2, entry_point_info_t, SECURE | EXECUTABLE),\ 113 .ep_info.pc = BL2_BASE, \ 114 } 115 116 /* 117 * The following constants identify the extents of the code & read-only data 118 * regions. These addresses are used by the MMU setup code and therefore they 119 * must be page-aligned. 120 * 121 * When the code and read-only data are mapped as a single atomic section 122 * (i.e. when SEPARATE_CODE_AND_RODATA=0) then we treat the whole section as 123 * code by specifying the read-only data section as empty. 124 * 125 * BL1 is different than the other images in the sense that its read-write data 126 * originally lives in Trusted ROM and needs to be relocated in Trusted SRAM at 127 * run-time. Therefore, the read-write data in ROM can be mapped with the same 128 * memory attributes as the read-only data region. For this reason, BL1 uses 129 * different macros. 130 * 131 * Note that BL1_ROM_END is not necessarily aligned on a page boundary as it 132 * just points to the end of BL1's actual content in Trusted ROM. Therefore it 133 * needs to be rounded up to the next page size in order to map the whole last 134 * page of it with the right memory attributes. 135 */ 136 #if SEPARATE_CODE_AND_RODATA 137 138 #define BL1_CODE_END BL_CODE_END 139 #define BL1_RO_DATA_BASE BL_RO_DATA_BASE 140 #define BL1_RO_DATA_END round_up(BL1_ROM_END, PAGE_SIZE) 141 #if BL2_IN_XIP_MEM 142 #define BL2_CODE_END BL_CODE_END 143 #define BL2_RO_DATA_BASE BL_RO_DATA_BASE 144 #define BL2_RO_DATA_END round_up(BL2_ROM_END, PAGE_SIZE) 145 #endif /* BL2_IN_XIP_MEM */ 146 #else 147 #define BL_RO_DATA_BASE UL(0) 148 #define BL_RO_DATA_END UL(0) 149 #define BL1_CODE_END round_up(BL1_ROM_END, PAGE_SIZE) 150 #if BL2_IN_XIP_MEM 151 #define BL2_RO_DATA_BASE UL(0) 152 #define BL2_RO_DATA_END UL(0) 153 #define BL2_CODE_END round_up(BL2_ROM_END, PAGE_SIZE) 154 #endif /* BL2_IN_XIP_MEM */ 155 #endif /* SEPARATE_CODE_AND_RODATA */ 156 157 #if MEASURED_BOOT 158 /* 159 * Start critical data Ids from 2^32/2 reserving Ids from 0 to (2^32/2 - 1) 160 * for Images, It is a critical data Id base for all platforms. 161 */ 162 #define CRITICAL_DATA_ID_BASE U(0x80000000) 163 #endif /* MEASURED_BOOT */ 164 165 #endif /* COMMON_DEF_H */ 166