feat(rmm): update rec_exit to use top for ripas

This patch updates rec_exit to use 'base' and 'top'
for 'set_ripas' structure to match RMM Specifiction
1.0-eac1.
Name of "struct smc_result *" parameter is unified
to "res" for all functions.

Signed-off-by: AlexeiFedorov <Alexei.Fedorov@arm.com>
Change-Id: I31df2be5c6d11623dcaa18860dcffa61de04134e
diff --git a/runtime/core/handler.c b/runtime/core/handler.c
index 9550bb2..891b043 100644
--- a/runtime/core/handler.c
+++ b/runtime/core/handler.c
@@ -52,14 +52,14 @@
 typedef unsigned long (*handler_5)(unsigned long arg0, unsigned long arg1,
 				   unsigned long arg2, unsigned long arg3,
 				   unsigned long arg4);
-typedef void (*handler_1_o)(unsigned long arg0, struct smc_result *ret);
+typedef void (*handler_1_o)(unsigned long arg0, struct smc_result *res);
 typedef void (*handler_2_o)(unsigned long arg0, unsigned long arg1,
-			    struct smc_result *ret);
+			    struct smc_result *res);
 typedef void (*handler_3_o)(unsigned long arg0, unsigned long arg1,
-			    unsigned long arg2, struct smc_result *ret);
+			    unsigned long arg2, struct smc_result *res);
 typedef void (*handler_4_o)(unsigned long arg0, unsigned long arg1,
 			    unsigned long arg2, unsigned long arg3,
-			    struct smc_result *ret);
+			    struct smc_result *res);
 
 /*
  * SMC RMI handler type encoding:
@@ -167,7 +167,7 @@
 
 static void rmi_log_on_exit(unsigned long handler_id,
 			    unsigned long args[],
-			    struct smc_result *ret)
+			    struct smc_result *res)
 {
 	const struct smc_handler *handler = &smc_handlers[handler_id];
 	unsigned long function_id = SMC64_RMI_FID(handler_id);
@@ -183,11 +183,11 @@
 		 * RMM_VERSION is special because it returns the
 		 * version number, not the error code.
 		 */
-		INFO("SMC_RMM_%-21s > %lx\n", handler->fn_name, ret->x[0]);
+		INFO("SMC_RMM_%-21s > %lx\n", handler->fn_name, res->x[0]);
 		return;
 	}
 
-	rc = unpack_return_code(ret->x[0]);
+	rc = unpack_return_code(res->x[0]);
 
 	if ((handler->log_exec) ||
 	    (handler->log_error && (rc.status != RMI_SUCCESS))) {
@@ -204,7 +204,7 @@
 
 		/* Print status */
 		if (rc.status >= RMI_ERROR_COUNT) {
-			INFO(" > %lx", ret->x[0]);
+			INFO(" > %lx", res->x[0]);
 		} else {
 			INFO(" > RMI_%s", rmi_status_string[rc.status]);
 		}
@@ -225,7 +225,7 @@
 			assert(num <= MAX_NUM_OUTPUT_VALS);
 
 			for (unsigned int i = 1U; i <= num; i++) {
-				INFO(" %lx", ret->x[i]);
+				INFO(" %lx", res->x[i]);
 			}
 		}
 		INFO("\n");
@@ -239,7 +239,7 @@
 		   unsigned long arg3,
 		   unsigned long arg4,
 		   unsigned long arg5,
