xlat v2: Split code into separate files

Instead of having one big file with all the code, it's better to have
a few smaller files that are more manageable:

- xlat_tables_core.c: Code related to the core functionality of the
  library (map and unmap regions, initialize xlat context).
- xlat_tables_context.c: Instantiation of the active image context
  as well as APIs to manipulate it.
- xlat_tables_utils.c: Helper code that isn't part of the core
  functionality (change attributes, debug print messages).

Change-Id: I3ea956fc1afd7473c0bb5e7c6aab3b2e5d88c711
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
diff --git a/include/lib/xlat_tables/xlat_tables_v2.h b/include/lib/xlat_tables/xlat_tables_v2.h
index 4dc2c5e..20a9ea1 100644
--- a/include/lib/xlat_tables/xlat_tables_v2.h
+++ b/include/lib/xlat_tables/xlat_tables_v2.h
@@ -123,10 +123,8 @@
 /*
  * Translation regimes supported by this library.
  */
-typedef enum xlat_regime {
-	EL1_EL0_REGIME,
-	EL3_REGIME,
-} xlat_regime_t;
+#define EL1_EL0_REGIME		1
+#define EL3_REGIME		3
 
 /*
  * Declare the translation context type.
@@ -161,12 +159,12 @@
  *   (resp. PLAT_PHY_ADDR_SPACE_SIZE) for the translation context describing the
  *   BL image currently executing.
  */
-#define REGISTER_XLAT_CONTEXT(_ctx_name, _mmap_count, _xlat_tables_count,	\
-			_virt_addr_space_size, _phy_addr_space_size)		\
-	_REGISTER_XLAT_CONTEXT_FULL_SPEC(_ctx_name, _mmap_count,	\
-					 _xlat_tables_count,		\
-					 _virt_addr_space_size,		\
-					 _phy_addr_space_size,		\
+#define REGISTER_XLAT_CONTEXT(_ctx_name, _mmap_count, _xlat_tables_count, \
+			_virt_addr_space_size, _phy_addr_space_size)	\
+	_REGISTER_XLAT_CONTEXT_FULL_SPEC(_ctx_name, (_mmap_count),	\
+					 (_xlat_tables_count),		\
+					 (_virt_addr_space_size),	\
+					 (_phy_addr_space_size),	\
 					 IMAGE_XLAT_DEFAULT_REGIME,	\
 					"xlat_table")
 
@@ -175,20 +173,20 @@
  *
  * _xlat_regime:
  *   Specify the translation regime managed by this xlat_ctx_t instance. The
- *   values are the one from xlat_regime_t enumeration.
+ *   values are the one from the EL*_REGIME definitions.
  *
  * _section_name:
  *   Specify the name of the section where the translation tables have to be
  *   placed by the linker.
  */
-#define REGISTER_XLAT_CONTEXT2(_ctx_name, _mmap_count, _xlat_tables_count,	\
-			_virt_addr_space_size, _phy_addr_space_size,		\
-			_xlat_regime, _section_name)				\
-	_REGISTER_XLAT_CONTEXT_FULL_SPEC(_ctx_name, _mmap_count,	\
-					 _xlat_tables_count,		\
-					 _virt_addr_space_size,		\
-					 _phy_addr_space_size,		\
-					 _xlat_regime, _section_name)
+#define REGISTER_XLAT_CONTEXT2(_ctx_name, _mmap_count, _xlat_tables_count, \
+			_virt_addr_space_size, _phy_addr_space_size,	\
+			_xlat_regime, _section_name)			\
+	_REGISTER_XLAT_CONTEXT_FULL_SPEC(_ctx_name, (_mmap_count),	\
+					 (_xlat_tables_count),		\
+					 (_virt_addr_space_size),	\
+					 (_phy_addr_space_size),	\
+					 (_xlat_regime), (_section_name))
 
 /******************************************************************************
  * Generic translation table APIs.
diff --git a/include/lib/xlat_tables/xlat_tables_v2_helpers.h b/include/lib/xlat_tables/xlat_tables_v2_helpers.h
index e1ea2b6..56b9a93 100644
--- a/include/lib/xlat_tables/xlat_tables_v2_helpers.h
+++ b/include/lib/xlat_tables/xlat_tables_v2_helpers.h
@@ -109,10 +109,8 @@
 	unsigned int initialized;
 
 	/*
-	 * Translation regime managed by this xlat_ctx_t. It takes the values of
-	 * the enumeration xlat_regime_t. The type is "int" to avoid a circular
-	 * dependency on xlat_tables_v2.h, but this member must be treated as
-	 * xlat_regime_t.
+	 * Translation regime managed by this xlat_ctx_t. It should be one of
+	 * the EL*_REGIME defines.
 	 */
 	int xlat_regime;
 };
@@ -157,7 +155,7 @@
 		.va_max_address = (_virt_addr_space_size) - 1,			\
 		.pa_max_address = (_phy_addr_space_size) - 1,			\
 		.mmap = _ctx_name##_mmap,					\
-		.mmap_num = _mmap_count,					\
+		.mmap_num = (_mmap_count),					\
 		.base_level = GET_XLAT_TABLE_LEVEL_BASE(_virt_addr_space_size),	\
 		.base_table = _ctx_name##_base_xlat_table,			\
 		.base_table_entries =						\