1 /*
2 * SPDX-License-Identifier: BSD-3-Clause
3 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4 */
5
6 #include <arch_helpers.h>
7 #include <attestation.h>
8 #include <buffer.h>
9 #include <debug.h>
10 #include <rmm_el3_ifc.h>
11 #include <smc-rmi.h>
12 #include <smc-rsi.h>
13
14 #ifdef NDEBUG
15 #define RMM_BUILD_TYPE "release"
16 #else
17 #define RMM_BUILD_TYPE "debug"
18 #endif
19
20 #define VER_STRING(toolchain, major, minor, patch) \
21 toolchain __STRING(major) "." \
22 __STRING(minor) "." __STRING(patch)
23
rmm_arch_init(void)24 static void rmm_arch_init(void)
25 {
26 MPAM(write_mpam2_el2(MPAM2_EL2_INIT));
27 MPAM(write_mpamhcr_el2(MPAMHCR_EL2_INIT));
28 SPE(write_pmscr_el2(PMSCR_EL2_INIT));
29
30 write_cnthctl_el2(CNTHCTL_EL2_INIT);
31 write_mdcr_el2(MDCR_EL2_INIT);
32 }
33
rmm_warmboot_main(void)34 void rmm_warmboot_main(void)
35 {
36 /*
37 * Do the rest of RMM architecture init
38 */
39 rmm_arch_init();
40
41 /*
42 * Finish initializing the slot buffer mechanism
43 */
44 slot_buf_init();
45 }
46
rmm_main(void)47 void rmm_main(void)
48 {
49 unsigned int rmm_el3_ifc_version = rmm_el3_ifc_get_version();
50 unsigned int manifest_version = rmm_el3_ifc_get_manifest_version();
51
52 /*
53 * Report project name, version, build type and
54 * commit information if it is present
55 */
56 NOTICE("Booting %s v.%s(%s) %s Built with %s\n",
57 NAME, VERSION, RMM_BUILD_TYPE, COMMIT_INFO,
58 #ifdef __clang__
59 VER_STRING("Clang ", __clang_major__, __clang_minor__,
60 __clang_patchlevel__)
61 #else
62 VER_STRING("GCC ", __GNUC__, __GNUC_MINOR__,
63 __GNUC_PATCHLEVEL__)
64 #endif
65 );
66
67 /* Report Boot Interface version */
68 NOTICE("RMM-EL3 Interface v.%u.%u\n",
69 RMM_EL3_IFC_GET_VERS_MAJOR(rmm_el3_ifc_version),
70 RMM_EL3_IFC_GET_VERS_MINOR(rmm_el3_ifc_version));
71
72 /* Report Boot Manifest version */
73 NOTICE("Boot Manifest Interface v.%u.%u\n",
74 RMM_EL3_MANIFEST_GET_VERS_MAJOR(manifest_version),
75 RMM_EL3_MANIFEST_GET_VERS_MINOR(manifest_version));
76
77 /* Report RMI/RSI ABI versions and build timestamp */
78 NOTICE("RMI/RSI ABI v.%u.%u/%u.%u built: %s %s\n",
79 RMI_ABI_VERSION_MAJOR, RMI_ABI_VERSION_MINOR,
80 RSI_ABI_VERSION_MAJOR, RSI_ABI_VERSION_MINOR,
81 __DATE__, __TIME__);
82
83 rmm_warmboot_main();
84
85 if (attestation_init() != 0) {
86 WARN("Attestation init failed.\n");
87 }
88 }
89