SPM: Split S-EL1 shim from S-EL0 application

The shim prepares the S-EL1/0 environment (stack, VBAR, MMU, I-cache,
BSS clear, PIE fixup) for usage by the S-EL0 application. Split ivy
and shim parition code into separate folders.

Signed-off-by: Ruari Phipps <ruari.phipps@arm.com>
Signed-off-by: Olivier Deprez <olivier.deprez@arm.com>
Signed-off-by: Daniel Boulby <daniel.boulby@arm.com>
Change-Id: I203bbc0d379b12bd5cf1991b95e4f3a7d78d63d4
diff --git a/spm/ivy/app/ivy_main.c b/spm/ivy/app/ivy_main.c
new file mode 100644
index 0000000..f51fcb5
--- /dev/null
+++ b/spm/ivy/app/ivy_main.c
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <assert.h>
+#include <debug.h>
+#include <errno.h>
+#include <ffa_helpers.h>
+#include <ivy_def.h>
+#include <platform_def.h>
+#include <sp_helpers.h>
+
+#include "ivy.h"
+
+/* Host machine information injected by the build system in the ELF file. */
+extern const char build_message[];
+extern const char version_string[];
+
+void __dead2 ivy_main(void)
+{
+	u_register_t ret;
+	svc_args args;
+
+	NOTICE("Entering S-EL0 Secure Partition\n");
+	NOTICE("%s\n", build_message);
+	NOTICE("%s\n", version_string);
+
+init:
+	args = (svc_args){.fid = FFA_MSG_WAIT};
+	ret = sp_svc(&args);
+	while (1) {
+		if (ret != FFA_MSG_SEND_DIRECT_REQ_SMC32) {
+			ERROR("unknown FF-A request %lx\n", ret);
+			goto init;
+		}
+		VERBOSE("Received request: %lx\n", args.arg3);
+		args.fid = FFA_MSG_SEND_DIRECT_RESP_SMC32;
+		args.arg1 = 0x80020000;
+		args.arg2 = 0;
+		args.arg3 = 0;
+		ret = sp_svc(&args);
+	}
+}