-		   struct smc_result *ret)
+		   struct smc_result *res)
 {
 	unsigned long handler_id;
 	const struct smc_handler *handler = NULL;
@@ -262,7 +262,7 @@
 	if ((handler == NULL) || (handler->fn_dummy == NULL)) {
 		VERBOSE("[%s] unknown function_id: %lx\n",
 			__func__, function_id);
-		ret->x[0] = SMC_UNKNOWN;
+		res->x[0] = SMC_UNKNOWN;
 		return;
 	}
 
@@ -279,40 +279,40 @@
 
 	switch (handler->type) {
 	case rmi_type_00:
-		ret->x[0] = handler->f_00();
+		res->x[0] = handler->f_00();
 		break;
 	case rmi_type_10:
-		ret->x[0] = handler->f_10(arg0);
+		res->x[0] = handler->f_10(arg0);
 		break;
 	case rmi_type_20:
-		ret->x[0] = handler->f_20(arg0, arg1);
+		res->x[0] = handler->f_20(arg0, arg1);
 		break;
 	case rmi_type_30:
-		ret->x[0] = handler->f_30(arg0, arg1, arg2);
+		res->x[0] = handler->f_30(arg0, arg1, arg2);
 		break;
 	case rmi_type_40:
-		ret->x[0] = handler->f_40(arg0, arg1, arg2, arg3);
+		res->x[0] = handler->f_40(arg0, arg1, arg2, arg3);
 		break;
 	case rmi_type_50:
-		ret->x[0] = handler->f_50(arg0, arg1, arg2, arg3, arg4);
+		res->x[0] = handler->f_50(arg0, arg1, arg2, arg3, arg4);
 		break;
 	case rmi_type_11:
-		handler->f_11(arg0, ret);
+		handler->f_11(arg0, res);
 		break;
 	case rmi_type_22:
-		handler->f_22(arg0, arg1, ret);
+		handler->f_22(arg0, arg1, res);
 		break;
 	case rmi_type_31:
-		handler->f_31(arg0, arg1, arg2, ret);
+		handler->f_31(arg0, arg1, arg2, res);
 		break;
 	case rmi_type_32:
-		handler->f_32(arg0, arg1, arg2, ret);
+		handler->f_32(arg0, arg1, arg2, res);
 		break;
 	case rmi_type_34:
-		handler->f_34(arg0, arg1, arg2, ret);
+		handler->f_34(arg0, arg1, arg2, res);
 		break;
 	case rmi_type_41:
-		handler->f_41(arg0, arg1, arg2, arg3, ret);
+		handler->f_41(arg0, arg1, arg2, arg3, res);
 		break;
 	default:
 		assert(false);
@@ -321,7 +321,7 @@
 	if (rmi_call_log_enabled) {
 		unsigned long args[] = {arg0, arg1, arg2, arg3, arg4};
 
-		rmi_log_on_exit(handler_id, args, ret);
+		rmi_log_on_exit(handler_id, args, res);
 	}
 
 	/* If the handler uses FPU, restore the saved  NS simd context. */
diff --git a/runtime/include/smc-handler.h b/runtime/include/smc-handler.h
index fb42e6b..1d6a41a 100644
--- a/runtime/include/smc-handler.h
+++ b/runtime/include/smc-handler.h
@@ -11,7 +11,7 @@
 unsigned long smc_version(void);
 
 void smc_read_feature_register(unsigned long index,
-				struct smc_result *ret_struct);
+				struct smc_result *res);
 
 unsigned long smc_data_create(unsigned long rd_addr,
 			      unsigned long data_addr,
@@ -25,7 +25,7 @@
 
 void smc_data_destroy(unsigned long rd_addr,
 		      unsigned long map_addr,
-		      struct smc_result *ret_struct);
+		      struct smc_result *res);
 
 unsigned long smc_granule_delegate(unsigned long addr);
 
@@ -48,7 +48,7 @@
 			    unsigned long rec_run_addr);
 
 void smc_rec_aux_count(unsigned long rd_addr,
-			struct smc_result *ret_struct);
+			struct smc_result *res);
 
 unsigned long smc_rtt_create(unsigned long rd_addr,
 			     unsigned long rtt_addr,
@@ -58,12 +58,12 @@
 void smc_rtt_destroy(unsigned long rd_addr,
 		     unsigned long map_addr,
 		     unsigned long ulevel,
-		     struct smc_result *ret_struct);
+		     struct smc_result *res);
 
 void smc_rtt_fold(unsigned long rd_addr,
 		  unsigned long map_addr,
 		  unsigned long ulevel,
-		  struct smc_result *ret_struct);
+		  struct smc_result *res);
 
 unsigned long smc_rtt_map_unprotected(unsigned long rd_addr,
 				      unsigned long map_addr,
@@ -78,7 +78,7 @@
 void smc_rtt_read_entry(unsigned long rd_addr,
 			unsigned long map_addr,
 			unsigned long ulevel,
-			struct smc_result *ret_struct);
+			struct smc_result *res);
 
 unsigned long smc_psci_complete(unsigned long calling_rec_addr,
 				unsigned long target_rec_addr);
@@ -92,6 +92,6 @@
 			unsigned long rec_addr,
 			unsigned long base,
 			unsigned long top,
-			struct smc_result *ret_struct);
+			struct smc_result *res);
 
 #endif /* SMC_HANDLER_H */
