tests: add unit tests for granule library

These tests don't test concurrency.

Signed-off-by: Javier Almansa Sobrino <javier.almansasobrino@arm.com>
Change-Id: Ib45e63c57da063da2cc5f425531f5f1e98799acc
diff --git a/lib/realm/src/buffer.c b/lib/realm/src/buffer.c
index 44823aa..c645777 100644
--- a/lib/realm/src/buffer.c
+++ b/lib/realm/src/buffer.c
@@ -8,6 +8,7 @@
 #include <assert.h>
 #include <attestation_token.h>
 #include <buffer.h>
+#include <buffer_private.h>
 #include <cpuid.h>
 #include <debug.h>
 #include <errno.h>
@@ -23,19 +24,6 @@
 #include <xlat_tables.h>
 
 /*
- * The VA space size for the high region, which maps the slot buffers,
- * needs to be a power of two, so round NR_CPU_SLOTS up to the closest
- * power of two.
- */
-#define ROUNDED_NR_CPU_SLOTS (1ULL << (64ULL - \
-				       __builtin_clzll((NR_CPU_SLOTS) - 1)))
-
-#define RMM_SLOT_BUF_VA_SIZE	((ROUNDED_NR_CPU_SLOTS) * (GRANULE_SIZE))
-
-#define SLOT_VIRT		((ULL(0xffffffffffffffff) - \
-				 RMM_SLOT_BUF_VA_SIZE + ULL(1)))
-
-/*
  * All the slot buffers for a given CPU must be mapped by a single translation
  * table, which means the max VA size should be <= 4KB * 512
  */
@@ -93,7 +81,7 @@
  */
 static struct xlat_table_entry te_cache[MAX_CPUS];
 
-static uintptr_t slot_to_va(enum buffer_slot slot)
+uintptr_t slot_to_va(enum buffer_slot slot)
 {
 	assert(slot < NR_CPU_SLOTS);
 
@@ -105,7 +93,7 @@
 	return &slot_buf_xlat_ctx[my_cpuid()];
 }
 
-static inline struct xlat_table_entry *get_cache_entry(void)
+struct xlat_table_entry *get_cache_entry(void)
 {
 	return &te_cache[my_cpuid()];
 }