Trusted Firmware-A Tests, version 2.0
This is the first public version of the tests for the Trusted
Firmware-A project. Please see the documentation provided in the
source tree for more details.
Change-Id: I6f3452046a1351ac94a71b3525c30a4ca8db7867
Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
Co-authored-by: amobal01 <amol.balasokamble@arm.com>
Co-authored-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
Co-authored-by: Asha R <asha.r@arm.com>
Co-authored-by: Chandni Cherukuri <chandni.cherukuri@arm.com>
Co-authored-by: David Cunado <david.cunado@arm.com>
Co-authored-by: Dimitris Papastamos <dimitris.papastamos@arm.com>
Co-authored-by: Douglas Raillard <douglas.raillard@arm.com>
Co-authored-by: dp-arm <dimitris.papastamos@arm.com>
Co-authored-by: Jeenu Viswambharan <jeenu.viswambharan@arm.com>
Co-authored-by: Jonathan Wright <jonathan.wright@arm.com>
Co-authored-by: Kévin Petit <kevin.petit@arm.com>
Co-authored-by: Roberto Vargas <roberto.vargas@arm.com>
Co-authored-by: Sathees Balya <sathees.balya@arm.com>
Co-authored-by: Shawon Roy <Shawon.Roy@arm.com>
Co-authored-by: Soby Mathew <soby.mathew@arm.com>
Co-authored-by: Thomas Abraham <thomas.abraham@arm.com>
Co-authored-by: Vikram Kanigiri <vikram.kanigiri@arm.com>
Co-authored-by: Yatharth Kochar <yatharth.kochar@arm.com>
diff --git a/plat/common/plat_common.c b/plat/common/plat_common.c
new file mode 100644
index 0000000..5713871
--- /dev/null
+++ b/plat/common/plat_common.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2018, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <arch_helpers.h>
+#include <console.h>
+#include <debug.h>
+#include <platform.h>
+#include <sp805.h>
+#include <xlat_tables_v2.h>
+
+/*
+ * The following platform functions are all weakly defined. They provide typical
+ * implementations that may be re-used by multiple platforms but may also be
+ * overridden by a platform if required.
+ */
+
+#pragma weak tftf_platform_end
+#pragma weak tftf_platform_watchdog_set
+#pragma weak tftf_platform_watchdog_reset
+#pragma weak tftf_plat_configure_mmu
+#pragma weak tftf_plat_enable_mmu
+#pragma weak tftf_plat_reset
+#pragma weak plat_get_prot_regions
+
+#if IMAGE_TFTF
+
+#define IMAGE_RO_BASE TFTF_BASE
+IMPORT_SYM(uintptr_t, __RO_END__, IMAGE_RO_END);
+
+#define IMAGE_RW_BASE IMAGE_RO_END
+IMPORT_SYM(uintptr_t, __TFTF_END__, IMAGE_RW_END);
+
+IMPORT_SYM(uintptr_t, __COHERENT_RAM_START__, COHERENT_RAM_START);
+IMPORT_SYM(uintptr_t, __COHERENT_RAM_END__, COHERENT_RAM_END);
+
+#elif IMAGE_NS_BL1U
+
+IMPORT_SYM(uintptr_t, __RO_END__, IMAGE_RO_END_UNALIGNED);
+#define IMAGE_RO_BASE NS_BL1U_RO_BASE
+#define IMAGE_RO_END round_up(IMAGE_RO_END_UNALIGNED, PAGE_SIZE)
+
+#define IMAGE_RW_BASE NS_BL1U_RW_BASE
+IMPORT_SYM(uintptr_t, __NS_BL1U_RAM_END__, IMAGE_RW_END);
+
+#elif IMAGE_NS_BL2U
+
+#define IMAGE_RO_BASE NS_BL2U_BASE
+IMPORT_SYM(uintptr_t, __RO_END__, IMAGE_RO_END);
+
+#define IMAGE_RW_BASE IMAGE_RO_END
+IMPORT_SYM(uintptr_t, __NS_BL2U_END__, IMAGE_RW_END_UNALIGNED);
+#define IMAGE_RW_END round_up(IMAGE_RW_END_UNALIGNED, PAGE_SIZE)
+
+#endif
+
+void tftf_platform_end(void)
+{
+ /*
+ * Send EOT (End Of Transmission) on the UART.
+ * This can be used to shutdown a software model.
+ */
+ static const char ascii_eot = 4;
+ console_putc(ascii_eot);
+}
+
+void tftf_platform_watchdog_set(void)
+{
+ /* Placeholder function which should be redefined by each platform */
+}
+
+void tftf_platform_watchdog_reset(void)
+{
+ /* Placeholder function which should be redefined by each platform */
+}
+
+void tftf_plat_configure_mmu(void)
+{
+ /* RO data + Code */
+ mmap_add_region(IMAGE_RO_BASE, IMAGE_RO_BASE,
+ IMAGE_RO_END - IMAGE_RO_BASE, MT_CODE);
+
+ /* Data + BSS */
+ mmap_add_region(IMAGE_RW_BASE, IMAGE_RW_BASE,
+ IMAGE_RW_END - IMAGE_RW_BASE, MT_RW_DATA);
+
+#if IMAGE_TFTF
+ mmap_add_region(COHERENT_RAM_START, COHERENT_RAM_START,
+ COHERENT_RAM_END - COHERENT_RAM_START,
+ MT_DEVICE | MT_RW | MT_NS);
+#endif
+
+ mmap_add(tftf_platform_get_mmap());
+ init_xlat_tables();
+
+ tftf_plat_enable_mmu();
+}
+
+void tftf_plat_enable_mmu(void)
+{
+#ifndef AARCH32
+ if (IS_IN_EL1())
+ enable_mmu_el1(0);
+ else if (IS_IN_EL2())
+ enable_mmu_el2(0);
+ else
+ panic();
+#else
+ if (IS_IN_HYP())
+ enable_mmu_hyp(0);
+ else
+ enable_mmu_svc_mon(0);
+#endif
+}
+
+void tftf_plat_reset(void)
+{
+ /*
+ * SP805 peripheral interrupt is not serviced in TFTF. The reset signal
+ * generated by it is used to reset the platform.
+ */
+ sp805_wdog_start(1);
+
+ /*
+ * Reset might take some execution cycles, Depending on the ratio between
+ * CPU clock frequency and Watchdog clock frequency
+ */
+ while (1)
+ ;
+}
+
+const mem_region_t *plat_get_prot_regions(int *nelem)
+{
+ *nelem = 0;
+ return NULL;
+}