1 /*
2  * Copyright (c) 2023, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include <stdint.h>
9 #include "common_target_cfg.h"
10 #include "tfm_hal_platform.h"
11 #include "region.h"
12 #include "region_defs.h"
13 
14 /* The section names come from the scatter file */
15 REGION_DECLARE(Load$$LR$$, LR_NS_PARTITION, $$Base);
16 REGION_DECLARE(Image$$, ER_VENEER, $$Base);
17 REGION_DECLARE(Image$$, VENEER_ALIGN, $$Limit);
18 #ifdef BL2
19 REGION_DECLARE(Load$$LR$$, LR_SECONDARY_PARTITION, $$Base);
20 #endif /* BL2 */
21 
22 const struct memory_region_limits memory_regions = {
23     .non_secure_code_start =
24         (uint32_t)&REGION_NAME(Load$$LR$$, LR_NS_PARTITION, $$Base) +
25         BL2_HEADER_SIZE,
26 
27     .non_secure_partition_base =
28         (uint32_t)&REGION_NAME(Load$$LR$$, LR_NS_PARTITION, $$Base),
29 
30     .non_secure_partition_limit =
31         (uint32_t)&REGION_NAME(Load$$LR$$, LR_NS_PARTITION, $$Base) +
32         NS_PARTITION_SIZE - 1,
33 
34     .veneer_base =
35         (uint32_t)&REGION_NAME(Image$$, ER_VENEER, $$Base),
36 
37     .veneer_limit =
38         (uint32_t)&REGION_NAME(Image$$, VENEER_ALIGN, $$Limit) - 1,
39 
40 #ifdef BL2
41     .secondary_partition_base =
42         (uint32_t)&REGION_NAME(Load$$LR$$, LR_SECONDARY_PARTITION, $$Base),
43 
44     .secondary_partition_limit =
45         (uint32_t)&REGION_NAME(Load$$LR$$, LR_SECONDARY_PARTITION, $$Base) +
46         SECONDARY_PARTITION_SIZE - 1,
47 #endif /* BL2 */
48 };
49 
tfm_hal_get_ns_VTOR(void)50 uint32_t tfm_hal_get_ns_VTOR(void)
51 {
52     return memory_regions.non_secure_code_start;
53 }
54 
tfm_hal_get_ns_MSP(void)55 uint32_t tfm_hal_get_ns_MSP(void)
56 {
57     return *((uint32_t *)memory_regions.non_secure_code_start);
58 }
59 
tfm_hal_get_ns_entry_point(void)60 uint32_t tfm_hal_get_ns_entry_point(void)
61 {
62     return *((uint32_t *)(memory_regions.non_secure_code_start + 4));
63 }
64