更新日期: 2022/06/01 来源: https://gitee.com/weharmony/kernel_liteos_a_note
los_hw_pri.h
浏览该文件的文档.
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
40extern "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). */
52typedef struct { //参考OsTaskSchedule来理解
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
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 */
81
82typedef 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 */
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 */
104extern VOID *OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack, BOOL initFlag);
105extern VOID OsUserCloneParentStack(VOID *childStack, UINTPTR parentTopOfStask, UINT32 parentStackSize);
106extern VOID OsUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack);
107extern VOID OsInitSignalContext(const VOID *sp, VOID *signalContext, UINTPTR sigHandler, UINT32 signo, UINT32 param);
108extern void arm_clean_cache_range(UINTPTR start, UINTPTR end);
109extern 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 */
macro EXC_SP_SET stackSize
Definition: asm.h:50
macro EXC_SP_SET reg1 mrc 获取CPU信息 and mov mul reg0 计算当前CPU栈的偏移位置 ldr reg1 相减得到栈顶 mov sp
Definition: asm.h:57
VOID OsUserCloneParentStack(VOID *childStack, UINTPTR parentTopOfStask, UINT32 parentStackSize)
把父任务上下文克隆给子任务
Definition: los_hw.c:107
VOID OsInitSignalContext(const VOID *sp, VOID *signalContext, UINTPTR sigHandler, UINT32 signo, UINT32 param)
初始化信号上下文
Definition: los_hw.c:138
VOID * OsTaskStackInit(UINT32 taskID, UINT32 stackSize, VOID *topStack, BOOL initFlag)
内核态任务运行栈初始化
Definition: los_hw.c:73
void arm_inv_cache_range(UINTPTR start, UINTPTR end)
VOID OsUserTaskStackInit(TaskContext *context, UINTPTR taskEntry, UINTPTR stack)
用户态运行栈初始化,此时上下文还在内核区
Definition: los_hw.c:123
void arm_clean_cache_range(UINTPTR start, UINTPTR end)
long unsigned int UINT64
Definition: los_typedef.h:66
unsigned long UINTPTR
Definition: los_typedef.h:68
unsigned int UINT32
Definition: los_typedef.h:57
size_t BOOL
Definition: los_typedef.h:88
UINT32 reserved1
Definition: los_hw_pri.h:84
UINT32 R3
Definition: los_hw_pri.h:90
UINT32 R0
Definition: los_hw_pri.h:87
UINT32 regCPSR
Definition: los_hw_pri.h:94
UINT32 LR
Definition: los_hw_pri.h:92
UINT32 PC
Definition: los_hw_pri.h:93
UINT32 USP
Definition: los_hw_pri.h:85
UINT32 R1
Definition: los_hw_pri.h:88
UINT32 ULR
Definition: los_hw_pri.h:86
UINT32 reserved2
Definition: los_hw_pri.h:83
UINT32 R2
Definition: los_hw_pri.h:89
UINT32 R12
Definition: los_hw_pri.h:91
UINT32 regCPSR
Definition: los_hw_pri.h:79
UINT32 LR
Definition: los_hw_pri.h:77
UINT32 R4
Definition: los_hw_pri.h:58
UINT32 R9
Definition: los_hw_pri.h:63
UINT32 R8
Definition: los_hw_pri.h:62
UINT32 R6
Definition: los_hw_pri.h:60
UINT32 ULR
Definition: los_hw_pri.h:71
UINT32 R11
Definition: los_hw_pri.h:65
UINT32 R3
Definition: los_hw_pri.h:75
UINT32 R10
Definition: los_hw_pri.h:64
UINT32 USP
Definition: los_hw_pri.h:70
UINT32 R0
Definition: los_hw_pri.h:72
UINT32 R5
Definition: los_hw_pri.h:59
UINT32 R2
Definition: los_hw_pri.h:74
UINT32 PC
Definition: los_hw_pri.h:78
UINT32 R12
Definition: los_hw_pri.h:76
UINT32 reserved1
Definition: los_hw_pri.h:69
UINT32 R1
Definition: los_hw_pri.h:73
UINT32 R7
Definition: los_hw_pri.h:61
UINT32 reserved2
Definition: los_hw_pri.h:68
UINT32 regFPSCR
Definition: los_hw_pri.h:55
UINT32 regFPEXC
Definition: los_hw_pri.h:56