Merge pull request #214 from soby-mathew/sm/bl_specific_mmap

Create BL stage specific translation tables
diff --git a/bl1/bl1.ld.S b/bl1/bl1.ld.S
index 8092396..007149b 100644
--- a/bl1/bl1.ld.S
+++ b/bl1/bl1.ld.S
@@ -35,8 +35,8 @@
 ENTRY(bl1_entrypoint)
 
 MEMORY {
-    ROM (rx): ORIGIN = BL1_RO_BASE, LENGTH = BL1_RO_LIMIT
-    RAM (rwx): ORIGIN = BL1_RW_BASE, LENGTH = BL1_RW_LIMIT
+    ROM (rx): ORIGIN = BL1_RO_BASE, LENGTH = BL1_RO_LIMIT - BL1_RO_BASE
+    RAM (rwx): ORIGIN = BL1_RW_BASE, LENGTH = BL1_RW_LIMIT - BL1_RW_BASE
 }
 
 SECTIONS
diff --git a/bl2/bl2.ld.S b/bl2/bl2.ld.S
index 1665f5d..65304de 100644
--- a/bl2/bl2.ld.S
+++ b/bl2/bl2.ld.S
@@ -35,7 +35,7 @@
 ENTRY(bl2_entrypoint)
 
 MEMORY {
-    RAM (rwx): ORIGIN = BL2_BASE, LENGTH = BL2_LIMIT
+    RAM (rwx): ORIGIN = BL2_BASE, LENGTH = BL2_LIMIT - BL2_BASE
 }
 
 
diff --git a/bl31/bl31.ld.S b/bl31/bl31.ld.S
index add65b8..124be85 100644
--- a/bl31/bl31.ld.S
+++ b/bl31/bl31.ld.S
@@ -36,7 +36,7 @@
 
 
 MEMORY {
-    RAM (rwx): ORIGIN = BL31_BASE, LENGTH = BL31_LIMIT
+    RAM (rwx): ORIGIN = BL31_BASE, LENGTH = BL31_LIMIT - BL31_BASE
 }
 
 
diff --git a/plat/fvp/include/plat_macros.S b/plat/fvp/include/plat_macros.S
index 0419906..f050261 100644
--- a/plat/fvp/include/plat_macros.S
+++ b/plat/fvp/include/plat_macros.S
@@ -33,8 +33,8 @@
 #include "../fvp_def.h"
 
 .section .rodata.gic_reg_name, "aS"
-gic_regs:
-	.asciz "gic_hppir", "gic_ahppir", "gic_ctlr", ""
+gicc_regs:
+	.asciz "gicc_hppir", "gicc_ahppir", "gicc_ctlr", ""
 gicd_pend_reg:
 	.asciz "gicd_ispendr regs (Offsets 0x200 - 0x278)\n Offset:\t\t\tvalue\n"
 newline:
@@ -46,19 +46,33 @@
 	 * The below macro prints out relevant GIC
 	 * registers whenever an unhandled exception is
 	 * taken in BL3-1.
-	 * Clobbers: x0 - x10, x16, sp
+	 * Clobbers: x0 - x10, x16, x17, sp
 	 * ---------------------------------------------
 	 */
 	.macro plat_print_gic_regs
-	adr	x0, plat_config
-	ldr	w16, [x0, #CONFIG_GICC_BASE_OFFSET]
-	cbz	x16, exit_print_gic_regs
-	/* gic base address is now in x16 */
-	adr	x6, gic_regs	/* Load the gic reg list to x6 */
-	/* Load the gic regs to gp regs used by str_in_crash_buf_print */
-	ldr	w8, [x16, #GICC_HPPIR]
-	ldr	w9, [x16, #GICC_AHPPIR]
-	ldr	w10, [x16, #GICC_CTLR]
+	mov_imm	x0, (VE_SYSREGS_BASE + V2M_SYS_ID)
+	ldr	w16, [x0]
+	/* Extract BLD (12th - 15th bits) from the SYS_ID */
+	ubfx	x16, x16, #SYS_ID_BLD_SHIFT, #4
+	/* Check if VE mmap */
+	cmp	w16, #BLD_GIC_VE_MMAP
+	b.eq	use_ve_mmap
+	/* Check if Cortex-A53/A57 mmap */
+	cmp	w16, #BLD_GIC_A53A57_MMAP
+	b.ne	exit_print_gic_regs
+	mov_imm	x17, BASE_GICC_BASE
+	mov_imm	x16, BASE_GICD_BASE
+	b	print_gicc_regs
+use_ve_mmap:
+	mov_imm	x17, VE_GICC_BASE
+	mov_imm	x16, VE_GICD_BASE
+print_gicc_regs:
+	/* gicc base address is now in x17 */
+	adr	x6, gicc_regs	/* Load the gicc reg list to x6 */
+	/* Load the gicc regs to gp regs used by str_in_crash_buf_print */
+	ldr	w8, [x17, #GICC_HPPIR]
+	ldr	w9, [x17, #GICC_AHPPIR]
+	ldr	w10, [x17, #GICC_CTLR]
 	/* Store to the crash buf and print to console */
 	bl	str_in_crash_buf_print
 
diff --git a/plat/juno/include/plat_macros.S b/plat/juno/include/plat_macros.S
index 0e08834..a9d2466 100644
--- a/plat/juno/include/plat_macros.S
+++ b/plat/juno/include/plat_macros.S
@@ -34,8 +34,8 @@
 #include "../juno_def.h"
 
 .section .rodata.gic_reg_name, "aS"
-gic_regs:
-	.asciz "gic_hppir", "gic_ahppir", "gic_ctlr", ""
+gicc_regs:
+	.asciz "gicc_hppir", "gicc_ahppir", "gicc_ctlr", ""
 gicd_pend_reg:
 	.asciz "gicd_ispendr regs (Offsets 0x200 - 0x278)\n Offset:\t\t\tvalue\n"
 newline:
@@ -52,13 +52,14 @@
 	 * ---------------------------------------------
 	 */
 	.macro plat_print_gic_regs
-	ldr	x16, =GICC_BASE
-	/* Load the gic reg list to x6 */
-	adr	x6, gic_regs
-	/* Load the gic regs to gp regs used by str_in_crash_buf_print */
-	ldr	w8, [x16, #GICC_HPPIR]
-	ldr	w9, [x16, #GICC_AHPPIR]
-	ldr	w10, [x16, #GICC_CTLR]
+	mov_imm	x16, GICD_BASE
+	mov_imm	x17, GICC_BASE
+	/* Load the gicc reg list to x6 */
+	adr	x6, gicc_regs
+	/* Load the gicc regs to gp regs used by str_in_crash_buf_print */
+	ldr	w8, [x17, #GICC_HPPIR]
+	ldr	w9, [x17, #GICC_AHPPIR]
+	ldr	w10, [x17, #GICC_CTLR]
 	/* Store to the crash buf and print to console */
 	bl	str_in_crash_buf_print