1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2019-2021, Arm Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * Description:
8  *     Software-defined memory map shared between SCP and AP cores.
9  */
10 
11 #ifndef SOFTWARE_MMAP_H
12 #define SOFTWARE_MMAP_H
13 
14 #include "system_mmap.h"
15 
16 /*
17  * The 4KB "Context Region" at the base of Trusted SRAM is used for several
18  * purposes. These are: the Shared Data Storage (SDS) Memory Region, the SCMI
19  * secure payload areas, and the context area for Application Processor
20  * firmware.
21  *
22  * Shared Data Storage (SDS) Memory Region: Used for structured storage of data
23  * that is shared between SCP Firmware and Application Processor firmware. The
24  * SDS Memory Region occupies the area between the context region base and
25  * the SCMI Secure Payload base.
26  *
27  * SCMI Secure Payload Areas: Storage for SCMI message contents in both the
28  * Agent->Platform and Platform->Agent directions.
29  *
30  * Application Processor Context Area: The usage of this area is defined by the
31  * firmware running on the Application Processors. The SCP firmware must zero
32  * this memory before releasing any Application Processors. This area must
33  * always be located in the top 64 bytes of the 4KB reserved region.
34  *
35  *
36  *       +-----------------------+ 4096
37  *       |                       |
38  *   64B |    AP Context Area    |
39  *       |                       |
40  *       +-----------------------+
41  *       |                       |
42  *  256B |        Unused         |
43  *       |                       |
44  *       +-----------------------+
45  *       |                       |
46  *       |   SCMI Sec. Payload   |
47  *  128B |   Platform to Agent   |
48  *       |                       |
49  *       +-----------------------+
50  *       |                       |
51  *  128B |   SCMI Sec. Payload   |
52  *       |   Agent to Platform   |
53  *       |                       |
54  *       +-----------------------+
55  *       |                       |
56  * 3520B |   SDS Memory Region   |
57  *       |                       |
58  *       +-----------------------+ 0
59  */
60 
61 /* Context Region */
62 #define CONTEXT_REGION_BASE           (TRUSTED_RAM_BASE)
63 #define CONTEXT_REGION_SIZE           (4096)
64 #define CONTEXT_REGION_LIMIT          (CONTEXT_REGION_BASE + \
65                                        CONTEXT_REGION_SIZE)
66 /* AP Context Area */
67 #define AP_CONTEXT_BASE               (CONTEXT_REGION_LIMIT - AP_CONTEXT_SIZE)
68 #define AP_CONTEXT_SIZE               (64)
69 
70 /* SCMI Secure Payload Areas */
71 #define SCMI_PAYLOAD_SIZE             (128)
72 #define SCMI_PAYLOAD_S_BASE           (CONTEXT_REGION_BASE + 3520)
73 #define SCMI_PAYLOAD_S_A2P_BASE       (SCMI_PAYLOAD_S_BASE)
74 #define SCMI_PAYLOAD_S_P2A_BASE       (SCMI_PAYLOAD_S_A2P_BASE + \
75                                        SCMI_PAYLOAD_SIZE)
76 
77 /* SDS Memory Region */
78 #define SCP_SDS_SECURE_BASE           (CONTEXT_REGION_BASE)
79 #define SCP_SDS_SECURE_SIZE           (SCMI_PAYLOAD_S_BASE - \
80                                        CONTEXT_REGION_BASE)
81 
82 /* SCMI Payload Areas */
83 #define SCMI_PAYLOAD_LOW_A2P_BASE     (NONTRUSTED_RAM_BASE)
84 #define SCMI_PAYLOAD_LOW_P2A_BASE     (SCMI_PAYLOAD_LOW_A2P_BASE + \
85                                        SCMI_PAYLOAD_SIZE)
86 #define SCMI_PAYLOAD_HIGH_A2P_BASE    (SCMI_PAYLOAD_LOW_P2A_BASE + \
87                                        SCMI_PAYLOAD_SIZE)
88 #define SCMI_PAYLOAD_HIGH_P2A_BASE    (SCMI_PAYLOAD_HIGH_A2P_BASE + \
89                                        SCMI_PAYLOAD_SIZE)
90 
91 /* SCMIv2 Fast Channels */
92 #define SCMI_FAST_CHANNEL_BASE        (SCMI_PAYLOAD_HIGH_P2A_BASE + \
93                                        SCMI_PAYLOAD_SIZE)
94 
95 /* SCMIv2 Performance statistics region */
96 #define SCMI_PERF_STATS_BASE          (SCMI_FAST_CHANNEL_BASE + \
97                                        SCMI_PAYLOAD_SIZE)
98 #define SCMI_PERF_STATS_SIZE          (0x1000)
99 
100 #endif /* SOFTWARE_MMAP_H */
101