Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 1 | /* |
Javier Almansa Sobrino | 7176a77 | 2021-11-24 18:37:37 +0000 | [diff] [blame] | 2 | * Copyright (c) 2021-2022, ARM Limited and Contributors. All rights reserved. |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | #ifndef ARM_PAS_DEF_H |
| 7 | #define ARM_PAS_DEF_H |
| 8 | |
johpow01 | 9d13402 | 2021-06-16 17:57:28 -0500 | [diff] [blame] | 9 | #include <lib/gpt_rme/gpt_rme.h> |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 10 | #include <plat/arm/common/arm_def.h> |
| 11 | |
| 12 | /***************************************************************************** |
| 13 | * PAS regions used to initialize the Granule Protection Table (GPT) |
| 14 | ****************************************************************************/ |
| 15 | |
| 16 | /* |
| 17 | * The PA space is initially mapped in the GPT as follows: |
| 18 | * |
| 19 | * ============================================================================ |
| 20 | * Base Addr| Size |L? GPT|PAS |Content |Comment |
| 21 | * ============================================================================ |
| 22 | * 0GB | 1GB |L0 GPT|ANY |TBROM (EL3 code) |Fixed mapping |
| 23 | * | | | |TSRAM (EL3 data) | |
AlexeiFedorov | aa44249 | 2022-11-29 13:32:41 +0000 | [diff] [blame] | 24 | * 00000000 | | | |IO (incl.UARTs & GIC) | |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 25 | * ---------------------------------------------------------------------------- |
| 26 | * 1GB | 1GB |L0 GPT|ANY |IO |Fixed mapping |
AlexeiFedorov | aa44249 | 2022-11-29 13:32:41 +0000 | [diff] [blame] | 27 | * 40000000 | | | | | |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 28 | * ---------------------------------------------------------------------------- |
AlexeiFedorov | aa44249 | 2022-11-29 13:32:41 +0000 | [diff] [blame] | 29 | * 2GB |2GB-64MB |L1 GPT|NS |DRAM (NS Kernel) |Use T.Descrip |
| 30 | * 80000000 | | | | | |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 31 | * ---------------------------------------------------------------------------- |
AlexeiFedorov | aa44249 | 2022-11-29 13:32:41 +0000 | [diff] [blame] | 32 | * 4GB-64MB |64MB-32MB-4MB|L1 GPT|SECURE|DRAM TZC |Use T.Descrip |
| 33 | * FC000000 | | | | | |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 34 | * ---------------------------------------------------------------------------- |
| 35 | * 4GB-32MB | | | | | |
| 36 | * -3MB-1MB |32MB |L1 GPT|REALM |RMM |Use T.Descrip |
AlexeiFedorov | aa44249 | 2022-11-29 13:32:41 +0000 | [diff] [blame] | 37 | * FDC00000 | | | | | |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 38 | * ---------------------------------------------------------------------------- |
| 39 | * 4GB-3MB | | | | | |
| 40 | * -1MB |3MB |L1 GPT|ROOT |EL3 DRAM data |Use T.Descrip |
AlexeiFedorov | aa44249 | 2022-11-29 13:32:41 +0000 | [diff] [blame] | 41 | * FFC00000 | | | | | |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 42 | * ---------------------------------------------------------------------------- |
| 43 | * 4GB-1MB |1MB |L1 GPT|ROOT |DRAM (L1 GPTs, SCP TZC) |Fixed mapping |
AlexeiFedorov | aa44249 | 2022-11-29 13:32:41 +0000 | [diff] [blame] | 44 | * FFF00000 | | | | | |
| 45 | * ---------------------------------------------------------------------------- |
| 46 | * 34GB |2GB |L1 GPT|NS |DRAM (NS Kernel) |Use T.Descrip |
| 47 | * 880000000| | | | | |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 48 | * ============================================================================ |
| 49 | * |
| 50 | * - 4KB of L0 GPT reside in TSRAM, on top of the CONFIG section. |
| 51 | * - ~1MB of L1 GPTs reside at the top of DRAM1 (TZC area). |
johpow01 | 9d13402 | 2021-06-16 17:57:28 -0500 | [diff] [blame] | 52 | * - The first 1GB region has GPT_GPI_ANY and, therefore, is not protected by |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 53 | * the GPT. |
| 54 | * - The DRAM TZC area is split into three regions: the L1 GPT region and |
johpow01 | 9d13402 | 2021-06-16 17:57:28 -0500 | [diff] [blame] | 55 | * 3MB of region below that are defined as GPT_GPI_ROOT, 32MB Realm region |
| 56 | * below that is defined as GPT_GPI_REALM and the rest of it is defined as |
| 57 | * GPT_GPI_SECURE. |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 58 | */ |
| 59 | |
| 60 | /* TODO: This might not be the best way to map the PAS */ |
| 61 | |
| 62 | /* Device memory 0 to 2GB */ |
| 63 | #define ARM_PAS_1_BASE (U(0)) |
AlexeiFedorov | aa44249 | 2022-11-29 13:32:41 +0000 | [diff] [blame] | 64 | #define ARM_PAS_1_SIZE ((ULL(1) << 31)) /* 2GB */ |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 65 | |
| 66 | /* NS memory 2GB to (end - 64MB) */ |
| 67 | #define ARM_PAS_2_BASE (ARM_PAS_1_BASE + ARM_PAS_1_SIZE) |
| 68 | #define ARM_PAS_2_SIZE (ARM_NS_DRAM1_SIZE) |
| 69 | |
Javier Almansa Sobrino | 7176a77 | 2021-11-24 18:37:37 +0000 | [diff] [blame] | 70 | /* Shared area between EL3 and RMM */ |
| 71 | #define ARM_PAS_SHARED_BASE (ARM_EL3_RMM_SHARED_BASE) |
| 72 | #define ARM_PAS_SHARED_SIZE (ARM_EL3_RMM_SHARED_SIZE) |
| 73 | |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 74 | /* Secure TZC region */ |
| 75 | #define ARM_PAS_3_BASE (ARM_AP_TZC_DRAM1_BASE) |
| 76 | #define ARM_PAS_3_SIZE (ARM_AP_TZC_DRAM1_SIZE) |
| 77 | |
AlexeiFedorov | aa44249 | 2022-11-29 13:32:41 +0000 | [diff] [blame] | 78 | /* NS memory 2GB */ |
| 79 | #define ARM_PAS_4_BASE ARM_DRAM2_BASE |
| 80 | #define ARM_PAS_4_SIZE ((ULL(1) << 31)) /* 2GB */ |
| 81 | |
johpow01 | 9d13402 | 2021-06-16 17:57:28 -0500 | [diff] [blame] | 82 | #define ARM_PAS_GPI_ANY MAP_GPT_REGION(ARM_PAS_1_BASE, \ |
| 83 | ARM_PAS_1_SIZE, \ |
| 84 | GPT_GPI_ANY) |
AlexeiFedorov | aa44249 | 2022-11-29 13:32:41 +0000 | [diff] [blame] | 85 | |
johpow01 | 9d13402 | 2021-06-16 17:57:28 -0500 | [diff] [blame] | 86 | #define ARM_PAS_KERNEL GPT_MAP_REGION_GRANULE(ARM_PAS_2_BASE, \ |
| 87 | ARM_PAS_2_SIZE, \ |
| 88 | GPT_GPI_NS) |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 89 | |
johpow01 | 9d13402 | 2021-06-16 17:57:28 -0500 | [diff] [blame] | 90 | #define ARM_PAS_SECURE GPT_MAP_REGION_GRANULE(ARM_PAS_3_BASE, \ |
| 91 | ARM_PAS_3_SIZE, \ |
| 92 | GPT_GPI_SECURE) |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 93 | |
AlexeiFedorov | aa44249 | 2022-11-29 13:32:41 +0000 | [diff] [blame] | 94 | #define ARM_PAS_KERNEL_1 GPT_MAP_REGION_GRANULE(ARM_PAS_4_BASE, \ |
| 95 | ARM_PAS_4_SIZE, \ |
| 96 | GPT_GPI_NS) |
Javier Almansa Sobrino | 7176a77 | 2021-11-24 18:37:37 +0000 | [diff] [blame] | 97 | /* |
| 98 | * REALM and Shared area share the same PAS, so consider them a single |
| 99 | * PAS region to configure in GPT. |
| 100 | */ |
johpow01 | 9d13402 | 2021-06-16 17:57:28 -0500 | [diff] [blame] | 101 | #define ARM_PAS_REALM GPT_MAP_REGION_GRANULE(ARM_REALM_BASE, \ |
Javier Almansa Sobrino | 7176a77 | 2021-11-24 18:37:37 +0000 | [diff] [blame] | 102 | (ARM_PAS_SHARED_SIZE + \ |
| 103 | ARM_REALM_SIZE), \ |
johpow01 | 9d13402 | 2021-06-16 17:57:28 -0500 | [diff] [blame] | 104 | GPT_GPI_REALM) |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 105 | |
johpow01 | 9d13402 | 2021-06-16 17:57:28 -0500 | [diff] [blame] | 106 | #define ARM_PAS_EL3_DRAM GPT_MAP_REGION_GRANULE(ARM_EL3_TZC_DRAM1_BASE, \ |
| 107 | ARM_EL3_TZC_DRAM1_SIZE, \ |
| 108 | GPT_GPI_ROOT) |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 109 | |
johpow01 | 9d13402 | 2021-06-16 17:57:28 -0500 | [diff] [blame] | 110 | #define ARM_PAS_GPTS GPT_MAP_REGION_GRANULE(ARM_L1_GPT_ADDR_BASE, \ |
| 111 | ARM_L1_GPT_SIZE, \ |
| 112 | GPT_GPI_ROOT) |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 113 | |
Zelalem Aweke | 5085abd | 2021-07-13 17:19:54 -0500 | [diff] [blame] | 114 | /* GPT Configuration options */ |
Zelalem Aweke | 5085abd | 2021-07-13 17:19:54 -0500 | [diff] [blame] | 115 | #define PLATFORM_L0GPTSZ GPCCR_L0GPTSZ_30BITS |
| 116 | |
Zelalem Aweke | c43c563 | 2021-07-12 23:41:05 -0500 | [diff] [blame] | 117 | #endif /* ARM_PAS_DEF_H */ |