refactor(gpt): productize and refactor GPT library

This patch updates and refactors the GPT library and fixes bugs.

- Support all combinations of PGS, PPS, and L0GPTSZ parameters.
- PPS and PGS are set at runtime, L0GPTSZ is read from GPCCR_EL3.
- Use compiler definitions to simplify code.
- Renaming functions to better suit intended uses.
- MMU enabled before GPT APIs called.
- Add comments to make function usage more clear in GPT library.
- Added _rme suffix to file names to differentiate better from the
  GPT file system code.
- Renamed gpt_defs.h to gpt_rme_private.h to better separate private
  and public code.
- Renamed gpt_core.c to gpt_rme.c to better conform to TF-A precedent.

Signed-off-by: John Powell <john.powell@arm.com>
Change-Id: I4cbb23b0f81e697baa9fb23ba458aa3f7d1ed919
diff --git a/services/std_svc/rmmd/rmmd_main.c b/services/std_svc/rmmd/rmmd_main.c
index 26a5b84..dacd150 100644
--- a/services/std_svc/rmmd/rmmd_main.c
+++ b/services/std_svc/rmmd/rmmd_main.c
@@ -16,7 +16,7 @@
 #include <context.h>
 #include <lib/el3_runtime/context_mgmt.h>
 #include <lib/el3_runtime/pubsub.h>
-#include <lib/gpt/gpt_defs.h>
+#include <lib/gpt_rme/gpt_rme.h>
 
 #include <lib/spinlock.h>
 #include <lib/utils.h>
@@ -296,12 +296,18 @@
 {
 	int ret;
 
-	ret = gpt_transition_pas(pa, src_sec_state, target_pas);
+	ret = gpt_transition_pas(pa, PAGE_SIZE_4KB, src_sec_state, target_pas);
 
 	/* Convert TF-A error codes into GTSI error codes */
 	if (ret == -EINVAL) {
+		ERROR("[GTSI] Transition failed: invalid %s\n", "address");
+		ERROR("       PA: 0x%llx, SRC: %d, PAS: %d\n", pa,
+		      src_sec_state, target_pas);
 		ret = GRAN_TRANS_RET_BAD_ADDR;
 	} else if (ret == -EPERM) {
+		ERROR("[GTSI] Transition failed: invalid %s\n", "caller/PAS");
+		ERROR("       PA: 0x%llx, SRC: %d, PAS: %d\n", pa,
+		      src_sec_state, target_pas);
 		ret = GRAN_TRANS_RET_BAD_PAS;
 	}
 
@@ -328,12 +334,10 @@
 	switch (smc_fid) {
 	case SMC_ASC_MARK_REALM:
 		SMC_RET1(handle, gtsi_transition_granule(x1, SMC_FROM_REALM,
-								GPI_REALM));
-		break;
+								GPT_GPI_REALM));
 	case SMC_ASC_MARK_NONSECURE:
 		SMC_RET1(handle, gtsi_transition_granule(x1, SMC_FROM_REALM,
-								GPI_NS));
-		break;
+								GPT_GPI_NS));
 	default:
 		WARN("RMM: Unsupported GTF call 0x%08x\n", smc_fid);
 		SMC_RET1(handle, SMC_UNK);