refactor(lib/realm): remove 'lib/realm' library

This patch removes the lib/realm library by refactoring its code and
moving its components to related submodules. It also introduces two
new libraries, 'lib/granule' and 'lib/slot_buf' with sources from
'lib/realm'

Change-Id: Id41eb2da20172d8da9a5f066b3e78ec4f1a6d35d
Signed-off-by: Javier Almansa Sobrino <javier.almansasobrino@arm.com>
Signed-off-by: Soby Mathew <soby.mathew@arm.com>
diff --git a/runtime/rsi/psci.c b/runtime/rsi/psci.c
index fa2401a..8c8da19 100644
--- a/runtime/rsi/psci.c
+++ b/runtime/rsi/psci.c
@@ -3,6 +3,7 @@
  * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
  */
 
+#include <buffer.h>
 #include <granule.h>
 #include <psci.h>
 #include <realm.h>
@@ -110,7 +111,7 @@
 static unsigned long rd_map_read_rec_count(struct granule *g_rd)
 {
 	unsigned long rec_count;
-	struct rd *rd = granule_map(g_rd, SLOT_RD);
+	struct rd *rd = buffer_granule_map(g_rd, SLOT_RD);
 
 	assert(rd != NULL);
 
@@ -228,7 +229,7 @@
 	 * the rd lock here before we set the Realm's new state.
 	 */
 	granule_lock(g_rd, GRANULE_STATE_RD);
-	rd = granule_map(rec->realm_info.g_rd, SLOT_RD);
+	rd = buffer_granule_map(rec->realm_info.g_rd, SLOT_RD);
 	assert(rd != NULL);
 
 	set_rd_state(rd, REALM_SYSTEM_OFF);