X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ArmPlatformPkg%2FSec%2FHelper.asm;h=b31cc31a97eeca196291f86bfbe6bf5a3ab73cae;hb=a75568e9c96cc17b1e802bb43f97c26af0e6f77b;hp=1649df399adae8f1dbf01f0c9d80858b4dc1b45e;hpb=513aa3497afd3b84f6f20ed53a18534cb72b2180;p=mirror_edk2.git diff --git a/ArmPlatformPkg/Sec/Helper.asm b/ArmPlatformPkg/Sec/Helper.asm index 1649df399a..b31cc31a97 100644 --- a/ArmPlatformPkg/Sec/Helper.asm +++ b/ArmPlatformPkg/Sec/Helper.asm @@ -1,5 +1,5 @@ // -// Copyright (c) 2011, ARM Limited. All rights reserved. +// Copyright (c) 2011-2012, ARM Limited. All rights reserved. // // This program and the accompanying materials // are licensed and made available under the terms and conditions of the BSD License @@ -11,7 +11,6 @@ // // - EXPORT monitor_vector_table EXPORT return_from_exception EXPORT enter_monitor_mode EXPORT copy_cpsr_into_spsr @@ -19,31 +18,32 @@ AREA Helper, CODE, READONLY - ALIGN 32 -monitor_vector_table - ldr pc, dead - ldr pc, dead - ldr pc, dead - ldr pc, dead - ldr pc, dead - ldr pc, dead - ldr pc, dead - ldr pc, dead +// r0: Monitor World EntryPoint +// r1: MpId +// r2: SecBootMode +// r3: Secure Monitor mode stack +enter_monitor_mode FUNCTION + cmp r3, #0 // If a Secure Monitor stack base has not been defined then use the Secure stack + moveq r3, sp -// arg0: Secure Monitor mode stack -enter_monitor_mode - mov r2, lr // Save current lr + mrs r4, cpsr // Save current mode (SVC) in r4 + bic r5, r4, #0x1f // Clear all mode bits + orr r5, r5, #0x16 // Set bits for Monitor mode + msr cpsr_cxsf, r5 // We are now in Monitor Mode - mrs r1, cpsr // Save current mode (SVC) in r1 - bic r3, r1, #0x1f // Clear all mode bits - orr r3, r3, #0x16 // Set bits for Monitor mode - msr cpsr_cxsf, r3 // We are now in Monitor Mode + mov sp, r3 // Set the stack of the Monitor Mode - mov sp, r0 // Use the passed sp - mov lr, r2 // Use the same lr as before + mov lr, r0 // Use the pass entrypoint as lr - msr spsr_cxsf, r1 // Use saved mode for the MOVS jump to the kernel - bx lr + msr spsr_cxsf, r4 // Use saved mode for the MOVS jump to the kernel + + mov r4, r0 // Swap EntryPoint and MpId registers + mov r0, r1 + mov r1, r2 + mov r2, r3 + + bx r4 + ENDFUNC // We cannot use the instruction 'movs pc, lr' because the caller can be written either in ARM or Thumb2 assembler. // When we will jump into this function, we will set the CPSR flag to ARM assembler. By copying directly 'lr' into @@ -64,7 +64,7 @@ copy_cpsr_into_spsr // Set the Non Secure Mode set_non_secure_mode push { r1 } - and r0, r0, #0x1f // Keep only the mode bits + and r0, r0, #0x1f // Keep only the mode bits mrs r1, spsr // Read the spsr bic r1, r1, #0x1f // Clear all mode bits orr r1, r1, r0