feat(fake_host): unify boot manifest setup in host platforms
Unify boot manifest and sysreg setup in host platforms.
Signed-off-by: Mate Toth-Pal <mate.toth-pal@arm.com>
Change-Id: I3d273f5bb8cb88d95278b9039573d837e12f4d56
diff --git a/plat/host/common/src/host_utils.c b/plat/host/common/src/host_utils.c
index 3959008..7f1a68f 100644
--- a/plat/host/common/src/host_utils.c
+++ b/plat/host/common/src/host_utils.c
@@ -6,9 +6,11 @@
#include <assert.h>
#include <debug.h>
#include <errno.h>
+#include <gic.h>
#include <host_defs.h>
#include <host_utils.h>
#include <plat_common.h>
+#include <rmm_el3_ifc.h>
#include <string.h>
#include <xlat_tables.h>
@@ -23,6 +25,17 @@
static unsigned char granules_buffer[HOST_MEM_SIZE] __aligned(GRANULE_SIZE);
/*
+ * Define and set the Boot Interface arguments.
+ */
+static unsigned char el3_rmm_shared_buffer[PAGE_SIZE] __aligned(PAGE_SIZE);
+
+/*
+ * Create a basic boot manifest.
+ */
+static struct rmm_core_manifest *boot_manifest =
+ (struct rmm_core_manifest *)el3_rmm_shared_buffer;
+
+/*
* Generic callback to access a sysreg for reading.
*/
static u_register_t sysreg_rd_cb(u_register_t *reg)
@@ -113,3 +126,45 @@
current_cpuid = cpuid;
}
+
+unsigned char *host_util_get_el3_rmm_shared_buffer(void)
+{
+ return el3_rmm_shared_buffer;
+}
+
+void host_util_setup_sysreg_and_boot_manifest(void)
+{
+ int ret;
+
+ /*
+ * Initialize ID_AA64MMFR0_EL1 with a physical address
+ * range of 48 bits (PARange bits set to 0b0101)
+ */
+ ret = host_util_set_default_sysreg_cb("id_aa64mmfr0_el1",
+ INPLACE(ID_AA64MMFR0_EL1_PARANGE, 5UL));
+
+ /*
+ * Initialize ICH_VTR_EL2 with 6 preemption bits.
+ * (PREbits is equal number of preemption bits minus one)
+ */
+ ret = host_util_set_default_sysreg_cb("ich_vtr_el2",
+ INPLACE(ICH_VTR_EL2_PRE_BITS, 5UL));
+
+ /* SCTLR_EL2 is reset to zero */
+ ret = host_util_set_default_sysreg_cb("sctlr_el2", 0UL);
+
+ /* TPIDR_EL2 is reset to zero */
+ ret = host_util_set_default_sysreg_cb("tpidr_el2", 0UL);
+
+ /*
+ * Only check the return value of the last callback setup, to detect
+ * if we are out of callback slots.
+ */
+ if (ret != 0) {
+ panic();
+ }
+
+ /* Initialize the boot manifest */
+ boot_manifest->version = RMM_EL3_IFC_SUPPORTED_VERSION;
+ boot_manifest->plat_data = (uintptr_t)NULL;
+}