restore stack pointer in normal mode, remove prints in u-boot final stage, add GIC_BASE_ADDRESS
PATCH 2/3 restore stack pointer in normal mode, remove prints in u-boot final stage, add GIC_BASE_ADDRESS
--- arch/arm/cpu/armv7/nonsec_virt.S | 5 +++++ arch/arm/cpu/armv7/virt-v7.c | 18 +++++++++++++++--- arch/arm/include/asm/armv7.h | 7 ++++--- arch/arm/lib/bootm.c | 2 +- common/bootstage.c | 3 +++ include/configs/socfpga_common.h | 2 ++ include/configs/socfpga_cyclone5.h | 1 + 7 files changed, 31 insertions(+), 7 deletions(-)
arch/arm/cpu/armv7/nonsec_virt.S +5 -0
@@ -50,6 +50,7 @@ _monitor_vectors: */ .align 5 _secure_monitor: + mov r2,r1 mrc p15, 0, r1, c1, c1, 0 @ read SCR bic r1, r1, #0x4e @ clear IRQ, FIQ, EA, nET bits orr r1, r1, #0x31 @ enable NS, AW, FW bits
@@ -68,6 +69,7 @@ _secure_monitor: mcreq p15, 4, r0, c12, c0, 0 @ write HVBAR #endif + mov sp,r2 @ restore stack pointer from caller (eq to secure mode stack) movs pc, lr @ return to non-secure SVC _hyp_trap:
@@ -168,12 +170,15 @@ ENTRY(_nonsec_init) mrc p15, 0, ip, c12, c0, 0 @ save secure copy of VBAR + stmfd sp!,{r2} @ save r2 as it is clobbered in monitor mode + mov r1,sp isb smc #0 @ call into MONITOR mode mcr p15, 0, ip, c12, c0, 0 @ write non-secure copy of VBAR mov r1, #1 + ldmfd sp!,{r2} @ restore r2 str r1, [r3, #GICC_CTLR] @ enable non-secure CPU i/f add r2, r2, #GIC_DIST_OFFSET str r1, [r2, #GICD_CTLR] @ allow private interrupts
arch/arm/cpu/armv7/virt-v7.c +15 -3
@@ -62,7 +62,9 @@ static unsigned long get_gicd_base_address(void)* which we know only for sure for those two CPUs. */ asm("mrc p15, 0, %0, c0, c0, 0\n" :"=r" (midr)); +printf ("midr: %x masked:%x\n" ,midr,midr &MIDR_PRIMARY_PART_MASK );switch (midr &MIDR_PRIMARY_PART_MASK ) { +case MIDR_CORTEX_A9_R0P0 :case MIDR_CORTEX_A9_R0P1 :case MIDR_CORTEX_A15_R0P0 :case MIDR_CORTEX_A7_R0P0 :
@@ -75,6 +77,7 @@ static unsigned long get_gicd_base_address(void)/* get the GIC base address from the CBAR register */ asm("mrc p15, 4, %0, c15, c0, 0\n" :"=r" (periphbase)); +printf ("periphbase: %x working_address:%x\n" ,periphbase, (periphbase &CBAR_MASK )+GIC_DIST_OFFSET );/* the PERIPHBASE can be mapped above 4 GB (lower 8 bits used to * encode this). Bail out here since we cannot access this without * enabling paging.
@@ -105,7 +108,7 @@ int armv7_switch_hyp(void)/* check whether we are in HYP mode already */ if ((read_cpsr () &0x1f ) ==0x1a ) { -debug ("CPU already in HYP mode\n" ); +printf ("CPU already in HYP mode\n" );return 0 ; }
@@ -148,11 +151,13 @@ int armv7_switch_nonsec(void) gic_dist_addr =get_gicd_base_address ();if (gic_dist_addr ==-1 )return -1 ; - + +printf ("enable GIC addr:%x \n" , gic_dist_addr +GICD_CTLR );/* enable the GIC distributor */ writel (readl (gic_dist_addr +GICD_CTLR ) |0x03 , gic_dist_addr +GICD_CTLR ); +printf ("typer register: %x\n" , gic_dist_addr +GICD_TYPER );/* TYPER[4:0] contains an encoded number of available interrupts */ itlinesnr =readl (gic_dist_addr +GICD_TYPER ) &0x1f ;
@@ -160,14 +165,21 @@ int armv7_switch_nonsec(void)* from non-secure state. The first 32 interrupts are private per * CPU and will be set later when enabling the GIC for each core */ +printf ("allow non secure access\n" );for (i =1 ; i <= itlinesnr; i++)writel ((unsigned )-1 , gic_dist_addr + GICD_IGROUPRn +4 * i); +printf ("set core boot addr\n" );smp_set_core_boot_addr ((unsigned long )_smp_pen,-1 ); +printf ("kick cpus\n" );smp_kick_all_cpus (); +/* read Monitor Vector Base Address Register */ + asm("mrc p15, 0, %0, c12, c0, 1" :"=r" (reg) : :"cc" ); +printf ("MVBAR (p15,0,c12,c0,1):%x\n" ,reg); +/* call the non-sec switching code on this CPU also */ +printf ("nonsec init" );_nonsec_init (); -return 0 ; }
arch/arm/include/asm/armv7.h +4 -3
@@ -25,9 +25,10 @@#define ARMV7_H /* Cortex-A9 revisions */ -#define MIDR_CORTEX_A9_R0P1 0x410FC091 -#define MIDR_CORTEX_A9_R1P2 0x411FC092 -#define MIDR_CORTEX_A9_R1P3 0x411FC093 +#define MIDR_CORTEX_A9_R0P0 0x410FC090 +#define MIDR_CORTEX_A9_R0P1 0x410FC091 +#define MIDR_CORTEX_A9_R1P2 0x411FC092 +#define MIDR_CORTEX_A9_R1P3 0x411FC093#define MIDR_CORTEX_A9_R2P10 0x412FC09A/* Cortex-A15 revisions */
arch/arm/lib/bootm.c +1 -1
@@ -99,7 +99,7 @@ static int fixup_memory_node(void *blob)static void announce_and_cleanup (void ) { -printf ("\nStarting kernel ...\n\n" ); +//printf("\nStarting kernel ...\n\n"); bootstage_mark_name (BOOTSTAGE_ID_BOOTM_HANDOFF ,"start_kernel" );#ifdef CONFIG_BOOTSTAGE_FDT bootstage_fdt_add_report ();
common/bootstage.c +3 -0
@@ -239,8 +239,11 @@ static int add_bootstages_devicetree(struct fdt_header *blob)int bootstage_fdt_add_report (void ) {if (add_bootstages_devicetree (working_fdt)) +return 0 ; +/* FIXME q puts("bootstage: Failed to add to device tree\n"); +*/ return 0 ; }#endif
include/configs/socfpga_common.h +2 -0
@@ -371,10 +371,12 @@/* * L4 Watchdog */ +/* #define CONFIG_HW_WATCHDOG #define CONFIG_HW_WATCHDOG_TIMEOUT_MS (2000) #define CONFIG_DESIGNWARE_WATCHDOG #define CONFIG_DW_WDT_BASE SOCFPGA_L4WD0_ADDRESS +*/ /* Clocks source frequency to watchdog timer */ #if defined(CONFIG_SOCFPGA_VIRTUAL_TARGET )#define CONFIG_DW_WDT_CLOCK_KHZ 2400
include/configs/socfpga_cyclone5.h +1 -0
@@ -38,5 +38,6 @@#define CONFIG_ARMV7_NONSEC #define CONFIG_SYSFLAGS_ADDR 0x1c010030#define CONFIG_SMP_PEN_ADDR CONFIG_SYSFLAGS_ADDR +#define CONFIG_ARM_GIC_BASE_ADDRESS 0xfffed000 - 0x1000 //GIC_DIST_OFFSET#endif /* __CONFIG_H */
Signature · 7 lines
1.7.9.5 --nextPart3272330.ldxLZMl4xy Content-Disposition: attachment; filename="0003-move-secure-mode-switch-directly-in-front-of-kernel-.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0003-move-secure-mode-switch-directly-in-front-of-kernel-.patch"