• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2009-2022 Huawei Technologies Co., Ltd. All rights reserved.
3  *
4  * UniProton is licensed under Mulan PSL v2.
5  * You can use this software according to the terms and conditions of the Mulan PSL v2.
6  * You may obtain a copy of Mulan PSL v2 at:
7  *          http://license.coscl.org.cn/MulanPSL2
8  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
9  * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
10  * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
11  * See the Mulan PSL v2 for more details.
12  * Create: 2009-12-22
13  * Description: 系统信息的内部头文件
14  */
15 #ifndef PRT_SYS_EXTERNAL_H
16 #define PRT_SYS_EXTERNAL_H
17 
18 #include "prt_sys.h"
19 #include "prt_task.h"
20 #include "prt_sem.h"
21 #include "prt_tick.h"
22 #include "prt_list_external.h"
23 #include "prt_asm_cpu_external.h"
24 #include "prt_cpu_external.h"
25 
26 #define OS_VAR_ARRAY_NUM OS_MAX_CORE_NUM
27 #define THIS_CORE() OS_THIS_CORE
28 
29 #define OS_SYS_PID_BASE (0x0U << OS_TSK_TCB_INDEX_BITS)
30 
31 #define OS_INT_ACTIVE_MASK \
32     (OS_FLG_HWI_ACTIVE | OS_FLG_TICK_ACTIVE | OS_FLG_SYS_ACTIVE | OS_FLG_EXC_ACTIVE)
33 
34 #define OS_INT_ACTIVE ((UNI_FLAG & OS_INT_ACTIVE_MASK) != 0)
35 #define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
36 #define OS_HWI_ACTIVE_MASK  (OS_FLG_HWI_ACTIVE | OS_FLG_TICK_ACTIVE | OS_FLG_SYS_ACTIVE | OS_FLG_EXC_ACTIVE)
37 #define OS_HWI_ACTIVE ((UNI_FLAG & OS_HWI_ACTIVE_MASK) != 0)
38 
39 #define OS_THREAD_FLAG_MASK \
40     (OS_FLG_HWI_ACTIVE | OS_FLG_BGD_ACTIVE | OS_FLG_TICK_ACTIVE | OS_FLG_SYS_ACTIVE | OS_FLG_EXC_ACTIVE)
41 
42 #define OS_SYS_TASK_STATUS(flag) (((flag) & OS_THREAD_FLAG_MASK) == OS_FLG_BGD_ACTIVE)
43 #define OS_SYS_HWI_STATUS(flag) (((flag) & OS_FLG_HWI_ACTIVE) != 0)
44 
45 #define OS_MS2CYCLE(ms, clock) DIV64(((ms) * (U64)(clock)), OS_SYS_MS_PER_SECOND) /* 毫秒转换成cycle */
46 #define OS_US2CYCLE(us, clock) DIV64(((us) * (U64)(clock)), OS_SYS_US_PER_SECOND) /* 微秒转换成cycle */
47 
48 /*
49  * 模块间typedef声明
50  */
51 typedef void (*TickDispFunc)(void);
52 /* 有TICK情况下CPU占用率触发函数类型定义。 */
53 typedef void (*TickEntryFunc)(void);
54 typedef void (*TaskScanFunc)(void);
55 /*
56  * 模块间全局变量声明
57  */
58 extern U32 g_threadNum;
59 extern U32 g_tickNoRespondCnt;
60 #define TICK_NO_RESPOND_CNT g_tickNoRespondCnt
61 
62 extern U32 g_systemClock;
63 
64 extern struct TickModInfo g_tickModInfo;
65 extern U64 g_uniTicks;
66 extern TickEntryFunc g_tickTaskEntry;
67 extern TaskScanFunc g_taskScanHook;
68 extern TickDispFunc g_tickDispatcher;
69 
70 extern U32 g_uniFlag;
71 #define UNI_FLAG g_uniFlag
72 
73 /*
74  * 模块间函数声明
75  */
76 extern U8 OsGetCpuType(void);
77 extern U64 OsCurCycleGet64(void);
78 extern U32 OsSetSysTimeHook(SysTimeFunc hook);
79 extern enum SysThreadType OsCurThreadType(void);
80 
81 /*
82  * 模块间内联函数定义
83  */
84 #define OS_TASK_SCAN()                \
85     do {                              \
86         if (g_taskScanHook != NULL) { \
87             g_taskScanHook();         \
88         }                             \
89     } while (0)
90 
OsSysGetTickPerSecond(void)91 OS_SEC_ALW_INLINE INLINE U32 OsSysGetTickPerSecond(void)
92 {
93     return g_tickModInfo.tickPerSecond;
94 }
95 
96 #endif /* PRT_SYS_EXTERNAL_H */
97