Add support for BL3-0 image

 - Add support for loading a BL3-0 image in BL2. Information about
   memory extents is populated by platform-specific code. Subsequent
   handling of BL3-0 is also platform specific.
   The BL2 main function has been broken down to improve readability.
   The BL3-2 image is now loaded before the BL3-3 image to align with
   the boot flow.

 - Build system: Add support for specifying a BL3-0 image that will be
   included into the FIP image.

 - IO FIP driver: Add support for identifying a BL3-0 image inside a
   FIP image.

 - Update the documentation to reflect the above changes.

Change-Id: I067c184afd52ccaa86569f13664757570c86fc48
diff --git a/Makefile b/Makefile
index b505d62..f4a7185 100644
--- a/Makefile
+++ b/Makefile
@@ -407,7 +407,23 @@
 $(eval $(call MAKE_BL,32,in_fip))
 endif
 
-${BUILD_PLAT}/fip.bin:	${FIP_DEPS} ${BL33} ${FIPTOOL}
+ifeq (${NEED_BL30},yes)
+FIP_DEPS += ${BL30}
+FIP_ARGS += --bl30 ${BL30}
+endif
+
+ifeq (${NEED_BL30},yes)
+# If BL3-0 is needed by the platform then 'BL30' variable must be defined.
+check_bl30:
+	$(if ${BL30},,$(error "To build a FIP for platform ${PLAT}, please set BL30 to point to the SCP firmware"))
+else
+# If BL3-0 is not needed by the platform but the user still specified the path
+# to a BL3-0 image then warn him that it will be ignored.
+check_bl30:
+	$(if ${BL30},$(warning "BL3-0 is not supported on platform ${PLAT}, it will just be ignored"),)
+endif
+
+${BUILD_PLAT}/fip.bin: ${FIP_DEPS} ${BL33} ${FIPTOOL} check_bl30
 			$(if ${BL33},,$(error "To build a FIP, please set BL33 to point to the Normal World binary, eg: BL33=../uefi/FVP_AARCH64_EFI.fd"))
 			${Q}${FIPTOOL} --dump \
 				${FIP_ARGS} \