blob: 81bdfeb4f35c4728f47573c72dca7aa99695d46a [file] [log] [blame]
Soby Mathewb4c6df42022-11-09 11:13:29 +00001/*
2 * SPDX-License-Identifier: BSD-3-Clause
3 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4 */
5
AlexeiFedoroveaec0c42023-02-01 18:13:32 +00006#include <arch_features.h>
Soby Mathewb4c6df42022-11-09 11:13:29 +00007#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
24static 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);
AlexeiFedoroveaec0c42023-02-01 18:13:32 +000031 write_vpidr_el2(read_midr_el1());
32 write_mdcr_el2(MDCR_EL2_INIT |
33 INPLACE(MDCR_EL2_HPMN,
34 EXTRACT(PMCR_EL0_N, read_pmcr_el0())));
Soby Mathewb4c6df42022-11-09 11:13:29 +000035}
36
37void rmm_warmboot_main(void)
38{
39 /*
40 * Do the rest of RMM architecture init
41 */
42 rmm_arch_init();
43
44 /*
45 * Finish initializing the slot buffer mechanism
46 */
Javier Almansa Sobrinoed932592023-01-24 12:50:41 +000047 slot_buf_finish_warmboot_init();
Soby Mathewb4c6df42022-11-09 11:13:29 +000048}
49
50void rmm_main(void)
51{
52 unsigned int rmm_el3_ifc_version = rmm_el3_ifc_get_version();
53 unsigned int manifest_version = rmm_el3_ifc_get_manifest_version();
54
55 /*
56 * Report project name, version, build type and
57 * commit information if it is present
58 */
59 NOTICE("Booting %s v.%s(%s) %s Built with %s\n",
60 NAME, VERSION, RMM_BUILD_TYPE, COMMIT_INFO,
61#ifdef __clang__
62 VER_STRING("Clang ", __clang_major__, __clang_minor__,
63 __clang_patchlevel__)
64#else
65 VER_STRING("GCC ", __GNUC__, __GNUC_MINOR__,
66 __GNUC_PATCHLEVEL__)
67#endif
68 );
69
70 /* Report Boot Interface version */
71 NOTICE("RMM-EL3 Interface v.%u.%u\n",
72 RMM_EL3_IFC_GET_VERS_MAJOR(rmm_el3_ifc_version),
73 RMM_EL3_IFC_GET_VERS_MINOR(rmm_el3_ifc_version));
74
75 /* Report Boot Manifest version */
76 NOTICE("Boot Manifest Interface v.%u.%u\n",
77 RMM_EL3_MANIFEST_GET_VERS_MAJOR(manifest_version),
78 RMM_EL3_MANIFEST_GET_VERS_MINOR(manifest_version));
79
80 /* Report RMI/RSI ABI versions and build timestamp */
81 NOTICE("RMI/RSI ABI v.%u.%u/%u.%u built: %s %s\n",
82 RMI_ABI_VERSION_MAJOR, RMI_ABI_VERSION_MINOR,
83 RSI_ABI_VERSION_MAJOR, RSI_ABI_VERSION_MINOR,
84 __DATE__, __TIME__);
85
86 rmm_warmboot_main();
87
88 if (attestation_init() != 0) {
89 WARN("Attestation init failed.\n");
90 }
91}