summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Bonnici <marc.bonnici@arm.com>2021-08-19 14:42:19 +0100
committerMarc Bonnici <marc.bonnici@arm.com>2021-10-06 16:00:34 +0100
commit72ed8b7329c2167b46d6b90fca83a476486d704d (patch)
tree6531fa4920412588b0c2fca5c4ef224aa2ee54f8
parenta6f2c49b0afc902c7455e98949869a2d64ad06a3 (diff)
downloadarm-trusted-firmware-72ed8b7329c2167b46d6b90fca83a476486d704d.tar.gz
lsp: Add Test Logical Partition with echo
Add an example logical partition that simply prints and echos the contents of a direct_request with the appropriate direct response. Change-Id: Ib2052c9a63a74830e5e83bd8c128c5f9b0d94658 Signed-off-by: Marc Bonnici <marc.bonnici@arm.com>
-rw-r--r--services/std_svc/spm/common/logical_sp_test.c43
-rw-r--r--services/std_svc/spm/common/spm.mk3
2 files changed, 45 insertions, 1 deletions
diff --git a/services/std_svc/spm/common/logical_sp_test.c b/services/std_svc/spm/common/logical_sp_test.c
new file mode 100644
index 000000000..f30471f4f
--- /dev/null
+++ b/services/std_svc/spm/common/logical_sp_test.c
@@ -0,0 +1,43 @@
+#include <common/debug.h>
+#include <smccc_helpers.h>
+#include <services/ffa_svc.h>
+#include <services/logical_sp.h>
+
+#define LP_PARTITION_ID 0xC000
+#define LP_UUID {0x0, 0x0, 0x0, 0x12}
+
+static int64_t sp_init(void) {
+ // TODO: Do some initialisation.
+ INFO("LSP: Init function called.\n");
+ return 0;
+}
+
+static uint64_t handle_ffa_direct_request(uint32_t smc_fid, bool secure_origin, uint64_t x1, uint64_t x2,
+ uint64_t x3, uint64_t x4, void *cookie, void *handle, uint64_t flags) {
+ uint64_t ret;
+
+ /* Determine if we have a 64 or 32 direct request. */
+ if (smc_fid == FFA_MSG_SEND_DIRECT_REQ_SMC32) {
+ ret = FFA_MSG_SEND_DIRECT_RESP_SMC32;
+ } else if (smc_fid == FFA_MSG_SEND_DIRECT_REQ_SMC64) {
+ ret = FFA_MSG_SEND_DIRECT_RESP_SMC64;
+ }
+ else {
+ panic(); // Unknown SMC
+ }
+ /* TODO: Do something with the request. - Echo only*/
+ INFO("Logical Partition: Received Direct Request from %s world!\n", secure_origin ? "Secure" : "Normal");
+
+ /* SP's must always respond to their calls so we can populate our response directly. */
+ SMC_RET8(handle, ret, 0, 0, x4, 0, 0, 0, 0);
+}
+
+/* Register logical partition */
+DECLARE_LOGICAL_PARTITION(
+ my_logical_partition,
+ sp_init, // Init Function
+ LP_PARTITION_ID, // FFA Partition ID
+ LP_UUID, // UUID
+ 0x1, // Partition Properties. Can only receive direct messages.
+ handle_ffa_direct_request // Callback for direct requests.
+);
diff --git a/services/std_svc/spm/common/spm.mk b/services/std_svc/spm/common/spm.mk
index 1f2a1beb3..31cb732b3 100644
--- a/services/std_svc/spm/common/spm.mk
+++ b/services/std_svc/spm/common/spm.mk
@@ -15,7 +15,8 @@ SPM_SOURCES := $(addprefix services/std_svc/spm/common/,\
${ARCH}/spm_shim_exceptions.S \
spm_common.c \
spm_setup.c \
- spm_xlat.c)
+ spm_xlat.c \
+ logical_sp_test.c)
# logical_mm_sp.c)