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 "juno_sds.h"
9 #include "software_mmap.h"
10
11 #include <mod_sds.h>
12
13 #include <fwk_assert.h>
14 #include <fwk_element.h>
15 #include <fwk_id.h>
16 #include <fwk_macros.h>
17 #include <fwk_module.h>
18
19 #include <stdbool.h>
20 #include <stdint.h>
21
22 static const uint32_t feature_flags = 0x00000000;
23 static const uint32_t version_packed = FWK_BUILD_VERSION;
24
25 static const struct mod_sds_region_desc sds_module_regions[] = {
26 [JUNO_SDS_REGION_SECURE] = {
27 .base = (void*)SCP_SDS_SECURE_BASE,
28 .size = SCP_SDS_SECURE_SIZE,
29 },
30 };
31
32 static_assert(
33 FWK_ARRAY_SIZE(sds_module_regions) == JUNO_SDS_REGION_COUNT,
34 "Mismatch between number of SDS regions and number of regions "
35 "provided by the SDS configuration.");
36
37 static const struct mod_sds_config sds_module_config = {
38 .regions = sds_module_regions,
39 .region_count = (unsigned int)JUNO_SDS_REGION_COUNT,
40 #ifdef BUILD_HAS_MOD_CLOCK
41 .clock_id = FWK_ID_NONE_INIT,
42 #endif
43 };
44
45 static const struct fwk_element element_table[] = {
46 [JUNO_SDS_RAM_VERSION_IDX] = {
47 .name = "",
48 .data = &(struct mod_sds_structure_desc) {
49 .id = (uint32_t) JUNO_SDS_RAM_VERSION,
50 .size = JUNO_SDS_RAM_VERSION_SIZE,
51 .region_id = (uint32_t) JUNO_SDS_REGION_SECURE,
52 .payload = &version_packed,
53 .finalize = true,
54 },
55 },
56 [JUNO_SDS_RAM_FEATURES_IDX] = {
57 .name = "",
58 .data = &(struct mod_sds_structure_desc) {
59 .id = (uint32_t) JUNO_SDS_FEATURE_AVAILABILITY,
60 .size = sizeof(feature_flags),
61 .region_id = (uint32_t) JUNO_SDS_REGION_SECURE,
62 .payload = &feature_flags,
63 .finalize = true,
64 },
65 },
66 [JUNO_SDS_RAM_IDX_COUNT] = { 0 },
67 };
68
get_element_table(fwk_id_t module_id)69 static const struct fwk_element *get_element_table(fwk_id_t module_id)
70 {
71 static_assert(BUILD_VERSION_MAJOR < UINT8_MAX, "Invalid version size");
72 static_assert(BUILD_VERSION_MINOR < UINT8_MAX, "Invalid version size");
73 static_assert(BUILD_VERSION_PATCH < UINT16_MAX, "Invalid version size");
74
75 return element_table;
76 }
77
78 struct fwk_module_config config_sds = {
79 .data = &sds_module_config,
80
81 .elements = FWK_MODULE_DYNAMIC_ELEMENTS(get_element_table),
82 };
83