diff --git a/runtime/rmi/feature.c b/runtime/rmi/feature.c
index dc086c8..1f67b3c 100644
--- a/runtime/rmi/feature.c
+++ b/runtime/rmi/feature.c
@@ -51,15 +51,15 @@
 }
 
 void smc_read_feature_register(unsigned long index,
-				struct smc_result *ret_struct)
+				struct smc_result *res)
 {
 	switch (index) {
 	case RMM_FEATURE_REGISTER_0_INDEX:
-		ret_struct->x[0] = RMI_SUCCESS;
-		ret_struct->x[1] = get_feature_register_0();
+		res->x[0] = RMI_SUCCESS;
+		res->x[1] = get_feature_register_0();
 		break;
 	default:
-		ret_struct->x[0] = RMI_ERROR_INPUT;
-		ret_struct->x[1] = 0UL;
+		res->x[0] = RMI_ERROR_INPUT;
+		res->x[1] = 0UL;
 	}
 }
diff --git a/runtime/rmi/rec.c b/runtime/rmi/rec.c
index 7226f90..52ff304 100644
--- a/runtime/rmi/rec.c
+++ b/runtime/rmi/rec.c
@@ -378,7 +378,7 @@
 	return RMI_SUCCESS;
 }
 
-void smc_rec_aux_count(unsigned long rd_addr, struct smc_result *ret_struct)
+void smc_rec_aux_count(unsigned long rd_addr, struct smc_result *res)
 {
 	unsigned int num_rec_aux;
 	struct granule *g_rd;
@@ -386,7 +386,7 @@
 
 	g_rd = find_lock_granule(rd_addr, GRANULE_STATE_RD);
 	if (g_rd == NULL) {
-		ret_struct->x[0] = RMI_ERROR_INPUT;
+		res->x[0] = RMI_ERROR_INPUT;
 		return;
 	}
 
@@ -395,8 +395,8 @@
 	buffer_unmap(rd);
 	granule_unlock(g_rd);
 
-	ret_struct->x[0] = RMI_SUCCESS;
-	ret_struct->x[1] = (unsigned long)num_rec_aux;
+	res->x[0] = RMI_SUCCESS;
+	res->x[1] = (unsigned long)num_rec_aux;
 }
 
 unsigned long smc_psci_complete(unsigned long calling_rec_addr,
diff --git a/runtime/rsi/memory.c b/runtime/rsi/memory.c
index 1affda7..3899031 100644
--- a/runtime/rsi/memory.c
+++ b/runtime/rsi/memory.c
@@ -14,28 +14,27 @@
 			      struct rmi_rec_exit *rec_exit,
 			      struct rsi_result *res)
 {
-	unsigned long start = rec->regs[1];
-	unsigned long size = rec->regs[2];
-	unsigned long end = start + size;
+	unsigned long base = rec->regs[1];
+	unsigned long top = base + rec->regs[2];
 	enum ripas ripas_val = (enum ripas)rec->regs[3];
 
-	if ((ripas_val > RIPAS_RAM)	    ||
-	    !GRANULE_ALIGNED(start) || !GRANULE_ALIGNED(size) ||
-	    (end <= start)	    || /* Size is zero, or range overflows */
-	    !region_in_rec_par(rec, start, end)) {
+	if ((ripas_val > RIPAS_RAM) ||
+	    !GRANULE_ALIGNED(base) || !GRANULE_ALIGNED(top) ||
+	    (top <= base)	    || /* Size is zero, or range overflows */
+	    !region_in_rec_par(rec, base, top)) {
 		res->action = UPDATE_REC_RETURN_TO_REALM;
 		res->smc_res.x[0] = RSI_ERROR_INPUT;
 		return;
 	}
 
-	rec->set_ripas.base = start;
-	rec->set_ripas.top = end;
-	rec->set_ripas.addr = start;
+	rec->set_ripas.base = base;
+	rec->set_ripas.top = top;
+	rec->set_ripas.addr = base;
 	rec->set_ripas.ripas_val = ripas_val;
 
 	rec_exit->exit_reason = RMI_EXIT_RIPAS_CHANGE;
-	rec_exit->ripas_base = start;
-	rec_exit->ripas_size = size;
+	rec_exit->ripas_base = base;
+	rec_exit->ripas_top = top;
 	rec_exit->ripas_value = (unsigned int)ripas_val;
 
 	res->action = UPDATE_REC_EXIT_TO_HOST;