• 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_SYS_PID_BASE (OsGetHwThreadId() << OS_TSK_TCB_INDEX_BITS)
27 
28 #define OS_INT_ACTIVE_MASK \
29     (OS_FLG_HWI_ACTIVE | OS_FLG_TICK_ACTIVE | OS_FLG_SYS_ACTIVE | OS_FLG_EXC_ACTIVE)
30 
31 #define OS_INT_ACTIVE ((UNI_FLAG & OS_INT_ACTIVE_MASK) != 0)
32 #define OS_INT_INACTIVE (!(OS_INT_ACTIVE))
33 #define OS_HWI_ACTIVE_MASK  (OS_FLG_HWI_ACTIVE | OS_FLG_TICK_ACTIVE | OS_FLG_SYS_ACTIVE | OS_FLG_EXC_ACTIVE)
34 #define OS_HWI_ACTIVE ((UNI_FLAG & OS_HWI_ACTIVE_MASK) != 0)
35 
36 #define OS_THREAD_FLAG_MASK \
37     (OS_FLG_HWI_ACTIVE | OS_FLG_BGD_ACTIVE | OS_FLG_TICK_ACTIVE | OS_FLG_SYS_ACTIVE | OS_FLG_EXC_ACTIVE)
38 
39 #define OS_SYS_TASK_STATUS(flag) (((flag) & OS_THREAD_FLAG_MASK) == OS_FLG_BGD_ACTIVE)
40 #define OS_SYS_HWI_STATUS(flag) (((flag) & OS_FLG_HWI_ACTIVE) != 0)
41 
42 #define OS_MS2CYCLE(ms, clock) DIV64(((ms) * (U64)(clock)), OS_SYS_MS_PER_SECOND) /* 毫秒转换成cycle */
43 #define OS_US2CYCLE(us, clock) DIV64(((us) * (U64)(clock)), OS_SYS_US_PER_SECOND) /* 微秒转换成cycle */
44 
45 /*
46  * 模块间typedef声明
47  */
48 typedef void (*TickDispFunc)(void);
49 /* 有TICK情况下CPU占用率触发函数类型定义。 */
50 typedef void (*TickEntryFunc)(void);
51 typedef void (*TaskScanFunc)(void);
52 typedef U64 (*SysTimeFunc)(void);
53 /*
54  * 模块间全局变量声明
55  */
56 extern U32 g_threadNum;
57 
58 extern U32 g_tickNoRespondCnt;
59 #define TICK_NO_RESPOND_CNT g_tickNoRespondCnt
60 
61 extern U32 g_systemClock;
62 
63 extern struct TickModInfo g_tickModInfo;
64 extern U64 g_uniTicks;
65 extern TickEntryFunc g_tickTaskEntry;
66 extern TaskScanFunc g_taskScanHook;
67 extern TickDispFunc g_tickDispatcher;
68 
69 extern U32 g_uniFlag;
70 #define UNI_FLAG g_uniFlag
71 
72 /*
73  * 模块间函数声明
74  */
75 extern U8 OsGetCpuType(void);
76 extern U64 OsCurCycleGet64(void);
77 extern U32 OsSetSysTimeHook(SysTimeFunc hook);
78 extern enum SysThreadType OsCurThreadType(void);
79 
80 /*
81  * 模块间内联函数定义
82  */
83 #define OS_TASK_SCAN()                \
84     do {                              \
85         if (g_taskScanHook != NULL) { \
86             g_taskScanHook();         \
87         }                             \
88     } while (0)
89 
90 #endif /* PRT_SYS_EXTERNAL_H */
91