summaryrefslogtreecommitdiff
path: root/cactus
diff options
context:
space:
mode:
authorSandrine Bailleux <sandrine.bailleux@arm.com>2017-12-05 15:35:06 +0000
committerSandrine Bailleux <sandrine.bailleux@arm.com>2017-12-12 15:42:43 +0000
commitf0153912f775b6ebaa7b18052b6d6e802a156eb6 (patch)
tree7cbf2cc21fcbf7b7ad198079cd73327e65a3f3e9 /cactus
parent00dc84188ea8cbc89d25cb00d794b5393f6c7cc7 (diff)
Cactus: Handle secure services requests
At the moment, Cactus doesn't really fulfil the role of a Secure Partition because it does not expose any secure service. It is involved during boot time only (where it exercises the memory management features provided by the SPM) and then does not serve any purpose at run time. This patch adds a run time dimension to Cactus. After sending the first SP_EVENT_COMPLETE SVC to SPM to signal it has completed its initialisations, Cactus is now able to handle service requests. For now, only the MM_COMMUNICATE call is supported. Change-Id: Icb3094f1bff2f618eaca3d63126ea183aebe23e3 Signed-off-by: Sandrine Bailleux <sandrine.bailleux@arm.com>
Diffstat (limited to 'cactus')
-rw-r--r--cactus/aarch64/cactus_entrypoint.S10
-rw-r--r--cactus/cactus_main.c48
2 files changed, 46 insertions, 12 deletions
diff --git a/cactus/aarch64/cactus_entrypoint.S b/cactus/aarch64/cactus_entrypoint.S
index 1eaa6bb..6ac51a7 100644
--- a/cactus/aarch64/cactus_entrypoint.S
+++ b/cactus/aarch64/cactus_entrypoint.S
@@ -97,15 +97,7 @@ func cactus_entrypoint
/* And do the rest in C code */
mov x0, x20
mov x1, x21
- bl cactus_main
-
- /* Tell SPM that we are done initialising */
- mov_imm x0, SP_EVENT_COMPLETE_AARCH64
- mov x1, #0
- svc #0
-
- /* Loop forever */
- b .
+ b cactus_main
.return_error:
/* Tell SPM that the initialization failed. */
diff --git a/cactus/cactus_main.c b/cactus/cactus_main.c
index 2a33735..eab80b8 100644
--- a/cactus/cactus_main.c
+++ b/cactus/cactus_main.c
@@ -10,9 +10,11 @@
#include <plat_arm.h>
#include <platform_def.h>
#include <secure_partition.h>
+#include <spm_svc.h>
#include <std_svc.h>
#include "cactus.h"
+#include "cactus_helpers.h"
#include "cactus_tests.h"
@@ -68,7 +70,41 @@ static void cactus_print_memory_layout(const secure_partition_boot_info_t *boot_
(void *) boot_info->sp_mem_base, (void *) boot_info->sp_mem_limit);
}
-int cactus_main(void *el3_el0_buffer, size_t el3_el0_buffer_size)
+
+static __dead2 void secure_services_loop(void)
+{
+ int32_t event_status_code;
+
+ /*
+ * The first time this loop is executed corresponds to when Cactus has
+ * finished initialising its run time environment and is ready to handle
+ * secure service requests.
+ */
+ NOTICE("Cactus: Signal end of init to SPM\n");
+ event_status_code = SPM_SUCCESS;
+
+ while (1) {
+ int32_t event_id = cactus_svc(SP_EVENT_COMPLETE_AARCH64,
+ event_status_code,
+ 0, 0, 0, 0, 0, 0);
+
+ switch (event_id) {
+ case MM_COMMUNICATE_AARCH64:
+ case MM_COMMUNICATE_AARCH32:
+ NOTICE("Cactus: Received MM_COMMUNICATE call\n");
+ event_status_code = SPM_SUCCESS;
+ break;
+
+ default:
+ NOTICE("Unhandled Service ID 0x%x\n", event_id);
+ event_status_code = -1;
+ break;
+ }
+ }
+}
+
+
+void __dead2 cactus_main(void *el3_el0_buffer, size_t el3_el0_buffer_size)
{
console_init(PLAT_ARM_UART_BASE,
PLAT_ARM_UART_CLK_IN_HZ,
@@ -101,11 +137,17 @@ int cactus_main(void *el3_el0_buffer, size_t el3_el0_buffer_size)
/*
- * Run tests.
+ * Run some initial tests.
+ *
+ * These are executed when the system is still booting, just after SPM
+ * has handed over to Cactus.
*/
misc_tests();
system_setup_tests();
mem_attr_changes_tests(boot_info);
- return 0;
+ /*
+ * Handle secure service requests.
+ */
+ secure_services_loop();
}