Compare commits
20 Commits
weekly_202
...
weekly_202
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74f8d3aa07 | ||
|
|
dc479fb7bd | ||
|
|
91bdcbd3c2 | ||
|
|
422f22f5d2 | ||
|
|
6c0865dd46 | ||
|
|
0257a0a14f | ||
|
|
046d8defdf | ||
|
|
7938d2e569 | ||
|
|
3d00a7d23a | ||
|
|
e3cd485db5 | ||
|
|
0e3936c4f8 | ||
|
|
95248d4482 | ||
|
|
1ecda9c033 | ||
|
|
9018eab20f | ||
|
|
e6bdfbb7a5 | ||
|
|
a28fcee1c5 | ||
|
|
f47da44b39 | ||
|
|
b37a7b7929 | ||
|
|
8e356c99c7 | ||
|
|
a1ae2ecc13 |
@@ -1,6 +1,6 @@
|
||||
### 相关的Issue
|
||||
|
||||
|
||||
|
||||
### 原因(目的、解决的问题等)
|
||||
|
||||
|
||||
@@ -8,5 +8,14 @@
|
||||
|
||||
|
||||
### 测试用例(新增、改动、可能影响的功能)
|
||||
|
||||
|
||||
|
||||
|
||||
### 是否需要同步至release(如:3.0LTS ... )分支?
|
||||
|
||||
必须选择一项(在MarkDown模式下用[x]替换[ ]即可勾选对应选项):
|
||||
- [ ] 是,需要同步的分支:
|
||||
- [ ] 否
|
||||
|
||||
理由:
|
||||
|
||||
|
||||
|
||||
@@ -29,13 +29,14 @@
|
||||
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/mksh/mksh.gni")
|
||||
|
||||
group("mksh") {
|
||||
deps = [ ":build_mksh" ]
|
||||
}
|
||||
|
||||
copy("copy_mksh_src") {
|
||||
sources = [ "$LITEOSTHIRDPARTY/mksh" ]
|
||||
sources = MKSH_SRC_DIR
|
||||
outputs = [ "$target_out_dir/mksh_build" ]
|
||||
}
|
||||
|
||||
|
||||
@@ -29,13 +29,14 @@
|
||||
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/toybox/toybox.gni")
|
||||
|
||||
group("toybox") {
|
||||
deps = [ ":build_toybox" ]
|
||||
}
|
||||
|
||||
copy("copy_toybox_src") {
|
||||
sources = [ "$LITEOSTHIRDPARTY/toybox" ]
|
||||
sources = TOYBOX_SRC_DIR
|
||||
outputs = [ "$target_out_dir/toybox_build" ]
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ extern VOID HalClockInit(VOID);
|
||||
extern UINT64 HalClockGetCycles(VOID);
|
||||
extern VOID HalDelayUs(UINT32 usecs);
|
||||
extern UINT32 HalClockGetTickTimerCycles(VOID);
|
||||
extern VOID HalClockTickTimerReload(UINT64 cycles);
|
||||
extern UINT64 HalClockTickTimerReload(UINT64 cycles);
|
||||
|
||||
extern UINT32 HrtimersInit(VOID);
|
||||
extern VOID HrtimerClockIrqClear(VOID);
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
|
||||
#include "los_hw_pri.h"
|
||||
#include "los_tick_pri.h"
|
||||
#include "los_sched_pri.h"
|
||||
#include "los_sys_pri.h"
|
||||
#include "gic_common.h"
|
||||
|
||||
@@ -139,11 +138,6 @@ LITE_OS_SEC_TEXT_INIT VOID HalClockInit(VOID)
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT VOID HalClockStart(VOID)
|
||||
{
|
||||
UINT32 ret = OsSchedSetTickTimerType(64); /* 64 bit tick timer */
|
||||
if (ret != LOS_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
HalIrqUnmask(OS_TICK_INT_NUM);
|
||||
|
||||
/* triggle the first tick */
|
||||
@@ -175,7 +169,7 @@ UINT32 HalClockGetTickTimerCycles(VOID)
|
||||
return (UINT32)((cval > cycles) ? (cval - cycles) : 0);
|
||||
}
|
||||
|
||||
VOID HalClockTickTimerReload(UINT64 cycles)
|
||||
UINT64 HalClockTickTimerReload(UINT64 cycles)
|
||||
{
|
||||
HalIrqMask(OS_TICK_INT_NUM);
|
||||
HalIrqClear(OS_TICK_INT_NUM);
|
||||
@@ -185,4 +179,5 @@ VOID HalClockTickTimerReload(UINT64 cycles)
|
||||
TimerCtlWrite(1);
|
||||
|
||||
HalIrqUnmask(OS_TICK_INT_NUM);
|
||||
return cycles;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "los_memory_pri.h"
|
||||
#include "los_printf_pri.h"
|
||||
#include "los_task_pri.h"
|
||||
#include "los_percpu_pri.h"
|
||||
#include "los_hw_pri.h"
|
||||
#ifdef LOSCFG_SAVE_EXCINFO
|
||||
#include "los_excinfo_pri.h"
|
||||
@@ -58,6 +59,7 @@
|
||||
#include "los_bitmap.h"
|
||||
#include "los_process_pri.h"
|
||||
#include "los_exc_pri.h"
|
||||
#include "los_sched_pri.h"
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
#include "console.h"
|
||||
#endif
|
||||
@@ -191,7 +193,7 @@ UINT32 OsArmSharedPageFault(UINT32 excType, ExcContext *frame, UINT32 far, UINT3
|
||||
return LOS_ERRNO_VM_NOT_FOUND;
|
||||
}
|
||||
#if defined(LOSCFG_KERNEL_SMP) && defined(LOSCFG_DEBUG_VERSION)
|
||||
BOOL irqEnable = !(LOS_SpinHeld(&g_taskSpin) && (OsPercpuGet()->taskLockCnt != 0));
|
||||
BOOL irqEnable = !(LOS_SpinHeld(&g_taskSpin) && OsSchedIsLock());
|
||||
if (irqEnable) {
|
||||
ArchIrqEnable();
|
||||
} else {
|
||||
@@ -535,9 +537,9 @@ STATIC VOID OsExcRestore(VOID)
|
||||
g_intCount[currCpuID] = 0;
|
||||
g_curNestCount[currCpuID] = 0;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
OsPercpuGet()->excFlag = CPU_RUNNING;
|
||||
OsCpuStatusSet(CPU_RUNNING);
|
||||
#endif
|
||||
OsPercpuGet()->taskLockCnt = 0;
|
||||
OsSchedLockSet(0);
|
||||
}
|
||||
|
||||
STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
|
||||
@@ -587,7 +589,7 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
/* Exception handling All operations should be kept prior to that operation */
|
||||
OsExcRestore();
|
||||
OsTaskToExit(runTask, OS_PRO_EXIT_OK);
|
||||
OsRunningTaskToExit(runTask, OS_PRO_EXIT_OK);
|
||||
} else {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
@@ -977,28 +979,6 @@ VOID OsDataAbortExcHandleEntry(ExcContext *excBufAddr)
|
||||
#define EXC_WAIT_INTER 50U
|
||||
#define EXC_WAIT_TIME 2000U
|
||||
|
||||
STATIC VOID OsAllCpuStatusOutput(VOID)
|
||||
{
|
||||
UINT32 i;
|
||||
|
||||
for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
|
||||
switch (g_percpu[i].excFlag) {
|
||||
case CPU_RUNNING:
|
||||
PrintExcInfo("cpu%u is running.\n", i);
|
||||
break;
|
||||
case CPU_HALT:
|
||||
PrintExcInfo("cpu%u is halted.\n", i);
|
||||
break;
|
||||
case CPU_EXC:
|
||||
PrintExcInfo("cpu%u is in exc.\n", i);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
PrintExcInfo("The current handling the exception is cpu%u !\n", ArchCurrCpuid());
|
||||
}
|
||||
|
||||
STATIC VOID WaitAllCpuStop(UINT32 cpuID)
|
||||
{
|
||||
UINT32 i;
|
||||
@@ -1006,7 +986,7 @@ STATIC VOID WaitAllCpuStop(UINT32 cpuID)
|
||||
|
||||
while (time < EXC_WAIT_TIME) {
|
||||
for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
|
||||
if ((i != cpuID) && (g_percpu[i].excFlag != CPU_HALT)) {
|
||||
if ((i != cpuID) && !OsCpuStatusIsHalt(i)) {
|
||||
LOS_Mdelay(EXC_WAIT_INTER);
|
||||
time += EXC_WAIT_INTER;
|
||||
break;
|
||||
@@ -1044,7 +1024,7 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
|
||||
UINT32 currCpuID = ArchCurrCpuid();
|
||||
UINT32 ret, target;
|
||||
|
||||
OsPercpuGet()->excFlag = CPU_EXC;
|
||||
OsCpuStatusSet(CPU_EXC);
|
||||
LOCKDEP_CLEAR_LOCKS();
|
||||
|
||||
LOS_SpinLock(&g_excSerializerSpin);
|
||||
@@ -1152,15 +1132,15 @@ LITE_OS_SEC_TEXT_INIT STATIC VOID OsPrintExcHead(UINT32 far)
|
||||
STATIC VOID OsSysStateSave(UINT32 *intCount, UINT32 *lockCount)
|
||||
{
|
||||
*intCount = g_intCount[ArchCurrCpuid()];
|
||||
*lockCount = OsPercpuGet()->taskLockCnt;
|
||||
*lockCount = OsSchedLockCountGet();
|
||||
g_intCount[ArchCurrCpuid()] = 0;
|
||||
OsPercpuGet()->taskLockCnt = 0;
|
||||
OsSchedLockSet(0);
|
||||
}
|
||||
|
||||
STATIC VOID OsSysStateRestore(UINT32 intCount, UINT32 lockCount)
|
||||
{
|
||||
g_intCount[ArchCurrCpuid()] = intCount;
|
||||
OsPercpuGet()->taskLockCnt = lockCount;
|
||||
OsSchedLockSet(lockCount);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1177,7 +1157,7 @@ LITE_OS_SEC_TEXT_INIT VOID OsExcHandleEntry(UINT32 excType, ExcContext *excBufAd
|
||||
#endif
|
||||
|
||||
/* Task scheduling is not allowed during exception handling */
|
||||
OsPercpuGet()->taskLockCnt++;
|
||||
OsSchedLock();
|
||||
|
||||
g_curNestCount[ArchCurrCpuid()]++;
|
||||
|
||||
|
||||
66
bundle.json
Normal file
66
bundle.json
Normal file
@@ -0,0 +1,66 @@
|
||||
{
|
||||
"name": "@ohos/liteos_a",
|
||||
"version": "3.1.0",
|
||||
"description": "liteos-a kernel",
|
||||
"homePage": "https://gitee.com/openharmony",
|
||||
"license": "BSD 3-clause",
|
||||
"repository": "https://gitee.com/openharmony/kernel_liteos_a",
|
||||
"domain": "os",
|
||||
"language": "",
|
||||
"publishAs": "code-segment",
|
||||
"private": false,
|
||||
"scripts": {},
|
||||
"tags": [
|
||||
"kernel"
|
||||
],
|
||||
"keywords": [
|
||||
"kernel",
|
||||
"liteos-a"
|
||||
],
|
||||
"envs": [],
|
||||
"dirs": [],
|
||||
"author": {},
|
||||
"contributors": [],
|
||||
"segment": {
|
||||
"destPath": "kernel/liteos_a"
|
||||
},
|
||||
"component": {
|
||||
"name": "liteos_a",
|
||||
"subsystem": "kernel",
|
||||
"syscap": [
|
||||
"SystemCapability.Kernel.liteos-a"
|
||||
],
|
||||
"features": [],
|
||||
"adated_system_type": [
|
||||
"small"
|
||||
],
|
||||
"rom": "1.5MB",
|
||||
"ram": "2MB",
|
||||
"deps": {
|
||||
"components": [
|
||||
],
|
||||
"third_party": [
|
||||
"bounds_checking_function",
|
||||
"toybox",
|
||||
"NuttX",
|
||||
"Linux_Kernel",
|
||||
"FatFs",
|
||||
"mksh",
|
||||
"musl",
|
||||
"mbedtls",
|
||||
"FreeBSD",
|
||||
"zlib",
|
||||
"lwip",
|
||||
"optimized-routines",
|
||||
"googletest"
|
||||
]
|
||||
},
|
||||
"build": {
|
||||
"sub_component": [
|
||||
"//kernel/liteos_a:liteos_a"
|
||||
],
|
||||
"inner_kits": [],
|
||||
"test": []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,21 +28,12 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/NuttX/NuttX.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_VFS_BLOCK_DEVICE)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchdev_driver.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchdev_register.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchdev_unregister.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_cache.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_read.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_sem.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_setup.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_teardown.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/drivers/bch/bchlib_write.c",
|
||||
]
|
||||
sources = NUTTX_DRIVERS_BCH_SRC_FILES
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
@@ -28,15 +28,16 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/NuttX/NuttX.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_DRIVERS_VIDEO)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [ "$LITEOSTHIRDPARTY/NuttX/drivers/video/fb.c" ]
|
||||
sources = NUTTX_DRIVERS_VIDEO_SRC_FILES
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "$LITEOSTHIRDPARTY/NuttX/include/nuttx/video" ]
|
||||
include_dirs = NUTTX_DRIVERS_VIDEO_INCLUDE_DIRS
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/FatFs/FatFs.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_FAT)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
@@ -38,12 +39,7 @@ kernel_module(module_name) {
|
||||
"os_adapt/format.c",
|
||||
]
|
||||
|
||||
sources += [
|
||||
"$LITEOSTHIRDPARTY/FatFs/source/diskio.c",
|
||||
"$LITEOSTHIRDPARTY/FatFs/source/ff.c",
|
||||
"$LITEOSTHIRDPARTY/FatFs/source/ffsystem.c",
|
||||
"$LITEOSTHIRDPARTY/FatFs/source/ffunicode.c",
|
||||
]
|
||||
sources += FATFS_SRC_FILES
|
||||
|
||||
include_dirs = [ "os_adapt" ]
|
||||
|
||||
@@ -51,5 +47,5 @@ kernel_module(module_name) {
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "$LITEOSTHIRDPARTY/FatFs/source" ]
|
||||
include_dirs = FATFS_INCLUDE_DIRS
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/Linux_Kernel/Linux_Kernel.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_JFFS)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
@@ -37,35 +38,9 @@ kernel_module(module_name) {
|
||||
"src/vfs_jffs2.c",
|
||||
]
|
||||
|
||||
sources += [
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/background.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/build.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/compr.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/compr_rtime.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/compr_rubin.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/compr_zlib.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/debug.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/dir.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/erase.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/file.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/fs.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/gc.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/malloc.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/nodelist.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/nodemgmt.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/read.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/readinode.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/scan.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/summary.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/super.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/write.c",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2/writev.c",
|
||||
]
|
||||
sources += LINUX_KERNEL_FS_JFFS2_SRC_FILES
|
||||
|
||||
include_dirs = [
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs",
|
||||
]
|
||||
include_dirs = LINUX_KERNEL_FS_JFFS2_INCLUDE_DIRS
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
@@ -28,13 +28,10 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/NuttX/NuttX.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_NFS)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/nfs/nfs_adapter.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/nfs/nfs_util.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/nfs/rpc_clnt.c",
|
||||
]
|
||||
sources = NUTTX_FS_NFS_SRC_FILES
|
||||
}
|
||||
|
||||
@@ -28,9 +28,10 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/NuttX/NuttX.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_RAMFS)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [ "$LITEOSTHIRDPARTY/NuttX/fs/tmpfs/fs_tmpfs.c" ]
|
||||
sources = NUTTX_FS_TMPFS_SRC_FILES
|
||||
}
|
||||
|
||||
@@ -28,12 +28,10 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/NuttX/NuttX.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_ROMFS)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/romfs/fs_romfs.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/romfs/fs_romfsutil.c",
|
||||
]
|
||||
sources = NUTTX_FS_ROMFS_SRC_FILES
|
||||
}
|
||||
|
||||
@@ -28,11 +28,17 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/NuttX/NuttX.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_VFS)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"$LITEOSTOPDIR/fs/vfs/epoll/fs_epoll.c",
|
||||
"$LITEOSTOPDIR/fs/vfs/mount.c",
|
||||
"$LITEOSTOPDIR/fs/vfs/path_cache.c",
|
||||
"$LITEOSTOPDIR/fs/vfs/vnode.c",
|
||||
"$LITEOSTOPDIR/fs/vfs/vnode_hash.c",
|
||||
"operation/fullpath.c",
|
||||
"operation/vfs_chattr.c",
|
||||
"operation/vfs_check.c",
|
||||
@@ -51,65 +57,11 @@ kernel_module(module_name) {
|
||||
"operation/vfs_writev.c",
|
||||
"vfs_cmd/vfs_shellcmd.c",
|
||||
]
|
||||
|
||||
sources += [
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/dirent/fs_closedir.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/dirent/fs_opendir.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/dirent/fs_readdir.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/dirent/fs_rewinddir.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/dirent/fs_seekdir.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/dirent/fs_telldir.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/driver/fs_blockproxy.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/driver/fs_closeblockdriver.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/driver/fs_findblockdriver.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/driver/fs_openblockdriver.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/driver/fs_registerblockdriver.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/driver/fs_registerdriver.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/driver/fs_unregisterblockdriver.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/driver/fs_unregisterdriver.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/inode/fs_files.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/mount/fs_foreachmountpoint.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/mount/fs_mount.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/mount/fs_sync.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/mount/fs_umount.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_close.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_dup.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_dup2.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_dupfd.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_dupfd2.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_fcntl.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_fsync.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_getfilep.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_ioctl.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_link.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_lseek.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_lseek64.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_mkdir.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_open.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_poll.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_pread.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_pread64.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_pwrite.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_pwrite64.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_read.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_readlink.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_rename.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_rmdir.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_select.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_sendfile.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_stat.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_statfs.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_symlink.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_truncate.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_truncate64.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_unlink.c",
|
||||
"$LITEOSTHIRDPARTY/NuttX/fs/vfs/fs_write.c",
|
||||
"$LITEOSTOPDIR/fs/vfs/epoll/fs_epoll.c",
|
||||
"$LITEOSTOPDIR/fs/vfs/mount.c",
|
||||
"$LITEOSTOPDIR/fs/vfs/path_cache.c",
|
||||
"$LITEOSTOPDIR/fs/vfs/vnode.c",
|
||||
"$LITEOSTOPDIR/fs/vfs/vnode_hash.c",
|
||||
]
|
||||
sources += NUTTX_FS_DIRENT_SRC_FILES
|
||||
sources += NUTTX_FS_DRIVER_SRC_FILES
|
||||
sources += NUTTX_FS_INODE_SRC_FILES
|
||||
sources += NUTTX_FS_MOUNT_SRC_FILES
|
||||
sources += NUTTX_FS_VFS_SRC_FILES
|
||||
|
||||
include_dirs = [
|
||||
"$LITEOSTOPDIR/syscall",
|
||||
|
||||
@@ -50,6 +50,9 @@
|
||||
#ifdef LOSCFG_SECURITY_CAPABILITY
|
||||
#include "capability_api.h"
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_DYNLOAD
|
||||
#include "los_load_elf.h"
|
||||
#endif
|
||||
#include "los_swtmr_pri.h"
|
||||
#include "los_vm_map.h"
|
||||
#include "los_vm_phys.h"
|
||||
@@ -75,6 +78,50 @@ STATIC INLINE VOID OsInsertPCBToFreeList(LosProcessCB *processCB)
|
||||
LOS_ListTailInsert(&g_freeProcess, &processCB->pendList);
|
||||
}
|
||||
|
||||
VOID OsDeleteTaskFromProcess(LosTaskCB *taskCB)
|
||||
{
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
|
||||
|
||||
LOS_ListDelete(&taskCB->threadList);
|
||||
processCB->threadNumber--;
|
||||
OsTaskInsertToRecycleList(taskCB);
|
||||
}
|
||||
|
||||
UINT32 OsProcessAddNewTask(UINT32 pid, LosTaskCB *taskCB)
|
||||
{
|
||||
UINT32 intSave;
|
||||
UINT16 numCount;
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(pid);
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
taskCB->processID = pid;
|
||||
LOS_ListTailInsert(&(processCB->threadSiblingList), &(taskCB->threadList));
|
||||
|
||||
if (OsProcessIsUserMode(processCB)) {
|
||||
taskCB->taskStatus |= OS_TASK_FLAG_USER_MODE;
|
||||
if (processCB->threadNumber > 0) {
|
||||
taskCB->basePrio = OS_TCB_FROM_TID(processCB->threadGroupID)->basePrio;
|
||||
} else {
|
||||
taskCB->basePrio = OS_USER_PROCESS_PRIORITY_HIGHEST;
|
||||
}
|
||||
} else {
|
||||
taskCB->basePrio = OsCurrTaskGet()->basePrio;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
taskCB->archMmu = (UINTPTR)&processCB->vmSpace->archMmu;
|
||||
#endif
|
||||
if (!processCB->threadNumber) {
|
||||
processCB->threadGroupID = taskCB->taskID;
|
||||
}
|
||||
processCB->threadNumber++;
|
||||
|
||||
numCount = processCB->threadCount;
|
||||
processCB->threadCount++;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return numCount;
|
||||
}
|
||||
|
||||
STATIC ProcessGroup *OsCreateProcessGroup(UINT32 pid)
|
||||
{
|
||||
LosProcessCB *processCB = NULL;
|
||||
@@ -337,11 +384,6 @@ STATIC VOID OsWaitCheckAndWakeParentProcess(LosProcessCB *parentCB, const LosPro
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsProcessResourcesToFree(LosProcessCB *processCB)
|
||||
{
|
||||
if (!(processCB->processStatus & (OS_PROCESS_STATUS_INIT | OS_PROCESS_STATUS_RUNNING))) {
|
||||
PRINT_ERR("The process(%d) has no permission to release process(%d) resources!\n",
|
||||
OsCurrProcessGet()->processID, processCB->processID);
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
if (OsProcessIsUserMode(processCB)) {
|
||||
(VOID)OsVmSpaceRegionFree(processCB->vmSpace);
|
||||
@@ -396,6 +438,7 @@ LITE_OS_SEC_TEXT STATIC VOID OsRecycleZombiesProcess(LosProcessCB *childCB, Proc
|
||||
OsExitProcessGroup(childCB, group);
|
||||
LOS_ListDelete(&childCB->siblingList);
|
||||
if (childCB->processStatus & OS_PROCESS_STATUS_ZOMBIES) {
|
||||
OsDeleteTaskFromProcess(OS_TCB_FROM_TID(childCB->threadGroupID));
|
||||
childCB->processStatus &= ~OS_PROCESS_STATUS_ZOMBIES;
|
||||
childCB->processStatus |= OS_PROCESS_FLAG_UNUSED;
|
||||
}
|
||||
@@ -455,13 +498,10 @@ STATIC VOID OsChildProcessResourcesFree(const LosProcessCB *processCB)
|
||||
}
|
||||
}
|
||||
|
||||
STATIC VOID OsProcessNaturalExit(LosTaskCB *runTask, UINT32 status)
|
||||
VOID OsProcessNaturalExit(LosProcessCB *processCB, UINT32 status)
|
||||
{
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(runTask->processID);
|
||||
LosProcessCB *parentCB = NULL;
|
||||
|
||||
LOS_ASSERT(processCB->processStatus & OS_PROCESS_STATUS_RUNNING);
|
||||
|
||||
OsChildProcessResourcesFree(processCB);
|
||||
|
||||
/* is a child process */
|
||||
@@ -485,7 +525,6 @@ STATIC VOID OsProcessNaturalExit(LosTaskCB *runTask, UINT32 status)
|
||||
(VOID)OsKill(processCB->parentProcessID, SIGCHLD, OS_KERNEL_KILL_PERMISSION);
|
||||
#endif
|
||||
LOS_ListHeadInsert(&g_processRecycleList, &processCB->pendList);
|
||||
OsRunTaskToDelete(runTask);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -636,13 +675,12 @@ UINT32 OsSetProcessName(LosProcessCB *processCB, const CHAR *name)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC UINT32 OsInitPCB(LosProcessCB *processCB, UINT32 mode, UINT16 priority, const CHAR *name)
|
||||
STATIC UINT32 OsInitPCB(LosProcessCB *processCB, UINT32 mode, const CHAR *name)
|
||||
{
|
||||
processCB->processMode = mode;
|
||||
processCB->processStatus = OS_PROCESS_STATUS_INIT;
|
||||
processCB->parentProcessID = OS_INVALID_VALUE;
|
||||
processCB->threadGroupID = OS_INVALID_VALUE;
|
||||
processCB->priority = priority;
|
||||
processCB->umask = OS_PROCESS_DEFAULT_UMASK;
|
||||
processCB->timerID = (timer_t)(UINTPTR)MAX_INVALID_TIMER_VID;
|
||||
|
||||
@@ -757,10 +795,10 @@ LITE_OS_SEC_TEXT INT32 LOS_GetGroupID(VOID)
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC UINT32 OsProcessCreateInit(LosProcessCB *processCB, UINT32 flags, const CHAR *name, UINT16 priority)
|
||||
STATIC UINT32 OsProcessCreateInit(LosProcessCB *processCB, UINT32 flags, const CHAR *name)
|
||||
{
|
||||
ProcessGroup *group = NULL;
|
||||
UINT32 ret = OsInitPCB(processCB, flags, priority, name);
|
||||
UINT32 ret = OsInitPCB(processCB, flags, name);
|
||||
if (ret != LOS_OK) {
|
||||
goto EXIT;
|
||||
}
|
||||
@@ -802,7 +840,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSystemProcessCreate(VOID)
|
||||
}
|
||||
|
||||
LosProcessCB *kerInitProcess = OS_PCB_FROM_PID(g_kernelInitProcess);
|
||||
ret = OsProcessCreateInit(kerInitProcess, OS_KERNEL_MODE, "KProcess", 0);
|
||||
ret = OsProcessCreateInit(kerInitProcess, OS_KERNEL_MODE, "KProcess");
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
@@ -810,10 +848,9 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSystemProcessCreate(VOID)
|
||||
kerInitProcess->processStatus &= ~OS_PROCESS_STATUS_INIT;
|
||||
g_processGroup = kerInitProcess->group;
|
||||
LOS_ListInit(&g_processGroup->groupList);
|
||||
OsCurrProcessSet(kerInitProcess);
|
||||
|
||||
LosProcessCB *idleProcess = OS_PCB_FROM_PID(g_kernelIdleProcess);
|
||||
ret = OsInitPCB(idleProcess, OS_KERNEL_MODE, OS_TASK_PRIORITY_LOWEST, "KIdle");
|
||||
ret = OsInitPCB(idleProcess, OS_KERNEL_MODE, "KIdle");
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
@@ -827,12 +864,13 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSystemProcessCreate(VOID)
|
||||
#ifdef LOSCFG_FS_VFS
|
||||
idleProcess->files = kerInitProcess->files;
|
||||
#endif
|
||||
idleProcess->processStatus &= ~OS_PROCESS_STATUS_INIT;
|
||||
|
||||
ret = OsIdleTaskCreate();
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
idleProcess->threadGroupID = OsPercpuGet()->idleTaskID;
|
||||
idleProcess->threadGroupID = OsGetIdleTaskId();
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
@@ -869,7 +907,7 @@ STATIC BOOL OsProcessCapPermitCheck(const LosProcessCB *processCB, UINT16 prio)
|
||||
}
|
||||
|
||||
/* user mode process can reduce the priority of itself */
|
||||
if ((runProcess->processID == processCB->processID) && (prio > processCB->priority)) {
|
||||
if ((runProcess->processID == processCB->processID) && (prio > OsCurrTaskGet()->basePrio)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -907,7 +945,7 @@ LITE_OS_SEC_TEXT INT32 OsSetProcessScheduler(INT32 which, INT32 pid, UINT16 prio
|
||||
}
|
||||
#endif
|
||||
|
||||
needSched = OsSchedModifyProcessSchedParam(processCB, policy, prio);
|
||||
needSched = OsSchedModifyProcessSchedParam(pid, policy, prio);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
LOS_MpSchedule(OS_MP_CPU_ALL);
|
||||
@@ -953,7 +991,6 @@ LITE_OS_SEC_TEXT INT32 LOS_SetProcessPriority(INT32 pid, UINT16 prio)
|
||||
|
||||
LITE_OS_SEC_TEXT INT32 OsGetProcessPriority(INT32 which, INT32 pid)
|
||||
{
|
||||
LosProcessCB *processCB = NULL;
|
||||
INT32 prio;
|
||||
UINT32 intSave;
|
||||
(VOID)which;
|
||||
@@ -966,14 +1003,14 @@ LITE_OS_SEC_TEXT INT32 OsGetProcessPriority(INT32 which, INT32 pid)
|
||||
return -LOS_EINVAL;
|
||||
}
|
||||
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(pid);
|
||||
SCHEDULER_LOCK(intSave);
|
||||
processCB = OS_PCB_FROM_PID(pid);
|
||||
if (OsProcessIsUnused(processCB)) {
|
||||
prio = -LOS_ESRCH;
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
prio = (INT32)processCB->priority;
|
||||
prio = (INT32)OS_TCB_FROM_TID(processCB->threadGroupID)->basePrio;
|
||||
|
||||
OUT:
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
@@ -1425,6 +1462,36 @@ STATIC VOID *OsUserInitStackAlloc(LosProcessCB *processCB, UINT32 *size)
|
||||
return (VOID *)(UINTPTR)region->range.base;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_DYNLOAD
|
||||
LITE_OS_SEC_TEXT VOID OsExecProcessVmSpaceRestore(LosVmSpace *oldSpace)
|
||||
{
|
||||
LosProcessCB *processCB = OsCurrProcessGet();
|
||||
LosTaskCB *runTask = OsCurrTaskGet();
|
||||
|
||||
processCB->vmSpace = oldSpace;
|
||||
runTask->archMmu = (UINTPTR)&processCB->vmSpace->archMmu;
|
||||
LOS_ArchMmuContextSwitch((LosArchMmu *)runTask->archMmu);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT LosVmSpace *OsExecProcessVmSpaceReplace(LosVmSpace *newSpace, UINTPTR stackBase, INT32 randomDevFD)
|
||||
{
|
||||
LosProcessCB *processCB = OsCurrProcessGet();
|
||||
LosTaskCB *runTask = OsCurrTaskGet();
|
||||
|
||||
OsProcessThreadGroupDestroy();
|
||||
OsTaskCBRecycleToFree();
|
||||
|
||||
LosVmSpace *oldSpace = processCB->vmSpace;
|
||||
processCB->vmSpace = newSpace;
|
||||
processCB->vmSpace->heapBase += OsGetRndOffset(randomDevFD);
|
||||
processCB->vmSpace->heapNow = processCB->vmSpace->heapBase;
|
||||
processCB->vmSpace->mapBase += OsGetRndOffset(randomDevFD);
|
||||
processCB->vmSpace->mapSize = stackBase - processCB->vmSpace->mapBase;
|
||||
runTask->archMmu = (UINTPTR)&processCB->vmSpace->archMmu;
|
||||
LOS_ArchMmuContextSwitch((LosArchMmu *)runTask->archMmu);
|
||||
return oldSpace;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT UINT32 OsExecRecycleAndInit(LosProcessCB *processCB, const CHAR *name,
|
||||
LosVmSpace *oldSpace, UINTPTR oldFiles)
|
||||
{
|
||||
@@ -1502,27 +1569,39 @@ LITE_OS_SEC_TEXT UINT32 OsExecStart(const TSK_ENTRY_FUNC entry, UINTPTR sp, UINT
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return LOS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC UINT32 OsUserInitProcessStart(UINT32 processID, TSK_INIT_PARAM_S *param)
|
||||
STATIC UINT32 OsUserInitProcessStart(LosProcessCB *processCB, TSK_INIT_PARAM_S *param)
|
||||
{
|
||||
UINT32 intSave;
|
||||
UINT32 taskID;
|
||||
INT32 ret;
|
||||
|
||||
taskID = OsCreateUserTask(processID, param);
|
||||
UINT32 taskID = OsCreateUserTask(processCB->processID, param);
|
||||
if (taskID == OS_INVALID_VALUE) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
ret = LOS_SetProcessPriority(processCB->processID, OS_PROCESS_USERINIT_PRIORITY);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("User init process set priority failed! ERROR:%d \n", ret);
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
processCB->processStatus &= ~OS_PROCESS_STATUS_INIT;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
ret = LOS_SetTaskScheduler(taskID, LOS_SCHED_RR, OS_TASK_PRIORITY_LOWEST);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("User init process set scheduler failed! ERROR:%d \n", ret);
|
||||
SCHEDULER_LOCK(intSave);
|
||||
(VOID)OsTaskDeleteUnsafe(OS_TCB_FROM_TID(taskID), OS_PRO_EXIT_OK, intSave);
|
||||
return LOS_NOK;
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
EXIT:
|
||||
(VOID)LOS_TaskDelete(taskID);
|
||||
return ret;
|
||||
}
|
||||
|
||||
STATIC UINT32 OsLoadUserInit(LosProcessCB *processCB)
|
||||
@@ -1598,7 +1677,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsUserInitProcess(VOID)
|
||||
VOID *stack = NULL;
|
||||
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(g_userInitProcess);
|
||||
ret = OsProcessCreateInit(processCB, OS_USER_MODE, "Init", OS_PROCESS_USERINIT_PRIORITY);
|
||||
ret = OsProcessCreateInit(processCB, OS_USER_MODE, "Init");
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
@@ -1619,7 +1698,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsUserInitProcess(VOID)
|
||||
param.userParam.userMapBase = (UINTPTR)stack;
|
||||
param.userParam.userMapSize = size;
|
||||
param.uwResved = OS_TASK_FLAG_PTHREAD_JOIN;
|
||||
ret = OsUserInitProcessStart(g_userInitProcess, ¶m);
|
||||
ret = OsUserInitProcessStart(processCB, ¶m);
|
||||
if (ret != LOS_OK) {
|
||||
(VOID)OsUnMMap(processCB->vmSpace, param.userParam.userMapBase, param.userParam.userMapSize);
|
||||
goto ERROR;
|
||||
@@ -1696,6 +1775,7 @@ STATIC UINT32 OsCopyTask(UINT32 flags, LosProcessCB *childProcessCB, const CHAR
|
||||
|
||||
LosTaskCB *childTaskCB = OS_TCB_FROM_TID(taskID);
|
||||
childTaskCB->taskStatus = runTask->taskStatus;
|
||||
childTaskCB->basePrio = runTask->basePrio;
|
||||
if (childTaskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
|
||||
childTaskCB->taskStatus &= ~OS_TASK_STATUS_RUNNING;
|
||||
} else {
|
||||
@@ -1703,7 +1783,6 @@ STATIC UINT32 OsCopyTask(UINT32 flags, LosProcessCB *childProcessCB, const CHAR
|
||||
LOS_Panic("Clone thread status not running error status: 0x%x\n", childTaskCB->taskStatus);
|
||||
}
|
||||
childTaskCB->taskStatus &= ~OS_TASK_STATUS_UNUSED;
|
||||
childProcessCB->priority = OS_PROCESS_PRIORITY_LOWEST;
|
||||
}
|
||||
|
||||
if (OsProcessIsUserMode(childProcessCB)) {
|
||||
@@ -1721,7 +1800,6 @@ STATIC UINT32 OsCopyParent(UINT32 flags, LosProcessCB *childProcessCB, LosProces
|
||||
LosProcessCB *parentProcessCB = NULL;
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
childProcessCB->priority = runProcessCB->priority;
|
||||
|
||||
if (flags & CLONE_PARENT) {
|
||||
parentProcessCB = OS_PCB_FROM_PID(runProcessCB->parentProcessID);
|
||||
@@ -1785,7 +1863,7 @@ STATIC UINT32 OsForkInitPCB(UINT32 flags, LosProcessCB *child, const CHAR *name,
|
||||
UINT32 ret;
|
||||
LosProcessCB *run = OsCurrProcessGet();
|
||||
|
||||
ret = OsInitPCB(child, run->processMode, OS_PROCESS_PRIORITY_LOWEST, name);
|
||||
ret = OsInitPCB(child, run->processMode, name);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
@@ -1813,6 +1891,7 @@ STATIC UINT32 OsChildSetProcessGroupAndSched(LosProcessCB *child, LosProcessCB *
|
||||
}
|
||||
}
|
||||
|
||||
child->processStatus &= ~OS_PROCESS_STATUS_INIT;
|
||||
OsSchedTaskEnQueue(OS_TCB_FROM_TID(child->threadGroupID));
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
@@ -1852,7 +1931,7 @@ STATIC UINT32 OsCopyProcessResources(UINT32 flags, LosProcessCB *child, LosProce
|
||||
|
||||
STATIC INT32 OsCopyProcess(UINT32 flags, const CHAR *name, UINTPTR sp, UINT32 size)
|
||||
{
|
||||
UINT32 intSave, ret, processID;
|
||||
UINT32 ret, processID;
|
||||
LosProcessCB *run = OsCurrProcessGet();
|
||||
|
||||
LosProcessCB *child = OsGetFreePCB();
|
||||
@@ -1884,8 +1963,7 @@ STATIC INT32 OsCopyProcess(UINT32 flags, const CHAR *name, UINTPTR sp, UINT32 si
|
||||
return processID;
|
||||
|
||||
ERROR_TASK:
|
||||
SCHEDULER_LOCK(intSave);
|
||||
(VOID)OsTaskDeleteUnsafe(OS_TCB_FROM_TID(child->threadGroupID), OS_PRO_EXIT_OK, intSave);
|
||||
(VOID)LOS_TaskDelete(child->threadGroupID);
|
||||
ERROR_INIT:
|
||||
OsDeInitPCB(child);
|
||||
return -ret;
|
||||
@@ -1934,8 +2012,8 @@ LITE_OS_SEC_TEXT VOID LOS_Exit(INT32 status)
|
||||
}
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
OsTaskExitGroup((UINT32)status);
|
||||
OsProcessExit(OsCurrTaskGet(), (UINT32)status);
|
||||
OsProcessThreadGroupDestroy();
|
||||
OsRunningTaskToExit(OsCurrTaskGet(), OS_PRO_EXIT_OK);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT INT32 LOS_GetUsedPIDList(UINT32 *pidList, INT32 pidMaxNum)
|
||||
@@ -1989,17 +2067,77 @@ LITE_OS_SEC_TEXT UINT32 LOS_GetCurrProcessID(VOID)
|
||||
return OsCurrProcessGet()->processID;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsProcessExit(LosTaskCB *runTask, INT32 status)
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
STATIC VOID ThreadGroupActiveTaskKilled(LosTaskCB *taskCB)
|
||||
{
|
||||
INT32 ret;
|
||||
|
||||
taskCB->taskStatus |= OS_TASK_FLAG_EXIT_KILL;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
/** The other core that the thread is running on and is currently running in a non-system call */
|
||||
if (!taskCB->sig.sigIntLock && (taskCB->taskStatus & OS_TASK_STATUS_RUNNING)) {
|
||||
taskCB->signal = SIGNAL_KILL;
|
||||
LOS_MpSchedule(taskCB->currCpu);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
ret = OsTaskKillUnsafe(taskCB->taskID, SIGKILL);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("pid %u exit, Exit task group %u kill %u failed! ERROR: %d\n",
|
||||
taskCB->processID, OsCurrTaskGet()->taskID, taskCB->taskID, ret);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(taskCB->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN)) {
|
||||
taskCB->taskStatus |= OS_TASK_FLAG_PTHREAD_JOIN;
|
||||
LOS_ListInit(&taskCB->joinList);
|
||||
}
|
||||
|
||||
ret = OsTaskJoinPendUnsafe(taskCB);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("pid %u exit, Exit task group %u to wait others task %u(0x%x) exit failed! ERROR: %d\n",
|
||||
taskCB->processID, OsCurrTaskGet()->taskID, taskCB->taskID, taskCB->taskStatus, ret);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsProcessThreadGroupDestroy(VOID)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
UINT32 intSave;
|
||||
LOS_ASSERT(runTask == OsCurrTaskGet());
|
||||
|
||||
OsTaskResourcesToFree(runTask);
|
||||
OsProcessResourcesToFree(OsCurrProcessGet());
|
||||
|
||||
LosProcessCB *processCB = OsCurrProcessGet();
|
||||
LosTaskCB *currTask = OsCurrTaskGet();
|
||||
SCHEDULER_LOCK(intSave);
|
||||
OsProcessNaturalExit(runTask, status);
|
||||
if ((processCB->processStatus & OS_PROCESS_FLAG_EXIT) || !OsProcessIsUserMode(processCB)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return;
|
||||
}
|
||||
|
||||
processCB->processStatus |= OS_PROCESS_FLAG_EXIT;
|
||||
processCB->threadGroupID = currTask->taskID;
|
||||
|
||||
LOS_DL_LIST *list = &processCB->threadSiblingList;
|
||||
LOS_DL_LIST *head = list;
|
||||
do {
|
||||
LosTaskCB *taskCB = LOS_DL_LIST_ENTRY(list->pstNext, LosTaskCB, threadList);
|
||||
if ((OsTaskIsInactive(taskCB) ||
|
||||
((taskCB->taskStatus & OS_TASK_STATUS_READY) && !taskCB->sig.sigIntLock)) &&
|
||||
!(taskCB->taskStatus & OS_TASK_STATUS_RUNNING)) {
|
||||
OsInactiveTaskDelete(taskCB);
|
||||
} else if (taskCB != currTask) {
|
||||
ThreadGroupActiveTaskKilled(taskCB);
|
||||
} else {
|
||||
/* Skip the current task */
|
||||
list = list->pstNext;
|
||||
}
|
||||
} while (head != list->pstNext);
|
||||
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
LOS_ASSERT(processCB->threadNumber == 1);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT UINT32 LOS_GetSystemProcessMaximum(VOID)
|
||||
|
||||
@@ -45,8 +45,6 @@ STATIC VOID OsSmpSecondaryInit(VOID *arg)
|
||||
{
|
||||
UNUSED(arg);
|
||||
|
||||
OsCurrProcessSet(OS_PCB_FROM_PID(OsGetKernelInitProcessID()));
|
||||
|
||||
#ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE
|
||||
OsSwtmrInit();
|
||||
#endif
|
||||
|
||||
@@ -52,13 +52,13 @@ LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_swtmrSpin);
|
||||
#define SWTMR_LOCK(state) LOS_SpinLockSave(&g_swtmrSpin, &(state))
|
||||
#define SWTMR_UNLOCK(state) LOS_SpinUnlockRestore(&g_swtmrSpin, (state))
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsSwtmrTask(VOID)
|
||||
STATIC VOID SwtmrTask(VOID)
|
||||
{
|
||||
SwtmrHandlerItemPtr swtmrHandlePtr = NULL;
|
||||
SwtmrHandlerItem swtmrHandle;
|
||||
UINT32 ret, swtmrHandlerQueue;
|
||||
|
||||
swtmrHandlerQueue = OsPercpuGet()->swtmrHandlerQueue;
|
||||
swtmrHandlerQueue = OsSchedSwtmrHandlerQueueGet();
|
||||
for (;;) {
|
||||
ret = LOS_QueueRead(swtmrHandlerQueue, &swtmrHandlePtr, sizeof(CHAR *), LOS_WAIT_FOREVER);
|
||||
if ((ret == LOS_OK) && (swtmrHandlePtr != NULL)) {
|
||||
@@ -72,14 +72,13 @@ LITE_OS_SEC_TEXT VOID OsSwtmrTask(VOID)
|
||||
}
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrTaskCreate(VOID)
|
||||
STATIC UINT32 SwtmrTaskCreate(UINT16 cpuid, UINT32 *swtmrTaskID)
|
||||
{
|
||||
UINT32 ret, swtmrTaskID;
|
||||
UINT32 ret;
|
||||
TSK_INIT_PARAM_S swtmrTask;
|
||||
UINT32 cpuid = ArchCurrCpuid();
|
||||
|
||||
(VOID)memset_s(&swtmrTask, sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
swtmrTask.pfnTaskEntry = (TSK_ENTRY_FUNC)OsSwtmrTask;
|
||||
swtmrTask.pfnTaskEntry = (TSK_ENTRY_FUNC)SwtmrTask;
|
||||
swtmrTask.uwStackSize = LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE;
|
||||
swtmrTask.pcName = "Swt_Task";
|
||||
swtmrTask.usTaskPrio = 0;
|
||||
@@ -87,15 +86,22 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrTaskCreate(VOID)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
swtmrTask.usCpuAffiMask = CPUID_TO_AFFI_MASK(cpuid);
|
||||
#endif
|
||||
ret = LOS_TaskCreate(&swtmrTaskID, &swtmrTask);
|
||||
ret = LOS_TaskCreate(swtmrTaskID, &swtmrTask);
|
||||
if (ret == LOS_OK) {
|
||||
g_percpu[cpuid].swtmrTaskID = swtmrTaskID;
|
||||
OS_TCB_FROM_TID(swtmrTaskID)->taskStatus |= OS_TASK_FLAG_SYSTEM_TASK;
|
||||
OS_TCB_FROM_TID(*swtmrTaskID)->taskStatus |= OS_TASK_FLAG_SYSTEM_TASK;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL OsIsSwtmrTask(const LosTaskCB *taskCB)
|
||||
{
|
||||
if (taskCB->taskEntry == (TSK_ENTRY_FUNC)SwtmrTask) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsSwtmrRecycle(UINT32 processID)
|
||||
{
|
||||
for (UINT16 index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++) {
|
||||
@@ -113,6 +119,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrInit(VOID)
|
||||
SWTMR_CTRL_S *swtmr = NULL;
|
||||
UINT32 swtmrHandlePoolSize;
|
||||
UINT32 cpuid = ArchCurrCpuid();
|
||||
UINT32 swtmrTaskID, swtmrHandlerQueue;
|
||||
|
||||
if (cpuid == 0) {
|
||||
size = sizeof(SWTMR_CTRL_S) * LOSCFG_BASE_CORE_SWTMR_LIMIT;
|
||||
swtmr = (SWTMR_CTRL_S *)LOS_MemAlloc(m_aucSysMem0, size); /* system resident resource */
|
||||
@@ -142,31 +150,21 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrInit(VOID)
|
||||
ret = LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM;
|
||||
goto ERROR;
|
||||
}
|
||||
|
||||
ret = OsSchedSwtmrScanRegister((SchedScan)OsSwtmrScan);
|
||||
if (ret != LOS_OK) {
|
||||
goto ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
ret = LOS_QueueCreate(NULL, OS_SWTMR_HANDLE_QUEUE_SIZE, &g_percpu[cpuid].swtmrHandlerQueue, 0, sizeof(CHAR *));
|
||||
ret = LOS_QueueCreate(NULL, OS_SWTMR_HANDLE_QUEUE_SIZE, &swtmrHandlerQueue, 0, sizeof(CHAR *));
|
||||
if (ret != LOS_OK) {
|
||||
ret = LOS_ERRNO_SWTMR_QUEUE_CREATE_FAILED;
|
||||
goto ERROR;
|
||||
}
|
||||
|
||||
ret = OsSwtmrTaskCreate();
|
||||
ret = SwtmrTaskCreate(cpuid, &swtmrTaskID);
|
||||
if (ret != LOS_OK) {
|
||||
ret = LOS_ERRNO_SWTMR_TASK_CREATE_FAILED;
|
||||
goto ERROR;
|
||||
}
|
||||
|
||||
ret = OsSortLinkInit(&g_percpu[cpuid].swtmrSortLink);
|
||||
if (ret != LOS_OK) {
|
||||
ret = LOS_ERRNO_SWTMR_SORTLINK_CREATE_FAILED;
|
||||
goto ERROR;
|
||||
}
|
||||
|
||||
OsSchedRunQueSwtmrInit(swtmrTaskID, swtmrHandlerQueue);
|
||||
return LOS_OK;
|
||||
|
||||
ERROR:
|
||||
@@ -178,7 +176,7 @@ ERROR:
|
||||
* Description: Start Software Timer
|
||||
* Input : swtmr --- Need to start software timer
|
||||
*/
|
||||
LITE_OS_SEC_TEXT VOID OsSwtmrStart(UINT64 currTime, SWTMR_CTRL_S *swtmr)
|
||||
LITE_OS_SEC_TEXT VOID OsSwtmrStart(SWTMR_CTRL_S *swtmr)
|
||||
{
|
||||
UINT32 ticks;
|
||||
|
||||
@@ -191,8 +189,8 @@ LITE_OS_SEC_TEXT VOID OsSwtmrStart(UINT64 currTime, SWTMR_CTRL_S *swtmr)
|
||||
}
|
||||
swtmr->ucState = OS_SWTMR_STATUS_TICKING;
|
||||
|
||||
OsAdd2SortLink(&swtmr->stSortList, swtmr->startTime, ticks, OS_SORT_LINK_SWTMR);
|
||||
OsSchedUpdateExpireTime(currTime);
|
||||
OsSchedAddSwtmr2TimeList(&swtmr->stSortList, swtmr->startTime, ticks);
|
||||
OsSchedUpdateExpireTime();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -208,15 +206,18 @@ STATIC INLINE VOID OsSwtmrDelete(SWTMR_CTRL_S *swtmr)
|
||||
swtmr->uwOwnerPid = 0;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsWakePendTimeSwtmr(Percpu *cpu, UINT64 currTime, SWTMR_CTRL_S *swtmr)
|
||||
VOID OsSwtmrWake(SchedRunQue *rq, UINT64 startTime, SortLinkList *sortList)
|
||||
{
|
||||
SWTMR_CTRL_S *swtmr = LOS_DL_LIST_ENTRY(sortList, SWTMR_CTRL_S, stSortList);
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_SWTMR_EXPIRED, swtmr);
|
||||
LOS_SpinLock(&g_swtmrSpin);
|
||||
SwtmrHandlerItemPtr swtmrHandler = (SwtmrHandlerItemPtr)LOS_MemboxAlloc(g_swtmrHandlerPool);
|
||||
if (swtmrHandler != NULL) {
|
||||
swtmrHandler->handler = swtmr->pfnHandler;
|
||||
swtmrHandler->arg = swtmr->uwArg;
|
||||
|
||||
if (LOS_QueueWrite(cpu->swtmrHandlerQueue, swtmrHandler, sizeof(CHAR *), LOS_NO_WAIT)) {
|
||||
if (LOS_QueueWrite(rq->swtmrHandlerQueue, swtmrHandler, sizeof(CHAR *), LOS_NO_WAIT)) {
|
||||
(VOID)LOS_MemboxFree(g_swtmrHandlerPool, swtmrHandler);
|
||||
}
|
||||
}
|
||||
@@ -233,54 +234,32 @@ STATIC INLINE VOID OsWakePendTimeSwtmr(Percpu *cpu, UINT64 currTime, SWTMR_CTRL_
|
||||
swtmr->ucState = OS_SWTMR_STATUS_CREATED;
|
||||
} else {
|
||||
swtmr->uwOverrun++;
|
||||
OsSwtmrStart(currTime, swtmr);
|
||||
swtmr->startTime = startTime;
|
||||
OsSwtmrStart(swtmr);
|
||||
}
|
||||
|
||||
LOS_SpinUnlock(&g_swtmrSpin);
|
||||
}
|
||||
|
||||
/*
|
||||
* Description: Tick interrupt interface module of software timer
|
||||
* Return : LOS_OK on success or error code on failure
|
||||
*/
|
||||
LITE_OS_SEC_TEXT VOID OsSwtmrScan(VOID)
|
||||
VOID OsSwtmrRestart(UINT64 startTime, SortLinkList *sortList)
|
||||
{
|
||||
Percpu *cpu = OsPercpuGet();
|
||||
SortLinkAttribute* swtmrSortLink = &OsPercpuGet()->swtmrSortLink;
|
||||
LOS_DL_LIST *listObject = &swtmrSortLink->sortLink;
|
||||
UINT32 intSave;
|
||||
|
||||
/*
|
||||
* it needs to be carefully coped with, since the swtmr is in specific sortlink
|
||||
* while other cores still has the chance to process it, like stop the timer.
|
||||
*/
|
||||
LOS_SpinLock(&cpu->swtmrSortLinkSpin);
|
||||
SWTMR_CTRL_S *swtmr = LOS_DL_LIST_ENTRY(sortList, SWTMR_CTRL_S, stSortList);
|
||||
SWTMR_LOCK(intSave);
|
||||
swtmr->startTime = startTime;
|
||||
OsSwtmrStart(swtmr);
|
||||
SWTMR_UNLOCK(intSave);
|
||||
}
|
||||
|
||||
if (LOS_ListEmpty(listObject)) {
|
||||
LOS_SpinUnlock(&cpu->swtmrSortLinkSpin);
|
||||
return;
|
||||
}
|
||||
SortLinkList *sortList = LOS_DL_LIST_ENTRY(listObject->pstNext, SortLinkList, sortLinkNode);
|
||||
BOOL OsSwtmrWorkQueueFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
UINT64 currTime = OsGetCurrSchedTimeCycle();
|
||||
while (sortList->responseTime <= currTime) {
|
||||
sortList = LOS_DL_LIST_ENTRY(listObject->pstNext, SortLinkList, sortLinkNode);
|
||||
SWTMR_CTRL_S *swtmr = LOS_DL_LIST_ENTRY(sortList, SWTMR_CTRL_S, stSortList);
|
||||
swtmr->startTime = GET_SORTLIST_VALUE(sortList);
|
||||
OsDeleteNodeSortLink(swtmrSortLink, sortList);
|
||||
LOS_SpinUnlock(&cpu->swtmrSortLinkSpin);
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_SWTMR_EXPIRED, swtmr);
|
||||
OsWakePendTimeSwtmr(cpu, currTime, swtmr);
|
||||
|
||||
LOS_SpinLock(&cpu->swtmrSortLinkSpin);
|
||||
if (LOS_ListEmpty(listObject)) {
|
||||
break;
|
||||
}
|
||||
|
||||
sortList = LOS_DL_LIST_ENTRY(listObject->pstNext, SortLinkList, sortLinkNode);
|
||||
}
|
||||
|
||||
LOS_SpinUnlock(&cpu->swtmrSortLinkSpin);
|
||||
SWTMR_LOCK(intSave);
|
||||
BOOL find = OsSchedSwtmrTimeListFind(checkFunc, arg);
|
||||
SWTMR_UNLOCK(intSave);
|
||||
return find;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -289,7 +268,12 @@ LITE_OS_SEC_TEXT VOID OsSwtmrScan(VOID)
|
||||
*/
|
||||
LITE_OS_SEC_TEXT UINT32 OsSwtmrGetNextTimeout(VOID)
|
||||
{
|
||||
return OsSortLinkGetNextExpireTime(&OsPercpuGet()->swtmrSortLink);
|
||||
UINT64 currTime = OsGetCurrSchedTimeCycle();
|
||||
UINT64 time = (OsSortLinkGetNextExpireTime(currTime, &OsSchedRunQue()->swtmrSortLink) / OS_CYCLE_PER_TICK);
|
||||
if (time > OS_INVALID_VALUE) {
|
||||
time = OS_INVALID_VALUE;
|
||||
}
|
||||
return (UINT32)time;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -298,12 +282,12 @@ LITE_OS_SEC_TEXT UINT32 OsSwtmrGetNextTimeout(VOID)
|
||||
*/
|
||||
LITE_OS_SEC_TEXT STATIC VOID OsSwtmrStop(SWTMR_CTRL_S *swtmr)
|
||||
{
|
||||
OsDeleteSortLink(&swtmr->stSortList, OS_SORT_LINK_SWTMR);
|
||||
OsSchedDeSwtmrFromTimeList(&swtmr->stSortList);
|
||||
|
||||
swtmr->ucState = OS_SWTMR_STATUS_CREATED;
|
||||
swtmr->uwOverrun = 0;
|
||||
|
||||
OsSchedUpdateExpireTime(OsGetCurrSchedTimeCycle());
|
||||
OsSchedUpdateExpireTime();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -312,7 +296,12 @@ LITE_OS_SEC_TEXT STATIC VOID OsSwtmrStop(SWTMR_CTRL_S *swtmr)
|
||||
*/
|
||||
LITE_OS_SEC_TEXT STATIC UINT32 OsSwtmrTimeGet(const SWTMR_CTRL_S *swtmr)
|
||||
{
|
||||
return OsSortLinkGetTargetExpireTime(&swtmr->stSortList);
|
||||
UINT64 currTime = OsGetCurrSchedTimeCycle();
|
||||
UINT64 time = (OsSortLinkGetTargetExpireTime(currTime, &swtmr->stSortList) / OS_CYCLE_PER_TICK);
|
||||
if (time > OS_INVALID_VALUE) {
|
||||
time = OS_INVALID_VALUE;
|
||||
}
|
||||
return (UINT32)time;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_SwtmrCreate(UINT32 interval,
|
||||
@@ -400,7 +389,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrStart(UINT16 swtmrID)
|
||||
/* fall-through */
|
||||
case OS_SWTMR_STATUS_CREATED:
|
||||
swtmr->startTime = OsGetCurrSchedTimeCycle();
|
||||
OsSwtmrStart(swtmr->startTime, swtmr);
|
||||
OsSwtmrStart(swtmr);
|
||||
break;
|
||||
default:
|
||||
ret = LOS_ERRNO_SWTMR_STATUS_INVALID;
|
||||
|
||||
@@ -94,6 +94,8 @@ VOID OsSetMainTask()
|
||||
for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
|
||||
g_mainTask[i].taskStatus = OS_TASK_STATUS_UNUSED;
|
||||
g_mainTask[i].taskID = LOSCFG_BASE_CORE_TSK_LIMIT;
|
||||
g_mainTask[i].processID = OS_KERNEL_PROCESS_GROUP;
|
||||
g_mainTask[i].basePrio = OS_TASK_PRIORITY_HIGHEST;
|
||||
g_mainTask[i].priority = OS_TASK_PRIORITY_LOWEST;
|
||||
#ifdef LOSCFG_KERNEL_SMP_LOCKDEP
|
||||
g_mainTask[i].lockDep.lockDepth = 0;
|
||||
@@ -111,14 +113,9 @@ LITE_OS_SEC_TEXT WEAK VOID OsIdleTask(VOID)
|
||||
}
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsInsertTCBToFreeList(LosTaskCB *taskCB)
|
||||
VOID OsTaskInsertToRecycleList(LosTaskCB *taskCB)
|
||||
{
|
||||
UINT32 taskID = taskCB->taskID;
|
||||
(VOID)memset_s(taskCB, sizeof(LosTaskCB), 0, sizeof(LosTaskCB));
|
||||
taskCB->taskID = taskID;
|
||||
taskCB->taskStatus = OS_TASK_STATUS_UNUSED;
|
||||
taskCB->processID = OS_INVALID_VALUE;
|
||||
LOS_ListAdd(&g_losFreeTask, &taskCB->pendList);
|
||||
LOS_ListTailInsert(&g_taskRecycleList, &taskCB->pendList);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT VOID OsTaskJoinPostUnsafe(LosTaskCB *taskCB)
|
||||
@@ -137,11 +134,6 @@ LITE_OS_SEC_TEXT_INIT VOID OsTaskJoinPostUnsafe(LosTaskCB *taskCB)
|
||||
|
||||
LITE_OS_SEC_TEXT UINT32 OsTaskJoinPendUnsafe(LosTaskCB *taskCB)
|
||||
{
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
|
||||
if (!(processCB->processStatus & OS_PROCESS_STATUS_RUNNING)) {
|
||||
return LOS_EPERM;
|
||||
}
|
||||
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_INIT) {
|
||||
return LOS_EINVAL;
|
||||
}
|
||||
@@ -160,11 +152,6 @@ LITE_OS_SEC_TEXT UINT32 OsTaskJoinPendUnsafe(LosTaskCB *taskCB)
|
||||
|
||||
LITE_OS_SEC_TEXT UINT32 OsTaskSetDetachUnsafe(LosTaskCB *taskCB)
|
||||
{
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
|
||||
if (!(processCB->processStatus & OS_PROCESS_STATUS_RUNNING)) {
|
||||
return LOS_EPERM;
|
||||
}
|
||||
|
||||
if (taskCB->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN) {
|
||||
if (LOS_ListEmpty(&(taskCB->joinList))) {
|
||||
LOS_ListDelete(&(taskCB->joinList));
|
||||
@@ -216,16 +203,14 @@ EXIT:
|
||||
|
||||
UINT32 OsGetIdleTaskId(VOID)
|
||||
{
|
||||
Percpu *perCpu = OsPercpuGet();
|
||||
return perCpu->idleTaskID;
|
||||
return OsSchedGetRunQueIdle();
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 OsIdleTaskCreate(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
TSK_INIT_PARAM_S taskInitParam;
|
||||
Percpu *perCpu = OsPercpuGet();
|
||||
UINT32 *idleTaskID = &perCpu->idleTaskID;
|
||||
UINT32 idleTaskID;
|
||||
|
||||
(VOID)memset_s((VOID *)(&taskInitParam), sizeof(TSK_INIT_PARAM_S), 0, sizeof(TSK_INIT_PARAM_S));
|
||||
taskInitParam.pfnTaskEntry = (TSK_ENTRY_FUNC)OsIdleTask;
|
||||
@@ -236,9 +221,10 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsIdleTaskCreate(VOID)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ret = LOS_TaskCreateOnly(idleTaskID, &taskInitParam);
|
||||
LosTaskCB *idleTask = OS_TCB_FROM_TID(*idleTaskID);
|
||||
ret = LOS_TaskCreateOnly(&idleTaskID, &taskInitParam);
|
||||
LosTaskCB *idleTask = OS_TCB_FROM_TID(idleTaskID);
|
||||
idleTask->taskStatus |= OS_TASK_FLAG_SYSTEM_TASK;
|
||||
OsSchedRunQueIdleInit(idleTaskID);
|
||||
OsSchedSetIdleTaskSchedParam(idleTask);
|
||||
|
||||
return ret;
|
||||
@@ -316,60 +302,87 @@ STATIC INLINE VOID OsTaskSyncWake(const LosTaskCB *taskCB)
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC VOID OsTaskReleaseHoldLock(LosProcessCB *processCB, LosTaskCB *taskCB)
|
||||
STATIC INLINE VOID OsInsertTCBToFreeList(LosTaskCB *taskCB)
|
||||
{
|
||||
LosMux *mux = NULL;
|
||||
UINT32 ret;
|
||||
UINT32 taskID = taskCB->taskID;
|
||||
(VOID)memset_s(taskCB, sizeof(LosTaskCB), 0, sizeof(LosTaskCB));
|
||||
taskCB->taskID = taskID;
|
||||
taskCB->taskStatus = OS_TASK_STATUS_UNUSED;
|
||||
taskCB->processID = OS_INVALID_VALUE;
|
||||
LOS_ListAdd(&g_losFreeTask, &taskCB->pendList);
|
||||
}
|
||||
|
||||
while (!LOS_ListEmpty(&taskCB->lockList)) {
|
||||
mux = LOS_DL_LIST_ENTRY(LOS_DL_LIST_FIRST(&taskCB->lockList), LosMux, holdList);
|
||||
ret = OsMuxUnlockUnsafe(taskCB, mux, NULL);
|
||||
if (ret != LOS_OK) {
|
||||
LOS_ListDelete(&mux->holdList);
|
||||
PRINT_ERR("mux ulock failed! : %u\n", ret);
|
||||
}
|
||||
}
|
||||
STATIC VOID OsTaskKernelResourcesToFree(UINT32 syncSignal, UINTPTR topOfStack)
|
||||
{
|
||||
OsTaskSyncDestroy(syncSignal);
|
||||
|
||||
(VOID)LOS_MemFree((VOID *)m_aucSysMem1, (VOID *)topOfStack);
|
||||
}
|
||||
|
||||
STATIC VOID OsTaskResourcesToFree(LosTaskCB *taskCB)
|
||||
{
|
||||
UINT32 syncSignal = LOSCFG_BASE_IPC_SEM_LIMIT;
|
||||
UINT32 intSave;
|
||||
UINTPTR topOfStack;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
if (processCB->processMode == OS_USER_MODE) {
|
||||
OsFutexNodeDeleteFromFutexHash(&taskCB->futex, TRUE, NULL, NULL);
|
||||
if ((taskCB->taskStatus & OS_TASK_FLAG_USER_MODE) && (taskCB->userMapBase != 0)) {
|
||||
SCHEDULER_LOCK(intSave);
|
||||
UINT32 mapBase = (UINTPTR)taskCB->userMapBase;
|
||||
UINT32 mapSize = taskCB->userMapSize;
|
||||
taskCB->userMapBase = 0;
|
||||
taskCB->userArea = 0;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
|
||||
LOS_ASSERT(!(OsProcessVmSpaceGet(processCB) == NULL));
|
||||
UINT32 ret = OsUnMMap(OsProcessVmSpaceGet(processCB), (UINTPTR)mapBase, mapSize);
|
||||
if ((ret != LOS_OK) && (mapBase != 0) && !OsProcessIsInit(processCB)) {
|
||||
PRINT_ERR("process(%u) unmmap user task(%u) stack failed! mapbase: 0x%x size :0x%x, error: %d\n",
|
||||
taskCB->processID, taskCB->taskID, mapBase, mapSize, ret);
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_LITEIPC
|
||||
LiteIpcRemoveServiceHandle(taskCB->taskID);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
OsTaskJoinPostUnsafe(taskCB);
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
|
||||
topOfStack = taskCB->topOfStack;
|
||||
taskCB->topOfStack = 0;
|
||||
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
|
||||
syncSignal = taskCB->syncSignal;
|
||||
taskCB->syncSignal = LOSCFG_BASE_IPC_SEM_LIMIT;
|
||||
#endif
|
||||
OsTaskKernelResourcesToFree(syncSignal, topOfStack);
|
||||
|
||||
OsTaskSyncWake(taskCB);
|
||||
SCHEDULER_LOCK(intSave);
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
OsClearSigInfoTmpList(&(taskCB->sig));
|
||||
#endif
|
||||
OsInsertTCBToFreeList(taskCB);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsTaskToExit(LosTaskCB *taskCB, UINT32 status)
|
||||
LITE_OS_SEC_TEXT VOID OsTaskCBRecycleToFree()
|
||||
{
|
||||
LosTaskCB *taskCB = NULL;
|
||||
UINT32 intSave;
|
||||
|
||||
LosProcessCB *runProcess = OS_PCB_FROM_PID(taskCB->processID);
|
||||
LosTaskCB *mainTask = OS_TCB_FROM_TID(runProcess->threadGroupID);
|
||||
if (mainTask == taskCB) {
|
||||
OsTaskExitGroup(status);
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
|
||||
if (runProcess->threadNumber == 1) { /* 1: The last task of the process exits */
|
||||
while (!LOS_ListEmpty(&g_taskRecycleList)) {
|
||||
taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_taskRecycleList));
|
||||
LOS_ListDelete(&taskCB->pendList);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
(VOID)OsProcessExit(taskCB, status);
|
||||
return;
|
||||
|
||||
OsTaskResourcesToFree(taskCB);
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
}
|
||||
|
||||
if ((taskCB->taskStatus & OS_TASK_FLAG_EXIT_KILL) || !(taskCB->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN)) {
|
||||
UINT32 ret = OsTaskDeleteUnsafe(taskCB, status, intSave);
|
||||
LOS_Panic("Task delete failed! ERROR : 0x%x\n", ret);
|
||||
return;
|
||||
}
|
||||
|
||||
OsTaskReleaseHoldLock(runProcess, taskCB);
|
||||
|
||||
OsSchedResched();
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -397,13 +410,12 @@ LITE_OS_SEC_TEXT_INIT VOID OsTaskEntry(UINT32 taskID)
|
||||
taskCB->joinRetval = 0;
|
||||
}
|
||||
|
||||
OsTaskToExit(taskCB, 0);
|
||||
OsRunningTaskToExit(taskCB, 0);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT STATIC UINT32 OsTaskCreateParamCheck(const UINT32 *taskID,
|
||||
TSK_INIT_PARAM_S *initParam, VOID **pool)
|
||||
{
|
||||
LosProcessCB *process = NULL;
|
||||
UINT32 poolSize = OS_SYS_MEM_SIZE;
|
||||
*pool = (VOID *)m_aucSysMem1;
|
||||
|
||||
@@ -415,11 +427,7 @@ LITE_OS_SEC_TEXT_INIT STATIC UINT32 OsTaskCreateParamCheck(const UINT32 *taskID,
|
||||
return LOS_ERRNO_TSK_PTR_NULL;
|
||||
}
|
||||
|
||||
process = OS_PCB_FROM_PID(initParam->processID);
|
||||
if (process->processMode > OS_USER_MODE) {
|
||||
return LOS_ERRNO_TSK_ID_INVALID;
|
||||
}
|
||||
|
||||
LosProcessCB *process = OS_PCB_FROM_PID(initParam->processID);
|
||||
if (!OsProcessIsUserMode(process)) {
|
||||
if (initParam->pcName == NULL) {
|
||||
return LOS_ERRNO_TSK_NAME_EMPTY;
|
||||
@@ -455,81 +463,6 @@ LITE_OS_SEC_TEXT_INIT STATIC VOID OsTaskStackAlloc(VOID **topStack, UINT32 stack
|
||||
*topStack = (VOID *)LOS_MemAllocAlign(pool, stackSize, LOSCFG_STACK_POINT_ALIGN_SIZE);
|
||||
}
|
||||
|
||||
STATIC VOID OsTaskKernelResourcesToFree(UINT32 syncSignal, UINTPTR topOfStack)
|
||||
{
|
||||
VOID *poolTmp = (VOID *)m_aucSysMem1;
|
||||
|
||||
OsTaskSyncDestroy(syncSignal);
|
||||
|
||||
(VOID)LOS_MemFree(poolTmp, (VOID *)topOfStack);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsTaskCBRecycleToFree()
|
||||
{
|
||||
LosTaskCB *taskCB = NULL;
|
||||
UINT32 intSave;
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
while (!LOS_ListEmpty(&g_taskRecycleList)) {
|
||||
taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&g_taskRecycleList));
|
||||
LOS_ListDelete(&taskCB->pendList);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
OsTaskResourcesToFree(taskCB);
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
}
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsTaskResourcesToFree(LosTaskCB *taskCB)
|
||||
{
|
||||
UINT32 syncSignal = LOSCFG_BASE_IPC_SEM_LIMIT;
|
||||
UINT32 intSave;
|
||||
UINTPTR topOfStack;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
|
||||
if (OsProcessIsUserMode(processCB) && (taskCB->userMapBase != 0)) {
|
||||
SCHEDULER_LOCK(intSave);
|
||||
UINT32 mapBase = (UINTPTR)taskCB->userMapBase;
|
||||
UINT32 mapSize = taskCB->userMapSize;
|
||||
taskCB->userMapBase = 0;
|
||||
taskCB->userArea = 0;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
LOS_ASSERT(!(processCB->vmSpace == NULL));
|
||||
UINT32 ret = OsUnMMap(processCB->vmSpace, (UINTPTR)mapBase, mapSize);
|
||||
if ((ret != LOS_OK) && (mapBase != 0) && !(processCB->processStatus & OS_PROCESS_STATUS_INIT)) {
|
||||
PRINT_ERR("process(%u) unmmap user task(%u) stack failed! mapbase: 0x%x size :0x%x, error: %d\n",
|
||||
processCB->processID, taskCB->taskID, mapBase, mapSize, ret);
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_LITEIPC
|
||||
LiteIpcRemoveServiceHandle(taskCB->taskID);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
|
||||
topOfStack = taskCB->topOfStack;
|
||||
taskCB->topOfStack = 0;
|
||||
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
|
||||
syncSignal = taskCB->syncSignal;
|
||||
taskCB->syncSignal = LOSCFG_BASE_IPC_SEM_LIMIT;
|
||||
#endif
|
||||
OsTaskKernelResourcesToFree(syncSignal, topOfStack);
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
OsClearSigInfoTmpList(&(taskCB->sig));
|
||||
#endif
|
||||
OsInsertTCBToFreeList(taskCB);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT STATIC VOID OsTaskCBInitBase(LosTaskCB *taskCB,
|
||||
const VOID *stackPtr,
|
||||
const VOID *topStack,
|
||||
@@ -558,7 +491,6 @@ LITE_OS_SEC_TEXT_INIT STATIC VOID OsTaskCBInitBase(LosTaskCB *taskCB,
|
||||
LOS_ListInit(&taskCB->joinList);
|
||||
}
|
||||
|
||||
taskCB->futex.index = OS_INVALID_VALUE;
|
||||
LOS_ListInit(&taskCB->lockList);
|
||||
SET_SORTLIST_VALUE(&taskCB->sortList, OS_SORT_LINK_INVALID_TIME);
|
||||
}
|
||||
@@ -566,34 +498,21 @@ LITE_OS_SEC_TEXT_INIT STATIC VOID OsTaskCBInitBase(LosTaskCB *taskCB,
|
||||
STATIC UINT32 OsTaskCBInit(LosTaskCB *taskCB, const TSK_INIT_PARAM_S *initParam,
|
||||
const VOID *stackPtr, const VOID *topStack)
|
||||
{
|
||||
UINT32 intSave;
|
||||
UINT32 ret;
|
||||
UINT32 numCount;
|
||||
UINT16 mode;
|
||||
LosProcessCB *processCB = NULL;
|
||||
|
||||
OsTaskCBInitBase(taskCB, stackPtr, topStack, initParam);
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
processCB = OS_PCB_FROM_PID(initParam->processID);
|
||||
taskCB->processID = processCB->processID;
|
||||
mode = processCB->processMode;
|
||||
LOS_ListTailInsert(&(processCB->threadSiblingList), &(taskCB->threadList));
|
||||
if (mode == OS_USER_MODE) {
|
||||
numCount = OsProcessAddNewTask(initParam->processID, taskCB);
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
taskCB->futex.index = OS_INVALID_VALUE;
|
||||
if (taskCB->taskStatus & OS_TASK_FLAG_USER_MODE) {
|
||||
taskCB->userArea = initParam->userParam.userArea;
|
||||
taskCB->userMapBase = initParam->userParam.userMapBase;
|
||||
taskCB->userMapSize = initParam->userParam.userMapSize;
|
||||
OsUserTaskStackInit(taskCB->stackPointer, (UINTPTR)taskCB->taskEntry, initParam->userParam.userSP);
|
||||
}
|
||||
|
||||
if (!processCB->threadNumber) {
|
||||
processCB->threadGroupID = taskCB->taskID;
|
||||
}
|
||||
processCB->threadNumber++;
|
||||
|
||||
numCount = processCB->threadCount;
|
||||
processCB->threadCount++;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
#endif
|
||||
|
||||
if (initParam->pcName != NULL) {
|
||||
ret = (UINT32)OsSetTaskName(taskCB, initParam->pcName, FALSE);
|
||||
@@ -688,7 +607,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreate(UINT32 *taskID, TSK_INIT_PARAM_S *in
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 intSave;
|
||||
LosTaskCB *taskCB = NULL;
|
||||
|
||||
if (initParam == NULL) {
|
||||
return LOS_ERRNO_TSK_PTR_NULL;
|
||||
@@ -708,7 +626,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskCreate(UINT32 *taskID, TSK_INIT_PARAM_S *in
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
taskCB = OS_TCB_FROM_TID(*taskID);
|
||||
|
||||
LosTaskCB *taskCB = OS_TCB_FROM_TID(*taskID);
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
OsSchedTaskEnQueue(taskCB);
|
||||
@@ -853,80 +772,79 @@ STATIC INLINE VOID OsTaskStatusUnusedSet(LosTaskCB *taskCB)
|
||||
OS_MEM_CLEAR(taskCB->taskID);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsRunTaskToDelete(LosTaskCB *runTask)
|
||||
STATIC VOID OsTaskReleaseHoldLock(LosTaskCB *taskCB)
|
||||
{
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(runTask->processID);
|
||||
LosMux *mux = NULL;
|
||||
UINT32 ret;
|
||||
|
||||
OsTaskReleaseHoldLock(processCB, runTask);
|
||||
OsTaskStatusUnusedSet(runTask);
|
||||
while (!LOS_ListEmpty(&taskCB->lockList)) {
|
||||
mux = LOS_DL_LIST_ENTRY(LOS_DL_LIST_FIRST(&taskCB->lockList), LosMux, holdList);
|
||||
ret = OsMuxUnlockUnsafe(taskCB, mux, NULL);
|
||||
if (ret != LOS_OK) {
|
||||
LOS_ListDelete(&mux->holdList);
|
||||
PRINT_ERR("mux ulock failed! : %u\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
LOS_ListDelete(&runTask->threadList);
|
||||
processCB->threadNumber--;
|
||||
LOS_ListTailInsert(&g_taskRecycleList, &runTask->pendList);
|
||||
OsEventWriteUnsafe(&g_resourceEvent, OS_RESOURCE_EVENT_FREE, FALSE, NULL);
|
||||
|
||||
OsSchedResched();
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if needs to do the delete operation on the running task.
|
||||
* Return TRUE, if needs to do the deletion.
|
||||
* Return FALSE, if meets following circumstances:
|
||||
* 1. Do the deletion across cores, if SMP is enabled
|
||||
* 2. Do the deletion when preemption is disabled
|
||||
* 3. Do the deletion in hard-irq
|
||||
* then LOS_TaskDelete will directly return with 'ret' value.
|
||||
*/
|
||||
STATIC BOOL OsRunTaskToDeleteCheckOnRun(LosTaskCB *taskCB, UINT32 *ret)
|
||||
{
|
||||
/* init default out return value */
|
||||
*ret = LOS_OK;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
/* ASYNCHRONIZED. No need to do task lock checking */
|
||||
if (taskCB->currCpu != ArchCurrCpuid()) {
|
||||
/*
|
||||
* the task is running on another cpu.
|
||||
* mask the target task with "kill" signal, and trigger mp schedule
|
||||
* which might not be essential but the deletion could more in time.
|
||||
*/
|
||||
taskCB->signal = SIGNAL_KILL;
|
||||
LOS_MpSchedule(taskCB->currCpu);
|
||||
*ret = OsTaskSyncWait(taskCB);
|
||||
return FALSE;
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
if (taskCB->taskStatus & OS_TASK_FLAG_USER_MODE) {
|
||||
OsFutexNodeDeleteFromFutexHash(&taskCB->futex, TRUE, NULL, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!OsPreemptableInSched()) {
|
||||
/* If the task is running and scheduler is locked then you can not delete it */
|
||||
*ret = LOS_ERRNO_TSK_DELETE_LOCKED;
|
||||
return FALSE;
|
||||
}
|
||||
OsTaskJoinPostUnsafe(taskCB);
|
||||
|
||||
if (OS_INT_ACTIVE) {
|
||||
/*
|
||||
* delete running task in interrupt.
|
||||
* mask "kill" signal and later deletion will be handled.
|
||||
*/
|
||||
taskCB->signal = SIGNAL_KILL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
OsTaskSyncWake(taskCB);
|
||||
}
|
||||
|
||||
STATIC VOID OsTaskDeleteInactive(LosProcessCB *processCB, LosTaskCB *taskCB)
|
||||
LITE_OS_SEC_TEXT VOID OsRunningTaskToExit(LosTaskCB *runTask, UINT32 status)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
if (OsProcessThreadGroupIDGet(runTask) == runTask->taskID) {
|
||||
OsProcessThreadGroupDestroy();
|
||||
}
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_TASK_DELETE, runTask);
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (OsProcessThreadNumberGet(runTask) == 1) { /* 1: The last task of the process exits */
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
OsTaskResourcesToFree(runTask);
|
||||
OsProcessResourcesToFree(OS_PCB_FROM_PID(runTask->processID));
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
|
||||
OsProcessNaturalExit(OS_PCB_FROM_PID(runTask->processID), status);
|
||||
OsTaskReleaseHoldLock(runTask);
|
||||
OsTaskStatusUnusedSet(runTask);
|
||||
} else if (runTask->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN) {
|
||||
OsTaskReleaseHoldLock(runTask);
|
||||
} else {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
OsTaskResourcesToFree(runTask);
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
OsInactiveTaskDelete(runTask);
|
||||
OsEventWriteUnsafe(&g_resourceEvent, OS_RESOURCE_EVENT_FREE, FALSE, NULL);
|
||||
}
|
||||
|
||||
OsSchedResched();
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsInactiveTaskDelete(LosTaskCB *taskCB)
|
||||
{
|
||||
LosMux *mux = (LosMux *)taskCB->taskMux;
|
||||
UINT16 taskStatus = taskCB->taskStatus;
|
||||
|
||||
LOS_ASSERT(!(taskStatus & OS_TASK_STATUS_RUNNING));
|
||||
|
||||
OsTaskReleaseHoldLock(processCB, taskCB);
|
||||
OsTaskReleaseHoldLock(taskCB);
|
||||
|
||||
OsSchedTaskExit(taskCB);
|
||||
if (taskStatus & OS_TASK_STATUS_PENDING) {
|
||||
LosMux *mux = (LosMux *)taskCB->taskMux;
|
||||
if (LOS_MuxIsValid(mux) == TRUE) {
|
||||
OsMuxBitmapRestore(mux, taskCB, (LosTaskCB *)mux->owner);
|
||||
}
|
||||
@@ -934,58 +852,15 @@ STATIC VOID OsTaskDeleteInactive(LosProcessCB *processCB, LosTaskCB *taskCB)
|
||||
|
||||
OsTaskStatusUnusedSet(taskCB);
|
||||
|
||||
LOS_ListDelete(&taskCB->threadList);
|
||||
processCB->threadNumber--;
|
||||
LOS_ListTailInsert(&g_taskRecycleList, &taskCB->pendList);
|
||||
return;
|
||||
}
|
||||
OsDeleteTaskFromProcess(taskCB);
|
||||
|
||||
LITE_OS_SEC_TEXT UINT32 OsTaskDeleteUnsafe(LosTaskCB *taskCB, UINT32 status, UINT32 intSave)
|
||||
{
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(taskCB->processID);
|
||||
UINT32 mode = processCB->processMode;
|
||||
UINT32 errRet = LOS_OK;
|
||||
|
||||
if (taskCB->taskStatus & OS_TASK_FLAG_SYSTEM_TASK) {
|
||||
errRet = LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK;
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
if ((taskCB->taskStatus & OS_TASK_STATUS_RUNNING) && !OsRunTaskToDeleteCheckOnRun(taskCB, &errRet)) {
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
if (!(taskCB->taskStatus & OS_TASK_STATUS_RUNNING)) {
|
||||
OsTaskDeleteInactive(processCB, taskCB);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
OsWriteResourceEvent(OS_RESOURCE_EVENT_FREE);
|
||||
return errRet;
|
||||
}
|
||||
OsHookCall(LOS_HOOK_TYPE_TASK_DELETE, taskCB);
|
||||
if (mode == OS_USER_MODE) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
OsTaskResourcesToFree(taskCB);
|
||||
SCHEDULER_LOCK(intSave);
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
LOS_ASSERT(OsPercpuGet()->taskLockCnt == 1);
|
||||
#else
|
||||
LOS_ASSERT(OsPercpuGet()->taskLockCnt == 0);
|
||||
#endif
|
||||
OsRunTaskToDelete(taskCB);
|
||||
|
||||
EXIT:
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return errRet;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDelete(UINT32 taskID)
|
||||
{
|
||||
UINT32 intSave;
|
||||
UINT32 ret;
|
||||
LosTaskCB *taskCB = NULL;
|
||||
LosProcessCB *processCB = NULL;
|
||||
UINT32 ret = LOS_OK;
|
||||
|
||||
if (OS_TID_CHECK_INVALID(taskID)) {
|
||||
return LOS_ERRNO_TSK_ID_INVALID;
|
||||
@@ -995,32 +870,33 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskDelete(UINT32 taskID)
|
||||
return LOS_ERRNO_TSK_YIELD_IN_INT;
|
||||
}
|
||||
|
||||
taskCB = OS_TCB_FROM_TID(taskID);
|
||||
LosTaskCB *taskCB = OS_TCB_FROM_TID(taskID);
|
||||
if (taskCB == OsCurrTaskGet()) {
|
||||
OsRunningTaskToExit(taskCB, OS_PRO_EXIT_OK);
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
|
||||
ret = LOS_ERRNO_TSK_NOT_CREATED;
|
||||
OS_GOTO_ERREND();
|
||||
}
|
||||
|
||||
if (taskCB->taskStatus & (OS_TASK_FLAG_SYSTEM_TASK | OS_TASK_FLAG_NO_DELETE)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
OsBackTrace();
|
||||
return LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK;
|
||||
}
|
||||
|
||||
processCB = OS_PCB_FROM_PID(taskCB->processID);
|
||||
if (processCB->threadNumber == 1) { /* 1: The last task of the process exits */
|
||||
if (processCB == OsCurrProcessGet()) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
OsProcessExit(taskCB, OS_PRO_EXIT_OK);
|
||||
return LOS_OK;
|
||||
if (taskCB->taskStatus & (OS_TASK_STATUS_UNUSED | OS_TASK_FLAG_SYSTEM_TASK | OS_TASK_FLAG_NO_DELETE)) {
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
|
||||
ret = LOS_ERRNO_TSK_NOT_CREATED;
|
||||
} else {
|
||||
ret = LOS_ERRNO_TSK_OPERATE_SYSTEM_TASK;
|
||||
}
|
||||
|
||||
ret = LOS_ERRNO_TSK_ID_INVALID;
|
||||
OS_GOTO_ERREND();
|
||||
}
|
||||
|
||||
return OsTaskDeleteUnsafe(taskCB, OS_PRO_EXIT_OK, intSave);
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
|
||||
taskCB->signal = SIGNAL_KILL;
|
||||
LOS_MpSchedule(taskCB->currCpu);
|
||||
ret = OsTaskSyncWait(taskCB);
|
||||
OS_GOTO_ERREND();
|
||||
}
|
||||
#endif
|
||||
|
||||
OsInactiveTaskDelete(taskCB);
|
||||
OsEventWriteUnsafe(&g_resourceEvent, OS_RESOURCE_EVENT_FREE, FALSE, NULL);
|
||||
|
||||
LOS_ERREND:
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
@@ -1149,13 +1025,21 @@ LITE_OS_SEC_TEXT_MINOR VOID LOS_TaskLock(VOID)
|
||||
UINT32 intSave;
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
OsCpuSchedLock(OsPercpuGet());
|
||||
OsSchedLock();
|
||||
LOS_IntRestore(intSave);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR VOID LOS_TaskUnlock(VOID)
|
||||
{
|
||||
OsCpuSchedUnlock(OsPercpuGet(), LOS_IntLock());
|
||||
UINT32 intSave;
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
BOOL needSched = OsSchedUnlockResch();
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
if (needSched) {
|
||||
LOS_Schedule();
|
||||
}
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskInfoGet(UINT32 taskID, TSK_INFO_S *taskInfo)
|
||||
@@ -1293,7 +1177,7 @@ LITE_OS_SEC_TEXT_MINOR UINT16 LOS_TaskCpuAffiGet(UINT32 taskID)
|
||||
*/
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsTaskProcSignal(VOID)
|
||||
{
|
||||
UINT32 intSave, ret;
|
||||
UINT32 ret;
|
||||
|
||||
/*
|
||||
* private and uninterruptable, no protection needed.
|
||||
@@ -1310,10 +1194,9 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTaskProcSignal(VOID)
|
||||
* clear the signal, and do the task deletion. if the signaled task has been
|
||||
* scheduled out, then this deletion will wait until next run.
|
||||
*/
|
||||
SCHEDULER_LOCK(intSave);
|
||||
runTask->signal = SIGNAL_NONE;
|
||||
ret = OsTaskDeleteUnsafe(runTask, OS_PRO_EXIT_OK, intSave);
|
||||
if (ret) {
|
||||
ret = LOS_TaskDelete(runTask->taskID);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("Task proc signal delete task(%u) failed err:0x%x\n", runTask->taskID, ret);
|
||||
}
|
||||
} else if (runTask->signal & SIGNAL_SUSPEND) {
|
||||
@@ -1335,7 +1218,6 @@ LITE_OS_SEC_TEXT INT32 OsSetTaskName(LosTaskCB *taskCB, const CHAR *name, BOOL s
|
||||
{
|
||||
UINT32 intSave;
|
||||
errno_t err;
|
||||
LosProcessCB *processCB = NULL;
|
||||
const CHAR *namePtr = NULL;
|
||||
CHAR nameBuff[OS_TCB_NAME_LEN] = { 0 };
|
||||
|
||||
@@ -1362,10 +1244,9 @@ LITE_OS_SEC_TEXT INT32 OsSetTaskName(LosTaskCB *taskCB, const CHAR *name, BOOL s
|
||||
}
|
||||
|
||||
err = LOS_OK;
|
||||
processCB = OS_PCB_FROM_PID(taskCB->processID);
|
||||
/* if thread is main thread, then set processName as taskName */
|
||||
if ((taskCB->taskID == processCB->threadGroupID) && (setPName == TRUE)) {
|
||||
err = (INT32)OsSetProcessName(processCB, (const CHAR *)taskCB->taskName);
|
||||
if ((taskCB->taskID == OsProcessThreadGroupIDGet(taskCB)) && (setPName == TRUE)) {
|
||||
err = (INT32)OsSetProcessName(OS_PCB_FROM_PID(taskCB->processID), (const CHAR *)taskCB->taskName);
|
||||
if (err != LOS_OK) {
|
||||
err = EINVAL;
|
||||
}
|
||||
@@ -1376,85 +1257,6 @@ EXIT:
|
||||
return err;
|
||||
}
|
||||
|
||||
STATIC VOID OsExitGroupActiveTaskKilled(LosProcessCB *processCB, LosTaskCB *taskCB)
|
||||
{
|
||||
INT32 ret;
|
||||
|
||||
taskCB->taskStatus |= OS_TASK_FLAG_EXIT_KILL;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
/* The other core that the thread is running on and is currently running in a non-system call */
|
||||
if (!taskCB->sig.sigIntLock && (taskCB->taskStatus & OS_TASK_STATUS_RUNNING)) {
|
||||
taskCB->signal = SIGNAL_KILL;
|
||||
LOS_MpSchedule(taskCB->currCpu);
|
||||
} else
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
{
|
||||
ret = OsTaskKillUnsafe(taskCB->taskID, SIGKILL);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("pid %u exit, Exit task group %u kill %u failed! ERROR: %d\n",
|
||||
taskCB->processID, OsCurrTaskGet()->taskID, taskCB->taskID, ret);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!(taskCB->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN)) {
|
||||
taskCB->taskStatus |= OS_TASK_FLAG_PTHREAD_JOIN;
|
||||
LOS_ListInit(&taskCB->joinList);
|
||||
}
|
||||
|
||||
ret = OsTaskJoinPendUnsafe(taskCB);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("pid %u exit, Exit task group %u to wait others task %u(0x%x) exit failed! ERROR: %d\n",
|
||||
taskCB->processID, OsCurrTaskGet()->taskID, taskCB->taskID, taskCB->taskStatus, ret);
|
||||
}
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsTaskExitGroup(UINT32 status)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
LosProcessCB *processCB = OsCurrProcessGet();
|
||||
LosTaskCB *currTask = OsCurrTaskGet();
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if ((processCB->processStatus & OS_PROCESS_FLAG_EXIT) || !OsProcessIsUserMode(processCB)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return;
|
||||
}
|
||||
|
||||
processCB->processStatus |= OS_PROCESS_FLAG_EXIT;
|
||||
processCB->threadGroupID = currTask->taskID;
|
||||
|
||||
LOS_DL_LIST *list = &processCB->threadSiblingList;
|
||||
LOS_DL_LIST *head = list;
|
||||
do {
|
||||
LosTaskCB *taskCB = LOS_DL_LIST_ENTRY(list->pstNext, LosTaskCB, threadList);
|
||||
if ((taskCB->taskStatus & (OS_TASK_STATUS_INIT | OS_TASK_STATUS_EXIT) ||
|
||||
((taskCB->taskStatus & OS_TASK_STATUS_READY) && !taskCB->sig.sigIntLock)) &&
|
||||
!(taskCB->taskStatus & OS_TASK_STATUS_RUNNING)) {
|
||||
OsTaskDeleteInactive(processCB, taskCB);
|
||||
} else {
|
||||
if (taskCB != currTask) {
|
||||
OsExitGroupActiveTaskKilled(processCB, taskCB);
|
||||
} else {
|
||||
/* Skip the current task */
|
||||
list = list->pstNext;
|
||||
}
|
||||
}
|
||||
} while (head != list->pstNext);
|
||||
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
LOS_ASSERT(processCB->threadNumber == 1);
|
||||
return;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT VOID OsExecDestroyTaskGroup(VOID)
|
||||
{
|
||||
OsTaskExitGroup(OS_PRO_EXIT_OK);
|
||||
OsTaskCBRecycleToFree();
|
||||
}
|
||||
|
||||
UINT32 OsUserTaskOperatePermissionsCheck(LosTaskCB *taskCB)
|
||||
{
|
||||
return OsUserProcessOperatePermissionsCheck(taskCB, OsCurrProcessGet()->processID);
|
||||
@@ -1511,7 +1313,6 @@ LITE_OS_SEC_TEXT_INIT STATIC UINT32 OsCreateUserTaskParamCheck(UINT32 processID,
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 OsCreateUserTask(UINT32 processID, TSK_INIT_PARAM_S *initParam)
|
||||
{
|
||||
LosProcessCB *processCB = NULL;
|
||||
UINT32 taskID;
|
||||
UINT32 ret;
|
||||
UINT32 intSave;
|
||||
@@ -1526,15 +1327,11 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCreateUserTask(UINT32 processID, TSK_INIT_PARAM_S
|
||||
initParam->policy = LOS_SCHED_RR;
|
||||
if (processID == OS_INVALID_VALUE) {
|
||||
SCHEDULER_LOCK(intSave);
|
||||
processCB = OsCurrProcessGet();
|
||||
LosProcessCB *processCB = OsCurrProcessGet();
|
||||
initParam->processID = processCB->processID;
|
||||
initParam->consoleID = processCB->consoleID;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
} else {
|
||||
processCB = OS_PCB_FROM_PID(processID);
|
||||
if (!(processCB->processStatus & (OS_PROCESS_STATUS_INIT | OS_PROCESS_STATUS_RUNNING))) {
|
||||
return OS_INVALID_VALUE;
|
||||
}
|
||||
initParam->processID = processID;
|
||||
initParam->consoleID = 0;
|
||||
}
|
||||
|
||||
@@ -34,8 +34,6 @@
|
||||
|
||||
#include "los_base.h"
|
||||
#include "los_hw_cpu.h"
|
||||
#include "los_spinlock.h"
|
||||
#include "los_sortlink_pri.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -49,29 +47,11 @@ typedef enum {
|
||||
CPU_HALT, /* cpu in the halt */
|
||||
CPU_EXC /* cpu in the exc */
|
||||
} ExcFlag;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
SortLinkAttribute taskSortLink; /* task sort link */
|
||||
SPIN_LOCK_S taskSortLinkSpin; /* task sort link spin lock */
|
||||
SortLinkAttribute swtmrSortLink; /* swtmr sort link */
|
||||
SPIN_LOCK_S swtmrSortLinkSpin; /* swtmr sort link spin lock */
|
||||
UINT64 responseTime; /* Response time for current CPU tick interrupts */
|
||||
UINT64 tickStartTime; /* The time when the tick interrupt starts processing */
|
||||
UINT32 responseID; /* The response ID of the current CPU tick interrupt */
|
||||
UINTPTR runProcess; /* The address of the process control block pointer to which
|
||||
the current CPU is running */
|
||||
UINT32 idleTaskID; /* idle task id */
|
||||
UINT32 taskLockCnt; /* task lock flag */
|
||||
UINT32 swtmrHandlerQueue; /* software timer timeout queue id */
|
||||
UINT32 swtmrTaskID; /* software timer task id */
|
||||
|
||||
UINT32 schedFlag; /* pending scheduler flag */
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
UINT32 excFlag; /* cpu halt or exc flag */
|
||||
UINT32 excFlag; /* cpu halt or exc flag */
|
||||
#ifdef LOSCFG_KERNEL_SMP_CALL
|
||||
LOS_DL_LIST funcLink; /* mp function call link */
|
||||
#endif
|
||||
LOS_DL_LIST funcLink; /* mp function call link */
|
||||
#endif
|
||||
} Percpu;
|
||||
|
||||
@@ -88,6 +68,19 @@ STATIC INLINE Percpu *OsPercpuGetByID(UINT32 cpuid)
|
||||
return &g_percpu[cpuid];
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 OsCpuStatusIsHalt(UINT16 cpuid)
|
||||
{
|
||||
return (OsPercpuGetByID(cpuid)->excFlag == CPU_HALT);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsCpuStatusSet(ExcFlag flag)
|
||||
{
|
||||
OsPercpuGet()->excFlag = flag;
|
||||
}
|
||||
|
||||
VOID OsAllCpuStatusOutput(VOID);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -80,10 +80,8 @@ typedef struct ProcessCB {
|
||||
UINT32 processID; /**< Process ID */
|
||||
UINT16 processStatus; /**< [15:4] Process Status; [3:0] The number of threads currently
|
||||
running in the process */
|
||||
UINT16 priority; /**< Process priority */
|
||||
UINT16 consoleID; /**< The console id of task belongs */
|
||||
UINT16 processMode; /**< Kernel Mode:0; User Mode:1; */
|
||||
UINT16 readyTaskNum; /**< The number of ready tasks in the current process */
|
||||
UINT32 parentProcessID; /**< Parent process ID */
|
||||
UINT32 exitCode; /**< Process exit status */
|
||||
LOS_DL_LIST pendList; /**< Block list to which the process belongs */
|
||||
@@ -149,7 +147,7 @@ typedef struct ProcessCB {
|
||||
*
|
||||
* The process is created but does not participate in scheduling.
|
||||
*/
|
||||
#define OS_PROCESS_STATUS_INIT 0x0010U
|
||||
#define OS_PROCESS_STATUS_INIT OS_TASK_STATUS_INIT
|
||||
|
||||
/**
|
||||
* @ingroup los_process
|
||||
@@ -157,7 +155,7 @@ typedef struct ProcessCB {
|
||||
*
|
||||
* The process is ready.
|
||||
*/
|
||||
#define OS_PROCESS_STATUS_READY 0x0020U
|
||||
#define OS_PROCESS_STATUS_READY OS_TASK_STATUS_READY
|
||||
|
||||
/**
|
||||
* @ingroup los_process
|
||||
@@ -165,7 +163,7 @@ typedef struct ProcessCB {
|
||||
*
|
||||
* The process is running.
|
||||
*/
|
||||
#define OS_PROCESS_STATUS_RUNNING 0x0040U
|
||||
#define OS_PROCESS_STATUS_RUNNING OS_TASK_STATUS_RUNNING
|
||||
|
||||
/**
|
||||
* @ingroup los_process
|
||||
@@ -173,7 +171,7 @@ typedef struct ProcessCB {
|
||||
*
|
||||
* The process is pending
|
||||
*/
|
||||
#define OS_PROCESS_STATUS_PENDING 0x0080U
|
||||
#define OS_PROCESS_STATUS_PENDING (OS_TASK_STATUS_PENDING | OS_TASK_STATUS_DELAY | OS_TASK_STATUS_SUSPENDED)
|
||||
|
||||
/**
|
||||
* @ingroup los_process
|
||||
@@ -181,23 +179,7 @@ typedef struct ProcessCB {
|
||||
*
|
||||
* The process is run out but the resources occupied by the process are not recovered.
|
||||
*/
|
||||
#define OS_PROCESS_STATUS_ZOMBIES 0x100U
|
||||
|
||||
/**
|
||||
* @ingroup los_process
|
||||
* Flag that indicates the process or process control block status.
|
||||
*
|
||||
* The number of task currently running under the process, it only works with multiple cores.
|
||||
*/
|
||||
#define OS_PROCESS_RUNTASK_COUNT_MASK 0x000FU
|
||||
|
||||
/**
|
||||
* @ingroup los_process
|
||||
* Flag that indicates the process or process control block status.
|
||||
*
|
||||
* The process status mask.
|
||||
*/
|
||||
#define OS_PROCESS_STATUS_MASK 0xFFF0U
|
||||
#define OS_PROCESS_STATUS_ZOMBIES 0x0100U
|
||||
|
||||
/**
|
||||
* @ingroup los_process
|
||||
@@ -267,6 +249,11 @@ STATIC INLINE BOOL OsProcessIsDead(const LosProcessCB *processCB)
|
||||
return ((processCB->processStatus & (OS_PROCESS_FLAG_UNUSED | OS_PROCESS_STATUS_ZOMBIES)) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsProcessIsInit(const LosProcessCB *processCB)
|
||||
{
|
||||
return (processCB->processStatus & OS_PROCESS_STATUS_INIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_process
|
||||
* The highest priority of a kernel mode process.
|
||||
@@ -297,13 +284,6 @@ STATIC INLINE BOOL OsProcessIsDead(const LosProcessCB *processCB)
|
||||
*/
|
||||
#define OS_PROCESS_USERINIT_PRIORITY 28
|
||||
|
||||
#define OS_GET_PROCESS_STATUS(status) ((UINT16)((UINT16)(status) & OS_PROCESS_STATUS_MASK))
|
||||
#define OS_PROCESS_GET_RUNTASK_COUNT(status) ((UINT16)(((UINT16)(status)) & OS_PROCESS_RUNTASK_COUNT_MASK))
|
||||
#define OS_PROCESS_RUNTASK_COUNT_ADD(status) ((UINT16)(((UINT16)(status)) & OS_PROCESS_STATUS_MASK) | \
|
||||
((OS_PROCESS_GET_RUNTASK_COUNT(status) + 1) & OS_PROCESS_RUNTASK_COUNT_MASK))
|
||||
#define OS_PROCESS_RUNTASK_COUNT_DEC(status) ((UINT16)(((UINT16)(status)) & OS_PROCESS_STATUS_MASK) | \
|
||||
((OS_PROCESS_GET_RUNTASK_COUNT(status) - 1) & OS_PROCESS_RUNTASK_COUNT_MASK))
|
||||
|
||||
#define OS_TASK_DEFAULT_STACK_SIZE 0x2000
|
||||
#define OS_USER_TASK_SYSCALL_STACK_SIZE 0x3000
|
||||
#define OS_USER_TASK_STACK_SIZE 0x100000
|
||||
@@ -374,16 +354,11 @@ STATIC INLINE LosProcessCB *OsCurrProcessGet(VOID)
|
||||
UINT32 intSave;
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
LosProcessCB *runProcess = (LosProcessCB *)OsPercpuGet()->runProcess;
|
||||
LosProcessCB *runProcess = OS_PCB_FROM_PID(OsCurrTaskGet()->processID);
|
||||
LOS_IntRestore(intSave);
|
||||
return runProcess;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsCurrProcessSet(const LosProcessCB *process)
|
||||
{
|
||||
OsPercpuGet()->runProcess = (UINTPTR)process;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_SECURITY_CAPABILITY
|
||||
STATIC INLINE User *OsCurrUserGet(VOID)
|
||||
{
|
||||
@@ -395,8 +370,44 @@ STATIC INLINE User *OsCurrUserGet(VOID)
|
||||
LOS_IntRestore(intSave);
|
||||
return user;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 OsProcessUserIDGet(const LosTaskCB *taskCB)
|
||||
{
|
||||
UINT32 intSave = LOS_IntLock();
|
||||
UINT32 uid = OS_INVALID;
|
||||
|
||||
LosProcessCB *process = OS_PCB_FROM_PID(taskCB->processID);
|
||||
if (process->user != NULL) {
|
||||
uid = process->user->userID;
|
||||
}
|
||||
LOS_IntRestore(intSave);
|
||||
return uid;
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC INLINE UINT32 OsProcessThreadGroupIDGet(const LosTaskCB *taskCB)
|
||||
{
|
||||
return OS_PCB_FROM_PID(taskCB->processID)->threadGroupID;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 OsProcessThreadNumberGet(const LosTaskCB *taskCB)
|
||||
{
|
||||
return OS_PCB_FROM_PID(taskCB->processID)->threadNumber;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
STATIC INLINE LosVmSpace *OsProcessVmSpaceGet(const LosProcessCB *processCB)
|
||||
{
|
||||
return processCB->vmSpace;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_DRIVERS_TZDRIVER
|
||||
STATIC INLINE struct Vnode *OsProcessExecVnodeGet(const LosProcessCB *processCB)
|
||||
{
|
||||
return processCB->execVnode;
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* return immediately if no child has exited.
|
||||
*/
|
||||
@@ -455,15 +466,14 @@ extern UINTPTR __user_init_bss;
|
||||
extern UINTPTR __user_init_end;
|
||||
extern UINTPTR __user_init_load_addr;
|
||||
extern UINT32 OsSystemProcessCreate(VOID);
|
||||
extern VOID OsProcessNaturalExit(LosProcessCB *processCB, UINT32 status);
|
||||
extern VOID OsProcessCBRecycleToFree(VOID);
|
||||
extern VOID OsProcessResourcesToFree(LosProcessCB *processCB);
|
||||
extern VOID OsProcessExit(LosTaskCB *runTask, INT32 status);
|
||||
extern UINT32 OsUserInitProcess(VOID);
|
||||
extern VOID OsTaskSchedQueueDequeue(LosTaskCB *taskCB, UINT16 status);
|
||||
extern VOID OsTaskSchedQueueEnqueue(LosTaskCB *taskCB, UINT16 status);
|
||||
extern INT32 OsClone(UINT32 flags, UINTPTR sp, UINT32 size);
|
||||
extern UINT32 OsExecRecycleAndInit(LosProcessCB *processCB, const CHAR *name,
|
||||
LosVmSpace *oldAspace, UINTPTR oldFiles);
|
||||
extern VOID OsExecProcessVmSpaceRestore(LosVmSpace *oldSpace);
|
||||
extern LosVmSpace *OsExecProcessVmSpaceReplace(LosVmSpace *newSpace, UINTPTR stackBase, INT32 randomDevFD);
|
||||
extern UINT32 OsExecRecycleAndInit(LosProcessCB *processCB, const CHAR *name, LosVmSpace *oldAspace, UINTPTR oldFiles);
|
||||
extern UINT32 OsExecStart(const TSK_ENTRY_FUNC entry, UINTPTR sp, UINTPTR mapBase, UINT32 mapSize);
|
||||
extern UINT32 OsSetProcessName(LosProcessCB *processCB, const CHAR *name);
|
||||
extern INT32 OsSetProcessScheduler(INT32 which, INT32 pid, UINT16 prio, UINT16 policy);
|
||||
@@ -478,6 +488,9 @@ extern UINTPTR OsGetSigHandler(VOID);
|
||||
extern VOID OsWaitWakeTask(LosTaskCB *taskCB, UINT32 wakePID);
|
||||
extern INT32 OsSendSignalToProcessGroup(INT32 pid, siginfo_t *info, INT32 permission);
|
||||
extern INT32 OsSendSignalToAllProcess(siginfo_t *info, INT32 permission);
|
||||
extern UINT32 OsProcessAddNewTask(UINT32 pid, LosTaskCB *taskCB);
|
||||
extern VOID OsDeleteTaskFromProcess(LosTaskCB *taskCB);
|
||||
extern VOID OsProcessThreadGroupDestroy(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -32,12 +32,22 @@
|
||||
#ifndef _LOS_SCHED_PRI_H
|
||||
#define _LOS_SCHED_PRI_H
|
||||
|
||||
#include "los_percpu_pri.h"
|
||||
#include "los_task_pri.h"
|
||||
#include "los_sortlink_pri.h"
|
||||
#include "los_sys_pri.h"
|
||||
#include "los_process_pri.h"
|
||||
#include "los_hwi.h"
|
||||
#include "hal_timer.h"
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
#include "los_stat_pri.h"
|
||||
#endif
|
||||
#include "los_stackinfo_pri.h"
|
||||
#include "los_futex_pri.h"
|
||||
#include "los_signal.h"
|
||||
#ifdef LOSCFG_KERNEL_CPUP
|
||||
#include "los_cpup_pri.h"
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_LITEIPC
|
||||
#include "hm_liteipc.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -50,17 +60,412 @@ extern "C" {
|
||||
#define OS_SCHED_MAX_RESPONSE_TIME (UINT64)(((UINT64)-1) - 1U)
|
||||
|
||||
extern UINT32 g_taskScheduled;
|
||||
typedef BOOL (*SchedScan)(VOID);
|
||||
#define OS_SCHEDULER_ACTIVE (g_taskScheduled & (1U << ArchCurrCpuid()))
|
||||
#define OS_SCHEDULER_ALL_ACTIVE (g_taskScheduled == LOSCFG_KERNEL_CPU_MASK)
|
||||
|
||||
extern UINT64 g_sysSchedStartTime;
|
||||
typedef BOOL (*SCHED_TL_FIND_FUNC)(UINTPTR, UINTPTR);
|
||||
|
||||
STATIC INLINE UINT64 OsGetCurrSchedTimeCycle(VOID)
|
||||
{
|
||||
if (g_sysSchedStartTime != OS_64BIT_MAX) {
|
||||
return (HalClockGetCycles() - g_sysSchedStartTime);
|
||||
return HalClockGetCycles();
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
INT_NO_RESCH = 0x0, /* no needs to schedule */
|
||||
INT_PEND_RESCH = 0x1, /* pending schedule flag */
|
||||
INT_PEND_TICK = 0x2, /* pending tick */
|
||||
} SchedFlag;
|
||||
|
||||
typedef struct {
|
||||
SortLinkAttribute taskSortLink; /* task sort link */
|
||||
SortLinkAttribute swtmrSortLink; /* swtmr sort link */
|
||||
UINT64 responseTime; /* Response time for current CPU tick interrupts */
|
||||
UINT32 responseID; /* The response ID of the current CPU tick interrupt */
|
||||
UINT32 idleTaskID; /* idle task id */
|
||||
UINT32 taskLockCnt; /* task lock flag */
|
||||
UINT32 swtmrTaskID; /* software timer task id */
|
||||
UINT32 swtmrHandlerQueue; /* software timer timeout queue id */
|
||||
UINT32 schedFlag; /* pending scheduler flag */
|
||||
} SchedRunQue;
|
||||
|
||||
extern SchedRunQue g_schedRunQue[LOSCFG_KERNEL_CORE_NUM];
|
||||
|
||||
STATIC INLINE SchedRunQue *OsSchedRunQue(VOID)
|
||||
{
|
||||
return &g_schedRunQue[ArchCurrCpuid()];
|
||||
}
|
||||
|
||||
STATIC INLINE SchedRunQue *OsSchedRunQueByID(UINT16 id)
|
||||
{
|
||||
return &g_schedRunQue[id];
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 OsSchedLockCountGet(VOID)
|
||||
{
|
||||
return OsSchedRunQue()->taskLockCnt;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedLockSet(UINT32 count)
|
||||
{
|
||||
OsSchedRunQue()->taskLockCnt = count;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedLock(VOID)
|
||||
{
|
||||
OsSchedRunQue()->taskLockCnt++;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedUnlock(VOID)
|
||||
{
|
||||
OsSchedRunQue()->taskLockCnt--;
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsSchedUnlockResch(VOID)
|
||||
{
|
||||
SchedRunQue *rq = OsSchedRunQue();
|
||||
if (rq->taskLockCnt > 0) {
|
||||
rq->taskLockCnt--;
|
||||
if ((rq->taskLockCnt == 0) && (rq->schedFlag & INT_PEND_RESCH) && OS_SCHEDULER_ACTIVE) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsSchedIsLock(VOID)
|
||||
{
|
||||
return (OsSchedRunQue()->taskLockCnt != 0);
|
||||
}
|
||||
|
||||
/* Check if preemptable with counter flag */
|
||||
STATIC INLINE BOOL OsPreemptable(VOID)
|
||||
{
|
||||
SchedRunQue *rq = OsSchedRunQue();
|
||||
/*
|
||||
* Unlike OsPreemptableInSched, the int may be not disabled when OsPreemptable
|
||||
* is called, needs mannually disable interrupt, to prevent current task from
|
||||
* being migrated to another core, and get the wrong preeptable status.
|
||||
*/
|
||||
UINT32 intSave = LOS_IntLock();
|
||||
BOOL preemptable = (rq->taskLockCnt == 0);
|
||||
if (!preemptable) {
|
||||
/* Set schedule flag if preemption is disabled */
|
||||
rq->schedFlag |= INT_PEND_RESCH;
|
||||
}
|
||||
LOS_IntRestore(intSave);
|
||||
return preemptable;
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsPreemptableInSched(VOID)
|
||||
{
|
||||
BOOL preemptable = FALSE;
|
||||
SchedRunQue *rq = OsSchedRunQue();
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
/*
|
||||
* For smp systems, schedule must hold the task spinlock, and this counter
|
||||
* will increase by 1 in that case.
|
||||
*/
|
||||
preemptable = (rq->taskLockCnt == 1);
|
||||
|
||||
#else
|
||||
preemptable = (rq->taskLockCnt == 0);
|
||||
#endif
|
||||
if (!preemptable) {
|
||||
/* Set schedule flag if preemption is disabled */
|
||||
rq->schedFlag |= INT_PEND_RESCH;
|
||||
}
|
||||
|
||||
return preemptable;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 OsSchedGetRunQueIdle(VOID)
|
||||
{
|
||||
return OsSchedRunQue()->idleTaskID;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedRunQuePendingSet(VOID)
|
||||
{
|
||||
OsSchedRunQue()->schedFlag |= INT_PEND_RESCH;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
STATIC INLINE VOID FindIdleRunQue(UINT16 *idleCpuID)
|
||||
{
|
||||
SchedRunQue *idleRq = OsSchedRunQueByID(0);
|
||||
UINT32 nodeNum = OsGetSortLinkNodeNum(&idleRq->taskSortLink) + OsGetSortLinkNodeNum(&idleRq->swtmrSortLink);
|
||||
UINT16 cpuID = 1;
|
||||
do {
|
||||
SchedRunQue *rq = OsSchedRunQueByID(cpuID);
|
||||
UINT32 temp = OsGetSortLinkNodeNum(&rq->taskSortLink) + OsGetSortLinkNodeNum(&rq->swtmrSortLink);
|
||||
if (nodeNum > temp) {
|
||||
*idleCpuID = cpuID;
|
||||
nodeNum = temp;
|
||||
}
|
||||
cpuID++;
|
||||
} while (cpuID < LOSCFG_KERNEL_CORE_NUM);
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC INLINE VOID OsSchedAddTask2TimeList(SortLinkList *node, UINT64 startTime, UINT32 waitTicks)
|
||||
{
|
||||
UINT16 idleCpu = 0;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
FindIdleRunQue(&idleCpu);
|
||||
#endif
|
||||
SchedRunQue *rq = OsSchedRunQueByID(idleCpu);
|
||||
UINT64 responseTime = startTime + (UINT64)waitTicks * OS_CYCLE_PER_TICK;
|
||||
OsAdd2SortLink(&rq->taskSortLink, node, responseTime, idleCpu);
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 OsSchedSwtmrHandlerQueueGet(VOID)
|
||||
{
|
||||
return OsSchedRunQue()->swtmrHandlerQueue;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedDeTaskFromTimeList(SortLinkList *node)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
SchedRunQue *rq = OsSchedRunQueByID(node->cpuid);
|
||||
#else
|
||||
SchedRunQue *rq = OsSchedRunQueByID(0);
|
||||
#endif
|
||||
OsDeleteFromSortLink(&rq->taskSortLink, node);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedAddSwtmr2TimeList(SortLinkList *node, UINT64 startTime, UINT32 waitTicks)
|
||||
{
|
||||
UINT16 idleCpu = 0;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
FindIdleRunQue(&idleCpu);
|
||||
#endif
|
||||
SchedRunQue *rq = OsSchedRunQueByID(idleCpu);
|
||||
UINT64 responseTime = startTime + (UINT64)waitTicks * OS_CYCLE_PER_TICK;
|
||||
OsAdd2SortLink(&rq->swtmrSortLink, node, responseTime, idleCpu);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedDeSwtmrFromTimeList(SortLinkList *node)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
SchedRunQue *rq = OsSchedRunQueByID(node->cpuid);
|
||||
#else
|
||||
SchedRunQue *rq = OsSchedRunQueByID(0);
|
||||
#endif
|
||||
OsDeleteFromSortLink(&rq->swtmrSortLink, node);
|
||||
}
|
||||
|
||||
VOID OsSchedRunQueIdleInit(UINT32 idleTaskID);
|
||||
VOID OsSchedRunQueSwtmrInit(UINT32 swtmrTaskID, UINT32 swtmrQueue);
|
||||
VOID OsSchedRunQueInit(VOID);
|
||||
BOOL OsSchedSwtmrTimeListFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg);
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Define a usable task priority.
|
||||
*
|
||||
* Highest task priority.
|
||||
*/
|
||||
#define OS_TASK_PRIORITY_HIGHEST 0
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Define a usable task priority.
|
||||
*
|
||||
* Lowest task priority.
|
||||
*/
|
||||
#define OS_TASK_PRIORITY_LOWEST 31
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is init.
|
||||
*/
|
||||
#define OS_TASK_STATUS_INIT 0x0001U
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is ready.
|
||||
*/
|
||||
#define OS_TASK_STATUS_READY 0x0002U
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is running.
|
||||
*/
|
||||
#define OS_TASK_STATUS_RUNNING 0x0004U
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is suspended.
|
||||
*/
|
||||
#define OS_TASK_STATUS_SUSPENDED 0x0008U
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is blocked.
|
||||
*/
|
||||
#define OS_TASK_STATUS_PENDING 0x0010U
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is delayed.
|
||||
*/
|
||||
#define OS_TASK_STATUS_DELAY 0x0020U
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The time for waiting for an event to occur expires.
|
||||
*/
|
||||
#define OS_TASK_STATUS_TIMEOUT 0x0040U
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is pend for a period of time.
|
||||
*/
|
||||
#define OS_TASK_STATUS_PEND_TIME 0x0080U
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is exit.
|
||||
*/
|
||||
#define OS_TASK_STATUS_EXIT 0x0100U
|
||||
|
||||
#define OS_TCB_NAME_LEN 32
|
||||
|
||||
typedef struct {
|
||||
VOID *stackPointer; /**< Task stack pointer */
|
||||
UINT16 taskStatus; /**< Task status */
|
||||
|
||||
/* The scheduling */
|
||||
UINT16 basePrio;
|
||||
UINT16 priority; /**< Task priority */
|
||||
UINT16 policy;
|
||||
UINT64 startTime; /**< The start time of each phase of task */
|
||||
UINT64 irqStartTime; /**< Interrupt start time */
|
||||
UINT32 irqUsedTime; /**< Interrupt consumption time */
|
||||
UINT32 initTimeSlice; /**< Task init time slice */
|
||||
INT32 timeSlice; /**< Task remaining time slice */
|
||||
UINT32 waitTimes; /**< Task delay time, tick number */
|
||||
SortLinkList sortList; /**< Task sortlink node */
|
||||
|
||||
UINT32 stackSize; /**< Task stack size */
|
||||
UINTPTR topOfStack; /**< Task stack top */
|
||||
UINT32 taskID; /**< Task ID */
|
||||
TSK_ENTRY_FUNC taskEntry; /**< Task entrance function */
|
||||
VOID *joinRetval; /**< pthread adaption */
|
||||
VOID *taskMux; /**< Task-held mutex */
|
||||
VOID *taskEvent; /**< Task-held event */
|
||||
UINTPTR args[4]; /**< Parameter, of which the maximum number is 4 */
|
||||
CHAR taskName[OS_TCB_NAME_LEN]; /**< Task name */
|
||||
LOS_DL_LIST pendList; /**< Task pend node */
|
||||
LOS_DL_LIST threadList; /**< thread list */
|
||||
UINT32 eventMask; /**< Event mask */
|
||||
UINT32 eventMode; /**< Event mode */
|
||||
UINT32 priBitMap; /**< BitMap for recording the change of task priority,
|
||||
the priority can not be greater than 31 */
|
||||
#ifdef LOSCFG_KERNEL_CPUP
|
||||
OsCpupBase taskCpup; /**< task cpu usage */
|
||||
#endif
|
||||
INT32 errorNo; /**< Error Num */
|
||||
UINT32 signal; /**< Task signal */
|
||||
sig_cb sig;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
UINT16 currCpu; /**< CPU core number of this task is running on */
|
||||
UINT16 lastCpu; /**< CPU core number of this task is running on last time */
|
||||
UINT16 cpuAffiMask; /**< CPU affinity mask, support up to 16 cores */
|
||||
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
|
||||
UINT32 syncSignal; /**< Synchronization for signal handling */
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_SMP_LOCKDEP
|
||||
LockDep lockDep;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
SchedStat schedStat; /**< Schedule statistics */
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
UINTPTR archMmu;
|
||||
UINTPTR userArea;
|
||||
UINTPTR userMapBase;
|
||||
UINT32 userMapSize; /**< user thread stack size ,real size : userMapSize + USER_STACK_MIN_SIZE */
|
||||
FutexNode futex;
|
||||
#endif
|
||||
UINT32 processID; /**< Which belong process */
|
||||
LOS_DL_LIST joinList; /**< join list */
|
||||
LOS_DL_LIST lockList; /**< Hold the lock list */
|
||||
UINTPTR waitID; /**< Wait for the PID or GID of the child process */
|
||||
UINT16 waitFlag; /**< The type of child process that is waiting, belonging to a group or parent,
|
||||
a specific child process, or any child process */
|
||||
#ifdef LOSCFG_KERNEL_LITEIPC
|
||||
IpcTaskInfo *ipcTaskInfo;
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_PERF
|
||||
UINTPTR pc;
|
||||
UINTPTR fp;
|
||||
#endif
|
||||
} LosTaskCB;
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsRunning(const LosTaskCB *taskCB)
|
||||
{
|
||||
return ((taskCB->taskStatus & OS_TASK_STATUS_RUNNING) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsReady(const LosTaskCB *taskCB)
|
||||
{
|
||||
return ((taskCB->taskStatus & OS_TASK_STATUS_READY) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsInactive(const LosTaskCB *taskCB)
|
||||
{
|
||||
return ((taskCB->taskStatus & (OS_TASK_STATUS_INIT | OS_TASK_STATUS_EXIT)) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsPending(const LosTaskCB *taskCB)
|
||||
{
|
||||
return ((taskCB->taskStatus & OS_TASK_STATUS_PENDING) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsSuspended(const LosTaskCB *taskCB)
|
||||
{
|
||||
return ((taskCB->taskStatus & OS_TASK_STATUS_SUSPENDED) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsBlocked(const LosTaskCB *taskCB)
|
||||
{
|
||||
return ((taskCB->taskStatus & (OS_TASK_STATUS_SUSPENDED | OS_TASK_STATUS_PENDING | OS_TASK_STATUS_DELAY)) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE LosTaskCB *OsCurrTaskGet(VOID)
|
||||
{
|
||||
return (LosTaskCB *)ArchCurrTaskGet();
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsCurrTaskSet(LosTaskCB *task)
|
||||
{
|
||||
ArchCurrTaskSet(task);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsCurrUserTaskSet(UINTPTR thread)
|
||||
{
|
||||
ArchCurrUserTaskSet(thread);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedIrqUpdateUsedTime(VOID)
|
||||
@@ -87,137 +492,46 @@ STATIC INLINE VOID OsSchedIrqStartTime(VOID)
|
||||
g_taskScheduled &= ~(1U << (cpuid)); \
|
||||
} while (0);
|
||||
|
||||
#define OS_SCHEDULER_ACTIVE (g_taskScheduled & (1U << ArchCurrCpuid()))
|
||||
#define OS_SCHEDULER_ALL_ACTIVE (g_taskScheduled == LOSCFG_KERNEL_CPU_MASK)
|
||||
|
||||
typedef enum {
|
||||
INT_NO_RESCH = 0x0, /* no needs to schedule */
|
||||
INT_PEND_RESCH = 0x1, /* pending schedule flag */
|
||||
INT_PEND_TICK = 0x2, /* pending tick */
|
||||
} SchedFlag;
|
||||
|
||||
/* Check if preemptable with counter flag */
|
||||
STATIC INLINE BOOL OsPreemptable(VOID)
|
||||
{
|
||||
/*
|
||||
* Unlike OsPreemptableInSched, the int may be not disabled when OsPreemptable
|
||||
* is called, needs mannually disable interrupt, to prevent current task from
|
||||
* being migrated to another core, and get the wrong preeptable status.
|
||||
*/
|
||||
UINT32 intSave = LOS_IntLock();
|
||||
BOOL preemptable = (OsPercpuGet()->taskLockCnt == 0);
|
||||
if (!preemptable) {
|
||||
/* Set schedule flag if preemption is disabled */
|
||||
OsPercpuGet()->schedFlag |= INT_PEND_RESCH;
|
||||
}
|
||||
LOS_IntRestore(intSave);
|
||||
return preemptable;
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsPreemptableInSched(VOID)
|
||||
{
|
||||
BOOL preemptable = FALSE;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
/*
|
||||
* For smp systems, schedule must hold the task spinlock, and this counter
|
||||
* will increase by 1 in that case.
|
||||
*/
|
||||
preemptable = (OsPercpuGet()->taskLockCnt == 1);
|
||||
|
||||
#else
|
||||
preemptable = (OsPercpuGet()->taskLockCnt == 0);
|
||||
#endif
|
||||
if (!preemptable) {
|
||||
/* Set schedule flag if preemption is disabled */
|
||||
OsPercpuGet()->schedFlag |= INT_PEND_RESCH;
|
||||
}
|
||||
|
||||
return preemptable;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsCpuSchedLock(Percpu *cpu)
|
||||
{
|
||||
cpu->taskLockCnt++;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsCpuSchedUnlock(Percpu *cpu, UINT32 intSave)
|
||||
{
|
||||
if (cpu->taskLockCnt > 0) {
|
||||
cpu->taskLockCnt--;
|
||||
if ((cpu->taskLockCnt == 0) && (cpu->schedFlag & INT_PEND_RESCH) && OS_SCHEDULER_ACTIVE) {
|
||||
cpu->schedFlag &= ~INT_PEND_RESCH;
|
||||
LOS_IntRestore(intSave);
|
||||
LOS_Schedule();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
}
|
||||
|
||||
extern UINT32 OsSchedSetTickTimerType(UINT32 timerType);
|
||||
|
||||
extern VOID OsSchedSetIdleTaskSchedParam(LosTaskCB *idleTask);
|
||||
|
||||
extern UINT32 OsSchedSwtmrScanRegister(SchedScan func);
|
||||
|
||||
extern VOID OsSchedResetSchedResponseTime(UINT64 responseTime);
|
||||
|
||||
extern VOID OsSchedUpdateExpireTime(UINT64 startTime);
|
||||
|
||||
extern VOID OsSchedToUserReleaseLock(VOID);
|
||||
|
||||
extern VOID OsSchedTaskDeQueue(LosTaskCB *taskCB);
|
||||
|
||||
extern VOID OsSchedTaskEnQueue(LosTaskCB *taskCB);
|
||||
|
||||
extern UINT32 OsSchedTaskWait(LOS_DL_LIST *list, UINT32 timeout, BOOL needSched);
|
||||
|
||||
extern VOID OsSchedTaskWake(LosTaskCB *resumedTask);
|
||||
|
||||
extern BOOL OsSchedModifyTaskSchedParam(LosTaskCB *taskCB, UINT16 policy, UINT16 priority);
|
||||
|
||||
extern BOOL OsSchedModifyProcessSchedParam(LosProcessCB *processCB, UINT16 policy, UINT16 priority);
|
||||
|
||||
extern VOID OsSchedSuspend(LosTaskCB *taskCB);
|
||||
|
||||
extern BOOL OsSchedResume(LosTaskCB *taskCB);
|
||||
|
||||
extern VOID OsSchedDelay(LosTaskCB *runTask, UINT32 tick);
|
||||
|
||||
extern VOID OsSchedYield(VOID);
|
||||
|
||||
extern VOID OsSchedTaskExit(LosTaskCB *taskCB);
|
||||
|
||||
extern VOID OsSchedTick(VOID);
|
||||
|
||||
extern UINT32 OsSchedInit(VOID);
|
||||
|
||||
extern VOID OsSchedStart(VOID);
|
||||
VOID OsSchedSetIdleTaskSchedParam(LosTaskCB *idleTask);
|
||||
VOID OsSchedResetSchedResponseTime(UINT64 responseTime);
|
||||
VOID OsSchedUpdateExpireTime(VOID);
|
||||
VOID OsSchedToUserReleaseLock(VOID);
|
||||
VOID OsSchedTaskDeQueue(LosTaskCB *taskCB);
|
||||
VOID OsSchedTaskEnQueue(LosTaskCB *taskCB);
|
||||
UINT32 OsSchedTaskWait(LOS_DL_LIST *list, UINT32 timeout, BOOL needSched);
|
||||
VOID OsSchedTaskWake(LosTaskCB *resumedTask);
|
||||
BOOL OsSchedModifyTaskSchedParam(LosTaskCB *taskCB, UINT16 policy, UINT16 priority);
|
||||
BOOL OsSchedModifyProcessSchedParam(UINT32 pid, UINT16 policy, UINT16 priority);
|
||||
VOID OsSchedSuspend(LosTaskCB *taskCB);
|
||||
BOOL OsSchedResume(LosTaskCB *taskCB);
|
||||
VOID OsSchedDelay(LosTaskCB *runTask, UINT32 tick);
|
||||
VOID OsSchedYield(VOID);
|
||||
VOID OsSchedTaskExit(LosTaskCB *taskCB);
|
||||
VOID OsSchedTick(VOID);
|
||||
UINT32 OsSchedInit(VOID);
|
||||
VOID OsSchedStart(VOID);
|
||||
|
||||
/*
|
||||
* This function simply picks the next task and switches to it.
|
||||
* Current task needs to already be in the right state or the right
|
||||
* queues it needs to be in.
|
||||
*/
|
||||
extern VOID OsSchedResched(VOID);
|
||||
|
||||
extern VOID OsSchedIrqEndCheckNeedSched(VOID);
|
||||
VOID OsSchedResched(VOID);
|
||||
VOID OsSchedIrqEndCheckNeedSched(VOID);
|
||||
|
||||
/*
|
||||
* This function inserts the runTask to the lock pending list based on the
|
||||
* task priority.
|
||||
*/
|
||||
extern LOS_DL_LIST *OsSchedLockPendFindPos(const LosTaskCB *runTask, LOS_DL_LIST *lockList);
|
||||
LOS_DL_LIST *OsSchedLockPendFindPos(const LosTaskCB *runTask, LOS_DL_LIST *lockList);
|
||||
|
||||
#ifdef LOSCFG_SCHED_TICK_DEBUG
|
||||
extern VOID OsSchedDebugRecordData(VOID);
|
||||
VOID OsSchedDebugRecordData(VOID);
|
||||
#endif
|
||||
|
||||
extern UINT32 OsShellShowTickRespo(VOID);
|
||||
UINT32 OsShellShowTickRespo(VOID);
|
||||
|
||||
extern UINT32 OsShellShowSchedParam(VOID);
|
||||
UINT32 OsShellShowSchedParam(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
#include "los_typedef.h"
|
||||
#include "los_list.h"
|
||||
#include "los_sys_pri.h"
|
||||
#include "los_spinlock.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -42,11 +42,6 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef enum {
|
||||
OS_SORT_LINK_TASK = 1,
|
||||
OS_SORT_LINK_SWTMR = 2,
|
||||
} SortLinkType;
|
||||
|
||||
typedef struct {
|
||||
LOS_DL_LIST sortLinkNode;
|
||||
UINT64 responseTime;
|
||||
@@ -58,19 +53,47 @@ typedef struct {
|
||||
typedef struct {
|
||||
LOS_DL_LIST sortLink;
|
||||
UINT32 nodeNum;
|
||||
SPIN_LOCK_S spinLock; /* swtmr sort link spin lock */
|
||||
} SortLinkAttribute;
|
||||
|
||||
#define OS_SORT_LINK_INVALID_TIME ((UINT64)-1)
|
||||
#define SET_SORTLIST_VALUE(sortList, value) (((SortLinkList *)(sortList))->responseTime = (value))
|
||||
#define GET_SORTLIST_VALUE(sortList) (((SortLinkList *)(sortList))->responseTime)
|
||||
|
||||
extern UINT64 OsGetNextExpireTime(UINT64 startTime);
|
||||
extern UINT32 OsSortLinkInit(SortLinkAttribute *sortLinkHeader);
|
||||
extern VOID OsDeleteNodeSortLink(SortLinkAttribute *sortLinkHeader, SortLinkList *sortList);
|
||||
extern VOID OsAdd2SortLink(SortLinkList *node, UINT64 startTime, UINT32 waitTicks, SortLinkType type);
|
||||
extern VOID OsDeleteSortLink(SortLinkList *node, SortLinkType type);
|
||||
extern UINT32 OsSortLinkGetTargetExpireTime(const SortLinkList *targetSortList);
|
||||
extern UINT32 OsSortLinkGetNextExpireTime(const SortLinkAttribute *sortLinkHeader);
|
||||
STATIC INLINE VOID OsDeleteNodeSortLink(SortLinkAttribute *sortLinkHeader, SortLinkList *sortList)
|
||||
{
|
||||
LOS_ListDelete(&sortList->sortLinkNode);
|
||||
SET_SORTLIST_VALUE(sortList, OS_SORT_LINK_INVALID_TIME);
|
||||
sortLinkHeader->nodeNum--;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT64 OsGetSortLinkNextExpireTime(SortLinkAttribute *sortHeader, UINT64 startTime, UINT32 tickPrecision)
|
||||
{
|
||||
LOS_DL_LIST *head = &sortHeader->sortLink;
|
||||
LOS_DL_LIST *list = head->pstNext;
|
||||
|
||||
if (LOS_ListEmpty(head)) {
|
||||
return OS_SORT_LINK_INVALID_TIME - tickPrecision;
|
||||
}
|
||||
|
||||
SortLinkList *listSorted = LOS_DL_LIST_ENTRY(list, SortLinkList, sortLinkNode);
|
||||
if (listSorted->responseTime <= (startTime + tickPrecision)) {
|
||||
return startTime + tickPrecision;
|
||||
}
|
||||
|
||||
return listSorted->responseTime;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 OsGetSortLinkNodeNum(SortLinkAttribute *head)
|
||||
{
|
||||
return head->nodeNum;
|
||||
}
|
||||
|
||||
VOID OsSortLinkInit(SortLinkAttribute *sortLinkHeader);
|
||||
VOID OsAdd2SortLink(SortLinkAttribute *head, SortLinkList *node, UINT64 responseTime, UINT16 idleCpu);
|
||||
VOID OsDeleteFromSortLink(SortLinkAttribute *head, SortLinkList *node);
|
||||
UINT64 OsSortLinkGetTargetExpireTime(UINT64 currTime, const SortLinkList *targetSortList);
|
||||
UINT64 OsSortLinkGetNextExpireTime(UINT64 currTime, const SortLinkAttribute *sortLinkHeader);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "los_swtmr.h"
|
||||
#include "los_spinlock.h"
|
||||
#include "los_sched_pri.h"
|
||||
|
||||
#ifdef LOSCFG_SECURITY_VID
|
||||
#include "vid_api.h"
|
||||
@@ -75,8 +76,6 @@ typedef SwtmrHandlerItem *SwtmrHandlerItemPtr;
|
||||
|
||||
extern SWTMR_CTRL_S *g_swtmrCBArray;
|
||||
|
||||
extern SortLinkAttribute g_swtmrSortLink; /* The software timer count list */
|
||||
|
||||
#define OS_SWT_FROM_SID(swtmrID) ((SWTMR_CTRL_S *)g_swtmrCBArray + ((swtmrID) % LOSCFG_BASE_CORE_SWTMR_LIMIT))
|
||||
|
||||
/**
|
||||
@@ -100,10 +99,13 @@ extern SortLinkAttribute g_swtmrSortLink; /* The software timer count list */
|
||||
* <ul><li>los_swtmr_pri.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see LOS_SwtmrStop
|
||||
*/
|
||||
extern VOID OsSwtmrScan(VOID);
|
||||
|
||||
extern BOOL OsIsSwtmrTask(const LosTaskCB *taskCB);
|
||||
extern VOID OsSwtmrRestart(UINT64 startTime, SortLinkList *sortList);
|
||||
extern VOID OsSwtmrWake(SchedRunQue *rq, UINT64 currTime, SortLinkList *sortList);
|
||||
extern UINT32 OsSwtmrInit(VOID);
|
||||
extern VOID OsSwtmrTask(VOID);
|
||||
extern VOID OsSwtmrRecycle(UINT32 processID);
|
||||
extern BOOL OsSwtmrWorkQueueFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg);
|
||||
extern SPIN_LOCK_S g_swtmrSpin;
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -33,20 +33,8 @@
|
||||
#define _LOS_TASK_PRI_H
|
||||
|
||||
#include "los_task.h"
|
||||
#include "los_percpu_pri.h"
|
||||
#include "los_spinlock.h"
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
#include "los_stat_pri.h"
|
||||
#endif
|
||||
#include "los_stackinfo_pri.h"
|
||||
#include "los_futex_pri.h"
|
||||
#include "los_signal.h"
|
||||
#ifdef LOSCFG_KERNEL_CPUP
|
||||
#include "los_cpup_pri.h"
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_LITEIPC
|
||||
#include "hm_liteipc.h"
|
||||
#endif
|
||||
#include "los_sched_pri.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
@@ -79,97 +67,6 @@ extern SPIN_LOCK_S g_taskSpin;
|
||||
*/
|
||||
#define OS_TASK_ERRORID 0xFFFFFFFF
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Define a usable task priority.
|
||||
*
|
||||
* Highest task priority.
|
||||
*/
|
||||
#define OS_TASK_PRIORITY_HIGHEST 0
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Define a usable task priority.
|
||||
*
|
||||
* Lowest task priority.
|
||||
*/
|
||||
#define OS_TASK_PRIORITY_LOWEST 31
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is init.
|
||||
*/
|
||||
#define OS_TASK_STATUS_INIT 0x0001U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is ready.
|
||||
*/
|
||||
#define OS_TASK_STATUS_READY 0x0002U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is running.
|
||||
*/
|
||||
#define OS_TASK_STATUS_RUNNING 0x0004U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is suspended.
|
||||
*/
|
||||
#define OS_TASK_STATUS_SUSPENDED 0x0008U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is blocked.
|
||||
*/
|
||||
#define OS_TASK_STATUS_PENDING 0x0010U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is delayed.
|
||||
*/
|
||||
#define OS_TASK_STATUS_DELAY 0x0020U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The time for waiting for an event to occur expires.
|
||||
*/
|
||||
#define OS_TASK_STATUS_TIMEOUT 0x0040U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is pend for a period of time.
|
||||
*/
|
||||
#define OS_TASK_STATUS_PEND_TIME 0x0080U
|
||||
|
||||
#define OS_TASK_STATUS_BLOCKED (OS_TASK_STATUS_INIT | OS_TASK_STATUS_PENDING | \
|
||||
OS_TASK_STATUS_DELAY | OS_TASK_STATUS_PEND_TIME)
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is exit.
|
||||
*/
|
||||
#define OS_TASK_STATUS_EXIT 0x0100U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
@@ -186,6 +83,14 @@ extern SPIN_LOCK_S g_taskSpin;
|
||||
*/
|
||||
#define OS_TASK_FLAG_PTHREAD_JOIN 0x0400U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The task is user mode task.
|
||||
*/
|
||||
#define OS_TASK_FLAG_USER_MODE 0x0800U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task property.
|
||||
@@ -306,76 +211,6 @@ extern SPIN_LOCK_S g_taskSpin;
|
||||
#define OS_RESOURCE_EVENT_MASK 0xFF
|
||||
#define OS_RESOURCE_EVENT_OOM 0x02
|
||||
#define OS_RESOURCE_EVENT_FREE 0x04
|
||||
#define OS_TCB_NAME_LEN 32
|
||||
|
||||
typedef struct {
|
||||
VOID *stackPointer; /**< Task stack pointer */
|
||||
UINT16 taskStatus; /**< Task status */
|
||||
|
||||
/* The scheduling */
|
||||
UINT16 priority; /**< Task priority */
|
||||
UINT16 policy;
|
||||
UINT64 startTime; /**< The start time of each phase of task */
|
||||
UINT64 irqStartTime; /**< Interrupt start time */
|
||||
UINT32 irqUsedTime; /**< Interrupt consumption time */
|
||||
UINT32 initTimeSlice; /**< Task init time slice */
|
||||
INT32 timeSlice; /**< Task remaining time slice */
|
||||
UINT32 waitTimes; /**< Task delay time, tick number */
|
||||
SortLinkList sortList; /**< Task sortlink node */
|
||||
|
||||
UINT32 stackSize; /**< Task stack size */
|
||||
UINTPTR topOfStack; /**< Task stack top */
|
||||
UINT32 taskID; /**< Task ID */
|
||||
TSK_ENTRY_FUNC taskEntry; /**< Task entrance function */
|
||||
VOID *joinRetval; /**< pthread adaption */
|
||||
VOID *taskMux; /**< Task-held mutex */
|
||||
VOID *taskEvent; /**< Task-held event */
|
||||
UINTPTR args[4]; /**< Parameter, of which the maximum number is 4 */
|
||||
CHAR taskName[OS_TCB_NAME_LEN]; /**< Task name */
|
||||
LOS_DL_LIST pendList; /**< Task pend node */
|
||||
LOS_DL_LIST threadList; /**< thread list */
|
||||
UINT32 eventMask; /**< Event mask */
|
||||
UINT32 eventMode; /**< Event mode */
|
||||
UINT32 priBitMap; /**< BitMap for recording the change of task priority,
|
||||
the priority can not be greater than 31 */
|
||||
#ifdef LOSCFG_KERNEL_CPUP
|
||||
OsCpupBase taskCpup; /**< task cpu usage */
|
||||
#endif
|
||||
INT32 errorNo; /**< Error Num */
|
||||
UINT32 signal; /**< Task signal */
|
||||
sig_cb sig;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
UINT16 currCpu; /**< CPU core number of this task is running on */
|
||||
UINT16 lastCpu; /**< CPU core number of this task is running on last time */
|
||||
UINT16 cpuAffiMask; /**< CPU affinity mask, support up to 16 cores */
|
||||
#ifdef LOSCFG_KERNEL_SMP_TASK_SYNC
|
||||
UINT32 syncSignal; /**< Synchronization for signal handling */
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_SMP_LOCKDEP
|
||||
LockDep lockDep;
|
||||
#endif
|
||||
#endif
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
SchedStat schedStat; /**< Schedule statistics */
|
||||
#endif
|
||||
UINTPTR userArea;
|
||||
UINTPTR userMapBase;
|
||||
UINT32 userMapSize; /**< user thread stack size ,real size : userMapSize + USER_STACK_MIN_SIZE */
|
||||
UINT32 processID; /**< Which belong process */
|
||||
FutexNode futex;
|
||||
LOS_DL_LIST joinList; /**< join list */
|
||||
LOS_DL_LIST lockList; /**< Hold the lock list */
|
||||
UINTPTR waitID; /**< Wait for the PID or GID of the child process */
|
||||
UINT16 waitFlag; /**< The type of child process that is waiting, belonging to a group or parent,
|
||||
a specific child process, or any child process */
|
||||
#ifdef LOSCFG_KERNEL_LITEIPC
|
||||
IpcTaskInfo *ipcTaskInfo;
|
||||
#endif
|
||||
#ifdef LOSCFG_KERNEL_PERF
|
||||
UINTPTR pc;
|
||||
UINTPTR fp;
|
||||
#endif
|
||||
} LosTaskCB;
|
||||
|
||||
typedef struct {
|
||||
LosTaskCB *runTask;
|
||||
@@ -416,21 +251,6 @@ typedef struct {
|
||||
UINT16 timeout; /**< Expiration duration */
|
||||
} OsTaskRobin;
|
||||
|
||||
STATIC INLINE LosTaskCB *OsCurrTaskGet(VOID)
|
||||
{
|
||||
return (LosTaskCB *)ArchCurrTaskGet();
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsCurrTaskSet(LosTaskCB *task)
|
||||
{
|
||||
ArchCurrTaskSet(task);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsCurrUserTaskSet(UINTPTR thread)
|
||||
{
|
||||
ArchCurrUserTaskSet(thread);
|
||||
}
|
||||
|
||||
STATIC INLINE LosTaskCB *OsGetTaskCB(UINT32 taskID)
|
||||
{
|
||||
return OS_TCB_FROM_TID(taskID);
|
||||
@@ -438,47 +258,17 @@ STATIC INLINE LosTaskCB *OsGetTaskCB(UINT32 taskID)
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsUnused(const LosTaskCB *taskCB)
|
||||
{
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_UNUSED) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsRunning(const LosTaskCB *taskCB)
|
||||
{
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsInactive(const LosTaskCB *taskCB)
|
||||
{
|
||||
if (taskCB->taskStatus & (OS_TASK_STATUS_UNUSED | OS_TASK_STATUS_INIT | OS_TASK_STATUS_EXIT)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsPending(const LosTaskCB *taskCB)
|
||||
{
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_PENDING) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return ((taskCB->taskStatus & OS_TASK_STATUS_UNUSED) != 0);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsTaskIsKilled(const LosTaskCB *taskCB)
|
||||
{
|
||||
if (taskCB->taskStatus & OS_TASK_FLAG_EXIT_KILL) {
|
||||
return TRUE;
|
||||
}
|
||||
return ((taskCB->taskStatus & OS_TASK_FLAG_EXIT_KILL) != 0);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
STATIC INLINE BOOL OsTaskIsUserMode(const LosTaskCB *taskCB)
|
||||
{
|
||||
return ((taskCB->taskStatus & OS_TASK_FLAG_USER_MODE) != 0);
|
||||
}
|
||||
|
||||
#define OS_TID_CHECK_INVALID(taskID) ((UINT32)(taskID) >= g_taskMaxNum)
|
||||
@@ -528,23 +318,19 @@ extern LosTaskCB *OsGetMainTask(VOID);
|
||||
extern VOID OsSetMainTask(VOID);
|
||||
extern UINT32 OsGetIdleTaskId(VOID);
|
||||
extern VOID OsTaskEntry(UINT32 taskID);
|
||||
extern SortLinkAttribute *OsTaskSortLinkGet(VOID);
|
||||
extern VOID OsTaskProcSignal(VOID);
|
||||
extern UINT32 OsTaskDeleteUnsafe(LosTaskCB *taskCB, UINT32 status, UINT32 intSave);
|
||||
extern VOID OsTaskResourcesToFree(LosTaskCB *taskCB);
|
||||
extern VOID OsRunTaskToDelete(LosTaskCB *taskCB);
|
||||
extern UINT32 OsCreateUserTask(UINT32 processID, TSK_INIT_PARAM_S *initParam);
|
||||
extern INT32 OsSetTaskName(LosTaskCB *taskCB, const CHAR *name, BOOL setPName);
|
||||
extern VOID OsTaskCBRecycleToFree(VOID);
|
||||
extern VOID OsTaskExitGroup(UINT32 status);
|
||||
extern VOID OsTaskToExit(LosTaskCB *taskCB, UINT32 status);
|
||||
extern VOID OsExecDestroyTaskGroup(VOID);
|
||||
extern VOID OsRunningTaskToExit(LosTaskCB *runTask, UINT32 status);
|
||||
extern UINT32 OsUserTaskOperatePermissionsCheck(LosTaskCB *taskCB);
|
||||
extern UINT32 OsUserProcessOperatePermissionsCheck(LosTaskCB *taskCB, UINT32 processID);
|
||||
extern INT32 OsTcbDispatch(LosTaskCB *stcb, siginfo_t *info);
|
||||
extern VOID OsWriteResourceEvent(UINT32 events);
|
||||
extern VOID OsWriteResourceEventUnsafe(UINT32 events);
|
||||
extern UINT32 OsResourceFreeTaskCreate(VOID);
|
||||
extern VOID OsTaskInsertToRecycleList(LosTaskCB *taskCB);
|
||||
extern VOID OsInactiveTaskDelete(LosTaskCB *taskCB);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -602,18 +602,18 @@ STATIC INT32 OsFutexWaitTask(const UINT32 *userVaddr, const UINT32 flags, const
|
||||
SCHEDULER_LOCK(intSave);
|
||||
OsTaskWaitSetPendMask(OS_TASK_WAIT_FUTEX, futexKey, timeOut);
|
||||
OsSchedTaskWait(&(node->pendList), timeOut, FALSE);
|
||||
OsPercpuGet()->taskLockCnt++;
|
||||
OsSchedLock();
|
||||
LOS_SpinUnlock(&g_taskSpin);
|
||||
|
||||
futexRet = OsFutexUnlock(&hashNode->listLock);
|
||||
if (futexRet) {
|
||||
OsPercpuGet()->taskLockCnt--;
|
||||
OsSchedUnlock();
|
||||
LOS_IntRestore(intSave);
|
||||
goto EXIT_UNLOCK_ERR;
|
||||
}
|
||||
|
||||
LOS_SpinLock(&g_taskSpin);
|
||||
OsPercpuGet()->taskLockCnt--;
|
||||
OsSchedUnlock();
|
||||
|
||||
/*
|
||||
* it will immediately do the scheduling, so there's no need to release the
|
||||
|
||||
@@ -695,8 +695,8 @@ VOID *OsSaveSignalContext(VOID *sp, VOID *newSp)
|
||||
return sp;
|
||||
}
|
||||
|
||||
if (task->taskStatus & OS_TASK_FLAG_EXIT_KILL) {
|
||||
OsTaskToExit(task, 0);
|
||||
if (OsTaskIsKilled(task)) {
|
||||
OsRunningTaskToExit(task, 0);
|
||||
return sp;
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +128,6 @@ LITE_OS_SEC_TEXT_MINOR UINT8 *OsShellCmdSchedPolicy(UINT16 policy)
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR UINT8 *OsShellProcessStatus(UINT16 status)
|
||||
{
|
||||
status = status & OS_PROCESS_STATUS_MASK;
|
||||
if (status & OS_PROCESS_STATUS_ZOMBIES) {
|
||||
return (UINT8 *)"Zombies";
|
||||
} else if (status & OS_PROCESS_STATUS_INIT) {
|
||||
@@ -137,11 +136,8 @@ LITE_OS_SEC_TEXT_MINOR UINT8 *OsShellProcessStatus(UINT16 status)
|
||||
return (UINT8 *)"Running";
|
||||
} else if (status & OS_PROCESS_STATUS_READY) {
|
||||
return (UINT8 *)"Ready";
|
||||
} else if (status & OS_PROCESS_STATUS_PENDING) {
|
||||
return (UINT8 *)"Pending";
|
||||
}
|
||||
|
||||
return (UINT8 *)"Invalid";
|
||||
return (UINT8 *)"Pending";
|
||||
}
|
||||
|
||||
STATIC VOID OsShellCmdProcessTitle(VOID *seqBuf, UINT16 flag)
|
||||
@@ -189,7 +185,7 @@ STATIC VOID OsShellCmdProcessInfoShow(const LosProcessCB *processCB, const INT32
|
||||
processCpup1s[pid].usage % LOS_CPUP_PRECISION_MULT);
|
||||
#endif /* LOSCFG_KERNEL_CPUP */
|
||||
PROCESS_INFO_SHOW(seqBuf, "%6s%9u%5d%10u%7s ",
|
||||
OsShellCmdSchedPolicy(LOS_SCHED_RR), processCB->priority,
|
||||
OsShellCmdSchedPolicy(LOS_SCHED_RR), OS_TCB_FROM_TID(processCB->threadGroupID)->basePrio,
|
||||
(INT32)processCB->threadGroupID, processCB->threadNumber,
|
||||
OsShellCmdProcessMode(processCB->processMode));
|
||||
} else {
|
||||
@@ -246,17 +242,28 @@ STATIC VOID OsProcessMemUsageGet(UINT32 *memArray)
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC UINT32 OsProcessInfoGet(LosProcessCB **pcbArray, INT32 **group, UINT32 **memArray, UINT16 flag)
|
||||
#define OS_TASK_STATUS_MASK 0x00FF
|
||||
STATIC VOID OsProcessInfoGet(LosProcessCB **pcbArray, INT32 **group,
|
||||
UINT32 **memArray, LosTaskCB **tcbArray,
|
||||
UINT16 flag)
|
||||
{
|
||||
UINT32 len = OS_PROCESS_ALL_INFO_LEN;
|
||||
LosProcessCB *processCB = NULL;
|
||||
INT32 *user = NULL;
|
||||
|
||||
(VOID)memcpy_s(*pcbArray, OS_PROCESS_INFO_LEN, g_processCBArray, OS_PROCESS_INFO_LEN);
|
||||
*group = (INT32 *)((UINTPTR)*pcbArray + OS_PROCESS_INFO_LEN);
|
||||
user = (INT32 *)((UINTPTR)*group + OS_PROCESS_GROUP_INFO_LEN);
|
||||
INT32 *user = (INT32 *)((UINTPTR)*group + OS_PROCESS_GROUP_INFO_LEN);
|
||||
|
||||
for (UINT32 tid = 0; tid < g_taskMaxNum; tid++) {
|
||||
LosTaskCB *taskCB = *tcbArray + tid;
|
||||
if (OsTaskIsUnused(taskCB)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
LosProcessCB *processCB = *pcbArray + taskCB->processID;
|
||||
if (!OsProcessIsDead(processCB) && !OsProcessIsInit(processCB)) {
|
||||
processCB->processStatus |= (taskCB->taskStatus & OS_TASK_STATUS_MASK);
|
||||
}
|
||||
}
|
||||
|
||||
for (UINT32 pid = 0; pid < g_processMaxNum; ++pid) {
|
||||
processCB = *pcbArray + pid;
|
||||
LosProcessCB *processCB = *pcbArray + pid;
|
||||
if (OsProcessIsUnused(processCB)) {
|
||||
continue;
|
||||
}
|
||||
@@ -295,11 +302,8 @@ STATIC UINT32 OsProcessInfoGet(LosProcessCB **pcbArray, INT32 **group, UINT32 **
|
||||
if (flag & OS_PROCESS_MEM_INFO) {
|
||||
*memArray = (UINT32 *)((UINTPTR)*pcbArray + OS_PROCESS_ALL_INFO_LEN);
|
||||
OsProcessMemUsageGet(*memArray);
|
||||
len += OS_PROCESS_MEM_ALL_INFO_LEN;
|
||||
}
|
||||
#endif
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
STATIC VOID OsShellCmdProcessInfoData(const LosProcessCB *pcbArray, const INT32 *group,
|
||||
@@ -522,16 +526,24 @@ STATIC VOID OsProcessAndTaskInfoGet(LosProcessCB **pcbArray, INT32 **group, LosT
|
||||
{
|
||||
BOOL lockFlag = FALSE;
|
||||
UINT32 intSave = 0;
|
||||
UINT32 processInfoLen;
|
||||
UINT32 processInfoLen = OS_PROCESS_ALL_INFO_LEN;
|
||||
|
||||
if (LOS_SpinHeld(&g_taskSpin) == FALSE) {
|
||||
SCHEDULER_LOCK(intSave);
|
||||
lockFlag = TRUE;
|
||||
}
|
||||
|
||||
processInfoLen = OsProcessInfoGet(pcbArray, group, memArray, flag);
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
if (flag & OS_PROCESS_MEM_INFO) {
|
||||
processInfoLen += OS_PROCESS_MEM_ALL_INFO_LEN;
|
||||
}
|
||||
#endif
|
||||
|
||||
(VOID)memcpy_s(*pcbArray, OS_PROCESS_INFO_LEN, g_processCBArray, OS_PROCESS_INFO_LEN);
|
||||
*tcbArray = (LosTaskCB *)((UINTPTR)*pcbArray + processInfoLen);
|
||||
(VOID)memcpy_s(*tcbArray, OS_TASK_INFO_LEN, g_taskCBArray, OS_TASK_INFO_LEN);
|
||||
|
||||
OsProcessInfoGet(pcbArray, group, memArray, tcbArray, flag);
|
||||
taskWaterLine = (UINT32 *)((UINTPTR)*tcbArray + OS_TASK_INFO_LEN);
|
||||
OsShellCmdTaskWaterLineGet(*tcbArray);
|
||||
if (lockFlag == TRUE) {
|
||||
|
||||
@@ -62,7 +62,7 @@ VOID OsMpScheduleHandler(VOID)
|
||||
* set schedule flag to differ from wake function,
|
||||
* so that the scheduler can be triggered at the end of irq.
|
||||
*/
|
||||
OsPercpuGet()->schedFlag |= INT_PEND_RESCH;
|
||||
OsSchedRunQuePendingSet();
|
||||
}
|
||||
|
||||
VOID OsMpHaltHandler(VOID)
|
||||
|
||||
@@ -30,7 +30,30 @@
|
||||
*/
|
||||
|
||||
#include "los_percpu_pri.h"
|
||||
#include "los_printf.h"
|
||||
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
Percpu g_percpu[LOSCFG_KERNEL_CORE_NUM];
|
||||
|
||||
VOID OsAllCpuStatusOutput(VOID)
|
||||
{
|
||||
UINT32 i;
|
||||
|
||||
for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
|
||||
switch (g_percpu[i].excFlag) {
|
||||
case CPU_RUNNING:
|
||||
PrintExcInfo("cpu%u is running.\n", i);
|
||||
break;
|
||||
case CPU_HALT:
|
||||
PrintExcInfo("cpu%u is halted.\n", i);
|
||||
break;
|
||||
case CPU_EXC:
|
||||
PrintExcInfo("cpu%u is in exc.\n", i);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
PrintExcInfo("The current handling the exception is cpu%u !\n", ArchCurrCpuid());
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -50,7 +50,7 @@ BOOL LOS_SpinHeld(const SPIN_LOCK_S *lock)
|
||||
VOID LOS_SpinLock(SPIN_LOCK_S *lock)
|
||||
{
|
||||
UINT32 intSave = LOS_IntLock();
|
||||
OsCpuSchedLock(OsPercpuGet());
|
||||
OsSchedLock();
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
LOCKDEP_CHECK_IN(lock);
|
||||
@@ -60,17 +60,22 @@ VOID LOS_SpinLock(SPIN_LOCK_S *lock)
|
||||
|
||||
INT32 LOS_SpinTrylock(SPIN_LOCK_S *lock)
|
||||
{
|
||||
Percpu *cpu = OsPercpuGet();
|
||||
UINT32 intSave = LOS_IntLock();
|
||||
OsCpuSchedLock(cpu);
|
||||
OsSchedLock();
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
INT32 ret = ArchSpinTrylock(&lock->rawLock);
|
||||
if (ret == LOS_OK) {
|
||||
LOCKDEP_CHECK_IN(lock);
|
||||
LOCKDEP_RECORD(lock);
|
||||
} else {
|
||||
OsCpuSchedUnlock(cpu, LOS_IntLock());
|
||||
return ret;
|
||||
}
|
||||
|
||||
intSave = LOS_IntLock();
|
||||
BOOL needSched = OsSchedUnlockResch();
|
||||
LOS_IntRestore(intSave);
|
||||
if (needSched) {
|
||||
LOS_Schedule();
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -78,16 +83,22 @@ INT32 LOS_SpinTrylock(SPIN_LOCK_S *lock)
|
||||
|
||||
VOID LOS_SpinUnlock(SPIN_LOCK_S *lock)
|
||||
{
|
||||
UINT32 intSave;
|
||||
LOCKDEP_CHECK_OUT(lock);
|
||||
ArchSpinUnlock(&lock->rawLock);
|
||||
|
||||
OsCpuSchedUnlock(OsPercpuGet(), LOS_IntLock());
|
||||
intSave = LOS_IntLock();
|
||||
BOOL needSched = OsSchedUnlockResch();
|
||||
LOS_IntRestore(intSave);
|
||||
if (needSched) {
|
||||
LOS_Schedule();
|
||||
}
|
||||
}
|
||||
|
||||
VOID LOS_SpinLockSave(SPIN_LOCK_S *lock, UINT32 *intSave)
|
||||
{
|
||||
*intSave = LOS_IntLock();
|
||||
OsCpuSchedLock(OsPercpuGet());
|
||||
OsSchedLock();
|
||||
|
||||
LOCKDEP_CHECK_IN(lock);
|
||||
ArchSpinLock(&lock->rawLock);
|
||||
@@ -99,7 +110,11 @@ VOID LOS_SpinUnlockRestore(SPIN_LOCK_S *lock, UINT32 intSave)
|
||||
LOCKDEP_CHECK_OUT(lock);
|
||||
ArchSpinUnlock(&lock->rawLock);
|
||||
|
||||
OsCpuSchedUnlock(OsPercpuGet(), intSave);
|
||||
BOOL needSched = OsSchedUnlockResch();
|
||||
LOS_IntRestore(intSave);
|
||||
if (needSched) {
|
||||
LOS_Schedule();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -30,20 +30,16 @@
|
||||
*/
|
||||
|
||||
#include "los_sortlink_pri.h"
|
||||
#include "los_memory.h"
|
||||
#include "los_exc.h"
|
||||
#include "los_percpu_pri.h"
|
||||
#include "los_sched_pri.h"
|
||||
#include "los_mp.h"
|
||||
|
||||
UINT32 OsSortLinkInit(SortLinkAttribute *sortLinkHeader)
|
||||
VOID OsSortLinkInit(SortLinkAttribute *sortLinkHeader)
|
||||
{
|
||||
LOS_ListInit(&sortLinkHeader->sortLink);
|
||||
LOS_SpinInit(&sortLinkHeader->spinLock);
|
||||
sortLinkHeader->nodeNum = 0;
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsAddNode2SortLink(SortLinkAttribute *sortLinkHeader, SortLinkList *sortList)
|
||||
STATIC INLINE VOID AddNode2SortLink(SortLinkAttribute *sortLinkHeader, SortLinkList *sortList)
|
||||
{
|
||||
LOS_DL_LIST *head = (LOS_DL_LIST *)&sortLinkHeader->sortLink;
|
||||
|
||||
@@ -77,156 +73,50 @@ STATIC INLINE VOID OsAddNode2SortLink(SortLinkAttribute *sortLinkHeader, SortLin
|
||||
} while (1);
|
||||
}
|
||||
|
||||
VOID OsDeleteNodeSortLink(SortLinkAttribute *sortLinkHeader, SortLinkList *sortList)
|
||||
VOID OsAdd2SortLink(SortLinkAttribute *head, SortLinkList *node, UINT64 responseTime, UINT16 idleCpu)
|
||||
{
|
||||
LOS_ListDelete(&sortList->sortLinkNode);
|
||||
SET_SORTLIST_VALUE(sortList, OS_SORT_LINK_INVALID_TIME);
|
||||
sortLinkHeader->nodeNum--;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT64 OsGetSortLinkNextExpireTime(SortLinkAttribute *sortHeader, UINT64 startTime)
|
||||
{
|
||||
LOS_DL_LIST *head = &sortHeader->sortLink;
|
||||
LOS_DL_LIST *list = head->pstNext;
|
||||
|
||||
if (LOS_ListEmpty(head)) {
|
||||
return OS_SCHED_MAX_RESPONSE_TIME - OS_TICK_RESPONSE_PRECISION;
|
||||
}
|
||||
|
||||
SortLinkList *listSorted = LOS_DL_LIST_ENTRY(list, SortLinkList, sortLinkNode);
|
||||
if (listSorted->responseTime <= (startTime + OS_TICK_RESPONSE_PRECISION)) {
|
||||
return startTime + OS_TICK_RESPONSE_PRECISION;
|
||||
}
|
||||
|
||||
return listSorted->responseTime;
|
||||
}
|
||||
|
||||
STATIC Percpu *OsFindIdleCpu(UINT16 *idleCpuID)
|
||||
{
|
||||
Percpu *idleCpu = OsPercpuGetByID(0);
|
||||
*idleCpuID = 0;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
UINT16 cpuID = 1;
|
||||
UINT32 nodeNum = idleCpu->taskSortLink.nodeNum + idleCpu->swtmrSortLink.nodeNum;
|
||||
|
||||
do {
|
||||
Percpu *cpu = OsPercpuGetByID(cpuID);
|
||||
UINT32 temp = cpu->taskSortLink.nodeNum + cpu->swtmrSortLink.nodeNum;
|
||||
if (nodeNum > temp) {
|
||||
idleCpu = cpu;
|
||||
*idleCpuID = cpuID;
|
||||
}
|
||||
|
||||
cpuID++;
|
||||
} while (cpuID < LOSCFG_KERNEL_CORE_NUM);
|
||||
#endif
|
||||
|
||||
return idleCpu;
|
||||
}
|
||||
|
||||
VOID OsAdd2SortLink(SortLinkList *node, UINT64 startTime, UINT32 waitTicks, SortLinkType type)
|
||||
{
|
||||
UINT32 intSave;
|
||||
Percpu *cpu = NULL;
|
||||
SortLinkAttribute *sortLinkHeader = NULL;
|
||||
SPIN_LOCK_S *spinLock = NULL;
|
||||
UINT16 idleCpu;
|
||||
|
||||
if (OS_SCHEDULER_ACTIVE) {
|
||||
cpu = OsFindIdleCpu(&idleCpu);
|
||||
} else {
|
||||
idleCpu = ArchCurrCpuid();
|
||||
cpu = OsPercpuGet();
|
||||
}
|
||||
|
||||
if (type == OS_SORT_LINK_TASK) {
|
||||
sortLinkHeader = &cpu->taskSortLink;
|
||||
spinLock = &cpu->taskSortLinkSpin;
|
||||
} else if (type == OS_SORT_LINK_SWTMR) {
|
||||
sortLinkHeader = &cpu->swtmrSortLink;
|
||||
spinLock = &cpu->swtmrSortLinkSpin;
|
||||
} else {
|
||||
LOS_Panic("Sort link type error : %u\n", type);
|
||||
}
|
||||
|
||||
LOS_SpinLockSave(spinLock, &intSave);
|
||||
SET_SORTLIST_VALUE(node, startTime + (UINT64)waitTicks * OS_CYCLE_PER_TICK);
|
||||
OsAddNode2SortLink(sortLinkHeader, node);
|
||||
LOS_SpinLock(&head->spinLock);
|
||||
SET_SORTLIST_VALUE(node, responseTime);
|
||||
AddNode2SortLink(head, node);
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
node->cpuid = idleCpu;
|
||||
#endif
|
||||
LOS_SpinUnlock(&head->spinLock);
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
if (idleCpu != ArchCurrCpuid()) {
|
||||
LOS_MpSchedule(CPUID_TO_AFFI_MASK(idleCpu));
|
||||
}
|
||||
#endif
|
||||
LOS_SpinUnlockRestore(spinLock, intSave);
|
||||
}
|
||||
|
||||
VOID OsDeleteSortLink(SortLinkList *node, SortLinkType type)
|
||||
VOID OsDeleteFromSortLink(SortLinkAttribute *head, SortLinkList *node)
|
||||
{
|
||||
UINT32 intSave;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
Percpu *cpu = OsPercpuGetByID(node->cpuid);
|
||||
#else
|
||||
Percpu *cpu = OsPercpuGetByID(0);
|
||||
#endif
|
||||
|
||||
SPIN_LOCK_S *spinLock = NULL;
|
||||
SortLinkAttribute *sortLinkHeader = NULL;
|
||||
if (type == OS_SORT_LINK_TASK) {
|
||||
sortLinkHeader = &cpu->taskSortLink;
|
||||
spinLock = &cpu->taskSortLinkSpin;
|
||||
} else if (type == OS_SORT_LINK_SWTMR) {
|
||||
sortLinkHeader = &cpu->swtmrSortLink;
|
||||
spinLock = &cpu->swtmrSortLinkSpin;
|
||||
} else {
|
||||
LOS_Panic("Sort link type error : %u\n", type);
|
||||
}
|
||||
|
||||
LOS_SpinLockSave(spinLock, &intSave);
|
||||
LOS_SpinLock(&head->spinLock);
|
||||
if (node->responseTime != OS_SORT_LINK_INVALID_TIME) {
|
||||
OsDeleteNodeSortLink(sortLinkHeader, node);
|
||||
OsDeleteNodeSortLink(head, node);
|
||||
}
|
||||
LOS_SpinUnlockRestore(spinLock, intSave);
|
||||
LOS_SpinUnlock(&head->spinLock);
|
||||
}
|
||||
|
||||
UINT64 OsGetNextExpireTime(UINT64 startTime)
|
||||
UINT64 OsSortLinkGetTargetExpireTime(UINT64 currTime, const SortLinkList *targetSortList)
|
||||
{
|
||||
UINT32 intSave;
|
||||
Percpu *cpu = OsPercpuGet();
|
||||
SortLinkAttribute *taskHeader = &cpu->taskSortLink;
|
||||
SortLinkAttribute *swtmrHeader = &cpu->swtmrSortLink;
|
||||
|
||||
LOS_SpinLockSave(&cpu->taskSortLinkSpin, &intSave);
|
||||
UINT64 taskExpirTime = OsGetSortLinkNextExpireTime(taskHeader, startTime);
|
||||
LOS_SpinUnlockRestore(&cpu->taskSortLinkSpin, intSave);
|
||||
|
||||
LOS_SpinLockSave(&cpu->swtmrSortLinkSpin, &intSave);
|
||||
UINT64 swtmrExpirTime = OsGetSortLinkNextExpireTime(swtmrHeader, startTime);
|
||||
LOS_SpinUnlockRestore(&cpu->swtmrSortLinkSpin, intSave);
|
||||
|
||||
return (taskExpirTime < swtmrExpirTime) ? taskExpirTime : swtmrExpirTime;
|
||||
}
|
||||
|
||||
UINT32 OsSortLinkGetTargetExpireTime(const SortLinkList *targetSortList)
|
||||
{
|
||||
UINT64 currTimes = OsGetCurrSchedTimeCycle();
|
||||
if (currTimes >= targetSortList->responseTime) {
|
||||
if (currTime >= targetSortList->responseTime) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (UINT32)(targetSortList->responseTime - currTimes) / OS_CYCLE_PER_TICK;
|
||||
return (UINT32)(targetSortList->responseTime - currTime);
|
||||
}
|
||||
|
||||
UINT32 OsSortLinkGetNextExpireTime(const SortLinkAttribute *sortLinkHeader)
|
||||
UINT64 OsSortLinkGetNextExpireTime(UINT64 currTime, const SortLinkAttribute *sortLinkHeader)
|
||||
{
|
||||
LOS_DL_LIST *head = (LOS_DL_LIST *)&sortLinkHeader->sortLink;
|
||||
|
||||
if (LOS_ListEmpty(head)) {
|
||||
return 0;
|
||||
return OS_SORT_LINK_INVALID_TIME;
|
||||
}
|
||||
|
||||
SortLinkList *listSorted = LOS_DL_LIST_ENTRY(head->pstNext, SortLinkList, sortLinkNode);
|
||||
return OsSortLinkGetTargetExpireTime(listSorted);
|
||||
return OsSortLinkGetTargetExpireTime(currTime, listSorted);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#include "los_spinlock.h"
|
||||
#include "los_swtmr_pri.h"
|
||||
#include "los_task_pri.h"
|
||||
#include "los_sched_pri.h"
|
||||
#include "los_tick.h"
|
||||
#include "los_vm_boot.h"
|
||||
#include "los_smp.h"
|
||||
@@ -72,6 +73,7 @@ LITE_OS_SEC_TEXT_INIT STATIC UINT32 EarliestInit(VOID)
|
||||
/* Must be placed at the beginning of the boot process */
|
||||
OsSetMainTask();
|
||||
OsCurrTaskSet(OsGetMainTask());
|
||||
OsSchedRunQueInit();
|
||||
|
||||
g_sysClock = OS_SYS_CLOCK;
|
||||
g_tickPerSecond = LOSCFG_BASE_CORE_TICK_PER_SECOND;
|
||||
|
||||
@@ -123,6 +123,7 @@ STATIC INLINE BOOL OsIsBadUserAddress(VADDR_T vaddr)
|
||||
return (vaddr >= USER_STACK_TOP_MAX);
|
||||
}
|
||||
|
||||
extern UINT32 OsGetRndOffset(INT32 randomDevFD);
|
||||
extern INT32 OsLoadELFFile(ELFLoadInfo *loadInfo);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -716,18 +716,18 @@ STATIC INT32 OsGetParamNum(CHAR *const *argv)
|
||||
return count;
|
||||
}
|
||||
|
||||
STATIC UINT32 OsGetRndOffset(const ELFLoadInfo *loadInfo)
|
||||
UINT32 OsGetRndOffset(INT32 randomDevFD)
|
||||
{
|
||||
UINT32 randomValue = 0;
|
||||
|
||||
#ifdef LOSCFG_ASLR
|
||||
if (read(loadInfo->randomDevFD, &randomValue, sizeof(UINT32)) == sizeof(UINT32)) {
|
||||
if (read(randomDevFD, &randomValue, sizeof(UINT32)) == sizeof(UINT32)) {
|
||||
randomValue &= RANDOM_MASK;
|
||||
} else {
|
||||
randomValue = (UINT32)random() & RANDOM_MASK;
|
||||
}
|
||||
#else
|
||||
(VOID)loadInfo;
|
||||
(VOID)randomDevFD;
|
||||
#endif
|
||||
|
||||
return ROUNDDOWN(randomValue, PAGE_SIZE);
|
||||
@@ -805,7 +805,7 @@ STATIC INT32 OsSetArgParams(ELFLoadInfo *loadInfo, CHAR *const *argv, CHAR *cons
|
||||
if (((UINT32)loadInfo->stackProt & (PROT_READ | PROT_WRITE)) != (PROT_READ | PROT_WRITE)) {
|
||||
return -ENOEXEC;
|
||||
}
|
||||
loadInfo->stackTopMax = USER_STACK_TOP_MAX - OsGetRndOffset(loadInfo);
|
||||
loadInfo->stackTopMax = USER_STACK_TOP_MAX - OsGetRndOffset(loadInfo->randomDevFD);
|
||||
loadInfo->stackBase = loadInfo->stackTopMax - USER_STACK_SIZE;
|
||||
loadInfo->stackSize = USER_STACK_SIZE;
|
||||
loadInfo->stackParamBase = loadInfo->stackTopMax - USER_PARAM_BYTE_MAX;
|
||||
@@ -963,7 +963,7 @@ STATIC INT32 OsLoadELFSegment(ELFLoadInfo *loadInfo)
|
||||
loadInfo->loadAddr = 0;
|
||||
|
||||
if (loadInfo->execInfo.elfEhdr.elfType == LD_ET_DYN) {
|
||||
loadBase = EXEC_MMAP_BASE + OsGetRndOffset(loadInfo);
|
||||
loadBase = EXEC_MMAP_BASE + OsGetRndOffset(loadInfo->randomDevFD);
|
||||
mapSize = OsGetAllocSize(elfPhdrTemp, loadInfo->execInfo.elfEhdr.elfPhNum);
|
||||
if (mapSize == 0) {
|
||||
PRINT_ERR("%s[%d], Failed to get allocation size of file: %s!\n", __FUNCTION__, __LINE__,
|
||||
@@ -1009,17 +1009,7 @@ STATIC INT32 OsLoadELFSegment(ELFLoadInfo *loadInfo)
|
||||
|
||||
STATIC VOID OsFlushAspace(ELFLoadInfo *loadInfo)
|
||||
{
|
||||
LosProcessCB *processCB = OsCurrProcessGet();
|
||||
|
||||
OsExecDestroyTaskGroup();
|
||||
|
||||
loadInfo->oldSpace = processCB->vmSpace;
|
||||
processCB->vmSpace = loadInfo->newSpace;
|
||||
processCB->vmSpace->heapBase += OsGetRndOffset(loadInfo);
|
||||
processCB->vmSpace->heapNow = processCB->vmSpace->heapBase;
|
||||
processCB->vmSpace->mapBase += OsGetRndOffset(loadInfo);
|
||||
processCB->vmSpace->mapSize = loadInfo->stackBase - processCB->vmSpace->mapBase;
|
||||
LOS_ArchMmuContextSwitch(&OsCurrProcessGet()->vmSpace->archMmu);
|
||||
loadInfo->oldSpace = OsExecProcessVmSpaceReplace(loadInfo->newSpace, loadInfo->stackBase, loadInfo->randomDevFD);
|
||||
}
|
||||
|
||||
STATIC VOID OsDeInitLoadInfo(ELFLoadInfo *loadInfo)
|
||||
@@ -1079,8 +1069,7 @@ INT32 OsLoadELFFile(ELFLoadInfo *loadInfo)
|
||||
|
||||
ret = OsLoadELFSegment(loadInfo);
|
||||
if (ret != LOS_OK) {
|
||||
OsCurrProcessGet()->vmSpace = loadInfo->oldSpace;
|
||||
LOS_ArchMmuContextSwitch(&OsCurrProcessGet()->vmSpace->archMmu);
|
||||
OsExecProcessVmSpaceRestore(loadInfo->oldSpace);
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
|
||||
@@ -697,7 +697,10 @@ LITE_OS_SEC_TEXT STATIC BOOL IsTaskAlive(UINT32 taskID)
|
||||
return FALSE;
|
||||
}
|
||||
tcb = OS_TCB_FROM_TID(taskID);
|
||||
if (!OsProcessIsUserMode(OS_PCB_FROM_PID(tcb->processID))) {
|
||||
if (!OsTaskIsUserMode(tcb)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (OsTaskIsUnused(tcb)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (OsTaskIsInactive(tcb)) {
|
||||
|
||||
@@ -28,19 +28,16 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/NuttX/NuttX.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_KERNEL_PIPE)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"//third_party/NuttX/drivers/pipes/fifo.c",
|
||||
"//third_party/NuttX/drivers/pipes/pipe.c",
|
||||
"//third_party/NuttX/drivers/pipes/pipe_common.c",
|
||||
]
|
||||
sources = NUTTX_DRIVERS_PIPES_SRC_FILES
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "//third_party/NuttX/drivers/pipes" ]
|
||||
include_dirs = NUTTX_DRIVERS_PIPES_INCLUDE_DIRS
|
||||
}
|
||||
|
||||
@@ -185,7 +185,6 @@ STATIC UINT32 OsPmSuspendSleep(LosPmCB *pm)
|
||||
LOS_SysSleepEnum mode;
|
||||
UINT32 prepare = 0;
|
||||
BOOL tickTimerStop = FALSE;
|
||||
UINT64 currTime;
|
||||
|
||||
ret = OsPmSuspendCheck(pm, &sysSuspendEarly, &deviceSuspend, &mode);
|
||||
if (ret != LOS_OK) {
|
||||
@@ -208,9 +207,8 @@ STATIC UINT32 OsPmSuspendSleep(LosPmCB *pm)
|
||||
|
||||
tickTimerStop = OsPmTickTimerStop(pm);
|
||||
if (!tickTimerStop) {
|
||||
currTime = OsGetCurrSchedTimeCycle();
|
||||
OsSchedResetSchedResponseTime(0);
|
||||
OsSchedUpdateExpireTime(currTime);
|
||||
OsSchedUpdateExpireTime();
|
||||
}
|
||||
|
||||
OsPmCpuSuspend(pm);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "trace_cnv.h"
|
||||
#include "los_init.h"
|
||||
#include "los_process.h"
|
||||
#include "los_sched_pri.h"
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
#include "los_mp.h"
|
||||
@@ -102,7 +103,7 @@ STATIC VOID OsTraceSetFrame(TraceEventFrame *frame, UINT32 eventType, UINTPTR id
|
||||
#ifdef LOSCFG_TRACE_FRAME_CORE_MSG
|
||||
frame->core.cpuId = ArchCurrCpuid();
|
||||
frame->core.hwiActive = OS_INT_ACTIVE ? TRUE : FALSE;
|
||||
frame->core.taskLockCnt = MIN(OsPercpuGet()->taskLockCnt, 0xF); /* taskLockCnt is 4 bits, max value = 0xF */
|
||||
frame->core.taskLockCnt = MIN(OsSchedLockCountGet(), 0xF); /* taskLockCnt is 4 bits, max value = 0xF */
|
||||
frame->core.paramCount = paramCount;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
MUSLDIR = "$LITEOSTHIRDPARTY/musl"
|
||||
OPTRTDIR = "$LITEOSTHIRDPARTY/optimized-routines"
|
||||
|
||||
import("//third_party/optimized-routines/optimized-routines.gni")
|
||||
import("$MUSLDIR/porting/liteos_a/kernel/musl.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_LIB_LIBC)
|
||||
@@ -54,13 +54,7 @@ kernel_module(module_name) {
|
||||
"$MUSLPORTINGDIR/src/string/strcpy.c",
|
||||
"$MUSLPORTINGDIR/src/string/strlen.c",
|
||||
]
|
||||
sources += [
|
||||
"$OPTRTDIR/string/arm/memchr.S",
|
||||
"$OPTRTDIR/string/arm/memcpy.S",
|
||||
"$OPTRTDIR/string/arm/strcmp.S",
|
||||
"$OPTRTDIR/string/arm/strcpy.c",
|
||||
"$OPTRTDIR/string/arm/strlen-armv6t2.S",
|
||||
]
|
||||
sources += OPTRT_STRING_ARM_SRC_FILES
|
||||
asmflags = [
|
||||
"-D__strlen_armv6t2=strlen",
|
||||
"-D__strcmp_arm=strcmp",
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/FreeBSD/FreeBSD.gni")
|
||||
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
@@ -38,7 +39,7 @@ kernel_module(module_name) {
|
||||
"src/los_seq_buf.c",
|
||||
]
|
||||
|
||||
sources += [ "$LITEOSTHIRDPARTY/FreeBSD/sys/libkern/crc32.c" ]
|
||||
sources += FREEBSD_SYS_LIBKERN_SRC_FILES
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
}
|
||||
|
||||
@@ -267,7 +267,7 @@ STATIC ssize_t TelnetWrite(struct file *file, const CHAR *buf, const size_t bufL
|
||||
if (telnetDev->clientFd != 0) {
|
||||
#ifdef LOSCFG_BASE_CORE_SWTMR_ENABLE
|
||||
/* DO NOT call blocking API in software timer task */
|
||||
if (((LosTaskCB*)OsCurrTaskGet())->taskEntry == (TSK_ENTRY_FUNC)OsSwtmrTask) {
|
||||
if (OsIsSwtmrTask(OsCurrTaskGet())) {
|
||||
TelnetUnlock();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "los_cpup_pri.h"
|
||||
#endif
|
||||
#include "los_hwi_pri.h"
|
||||
#include "los_sys_pri.h"
|
||||
#include "shcmd.h"
|
||||
|
||||
|
||||
|
||||
@@ -948,7 +948,6 @@ EXIT:
|
||||
int SysUserThreadDetach(unsigned int taskID)
|
||||
{
|
||||
unsigned int intSave;
|
||||
LosTaskCB *taskCB = NULL;
|
||||
unsigned int ret;
|
||||
|
||||
if (OS_TID_CHECK_INVALID(taskID)) {
|
||||
@@ -956,14 +955,13 @@ int SysUserThreadDetach(unsigned int taskID)
|
||||
}
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
taskCB = OS_TCB_FROM_TID(taskID);
|
||||
ret = OsUserTaskOperatePermissionsCheck(taskCB);
|
||||
ret = OsUserTaskOperatePermissionsCheck(OS_TCB_FROM_TID(taskID));
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
if (ret != LOS_OK) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = OsTaskDeleteUnsafe(taskCB, OS_PRO_EXIT_OK, intSave);
|
||||
ret = LOS_TaskDelete(taskID);
|
||||
if (ret != LOS_OK) {
|
||||
return ESRCH;
|
||||
}
|
||||
@@ -997,12 +995,13 @@ EXIT:
|
||||
|
||||
void SysUserExitGroup(int status)
|
||||
{
|
||||
OsTaskExitGroup((unsigned int)status);
|
||||
(void)status;
|
||||
OsProcessThreadGroupDestroy();
|
||||
}
|
||||
|
||||
void SysThreadExit(int status)
|
||||
{
|
||||
OsTaskToExit(OsCurrTaskGet(), (unsigned int)status);
|
||||
OsRunningTaskToExit(OsCurrTaskGet(), (unsigned int)status);
|
||||
}
|
||||
|
||||
int SysFutex(const unsigned int *uAddr, unsigned int flags, int val,
|
||||
|
||||
@@ -63,10 +63,42 @@ config("public_config_for_pressure") {
|
||||
cflags_cc = cflags
|
||||
}
|
||||
|
||||
# Note: The execution time of a single XXX_door.bin cannot exceed 90 seconds.
|
||||
group("unittest") {
|
||||
deps = []
|
||||
if (ohos_build_type == "debug") {
|
||||
if (LOSCFG_USER_TEST_FS_JFFS == true) {
|
||||
# basic test
|
||||
if (LOSCFG_USER_TEST_BASIC == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "basic:liteos_a_basic_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "basic:liteos_a_basic_unittest" ]
|
||||
}
|
||||
}
|
||||
|
||||
# drivers test
|
||||
if (LOSCFG_USER_TEST_DRIVERS == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "drivers:liteos_a_drivers_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "drivers:liteos_a_drivers_unittest" ]
|
||||
}
|
||||
}
|
||||
|
||||
# extended test
|
||||
if (LOSCFG_USER_TEST_EXTENDED == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "extended:liteos_a_extended_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "extended:liteos_a_extended_unittest" ]
|
||||
}
|
||||
}
|
||||
|
||||
# fs test
|
||||
if (LOSCFG_USER_TEST_FS == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "fs:liteos_a_fs_unittest_door" ]
|
||||
}
|
||||
@@ -77,264 +109,46 @@ group("unittest") {
|
||||
deps += [ "fs:liteos_a_fs_unittest_pressure" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_FS_VFAT == true) {
|
||||
|
||||
# libc test
|
||||
if (LOSCFG_USER_TEST_LIBC == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "fs/vfat:liteos_a_fs_vfat_unittest_door" ]
|
||||
deps += [ "libc:liteos_a_libc_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "fs/vfat:liteos_a_fs_vfat_unittest" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_HIGH) {
|
||||
deps += [ "fs/vfat:liteos_a_fs_vfat_unittest_pressure" ]
|
||||
deps += [ "libc:liteos_a_libc_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_FS_PROC == true) {
|
||||
|
||||
# net test
|
||||
if (LOSCFG_USER_TEST_NET == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "fs/proc:liteos_a_fs_procfs_unittest_door" ]
|
||||
deps += [ "net:liteos_a_net_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "fs/proc:liteos_a_fs_procfs_unittest" ]
|
||||
deps += [ "net:liteos_a_net_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_MISC == true) {
|
||||
|
||||
# process test
|
||||
if (LOSCFG_USER_TEST_PROCESS_THREAD == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "misc:liteos_a_misc_unittest_door" ]
|
||||
deps += [ "process/basic:liteos_a_process_basic_unittest_door" ]
|
||||
deps += [ "process/lock:liteos_a_process_lock_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "misc:liteos_a_misc_unittest" ]
|
||||
deps += [ "process/basic:liteos_a_process_basic_unittest" ]
|
||||
deps += [ "process/lock:liteos_a_process_lock_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_DRIVERS_HID == true) {
|
||||
|
||||
# security test
|
||||
if (LOSCFG_USER_TEST_SECURITY == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "drivers/hid:liteos_a_drivers_hid_unittest_door" ]
|
||||
deps += [ "security:liteos_a_security_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "drivers/hid:liteos_a_drivers_hid_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_DRIVERS_STORAGE == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "drivers/storage:liteos_a_drivers_storage_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "drivers/storage:liteos_a_drivers_storage_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_DYNLOAD == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "dynload:liteos_a_dynload_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "dynload:liteos_a_dynload_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_EXC == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "exc:liteos_a_exc_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "exc:liteos_a_exc_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_IO == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "IO:liteos_a_io_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "IO:liteos_a_io_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_IPC == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "IPC:liteos_a_ipc_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "IPC:liteos_a_ipc_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LITEIPC == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "liteipc:liteos_a_liteipc_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "liteipc:liteos_a_liteipc_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_MEM_SHM == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "mem/shm:liteos_a_mem_shm_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "mem/shm:liteos_a_mem_shm_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_MEM_VM == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "mem/vm:liteos_a_mem_vm_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "mem/vm:liteos_a_mem_vm_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_NET_NETDB == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "net/netdb:liteos_a_net_netdb_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "net/netdb:liteos_a_net_netdb_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_NET_RESOLV == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "net/resolv:liteos_a_net_resolv_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "net/resolv:liteos_a_net_resolv_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_NET_SOCKET == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "net/socket:liteos_a_net_socket_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "net/socket:liteos_a_net_socket_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_POSIX_MEM == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "posix/mem:liteos_a_posix_mem_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "posix/mem:liteos_a_posix_mem_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_POSIX_MQUEUE == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "posix/mqueue:liteos_a_posix_mqueue_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "posix/mqueue:liteos_a_posix_mqueue_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_POSIX_PTHREAD == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "posix/pthread:liteos_a_posix_pthread_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "posix/pthread:liteos_a_posix_pthread_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_MUTEX == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "process/mutex:liteos_a_mutex_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "process/mutex:liteos_a_mutex_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_PROCESS == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "process/process:liteos_a_process_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "process/process:liteos_a_process_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_PTHREAD == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "process/pthread:liteos_a_pthread_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "process/pthread:liteos_a_pthread_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_RWLOCK == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "process/rwlock:liteos_a_rwlock_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "process/rwlock:liteos_a_rwlock_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_SPINLOCK == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "process/spinlock:liteos_a_spinlock_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "process/spinlock:liteos_a_spinlock_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_SECURITY_REUGID == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "security/reugid:liteos_a_security_reugid_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "security/reugid:liteos_a_security_reugid_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_SECURITY_CAPABILITY == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps +=
|
||||
[ "security/capability:liteos_a_security_capability_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "security/capability:liteos_a_security_capability_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_SECURITY_VID == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "security/vid:liteos_a_security_vid_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "security/vid:liteos_a_security_vid_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_UTIL == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "util:liteos_a_util_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "util:liteos_a_util_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_TIME_TIMER == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "time/timer:liteos_a_time_timer_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "time/timer:liteos_a_time_timer_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_TIME_CLOCK == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "time/clock:liteos_a_time_clock_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "time/clock:liteos_a_time_clock_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_SYS == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "sys:liteos_a_sys_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "sys:liteos_a_sys_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_SIGNAL == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "signal:liteos_a_signal_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "signal:liteos_a_signal_unittest" ]
|
||||
}
|
||||
}
|
||||
if (LOSCFG_USER_TEST_TRACE == true) {
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
deps += [ "trace:liteos_a_trace_unittest_door" ]
|
||||
}
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
deps += [ "trace:liteos_a_trace_unittest" ]
|
||||
deps += [ "security:liteos_a_security_unittest" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//build/lite/config/test.gni")
|
||||
import("../config.gni")
|
||||
|
||||
common_include_dirs = [
|
||||
"//third_party/googletest/googletest/include",
|
||||
"../common/include",
|
||||
"../IO",
|
||||
]
|
||||
|
||||
sources_entry = [
|
||||
"../common/osTest.cpp",
|
||||
"io_test.cpp",
|
||||
]
|
||||
|
||||
sources_smoke = [
|
||||
"smoke/IO_test_005.cpp",
|
||||
"smoke/IO_test_008.cpp",
|
||||
"smoke/IO_test_010.cpp",
|
||||
"smoke/IO_test_013.cpp",
|
||||
]
|
||||
|
||||
sources_full = [
|
||||
"full/IO_test_confstr_001.cpp",
|
||||
"full/IO_test_dcgettext_001.cpp",
|
||||
"full/IO_test_dcgettext_002.cpp",
|
||||
"full/IO_test_dcngettext_001.cpp",
|
||||
"full/IO_test_dcngettext_002.cpp",
|
||||
"full/IO_test_dngettext_001.cpp",
|
||||
"full/IO_test_dngettext_002.cpp",
|
||||
"full/IO_test_duplocale_001.cpp",
|
||||
"full/IO_test_locale_001.cpp",
|
||||
"full/IO_test_locale_002.cpp",
|
||||
"full/IO_test_ngettext_001.cpp",
|
||||
"full/IO_test_nl_langinfo_001.cpp",
|
||||
"full/IO_test_nl_langinfo_l_001.cpp",
|
||||
"full/IO_test_strcasecmp_l_001.cpp",
|
||||
"full/IO_test_strcasecmp_l_002.cpp",
|
||||
"full/IO_test_strfmon_l_001.cpp",
|
||||
"full/IO_test_strfmon_l_002.cpp",
|
||||
"full/It_locale_localeconv_001.cpp",
|
||||
"full/It_stdio_fputws_001.cpp",
|
||||
"full/It_stdio_fwprintf_001.cpp",
|
||||
"full/It_stdio_getc_unlocked_001.cpp",
|
||||
"full/It_stdio_hasmntopt_001.cpp",
|
||||
"full/It_stdio_mblen_001.cpp",
|
||||
"full/It_stdio_mbrlen_001.cpp",
|
||||
"full/It_stdio_putwc_001.cpp",
|
||||
"full/It_stdio_readv_001.cpp",
|
||||
"full/It_stdio_rindex_001.cpp",
|
||||
"full/It_stdio_setlogmask_001.cpp",
|
||||
"full/It_stdlib_gcvt_001.cpp",
|
||||
"full/It_stdlib_poll_002.cpp",
|
||||
"full/It_stdlib_poll_003.cpp",
|
||||
"full/IO_test_gettext_001.cpp",
|
||||
"full/IO_test_strncasecmp_l_001.cpp",
|
||||
"full/IO_test_strncasecmp_l_002.cpp",
|
||||
"full/IO_test_ppoll_001.cpp",
|
||||
"full/IO_test_ppoll_002.cpp",
|
||||
"full/IO_test_ppoll_003.cpp",
|
||||
"full/IO_test_pselect_001.cpp",
|
||||
"full/IO_test_pselect_002.cpp",
|
||||
"full/IO_test_epoll_001.cpp",
|
||||
"full/IO_test_epoll_002.cpp",
|
||||
]
|
||||
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
unittest("liteos_a_io_unittest_door") {
|
||||
output_extension = "bin"
|
||||
output_dir = "$root_out_dir/test/unittest/kernel"
|
||||
include_dirs = common_include_dirs
|
||||
sources = sources_entry
|
||||
sources += sources_smoke
|
||||
sources_full = []
|
||||
sources += sources_full
|
||||
configs = [ "..:public_config_for_door" ]
|
||||
deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
unittest("liteos_a_io_unittest") {
|
||||
output_extension = "bin"
|
||||
output_dir = "$root_out_dir/test/unittest/kernel"
|
||||
include_dirs = common_include_dirs
|
||||
sources = sources_entry
|
||||
sources += sources_smoke
|
||||
sources += sources_full
|
||||
configs = [ "..:public_config_for_all" ]
|
||||
deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
@@ -28,28 +27,11 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//build/lite/config/test.gni")
|
||||
import("../config.gni")
|
||||
|
||||
common_include_dirs = [
|
||||
"//third_party/googletest/googletest/include",
|
||||
"../common/include",
|
||||
"../dynload",
|
||||
]
|
||||
|
||||
sources_entry = [
|
||||
"../common/osTest.cpp",
|
||||
"dynload_test.cpp",
|
||||
]
|
||||
|
||||
sources_smoke = [
|
||||
"smoke/dynload_test_002.cpp",
|
||||
"smoke/dynload_test_004.cpp",
|
||||
]
|
||||
|
||||
sources_full = []
|
||||
import("//kernel/liteos_a/testsuites/unittest/config.gni")
|
||||
import("./config.gni")
|
||||
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
unittest("liteos_a_dynload_unittest_door") {
|
||||
unittest("liteos_a_basic_unittest_door") {
|
||||
output_extension = "bin"
|
||||
output_dir = "$root_out_dir/test/unittest/kernel"
|
||||
include_dirs = common_include_dirs
|
||||
@@ -63,7 +45,7 @@ if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_LOW) {
|
||||
}
|
||||
|
||||
if (LOSCFG_USER_TEST_LEVEL >= TEST_LEVEL_MIDDLE) {
|
||||
unittest("liteos_a_dynload_unittest") {
|
||||
unittest("liteos_a_basic_unittest") {
|
||||
output_extension = "bin"
|
||||
output_dir = "$root_out_dir/test/unittest/kernel"
|
||||
include_dirs = common_include_dirs
|
||||
76
testsuites/unittest/basic/config.gni
Normal file
76
testsuites/unittest/basic/config.gni
Normal file
@@ -0,0 +1,76 @@
|
||||
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//build/lite/config/test.gni")
|
||||
import("//kernel/liteos_a/testsuites/unittest/config.gni")
|
||||
|
||||
common_include_dirs = [
|
||||
"//third_party/googletest/googletest/include",
|
||||
"../common/include",
|
||||
]
|
||||
|
||||
sources_entry = [ "../common/osTest.cpp" ]
|
||||
|
||||
sources_smoke = []
|
||||
|
||||
sources_full = []
|
||||
|
||||
# dynload module
|
||||
if (LOSCFG_USER_TEST_DYNLOAD == true) {
|
||||
import("./dynload/config.gni")
|
||||
common_include_dirs += dynload_include_dirs
|
||||
sources_entry += dynload_sources_entry
|
||||
sources_smoke += dynload_sources_smoke
|
||||
sources_full += dynload_sources_full
|
||||
}
|
||||
|
||||
# exc module
|
||||
if (LOSCFG_USER_TEST_EXC == true) {
|
||||
import("./exc/config.gni")
|
||||
common_include_dirs += exc_include_dirs
|
||||
sources_entry += exc_sources_entry
|
||||
sources_smoke += exc_sources_smoke
|
||||
sources_full += exc_sources_full
|
||||
}
|
||||
|
||||
# mem module
|
||||
if (LOSCFG_USER_TEST_MEM_SHM == true) {
|
||||
import("./mem/shm/config.gni")
|
||||
common_include_dirs += mem_shm_include_dirs
|
||||
sources_entry += mem_shm_sources_entry
|
||||
sources_smoke += mem_shm_sources_smoke
|
||||
sources_full += mem_shm_sources_full
|
||||
}
|
||||
|
||||
if (LOSCFG_USER_TEST_MEM_VM == true) {
|
||||
import("./mem/vm/config.gni")
|
||||
common_include_dirs += mem_vm_include_dirs
|
||||
sources_entry += mem_vm_sources_entry
|
||||
sources_smoke += mem_vm_sources_smoke
|
||||
sources_full += mem_vm_sources_full
|
||||
}
|
||||
40
testsuites/unittest/basic/dynload/config.gni
Normal file
40
testsuites/unittest/basic/dynload/config.gni
Normal file
@@ -0,0 +1,40 @@
|
||||
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/testsuites/unittest/config.gni")
|
||||
|
||||
dynload_include_dirs = [ "$TEST_UNITTEST_DIR/basic/dynload" ]
|
||||
|
||||
dynload_sources_entry = [ "$TEST_UNITTEST_DIR/basic/dynload/dynload_test.cpp" ]
|
||||
|
||||
dynload_sources_smoke = [
|
||||
"$TEST_UNITTEST_DIR/basic/dynload/smoke/dynload_test_002.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/dynload/smoke/dynload_test_004.cpp",
|
||||
]
|
||||
|
||||
dynload_sources_full = []
|
||||
44
testsuites/unittest/basic/exc/config.gni
Normal file
44
testsuites/unittest/basic/exc/config.gni
Normal file
@@ -0,0 +1,44 @@
|
||||
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/testsuites/unittest/config.gni")
|
||||
|
||||
exc_include_dirs = [ "$TEST_UNITTEST_DIR/basic/exc" ]
|
||||
|
||||
exc_sources_entry = [ "$TEST_UNITTEST_DIR/basic/exc/exc_test.cpp" ]
|
||||
|
||||
exc_sources_smoke = [
|
||||
"$TEST_UNITTEST_DIR/basic/exc/smoke/it_test_exc_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/exc/smoke/it_test_exc_002.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/exc/smoke/it_test_exc_003.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/exc/smoke/it_test_exc_004.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/exc/smoke/it_test_exc_005.cpp",
|
||||
]
|
||||
|
||||
exc_sources_full =
|
||||
[ "$TEST_UNITTEST_DIR/basic/exc/full/it_test_fexecve_001.cpp" ]
|
||||
52
testsuites/unittest/basic/mem/shm/config.gni
Normal file
52
testsuites/unittest/basic/mem/shm/config.gni
Normal file
@@ -0,0 +1,52 @@
|
||||
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/testsuites/unittest/config.gni")
|
||||
|
||||
mem_shm_include_dirs = [ "$TEST_UNITTEST_DIR/basic/mem/shm" ]
|
||||
|
||||
mem_shm_sources_entry = [ "$TEST_UNITTEST_DIR/basic/mem/shm/mem_shm_test.cpp" ]
|
||||
|
||||
mem_shm_sources_smoke =
|
||||
[ "$TEST_UNITTEST_DIR/basic/mem/shm/smoke/shm_test_011.cpp" ]
|
||||
|
||||
mem_shm_sources_full = [
|
||||
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_002.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_003.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_004.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_005.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_006.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_007.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_008.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_009.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_010.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_012.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_013.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/shm/full/shm_test_014.cpp",
|
||||
]
|
||||
53
testsuites/unittest/basic/mem/vm/config.gni
Normal file
53
testsuites/unittest/basic/mem/vm/config.gni
Normal file
@@ -0,0 +1,53 @@
|
||||
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/testsuites/unittest/config.gni")
|
||||
|
||||
mem_vm_include_dirs = [ "$TEST_UNITTEST_DIR/basic/mem/vm" ]
|
||||
|
||||
mem_vm_sources_entry = [ "$TEST_UNITTEST_DIR/basic/mem/vm/mem_vm_test.cpp" ]
|
||||
|
||||
mem_vm_sources_smoke = [
|
||||
"$TEST_UNITTEST_DIR/basic/mem/vm/smoke/mmap_test_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/vm/smoke/mmap_test_002.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/vm/smoke/mmap_test_003.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/vm/smoke/mmap_test_004.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/vm/smoke/mmap_test_005.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/vm/smoke/mmap_test_006.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/vm/smoke/mmap_test_007.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/vm/smoke/mmap_test_008.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/vm/smoke/mmap_test_009.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/vm/smoke/mmap_test_010.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/vm/smoke/mprotect_test_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/vm/smoke/mremap_test_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/vm/smoke/oom_test_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/vm/smoke/open_wmemstream_test_001.cpp",
|
||||
"$TEST_UNITTEST_DIR/basic/mem/vm/smoke/user_copy_test_001.cpp",
|
||||
]
|
||||
|
||||
mem_vm_sources_full = []
|
||||
@@ -5,15 +5,15 @@
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
@@ -27,6 +27,8 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
TEST_UNITTEST_DIR = rebase_path(".")
|
||||
|
||||
TEST_LEVEL_LOW = 1
|
||||
TEST_LEVEL_MIDDLE = 3
|
||||
TEST_LEVEL_HIGH = 5
|
||||
@@ -42,36 +44,83 @@ LOSCFG_USER_TEST_LEVEL = TEST_LEVEL_HIGH
|
||||
# "disable": those testsuites is disable
|
||||
LOSCFG_USER_TEST_SMP = "default"
|
||||
|
||||
LOSCFG_USER_TEST_MISC = true
|
||||
LOSCFG_USER_TEST_DRIVERS_HID = true
|
||||
LOSCFG_USER_TEST_DRIVERS_STORAGE = true
|
||||
########## basic test ##########
|
||||
# Control switch for basic function test
|
||||
LOSCFG_USER_TEST_BASIC = true
|
||||
|
||||
# Module list
|
||||
LOSCFG_USER_TEST_DYNLOAD = true
|
||||
LOSCFG_USER_TEST_EXC = true
|
||||
LOSCFG_USER_TEST_MEM_SHM = true
|
||||
LOSCFG_USER_TEST_MEM_VM = true
|
||||
|
||||
########## process test ##########
|
||||
# Control switch for process&pthread function test
|
||||
LOSCFG_USER_TEST_PROCESS_THREAD = true
|
||||
|
||||
# Module list
|
||||
LOSCFG_USER_TEST_MUTEX = true
|
||||
LOSCFG_USER_TEST_PROCESS = true
|
||||
LOSCFG_USER_TEST_PTHREAD = true
|
||||
LOSCFG_USER_TEST_RWLOCK = true
|
||||
LOSCFG_USER_TEST_SPINLOCK = true
|
||||
|
||||
########## extended test ##########
|
||||
# Control switch for extended function test
|
||||
LOSCFG_USER_TEST_EXTENDED = true
|
||||
|
||||
# Module list
|
||||
LOSCFG_USER_TEST_IPC = false
|
||||
LOSCFG_USER_TEST_LITEIPC = false
|
||||
LOSCFG_USER_TEST_SIGNAL = true
|
||||
LOSCFG_USER_TEST_TRACE = false
|
||||
|
||||
########## drivers test ##########
|
||||
# Control switch for drivers function test
|
||||
LOSCFG_USER_TEST_DRIVERS = true
|
||||
|
||||
# Module list
|
||||
LOSCFG_USER_TEST_DRIVERS_HID = true
|
||||
LOSCFG_USER_TEST_DRIVERS_STORAGE = true
|
||||
|
||||
########## fs test ##########
|
||||
# Control switch for fs function test
|
||||
LOSCFG_USER_TEST_FS = true
|
||||
|
||||
# Module list
|
||||
LOSCFG_USER_TEST_FS_JFFS = false
|
||||
LOSCFG_USER_TEST_FS_PROC = false
|
||||
LOSCFG_USER_TEST_FS_VFAT = false
|
||||
|
||||
########## libc test ##########
|
||||
# Control switch for libc & posix function test
|
||||
LOSCFG_USER_TEST_LIBC = true
|
||||
|
||||
# Module list
|
||||
LOSCFG_USER_TEST_IO = true
|
||||
LOSCFG_USER_TEST_IPC = false
|
||||
LOSCFG_USER_TEST_LITEIPC = false
|
||||
LOSCFG_USER_TEST_MEM_VM = true
|
||||
LOSCFG_USER_TEST_MEM_SHM = true
|
||||
LOSCFG_USER_TEST_NET_NETDB = true
|
||||
LOSCFG_USER_TEST_NET_RESOLV = true
|
||||
LOSCFG_USER_TEST_NET_SOCKET = true
|
||||
LOSCFG_USER_TEST_POSIX_PTHREAD = false
|
||||
LOSCFG_USER_TEST_POSIX_MQUEUE = true
|
||||
LOSCFG_USER_TEST_MISC = true
|
||||
LOSCFG_USER_TEST_POSIX_MEM = true
|
||||
LOSCFG_USER_TEST_SPINLOCK = true
|
||||
LOSCFG_USER_TEST_RWLOCK = true
|
||||
LOSCFG_USER_TEST_PTHREAD = true
|
||||
LOSCFG_USER_TEST_PROCESS = true
|
||||
LOSCFG_USER_TEST_MUTEX = true
|
||||
LOSCFG_USER_TEST_SECURITY_CAPABILITY = true
|
||||
LOSCFG_USER_TEST_SECURITY_VID = true
|
||||
LOSCFG_USER_TEST_SECURITY_REUGID = true
|
||||
LOSCFG_USER_TEST_SIGNAL = true
|
||||
LOSCFG_USER_TEST_POSIX_MQUEUE = true
|
||||
LOSCFG_USER_TEST_POSIX_PTHREAD = false
|
||||
LOSCFG_USER_TEST_SYS = true
|
||||
LOSCFG_USER_TEST_TIME_CLOCK = true
|
||||
LOSCFG_USER_TEST_TIME_TIMER = true
|
||||
LOSCFG_USER_TEST_UTIL = true
|
||||
LOSCFG_USER_TEST_TRACE = false
|
||||
|
||||
########## net test ##########
|
||||
# Control switch for network function test
|
||||
LOSCFG_USER_TEST_NET = true
|
||||
|
||||
# Module list
|
||||
LOSCFG_USER_TEST_NET_NETDB = true
|
||||
LOSCFG_USER_TEST_NET_RESOLV = true
|
||||
LOSCFG_USER_TEST_NET_SOCKET = true
|
||||
|
||||
########## security test ##########
|
||||
# Control switch for security function test
|
||||
LOSCFG_USER_TEST_SECURITY = true
|
||||
|
||||
# Module list
|
||||
LOSCFG_USER_TEST_SECURITY_CAPABILITY = true
|
||||
LOSCFG_USER_TEST_SECURITY_REUGID = true
|
||||
LOSCFG_USER_TEST_SECURITY_VID = true
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user