1 /*
2  * Copyright (c) 2013, Google Inc. All rights reserved
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining
5  * a copy of this software and associated documentation files
6  * (the "Software"), to deal in the Software without restriction,
7  * including without limitation the rights to use, copy, modify, merge,
8  * publish, distribute, sublicense, and/or sell copies of the Software,
9  * and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be
13  * included in all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  */
23 #ifndef __LIB_SM_MONITOR_H
24 
25 #define MODE_USR 0x10
26 #define MODE_FIQ 0x11
27 #define MODE_IRQ 0x12
28 #define MODE_SVC 0x13
29 #define MODE_MON 0x16
30 #define MODE_ABT 0x17
31 #define MODE_UND 0x1b
32 #define MODE_SYS 0x1f
33 #define MODE_SVC_IRQ_DISABLED 0x93
34 #define MODE_SVC_IRQ_FIQ_DISABLED 0xd3
35 
36 /* SCR values for secure and non-secure modes */
37 #define SM_SCR_NONSECURE 0x5
38 #define SM_SCR_SECURE 0x0
39 
40 /* clang-format off */
41 
42 /* sets SCR.NS bit to 1 (assumes monitor mode) */
43 .macro SWITCH_SCR_TO_NONSECURE, tmp
44 	mov	\tmp, #SM_SCR_NONSECURE
45 	mcr	p15, 0, \tmp, c1, c1, 0
46 	isb
47 .endm
48 
49 /* sets SCR.NS bit to 0 (assumes monitor mode) */
50 .macro SWITCH_SCR_TO_SECURE, tmp
51 	mov	\tmp, #SM_SCR_SECURE
52 	mcr	p15, 0, \tmp, c1, c1, 0
53 	isb
54 .endm
55 
56 /* clang-format on */
57 
58 #endif /* __LIB_SM_MONITOR_H */
59