Remove concept of top/bottom image loading

This concept is no longer required since we now support loading of
images at fixed addresses only.

The image loader now automatically detects the position of the image
inside the current memory layout and updates the layout such that
memory fragmentation is minimised.

The 'attr' field of the meminfo data structure, which used to hold
the bottom/top loading information, has been removed. Also the 'next'
field has been removed as it wasn't used anywhere.

The 'init_bl2_mem_layout()' function has been moved out of common
code and put in BL1-specific code. It has also been renamed into
'bl1_init_bl2_mem_layout'.

Fixes ARM-software/tf-issues#109

Change-Id: I3f54642ce7b763d5ee3b047ad0ab59eabbcf916d
diff --git a/include/common/bl_common.h b/include/common/bl_common.h
index f5e2a9a..154c0f4 100644
--- a/include/common/bl_common.h
+++ b/include/common/bl_common.h
@@ -38,15 +38,11 @@
 #define DOWN	0
 
 /*******************************************************************************
- * Constants for loading images. When BLx wants to load BLy, it looks at a
- * meminfo structure to find the extents of free memory. Then depending upon
- * how it has been configured, it can either load BLy at the top or bottom of
- * the free memory. These constants indicate the choice.
- * TODO: Make this configurable while building the trusted firmware.
- ******************************************************************************/
-#define TOP_LOAD	0x1
-#define BOT_LOAD	!TOP_LOAD
-#define LOAD_MASK	(1 << 0)
+ * Constants to identify the location of a memory region in a given memory
+ * layout.
+******************************************************************************/
+#define TOP	0x1
+#define BOTTOM	!TOP
 
 /******************************************************************************
  * Opcode passed in x0 to tell next EL that we want to run an image.
@@ -97,18 +93,17 @@
 #include <cdefs.h> /* For __dead2 */
 #include <cassert.h>
 #include <stdint.h>
+#include <stddef.h>
 
 /*******************************************************************************
  * Structure used for telling the next BL how much of a particular type of
  * memory is available for its use and how much is already used.
  ******************************************************************************/
 typedef struct meminfo {
-	unsigned long total_base;
-	long total_size;
-	unsigned long free_base;
-	long free_size;
-	unsigned long attr;
-	unsigned long next;
+	uint64_t total_base;
+	size_t total_size;
+	uint64_t free_base;
+	size_t free_size;
 } meminfo_t;
 
 typedef struct aapcs64_params {
@@ -209,14 +204,16 @@
 unsigned long page_align(unsigned long, unsigned);
 void change_security_state(unsigned int);
 unsigned long image_size(const char *);
-int load_image(meminfo_t *,
-		const char *,
-		unsigned int,
-		unsigned long,
-		image_info_t *,
-		entry_point_info_t *);
+int load_image(meminfo_t *mem_layout,
+	       const char *image_name,
+	       uint64_t image_base,
+	       image_info_t *image_data,
+	       entry_point_info_t *entry_point_info);
 extern const char build_message[];
 
+void reserve_mem(uint64_t *free_base, size_t *free_size,
+		uint64_t addr, size_t size);
+
 #endif /*__ASSEMBLY__*/
 
 #endif /* __BL_COMMON_H__ */