summaryrefslogtreecommitdiff
path: root/cactus/cactus_helpers.c
diff options
context:
space:
mode:
authorSandrine Bailleux <sandrine.bailleux@arm.com>2018-03-13 13:16:12 +0100
committerSandrine Bailleux <sandrine.bailleux@arm.com>2018-03-19 11:54:40 +0000
commit90d54fce5f4c2ed0ab4de290e2c47f9093d998b2 (patch)
tree67090a9fa733bf5465ad520d966e6f1ff64559f8 /cactus/cactus_helpers.c
parent2c95f88f8fff99f8ab41bd1a7fd6b9100b18e445 (diff)
Cactus: Move legacy MM_COMMUNICATE code in a sub-directory
The goal is to easily build a version of Cactus that speaks the MM_COMMUNICATE legacy language, without interfering with the new SPCI/SPRT interfaces. This patch introduces the notion of "profile" for Cactus. For now, the only profile is "legacy". In a subsequent patch we will introduce a profile for SPCI/SPRT. Profiles are specified on the command line when building Cactus, e.g.: > make CACTUS_PROFILE=legacy cactus The initialisation code is shared amongst all profiles but then each profile is supposed to provide its own version of the secure_services_loop() function, which is called from cactus_main(). The profile name is printed in the version string at boot time. The cactus_sleep() function has been moved to the cactus_helpers.c file because it will be shared amongst the legacy and SPCI/SPRT profiles. Change-Id: Iab1d0ec972f9bd5b818eec6eed131fd0ea328c51 Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
Diffstat (limited to 'cactus/cactus_helpers.c')
-rw-r--r--cactus/cactus_helpers.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/cactus/cactus_helpers.c b/cactus/cactus_helpers.c
index 7b646bc..8844339 100644
--- a/cactus/cactus_helpers.c
+++ b/cactus/cactus_helpers.c
@@ -5,6 +5,8 @@
*/
#include <debug.h>
+#include <mmio.h>
+#include <platform_def.h>
#include <stdint.h>
#include <stdlib.h>
@@ -53,3 +55,17 @@ void announce_test_end(const char *test_desc)
INFO("Test \"%s\" passed.\n", test_desc);
}
+void cactus_sleep(uint32_t duration_sec)
+{
+ uint32_t timer_freq = mmio_read_32(SYS_CNT_CONTROL_BASE + CNTFID_OFF);
+ VERBOSE("Timer frequency = %u\n", timer_freq);
+
+ INFO("Sleeping for %u seconds...\n", duration_sec);
+ uint64_t time1 = mmio_read_64(SYS_CNT_READ_BASE);
+ volatile uint64_t time2 = time1;
+ while ((time2 - time1) < duration_sec * timer_freq) {
+ time2 = mmio_read_64(SYS_CNT_READ_BASE);
+ }
+
+ INFO("Done\n");
+}