Antonio Nino Diaz | 7289f92 | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 1 | /* |
Antonio Nino Diaz | cbccdbf | 2019-01-21 11:53:29 +0000 | [diff] [blame] | 2 | * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved. |
Antonio Nino Diaz | 7289f92 | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 6 | #ifndef ARM_SPM_DEF_H |
| 7 | #define ARM_SPM_DEF_H |
Antonio Nino Diaz | 7289f92 | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 8 | |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 9 | #include <lib/utils_def.h> |
| 10 | #include <lib/xlat_tables/xlat_tables_defs.h> |
| 11 | |
Antonio Nino Diaz | 7289f92 | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 12 | /* |
Antonio Nino Diaz | 840627f | 2018-11-27 08:36:02 +0000 | [diff] [blame] | 13 | * Reserve 4 MiB for binaries of Secure Partitions and Resource Description |
| 14 | * blobs. |
| 15 | */ |
| 16 | #define PLAT_SP_PACKAGE_BASE BL32_BASE |
| 17 | #define PLAT_SP_PACKAGE_SIZE ULL(0x400000) |
| 18 | |
| 19 | #define PLAT_MAP_SP_PACKAGE_MEM_RO MAP_REGION_FLAT( \ |
| 20 | PLAT_SP_PACKAGE_BASE, \ |
| 21 | PLAT_SP_PACKAGE_SIZE, \ |
| 22 | MT_MEMORY | MT_RO | MT_SECURE) |
| 23 | #define PLAT_MAP_SP_PACKAGE_MEM_RW MAP_REGION_FLAT( \ |
| 24 | PLAT_SP_PACKAGE_BASE, \ |
| 25 | PLAT_SP_PACKAGE_SIZE, \ |
| 26 | MT_MEMORY | MT_RW | MT_SECURE) |
| 27 | |
| 28 | /* |
| 29 | * The rest of the memory reserved for BL32 is free for SPM to use it as memory |
| 30 | * pool to allocate memory regions requested in the resource description. |
| 31 | */ |
| 32 | #define PLAT_SPM_HEAP_BASE (PLAT_SP_PACKAGE_BASE + PLAT_SP_PACKAGE_SIZE) |
| 33 | #define PLAT_SPM_HEAP_SIZE (BL32_LIMIT - BL32_BASE - PLAT_SP_PACKAGE_SIZE) |
| 34 | |
Antonio Nino Diaz | cbccdbf | 2019-01-21 11:53:29 +0000 | [diff] [blame] | 35 | #if SPM_MM |
Antonio Nino Diaz | 840627f | 2018-11-27 08:36:02 +0000 | [diff] [blame] | 36 | |
| 37 | /* |
Antonio Nino Diaz | 7289f92 | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 38 | * If BL31 is placed in DRAM, place the Secure Partition in DRAM right after the |
| 39 | * region used by BL31. If BL31 it is placed in SRAM, put the Secure Partition |
| 40 | * at the base of DRAM. |
| 41 | */ |
| 42 | #define ARM_SP_IMAGE_BASE BL32_BASE |
| 43 | #define ARM_SP_IMAGE_LIMIT BL32_LIMIT |
| 44 | /* The maximum size of the S-EL0 payload can be 3MB */ |
| 45 | #define ARM_SP_IMAGE_SIZE ULL(0x300000) |
| 46 | |
| 47 | #ifdef IMAGE_BL2 |
| 48 | /* SPM Payload memory. Mapped as RW in BL2. */ |
| 49 | #define ARM_SP_IMAGE_MMAP MAP_REGION_FLAT( \ |
| 50 | ARM_SP_IMAGE_BASE, \ |
| 51 | ARM_SP_IMAGE_SIZE, \ |
| 52 | MT_MEMORY | MT_RW | MT_SECURE) |
| 53 | #endif |
Antonio Nino Diaz | fe7b2be | 2018-10-30 11:54:20 +0000 | [diff] [blame] | 54 | |
Antonio Nino Diaz | 7289f92 | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 55 | #ifdef IMAGE_BL31 |
| 56 | /* SPM Payload memory. Mapped as code in S-EL1 */ |
| 57 | #define ARM_SP_IMAGE_MMAP MAP_REGION2( \ |
| 58 | ARM_SP_IMAGE_BASE, \ |
| 59 | ARM_SP_IMAGE_BASE, \ |
| 60 | ARM_SP_IMAGE_SIZE, \ |
| 61 | MT_CODE | MT_SECURE | MT_USER, \ |
| 62 | PAGE_SIZE) |
| 63 | #endif |
| 64 | |
| 65 | /* |
| 66 | * Memory shared between EL3 and S-EL0. It is used by EL3 to push data into |
| 67 | * S-EL0, so it is mapped with RW permission from EL3 and with RO permission |
| 68 | * from S-EL0. Placed after SPM Payload memory. |
| 69 | */ |
| 70 | #define PLAT_SPM_BUF_BASE (ARM_SP_IMAGE_BASE + ARM_SP_IMAGE_SIZE) |
| 71 | #define PLAT_SPM_BUF_SIZE ULL(0x100000) |
| 72 | |
| 73 | #define ARM_SPM_BUF_EL3_MMAP MAP_REGION_FLAT( \ |
| 74 | PLAT_SPM_BUF_BASE, \ |
| 75 | PLAT_SPM_BUF_SIZE, \ |
| 76 | MT_RW_DATA | MT_SECURE) |
| 77 | #define ARM_SPM_BUF_EL0_MMAP MAP_REGION2( \ |
| 78 | PLAT_SPM_BUF_BASE, \ |
| 79 | PLAT_SPM_BUF_BASE, \ |
| 80 | PLAT_SPM_BUF_SIZE, \ |
| 81 | MT_RO_DATA | MT_SECURE | MT_USER,\ |
| 82 | PAGE_SIZE) |
| 83 | |
| 84 | /* |
| 85 | * Memory shared between Normal world and S-EL0 for passing data during service |
| 86 | * requests. Mapped as RW and NS. Placed after the shared memory between EL3 and |
| 87 | * S-EL0. |
| 88 | */ |
Ard Biesheuvel | 8b034fc | 2018-12-29 19:43:21 +0100 | [diff] [blame] | 89 | #define PLAT_SP_IMAGE_NS_BUF_BASE (PLAT_SPM_BUF_BASE + PLAT_SPM_BUF_SIZE) |
| 90 | #define PLAT_SP_IMAGE_NS_BUF_SIZE ULL(0x10000) |
Antonio Nino Diaz | 7289f92 | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 91 | #define ARM_SP_IMAGE_NS_BUF_MMAP MAP_REGION2( \ |
Ard Biesheuvel | 8b034fc | 2018-12-29 19:43:21 +0100 | [diff] [blame] | 92 | PLAT_SP_IMAGE_NS_BUF_BASE, \ |
| 93 | PLAT_SP_IMAGE_NS_BUF_BASE, \ |
| 94 | PLAT_SP_IMAGE_NS_BUF_SIZE, \ |
Antonio Nino Diaz | 7289f92 | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 95 | MT_RW_DATA | MT_NS | MT_USER, \ |
| 96 | PAGE_SIZE) |
| 97 | |
| 98 | /* |
| 99 | * RW memory, which uses the remaining Trusted DRAM. Placed after the memory |
Sughosh Ganu | 5f21294 | 2018-05-16 15:35:25 +0530 | [diff] [blame] | 100 | * shared between Secure and Non-secure worlds, or after the platform specific |
| 101 | * buffers, if defined. First there is the stack memory for all CPUs and then |
| 102 | * there is the common heap memory. Both are mapped with RW permissions. |
Antonio Nino Diaz | 7289f92 | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 103 | */ |
Sughosh Ganu | 5f21294 | 2018-05-16 15:35:25 +0530 | [diff] [blame] | 104 | #define PLAT_SP_IMAGE_STACK_BASE PLAT_ARM_SP_IMAGE_STACK_BASE |
Antonio Nino Diaz | 7289f92 | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 105 | #define PLAT_SP_IMAGE_STACK_PCPU_SIZE ULL(0x2000) |
| 106 | #define ARM_SP_IMAGE_STACK_TOTAL_SIZE (PLATFORM_CORE_COUNT * \ |
| 107 | PLAT_SP_IMAGE_STACK_PCPU_SIZE) |
| 108 | |
| 109 | #define ARM_SP_IMAGE_HEAP_BASE (PLAT_SP_IMAGE_STACK_BASE + \ |
| 110 | ARM_SP_IMAGE_STACK_TOTAL_SIZE) |
| 111 | #define ARM_SP_IMAGE_HEAP_SIZE (ARM_SP_IMAGE_LIMIT - ARM_SP_IMAGE_HEAP_BASE) |
| 112 | |
| 113 | #define ARM_SP_IMAGE_RW_MMAP MAP_REGION2( \ |
| 114 | PLAT_SP_IMAGE_STACK_BASE, \ |
| 115 | PLAT_SP_IMAGE_STACK_BASE, \ |
| 116 | (ARM_SP_IMAGE_LIMIT - \ |
| 117 | PLAT_SP_IMAGE_STACK_BASE), \ |
| 118 | MT_RW_DATA | MT_SECURE | MT_USER,\ |
| 119 | PAGE_SIZE) |
| 120 | |
| 121 | /* Total number of memory regions with distinct properties */ |
| 122 | #define ARM_SP_IMAGE_NUM_MEM_REGIONS 6 |
| 123 | |
Antonio Nino Diaz | cbccdbf | 2019-01-21 11:53:29 +0000 | [diff] [blame] | 124 | #endif /* SPM_MM */ |
Antonio Nino Diaz | fe7b2be | 2018-10-30 11:54:20 +0000 | [diff] [blame] | 125 | |
Antonio Nino Diaz | 7289f92 | 2017-11-09 11:34:09 +0000 | [diff] [blame] | 126 | /* Cookies passed to the Secure Partition at boot. Not used by ARM platforms. */ |
| 127 | #define PLAT_SPM_COOKIE_0 ULL(0) |
| 128 | #define PLAT_SPM_COOKIE_1 ULL(0) |
| 129 | |
Antonio Nino Diaz | b86edcb | 2018-10-30 11:12:42 +0000 | [diff] [blame] | 130 | /* |
| 131 | * Max number of elements supported by SPM in this platform. The defines below |
| 132 | * are used to allocate memory at compile time for different arrays in SPM. |
| 133 | */ |
Antonio Nino Diaz | 8cc23f9 | 2018-10-30 11:35:30 +0000 | [diff] [blame] | 134 | #define PLAT_SPM_MAX_PARTITIONS U(2) |
| 135 | |
Antonio Nino Diaz | b86edcb | 2018-10-30 11:12:42 +0000 | [diff] [blame] | 136 | #define PLAT_SPM_MEM_REGIONS_MAX U(80) |
| 137 | #define PLAT_SPM_NOTIFICATIONS_MAX U(30) |
| 138 | #define PLAT_SPM_SERVICES_MAX U(30) |
| 139 | |
Antonio Nino Diaz | b5b585a | 2018-11-08 14:20:07 +0000 | [diff] [blame] | 140 | #define PLAT_SPCI_HANDLES_MAX_NUM U(20) |
Antonio Nino Diaz | 8903641 | 2018-10-18 14:54:57 +0100 | [diff] [blame] | 141 | #define PLAT_SPM_RESPONSES_MAX U(30) |
Antonio Nino Diaz | b5b585a | 2018-11-08 14:20:07 +0000 | [diff] [blame] | 142 | |
Antonio Nino Diaz | 5eb8837 | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 143 | #endif /* ARM_SPM_DEF_H */ |