]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Sec/Arm/Helper.asm
ArmPlatformPkg/Sec: fix return_from_exception code and comment
[mirror_edk2.git] / ArmPlatformPkg / Sec / Arm / Helper.asm
index b31cc31a97eeca196291f86bfbe6bf5a3ab73cae..0a2baaf19e36c65afa4a3078e43e612098dcdf04 100644 (file)
@@ -1,13 +1,13 @@
 //\r
 //  Copyright (c) 2011-2012, ARM Limited. All rights reserved.\r
-//  \r
-//  This program and the accompanying materials                          \r
-//  are licensed and made available under the terms and conditions of the BSD License         \r
-//  which accompanies this distribution.  The full text of the license may be found at        \r
-//  http://opensource.org/licenses/bsd-license.php                                            \r
 //\r
-//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+//  This program and the accompanying materials\r
+//  are licensed and made available under the terms and conditions of the BSD License\r
+//  which accompanies this distribution.  The full text of the license may be found at\r
+//  http://opensource.org/licenses/bsd-license.php\r
+//\r
+//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 //\r
 //\r
 \r
@@ -15,7 +15,7 @@
     EXPORT  enter_monitor_mode\r
     EXPORT  copy_cpsr_into_spsr\r
     EXPORT  set_non_secure_mode\r
-    \r
+\r
     AREA   Helper, CODE, READONLY\r
 \r
 // r0: Monitor World EntryPoint\r
@@ -34,7 +34,7 @@ enter_monitor_mode FUNCTION
     mov     sp, r3                      // Set the stack of the Monitor Mode\r
 \r
     mov     lr, r0                      // Use the pass entrypoint as lr\r
-    \r
+\r
     msr     spsr_cxsf, r4               // Use saved mode for the MOVS jump to the kernel\r
 \r
     mov     r4, r0                      // Swap EntryPoint and MpId registers\r
@@ -45,10 +45,8 @@ enter_monitor_mode FUNCTION
     bx      r4\r
     ENDFUNC\r
 \r
-// We cannot use the instruction 'movs pc, lr' because the caller can be written either in ARM or Thumb2 assembler.\r
-// When we will jump into this function, we will set the CPSR flag to ARM assembler. By copying directly 'lr' into\r
-// 'pc'; we will not change the CPSR flag and it will crash.\r
-// The way to fix this limitation is to do the movs into the ARM assmbler code and then do a 'bx'.\r
+// Return-from-exception is not an interworking return, so we must do it\r
+// in two steps, in case r0 has the Thumb bit set.\r
 return_from_exception\r
     adr     lr, returned_exception\r
     movs    pc, lr\r
@@ -67,7 +65,7 @@ set_non_secure_mode
     and     r0, r0, #0x1f     // Keep only the mode bits\r
     mrs     r1, spsr          // Read the spsr\r
     bic     r1, r1, #0x1f     // Clear all mode bits\r
-    orr            r1, r1, r0\r
+    orr     r1, r1, r0\r
     msr     spsr_cxsf, r1     // write back spsr (may have caused a mode switch)\r
     isb\r
     pop     { r1 }\r
@@ -75,5 +73,5 @@ set_non_secure_mode
 \r
 dead\r
     B       dead\r
-    \r
+\r
     END\r