1 /* 2 * Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved. 3 * Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without modification, 6 * are permitted provided that the following conditions are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright notice, this list of 9 * conditions and the following disclaimer. 10 * 11 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 12 * of conditions and the following disclaimer in the documentation and/or other materials 13 * provided with the distribution. 14 * 15 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 16 * to endorse or promote products derived from this software without specific prior written 17 * permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 21 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #ifndef _LOS_ARCH_CONTEXT_H 33 #define _LOS_ARCH_CONTEXT_H 34 35 #include "los_config.h" 36 #include "los_compiler.h" 37 38 #ifdef __cplusplus 39 #if __cplusplus 40 extern "C" { 41 #endif /* __cplusplus */ 42 #endif /* __cplusplus */ 43 44 #define PSR_T_ARM 0x00000000U 45 #define PSR_T_THUMB 0x00000020U 46 #define PSR_MODE_SVC 0x00000013U 47 #define PSR_MODE_SYS 0x0000001FU 48 49 #define PSR_MODE_SVC_THUMB (PSR_MODE_SVC | PSR_T_THUMB) 50 #define PSR_MODE_SVC_ARM (PSR_MODE_SVC | PSR_T_ARM) 51 52 #define PSR_MODE_SYS_THUMB (PSR_MODE_SYS | PSR_T_THUMB) 53 #define PSR_MODE_SYS_ARM (PSR_MODE_SYS | PSR_T_ARM) 54 55 VOID OsTaskEntryArm(VOID); 56 VOID OsTaskEntryThumb(VOID); 57 58 typedef struct TagTskContext { 59 UINT32 spsr; 60 UINT32 r0; 61 UINT32 r1; 62 UINT32 r2; 63 UINT32 r3; 64 UINT32 r4; 65 UINT32 r5; 66 UINT32 r6; 67 UINT32 r7; 68 UINT32 r8; 69 UINT32 r9; 70 UINT32 r10; 71 UINT32 r11; 72 UINT32 r12; 73 UINT32 sp; 74 UINT32 lr; 75 UINT32 pc; 76 } TaskContext; 77 78 /** 79 * @ingroup los_config 80 * @brief: Task start running function. 81 * 82 * @par Description: 83 * This API is used to start a task. 84 * 85 * @attention: 86 * <ul><li>None.</li></ul> 87 * 88 * @param: None. 89 * 90 * @retval None. 91 * 92 * @par Dependency: 93 * <ul><li>los_config.h: the header file that contains the API declaration.</li></ul> 94 * @see None. 95 */ 96 extern VOID HalStartToRun(VOID); 97 98 /** 99 * @ingroup los_arch_context 100 * @brief Wait for interrupt. 101 * 102 * @par Description: 103 * <ul> 104 * <li>This API is used to suspend execution until interrupt or a debug request occurs.</li> 105 * </ul> 106 * @attention None. 107 * 108 * @param None. 109 * 110 * @retval: None. 111 * 112 * @par Dependency: 113 * los_arch_context.h: the header file that contains the API declaration. 114 * @see None. 115 */ 116 extern VOID wfi(VOID); 117 118 /** 119 * @ingroup los_arch_context 120 * @brief: mem fence function. 121 * 122 * @par Description: 123 * This API is used to fence for memory. 124 * 125 * @attention: 126 * <ul><li>None.</li></ul> 127 * 128 * @param: None. 129 * 130 * @retval:None. 131 * @par Dependency: 132 * <ul><li>los_arch_context.h: the header file that contains the API declaration.</li></ul> 133 * @see None. 134 */ 135 extern VOID dmb(VOID); 136 137 /** 138 * @ingroup los_arch_context 139 * @brief: mem fence function. 140 * 141 * @par Description: 142 * This API is same as dmb, it just for adaptation. 143 * 144 * @attention: 145 * <ul><li>None.</li></ul> 146 * 147 * @param: None. 148 * 149 * @retval:None. 150 * @par Dependency: 151 * <ul><li>los_arch_context.h: the header file that contains the API declaration.</li></ul> 152 * @see None. 153 */ 154 extern VOID dsb(VOID); 155 156 /** 157 * @ingroup los_arch_context 158 * @brief: instruction fence function. 159 * 160 * @par Description: 161 * This API is used to fence for instruction. 162 * 163 * @attention: 164 * <ul><li>None.</li></ul> 165 * 166 * @param: None. 167 * 168 * @retval:None. 169 * @par Dependency: 170 * <ul><li>los_arch_context.h: the header file that contains the API declaration.</li></ul> 171 * @see None. 172 */ 173 extern VOID isb(VOID); 174 175 #ifdef __cplusplus 176 #if __cplusplus 177 } 178 #endif /* __cplusplus */ 179 #endif /* __cplusplus */ 180 181 #endif /* _LOS_ARCH_CONTEXT_H */ 182