]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/Sec/Helper.asm
Patch from open source community for CryptoPkg to allow it to build for ARM using...
[mirror_edk2.git] / ArmPlatformPkg / Sec / Helper.asm
1 //
2 // Copyright (c) 2011, ARM Limited. All rights reserved.
3 //
4 // This program and the accompanying materials
5 // are licensed and made available under the terms and conditions of the BSD License
6 // which accompanies this distribution. The full text of the license may be found at
7 // http://opensource.org/licenses/bsd-license.php
8 //
9 // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 //
12 //
13
14 EXPORT monitor_vector_table
15 EXPORT return_from_exception
16 EXPORT enter_monitor_mode
17 EXPORT copy_cpsr_into_spsr
18
19 AREA Helper, CODE, READONLY
20
21 ALIGN 32
22 monitor_vector_table
23 ldr pc, dead
24 ldr pc, dead
25 ldr pc, dead
26 ldr pc, dead
27 ldr pc, dead
28 ldr pc, dead
29 ldr pc, dead
30 ldr pc, dead
31
32 // arg0: Secure Monitor mode stack
33 enter_monitor_mode
34 mov r2, lr // Save current lr
35
36 mrs r1, cpsr // Save current mode (SVC) in r1
37 bic r3, r1, #0x1f // Clear all mode bits
38 orr r3, r3, #0x16 // Set bits for Monitor mode
39 msr cpsr_cxsf, r3 // We are now in Monitor Mode
40
41 mov sp, r0 // Use the passed sp
42 mov lr, r2 // Use the same lr as before
43
44 msr spsr_cxsf, r1 // Use saved mode for the MOVS jump to the kernel
45 bx lr
46
47 // We cannot use the instruction 'movs pc, lr' because the caller can be written either in ARM or Thumb2 assembler.
48 // When we will jump into this function, we will set the CPSR flag to ARM assembler. By copying directly 'lr' into
49 // 'pc'; we will not change the CPSR flag and it will crash.
50 // The way to fix this limitation is to do the movs into the ARM assmbler code and then do a 'bx'.
51 return_from_exception
52 adr lr, returned_exception
53 movs pc, lr
54 returned_exception // We are now in non-secure state
55 bx r0
56
57 // Save the current Program Status Register (PSR) into the Saved PSR
58 copy_cpsr_into_spsr
59 mrs r0, cpsr
60 msr spsr_cxsf, r0
61 bx lr
62
63 dead
64 B dead
65
66 END