Add support for handling runtime service requests

This patch uses the reworked exception handling support to handle
runtime service requests through SMCs following the SMC calling
convention. This is a giant commit since all the changes are
inter-related. It does the following:

1. Replace the old exception handling mechanism with the new one
2. Enforce that SP_EL0 is used C runtime stacks.
3. Ensures that the cold and warm boot paths use the 'cpu_context'
   structure to program an ERET into the next lower EL.
4. Ensures that SP_EL3 always points to the next 'cpu_context'
   structure prior to an ERET into the next lower EL
5. Introduces a PSCI SMC handler which completes the use of PSCI as a
   runtime service

Change-Id: I661797f834c0803d2c674d20f504df1b04c2b852
Co-authored-by: Achin Gupta <achin.gupta@arm.com>
diff --git a/include/runtime_svc.h b/include/runtime_svc.h
index 3ee043e..ad202a9 100644
--- a/include/runtime_svc.h
+++ b/include/runtime_svc.h
@@ -101,43 +101,8 @@
 #define SERROR_AARCH32			0xf
 
 /*******************************************************************************
- * Constants that allow assembler code to access members of the 'gp_regs'
- * structure at their correct offsets.
+ * Structure definition, typedefs & constants for the runtime service framework
  ******************************************************************************/
-#define SIZEOF_GPREGS		0x110
-#define GPREGS_X0_OFF		0x0
-#define GPREGS_X1_OFF		0x8
-#define GPREGS_X2_OFF		0x10
-#define GPREGS_X3_OFF		0x18
-#define GPREGS_X4_OFF		0x20
-#define GPREGS_X5_OFF		0x28
-#define GPREGS_X6_OFF		0x30
-#define GPREGS_X7_OFF		0x38
-#define GPREGS_X8_OFF		0x40
-#define GPREGS_X9_OFF		0x48
-#define GPREGS_X10_OFF		0x50
-#define GPREGS_X11_OFF		0x58
-#define GPREGS_X12_OFF		0x60
-#define GPREGS_X13_OFF		0x68
-#define GPREGS_X14_OFF		0x70
-#define GPREGS_X15_OFF		0x78
-#define GPREGS_X16_OFF		0x80
-#define GPREGS_X17_OFF		0x88
-#define GPREGS_X18_OFF		0x90
-#define GPREGS_X19_OFF		0x98
-#define GPREGS_X20_OFF		0xA0
-#define GPREGS_X21_OFF		0xA8
-#define GPREGS_X22_OFF		0xB0
-#define GPREGS_X23_OFF		0xB8
-#define GPREGS_X24_OFF		0xC0
-#define GPREGS_X25_OFF		0xC8
-#define GPREGS_X26_OFF		0xD0
-#define GPREGS_X27_OFF		0xD8
-#define GPREGS_X28_OFF		0xE0
-#define GPREGS_SP_EL0_OFF	0xE8
-#define GPREGS_SPSR_OFF		0xF0
-#define GPREGS_FP_OFF		0x100
-#define GPREGS_LR_OFF		0x108
 
 /*
  * Constants to allow the assembler access a runtime service
@@ -219,46 +184,6 @@
 				  void *handle,
 				  uint64_t flags);
 typedef struct {
-	uint64_t x0;
-	uint64_t x1;
-	uint64_t x2;
-	uint64_t x3;
-	uint64_t x4;
-	uint64_t x5;
-	uint64_t x6;
-	uint64_t x7;
-	uint64_t x8;
-	uint64_t x9;
-	uint64_t x10;
-	uint64_t x11;
-	uint64_t x12;
-	uint64_t x13;
-	uint64_t x14;
-	uint64_t x15;
-	uint64_t x16;
-	uint64_t x17;
-	uint64_t x18;
-	uint64_t x19;
-	uint64_t x20;
-	uint64_t x21;
-	uint64_t x22;
-	uint64_t x23;
-	uint64_t x24;
-	uint64_t x25;
-	uint64_t x26;
-	uint64_t x27;
-	uint64_t x28;
-	uint64_t sp_el0;
-	uint32_t spsr;
-	/*
-	 * Alignment constraint which allows save & restore of fp & lr on the
-	 * stack during exception handling
-	 */
-	uint64_t fp __aligned(16);
-	uint64_t lr;
-} __aligned(16) gp_regs;
-
-typedef struct {
 	uint8_t start_oen;
 	uint8_t end_oen;
 	uint8_t call_type;
@@ -280,16 +205,6 @@
 			_setup, \
 			_smch }
 
-/*******************************************************************************
- * Compile time assertions to ensure that:
- * 1)  the assembler code's view of the size of the 'gp_regs' data structure is
- *     the same as the actual size of this data structure.
- * 2)  the assembler code's view of the offset of the frame pointer member of
- *     the 'gp_regs' structure is the same as the actual offset of this member.
- ******************************************************************************/
-CASSERT((sizeof(gp_regs) == SIZEOF_GPREGS), assert_sizeof_gpregs_mismatch);
-CASSERT(GPREGS_FP_OFF == __builtin_offsetof(gp_regs, fp), \
-	assert_gpregs_fp_offset_mismatch);
 /*
  * Compile time assertions related to the 'rt_svc_desc' structure to:
  * 1. ensure that the assembler and the compiler view of the size
@@ -323,6 +238,7 @@
 extern void runtime_svc_init();
 extern uint64_t __RT_SVC_DESCS_START__;
 extern uint64_t __RT_SVC_DESCS_END__;
-
+extern uint64_t get_exception_stack(uint64_t mpidr);
+extern void fault_handler(void *handle);
 #endif /*__ASSEMBLY__*/
 #endif /* __RUNTIME_SVC_H__ */