BL31: Add SDEI dispatcher

The implementation currently supports only interrupt-based SDEI events,
and supports all interfaces as defined by SDEI specification version
1.0 [1].

Introduce the build option SDEI_SUPPORT to include SDEI dispatcher in
BL31.

Update user guide and porting guide. SDEI documentation to follow.

[1] http://infocenter.arm.com/help/topic/com.arm.doc.den0054a/ARM_DEN0054A_Software_Delegated_Exception_Interface.pdf

Change-Id: I758b733084e4ea3b27ac77d0259705565842241a
Co-authored-by: Yousuf A <yousuf.sait@arm.com>
Signed-off-by: Jeenu Viswambharan <jeenu.viswambharan@arm.com>
diff --git a/services/std_svc/std_svc_setup.c b/services/std_svc/std_svc_setup.c
index 977ed7f..ffc3471 100644
--- a/services/std_svc/std_svc_setup.c
+++ b/services/std_svc/std_svc_setup.c
@@ -11,6 +11,7 @@
 #include <psci.h>
 #include <runtime_instr.h>
 #include <runtime_svc.h>
+#include <sdei.h>
 #include <smcc_helpers.h>
 #include <spm_svc.h>
 #include <std_svc.h>
@@ -45,6 +46,11 @@
 	}
 #endif
 
+#if SDEI_SUPPORT
+	/* SDEI initialisation */
+	sdei_init();
+#endif
+
 	return ret;
 }
 
@@ -92,7 +98,6 @@
 		SMC_RET1(handle, ret);
 	}
 
-
 #if ENABLE_SPM
 	/*
 	 * Dispatch SPM calls to SPM SMC handler and return its return
@@ -104,6 +109,13 @@
 	}
 #endif
 
+#if SDEI_SUPPORT
+	if (is_sdei_fid(smc_fid)) {
+		return sdei_smc_handler(smc_fid, x1, x2, x3, x4, cookie, handle,
+				flags);
+	}
+#endif
+
 	switch (smc_fid) {
 	case ARM_STD_SVC_CALL_COUNT:
 		/*