1 /*
2 * Arm SCP/MCP Software
3 * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8 #include "clock_soc.h"
9 #include "scp_mmap.h"
10 #include "scp_pik.h"
11 #include "tc2_sds.h"
12
13 #include <mod_sds.h>
14
15 #include <fwk_assert.h>
16 #include <fwk_element.h>
17 #include <fwk_id.h>
18 #include <fwk_macros.h>
19 #include <fwk_module.h>
20 #include <fwk_module_idx.h>
21
22 #include <stdbool.h>
23 #include <stdint.h>
24
25 static const uint32_t feature_flags = 0x00000000;
26
27 static const struct mod_sds_region_desc sds_module_regions[1] = {
28 [TC2_SDS_REGION_SECURE] =
29 {
30 .base = (void *)SCP_SDS_MEM_BASE,
31 .size = SCP_SDS_MEM_SIZE,
32 },
33 };
34
35 static_assert(
36 FWK_ARRAY_SIZE(sds_module_regions) == TC2_SDS_REGION_COUNT,
37 "Mismatch between number of SDS regions and number of regions "
38 "provided by the SDS configuration.");
39
40 const struct mod_sds_config sds_module_config = {
41 .regions = sds_module_regions,
42 .region_count = TC2_SDS_REGION_COUNT,
43 .clock_id =
44 FWK_ID_ELEMENT_INIT(FWK_MODULE_IDX_CLOCK, CLOCK_IDX_CPU_GROUP_HAYES)
45 };
46
47 static struct fwk_element sds_element_table[4] = {
48 {
49 .name = "CPU Info",
50 .data = &((struct mod_sds_structure_desc){
51 .id = TC2_SDS_CPU_INFO,
52 .size = TC2_SDS_CPU_INFO_SIZE,
53 .region_id = TC2_SDS_REGION_SECURE,
54 .finalize = true,
55 }),
56 },
57 {
58 .name = "Feature Availability",
59 .data = &((struct mod_sds_structure_desc){
60 .id = TC2_SDS_FEATURE_AVAILABILITY,
61 .size = TC2_SDS_FEATURE_AVAILABILITY_SIZE,
62 .payload = &feature_flags,
63 .region_id = TC2_SDS_REGION_SECURE,
64 .finalize = true,
65 }),
66 },
67 {
68 .name = "Bootloader",
69 .data = &((struct mod_sds_structure_desc){
70 .id = TC2_SDS_BOOTLOADER,
71 .size = TC2_SDS_BOOTLOADER_SIZE,
72 .region_id = TC2_SDS_REGION_SECURE,
73 .finalize = true,
74 }),
75 },
76 { 0 }, /* Termination description. */
77 };
78
79 static_assert(
80 SCP_SDS_MEM_SIZE > TC2_SDS_CPU_INFO_SIZE +
81 TC2_SDS_FEATURE_AVAILABILITY_SIZE + TC2_SDS_BOOTLOADER_SIZE,
82 "SDS structures too large for SDS SRAM.\n");
83
sds_get_element_table(fwk_id_t module_id)84 static const struct fwk_element *sds_get_element_table(fwk_id_t module_id)
85 {
86 static_assert(BUILD_VERSION_MAJOR < UINT8_MAX, "Invalid version size");
87 static_assert(BUILD_VERSION_MINOR < UINT8_MAX, "Invalid version size");
88 static_assert(BUILD_VERSION_PATCH < UINT16_MAX, "Invalid version size");
89
90 return sds_element_table;
91 }
92
93 struct fwk_module_config config_sds = {
94 .elements = FWK_MODULE_DYNAMIC_ELEMENTS(sds_get_element_table),
95 .data = &sds_module_config,
96 };
97