• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ----------------------------------------------------------------------------
2  * Copyright (c) Huawei Technologies Co., Ltd. 2018-2019. All rights reserved.
3  * Description: Percpu Private HeadFile
4  * Author: Huawei LiteOS Team
5  * Create: 2018-08-29
6  * Redistribution and use in source and binary forms, with or without modification,
7  * are permitted provided that the following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice, this list of
9  * conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright notice, this list
11  * of conditions and the following disclaimer in the documentation and/or other materials
12  * provided with the distribution.
13  * 3. Neither the name of the copyright holder nor the names of its contributors may be used
14  * to endorse or promote products derived from this software without specific prior written
15  * permission.
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
18  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
20  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
23  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  * --------------------------------------------------------------------------- */
28 
29 #ifndef _LOS_PERCPU_PRI_H
30 #define _LOS_PERCPU_PRI_H
31 
32 #include "los_base.h"
33 #include "los_sortlink_pri.h"
34 
35 #include "arch/cpu.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif /* __cplusplus */
40 
41 #ifdef LOSCFG_KERNEL_SMP
42 typedef enum {
43     CPU_RUNNING = 0,   /* cpu is running */
44     CPU_HALT,          /* cpu in the halt */
45     CPU_EXC            /* cpu in the exc */
46 } ExcFlag;
47 #endif
48 
49 typedef struct {
50     UINT16 head;
51     UINT16 tail;
52     UINT32 free;
53     UINTPTR* buf;
54 } ExpiryList;
55 
56 typedef struct {
57     SortLinkAttribute taskSortLink;             /* task sort link */
58 #ifdef LOSCFG_BASE_CORE_SWTMR
59     SortLinkAttribute swtmrSortLink;            /* swtmr sort link */
60     ExpiryList expiryList;                      /* swtmr expiry List */
61 #endif
62 
63     UINT32 idleTaskId;                          /* idle task id */
64     UINT32 taskLockCnt;                         /* task lock flag */
65     UINT32 swtmrHandlerQueue;                   /* software timer timeout queue id */
66     UINT32 swtmrTaskId;                         /* software timer task id */
67 #ifndef LOSCFG_SCHED_LATENCY
68     UINT32 schedFlag;                           /* pending scheduler flag */
69 #endif
70 #ifdef LOSCFG_KERNEL_SMP
71     UINT32 excFlag;                             /* cpu halt or exc flag */
72 #ifdef LOSCFG_KERNEL_SMP_CALL
73     LOS_DL_LIST funcLink;                       /* mp function call link */
74 #endif
75 #endif
76 } Percpu;
77 
78 /* the kernel per-cpu structure */
79 extern Percpu g_percpu[LOSCFG_KERNEL_CORE_NUM];
80 
OsPercpuGet(VOID)81 STATIC INLINE Percpu *OsPercpuGet(VOID)
82 {
83     return &g_percpu[ArchCurrCpuid()];
84 }
85 
OsPercpuGetByID(UINT32 cpuid)86 STATIC INLINE Percpu *OsPercpuGetByID(UINT32 cpuid)
87 {
88     return &g_percpu[cpuid];
89 }
90 
91 #ifdef __cplusplus
92 }
93 #endif /* __cplusplus */
94 
95 #endif /* _LOS_PERCPU_PRI_H */
96