• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_HW_PRI_H
33 #define _LOS_HW_PRI_H
34 
35 #include "los_base.h"
36 #include "los_hw.h"
37 
38 #ifdef __cplusplus
39 #if __cplusplus
40 extern "C" {
41 #endif /* __cplusplus */
42 #endif /* __cplusplus */
43 
44 #if defined(LOSCFG_ARCH_FPU_VFP_D16)
45 #define FP_REGS_NUM     16
46 #elif defined (LOSCFG_ARCH_FPU_VFP_D32)
47 #define FP_REGS_NUM     32
48 #endif
49 #define GEN_REGS_NUM    13
50 
51 /* The size of this structure must be smaller than or equal to the size specified by OS_TSK_STACK_ALIGN (16 bytes). */
52 typedef struct {
53 #if !defined(LOSCFG_ARCH_FPU_DISABLE)
54     UINT64 D[FP_REGS_NUM]; /* D0-D31 */
55     UINT32 regFPSCR;       /* FPSCR */
56     UINT32 regFPEXC;       /* FPEXC */
57 #endif
58     UINT32 R4;
59     UINT32 R5;
60     UINT32 R6;
61     UINT32 R7;
62     UINT32 R8;
63     UINT32 R9;
64     UINT32 R10;
65     UINT32 R11;
66 
67     /* It has the same structure as IrqContext */
68     UINT32 reserved2; /**< Multiplexing registers, used in interrupts and system calls but with different meanings */
69     UINT32 reserved1; /**< Multiplexing registers, used in interrupts and system calls but with different meanings */
70     UINT32 USP;       /**< User mode sp register */
71     UINT32 ULR;       /**< User mode lr register */
72     UINT32 R0;
73     UINT32 R1;
74     UINT32 R2;
75     UINT32 R3;
76     UINT32 R12;
77     UINT32 LR;
78     UINT32 PC;
79     UINT32 regCPSR;
80 } TaskContext;
81 
82 typedef struct {
83     UINT32 reserved2; /**< Multiplexing registers, used in interrupts and system calls but with different meanings */
84     UINT32 reserved1; /**< Multiplexing registers, used in interrupts and system calls but with different meanings */
85     UINT32 USP;       /**< User mode sp register */
86     UINT32 ULR;       /**< User mode lr register */
87     UINT32 R0;
88     UINT32 R1;
89     UINT32 R2;
90     UINT32 R3;
91     UINT32 R12;
92     UINT32 LR;
93     UINT32 PC;
94     UINT32 regCPSR;
95 } IrqContext;
96 
97 /*
98  * Description : task stack initialization
99  * Input       : taskID    -- task ID
100  *               stackSize -- task stack size
101  *               topStack  -- stack top of task (low address)
102  * Return      : pointer to the task context
103  */
104 extern VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack, BOOL initFlag);
105 extern VOID OsUserCloneParentStack(VOID *childStack, UINTPTR parentTopOfStask, UINT32 parentStackSize);
106 extern VOID OsUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack);
107 extern VOID OsInitSignalContext(const VOID *sp, VOID *signalContext, UINTPTR sigHandler, UINT32 signo, UINT32 param);
108 extern void arm_clean_cache_range(UINTPTR start, UINTPTR end);
109 extern void arm_inv_cache_range(UINTPTR start, UINTPTR end);
110 
111 #ifdef __cplusplus
112 #if __cplusplus
113 }
114 #endif /* __cplusplus */
115 #endif /* __cplusplus */
116 
117 #endif /* _LOS_HW_PRI_H */
118