Compare commits
136 Commits
weekly_202
...
monthly_20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16fdbdf650 | ||
|
|
bee3d97163 | ||
|
|
398f4a6ada | ||
|
|
19553f73e1 | ||
|
|
de24efadfa | ||
|
|
0057fb0dd5 | ||
|
|
bcf7e8ee02 | ||
|
|
0b9cac2cd3 | ||
|
|
9958f647f5 | ||
|
|
fa6b2d352c | ||
|
|
7f57e11ef9 | ||
|
|
1097d41a40 | ||
|
|
90d6ff9a6f | ||
|
|
eebe85fe31 | ||
|
|
b126f1cb5f | ||
|
|
639160f517 | ||
|
|
7fef6ac8d9 | ||
|
|
2f44d18618 | ||
|
|
fbc81cd821 | ||
|
|
a6e17fea9b | ||
|
|
18f7ab1380 | ||
|
|
d205cfa65a | ||
|
|
11b35fe795 | ||
|
|
b086195e97 | ||
|
|
b90531e366 | ||
|
|
a1a6286500 | ||
|
|
e1027b5902 | ||
|
|
b9a445ca44 | ||
|
|
338044cd9c | ||
|
|
18a2fc8e8d | ||
|
|
fa0e803ac9 | ||
|
|
4f641cc145 | ||
|
|
9063a45d5a | ||
|
|
4b4e1264f5 | ||
|
|
3f5307e7bb | ||
|
|
eddcb840d3 | ||
|
|
a0e205eb0a | ||
|
|
707028dfe1 | ||
|
|
49d72afc8e | ||
|
|
c11ff67869 | ||
|
|
b6a49e7c89 | ||
|
|
e847c8b468 | ||
|
|
faeeaf294c | ||
|
|
b2caf46b4e | ||
|
|
ccbc55df60 | ||
|
|
7f4294af00 | ||
|
|
4a63bacc47 | ||
|
|
ee6f3f0d79 | ||
|
|
e05300cdf0 | ||
|
|
b8951e2cd9 | ||
|
|
e3ce27536c | ||
|
|
a6c5309a5f | ||
|
|
65d5526c70 | ||
|
|
33c4e194b8 | ||
|
|
1b11caa45c | ||
|
|
6ba17fc862 | ||
|
|
f61ecd7669 | ||
|
|
ec3c8be6ee | ||
|
|
3cd28f32ca | ||
|
|
4b6a6e806f | ||
|
|
216c124854 | ||
|
|
e26d969ca8 | ||
|
|
45f66359cd | ||
|
|
5b87a530f5 | ||
|
|
5280a45434 | ||
|
|
f7a8630584 | ||
|
|
cb67dd5498 | ||
|
|
6d8cef40c8 | ||
|
|
41b80ad20a | ||
|
|
47fac7158e | ||
|
|
6c0e1b1f04 | ||
|
|
b06520ac7c | ||
|
|
e4cad073a9 | ||
|
|
b151fa6b65 | ||
|
|
40329e182c | ||
|
|
0f38ecb863 | ||
|
|
3f43438017 | ||
|
|
bc70db58a7 | ||
|
|
ac9399d2b7 | ||
|
|
89850d0715 | ||
|
|
86be540829 | ||
|
|
0f75bf01a6 | ||
|
|
395c0be775 | ||
|
|
a40f8383ee | ||
|
|
87a7df48b8 | ||
|
|
2df39a7e51 | ||
|
|
9f8127cc54 | ||
|
|
2f1ed39bc1 | ||
|
|
0770e5f972 | ||
|
|
0fb16312dc | ||
|
|
9a030d6930 | ||
|
|
29dde5d752 | ||
|
|
b797f50596 | ||
|
|
913d22bf83 | ||
|
|
3824d1e9e4 | ||
|
|
7941b93d1c | ||
|
|
d376efbe46 | ||
|
|
64ddb1ff07 | ||
|
|
f02d40d25d | ||
|
|
672bc729a6 | ||
|
|
31403e0e45 | ||
|
|
456d255a81 | ||
|
|
8c44c82723 | ||
|
|
4c024f757e | ||
|
|
59329ce7c6 | ||
|
|
be68dc8bca | ||
|
|
74f8d3aa07 | ||
|
|
dc479fb7bd | ||
|
|
91bdcbd3c2 | ||
|
|
422f22f5d2 | ||
|
|
6c0865dd46 | ||
|
|
0257a0a14f | ||
|
|
046d8defdf | ||
|
|
7938d2e569 | ||
|
|
3d00a7d23a | ||
|
|
e3cd485db5 | ||
|
|
0e3936c4f8 | ||
|
|
95248d4482 | ||
|
|
1ecda9c033 | ||
|
|
9018eab20f | ||
|
|
e6bdfbb7a5 | ||
|
|
a28fcee1c5 | ||
|
|
f47da44b39 | ||
|
|
b37a7b7929 | ||
|
|
8e356c99c7 | ||
|
|
a1ae2ecc13 | ||
|
|
b7d624208b | ||
|
|
87b8e6b0ad | ||
|
|
321018cee0 | ||
|
|
b0c046f8ac | ||
|
|
f2861ddfb4 | ||
|
|
48f5481c65 | ||
|
|
b65897d517 | ||
|
|
6c4e4b16ab | ||
|
|
a0ad1a4333 | ||
|
|
f504cc9145 |
@@ -1,6 +1,6 @@
|
||||
### 相关的Issue
|
||||
|
||||
|
||||
|
||||
### 原因(目的、解决的问题等)
|
||||
|
||||
|
||||
@@ -8,5 +8,14 @@
|
||||
|
||||
|
||||
### 测试用例(新增、改动、可能影响的功能)
|
||||
|
||||
|
||||
|
||||
|
||||
### 是否需要同步至release(如:3.0LTS ... )分支?
|
||||
|
||||
必须选择一项(在MarkDown模式下用[x]替换[ ]即可勾选对应选项):
|
||||
- [ ] 是,需要同步的分支:
|
||||
- [ ] 否
|
||||
|
||||
理由:
|
||||
|
||||
|
||||
|
||||
38
BUILD.gn
38
BUILD.gn
@@ -35,6 +35,7 @@ declare_args() {
|
||||
tee_enable = false
|
||||
liteos_name = "OHOS_Image"
|
||||
liteos_skip_make = false
|
||||
liteos_is_mini = false
|
||||
}
|
||||
|
||||
tee = ""
|
||||
@@ -75,7 +76,6 @@ generate_notice_file("kernel_notice_file") {
|
||||
"$LITEOSTHIRDPARTY/musl",
|
||||
"$LITEOSTHIRDPARTY/zlib",
|
||||
"$LITEOSTHIRDPARTY/FatFs",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel",
|
||||
"$LITEOSTHIRDPARTY/lwip",
|
||||
"$LITEOSTHIRDPARTY/NuttX",
|
||||
"$LITEOSTHIRDPARTY/mtd-utils",
|
||||
@@ -129,7 +129,9 @@ config("stdinc_config") {
|
||||
"-isystem",
|
||||
std_include,
|
||||
]
|
||||
cflags += [ "-nostdinc" ]
|
||||
if (!defined(LOSCFG_LIBC_NEWLIB)) {
|
||||
cflags += [ "-nostdinc" ]
|
||||
}
|
||||
asmflags = cflags
|
||||
}
|
||||
|
||||
@@ -290,6 +292,7 @@ group("modules") {
|
||||
"security",
|
||||
"shell",
|
||||
"syscall",
|
||||
"testsuites/kernel:kernel_test",
|
||||
]
|
||||
|
||||
deps += [
|
||||
@@ -315,13 +318,17 @@ group("kernel") {
|
||||
}
|
||||
|
||||
group("liteos_a") {
|
||||
deps = [
|
||||
":apps",
|
||||
":kernel",
|
||||
":make",
|
||||
":tests",
|
||||
"//prebuilts/lite/sysroot/build:strip",
|
||||
]
|
||||
deps = [ ":kernel" ]
|
||||
if (!liteos_is_mini) {
|
||||
deps += [
|
||||
":apps",
|
||||
":tests",
|
||||
"//prebuilts/lite/sysroot/build:strip",
|
||||
]
|
||||
if (liteos_skip_make == false) {
|
||||
deps += [ ":make" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
executable("liteos") {
|
||||
@@ -337,6 +344,17 @@ executable("liteos") {
|
||||
"-Wl,--no-eh-frame-hdr",
|
||||
]
|
||||
|
||||
if (defined(LOSCFG_LIBC_NEWLIB)) {
|
||||
ldflags += [
|
||||
"-Wl,--wrap=_free_r",
|
||||
"-Wl,--wrap,_malloc_usable_size_r",
|
||||
"-Wl,--wrap,_malloc_r",
|
||||
"-Wl,--wrap,_memalign_r",
|
||||
"-Wl,--wrap,_realloc_r",
|
||||
"-Wl,--wrap,_fseeko_r",
|
||||
]
|
||||
ldflags -= [ "-nostdlib" ]
|
||||
}
|
||||
libgcc = exec_script("//build/lite/run_shell_cmd.py",
|
||||
[ "$cc -print-libgcc-file-name" ],
|
||||
"trim string")
|
||||
@@ -348,7 +366,7 @@ executable("liteos") {
|
||||
} else {
|
||||
ldflags +=
|
||||
[ "-Wl,-T" + rebase_path("tools/build/liteos.ld", root_build_dir) ]
|
||||
ldflags += [ "-Wl,-nostartfiles" ]
|
||||
ldflags += [ "-nostartfiles" ]
|
||||
inputs = [ "tools/build/liteos.ld" ]
|
||||
}
|
||||
|
||||
|
||||
6
Kconfig
6
Kconfig
@@ -189,7 +189,7 @@ config DEBUG_VERSION
|
||||
It also means you do not want to use debug modules, like shell,telnet,tftp,nfs and
|
||||
memory check, etc.
|
||||
If you select this option that means you enable a debug version for LiteOS.
|
||||
That means you want a opposite behaviour compared to release version.
|
||||
That means you want an opposite behaviour compared to release version.
|
||||
|
||||
config DEBUG_KERNEL
|
||||
bool "Enable Debug LiteOS Kernel Resource"
|
||||
@@ -198,7 +198,7 @@ config DEBUG_KERNEL
|
||||
help
|
||||
If you select this option that means you enable debugging kernel resource.
|
||||
It also means you want to get queue, mutex, semaphore, memory debug information.
|
||||
That means you want a opposite behaviour compared to release version.
|
||||
That means you want an opposite behaviour compared to release version.
|
||||
|
||||
config DEBUG_QUEUE
|
||||
bool "Enable Queue Debugging"
|
||||
@@ -265,7 +265,7 @@ config MEM_LEAKCHECK
|
||||
default n
|
||||
depends on DEBUG_VERSION && MEM_DEBUG
|
||||
help
|
||||
Answer Y to enable record the LR of Function call stack of Mem operation, it can check the mem leak through the infomations of mem node.
|
||||
Answer Y to enable record the LR of Function call stack of Mem operation, it can check the mem leak through the informations of mem node.
|
||||
config BASE_MEM_NODE_INTEGRITY_CHECK
|
||||
bool "Enable integrity check or not"
|
||||
default n
|
||||
|
||||
2
Makefile
2
Makefile
@@ -97,7 +97,7 @@ Targets:
|
||||
cleanall: clean all build outputs
|
||||
all: make liteos kernel image and rootfs image (Default target)
|
||||
$(APPS): build all apps
|
||||
$(ROOTFS): make a original rootfs image
|
||||
$(ROOTFS): make an original rootfs image
|
||||
$(LITEOS_LIBS_TARGET): compile all kernel modules (libraries)
|
||||
$(LITEOS_TARGET): make liteos kernel image
|
||||
update_config: update product kernel config (use menuconfig)
|
||||
|
||||
9
OAT.xml
9
OAT.xml
@@ -12,9 +12,10 @@
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
This is the configuration file template for OpenHarmony OSS Audit Tool, please copy it to your project root dir and modify it refer to OpenHarmony/tools_oat/README.
|
||||
|
||||
<!--
|
||||
This is the configuration file template for OpenHarmony OSS Audit Tool. Please copy it to your project root dir and modify it by referring to OpenHarmony/tools_oat/README.
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
@@ -22,7 +23,7 @@
|
||||
<licensefile></licensefile>
|
||||
<policylist>
|
||||
<policy name="projectPolicy" desc="">
|
||||
<policyitem type="copyright" name="Huawei Technologies Co., Ltd. All rights reserved." path=".*" desc="original liteos copyright"/>
|
||||
<policyitem type="copyright" name="Huawei Device Co., Ltd. All rights reserved." path=".*" desc="original liteos copyright"/>
|
||||
<policyitem type="license" name="BSD-3-Clause" path=".*" desc="Liteos kernel use bsd3 license"/>
|
||||
</policy>
|
||||
</policylist>
|
||||
@@ -37,7 +38,7 @@
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
</filefilter>
|
||||
<filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
|
||||
<filefilter name="defaultPolicyFilter" desc="Filters for license header policies">
|
||||
<!--filteritem type="filename" name="*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="abcdefg/.*.uvwxyz" desc="Describe the reason for filtering scan results"/-->
|
||||
<!--filteritem type="filepath" name="projectroot/[a-zA-Z0-9]{20,}.sh" desc="Temp files"/-->
|
||||
|
||||
17
README.md
17
README.md
@@ -62,20 +62,19 @@ The OpenHarmony LiteOS Cortex-A is a new-generation kernel developed based on th
|
||||
## Constraints<a name="section119744591305"></a>
|
||||
|
||||
- Programming languages: C and C++
|
||||
- Applicable development boards: Hi3518E V300 and Hi3516D V300
|
||||
- Hi3518E V300 uses the JFFS2 file system by default, and Hi3516D V300 uses the FAT file system by default.
|
||||
- Applicable development boards: Hi3516D V300
|
||||
- Hi3516D V300 uses the FAT file system by default.
|
||||
|
||||
## Usage<a name="section741617511812"></a>
|
||||
|
||||
OpenHarmony LiteOS Cortex-A supports the [Hi3518E V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3518.md) and [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3516.md). You can develop and run your applications based on both development boards.
|
||||
OpenHarmony LiteOS Cortex-A supports the [Hi3516D V300](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-introduction-hi3516.md). You can develop and run your applications based on this development board.
|
||||
|
||||
### Preparations<a name="section1579912573329"></a>
|
||||
|
||||
You need to set up the compilation environment on Linux.
|
||||
|
||||
- [Compilation environment on Linux](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-env-setup-lin.md)
|
||||
- For Hi3518E V300, see [Setting Up the Hi3518 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3518-setting.md).
|
||||
- For Hi3516D V300, see [Setting Up the Hi3516 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3516-setting.md).
|
||||
- [Setting Up Ubuntu Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-env-setup.md)
|
||||
- For Hi3516D V300, see [Setting Up the Hi3516 Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md).
|
||||
|
||||
### Source Code Acquisition<a name="section11443189655"></a>
|
||||
|
||||
@@ -85,9 +84,7 @@ Download and decompress a set of source code on a Linux server to acquire the [
|
||||
|
||||
For details about how to develop the first application, see:
|
||||
|
||||
- [Developing the First Example Program Running on Hi3518](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3518-running.md)
|
||||
|
||||
- [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-board3516-running.md)
|
||||
- [Developing the First Example Program Running on Hi3516](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)
|
||||
|
||||
## Repositories Involved<a name="section1371113476307"></a>
|
||||
|
||||
@@ -95,5 +92,5 @@ For details about how to develop the first application, see:
|
||||
|
||||
[drivers\_liteos](https://gitee.com/openharmony/drivers_liteos/blob/master/README.md)
|
||||
|
||||
**kernel\_liteos\_a**
|
||||
[kernel\_liteos\_a](https://gitee.com/openharmony/kernel_liteos_a/blob/master/README.md)
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ OpenHarmony LiteOS-A內核是基於Huawei LiteOS內核演進發展的新一代
|
||||
│ ├── hw # 時鐘與中斷相關邏輯代碼
|
||||
│ ├── include # 對外暴露頭文件存放目錄
|
||||
│ └── uart # 串口相關邏輯代碼
|
||||
├── platform # 支持不同的芯片平台代碼,如Hi3516DV300等
|
||||
├── security # 安全特性相關的代碼,包括進程權限管理和虛擬id映射管理
|
||||
├── syscall # 系統調用
|
||||
└── tools # 構建工具及相關配置和代碼
|
||||
@@ -63,19 +62,18 @@ OpenHarmony LiteOS-A內核是基於Huawei LiteOS內核演進發展的新一代
|
||||
## 約束<a name="section119744591305"></a>
|
||||
|
||||
- 開發語言:C/C++;
|
||||
- 適用於Hi3518EV300、Hi3516DV300單板;
|
||||
- Hi3518EV300默認使用jffs2文件系統,Hi3516DV300默認使用FAT文件系統。
|
||||
- 適用於Hi3516DV300單板;
|
||||
- Hi3516DV300默認使用FAT文件系統。
|
||||
|
||||
## 使用說明<a name="section741617511812"></a>
|
||||
|
||||
OpenHarmony LiteOS-A內核支持Hi3518EV300([介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3518.md))、Hi3516DV300([介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3516.md))單板,開發者可基於兩種單板開發運行自己的應用程序。
|
||||
OpenHarmony LiteOS-A內核支持Hi3516DV300([介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md))單板,開發者可基於此單板開發運行自己的應用程序。
|
||||
|
||||
### 準備<a name="section1579912573329"></a>
|
||||
|
||||
開發者需要在Linux上搭建編譯環境:
|
||||
|
||||
- [Ubuntu編譯環境凖備](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md);
|
||||
- Hi3518EV300單板:參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md);
|
||||
- [編譯環境凖備](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md);
|
||||
- Hi3516DV300單板:參考[環境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
|
||||
|
||||
### 獲取源碼<a name="section11443189655"></a>
|
||||
@@ -86,8 +84,6 @@ OpenHarmony LiteOS-A內核支持Hi3518EV300([介紹](https://gitee.com/openhar
|
||||
|
||||
開發者開發第一個應用程序可參考:
|
||||
|
||||
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md);
|
||||
|
||||
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。
|
||||
|
||||
## 相關倉<a name="section1371113476307"></a>
|
||||
@@ -96,4 +92,4 @@ OpenHarmony LiteOS-A內核支持Hi3518EV300([介紹](https://gitee.com/openhar
|
||||
|
||||
[drivers\_liteos](https://gitee.com/openharmony/drivers_liteos/blob/master/README_zh.md)
|
||||
|
||||
**kernel\_liteos\_a**
|
||||
[kernel\_liteos\_a](https://gitee.com/openharmony/kernel_liteos_a/blob/master/README_zh-HK.md)
|
||||
|
||||
16
README_zh.md
16
README_zh.md
@@ -53,7 +53,6 @@ OpenHarmony LiteOS-A内核是基于Huawei LiteOS内核演进发展的新一代
|
||||
│ ├── hw # 时钟与中断相关逻辑代码
|
||||
│ ├── include # 对外暴露头文件存放目录
|
||||
│ └── uart # 串口相关逻辑代码
|
||||
├── platform # 支持不同的芯片平台代码,如Hi3516DV300等
|
||||
├── security # 安全特性相关的代码,包括进程权限管理和虚拟id映射管理
|
||||
├── syscall # 系统调用
|
||||
└── tools # 构建工具及相关配置和代码
|
||||
@@ -62,19 +61,18 @@ OpenHarmony LiteOS-A内核是基于Huawei LiteOS内核演进发展的新一代
|
||||
## 约束<a name="section119744591305"></a>
|
||||
|
||||
- 开发语言:C/C++;
|
||||
- 适用于Hi3518EV300、Hi3516DV300单板;
|
||||
- Hi3518EV300默认使用jffs2文件系统,Hi3516DV300默认使用FAT文件系统。
|
||||
- 适用于Hi3516DV300单板;
|
||||
- Hi3516DV300默认使用FAT文件系统。
|
||||
|
||||
## 使用说明<a name="section741617511812"></a>
|
||||
|
||||
OpenHarmony LiteOS-A内核支持Hi3518EV300([介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3518.md))、Hi3516DV300([介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/oem_minitinier_des_3516.md))单板,开发者可基于两种单板开发运行自己的应用程序。
|
||||
OpenHarmony LiteOS-A内核支持[Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.md)单板。开发者可基于此单板开发运行自己的应用程序。
|
||||
|
||||
### 准备<a name="section1579912573329"></a>
|
||||
|
||||
开发者需要在Linux上搭建编译环境:
|
||||
|
||||
- [Ubuntu编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup-linux.md);
|
||||
- Hi3518EV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-setting.md);
|
||||
- [编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-env-setup.md);
|
||||
- Hi3516DV300单板:参考[环境搭建](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-setting.md)。
|
||||
|
||||
### 获取源码<a name="section11443189655"></a>
|
||||
@@ -83,9 +81,7 @@ OpenHarmony LiteOS-A内核支持Hi3518EV300([介绍](https://gitee.com/openhar
|
||||
|
||||
### 编译构建<a name="section2081013992812"></a>
|
||||
|
||||
开发者开发第一个应用程序可参考:
|
||||
|
||||
- [helloworld for Hi3518EV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3518-running.md);
|
||||
如果这是您的首次应用程序开发,可参考:
|
||||
|
||||
- [helloworld for Hi3516DV300](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-steps-hi3516-running.md)。
|
||||
|
||||
@@ -95,5 +91,5 @@ OpenHarmony LiteOS-A内核支持Hi3518EV300([介绍](https://gitee.com/openhar
|
||||
|
||||
[drivers\_liteos](https://gitee.com/openharmony/drivers_liteos/blob/master/README_zh.md)
|
||||
|
||||
**kernel\_liteos\_a**
|
||||
[kernel\_liteos\_a](https://gitee.com/openharmony/kernel_liteos_a/blob/master/README_zh.md)
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
#endif
|
||||
int main(int argc, char * const *argv)
|
||||
{
|
||||
(void)argv;
|
||||
int ret;
|
||||
pid_t gid;
|
||||
const char *shellPath = "/bin/mksh";
|
||||
|
||||
144
apps/lms/src/sample_usr_lms.c
Executable file → Normal file
144
apps/lms/src/sample_usr_lms.c
Executable file → Normal file
@@ -50,14 +50,16 @@ static void BufReadTest(void *buf, int start, int end)
|
||||
|
||||
static void LmsMallocTest(void)
|
||||
{
|
||||
#define TEST_SIZE 16
|
||||
printf("\n-------- LmsMallocTest Start --------\n");
|
||||
char *buf = (char *)malloc(16);
|
||||
printf("[LmsMallocTest] malloc addr:%p size:%d\n", buf, 16);
|
||||
|
||||
printf("[LmsMallocTest] read overflow & underflow error should be triggered, read range[-1,16]\n");
|
||||
BufReadTest(buf, -1, 16);
|
||||
printf("[LmsMallocTest] write overflow error should be triggered, write range[0,16]\n");
|
||||
BufWriteTest(buf, 0, 16);
|
||||
char *buf = (char *)malloc(TEST_SIZE);
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
printf("[LmsMallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n");
|
||||
BufReadTest(buf, -1, TEST_SIZE);
|
||||
printf("[LmsMallocTest] write overflow error should be triggered, write range[0, TEST_SIZE]\n");
|
||||
BufWriteTest(buf, 0, TEST_SIZE);
|
||||
|
||||
free(buf);
|
||||
printf("\n-------- LmsMallocTest End --------\n");
|
||||
@@ -65,46 +67,61 @@ static void LmsMallocTest(void)
|
||||
|
||||
static void LmsReallocTest(void)
|
||||
{
|
||||
#define TEST_SIZE 64
|
||||
#define TEST_SIZE_MIN 32
|
||||
printf("\n-------- LmsReallocTest Start --------\n");
|
||||
char *buf = (char *)malloc(64);
|
||||
printf("[LmsReallocTest] malloc addr:%p size:%d\n", buf, 64);
|
||||
printf("[LmsReallocTest] read overflow & underflow error should be triggered, read range[-1,64]\n");
|
||||
BufReadTest(buf, -1, 64);
|
||||
buf = (char *)realloc(buf, 32);
|
||||
printf("[LmsReallocTest] realloc addr:%p size:%d\n", buf, 32);
|
||||
printf("[LmsReallocTest] read overflow & underflow error should be triggered, read range[-1,32]\n");
|
||||
BufReadTest(buf, -1, 32);
|
||||
free(buf);
|
||||
char *buf = (char *)malloc(TEST_SIZE);
|
||||
printf("[LmsReallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n");
|
||||
BufReadTest(buf, -1, TEST_SIZE);
|
||||
char *buf1 = (char *)realloc(buf, TEST_SIZE_MIN);
|
||||
if (buf1 == NULL) {
|
||||
free(buf);
|
||||
return;
|
||||
}
|
||||
buf = NULL;
|
||||
printf("[LmsReallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE_MIN]\n");
|
||||
BufReadTest(buf1, -1, TEST_SIZE_MIN);
|
||||
free(buf1);
|
||||
printf("\n-------- LmsReallocTest End --------\n");
|
||||
}
|
||||
|
||||
static void LmsCallocTest(void)
|
||||
{
|
||||
#define TEST_SIZE 16
|
||||
printf("\n-------- LmsCallocTest Start --------\n");
|
||||
char *buf = (char *)calloc(4, 4);
|
||||
printf("[LmsCallocTest] calloc addr:%p size:%d\n", buf, 16);
|
||||
printf("[LmsCallocTest] read overflow & underflow error should be triggered, read range[-1,16]\n");
|
||||
BufReadTest(buf, -1, 16);
|
||||
char *buf = (char *)calloc(4, 4); /* 4: test size */
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
printf("[LmsCallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n");
|
||||
BufReadTest(buf, -1, TEST_SIZE);
|
||||
free(buf);
|
||||
printf("\n-------- LmsCallocTest End --------\n");
|
||||
}
|
||||
|
||||
static void LmsVallocTest(void)
|
||||
{
|
||||
#define TEST_SIZE 4096
|
||||
printf("\n-------- LmsVallocTest Start --------\n");
|
||||
char *buf = (char *)valloc(4096);
|
||||
printf("[LmsVallocTest] valloc addr:%p size:%d\n", buf, 4096);
|
||||
printf("[LmsVallocTest] read overflow & underflow error should be triggered, read range[-1,4096]\n");
|
||||
BufReadTest(buf, -1, 4096);
|
||||
char *buf = (char *)valloc(TEST_SIZE);
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
printf("[LmsVallocTest] read overflow & underflow error should be triggered, read range[-1, TEST_SIZE]\n");
|
||||
BufReadTest(buf, -1, TEST_SIZE);
|
||||
free(buf);
|
||||
printf("\n-------- LmsVallocTest End --------\n");
|
||||
}
|
||||
|
||||
static void LmsAlignedAllocTest(void)
|
||||
{
|
||||
#define TEST_ALIGN_SIZE 64
|
||||
#define TEST_SIZE 128
|
||||
printf("\n-------- LmsAlignedAllocTest Start --------\n");
|
||||
char *buf = (char *)aligned_alloc(64, 128);
|
||||
printf("[LmsAlignedAllocTest] aligned_alloc boundsize:%d addr:%p size:%d\n", 64, buf, 128);
|
||||
char *buf = (char *)aligned_alloc(TEST_ALIGN_SIZE, TEST_SIZE);
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
printf("[LmsAlignedAllocTest] read overflow & underflow error should be triggered, read range[-1,128]\n");
|
||||
BufReadTest(buf, -1, 128);
|
||||
free(buf);
|
||||
@@ -113,44 +130,55 @@ static void LmsAlignedAllocTest(void)
|
||||
|
||||
static void LmsMemsetTest(void)
|
||||
{
|
||||
#define TEST_SIZE 32
|
||||
printf("\n-------- LmsMemsetTest Start --------\n");
|
||||
char *buf = (char *)malloc(32);
|
||||
printf("[LmsMemsetTest] malloc addr:%p size:%d\n", buf, 32);
|
||||
printf("[LmsMemsetTest] memset overflow & underflow error should be triggered, memset size:%d\n", 33);
|
||||
memset(buf, 0, 33);
|
||||
char *buf = (char *)malloc(TEST_SIZE);
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
printf("[LmsMemsetTest] memset overflow & underflow error should be triggered, memset size:%d\n", TEST_SIZE + 1);
|
||||
memset(buf, 0, TEST_SIZE + 1);
|
||||
free(buf);
|
||||
printf("\n-------- LmsMemsetTest End --------\n");
|
||||
}
|
||||
|
||||
static void LmsMemcpyTest(void)
|
||||
{
|
||||
#define TEST_SIZE 20
|
||||
printf("\n-------- LmsMemcpyTest Start --------\n");
|
||||
char *buf = (char *)malloc(20);
|
||||
printf("[LmsMemcpyTest] malloc addr:%p size:%d\n", buf, 20);
|
||||
char localBuf[32] = {0};
|
||||
printf("[LmsMemcpyTest] memcpy overflow error should be triggered, memcpy size:%d\n", 21);
|
||||
memcpy(buf, localBuf, 21);
|
||||
char *buf = (char *)malloc(TEST_SIZE);
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
char localBuf[32] = {0}; /* 32: test size */
|
||||
printf("[LmsMemcpyTest] memcpy overflow error should be triggered, memcpy size:%d\n", TEST_SIZE + 1);
|
||||
memcpy(buf, localBuf, TEST_SIZE + 1);
|
||||
free(buf);
|
||||
printf("\n-------- LmsMemcpyTest End --------\n");
|
||||
}
|
||||
|
||||
static void LmsMemmoveTest(void)
|
||||
{
|
||||
#define TEST_SIZE 20
|
||||
printf("\n-------- LmsMemmoveTest Start --------\n");
|
||||
char *buf = (char *)malloc(20);
|
||||
printf("[LmsMemmoveTest] malloc addr:%p size:%d\n", buf, 20);
|
||||
printf("[LmsMemmoveTest] memmove overflow error should be triggered, dest addr:%p src addr:%p size:%d\n", buf + 12,
|
||||
buf, 10);
|
||||
memmove(buf + 12, buf, 10);
|
||||
char *buf = (char *)malloc(TEST_SIZE);
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
printf("[LmsMemmoveTest] memmove overflow error should be triggered\n");
|
||||
memmove(buf + 12, buf, 10); /* 12 and 10: test size */
|
||||
free(buf);
|
||||
printf("\n-------- LmsMemmoveTest End --------\n");
|
||||
}
|
||||
|
||||
static void LmsStrcpyTest(void)
|
||||
{
|
||||
#define TEST_SIZE 16
|
||||
printf("\n-------- LmsStrcpyTest Start --------\n");
|
||||
char *buf = (char *)malloc(16);
|
||||
printf("[LmsStrcpyTest] malloc addr:%p size:%d\n", buf, 16);
|
||||
char *buf = (char *)malloc(TEST_SIZE);
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
char *testStr = "bbbbbbbbbbbbbbbbb";
|
||||
printf("[LmsStrcpyTest] strcpy overflow error should be triggered, src string buf size:%d\n", strlen(testStr) + 1);
|
||||
strcpy(buf, testStr);
|
||||
@@ -160,9 +188,12 @@ static void LmsStrcpyTest(void)
|
||||
|
||||
static void LmsStrcatTest(void)
|
||||
{
|
||||
#define TEST_SIZE 16
|
||||
printf("\n-------- LmsStrcatTest Start --------\n");
|
||||
char *buf = (char *)malloc(16);
|
||||
printf("[LmsStrcatTest] malloc addr:%p size:%d\n", buf, 16);
|
||||
char *buf = (char *)malloc(TEST_SIZE);
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
buf[0] = 'a';
|
||||
buf[1] = 'b';
|
||||
buf[2] = 0;
|
||||
@@ -177,22 +208,30 @@ static void LmsStrcatTest(void)
|
||||
|
||||
static void LmsFreeTest(void)
|
||||
{
|
||||
#define TEST_SIZE 16
|
||||
printf("\n-------- LmsFreeTest Start --------\n");
|
||||
char *buf = (char *)malloc(16);
|
||||
printf("[LmsFreeTest] malloc addr:%p size:%d\n", buf, 16);
|
||||
printf("[LmsFreeTest] free addr:%p\n", buf, 16);
|
||||
char *buf = (char *)malloc(TEST_SIZE);
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
printf("[LmsFreeTest] free size:%d\n", TEST_SIZE);
|
||||
free(buf);
|
||||
printf("[LmsFreeTest] Use after free error should be triggered, read addr:%p range[1,1]\n", buf);
|
||||
printf("[LmsFreeTest] Use after free error should be triggered, read range[1,1]\n");
|
||||
BufReadTest(buf, 1, 1);
|
||||
printf("[LmsFreeTest] double free error should be triggered, free addr:%p\n", buf);
|
||||
printf("[LmsFreeTest] double free error should be triggered\n");
|
||||
free(buf);
|
||||
printf("\n-------- LmsFreeTest End --------\n");
|
||||
}
|
||||
|
||||
int main(int argc, char * const * argv)
|
||||
int main(int argc, char * const *argv)
|
||||
{
|
||||
(void)argc;
|
||||
(void)argv;
|
||||
printf("\n############### Lms Test start ###############\n");
|
||||
char *tmp = (char *)malloc(5000);
|
||||
char *tmp = (char *)malloc(5000); /* 5000: test mem size */
|
||||
if (tmp == NULL) {
|
||||
return;
|
||||
}
|
||||
LmsMallocTest();
|
||||
LmsReallocTest();
|
||||
LmsCallocTest();
|
||||
@@ -204,5 +243,6 @@ int main(int argc, char * const * argv)
|
||||
LmsStrcpyTest();
|
||||
LmsStrcatTest();
|
||||
LmsFreeTest();
|
||||
free(tmp);
|
||||
printf("\n############### Lms Test End ###############\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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" ]
|
||||
}
|
||||
|
||||
|
||||
@@ -62,10 +62,17 @@ int main(int argc, char **argv)
|
||||
PerfStop(fd);
|
||||
} else if ((argc == THREE_ARGS) && strcmp(argv[1], "read") == 0) {
|
||||
size_t size = strtoul(argv[THREE_ARGS - 1], NULL, 0);
|
||||
if (size <= 0) {
|
||||
goto EXIT:
|
||||
}
|
||||
|
||||
char *buf = (char *)malloc(size);
|
||||
int len = PerfRead(fd, buf, size);
|
||||
PerfPrintBuffer(buf, len);
|
||||
free(buf);
|
||||
if (buf != NULL) {
|
||||
int len = PerfRead(fd, buf, size);
|
||||
PerfPrintBuffer(buf, len);
|
||||
free(buf);
|
||||
buf = NULL;
|
||||
}
|
||||
} else if ((argc == TWO_ARGS) && strcmp(argv[1], "list") == 0) {
|
||||
PerfList();
|
||||
} else if ((argc >= THREE_ARGS) && strcmp(argv[1], "stat") == 0) {
|
||||
@@ -77,6 +84,7 @@ int main(int argc, char **argv)
|
||||
PerfUsage();
|
||||
}
|
||||
|
||||
EXIT:
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -113,7 +113,6 @@ ssize_t PerfWriteFile(const char *filePath, const char *buf, ssize_t bufSize)
|
||||
ssize_t totalWrite = 0;
|
||||
|
||||
if (filePath == NULL || buf == NULL || bufSize == 0) {
|
||||
printf("filePath: %p, buf: %p, bufSize: %u!\n", filePath, buf, bufSize);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@ extern "C" {
|
||||
#define QUOTES_STATUS_CLOSE(qu) ((qu) == FALSE)
|
||||
#define QUOTES_STATUS_OPEN(qu) ((qu) == TRUE)
|
||||
|
||||
typedef size_t bool;
|
||||
|
||||
typedef struct {
|
||||
unsigned int consoleID;
|
||||
|
||||
@@ -32,13 +32,15 @@
|
||||
#ifndef _SHELL_PRI_H
|
||||
#define _SHELL_PRI_H
|
||||
|
||||
#include "shell.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern void *ShellEntry(void *argv);
|
||||
extern void ShellEntry(ShellCB *shellCB);
|
||||
extern void *ShellTask(void *argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#ifndef _SHMSG_H
|
||||
#define _SHMSG_H
|
||||
|
||||
#include "shell_list.h"
|
||||
#include "shell.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -61,8 +62,7 @@ extern "C" {
|
||||
|
||||
typedef void (* OutputFunc)(const char *fmt, ...);
|
||||
extern int ShellTaskInit(ShellCB *shellCB);
|
||||
extern int ShellEntryInit(ShellCB *shellCB);
|
||||
extern void ChildExec(const char *cmdName, char *const paramArray[]);
|
||||
extern void ChildExec(const char *cmdName, char *const paramArray[], bool foreground);
|
||||
extern void ShellCmdLineParse(char c, OutputFunc outputFunc, ShellCB *shellCB);
|
||||
extern int ShellNotify(ShellCB *shellCB);
|
||||
|
||||
|
||||
@@ -31,13 +31,16 @@
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include "show.h"
|
||||
#include "shmsg.h"
|
||||
#include "shcmd.h"
|
||||
#include "shell_pri.h"
|
||||
#include "semaphore.h"
|
||||
#include "securec.h"
|
||||
#include "unistd.h"
|
||||
#include <sys/syscall.h>
|
||||
|
||||
ShellCB *g_shellCB = NULL;
|
||||
|
||||
@@ -77,13 +80,8 @@ static int OsShellCreateTask(ShellCB *shellCB)
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
ret = ShellEntryInit(shellCB);
|
||||
if (ret != SH_OK) {
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
(void)pthread_join(shellCB->shellTaskHandle, NULL);
|
||||
(void)pthread_join(shellCB->shellEntryHandle, NULL);
|
||||
shellCB->shellEntryHandle = pthread_self();
|
||||
return 0;
|
||||
|
||||
OUT:
|
||||
ShellDeinit(shellCB);
|
||||
@@ -98,7 +96,7 @@ static int DoShellExec(char **argv)
|
||||
char *cmdLine = NULL;
|
||||
|
||||
if (strncmp(argv[0], SHELL_EXEC_COMMAND, SHELL_EXEC_COMMAND_BYTES) == 0) {
|
||||
ChildExec(argv[1], argv + 1);
|
||||
ChildExec(argv[1], argv + 1, FALSE);
|
||||
}
|
||||
for (i = 0; argv[i]; i++) {
|
||||
len += strlen(argv[i]);
|
||||
@@ -108,11 +106,15 @@ static int DoShellExec(char **argv)
|
||||
if (!cmdLine) {
|
||||
return ret;
|
||||
}
|
||||
memset_s(cmdLine, len, 0, len);
|
||||
errno_t ret1 = memset_s(cmdLine, len, 0, len);
|
||||
if (ret1 != EOK) {
|
||||
free(cmdLine);
|
||||
return ret1;
|
||||
}
|
||||
|
||||
for (j = 0; j < i; j++) {
|
||||
strcat_s(cmdLine, len, argv[j]);
|
||||
strcat_s(cmdLine, len, " ");
|
||||
(void)strcat_s(cmdLine, len, argv[j]);
|
||||
(void)strcat_s(cmdLine, len, " ");
|
||||
}
|
||||
|
||||
cmdLine[len - 2] = '\0'; /* 2, (len - 2) is the end of cmdline buf */
|
||||
@@ -121,11 +123,22 @@ static int DoShellExec(char **argv)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void ShellSigChildHook(int sig)
|
||||
{
|
||||
(void)sig;
|
||||
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret = SH_NOK;
|
||||
ShellCB *shellCB = NULL;
|
||||
|
||||
(void)signal(SIGCHLD, ShellSigChildHook);
|
||||
|
||||
if (argc > 1) {
|
||||
ret = DoShellExec(argv + 1);
|
||||
return ret;
|
||||
@@ -161,7 +174,12 @@ int main(int argc, char **argv)
|
||||
sem_init(&shellCB->shellSem, 0, 0);
|
||||
|
||||
g_shellCB = shellCB;
|
||||
return OsShellCreateTask(shellCB);
|
||||
ret = OsShellCreateTask(shellCB);
|
||||
if (ret != SH_OK) {
|
||||
goto ERR_OUT3;
|
||||
}
|
||||
|
||||
ShellEntry(shellCB);
|
||||
|
||||
ERR_OUT3:
|
||||
(void)pthread_mutex_destroy(&shellCB->historyMutex);
|
||||
|
||||
@@ -36,7 +36,6 @@
|
||||
#include "dirent.h"
|
||||
#include "securec.h"
|
||||
|
||||
|
||||
#define SHELL_INIT_MAGIC_FLAG 0xABABABAB
|
||||
#define CTRL_C 0x03 /* 0x03: ctrl+c ASCII */
|
||||
|
||||
@@ -378,7 +377,7 @@ static int OsTabMatchFile(char *cmdKey, unsigned int *len)
|
||||
* Description: Pass in the string and clear useless space ,which include:
|
||||
* 1) The overmatch space which is not be marked by Quote's area
|
||||
* Squeeze the overmatch space into one space
|
||||
* 2) Clear all space before first valid charatctor
|
||||
* 2) Clear all space before first valid character
|
||||
* Input: cmdKey : Pass in the buff string, which is ready to be operated
|
||||
* cmdOut : Pass out the buffer string ,which has already been operated
|
||||
* size : cmdKey length
|
||||
@@ -407,17 +406,17 @@ unsigned int OsCmdKeyShift(const char *cmdKey, char *cmdOut, unsigned int size)
|
||||
|
||||
/* Backup the 'output' start address */
|
||||
outputBak = output;
|
||||
/* Scan each charactor in 'cmdKey',and squeeze the overmuch space and ignore invalid charactor */
|
||||
/* Scan each character in 'cmdKey',and squeeze the overmuch space and ignore invalid character */
|
||||
for (; *cmdKey != '\0'; cmdKey++) {
|
||||
/* Detected a Double Quotes, switch the matching status */
|
||||
if (*(cmdKey) == '\"') {
|
||||
SWITCH_QUOTES_STATUS(quotes);
|
||||
}
|
||||
/* Ignore the current charactor in following situation */
|
||||
/* Ignore the current character in following situation */
|
||||
/* 1) Quotes matching status is FALSE (which said that the space is not been marked by double quotes) */
|
||||
/* 2) Current charactor is a space */
|
||||
/* 3) Next charactor is a space too, or the string is been seeked to the end already(\0) */
|
||||
/* 4) Invalid charactor, such as single quotes */
|
||||
/* 2) Current character is a space */
|
||||
/* 3) Next character is a space too, or the string is been seeked to the end already(\0) */
|
||||
/* 4) Invalid character, such as single quotes */
|
||||
if ((*cmdKey == ' ') && ((*(cmdKey + 1) == ' ') || (*(cmdKey + 1) == '\0')) && QUOTES_STATUS_CLOSE(quotes)) {
|
||||
continue;
|
||||
}
|
||||
@@ -431,7 +430,7 @@ unsigned int OsCmdKeyShift(const char *cmdKey, char *cmdOut, unsigned int size)
|
||||
/* Restore the 'output' start address */
|
||||
output = outputBak;
|
||||
len = strlen(output);
|
||||
/* Clear the space which is located at the first charactor in buffer */
|
||||
/* Clear the space which is located at the first character in buffer */
|
||||
if (*output == ' ') {
|
||||
output++;
|
||||
len--;
|
||||
@@ -585,7 +584,6 @@ END:
|
||||
|
||||
unsigned int OsCmdExec(CmdParsed *cmdParsed, char *cmdStr)
|
||||
{
|
||||
/* TODO: complete the usrspace command */
|
||||
unsigned int ret = SH_OK;
|
||||
if (cmdParsed && cmdStr) {
|
||||
ret = SH_NOK;
|
||||
|
||||
@@ -334,12 +334,12 @@ char *GetCmdName(const char *cmdline, unsigned int len)
|
||||
/* If reach a double quotes, switch the quotes matching status */
|
||||
if (*tmpStr == '\"') {
|
||||
SWITCH_QUOTES_STATUS(quotes);
|
||||
/* Ignore the double quote charactor itself */
|
||||
/* Ignore the double quote character itself */
|
||||
tmpStr++;
|
||||
continue;
|
||||
}
|
||||
/* If detected a space which the quotes matching status is false */
|
||||
/* which said has detected the first space for seperator, finish this scan operation */
|
||||
/* which said has detected the first space for separator, finish this scan operation */
|
||||
if ((*tmpStr == ' ') && (QUOTES_STATUS_CLOSE(quotes))) {
|
||||
break;
|
||||
}
|
||||
@@ -351,7 +351,7 @@ char *GetCmdName(const char *cmdline, unsigned int len)
|
||||
return cmdName;
|
||||
}
|
||||
|
||||
void ChildExec(const char *cmdName, char *const paramArray[])
|
||||
void ChildExec(const char *cmdName, char *const paramArray[], bool foreground)
|
||||
{
|
||||
int ret;
|
||||
pid_t gid;
|
||||
@@ -367,10 +367,12 @@ void ChildExec(const char *cmdName, char *const paramArray[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = tcsetpgrp(STDIN_FILENO, gid);
|
||||
if (ret != 0) {
|
||||
printf("tcsetpgrp failed, errno %d\n", errno);
|
||||
exit(1);
|
||||
if (!foreground) {
|
||||
ret = tcsetpgrp(STDIN_FILENO, gid);
|
||||
if (ret != 0) {
|
||||
printf("tcsetpgrp failed, errno %d\n", errno);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
ret = execve(cmdName, paramArray, NULL);
|
||||
@@ -404,20 +406,30 @@ int CheckExit(const char *cmdName, const CmdParsed *cmdParsed)
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
static void DoCmdExec(const char *cmdName, const char *cmdline, unsigned int len, const CmdParsed *cmdParsed)
|
||||
static void DoCmdExec(const char *cmdName, const char *cmdline, unsigned int len, CmdParsed *cmdParsed)
|
||||
{
|
||||
bool foreground = FALSE;
|
||||
int ret;
|
||||
pid_t forkPid;
|
||||
|
||||
if (strncmp(cmdline, CMD_EXEC_COMMAND, CMD_EXEC_COMMAND_BYTES) == 0) {
|
||||
if ((cmdParsed->paramCnt > 1) && (strcmp(cmdParsed->paramArray[cmdParsed->paramCnt - 1], "&") == 0)) {
|
||||
free(cmdParsed->paramArray[cmdParsed->paramCnt - 1]);
|
||||
cmdParsed->paramArray[cmdParsed->paramCnt - 1] = NULL;
|
||||
cmdParsed->paramCnt--;
|
||||
foreground = TRUE;
|
||||
}
|
||||
|
||||
forkPid = fork();
|
||||
if (forkPid < 0) {
|
||||
printf("Faild to fork from shell\n");
|
||||
return;
|
||||
} else if (forkPid == 0) {
|
||||
ChildExec(cmdParsed->paramArray[0], cmdParsed->paramArray);
|
||||
ChildExec(cmdParsed->paramArray[0], cmdParsed->paramArray, foreground);
|
||||
} else {
|
||||
waitpid(forkPid, 0, 0);
|
||||
if (!foreground) {
|
||||
(void)waitpid(forkPid, 0, 0);
|
||||
}
|
||||
ret = tcsetpgrp(STDIN_FILENO, getpid());
|
||||
if (ret != 0) {
|
||||
printf("tcsetpgrp failed, errno %d\n", errno);
|
||||
@@ -503,7 +515,7 @@ unsigned int PreHandleCmdline(const char *input, char **output, unsigned int *ou
|
||||
*output = shiftStr;
|
||||
*outputlen = shiftLen;
|
||||
|
||||
/* Check and parse "./", located at the first two charaters of the cmd */
|
||||
/* Check and parse "./", located at the first two characters of the cmd */
|
||||
if ((shiftLen > removeLen) && (shiftStr[0] == '.') && (shiftStr[1] == '/')) {
|
||||
execLen = strlen(execCmd);
|
||||
newLen = execLen + shiftLen - removeLen; /* i.e., newLen - execLen == shiftLen - removeLen */
|
||||
@@ -567,20 +579,10 @@ static void ExecCmdline(const char *cmdline)
|
||||
free(output);
|
||||
}
|
||||
|
||||
void RecycleZombieChild(void)
|
||||
{
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
static void ShellCmdProcess(ShellCB *shellCB)
|
||||
{
|
||||
char *buf = NULL;
|
||||
while (1) {
|
||||
/* recycle zombine child process */
|
||||
RecycleZombieChild();
|
||||
buf = GetCmdline(shellCB);
|
||||
char *buf = GetCmdline(shellCB);
|
||||
if (buf == NULL) {
|
||||
break;
|
||||
}
|
||||
@@ -654,25 +656,19 @@ static int ShellKernelReg(unsigned int shellHandle)
|
||||
return ioctl(STDIN_FILENO, CONSOLE_CONTROL_REG_USERTASK, shellHandle);
|
||||
}
|
||||
|
||||
void *ShellEntry(void *argv)
|
||||
void ShellEntry(ShellCB *shellCB)
|
||||
{
|
||||
char ch;
|
||||
int ret;
|
||||
int n;
|
||||
pid_t tid = syscall(__NR_gettid);
|
||||
ShellCB *shellCB = (ShellCB *)argv;
|
||||
|
||||
if (shellCB == NULL) {
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
(void)memset_s(shellCB->shellBuf, SHOW_MAX_LEN, 0, SHOW_MAX_LEN);
|
||||
|
||||
ret = prctl(PR_SET_NAME, "ShellEntry");
|
||||
if (ret != SH_OK) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = ShellKernelReg((int)tid);
|
||||
if (ret != 0) {
|
||||
printf("another shell is already running!\n");
|
||||
@@ -685,32 +681,5 @@ void *ShellEntry(void *argv)
|
||||
ShellCmdLineParse(ch, (OutputFunc)printf, shellCB);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
int ShellEntryInit(ShellCB *shellCB)
|
||||
{
|
||||
int ret;
|
||||
size_t stackSize = SHELL_ENTRY_STACKSIZE;
|
||||
void *arg = NULL;
|
||||
pthread_attr_t attr;
|
||||
|
||||
if (shellCB == NULL) {
|
||||
return SH_NOK;
|
||||
}
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
if (ret != SH_OK) {
|
||||
return SH_NOK;
|
||||
}
|
||||
|
||||
pthread_attr_setstacksize(&attr, stackSize);
|
||||
arg = (void *)shellCB;
|
||||
ret = pthread_create(&shellCB->shellEntryHandle, &attr, &ShellEntry, arg);
|
||||
if (ret != SH_OK) {
|
||||
return SH_NOK;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ extern "C" {
|
||||
|
||||
#define TFTP_NULL_UINT32 ((u32_t)0xffffffffUL)
|
||||
|
||||
#define TFTP_NULL_INT32 -1
|
||||
#define TFTP_NULL_INT32 (-1)
|
||||
|
||||
/** @cond liteos
|
||||
* @defgroup TFTP_Interfaces
|
||||
@@ -114,7 +114,7 @@ typedef enum tagTFTPC_OpCode {
|
||||
TFTPC_OP_RRQ = 1, /* read request */
|
||||
TFTPC_OP_WRQ, /* write request */
|
||||
TFTPC_OP_DATA, /* data packet */
|
||||
TFTPC_OP_ACK, /* acknowledgement */
|
||||
TFTPC_OP_ACK, /* acknowledgment */
|
||||
TFTPC_OP_ERROR, /* error code */
|
||||
TFTPC_OP_OPT /* option code */
|
||||
} TFTPC_OPCODE_E;
|
||||
|
||||
@@ -50,11 +50,11 @@ static char *TftpError[] = {
|
||||
"Error while sending data to the peer\n",
|
||||
"Requested file is not found\n",
|
||||
"This is the error sent by the server when hostname cannot be resolved\n",
|
||||
"Input paramters passed to TFTP interfaces are invalid\n",
|
||||
"Input parameters passed to TFTP interfaces are invalid\n",
|
||||
"Error detected in TFTP packet or the error received from the TFTP server\n",
|
||||
"Error during packet synhronization while sending or unexpected packet is received\n",
|
||||
"File size limit crossed, Max block can be 0xFFFF, each block containing 512 bytes\n",
|
||||
"File name lenght greater than 256\n",
|
||||
"File name length greater than 256\n",
|
||||
"Hostname IP is not valid\n",
|
||||
"TFTP server returned file access error\n",
|
||||
"TFTP server returned error signifying that the DISK is full to write\n",
|
||||
@@ -66,11 +66,11 @@ static char *TftpError[] = {
|
||||
"File create error\n",
|
||||
"File write error\n",
|
||||
"Max time expired while waiting for file to be recived\n",
|
||||
"Error when the received packet is less than 4bytes(error lenght) or greater than 512bytes\n",
|
||||
"Error when the received packet is less than 4bytes(error length) or greater than 512bytes\n",
|
||||
"Returned by TFTP server for protocol user error\n",
|
||||
"The destination file path length greater than 256\n",
|
||||
"Returned by TFTP server for undefined transfer ID\n",
|
||||
"IOCTL fucntion failed at TFTP client while setting the socket to non-block\n",
|
||||
"IOCTL function failed at TFTP client while setting the socket to non-block\n",
|
||||
};
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
|
||||
@@ -189,7 +189,7 @@ u32_t lwip_tftp_recv_from_server(s32_t iSockNum, u32_t *pulSize, TFTPC_PACKET_S
|
||||
if (iRet == -1) {
|
||||
return TFTPC_SELECT_ERROR;
|
||||
} else if (iRet == 0) {
|
||||
return TFTPC_TIMEOUT_ERROR; /* Select timeout occured */
|
||||
return TFTPC_TIMEOUT_ERROR; /* Select timeout occurred */
|
||||
}
|
||||
|
||||
if (!FD_ISSET(iSockNum, &stReadfds)) {
|
||||
@@ -218,7 +218,7 @@ u32_t lwip_tftp_recv_from_server(s32_t iSockNum, u32_t *pulSize, TFTPC_PACKET_S
|
||||
usOpcode = ntohs(pstRecvBuf->usOpcode);
|
||||
/* if this packet is ERROR packet */
|
||||
if (usOpcode == TFTPC_OP_ERROR) {
|
||||
ulError = ntohs (pstRecvBuf->u.stTFTP_Err.usErrNum);
|
||||
ulError = ntohs(pstRecvBuf->u.stTFTP_Err.usErrNum);
|
||||
|
||||
/*If the error is according to RFC,then convert to lwip error codes.
|
||||
Constant values are used in the cases as these error codes are as per
|
||||
@@ -268,7 +268,7 @@ u32_t lwip_tftp_recv_from_server(s32_t iSockNum, u32_t *pulSize, TFTPC_PACKET_S
|
||||
*pulSize = (u32_t)iRet;
|
||||
|
||||
/* If received packet is first block of data(for get operation) or if
|
||||
received packet is acknowledgement for write request (put operation)
|
||||
received packet is acknowledgment for write request (put operation)
|
||||
store the received port number */
|
||||
if (((usOpcode == TFTPC_OP_DATA) &&
|
||||
(ntohs(pstRecvBuf->u.stTFTP_Data.usBlknum) == 1)) ||
|
||||
@@ -687,7 +687,7 @@ u32_t lwip_tftp_get_file_by_filename(u32_t ulHostAddr,
|
||||
|
||||
ulErrCode = lwip_tftp_recv_from_server(iSockNum, &ulRecvSize, pstRecvBuf,
|
||||
&ulIgnorePkt, &stServerAddr, pstSendBuf);
|
||||
/* If select timeout occured */
|
||||
/* If select timeout occurred */
|
||||
if (ulErrCode == TFTPC_TIMEOUT_ERROR) {
|
||||
ulTotalTime++;
|
||||
if (ulTotalTime < TFTPC_MAX_SEND_REQ_ATTEMPTS) {
|
||||
@@ -727,7 +727,7 @@ u32_t lwip_tftp_get_file_by_filename(u32_t ulHostAddr,
|
||||
}
|
||||
|
||||
/* if this packet is unkonwn or incorrect packet */
|
||||
if (ntohs (pstRecvBuf->usOpcode) != TFTPC_OP_DATA) {
|
||||
if (ntohs(pstRecvBuf->usOpcode) != TFTPC_OP_DATA) {
|
||||
/* Send error packet to server */
|
||||
lwip_tftp_send_error(iSockNum,
|
||||
TFTPC_PROTOCOL_PROTO_ERROR,
|
||||
@@ -982,7 +982,7 @@ u32_t lwip_tftp_put_file_by_filename(u32_t ulHostAddr, u16_t usTftpServPort, u8_
|
||||
return TFTPC_MEMALLOC_ERROR;
|
||||
}
|
||||
|
||||
/* First time intialize the buffer */
|
||||
/* First time initialize the buffer */
|
||||
(void)memset_s((void *)pstSendBuf, sizeof(TFTPC_PACKET_S), 0, sizeof(TFTPC_PACKET_S));
|
||||
|
||||
/* The destination path can only be one of the following:
|
||||
@@ -1221,7 +1221,7 @@ u32_t lwip_tftp_inner_put_file(s32_t iSockNum,
|
||||
return TFTPC_MEMALLOC_ERROR;
|
||||
}
|
||||
|
||||
/* First time intialize the buffer */
|
||||
/* First time initialize the buffer */
|
||||
(void)memset_s((void *)pstRecvBuf, sizeof(TFTPC_PACKET_S), 0, sizeof(TFTPC_PACKET_S));
|
||||
|
||||
/* Initialize from address to the server address at first */
|
||||
@@ -1235,7 +1235,7 @@ u32_t lwip_tftp_inner_put_file(s32_t iSockNum,
|
||||
ulError = lwip_tftp_recv_from_server(iSockNum, &ulPktSize,
|
||||
pstRecvBuf, &ulIgnorePkt,
|
||||
pstServerAddr, pstSendBuf);
|
||||
/* If select timeout occured */
|
||||
/* If select timeout occurred */
|
||||
if (ulError == TFTPC_TIMEOUT_ERROR) {
|
||||
ulTotalTime++;
|
||||
if (ulTotalTime < TFTPC_MAX_SEND_REQ_ATTEMPTS) {
|
||||
@@ -1526,7 +1526,7 @@ u32_t lwip_tftp_get_file_by_filename_to_rawmem(u32_t ulHostAddr,
|
||||
|
||||
ulErrCode = lwip_tftp_recv_from_server(iSockNum, &ulRecvSize, pstRecvBuf, &ulIgnorePkt,
|
||||
&stServerAddr, pstSendBuf);
|
||||
/* If select timeout occured */
|
||||
/* If select timeout occurred */
|
||||
if (ulErrCode == TFTPC_TIMEOUT_ERROR) {
|
||||
ulTotalTime++;
|
||||
if (ulTotalTime < TFTPC_MAX_SEND_REQ_ATTEMPTS) {
|
||||
@@ -1557,7 +1557,7 @@ u32_t lwip_tftp_get_file_by_filename_to_rawmem(u32_t ulHostAddr,
|
||||
}
|
||||
|
||||
/* if this packet is unkonwn or incorrect packet */
|
||||
if (ntohs (pstRecvBuf->usOpcode) != TFTPC_OP_DATA) {
|
||||
if (ntohs(pstRecvBuf->usOpcode) != TFTPC_OP_DATA) {
|
||||
/* Send error packet to server */
|
||||
lwip_tftp_send_error(iSockNum,
|
||||
TFTPC_PROTOCOL_PROTO_ERROR,
|
||||
|
||||
@@ -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" ]
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,10 @@ static void TraceRead(int fd, size_t size)
|
||||
{
|
||||
ssize_t i;
|
||||
ssize_t len;
|
||||
if (size <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
char *buffer = (char *)malloc(size);
|
||||
if (buffer == NULL) {
|
||||
printf("Read buffer malloc failed.\n");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -246,7 +246,7 @@ STATIC INLINE INT32 LOS_AtomicIncRet(Atomic *v)
|
||||
* @brief Atomic auto-decrement.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to implementating the atomic auto-decrement.
|
||||
* This API is used to implement the atomic auto-decrement.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The pointer v must not be NULL.</li>
|
||||
@@ -280,7 +280,7 @@ STATIC INLINE VOID LOS_AtomicDec(Atomic *v)
|
||||
* @brief Atomic auto-decrement.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to implementating the atomic auto-decrement and return the result of auto-decrement.
|
||||
* This API is used to implement the atomic auto-decrement and return the result of auto-decrement.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The pointer v must not be NULL.</li>
|
||||
@@ -531,7 +531,7 @@ STATIC INLINE INT64 LOS_Atomic64IncRet(Atomic64 *v)
|
||||
* @brief Atomic64 auto-decrement.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to implementating the atomic64 auto-decrement.
|
||||
* This API is used to implement the atomic64 auto-decrement.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The pointer v must not be NULL.</li>
|
||||
@@ -566,7 +566,7 @@ STATIC INLINE VOID LOS_Atomic64Dec(Atomic64 *v)
|
||||
* @brief Atomic64 auto-decrement.
|
||||
*
|
||||
* @par Description:
|
||||
* This API is used to implementating the atomic64 auto-decrement and return the result of auto-decrement.
|
||||
* This API is used to implement the atomic64 auto-decrement and return the result of auto-decrement.
|
||||
* @attention
|
||||
* <ul>
|
||||
* <li>The pointer v must not be NULL.</li>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ extern "C" {
|
||||
#define HWI_IS_REGISTED(num) ((&g_hwiForm[num])->pstNext != NULL)
|
||||
#endif
|
||||
extern VOID OsHwiInit(VOID);
|
||||
extern VOID OsIncHwiFormCnt(UINT32 index);
|
||||
extern UINT32 OsGetHwiFormCnt(UINT32 index);
|
||||
extern VOID OsIncHwiFormCnt(UINT16 cpuid, UINT32 index);
|
||||
extern UINT32 OsGetHwiFormCnt(UINT16 cpuid, UINT32 index);
|
||||
extern CHAR *OsGetHwiFormName(UINT32 index);
|
||||
extern VOID OsInterrupt(UINT32 intNum);
|
||||
extern VOID OsSyscallHandleInit(VOID);
|
||||
|
||||
@@ -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
|
||||
@@ -72,7 +74,7 @@
|
||||
|
||||
STATIC UINTPTR g_minAddr;
|
||||
STATIC UINTPTR g_maxAddr;
|
||||
STATIC UINT32 g_currHandleExcCpuID = INVALID_CPUID;
|
||||
STATIC UINT32 g_currHandleExcCpuid = INVALID_CPUID;
|
||||
VOID OsExcHook(UINT32 excType, ExcContext *excBufAddr, UINT32 far, UINT32 fsr);
|
||||
UINT32 g_curNestCount[LOSCFG_KERNEL_CORE_NUM] = { 0 };
|
||||
BOOL g_excFromUserMode[LOSCFG_KERNEL_CORE_NUM];
|
||||
@@ -86,6 +88,7 @@ STATIC UINT32 g_nextExcWaitCpu = INVALID_CPUID;
|
||||
#define OS_MAX_BACKTRACE 15U
|
||||
#define DUMPSIZE 128U
|
||||
#define DUMPREGS 12U
|
||||
#define COM_REGS 4U
|
||||
#define INSTR_SET_MASK 0x01000020U
|
||||
#define THUMB_INSTR_LEN 2U
|
||||
#define ARM_INSTR_LEN 4U
|
||||
@@ -110,11 +113,11 @@ STATIC const StackInfo g_excStack[] = {
|
||||
UINT32 OsGetSystemStatus(VOID)
|
||||
{
|
||||
UINT32 flag;
|
||||
UINT32 cpuID = g_currHandleExcCpuID;
|
||||
UINT32 cpuid = g_currHandleExcCpuid;
|
||||
|
||||
if (cpuID == INVALID_CPUID) {
|
||||
if (cpuid == INVALID_CPUID) {
|
||||
flag = OS_SYSTEM_NORMAL;
|
||||
} else if (cpuID == ArchCurrCpuid()) {
|
||||
} else if (cpuid == ArchCurrCpuid()) {
|
||||
flag = OS_SYSTEM_EXC_CURR_CPU;
|
||||
} else {
|
||||
flag = OS_SYSTEM_EXC_OTHER_CPU;
|
||||
@@ -191,7 +194,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 {
|
||||
@@ -514,13 +517,22 @@ VOID OsDumpContextMem(const ExcContext *excBufAddr)
|
||||
return;
|
||||
}
|
||||
|
||||
for (excReg = &(excBufAddr->R0); count <= DUMPREGS; excReg++, count++) {
|
||||
for (excReg = &(excBufAddr->R0); count < COM_REGS; excReg++, count++) {
|
||||
if (IS_VALID_ADDR(*excReg)) {
|
||||
PrintExcInfo("\ndump mem around R%u:%p", count, (*excReg));
|
||||
OsDumpMemByte(DUMPSIZE, ((*excReg) - (DUMPSIZE >> 1)));
|
||||
}
|
||||
}
|
||||
|
||||
for (excReg = &(excBufAddr->R4); count < DUMPREGS; excReg++, count++) {
|
||||
if (IS_VALID_ADDR(*excReg)) {
|
||||
PrintExcInfo("\ndump mem around R%u:%p", count, (*excReg));
|
||||
OsDumpMemByte(DUMPSIZE, ((*excReg) - (DUMPSIZE >> 1)));
|
||||
}
|
||||
}
|
||||
if (IS_VALID_ADDR(excBufAddr->R12)) {
|
||||
PrintExcInfo("\ndump mem around R12:%p", excBufAddr->R12);
|
||||
OsDumpMemByte(DUMPSIZE, (excBufAddr->R12 - (DUMPSIZE >> 1)));
|
||||
}
|
||||
if (IS_VALID_ADDR(excBufAddr->SP)) {
|
||||
PrintExcInfo("\ndump mem around SP:%p", excBufAddr->SP);
|
||||
OsDumpMemByte(DUMPSIZE, (excBufAddr->SP - (DUMPSIZE >> 1)));
|
||||
@@ -529,15 +541,15 @@ VOID OsDumpContextMem(const ExcContext *excBufAddr)
|
||||
|
||||
STATIC VOID OsExcRestore(VOID)
|
||||
{
|
||||
UINT32 currCpuID = ArchCurrCpuid();
|
||||
UINT32 currCpuid = ArchCurrCpuid();
|
||||
|
||||
g_excFromUserMode[currCpuID] = FALSE;
|
||||
g_intCount[currCpuID] = 0;
|
||||
g_curNestCount[currCpuID] = 0;
|
||||
g_excFromUserMode[currCpuid] = FALSE;
|
||||
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)
|
||||
@@ -554,15 +566,15 @@ STATIC VOID OsUserExcHandle(ExcContext *excBufAddr)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
LOS_SpinLock(&g_excSerializerSpin);
|
||||
if (g_nextExcWaitCpu != INVALID_CPUID) {
|
||||
g_currHandleExcCpuID = g_nextExcWaitCpu;
|
||||
g_currHandleExcCpuid = g_nextExcWaitCpu;
|
||||
g_nextExcWaitCpu = INVALID_CPUID;
|
||||
} else {
|
||||
g_currHandleExcCpuID = INVALID_CPUID;
|
||||
g_currHandleExcCpuid = INVALID_CPUID;
|
||||
}
|
||||
g_currHandleExcPID = OS_INVALID_VALUE;
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
#else
|
||||
g_currHandleExcCpuID = INVALID_CPUID;
|
||||
g_currHandleExcCpuid = INVALID_CPUID;
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
@@ -587,7 +599,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);
|
||||
|
||||
@@ -643,6 +655,7 @@ STATIC INLINE BOOL FindSuitableStack(UINTPTR regFP, UINTPTR *start, UINTPTR *end
|
||||
const StackInfo *stack = NULL;
|
||||
vaddr_t kvaddr;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == TRUE) {
|
||||
taskCB = OsCurrTaskGet();
|
||||
stackStart = taskCB->userMapBase;
|
||||
@@ -653,6 +666,7 @@ STATIC INLINE BOOL FindSuitableStack(UINTPTR regFP, UINTPTR *start, UINTPTR *end
|
||||
}
|
||||
return found;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Search in the task stacks */
|
||||
for (index = 0; index < g_taskMaxNum; index++) {
|
||||
@@ -977,36 +991,14 @@ 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)
|
||||
STATIC VOID WaitAllCpuStop(UINT32 cpuid)
|
||||
{
|
||||
UINT32 i;
|
||||
UINT32 time = 0;
|
||||
|
||||
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;
|
||||
@@ -1020,19 +1012,19 @@ STATIC VOID WaitAllCpuStop(UINT32 cpuID)
|
||||
return;
|
||||
}
|
||||
|
||||
STATIC VOID OsWaitOtherCoresHandleExcEnd(UINT32 currCpuID)
|
||||
STATIC VOID OsWaitOtherCoresHandleExcEnd(UINT32 currCpuid)
|
||||
{
|
||||
while (1) {
|
||||
LOS_SpinLock(&g_excSerializerSpin);
|
||||
if ((g_currHandleExcCpuID == INVALID_CPUID) || (g_currHandleExcCpuID == currCpuID)) {
|
||||
g_currHandleExcCpuID = currCpuID;
|
||||
if ((g_currHandleExcCpuid == INVALID_CPUID) || (g_currHandleExcCpuid == currCpuid)) {
|
||||
g_currHandleExcCpuid = currCpuid;
|
||||
g_currHandleExcPID = OsCurrProcessGet()->processID;
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
break;
|
||||
}
|
||||
|
||||
if (g_nextExcWaitCpu == INVALID_CPUID) {
|
||||
g_nextExcWaitCpu = currCpuID;
|
||||
g_nextExcWaitCpu = currCpuid;
|
||||
}
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
LOS_Mdelay(EXC_WAIT_INTER);
|
||||
@@ -1041,25 +1033,25 @@ STATIC VOID OsWaitOtherCoresHandleExcEnd(UINT32 currCpuID)
|
||||
|
||||
STATIC VOID OsCheckAllCpuStatus(VOID)
|
||||
{
|
||||
UINT32 currCpuID = ArchCurrCpuid();
|
||||
UINT32 currCpuid = ArchCurrCpuid();
|
||||
UINT32 ret, target;
|
||||
|
||||
OsPercpuGet()->excFlag = CPU_EXC;
|
||||
OsCpuStatusSet(CPU_EXC);
|
||||
LOCKDEP_CLEAR_LOCKS();
|
||||
|
||||
LOS_SpinLock(&g_excSerializerSpin);
|
||||
/* Only the current CPU anomaly */
|
||||
if (g_currHandleExcCpuID == INVALID_CPUID) {
|
||||
g_currHandleExcCpuID = currCpuID;
|
||||
if (g_currHandleExcCpuid == INVALID_CPUID) {
|
||||
g_currHandleExcCpuid = currCpuid;
|
||||
g_currHandleExcPID = OsCurrProcessGet()->processID;
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
#ifndef LOSCFG_SAVE_EXCINFO
|
||||
if (g_excFromUserMode[currCpuID] == FALSE) {
|
||||
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuID));
|
||||
if (g_excFromUserMode[currCpuid] == FALSE) {
|
||||
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuid));
|
||||
HalIrqSendIpi(target, LOS_MP_IPI_HALT);
|
||||
}
|
||||
#endif
|
||||
} else if (g_excFromUserMode[currCpuID] == TRUE) {
|
||||
} else if (g_excFromUserMode[currCpuid] == TRUE) {
|
||||
/* Both cores raise exceptions, and the current core is a user-mode exception.
|
||||
* Both cores are abnormal and come from the same process
|
||||
*/
|
||||
@@ -1071,12 +1063,12 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
|
||||
}
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
|
||||
OsWaitOtherCoresHandleExcEnd(currCpuID);
|
||||
OsWaitOtherCoresHandleExcEnd(currCpuid);
|
||||
} else {
|
||||
if ((g_currHandleExcCpuID < LOSCFG_KERNEL_CORE_NUM) && (g_excFromUserMode[g_currHandleExcCpuID] == TRUE)) {
|
||||
g_currHandleExcCpuID = currCpuID;
|
||||
if ((g_currHandleExcCpuid < LOSCFG_KERNEL_CORE_NUM) && (g_excFromUserMode[g_currHandleExcCpuid] == TRUE)) {
|
||||
g_currHandleExcCpuid = currCpuid;
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuID));
|
||||
target = (UINT32)(OS_MP_CPU_ALL & ~CPUID_TO_AFFI_MASK(currCpuid));
|
||||
HalIrqSendIpi(target, LOS_MP_IPI_HALT);
|
||||
} else {
|
||||
LOS_SpinUnlock(&g_excSerializerSpin);
|
||||
@@ -1086,7 +1078,7 @@ STATIC VOID OsCheckAllCpuStatus(VOID)
|
||||
#ifndef LOSCFG_SAVE_EXCINFO
|
||||
/* use halt ipi to stop other active cores */
|
||||
if (g_excFromUserMode[ArchCurrCpuid()] == FALSE) {
|
||||
WaitAllCpuStop(currCpuID);
|
||||
WaitAllCpuStop(currCpuid);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -1097,7 +1089,7 @@ STATIC VOID OsCheckCpuStatus(VOID)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
OsCheckAllCpuStatus();
|
||||
#else
|
||||
g_currHandleExcCpuID = ArchCurrCpuid();
|
||||
g_currHandleExcCpuid = ArchCurrCpuid();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1152,15 +1144,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 +1169,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()]++;
|
||||
|
||||
|
||||
@@ -46,16 +46,11 @@ LITE_OS_SEC_BSS SPIN_LOCK_INIT(g_hwiSpin);
|
||||
size_t g_intCount[LOSCFG_KERNEL_CORE_NUM] = {0};
|
||||
HwiHandleForm g_hwiForm[OS_HWI_MAX_NUM];
|
||||
STATIC CHAR *g_hwiFormName[OS_HWI_MAX_NUM] = {0};
|
||||
STATIC UINT32 g_hwiFormCnt[OS_HWI_MAX_NUM] = {0};
|
||||
STATIC UINT32 g_hwiFormCnt[LOSCFG_KERNEL_CORE_NUM][OS_HWI_MAX_NUM] = {0};
|
||||
|
||||
VOID OsIncHwiFormCnt(UINT32 index)
|
||||
UINT32 OsGetHwiFormCnt(UINT16 cpuid, UINT32 index)
|
||||
{
|
||||
g_hwiFormCnt[index]++;
|
||||
}
|
||||
|
||||
UINT32 OsGetHwiFormCnt(UINT32 index)
|
||||
{
|
||||
return g_hwiFormCnt[index];
|
||||
return g_hwiFormCnt[cpuid][index];
|
||||
}
|
||||
|
||||
CHAR *OsGetHwiFormName(UINT32 index)
|
||||
@@ -74,16 +69,17 @@ VOID OsInterrupt(UINT32 intNum)
|
||||
{
|
||||
HwiHandleForm *hwiForm = NULL;
|
||||
UINT32 *intCnt = NULL;
|
||||
UINT16 cpuid = ArchCurrCpuid();
|
||||
|
||||
/* Must keep the operation at the beginning of the interface */
|
||||
intCnt = &g_intCount[ArchCurrCpuid()];
|
||||
intCnt = &g_intCount[cpuid];
|
||||
*intCnt = *intCnt + 1;
|
||||
|
||||
OsSchedIrqStartTime();
|
||||
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
OsCpupIrqStart();
|
||||
OsCpupIrqStart(cpuid);
|
||||
#endif
|
||||
|
||||
OsSchedIrqStartTime();
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_ENTER, intNum);
|
||||
hwiForm = (&g_hwiForm[intNum]);
|
||||
#ifndef LOSCFG_NO_SHARED_IRQ
|
||||
@@ -105,14 +101,14 @@ VOID OsInterrupt(UINT32 intNum)
|
||||
#ifndef LOSCFG_NO_SHARED_IRQ
|
||||
}
|
||||
#endif
|
||||
++g_hwiFormCnt[intNum];
|
||||
++g_hwiFormCnt[cpuid][intNum];
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_ISR_EXIT, intNum);
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
OsCpupIrqEnd(intNum);
|
||||
#endif
|
||||
OsSchedIrqUpdateUsedTime();
|
||||
OsSchedIrqUsedTimeUpdate();
|
||||
|
||||
#ifdef LOSCFG_CPUP_INCLUDE_IRQ
|
||||
OsCpupIrqEnd(cpuid, intNum);
|
||||
#endif
|
||||
/* Must keep the operation at the end of the interface */
|
||||
*intCnt = *intCnt - 1;
|
||||
}
|
||||
|
||||
@@ -121,8 +121,9 @@ reset_vector:
|
||||
mcr p15, 0, r0, c13, c0, 4
|
||||
/* do some early cpu setup: i/d cache disable, mmu disabled */
|
||||
mrc p15, 0, r0, c1, c0, 0
|
||||
bic r0, #(1<<12)
|
||||
bic r0, #(1<<2 | 1<<0)
|
||||
bic r0, #(1 << 12) /* i cache */
|
||||
bic r0, #(1 << 2) /* d cache */
|
||||
bic r0, #(1 << 0) /* mmu */
|
||||
mcr p15, 0, r0, c1, c0, 0
|
||||
|
||||
/* enable fpu+neon */
|
||||
@@ -282,11 +283,11 @@ mmu_setup:
|
||||
mcr p15, 0, r12, c1, c0, 1 /* ACTLR, Auxlliary Control Register */
|
||||
dsb
|
||||
mrc p15, 0, r12, c1, c0, 0
|
||||
bic r12, #(1 << 29 | 1 << 28)
|
||||
orr r12, #(1 << 0)
|
||||
bic r12, #(1 << 29 | 1 << 28) /* Disable TRE/AFE */
|
||||
orr r12, #(1 << 0) /* mmu enable */
|
||||
bic r12, #(1 << 1)
|
||||
orr r12, #(1 << 2)
|
||||
orr r12, #(1 << 12)
|
||||
orr r12, #(1 << 2) /* D cache enable */
|
||||
orr r12, #(1 << 12) /* I cache enable */
|
||||
mcr p15, 0, r12, c1, c0, 0 /* Set SCTLR with r12: Turn on the MMU, I/D cache Disable TRE/AFE */
|
||||
isb
|
||||
ldr pc, =1f /* Convert to VA */
|
||||
|
||||
@@ -101,8 +101,9 @@ __exception_handlers:
|
||||
reset_vector:
|
||||
/* do some early cpu setup: i/d cache disable, mmu disabled */
|
||||
mrc p15, 0, r0, c1, c0, 0
|
||||
bic r0, #(1<<12)
|
||||
bic r0, #(1<<2 | 1<<0)
|
||||
bic r0, #(1 << 12) /* i cache */
|
||||
bic r0, #(1 << 2) /* d cache */
|
||||
bic r0, #(1 << 0) /* mmu */
|
||||
mcr p15, 0, r0, c1, c0, 0
|
||||
|
||||
/* enable fpu+neon */
|
||||
@@ -269,11 +270,11 @@ mmu_setup:
|
||||
isb
|
||||
|
||||
mrc p15, 0, r12, c1, c0, 0
|
||||
bic r12, #(1 << 29 | 1 << 28)
|
||||
orr r12, #(1 << 0)
|
||||
bic r12, #(1 << 29 | 1 << 28) /* Disable TRE/AFE */
|
||||
orr r12, #(1 << 0) /* mmu enable */
|
||||
bic r12, #(1 << 1)
|
||||
orr r12, #(1 << 2)
|
||||
orr r12, #(1 << 12)
|
||||
orr r12, #(1 << 2) /* D cache enable */
|
||||
orr r12, #(1 << 12) /* I cache enable */
|
||||
mcr p15, 0, r12, c1, c0, 0 /* Set SCTLR with r12: Turn on the MMU, I/D cache Disable TRE/AFE */
|
||||
isb
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ INT32 LOS_StrncpyFromUser(CHAR *dst, const CHAR *src, INT32 count)
|
||||
}
|
||||
|
||||
maxCount = (LOS_IsUserAddressRange((VADDR_T)(UINTPTR)src, (size_t)count)) ? \
|
||||
count : (USER_ASPACE_TOP_MAX - (UINTPTR)src);
|
||||
count : (INT32)(USER_ASPACE_TOP_MAX - (UINTPTR)src);
|
||||
|
||||
for (i = 0; i < maxCount; ++i) {
|
||||
if (LOS_GetUser(&character, src + offset) != LOS_OK) {
|
||||
|
||||
@@ -49,7 +49,7 @@ STATIC UINT32 g_curIrqNum = 0;
|
||||
*/
|
||||
STATIC VOID GicWriteSgi(UINT32 vector, UINT32 cpuMask, UINT32 filter)
|
||||
{
|
||||
UINT32 val = ((filter & 0x3) << 24) | ((cpuMask & 0xFF) << 16) |
|
||||
UINT32 val = ((filter & 0x3) << 24) | ((cpuMask & 0xFF) << 16) | /* 24, 16: Register bit offset */
|
||||
(vector & 0xF);
|
||||
|
||||
GIC_REG_32(GICD_SGIR) = val;
|
||||
@@ -62,7 +62,7 @@ VOID HalIrqSendIpi(UINT32 target, UINT32 ipi)
|
||||
|
||||
VOID HalIrqSetAffinity(UINT32 vector, UINT32 cpuMask)
|
||||
{
|
||||
UINT32 offset = vector / 4;
|
||||
UINT32 offset = vector / 4; /* 4: Interrupt bit width */
|
||||
UINT32 index = vector & 0x3;
|
||||
|
||||
GIC_REG_8(GICD_ITARGETSR(offset) + index) = cpuMask;
|
||||
@@ -80,7 +80,7 @@ VOID HalIrqMask(UINT32 vector)
|
||||
return;
|
||||
}
|
||||
|
||||
GIC_REG_32(GICD_ICENABLER(vector / 32)) = 1U << (vector % 32);
|
||||
GIC_REG_32(GICD_ICENABLER(vector / 32)) = 1U << (vector % 32); /* 32: Interrupt bit width */
|
||||
}
|
||||
|
||||
VOID HalIrqUnmask(UINT32 vector)
|
||||
@@ -89,7 +89,7 @@ VOID HalIrqUnmask(UINT32 vector)
|
||||
return;
|
||||
}
|
||||
|
||||
GIC_REG_32(GICD_ISENABLER(vector >> 5)) = 1U << (vector % 32);
|
||||
GIC_REG_32(GICD_ISENABLER(vector >> 5)) = 1U << (vector % 32); /* 5, 32: Register bit offset */
|
||||
}
|
||||
|
||||
VOID HalIrqPending(UINT32 vector)
|
||||
@@ -98,7 +98,7 @@ VOID HalIrqPending(UINT32 vector)
|
||||
return;
|
||||
}
|
||||
|
||||
GIC_REG_32(GICD_ISPENDR(vector >> 5)) = 1U << (vector % 32);
|
||||
GIC_REG_32(GICD_ISPENDR(vector >> 5)) = 1U << (vector % 32); /* 5, 32: Register bit offset */
|
||||
}
|
||||
|
||||
VOID HalIrqClear(UINT32 vector)
|
||||
@@ -119,24 +119,24 @@ VOID HalIrqInit(VOID)
|
||||
{
|
||||
UINT32 i;
|
||||
|
||||
/* set externel interrupts to be level triggered, active low. */
|
||||
for (i = 32; i < OS_HWI_MAX_NUM; i += 16) {
|
||||
GIC_REG_32(GICD_ICFGR(i / 16)) = 0;
|
||||
/* set external interrupts to be level triggered, active low. */
|
||||
for (i = 32; i < OS_HWI_MAX_NUM; i += 16) { /* 32: Start interrupt number, 16: Interrupt bit width */
|
||||
GIC_REG_32(GICD_ICFGR(i / 16)) = 0; /* 16: Register bit offset */
|
||||
}
|
||||
|
||||
/* set externel interrupts to CPU 0 */
|
||||
for (i = 32; i < OS_HWI_MAX_NUM; i += 4) {
|
||||
/* set external interrupts to CPU 0 */
|
||||
for (i = 32; i < OS_HWI_MAX_NUM; i += 4) { /* 32: Start interrupt number, 4: Interrupt bit width */
|
||||
GIC_REG_32(GICD_ITARGETSR(i / 4)) = 0x01010101;
|
||||
}
|
||||
|
||||
/* set priority on all interrupts */
|
||||
for (i = 0; i < OS_HWI_MAX_NUM; i += 4) {
|
||||
for (i = 0; i < OS_HWI_MAX_NUM; i += 4) { /* 4: Interrupt bit width */
|
||||
GIC_REG_32(GICD_IPRIORITYR(i / 4)) = GICD_INT_DEF_PRI_X4;
|
||||
}
|
||||
|
||||
/* disable all interrupts. */
|
||||
for (i = 0; i < OS_HWI_MAX_NUM; i += 32) {
|
||||
GIC_REG_32(GICD_ICENABLER(i / 32)) = ~0;
|
||||
for (i = 0; i < OS_HWI_MAX_NUM; i += 32) { /* 32: Interrupt bit width */
|
||||
GIC_REG_32(GICD_ICENABLER(i / 32)) = ~0; /* 32: Interrupt bit width */
|
||||
}
|
||||
|
||||
HalIrqInitPercpu();
|
||||
|
||||
@@ -42,9 +42,9 @@ STATIC UINT32 g_curIrqNum = 0;
|
||||
|
||||
STATIC INLINE UINT64 MpidrToAffinity(UINT64 mpidr)
|
||||
{
|
||||
return ((MPIDR_AFF_LEVEL(mpidr, 3) << 32) |
|
||||
(MPIDR_AFF_LEVEL(mpidr, 2) << 16) |
|
||||
(MPIDR_AFF_LEVEL(mpidr, 1) << 8) |
|
||||
return ((MPIDR_AFF_LEVEL(mpidr, 3) << 32) | /* 3: Serial number, 32: Register bit offset */
|
||||
(MPIDR_AFF_LEVEL(mpidr, 2) << 16) | /* 2: Serial number, 16: Register bit offset */
|
||||
(MPIDR_AFF_LEVEL(mpidr, 1) << 8) | /* 1: Serial number, 8: Register bit offset */
|
||||
(MPIDR_AFF_LEVEL(mpidr, 0)));
|
||||
}
|
||||
|
||||
@@ -106,10 +106,10 @@ STATIC VOID GicSgi(UINT32 irq, UINT32 cpuMask)
|
||||
tList = GicTargetList(&cpu, cpuMask, cluster);
|
||||
|
||||
/* Generates a Group 1 interrupt for the current security state */
|
||||
val = ((MPIDR_AFF_LEVEL(cluster, 3) << 48) |
|
||||
(MPIDR_AFF_LEVEL(cluster, 2) << 32) |
|
||||
(MPIDR_AFF_LEVEL(cluster, 1) << 16) |
|
||||
(irq << 24) | tList);
|
||||
val = ((MPIDR_AFF_LEVEL(cluster, 3) << 48) | /* 3: Serial number, 48: Register bit offset */
|
||||
(MPIDR_AFF_LEVEL(cluster, 2) << 32) | /* 2: Serial number, 32: Register bit offset */
|
||||
(MPIDR_AFF_LEVEL(cluster, 1) << 16) | /* 1: Serial number, 16: Register bit offset */
|
||||
(irq << 24) | tList); /* 24: Register bit offset */
|
||||
|
||||
GiccSetSgi1r(val);
|
||||
}
|
||||
@@ -150,9 +150,9 @@ STATIC INLINE VOID GicdSetGroup(UINT32 irq)
|
||||
{
|
||||
/* configure spi as group 0 on secure mode and group 1 on unsecure mode */
|
||||
#ifdef LOSCFG_ARCH_SECURE_MONITOR_MODE
|
||||
GIC_REG_32(GICD_IGROUPR(irq / 32)) = 0;
|
||||
GIC_REG_32(GICD_IGROUPR(irq / 32)) = 0; /* 32: Interrupt bit width */
|
||||
#else
|
||||
GIC_REG_32(GICD_IGROUPR(irq / 32)) = 0xffffffff;
|
||||
GIC_REG_32(GICD_IGROUPR(irq / 32)) = 0xffffffff; /* 32: Interrupt bit width */
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -248,13 +248,13 @@ UINT32 HalCurIrqGet(VOID)
|
||||
VOID HalIrqMask(UINT32 vector)
|
||||
{
|
||||
INT32 i;
|
||||
const UINT32 mask = 1U << (vector % 32);
|
||||
const UINT32 mask = 1U << (vector % 32); /* 32: Interrupt bit width */
|
||||
|
||||
if ((vector > OS_USER_HWI_MAX) || (vector < OS_USER_HWI_MIN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (vector < 32) {
|
||||
if (vector < 32) { /* 32: Interrupt bit width */
|
||||
for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
|
||||
GIC_REG_32(GICR_ICENABLER0(i)) = mask;
|
||||
GicWaitForRwp(GICR_CTLR(i));
|
||||
@@ -268,19 +268,19 @@ VOID HalIrqMask(UINT32 vector)
|
||||
VOID HalIrqUnmask(UINT32 vector)
|
||||
{
|
||||
INT32 i;
|
||||
const UINT32 mask = 1U << (vector % 32);
|
||||
const UINT32 mask = 1U << (vector % 32); /* 32: Interrupt bit width */
|
||||
|
||||
if ((vector > OS_USER_HWI_MAX) || (vector < OS_USER_HWI_MIN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (vector < 32) {
|
||||
if (vector < 32) { /* 32: Interrupt bit width */
|
||||
for (i = 0; i < LOSCFG_KERNEL_CORE_NUM; i++) {
|
||||
GIC_REG_32(GICR_ISENABLER0(i)) = mask;
|
||||
GicWaitForRwp(GICR_CTLR(i));
|
||||
}
|
||||
} else {
|
||||
GIC_REG_32(GICD_ISENABLER(vector >> 5)) = mask;
|
||||
GIC_REG_32(GICD_ISENABLER(vector >> 5)) = mask; /* 5: Register bit offset */
|
||||
GicWaitForRwp(GICD_CTLR);
|
||||
}
|
||||
}
|
||||
@@ -291,7 +291,7 @@ VOID HalIrqPending(UINT32 vector)
|
||||
return;
|
||||
}
|
||||
|
||||
GIC_REG_32(GICD_ISPENDR(vector >> 5)) = 1U << (vector % 32);
|
||||
GIC_REG_32(GICD_ISPENDR(vector >> 5)) = 1U << (vector % 32); /* 5: Register bit offset, 32: Interrupt bit width */
|
||||
}
|
||||
|
||||
VOID HalIrqClear(UINT32 vector)
|
||||
@@ -362,30 +362,30 @@ VOID HalIrqInit(VOID)
|
||||
GicWaitForRwp(GICD_CTLR);
|
||||
ISB;
|
||||
|
||||
/* set externel interrupts to be level triggered, active low. */
|
||||
for (i = 32; i < OS_HWI_MAX_NUM; i += 16) {
|
||||
/* set external interrupts to be level triggered, active low. */
|
||||
for (i = 32; i < OS_HWI_MAX_NUM; i += 16) { /* 32: Start interrupt number, 16: Interrupt bit width */
|
||||
GIC_REG_32(GICD_ICFGR(i / 16)) = 0;
|
||||
}
|
||||
|
||||
/* config distributer, mask and clear all spis, set group x */
|
||||
for (i = 32; i < OS_HWI_MAX_NUM; i += 32) {
|
||||
GIC_REG_32(GICD_ICENABLER(i / 32)) = 0xffffffff;
|
||||
GIC_REG_32(GICD_ICPENDR(i / 32)) = 0xffffffff;
|
||||
GIC_REG_32(GICD_IGRPMODR(i / 32)) = 0;
|
||||
for (i = 32; i < OS_HWI_MAX_NUM; i += 32) { /* 32: Start interrupt number, 32: Interrupt bit width */
|
||||
GIC_REG_32(GICD_ICENABLER(i / 32)) = 0xffffffff; /* 32: Interrupt bit width */
|
||||
GIC_REG_32(GICD_ICPENDR(i / 32)) = 0xffffffff; /* 32: Interrupt bit width */
|
||||
GIC_REG_32(GICD_IGRPMODR(i / 32)) = 0; /* 32: Interrupt bit width */
|
||||
|
||||
GicdSetGroup(i);
|
||||
}
|
||||
|
||||
/* set spi priority as default */
|
||||
for (i = 32; i < OS_HWI_MAX_NUM; i++) {
|
||||
for (i = 32; i < OS_HWI_MAX_NUM; i++) { /* 32: Start interrupt number */
|
||||
GicdSetPmr(i, MIN_INTERRUPT_PRIORITY);
|
||||
}
|
||||
|
||||
GicWaitForRwp(GICD_CTLR);
|
||||
|
||||
/* disable all interrupts. */
|
||||
for (i = 0; i < OS_HWI_MAX_NUM; i += 32) {
|
||||
GIC_REG_32(GICD_ICENABLER(i / 32)) = 0xffffffff;
|
||||
for (i = 0; i < OS_HWI_MAX_NUM; i += 32) { /* 32: Interrupt bit width */
|
||||
GIC_REG_32(GICD_ICENABLER(i / 32)) = 0xffffffff; /* 32: Interrupt bit width */
|
||||
}
|
||||
|
||||
/* enable distributor with ARE, group 1 enabled */
|
||||
@@ -393,7 +393,7 @@ VOID HalIrqInit(VOID)
|
||||
|
||||
/* set spi to boot cpu only. ARE must be enabled */
|
||||
affinity = MpidrToAffinity(AARCH64_SYSREG_READ(mpidr_el1));
|
||||
for (i = 32; i < OS_HWI_MAX_NUM; i++) {
|
||||
for (i = 32; i < OS_HWI_MAX_NUM; i++) { /* 32: Start interrupt number */
|
||||
GIC_REG_64(GICD_IROUTER(i)) = affinity;
|
||||
}
|
||||
|
||||
|
||||
@@ -77,8 +77,8 @@ enum {
|
||||
#define GICD_PIDR2V3 (GICD_OFFSET + 0xffe8)
|
||||
|
||||
#ifdef LOSCFG_ARCH_GIC_V3
|
||||
#define GICD_IGRPMODR(n) (GICD_OFFSET + 0x0d00 + (n) * 4) /* Interrupt Group Mode Reisters */
|
||||
#define GICD_IROUTER(n) (GICD_OFFSET + 0x6000 + (n) * 8) /* Interrupt Rounter Reisters */
|
||||
#define GICD_IGRPMODR(n) (GICD_OFFSET + 0x0d00 + (n) * 4) /* Interrupt Group Mode Registers */
|
||||
#define GICD_IROUTER(n) (GICD_OFFSET + 0x6000 + (n) * 8) /* Interrupt Rounter Registers */
|
||||
#endif
|
||||
|
||||
#define GIC_REG_8(reg) (*(volatile UINT8 *)((UINTPTR)(GIC_BASE_ADDR + (reg))))
|
||||
|
||||
0
arch/arm/include/gic_v3.h
Executable file → Normal file
0
arch/arm/include/gic_v3.h
Executable file → Normal file
65
bundle.json
Normal file
65
bundle.json
Normal file
@@ -0,0 +1,65 @@
|
||||
{
|
||||
"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",
|
||||
"FatFs",
|
||||
"mksh",
|
||||
"musl",
|
||||
"mbedtls",
|
||||
"FreeBSD",
|
||||
"zlib",
|
||||
"lwip",
|
||||
"optimized-routines",
|
||||
"googletest"
|
||||
]
|
||||
},
|
||||
"build": {
|
||||
"sub_component": [
|
||||
"//kernel/liteos_a:liteos_a"
|
||||
],
|
||||
"inner_kits": [],
|
||||
"test": []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ extern "C" {
|
||||
/* CONSTANTS */
|
||||
|
||||
#define MQ_USE_MAGIC 0x89abcdef
|
||||
/* not suppurt prio */
|
||||
/* not support prio */
|
||||
#define MQ_PRIO_MAX 1
|
||||
|
||||
typedef union send_receive_t {
|
||||
@@ -297,7 +297,7 @@ extern int mq_send(mqd_t personal, const char *msg, size_t msgLen, unsigned int
|
||||
* <li><b>EAGAIN</b>: The message queue is empty.</li>
|
||||
* <li><b>EINVAL</b>: invalid parameter.</li>
|
||||
* <li><b>EMSGSIZE</b>: The message to be received is too long.</li>
|
||||
* <li><b>ETIMEDOUT</b>: The operaton times out.</li>
|
||||
* <li><b>ETIMEDOUT</b>: The operation times out.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @par Dependency:
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
*/
|
||||
|
||||
void *calloc(size_t nitems, size_t size)
|
||||
{ /*lint !e578*/
|
||||
{
|
||||
size_t real_size;
|
||||
void *ptr = NULL;
|
||||
|
||||
@@ -78,7 +78,7 @@ void free(void *ptr)
|
||||
*/
|
||||
|
||||
void *malloc(size_t size)
|
||||
{ /*lint !e31 !e10*/
|
||||
{
|
||||
if (size == 0) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ void *malloc(size_t size)
|
||||
}
|
||||
|
||||
void *zalloc(size_t size)
|
||||
{ /*lint !e10*/
|
||||
{
|
||||
void *ptr = NULL;
|
||||
|
||||
if (size == 0) {
|
||||
@@ -142,4 +142,4 @@ void *realloc(void *ptr, size_t size)
|
||||
}
|
||||
|
||||
return LOS_KernelRealloc(ptr, (UINT32) size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -158,7 +158,7 @@ STATIC VOID SetPthreadAttr(const _pthread_data *self, const pthread_attr_t *attr
|
||||
}
|
||||
if (outAttr->inheritsched == PTHREAD_INHERIT_SCHED) {
|
||||
if (self->task == NULL) {
|
||||
outAttr->schedparam.sched_priority = ((LosTaskCB *)(OsCurrTaskGet()))->priority;
|
||||
outAttr->schedparam.sched_priority = LOS_TaskPriGet(OsCurrTaskGet()->taskID);
|
||||
} else {
|
||||
outAttr->schedpolicy = self->attr.schedpolicy;
|
||||
outAttr->schedparam = self->attr.schedparam;
|
||||
|
||||
@@ -387,9 +387,16 @@ int gettimeofday64(struct timeval64 *tv, struct timezone *tz)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_LIBC_NEWLIB
|
||||
int gettimeofday(struct timeval *tv, void *_tz)
|
||||
#else
|
||||
int gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||
#endif
|
||||
{
|
||||
struct timeval64 stTimeVal64 = {0};
|
||||
#ifdef LOSCFG_LIBC_NEWLIB
|
||||
struct timezone *tz = (struct timezone *)_tz;
|
||||
#endif
|
||||
|
||||
if (tv == NULL) {
|
||||
TIME_RETURN(EINVAL);
|
||||
@@ -647,7 +654,7 @@ int clock_getres(clockid_t clockID, struct timespec *tp)
|
||||
case CLOCK_MONOTONIC_RAW:
|
||||
case CLOCK_MONOTONIC:
|
||||
case CLOCK_REALTIME:
|
||||
/* the accessable rtc resolution */
|
||||
/* the accessible rtc resolution */
|
||||
tp->tv_nsec = OS_SYS_NS_PER_US; /* the precision of clock_gettime is 1us */
|
||||
tp->tv_sec = 0;
|
||||
break;
|
||||
@@ -718,6 +725,7 @@ typedef struct {
|
||||
|
||||
static VOID SwtmrProc(UINTPTR tmrArg)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_VM
|
||||
INT32 sig, ret;
|
||||
UINT32 intSave;
|
||||
pid_t pid;
|
||||
@@ -761,9 +769,47 @@ static VOID SwtmrProc(UINTPTR tmrArg)
|
||||
return;
|
||||
EXIT:
|
||||
PRINT_ERR("Dispatch signals failed!, ret: %d\r\n", ret);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
int timer_create(clockid_t clockID, struct sigevent *restrict evp, timer_t *restrict timerID)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT16 swtmrID;
|
||||
#ifdef LOSCFG_SECURITY_VID
|
||||
UINT16 vid;
|
||||
#endif
|
||||
|
||||
if (!timerID || (clockID != CLOCK_REALTIME) || !evp) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((evp->sigev_notify != SIGEV_THREAD) || evp->sigev_notify_attributes) {
|
||||
errno = ENOTSUP;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)evp->sigev_notify_function,
|
||||
&swtmrID, (UINTPTR)evp->sigev_value.sival_ptr);
|
||||
if (ret != LOS_OK) {
|
||||
errno = (ret == LOS_ERRNO_SWTMR_MAXSIZE) ? EAGAIN : EINVAL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_SECURITY_VID
|
||||
vid = AddNodeByRid(swtmrID);
|
||||
if (vid == MAX_INVALID_TIMER_VID) {
|
||||
(VOID)LOS_SwtmrDelete(swtmrID);
|
||||
return -1;
|
||||
}
|
||||
swtmrID = vid;
|
||||
#endif
|
||||
*timerID = (timer_t)(UINTPTR)swtmrID;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int OsTimerCreate(clockid_t clockID, struct ksigevent *evp, timer_t *timerID)
|
||||
{
|
||||
UINT32 ret;
|
||||
@@ -823,6 +869,7 @@ int timer_delete(timer_t timerID)
|
||||
{
|
||||
UINT16 swtmrID = (UINT16)(UINTPTR)timerID;
|
||||
VOID *arg = NULL;
|
||||
UINTPTR swtmrProc;
|
||||
|
||||
#ifdef LOSCFG_SECURITY_VID
|
||||
swtmrID = GetRidByVid(swtmrID);
|
||||
@@ -832,10 +879,11 @@ int timer_delete(timer_t timerID)
|
||||
}
|
||||
|
||||
arg = (VOID *)OS_SWT_FROM_SID(swtmrID)->uwArg;
|
||||
swtmrProc = (UINTPTR)OS_SWT_FROM_SID(swtmrID)->pfnHandler;
|
||||
if (LOS_SwtmrDelete(swtmrID)) {
|
||||
goto ERROUT;
|
||||
}
|
||||
if (arg != NULL) {
|
||||
if ((swtmrProc == (UINTPTR)SwtmrProc) && (arg != NULL)) {
|
||||
free(arg);
|
||||
}
|
||||
|
||||
@@ -979,7 +1027,11 @@ STATIC INT32 DoNanoSleep(UINT64 nanoseconds)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_LIBC_NEWLIB
|
||||
int usleep(unsigned long useconds)
|
||||
#else
|
||||
int usleep(unsigned useconds)
|
||||
#endif
|
||||
{
|
||||
return DoNanoSleep((UINT64)useconds * OS_SYS_NS_PER_US);
|
||||
}
|
||||
|
||||
@@ -45,8 +45,6 @@
|
||||
#include "bcache.h"
|
||||
#endif
|
||||
|
||||
#include "pthread.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
@@ -165,7 +163,7 @@ extern "C" {
|
||||
#define DISK_ATA_GET_MODEL 21 /* Get model name */
|
||||
#define DISK_ATA_GET_SN 22 /* Get serial number */
|
||||
|
||||
#ifdef LOSCFG_FS_FAT_CACHE
|
||||
#ifndef LOSCFG_FS_FAT_CACHE
|
||||
#define DISK_DIRECT_BUFFER_SIZE 4 /* los_disk direct io buffer when bcache is off */
|
||||
#endif
|
||||
|
||||
@@ -253,7 +251,7 @@ struct disk_divide_info {
|
||||
* </ul>
|
||||
*
|
||||
* @param diskName [IN] Type #const CHAR * disk driver name.
|
||||
* @param bops [IN] Type #const struct block_operations * block driver control sturcture.
|
||||
* @param bops [IN] Type #const struct block_operations * block driver control structure.
|
||||
* @param priv [IN] Type #VOID * private data of vnode.
|
||||
* @param diskID [IN] Type #INT32 disk id number, less than SYS_MAX_DISK.
|
||||
* @param info [IN] Type #VOID * disk driver partition information.
|
||||
@@ -712,7 +710,7 @@ INT32 los_alloc_diskid_byname(const CHAR *diskName);
|
||||
* @brief get the INUSED disk id.
|
||||
*
|
||||
* @par Description:
|
||||
* Get the correponding INUSED disk id by diskName.
|
||||
* Get the corresponding INUSED disk id by diskName.
|
||||
*
|
||||
* @attention
|
||||
* <ul>
|
||||
|
||||
@@ -107,7 +107,7 @@ INT32 los_alloc_diskid_byname(const CHAR *diskName)
|
||||
size_t nameLen;
|
||||
|
||||
if (diskName == NULL) {
|
||||
PRINT_ERR("The paramter disk_name is NULL");
|
||||
PRINT_ERR("The parameter disk_name is NULL");
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ INT32 los_get_diskid_byname(const CHAR *diskName)
|
||||
size_t diskNameLen;
|
||||
|
||||
if (diskName == NULL) {
|
||||
PRINT_ERR("The paramter diskName is NULL");
|
||||
PRINT_ERR("The parameter diskName is NULL");
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
@@ -756,7 +756,7 @@ INT32 DiskPartitionRegister(los_disk *disk)
|
||||
los_part *part = NULL;
|
||||
struct disk_divide_info parInfo;
|
||||
|
||||
/* Fill disk_divide_info structure to set partition's infomation. */
|
||||
/* Fill disk_divide_info structure to set partition's information. */
|
||||
(VOID)memset_s(parInfo.part, sizeof(parInfo.part), 0, sizeof(parInfo.part));
|
||||
partSize = sizeof(parInfo.part) / sizeof(parInfo.part[0]);
|
||||
|
||||
@@ -788,7 +788,7 @@ INT32 DiskPartitionRegister(los_disk *disk)
|
||||
}
|
||||
|
||||
for (i = 0; i < partSize; i++) {
|
||||
/* Read the disk_divide_info structure to get partition's infomation. */
|
||||
/* Read the disk_divide_info structure to get partition's information. */
|
||||
if ((parInfo.part[i].type != 0) && (parInfo.part[i].type != EXTENDED_PAR) &&
|
||||
(parInfo.part[i].type != EXTENDED_8G)) {
|
||||
part = get_part(DiskAddPart(disk, parInfo.part[i].sector_start, parInfo.part[i].sector_count, TRUE));
|
||||
|
||||
@@ -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" ]
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ void RandomOperationsInit(const RandomOperations *r)
|
||||
if (r != NULL) {
|
||||
(void)memcpy_s(&g_randomOp, sizeof(RandomOperations), r, sizeof(RandomOperations));
|
||||
} else {
|
||||
PRINT_ERR("param is invalid\n", __FUNCTION__, __LINE__);
|
||||
PRINT_ERR("%s %d param is invalid\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ static ssize_t TraceWrite(struct file *filep, const char *buffer, size_t buflen)
|
||||
if (info == NULL) {
|
||||
return -ENOMEM;
|
||||
}
|
||||
memset_s(info, infoLen, 0, infoLen);
|
||||
(void)memset_s(info, infoLen, 0, infoLen);
|
||||
|
||||
ret = LOS_CopyToKernel(info, infoLen, buffer, buflen);
|
||||
if (ret != 0) {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -289,7 +289,7 @@ static INT32 BlockDriverRegisterOperate(mtd_partition *newNode,
|
||||
if (ret) {
|
||||
free(newNode->blockdriver_name);
|
||||
newNode->blockdriver_name = NULL;
|
||||
PRINT_ERR("register blkdev partion error\n");
|
||||
PRINT_ERR("register blkdev partition error\n");
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
@@ -322,7 +322,7 @@ static INT32 CharDriverRegisterOperate(mtd_partition *newNode,
|
||||
|
||||
ret = register_driver(newNode->chardriver_name, param->char_ops, RWE_RW_RW, newNode);
|
||||
if (ret) {
|
||||
PRINT_ERR("register chardev partion error\n");
|
||||
PRINT_ERR("register chardev partition error\n");
|
||||
free(newNode->chardriver_name);
|
||||
newNode->chardriver_name = NULL;
|
||||
return ret;
|
||||
@@ -340,7 +340,7 @@ static INT32 BlockDriverUnregister(mtd_partition *node)
|
||||
if (node->blockdriver_name != NULL) {
|
||||
ret = unregister_blockdriver(node->blockdriver_name);
|
||||
if (ret == -EBUSY) {
|
||||
PRINT_ERR("unregister blkdev partion error:%d\n", ret);
|
||||
PRINT_ERR("unregister blkdev partition error:%d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
free(node->blockdriver_name);
|
||||
@@ -356,7 +356,7 @@ static INT32 CharDriverUnregister(mtd_partition *node)
|
||||
if (node->chardriver_name != NULL) {
|
||||
ret = unregister_driver(node->chardriver_name);
|
||||
if (ret == -EBUSY) {
|
||||
PRINT_ERR("unregister chardev partion error:%d\n", ret);
|
||||
PRINT_ERR("unregister chardev partition error:%d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
free(node->chardriver_name);
|
||||
|
||||
@@ -4,7 +4,7 @@ source "fs/ramfs/Kconfig"
|
||||
source "fs/romfs/Kconfig"
|
||||
source "fs/nfs/Kconfig"
|
||||
source "fs/proc/Kconfig"
|
||||
source "fs/jffs2/Kconfig"
|
||||
#source "fs/jffs2/Kconfig"
|
||||
source "fs/rootfs/Kconfig"
|
||||
source "fs/patchfs/Kconfig"
|
||||
source "fs/zpfs/Kconfig"
|
||||
source "fs/zpfs/Kconfig"
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -1861,7 +1861,7 @@ static FRESULT fatfs_setlabel(los_part *part)
|
||||
return result;
|
||||
}
|
||||
|
||||
int fatfs_mkfs (struct Vnode *device, int sectors, int option)
|
||||
int fatfs_mkfs(struct Vnode *device, int sectors, int option)
|
||||
{
|
||||
BYTE *work_buff = NULL;
|
||||
los_part *part = NULL;
|
||||
|
||||
@@ -137,7 +137,7 @@ int fatfs_readdir(struct Vnode *vnode, struct fs_dirent_s *idir);
|
||||
int fatfs_rewinddir(struct Vnode *vnode, struct fs_dirent_s *dir);
|
||||
int fatfs_closedir(struct Vnode *vnode, struct fs_dirent_s *dir);
|
||||
int fatfs_rename(struct Vnode *oldvnode, struct Vnode *newparent, const char *oldname, const char *newname);
|
||||
int fatfs_mkfs (struct Vnode *device, int sectors, int option);
|
||||
int fatfs_mkfs(struct Vnode *device, int sectors, int option);
|
||||
int fatfs_mkdir(struct Vnode *parent, const char *name, mode_t mode, struct Vnode **vpp);
|
||||
int fatfs_rmdir(struct Vnode *parent, struct Vnode *vp, const char *name);
|
||||
int fatfs_unlink(struct Vnode *parent, struct Vnode *vp, const char *name);
|
||||
|
||||
@@ -319,7 +319,7 @@ FRESULT f_regvirfs(FATFS *fs)
|
||||
|
||||
/* Set the CHILD object field */
|
||||
for (i = 0; i < fs->vir_amount; i++) {
|
||||
pfs = ff_memalloc(sizeof(FATFS)); /* Allocate a memeory for current child FATFS object */
|
||||
pfs = ff_memalloc(sizeof(FATFS)); /* Allocate a memory for current child FATFS object */
|
||||
if (pfs == NULL) { /* If allocate failed, must call 'f_unregvirfs' to free the previous FATFS object memory */
|
||||
goto ERROUT;
|
||||
}
|
||||
@@ -500,7 +500,7 @@ static void FatfsSetChildClst(BYTE *work, FATFS *fs, WORD i)
|
||||
* - FR_OK : The external SD configure is complete, all info has been set to the
|
||||
* each CHILD FATFS
|
||||
* - FR_NOT_MATCHED : The virtual partition's configure does not matched as current setting
|
||||
* - FR_MODIFIED : The virtual partition's configure has been destoried partly or completely
|
||||
* - FR_MODIFIED : The virtual partition's configure has been destroyed partly or completely
|
||||
* - FR_NOVIRPART : The external SD has not been apllied as virtual partition yet
|
||||
*
|
||||
* Others Return Value:
|
||||
@@ -581,11 +581,11 @@ FRESULT f_checkvirpart(FATFS *fs, const TCHAR *path, BYTE vol)
|
||||
labelTmp = (DWORD *)label;
|
||||
*labelTmp = tmp;
|
||||
tmp = ld_dword(work + VR_PARTITION + i * VR_ITEMSIZE + VR_Entry + 4);
|
||||
*((DWORD * )(label + 4)) = tmp;
|
||||
*((DWORD *)(label + 4)) = tmp;
|
||||
tmp = ld_dword(work + VR_PARTITION + i * VR_ITEMSIZE + VR_Entry + 8);
|
||||
*((DWORD * )(label + 8)) = tmp;
|
||||
*((DWORD *)(label + 8)) = tmp;
|
||||
tmp = ld_dword(work + VR_PARTITION + i * VR_ITEMSIZE + VR_Entry + 12);
|
||||
*((DWORD * )(label + 12)) = tmp;
|
||||
*((DWORD *)(label + 12)) = tmp;
|
||||
|
||||
if (f_checkname(label) != FR_OK) {
|
||||
(void)f_unregvirfs(fs);
|
||||
@@ -721,11 +721,11 @@ FRESULT f_makevirpart(FATFS *fs, const TCHAR *path, BYTE vol)
|
||||
labelTmp = (DWORD *)label;
|
||||
tmp = *labelTmp;
|
||||
st_dword(work + VR_PARTITION + i * VR_ITEMSIZE + VR_Entry + 0, tmp);
|
||||
tmp = *((DWORD * )(label + 4));
|
||||
tmp = *((DWORD *)(label + 4));
|
||||
st_dword(work + VR_PARTITION + i * VR_ITEMSIZE + VR_Entry + 4, tmp);
|
||||
tmp = *((DWORD * )(label + 8));
|
||||
tmp = *((DWORD *)(label + 8));
|
||||
st_dword(work + VR_PARTITION + i * VR_ITEMSIZE + VR_Entry + 8, tmp);
|
||||
tmp = *((DWORD * )(label + 12));
|
||||
tmp = *((DWORD *)(label + 12));
|
||||
st_dword(work + VR_PARTITION + i * VR_ITEMSIZE + VR_Entry + 12, tmp);
|
||||
|
||||
virpartper += g_fatVirPart.virtualinfo.virpartpercent[i];
|
||||
|
||||
@@ -98,7 +98,7 @@ extern char *rindex(const char *s, int c);
|
||||
* @ingroup fs
|
||||
*
|
||||
* @par Description:
|
||||
* The set_label() function shall set the value of a global varible,
|
||||
* The set_label() function shall set the value of a global variable,
|
||||
* the value will be used to set the label of SD card in format().
|
||||
*
|
||||
* @param name [IN] label to set, the length must be less than 12
|
||||
|
||||
@@ -31,45 +31,86 @@ import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_JFFS)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
linux_path = rebase_path("//kernel/linux/linux-5.10")
|
||||
out_path = rebase_path(target_out_dir)
|
||||
|
||||
kernel_module(module_name) {
|
||||
patch_path = rebase_path(".")
|
||||
cmd = "if [ -d ${out_path}/jffs2_build ]; then rm -r ${out_path}/jffs2_build; fi && mkdir -p ${out_path}/jffs2_build/fs"
|
||||
cmd += " && cp ${linux_path}/fs/jffs2 ${out_path}/jffs2_build/fs/. -r"
|
||||
cmd += " && pushd ${out_path}/jffs2_build/"
|
||||
cmd += " && patch -p1 < ${patch_path}/jffs2.patch && popd"
|
||||
exec_script("//build/lite/run_shell_cmd.py", [ cmd ])
|
||||
|
||||
sources = [
|
||||
"src/jffs2_hash.c",
|
||||
"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",
|
||||
"${out_path}/jffs2_build/fs/jffs2/background.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/build.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/compr.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/compr_rtime.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/compr_rubin.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/compr_zlib.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/debug.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/dir.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/erase.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/file.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/fs.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/gc.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/malloc.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/nodelist.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/nodemgmt.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/read.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/readinode.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/scan.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/summary.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/super.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/write.c",
|
||||
"${out_path}/jffs2_build/fs/jffs2/writev.c",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs/jffs2",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel/fs",
|
||||
"${out_path}/jffs2_build/fs",
|
||||
"${out_path}/jffs2_build/fs/jffs2",
|
||||
]
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
|
||||
deps = [ ":cp_jffs2_src" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
|
||||
action("cp_jffs2_src") {
|
||||
script = "//build/lite/run_shell_cmd.py"
|
||||
|
||||
outputs = [
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/background.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/build.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/compr.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/compr_rtime.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/compr_rubin.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/compr_zlib.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/debug.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/dir.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/erase.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/file.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/fs.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/gc.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/malloc.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/nodelist.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/nodemgmt.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/read.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/readinode.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/scan.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/summary.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/super.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/write.c",
|
||||
"${target_out_dir}/jffs2_build/fs/jffs2/writev.c",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -31,13 +31,51 @@ include $(LITEOSTOPDIR)/config.mk
|
||||
|
||||
MODULE_NAME := $(notdir $(shell pwd))
|
||||
|
||||
LOCAL_SRCS := $(wildcard src/*.c) \
|
||||
$(wildcard $(LITEOSTHIRDPARTY)/Linux_Kernel/fs/jffs2/*.c)
|
||||
LINUX_PATH := $(LITEOSTOPDIR)/../linux/linux-5.10
|
||||
LOCAL_PATH := $(shell pwd)
|
||||
TEMP_SRC_PATH := $(OUT)/jffs2_build
|
||||
|
||||
LOCAL_SRCS := \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/background.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/build.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/compr.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/compr_rtime.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/compr_rubin.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/compr_zlib.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/debug.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/dir.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/erase.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/file.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/fs.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/gc.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/malloc.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/nodelist.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/nodemgmt.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/read.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/readinode.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/scan.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/summary.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/super.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/write.c \
|
||||
$(TEMP_SRC_PATH)/fs/jffs2/writev.c \
|
||||
$(LOCAL_PATH)/src/jffs2_hash.c \
|
||||
$(LOCAL_PATH)/src/vfs_jffs2.c \
|
||||
|
||||
LOCAL_INCLUDE := \
|
||||
-I $(LITEOSTOPDIR)/fs/jffs2/include \
|
||||
-I $(LITEOSTHIRDPARTY)/Linux_Kernel/fs/jffs2 \
|
||||
-I $(LITEOSTHIRDPARTY)/Linux_Kernel/fs
|
||||
-I $(TEMP_SRC_PATH)/fs/jffs2 \
|
||||
-I $(TEMP_SRC_PATH)/fs
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE)
|
||||
|
||||
.PHONY: patch patch_clean
|
||||
$(LOCAL_SRCS): patch
|
||||
|
||||
patch: patch_clean
|
||||
cp $(LINUX_PATH)/fs/jffs2 $(TEMP_SRC_PATH)/fs/. -r
|
||||
cd $(TEMP_SRC_PATH) && patch -p1 < $(LOCAL_PATH)/jffs2.patch
|
||||
|
||||
patch_clean:
|
||||
$(HIDE) $(RM) -rf $(TEMP_SRC_PATH)
|
||||
|
||||
include $(MODULE)
|
||||
|
||||
|
||||
9927
fs/jffs2/jffs2.patch
Normal file
9927
fs/jffs2/jffs2.patch
Normal file
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
}
|
||||
|
||||
@@ -55,14 +55,15 @@ INT32 OsMountPatchFs(VOID)
|
||||
}
|
||||
partInfo.fsType = strdup(FS_TYPE);
|
||||
if (partInfo.fsType == NULL) {
|
||||
return LOS_NOK;
|
||||
ret = LOS_NOK;
|
||||
goto EXIT;
|
||||
}
|
||||
partInfo.startAddr = PATCHFS_FLASH_ADDR;
|
||||
partInfo.partSize = PATCHFS_FLASH_SIZE;
|
||||
#else
|
||||
ret = GetPartitionInfo(&partInfo);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
goto EXIT;
|
||||
}
|
||||
partInfo.startAddr = (partInfo.startAddr >= 0) ? partInfo.startAddr : PATCHFS_FLASH_ADDR;
|
||||
partInfo.partSize = (partInfo.partSize >= 0) ? partInfo.partSize : PATCHFS_FLASH_SIZE;
|
||||
@@ -71,7 +72,7 @@ INT32 OsMountPatchFs(VOID)
|
||||
ret = LOS_NOK;
|
||||
partInfo.devName = strdup(PATCH_FLASH_DEV_NAME);
|
||||
if (partInfo.devName == NULL) {
|
||||
return LOS_NOK;
|
||||
goto EXIT;
|
||||
}
|
||||
const CHAR *devName = GetDevNameOfPartition(&partInfo);
|
||||
if (devName != NULL) {
|
||||
@@ -92,9 +93,13 @@ INT32 OsMountPatchFs(VOID)
|
||||
ResetDevNameofPartition(&partInfo);
|
||||
}
|
||||
|
||||
EXIT:
|
||||
free(partInfo.devName);
|
||||
partInfo.devName = NULL;
|
||||
free(partInfo.storageType);
|
||||
partInfo.storageType = NULL;
|
||||
free(partInfo.fsType);
|
||||
partInfo.fsType = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ typedef unsigned short fmode_t;
|
||||
#define FMODE_64BITHASH ((fmode_t)0x400)
|
||||
/* 32bit hashes as llseek() offset (for directories) */
|
||||
#define FMODE_32BITHASH ((fmode_t)0x200)
|
||||
/* File is opened using open(.., 3, ..) and is writeable only for ioctls
|
||||
/* File is opened using open(.., 3, ..) and is writable only for ioctls
|
||||
* (specialy hack for floppy.c)
|
||||
*/
|
||||
#define FMODE_WRITE_IOCTL ((fmode_t)0x100)
|
||||
|
||||
@@ -87,7 +87,7 @@ static struct ProcDirEntry *ProcFindNode(struct ProcDirEntry *parent, const char
|
||||
}
|
||||
|
||||
/*
|
||||
* descrition: find the file's handle
|
||||
* description: find the file's handle
|
||||
* path: the file of fullpath
|
||||
* return: the file of handle
|
||||
* add by ll
|
||||
@@ -519,7 +519,7 @@ int ProcOpen(struct ProcFile *procFile)
|
||||
|
||||
static int ProcRead(struct ProcDirEntry *pde, char *buf, size_t len)
|
||||
{
|
||||
if (pde == NULL || pde == NULL || pde->pf == NULL) {
|
||||
if (pde == NULL || pde->pf == NULL) {
|
||||
return PROC_ERROR;
|
||||
}
|
||||
struct ProcFile *procFile = pde->pf;
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -29,10 +29,9 @@ endchoice
|
||||
config BOOTENV_ADDR
|
||||
int "Address of boot command line (KB)"
|
||||
depends on PLATFORM_ROOTFS && (STORAGE_SPINOR || STORAGE_SPINAND || STORAGE_EMMC)
|
||||
range 0 1024
|
||||
default 512
|
||||
help
|
||||
Boot command line addr, range from 0 to 1MB.
|
||||
Boot command line addr.
|
||||
|
||||
config BOOTENV_RAM
|
||||
bool "Read bootenv from RAM"
|
||||
|
||||
@@ -214,7 +214,7 @@ UINT64 LOS_SizeStrToNum(CHAR *value)
|
||||
UINT64 num = 0;
|
||||
|
||||
/* If the string is a hexadecimal value */
|
||||
if (sscanf_s(value, "0x%x", &num) > 0) {
|
||||
if (sscanf_s(value, "0x%llx", &num) > 0) {
|
||||
value += strlen("0x");
|
||||
if (strspn(value, "0123456789abcdefABCDEF") < strlen(value)) {
|
||||
goto ERROUT;
|
||||
@@ -247,4 +247,4 @@ UINT64 LOS_SizeStrToNum(CHAR *value)
|
||||
ERROUT:
|
||||
PRINT_ERR("Invalid value string \"%s\"!\n", value);
|
||||
return num;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,7 +327,7 @@ STATIC INT32 CheckValidation(UINT64 rootAddr, UINT64 rootSize, UINT64 userAddr,
|
||||
|
||||
if ((rootAddr & (alignSize - 1)) || (rootSize & (alignSize - 1)) ||
|
||||
(userAddr & (alignSize - 1)) || (userSize & (alignSize - 1))) {
|
||||
PRINT_ERR("The address or size value should be 0x%x aligned!\n", alignSize);
|
||||
PRINT_ERR("The address or size value should be 0x%llx aligned!\n", alignSize);
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
@@ -371,4 +371,4 @@ INT32 OsMountRootfs()
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -351,7 +351,7 @@ static INT32 BcacheSyncBlock(OsBcache *bc, OsBcacheBlock *block)
|
||||
UINT32 len, start, end;
|
||||
|
||||
if (block->modified == TRUE) {
|
||||
D(("bcache writting block = %llu\n", block->num));
|
||||
D(("bcache writing block = %llu\n", block->num));
|
||||
|
||||
ret = FindFlagPos(block->flag, bc->sectorPerBlock >> UNINT_LOG2_SHIFT, &start, &end);
|
||||
if (ret == ENOERR) {
|
||||
@@ -932,7 +932,7 @@ INT32 BlockCacheWrite(OsBcache *bc, const UINT8 *buf, UINT32 *len, UINT64 sector
|
||||
bc->modifiedBlock++;
|
||||
}
|
||||
if ((pos == 0) && (currentSize == bc->blockSize)) {
|
||||
memset_s(block->flag, sizeof(block->flag), 0xFF, sizeof(block->flag));
|
||||
(void)memset_s(block->flag, sizeof(block->flag), 0xFF, sizeof(block->flag));
|
||||
block->allDirty = TRUE;
|
||||
} else {
|
||||
BcacheSetFlag(bc, block, (UINT32)pos, currentSize);
|
||||
|
||||
23
fs/vfs/epoll/fs_epoll.c
Executable file → Normal file
23
fs/vfs/epoll/fs_epoll.c
Executable file → Normal file
@@ -164,23 +164,23 @@ static VOID DoEpollClose(struct epoll_head *epHead)
|
||||
}
|
||||
|
||||
/**
|
||||
* epoll_create,
|
||||
* epoll_create unsupported api
|
||||
*
|
||||
* epoll_create is implemented by calling epoll_create1, it's parameter 'size' is useless.
|
||||
*
|
||||
* epoll_create1,
|
||||
* The simple version of epoll does not use red-black trees,
|
||||
* so when fd is normal value (greater than 0),
|
||||
* actually allocated epoll can manage num of EPOLL_DEFAULT_SIZE
|
||||
*
|
||||
* @param size: not actually used
|
||||
* @param flags: not actually used
|
||||
* @return epoll fd
|
||||
*/
|
||||
int epoll_create(int size)
|
||||
int epoll_create1(int flags)
|
||||
{
|
||||
(void)flags;
|
||||
int fd = -1;
|
||||
|
||||
if (size <= 0) {
|
||||
set_errno(EINVAL);
|
||||
return fd;
|
||||
}
|
||||
|
||||
struct epoll_head *epHead = (struct epoll_head *)malloc(sizeof(struct epoll_head));
|
||||
if (epHead == NULL) {
|
||||
set_errno(ENOMEM);
|
||||
@@ -242,6 +242,11 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ev == NULL) {
|
||||
set_errno(EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (op) {
|
||||
case EPOLL_CTL_ADD:
|
||||
ret = CheckFdExist(epHead, fd);
|
||||
@@ -304,7 +309,7 @@ int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, int timeout
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (maxevents <= 0) {
|
||||
if ((maxevents <= 0) || (evs == NULL)) {
|
||||
set_errno(EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
2
fs/vfs/include/epoll.h
Executable file → Normal file
2
fs/vfs/include/epoll.h
Executable file → Normal file
@@ -72,7 +72,7 @@ struct epoll_event {
|
||||
epoll_data_t data;
|
||||
};
|
||||
|
||||
int epoll_create(int size);
|
||||
int epoll_create1(int flags);
|
||||
int epoll_close(int epfd);
|
||||
int epoll_ctl(int epfd, int op, int fd, struct epoll_event *ev);
|
||||
int epoll_wait(int epfd, FAR struct epoll_event *evs, int maxevents, int timeout);
|
||||
|
||||
@@ -133,7 +133,7 @@ int fallocate64(int fd, int mode, off64_t offset, off64_t len)
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
if (filep->f_oflags & O_DIRECTORY) {
|
||||
if ((unsigned int)filep->f_oflags & O_DIRECTORY) {
|
||||
set_errno(EBADF);
|
||||
return VFS_ERROR;
|
||||
}
|
||||
|
||||
@@ -35,115 +35,174 @@
|
||||
#include "path_cache.h"
|
||||
|
||||
/* vnode operations returns EIO */
|
||||
static int ErrorVopCreate (struct Vnode *parent, const char *name, int mode, struct Vnode **vnode)
|
||||
static int ErrorVopCreate(struct Vnode *parent, const char *name, int mode, struct Vnode **vnode)
|
||||
{
|
||||
(void)parent;
|
||||
(void)name;
|
||||
(void)mode;
|
||||
(void)vnode;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopLookup (struct Vnode *parent, const char *name, int len, struct Vnode **vnode)
|
||||
static int ErrorVopLookup(struct Vnode *parent, const char *name, int len, struct Vnode **vnode)
|
||||
{
|
||||
(void)parent;
|
||||
(void)name;
|
||||
(void)len;
|
||||
(void)vnode;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopOpen (struct Vnode *vnode, int fd, int mode, int flags)
|
||||
static int ErrorVopOpen(struct Vnode *vnode, int fd, int mode, int flags)
|
||||
{
|
||||
(void)vnode;
|
||||
(void)fd;
|
||||
(void)mode;
|
||||
(void)flags;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopClose (struct Vnode *vnode)
|
||||
static int ErrorVopClose(struct Vnode *vnode)
|
||||
{
|
||||
(void)vnode;
|
||||
/* already closed at force umount, do nothing here */
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int ErrorVopReclaim (struct Vnode *vnode)
|
||||
static int ErrorVopReclaim(struct Vnode *vnode)
|
||||
{
|
||||
(void)vnode;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopUnlink (struct Vnode *parent, struct Vnode *vnode, const char *fileName)
|
||||
static int ErrorVopUnlink(struct Vnode *parent, struct Vnode *vnode, const char *fileName)
|
||||
{
|
||||
(void)parent;
|
||||
(void)vnode;
|
||||
(void)fileName;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopRmdir (struct Vnode *parent, struct Vnode *vnode, const char *dirName)
|
||||
static int ErrorVopRmdir(struct Vnode *parent, struct Vnode *vnode, const char *dirName)
|
||||
{
|
||||
(void)parent;
|
||||
(void)vnode;
|
||||
(void)dirName;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopMkdir (struct Vnode *parent, const char *dirName, mode_t mode, struct Vnode **vnode)
|
||||
static int ErrorVopMkdir(struct Vnode *parent, const char *dirName, mode_t mode, struct Vnode **vnode)
|
||||
{
|
||||
(void)parent;
|
||||
(void)dirName;
|
||||
(void)mode;
|
||||
(void)vnode;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopReaddir (struct Vnode *vnode, struct fs_dirent_s *dir)
|
||||
static int ErrorVopReaddir(struct Vnode *vnode, struct fs_dirent_s *dir)
|
||||
{
|
||||
(void)vnode;
|
||||
(void)dir;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopOpendir (struct Vnode *vnode, struct fs_dirent_s *dir)
|
||||
static int ErrorVopOpendir(struct Vnode *vnode, struct fs_dirent_s *dir)
|
||||
{
|
||||
(void)vnode;
|
||||
(void)dir;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopRewinddir (struct Vnode *vnode, struct fs_dirent_s *dir)
|
||||
static int ErrorVopRewinddir(struct Vnode *vnode, struct fs_dirent_s *dir)
|
||||
{
|
||||
(void)vnode;
|
||||
(void)dir;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopClosedir (struct Vnode *vnode, struct fs_dirent_s *dir)
|
||||
static int ErrorVopClosedir(struct Vnode *vnode, struct fs_dirent_s *dir)
|
||||
{
|
||||
(void)vnode;
|
||||
(void)dir;
|
||||
/* already closed at force umount, do nothing here */
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int ErrorVopGetattr (struct Vnode *vnode, struct stat *st)
|
||||
static int ErrorVopGetattr(struct Vnode *vnode, struct stat *st)
|
||||
{
|
||||
(void)vnode;
|
||||
(void)st;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopSetattr (struct Vnode *vnode, struct stat *st)
|
||||
static int ErrorVopSetattr(struct Vnode *vnode, struct stat *st)
|
||||
{
|
||||
(void)vnode;
|
||||
(void)st;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopChattr (struct Vnode *vnode, struct IATTR *attr)
|
||||
static int ErrorVopChattr(struct Vnode *vnode, struct IATTR *attr)
|
||||
{
|
||||
(void)vnode;
|
||||
(void)attr;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopRename (struct Vnode *src, struct Vnode *dstParent, const char *srcName, const char *dstName)
|
||||
static int ErrorVopRename(struct Vnode *src, struct Vnode *dstParent, const char *srcName, const char *dstName)
|
||||
{
|
||||
(void)src;
|
||||
(void)dstParent;
|
||||
(void)srcName;
|
||||
(void)dstName;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopTruncate (struct Vnode *vnode, off_t len)
|
||||
static int ErrorVopTruncate(struct Vnode *vnode, off_t len)
|
||||
{
|
||||
(void)vnode;
|
||||
(void)len;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopTruncate64 (struct Vnode *vnode, off64_t len)
|
||||
static int ErrorVopTruncate64(struct Vnode *vnode, off64_t len)
|
||||
{
|
||||
(void)vnode;
|
||||
(void)len;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopFscheck (struct Vnode *vnode, struct fs_dirent_s *dir)
|
||||
static int ErrorVopFscheck(struct Vnode *vnode, struct fs_dirent_s *dir)
|
||||
{
|
||||
(void)vnode;
|
||||
(void)dir;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopLink (struct Vnode *src, struct Vnode *dstParent, struct Vnode **dst, const char *dstName)
|
||||
static int ErrorVopLink(struct Vnode *src, struct Vnode *dstParent, struct Vnode **dst, const char *dstName)
|
||||
{
|
||||
(void)src;
|
||||
(void)dstParent;
|
||||
(void)dst;
|
||||
(void)dstName;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorVopSymlink (struct Vnode *parentVnode, struct Vnode **newVnode, const char *path, const char *target)
|
||||
static int ErrorVopSymlink(struct Vnode *parentVnode, struct Vnode **newVnode, const char *path, const char *target)
|
||||
{
|
||||
(void)parentVnode;
|
||||
(void)newVnode;
|
||||
(void)path;
|
||||
(void)target;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static ssize_t ErrorVopReadlink (struct Vnode *vnode, char *buffer, size_t bufLen)
|
||||
static ssize_t ErrorVopReadlink(struct Vnode *vnode, char *buffer, size_t bufLen)
|
||||
{
|
||||
(void)vnode;
|
||||
(void)buffer;
|
||||
(void)bufLen;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
@@ -173,74 +232,107 @@ static struct VnodeOps g_errorVnodeOps = {
|
||||
};
|
||||
|
||||
/* file operations returns EIO */
|
||||
static int ErrorFopOpen (struct file *filep)
|
||||
static int ErrorFopOpen(struct file *filep)
|
||||
{
|
||||
(void)filep;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorFopClose (struct file *filep)
|
||||
static int ErrorFopClose(struct file *filep)
|
||||
{
|
||||
(void)filep;
|
||||
/* already closed at force umount, do nothing here */
|
||||
return OK;
|
||||
}
|
||||
|
||||
static ssize_t ErrorFopRead (struct file *filep, char *buffer, size_t buflen)
|
||||
static ssize_t ErrorFopRead(struct file *filep, char *buffer, size_t buflen)
|
||||
{
|
||||
(void)filep;
|
||||
(void)buffer;
|
||||
(void)buflen;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static ssize_t ErrorFopWrite (struct file *filep, const char *buffer, size_t buflen)
|
||||
static ssize_t ErrorFopWrite(struct file *filep, const char *buffer, size_t buflen)
|
||||
{
|
||||
(void)filep;
|
||||
(void)buffer;
|
||||
(void)buflen;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static off_t ErrorFopSeek (struct file *filep, off_t offset, int whence)
|
||||
static off_t ErrorFopSeek(struct file *filep, off_t offset, int whence)
|
||||
{
|
||||
(void)filep;
|
||||
(void)offset;
|
||||
(void)whence;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorFopIoctl (struct file *filep, int cmd, unsigned long arg)
|
||||
static int ErrorFopIoctl(struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
(void)filep;
|
||||
(void)cmd;
|
||||
(void)arg;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorFopMmap (struct file* filep, struct VmMapRegion *region)
|
||||
static int ErrorFopMmap(struct file* filep, struct VmMapRegion *region)
|
||||
{
|
||||
(void)filep;
|
||||
(void)region;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorFopPoll (struct file *filep, poll_table *fds)
|
||||
static int ErrorFopPoll(struct file *filep, poll_table *fds)
|
||||
{
|
||||
(void)filep;
|
||||
(void)fds;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorFopStat (struct file *filep, struct stat* st)
|
||||
static int ErrorFopStat(struct file *filep, struct stat* st)
|
||||
{
|
||||
(void)filep;
|
||||
(void)st;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorFopFallocate (struct file* filep, int mode, off_t offset, off_t len)
|
||||
static int ErrorFopFallocate(struct file* filep, int mode, off_t offset, off_t len)
|
||||
{
|
||||
(void)filep;
|
||||
(void)mode;
|
||||
(void)offset;
|
||||
(void)len;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorFopFallocate64 (struct file *filep, int mode, off64_t offset, off64_t len)
|
||||
static int ErrorFopFallocate64(struct file *filep, int mode, off64_t offset, off64_t len)
|
||||
{
|
||||
(void)filep;
|
||||
(void)mode;
|
||||
(void)offset;
|
||||
(void)len;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorFopFsync (struct file *filep)
|
||||
static int ErrorFopFsync(struct file *filep)
|
||||
{
|
||||
(void)filep;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static ssize_t ErrorFopReadpage (struct file *filep, char *buffer, size_t buflen)
|
||||
static ssize_t ErrorFopReadpage(struct file *filep, char *buffer, size_t buflen)
|
||||
{
|
||||
(void)filep;
|
||||
(void)buffer;
|
||||
(void)buflen;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
static int ErrorFopUnlink (struct Vnode *vnode)
|
||||
static int ErrorFopUnlink(struct Vnode *vnode)
|
||||
{
|
||||
(void)vnode;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
|
||||
@@ -637,7 +637,7 @@ void ls(const char *pathname)
|
||||
|
||||
if (statInfo.st_mode & S_IFDIR) { /* list all directory and file */
|
||||
ret = LsDir((pathname == NULL) ? path : pathname);
|
||||
} else { /* show the file infomation */
|
||||
} else { /* show the file information */
|
||||
ret = LsFile(path);
|
||||
}
|
||||
if (ret < 0) {
|
||||
|
||||
@@ -654,7 +654,7 @@ static int os_shell_cmd_do_cp(const char *src_filepath, const char *dst_filename
|
||||
char *dst_filepath = NULL;
|
||||
char *buf = NULL;
|
||||
const char *filename = NULL;
|
||||
size_t r_size, w_size;
|
||||
ssize_t r_size, w_size;
|
||||
int src_fd = -1;
|
||||
int dst_fd = -1;
|
||||
struct stat stat_buf;
|
||||
@@ -1391,8 +1391,8 @@ int checkNum(const char *arg)
|
||||
#ifdef LOSCFG_KERNEL_SYSCALL
|
||||
int osShellCmdSu(int argc, const char **argv)
|
||||
{
|
||||
unsigned int su_uid;
|
||||
unsigned int su_gid;
|
||||
int su_uid;
|
||||
int su_gid;
|
||||
|
||||
if (argc == 0)
|
||||
{
|
||||
|
||||
@@ -198,7 +198,7 @@ int VnodeFree(struct Vnode *vnode)
|
||||
g_totalVnodeSize--;
|
||||
} else {
|
||||
/* for normal vnode, reclaim it to g_VnodeFreeList */
|
||||
memset_s(vnode, sizeof(struct Vnode), 0, sizeof(struct Vnode));
|
||||
(void)memset_s(vnode, sizeof(struct Vnode), 0, sizeof(struct Vnode));
|
||||
LOS_ListAdd(&g_vnodeFreeList, &vnode->actFreeEntry);
|
||||
g_freeVnodeSize++;
|
||||
}
|
||||
@@ -380,6 +380,11 @@ int VnodeLookupAt(const char *path, struct Vnode **result, uint32_t flags, struc
|
||||
if (orgVnode != NULL) {
|
||||
startVnode = orgVnode;
|
||||
normalizedPath = strdup(path);
|
||||
if (normalizedPath == NULL) {
|
||||
PRINT_ERR("[VFS]lookup failed, strdup err\n");
|
||||
ret = -EINVAL;
|
||||
goto OUT_FREE_PATH;
|
||||
}
|
||||
} else {
|
||||
ret = PreProcess(path, &startVnode, &normalizedPath);
|
||||
if (ret != LOS_OK) {
|
||||
|
||||
@@ -67,6 +67,12 @@ config PAGE_TABLE_FINE_LOCK
|
||||
help
|
||||
This option will enable fine lock for page table.
|
||||
|
||||
config ENABLE_KERNEL_TEST
|
||||
bool "Enable kernel test"
|
||||
default n
|
||||
help
|
||||
This option will enable kernel test.
|
||||
|
||||
######################### config options of extended #####################
|
||||
source "kernel/extended/Kconfig"
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-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:
|
||||
@@ -65,10 +65,12 @@ kernel_module(module_name) {
|
||||
"mp/los_mp.c",
|
||||
"mp/los_percpu.c",
|
||||
"mp/los_spinlock.c",
|
||||
"mp/los_stat.c",
|
||||
"om/los_err.c",
|
||||
"sched/sched_sq/los_sched.c",
|
||||
"sched/sched_sq/los_sortlink.c",
|
||||
"sched/los_idle.c",
|
||||
"sched/los_priority.c",
|
||||
"sched/los_sched.c",
|
||||
"sched/los_sortlink.c",
|
||||
"sched/los_statistics.c",
|
||||
"vm/los_vm_boot.c",
|
||||
"vm/los_vm_dump.c",
|
||||
"vm/los_vm_fault.c",
|
||||
@@ -88,8 +90,13 @@ kernel_module(module_name) {
|
||||
}
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
configs += [ ":private" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "include" ]
|
||||
}
|
||||
|
||||
config("private") {
|
||||
cflags = [ "-Wno-frame-address" ]
|
||||
}
|
||||
|
||||
@@ -37,9 +37,9 @@ LOCAL_SRCS := $(wildcard ipc/*.c) $(wildcard core/*.c) $(wildcard mem/membox/*.
|
||||
$(wildcard misc/*.c)\
|
||||
$(wildcard mem/tlsf/*.c) \
|
||||
$(wildcard mp/*.c) \
|
||||
$(wildcard sched/sched_sq/*.c) \
|
||||
$(wildcard sched/*.c) \
|
||||
$(wildcard vm/*.c)
|
||||
|
||||
LOCAL_FLAGS := $(LITEOS_CFLAGS_INTERWORK)
|
||||
LOCAL_FLAGS := $(LITEOS_CFLAGS_INTERWORK) -Wno-frame-address
|
||||
|
||||
include $(MODULE)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -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,52 @@ 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, SchedParam *param)
|
||||
{
|
||||
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) {
|
||||
LosTaskCB *task = OS_TCB_FROM_TID(processCB->threadGroupID);
|
||||
task->ops->schedParamGet(task, param);
|
||||
} else {
|
||||
OsSchedProcessDefaultSchedParamGet(param->policy, param);
|
||||
}
|
||||
} else {
|
||||
LosTaskCB *runTask = OsCurrTaskGet();
|
||||
runTask->ops->schedParamGet(runTask, param);
|
||||
}
|
||||
|
||||
#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;
|
||||
@@ -129,7 +178,7 @@ STATIC ProcessGroup *OsFindProcessGroup(UINT32 gid)
|
||||
}
|
||||
}
|
||||
|
||||
PRINT_INFO("%s is find group : %u failed!\n", __FUNCTION__, gid);
|
||||
PRINT_INFO("%s failed! group id = %u\n", __FUNCTION__, gid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -236,7 +285,7 @@ STATIC LosProcessCB *OsFindExitChildProcess(const LosProcessCB *processCB, INT32
|
||||
VOID OsWaitWakeTask(LosTaskCB *taskCB, UINT32 wakePID)
|
||||
{
|
||||
taskCB->waitID = wakePID;
|
||||
OsSchedTaskWake(taskCB);
|
||||
taskCB->ops->wake(taskCB);
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
LOS_MpSchedule(OS_MP_CPU_ALL);
|
||||
#endif
|
||||
@@ -337,11 +386,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 +440,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 +500,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 +527,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 +677,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 +797,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 +842,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 +850,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 +866,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;
|
||||
}
|
||||
@@ -859,7 +899,7 @@ STATIC INLINE INT32 OsProcessSchedlerParamCheck(INT32 which, INT32 pid, UINT16 p
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_SECURITY_CAPABILITY
|
||||
STATIC BOOL OsProcessCapPermitCheck(const LosProcessCB *processCB, UINT16 prio)
|
||||
STATIC BOOL OsProcessCapPermitCheck(const LosProcessCB *processCB, const SchedParam *param, UINT16 prio)
|
||||
{
|
||||
LosProcessCB *runProcess = OsCurrProcessGet();
|
||||
|
||||
@@ -869,7 +909,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 > param->basePrio)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -883,31 +923,33 @@ STATIC BOOL OsProcessCapPermitCheck(const LosProcessCB *processCB, UINT16 prio)
|
||||
|
||||
LITE_OS_SEC_TEXT INT32 OsSetProcessScheduler(INT32 which, INT32 pid, UINT16 prio, UINT16 policy)
|
||||
{
|
||||
LosProcessCB *processCB = NULL;
|
||||
BOOL needSched = FALSE;
|
||||
SchedParam param = { 0 };
|
||||
UINT32 intSave;
|
||||
INT32 ret;
|
||||
|
||||
ret = OsProcessSchedlerParamCheck(which, pid, prio, policy);
|
||||
INT32 ret = OsProcessSchedlerParamCheck(which, pid, prio, policy);
|
||||
if (ret != LOS_OK) {
|
||||
return -ret;
|
||||
}
|
||||
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(pid);
|
||||
SCHEDULER_LOCK(intSave);
|
||||
processCB = OS_PCB_FROM_PID(pid);
|
||||
if (OsProcessIsInactive(processCB)) {
|
||||
ret = LOS_ESRCH;
|
||||
goto EXIT;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_SECURITY_CAPABILITY
|
||||
if (!OsProcessCapPermitCheck(processCB, prio)) {
|
||||
if (!OsProcessCapPermitCheck(processCB, ¶m, prio)) {
|
||||
ret = LOS_EPERM;
|
||||
goto EXIT;
|
||||
}
|
||||
#endif
|
||||
|
||||
needSched = OsSchedModifyProcessSchedParam(processCB, policy, prio);
|
||||
LosTaskCB *taskCB = OS_TCB_FROM_TID(processCB->threadGroupID);
|
||||
taskCB->ops->schedParamGet(taskCB, ¶m);
|
||||
param.basePrio = prio;
|
||||
|
||||
BOOL needSched = taskCB->ops->schedParamModify(taskCB, ¶m);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
LOS_MpSchedule(OS_MP_CPU_ALL);
|
||||
@@ -953,9 +995,8 @@ 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;
|
||||
SchedParam param = { 0 };
|
||||
(VOID)which;
|
||||
|
||||
if (OS_PID_CHECK_INVALID(pid)) {
|
||||
@@ -966,18 +1007,18 @@ 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;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return -LOS_ESRCH;
|
||||
}
|
||||
|
||||
prio = (INT32)processCB->priority;
|
||||
LosTaskCB *taskCB = OS_TCB_FROM_TID(processCB->threadGroupID);
|
||||
taskCB->ops->schedParamGet(taskCB, ¶m);
|
||||
|
||||
OUT:
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return prio;
|
||||
return param.basePrio;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT INT32 LOS_GetProcessPriority(INT32 pid)
|
||||
@@ -1013,8 +1054,7 @@ STATIC VOID OsWaitInsertWaitListInOrder(LosTaskCB *runTask, LosProcessCB *proces
|
||||
/* if runTask->waitFlag == OS_PROCESS_WAIT_PRO,
|
||||
* this node is inserted directly into the header of the waitList
|
||||
*/
|
||||
|
||||
(VOID)OsSchedTaskWait(list->pstNext, LOS_WAIT_FOREVER, TRUE);
|
||||
(VOID)runTask->ops->wait(runTask, list->pstNext, LOS_WAIT_FOREVER);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1165,13 +1205,10 @@ STATIC INT32 OsWait(INT32 pid, USER INT32 *status, USER siginfo_t *info, UINT32
|
||||
UINT32 ret;
|
||||
UINT32 intSave;
|
||||
LosProcessCB *childCB = NULL;
|
||||
LosProcessCB *processCB = NULL;
|
||||
LosTaskCB *runTask = NULL;
|
||||
|
||||
LosProcessCB *processCB = OsCurrProcessGet();
|
||||
LosTaskCB *runTask = OsCurrTaskGet();
|
||||
SCHEDULER_LOCK(intSave);
|
||||
processCB = OsCurrProcessGet();
|
||||
runTask = OsCurrTaskGet();
|
||||
|
||||
ret = OsWaitChildProcessCheck(processCB, pid, &childCB);
|
||||
if (ret != LOS_OK) {
|
||||
pid = -ret;
|
||||
@@ -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;
|
||||
@@ -1646,47 +1725,37 @@ STATIC UINT32 OsCopyUser(LosProcessCB *childCB, LosProcessCB *parentCB)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID OsInitCopyTaskParam(LosProcessCB *childProcessCB, const CHAR *name, UINTPTR entry, UINT32 size,
|
||||
TSK_INIT_PARAM_S *childPara)
|
||||
{
|
||||
LosTaskCB *mainThread = NULL;
|
||||
UINT32 intSave;
|
||||
|
||||
SCHEDULER_LOCK(intSave);
|
||||
mainThread = OsCurrTaskGet();
|
||||
|
||||
if (OsProcessIsUserMode(childProcessCB)) {
|
||||
childPara->pfnTaskEntry = mainThread->taskEntry;
|
||||
childPara->uwStackSize = mainThread->stackSize;
|
||||
childPara->userParam.userArea = mainThread->userArea;
|
||||
childPara->userParam.userMapBase = mainThread->userMapBase;
|
||||
childPara->userParam.userMapSize = mainThread->userMapSize;
|
||||
} else {
|
||||
childPara->pfnTaskEntry = (TSK_ENTRY_FUNC)entry;
|
||||
childPara->uwStackSize = size;
|
||||
}
|
||||
childPara->pcName = (CHAR *)name;
|
||||
childPara->policy = mainThread->policy;
|
||||
childPara->usTaskPrio = mainThread->priority;
|
||||
childPara->processID = childProcessCB->processID;
|
||||
if (mainThread->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN) {
|
||||
childPara->uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
}
|
||||
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
}
|
||||
|
||||
STATIC UINT32 OsCopyTask(UINT32 flags, LosProcessCB *childProcessCB, const CHAR *name, UINTPTR entry, UINT32 size)
|
||||
{
|
||||
LosTaskCB *runTask = OsCurrTaskGet();
|
||||
TSK_INIT_PARAM_S childPara = { 0 };
|
||||
UINT32 ret;
|
||||
UINT32 intSave;
|
||||
UINT32 taskID;
|
||||
TSK_INIT_PARAM_S taskParam = { 0 };
|
||||
UINT32 ret, taskID, intSave;
|
||||
SchedParam param = { 0 };
|
||||
|
||||
OsInitCopyTaskParam(childProcessCB, name, entry, size, &childPara);
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (OsProcessIsUserMode(childProcessCB)) {
|
||||
taskParam.pfnTaskEntry = runTask->taskEntry;
|
||||
taskParam.uwStackSize = runTask->stackSize;
|
||||
taskParam.userParam.userArea = runTask->userArea;
|
||||
taskParam.userParam.userMapBase = runTask->userMapBase;
|
||||
taskParam.userParam.userMapSize = runTask->userMapSize;
|
||||
} else {
|
||||
taskParam.pfnTaskEntry = (TSK_ENTRY_FUNC)entry;
|
||||
taskParam.uwStackSize = size;
|
||||
}
|
||||
if (runTask->taskStatus & OS_TASK_FLAG_PTHREAD_JOIN) {
|
||||
taskParam.uwResved = LOS_TASK_ATTR_JOINABLE;
|
||||
}
|
||||
|
||||
ret = LOS_TaskCreateOnly(&taskID, &childPara);
|
||||
runTask->ops->schedParamGet(runTask, ¶m);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
taskParam.pcName = (CHAR *)name;
|
||||
taskParam.policy = param.policy;
|
||||
taskParam.usTaskPrio = param.priority;
|
||||
taskParam.processID = childProcessCB->processID;
|
||||
|
||||
ret = LOS_TaskCreateOnly(&taskID, &taskParam);
|
||||
if (ret != LOS_OK) {
|
||||
if (ret == LOS_ERRNO_TSK_TCB_UNAVAILABLE) {
|
||||
return LOS_EAGAIN;
|
||||
@@ -1696,6 +1765,7 @@ STATIC UINT32 OsCopyTask(UINT32 flags, LosProcessCB *childProcessCB, const CHAR
|
||||
|
||||
LosTaskCB *childTaskCB = OS_TCB_FROM_TID(taskID);
|
||||
childTaskCB->taskStatus = runTask->taskStatus;
|
||||
childTaskCB->ops->schedParamModify(childTaskCB, ¶m);
|
||||
if (childTaskCB->taskStatus & OS_TASK_STATUS_RUNNING) {
|
||||
childTaskCB->taskStatus &= ~OS_TASK_STATUS_RUNNING;
|
||||
} else {
|
||||
@@ -1703,7 +1773,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 +1790,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 +1853,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;
|
||||
}
|
||||
@@ -1804,6 +1872,7 @@ STATIC UINT32 OsChildSetProcessGroupAndSched(LosProcessCB *child, LosProcessCB *
|
||||
UINT32 ret;
|
||||
ProcessGroup *group = NULL;
|
||||
|
||||
LosTaskCB *taskCB = OS_TCB_FROM_TID(child->threadGroupID);
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (run->group->groupID == OS_USER_PRIVILEGE_PROCESS_GROUP) {
|
||||
ret = OsSetProcessGroupIDUnsafe(child->processID, child->processID, &group);
|
||||
@@ -1813,7 +1882,8 @@ STATIC UINT32 OsChildSetProcessGroupAndSched(LosProcessCB *child, LosProcessCB *
|
||||
}
|
||||
}
|
||||
|
||||
OsSchedTaskEnQueue(OS_TCB_FROM_TID(child->threadGroupID));
|
||||
child->processStatus &= ~OS_PROCESS_STATUS_INIT;
|
||||
taskCB->ops->enqueue(OsSchedRunqueue(), taskCB);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, group);
|
||||
@@ -1852,7 +1922,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 +1954,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;
|
||||
@@ -1924,6 +1993,8 @@ LITE_OS_SEC_TEXT VOID LOS_Exit(INT32 status)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
(void)status;
|
||||
|
||||
/* The exit of a kernel - state process must be kernel - state and all threads must actively exit */
|
||||
LosProcessCB *processCB = OsCurrProcessGet();
|
||||
SCHEDULER_LOCK(intSave);
|
||||
@@ -1934,8 +2005,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 +2060,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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -43,6 +43,9 @@
|
||||
#error "swtmr maxnum cannot be zero"
|
||||
#endif /* LOSCFG_BASE_CORE_SWTMR_LIMIT <= 0 */
|
||||
|
||||
STATIC INLINE VOID SwtmrDelete(SWTMR_CTRL_S *swtmr);
|
||||
STATIC INLINE UINT64 SwtmrToStart(SWTMR_CTRL_S *swtmr, UINT16 cpuid);
|
||||
|
||||
LITE_OS_SEC_BSS SWTMR_CTRL_S *g_swtmrCBArray = NULL; /* First address in Timer memory space */
|
||||
LITE_OS_SEC_BSS UINT8 *g_swtmrHandlerPool = NULL; /* Pool of Swtmr Handler */
|
||||
LITE_OS_SEC_BSS LOS_DL_LIST g_swtmrFreeList; /* Free list of Software Timer */
|
||||
@@ -52,34 +55,243 @@ 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)
|
||||
{
|
||||
SwtmrHandlerItemPtr swtmrHandlePtr = NULL;
|
||||
SwtmrHandlerItem swtmrHandle;
|
||||
UINT32 ret, swtmrHandlerQueue;
|
||||
typedef struct {
|
||||
SortLinkAttribute swtmrSortLink;
|
||||
LosTaskCB *swtmrTask; /* software timer task id */
|
||||
LOS_DL_LIST swtmrHandlerQueue; /* software timer timeout queue id */
|
||||
} SwtmrRunqueue;
|
||||
|
||||
swtmrHandlerQueue = OsPercpuGet()->swtmrHandlerQueue;
|
||||
STATIC SwtmrRunqueue g_swtmrRunqueue[LOSCFG_KERNEL_CORE_NUM];
|
||||
|
||||
#ifdef LOSCFG_SWTMR_DEBUG
|
||||
#define OS_SWTMR_PERIOD_TO_CYCLE(period) (((UINT64)(period) * OS_NS_PER_TICK) / OS_NS_PER_CYCLE)
|
||||
STATIC SwtmrDebugData *g_swtmrDebugData = NULL;
|
||||
|
||||
BOOL OsSwtmrDebugDataUsed(UINT32 swtmrID)
|
||||
{
|
||||
if (swtmrID > LOSCFG_BASE_CORE_SWTMR_LIMIT) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return g_swtmrDebugData[swtmrID].swtmrUsed;
|
||||
}
|
||||
|
||||
UINT32 OsSwtmrDebugDataGet(UINT32 swtmrID, SwtmrDebugData *data, UINT32 len, UINT8 *mode)
|
||||
{
|
||||
UINT32 intSave;
|
||||
errno_t ret;
|
||||
|
||||
if ((swtmrID > LOSCFG_BASE_CORE_SWTMR_LIMIT) || (data == NULL) ||
|
||||
(mode == NULL) || (len < sizeof(SwtmrDebugData))) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
|
||||
SWTMR_CTRL_S *swtmr = &g_swtmrCBArray[swtmrID];
|
||||
SWTMR_LOCK(intSave);
|
||||
ret = memcpy_s(data, len, &g_swtmrDebugData[swtmrID], sizeof(SwtmrDebugData));
|
||||
*mode = swtmr->ucMode;
|
||||
SWTMR_UNLOCK(intSave);
|
||||
if (ret != EOK) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
return LOS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC VOID SwtmrDebugDataInit(VOID)
|
||||
{
|
||||
#ifdef LOSCFG_SWTMR_DEBUG
|
||||
UINT32 size = sizeof(SwtmrDebugData) * LOSCFG_BASE_CORE_SWTMR_LIMIT;
|
||||
g_swtmrDebugData = (SwtmrDebugData *)LOS_MemAlloc(m_aucSysMem1, size);
|
||||
if (g_swtmrDebugData == NULL) {
|
||||
PRINT_ERR("SwtmrDebugDataInit malloc failed!\n");
|
||||
return;
|
||||
}
|
||||
(VOID)memset_s(g_swtmrDebugData, size, 0, size);
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC INLINE VOID SwtmrDebugDataUpdate(SWTMR_CTRL_S *swtmr, UINT32 ticks, UINT32 times)
|
||||
{
|
||||
#ifdef LOSCFG_SWTMR_DEBUG
|
||||
SwtmrDebugData *data = &g_swtmrDebugData[swtmr->usTimerID];
|
||||
if (data->period != ticks) {
|
||||
(VOID)memset_s(&data->base, sizeof(SwtmrDebugBase), 0, sizeof(SwtmrDebugBase));
|
||||
data->period = ticks;
|
||||
}
|
||||
data->base.startTime = swtmr->startTime;
|
||||
data->base.times += times;
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC INLINE VOID SwtmrDebugDataStart(SWTMR_CTRL_S *swtmr, UINT16 cpuid)
|
||||
{
|
||||
#ifdef LOSCFG_SWTMR_DEBUG
|
||||
SwtmrDebugData *data = &g_swtmrDebugData[swtmr->usTimerID];
|
||||
data->swtmrUsed = TRUE;
|
||||
data->handler = swtmr->pfnHandler;
|
||||
data->cpuid = cpuid;
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC INLINE VOID SwtmrDebugWaitTimeCalculate(UINT32 swtmrID, SwtmrHandlerItemPtr swtmrHandler)
|
||||
{
|
||||
#ifdef LOSCFG_SWTMR_DEBUG
|
||||
SwtmrDebugBase *data = &g_swtmrDebugData[swtmrID].base;
|
||||
swtmrHandler->swtmrID = swtmrID;
|
||||
UINT64 currTime = OsGetCurrSchedTimeCycle();
|
||||
UINT64 waitTime = currTime - data->startTime;
|
||||
data->waitTime += waitTime;
|
||||
if (waitTime > data->waitTimeMax) {
|
||||
data->waitTimeMax = waitTime;
|
||||
}
|
||||
data->readyStartTime = currTime;
|
||||
data->waitCount++;
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC INLINE VOID SwtmrDebugDataClear(UINT32 swtmrID)
|
||||
{
|
||||
#ifdef LOSCFG_SWTMR_DEBUG
|
||||
(VOID)memset_s(&g_swtmrDebugData[swtmrID], sizeof(SwtmrDebugData), 0, sizeof(SwtmrDebugData));
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC INLINE VOID SwtmrHandler(SwtmrHandlerItemPtr swtmrHandle)
|
||||
{
|
||||
#ifdef LOSCFG_SWTMR_DEBUG
|
||||
UINT32 intSave;
|
||||
SwtmrDebugBase *data = &g_swtmrDebugData[swtmrHandle->swtmrID].base;
|
||||
UINT64 startTime = OsGetCurrSchedTimeCycle();
|
||||
#endif
|
||||
swtmrHandle->handler(swtmrHandle->arg);
|
||||
#ifdef LOSCFG_SWTMR_DEBUG
|
||||
UINT64 runTime = OsGetCurrSchedTimeCycle() - startTime;
|
||||
SWTMR_LOCK(intSave);
|
||||
data->runTime += runTime;
|
||||
if (runTime > data->runTimeMax) {
|
||||
data->runTimeMax = runTime;
|
||||
}
|
||||
runTime = startTime - data->readyStartTime;
|
||||
data->readyTime += runTime;
|
||||
if (runTime > data->readyTimeMax) {
|
||||
data->readyTimeMax = runTime;
|
||||
}
|
||||
data->runCount++;
|
||||
SWTMR_UNLOCK(intSave);
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC INLINE VOID SwtmrWake(SwtmrRunqueue *srq, UINT64 startTime, SortLinkList *sortList)
|
||||
{
|
||||
UINT32 intSave;
|
||||
SWTMR_CTRL_S *swtmr = LOS_DL_LIST_ENTRY(sortList, SWTMR_CTRL_S, stSortList);
|
||||
SwtmrHandlerItemPtr swtmrHandler = (SwtmrHandlerItemPtr)LOS_MemboxAlloc(g_swtmrHandlerPool);
|
||||
LOS_ASSERT(swtmrHandler != NULL);
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_SWTMR_EXPIRED, swtmr);
|
||||
|
||||
SWTMR_LOCK(intSave);
|
||||
swtmrHandler->handler = swtmr->pfnHandler;
|
||||
swtmrHandler->arg = swtmr->uwArg;
|
||||
LOS_ListTailInsert(&srq->swtmrHandlerQueue, &swtmrHandler->node);
|
||||
SwtmrDebugWaitTimeCalculate(swtmr->usTimerID, swtmrHandler);
|
||||
|
||||
if (swtmr->ucMode == LOS_SWTMR_MODE_ONCE) {
|
||||
SwtmrDelete(swtmr);
|
||||
|
||||
if (swtmr->usTimerID < (OS_SWTMR_MAX_TIMERID - LOSCFG_BASE_CORE_SWTMR_LIMIT)) {
|
||||
swtmr->usTimerID += LOSCFG_BASE_CORE_SWTMR_LIMIT;
|
||||
} else {
|
||||
swtmr->usTimerID %= LOSCFG_BASE_CORE_SWTMR_LIMIT;
|
||||
}
|
||||
} else if (swtmr->ucMode == LOS_SWTMR_MODE_NO_SELFDELETE) {
|
||||
swtmr->ucState = OS_SWTMR_STATUS_CREATED;
|
||||
} else {
|
||||
swtmr->uwOverrun++;
|
||||
swtmr->startTime = startTime;
|
||||
(VOID)SwtmrToStart(swtmr, ArchCurrCpuid());
|
||||
}
|
||||
|
||||
SWTMR_UNLOCK(intSave);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID ScanSwtmrTimeList(SwtmrRunqueue *srq)
|
||||
{
|
||||
UINT32 intSave;
|
||||
SortLinkAttribute *swtmrSortLink = &srq->swtmrSortLink;
|
||||
LOS_DL_LIST *listObject = &swtmrSortLink->sortLink;
|
||||
|
||||
/*
|
||||
* 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_SpinLockSave(&swtmrSortLink->spinLock, &intSave);
|
||||
|
||||
if (LOS_ListEmpty(listObject)) {
|
||||
LOS_SpinUnlockRestore(&swtmrSortLink->spinLock, intSave);
|
||||
return;
|
||||
}
|
||||
SortLinkList *sortList = LOS_DL_LIST_ENTRY(listObject->pstNext, SortLinkList, sortLinkNode);
|
||||
|
||||
UINT64 currTime = OsGetCurrSchedTimeCycle();
|
||||
while (sortList->responseTime <= currTime) {
|
||||
sortList = LOS_DL_LIST_ENTRY(listObject->pstNext, SortLinkList, sortLinkNode);
|
||||
UINT64 startTime = GET_SORTLIST_VALUE(sortList);
|
||||
OsDeleteNodeSortLink(swtmrSortLink, sortList);
|
||||
LOS_SpinUnlockRestore(&swtmrSortLink->spinLock, intSave);
|
||||
|
||||
SwtmrWake(srq, startTime, sortList);
|
||||
|
||||
LOS_SpinLockSave(&swtmrSortLink->spinLock, &intSave);
|
||||
if (LOS_ListEmpty(listObject)) {
|
||||
break;
|
||||
}
|
||||
|
||||
sortList = LOS_DL_LIST_ENTRY(listObject->pstNext, SortLinkList, sortLinkNode);
|
||||
}
|
||||
|
||||
LOS_SpinUnlockRestore(&swtmrSortLink->spinLock, intSave);
|
||||
return;
|
||||
}
|
||||
|
||||
STATIC VOID SwtmrTask(VOID)
|
||||
{
|
||||
SwtmrHandlerItem swtmrHandle;
|
||||
UINT32 intSave;
|
||||
UINT64 waitTime;
|
||||
|
||||
SwtmrRunqueue *srq = &g_swtmrRunqueue[ArchCurrCpuid()];
|
||||
LOS_DL_LIST *head = &srq->swtmrHandlerQueue;
|
||||
for (;;) {
|
||||
ret = LOS_QueueRead(swtmrHandlerQueue, &swtmrHandlePtr, sizeof(CHAR *), LOS_WAIT_FOREVER);
|
||||
if ((ret == LOS_OK) && (swtmrHandlePtr != NULL)) {
|
||||
swtmrHandle.handler = swtmrHandlePtr->handler;
|
||||
swtmrHandle.arg = swtmrHandlePtr->arg;
|
||||
waitTime = OsSortLinkGetNextExpireTime(OsGetCurrSchedTimeCycle(), &srq->swtmrSortLink);
|
||||
if (waitTime != 0) {
|
||||
SCHEDULER_LOCK(intSave);
|
||||
srq->swtmrTask->ops->delay(srq->swtmrTask, waitTime);
|
||||
OsHookCall(LOS_HOOK_TYPE_MOVEDTASKTODELAYEDLIST, srq->swtmrTask);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
}
|
||||
|
||||
ScanSwtmrTimeList(srq);
|
||||
|
||||
while (!LOS_ListEmpty(head)) {
|
||||
SwtmrHandlerItemPtr swtmrHandlePtr = LOS_DL_LIST_ENTRY(LOS_DL_LIST_FIRST(head), SwtmrHandlerItem, node);
|
||||
LOS_ListDelete(&swtmrHandlePtr->node);
|
||||
|
||||
(VOID)memcpy_s(&swtmrHandle, sizeof(SwtmrHandlerItem), swtmrHandlePtr, sizeof(SwtmrHandlerItem));
|
||||
(VOID)LOS_MemboxFree(g_swtmrHandlerPool, swtmrHandlePtr);
|
||||
if (swtmrHandle.handler != NULL) {
|
||||
swtmrHandle.handler(swtmrHandle.arg);
|
||||
}
|
||||
SwtmrHandler(&swtmrHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 +299,27 @@ 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;
|
||||
}
|
||||
|
||||
UINT32 OsSwtmrTaskIDGetByCpuid(UINT16 cpuid)
|
||||
{
|
||||
return g_swtmrRunqueue[cpuid].swtmrTask->taskID;
|
||||
}
|
||||
|
||||
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++) {
|
||||
@@ -105,82 +329,148 @@ LITE_OS_SEC_TEXT_INIT VOID OsSwtmrRecycle(UINT32 processID)
|
||||
}
|
||||
}
|
||||
|
||||
STATIC UINT32 SwtmrBaseInit(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 size = sizeof(SWTMR_CTRL_S) * LOSCFG_BASE_CORE_SWTMR_LIMIT;
|
||||
SWTMR_CTRL_S *swtmr = (SWTMR_CTRL_S *)LOS_MemAlloc(m_aucSysMem0, size); /* system resident resource */
|
||||
if (swtmr == NULL) {
|
||||
return LOS_ERRNO_SWTMR_NO_MEMORY;
|
||||
}
|
||||
|
||||
(VOID)memset_s(swtmr, size, 0, size);
|
||||
g_swtmrCBArray = swtmr;
|
||||
LOS_ListInit(&g_swtmrFreeList);
|
||||
for (UINT16 index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++, swtmr++) {
|
||||
swtmr->usTimerID = index;
|
||||
LOS_ListTailInsert(&g_swtmrFreeList, &swtmr->stSortList.sortLinkNode);
|
||||
}
|
||||
|
||||
size = LOS_MEMBOX_SIZE(sizeof(SwtmrHandlerItem), OS_SWTMR_HANDLE_QUEUE_SIZE);
|
||||
g_swtmrHandlerPool = (UINT8 *)LOS_MemAlloc(m_aucSysMem1, size); /* system resident resource */
|
||||
if (g_swtmrHandlerPool == NULL) {
|
||||
return LOS_ERRNO_SWTMR_NO_MEMORY;
|
||||
}
|
||||
|
||||
ret = LOS_MemboxInit(g_swtmrHandlerPool, size, sizeof(SwtmrHandlerItem));
|
||||
if (ret != LOS_OK) {
|
||||
return LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM;
|
||||
}
|
||||
|
||||
for (UINT16 index = 0; index < LOSCFG_KERNEL_CORE_NUM; index++) {
|
||||
SwtmrRunqueue *srq = &g_swtmrRunqueue[index];
|
||||
/* The linked list of all cores must be initialized at core 0 startup for load balancing */
|
||||
OsSortLinkInit(&srq->swtmrSortLink);
|
||||
LOS_ListInit(&srq->swtmrHandlerQueue);
|
||||
srq->swtmrTask = NULL;
|
||||
}
|
||||
|
||||
SwtmrDebugDataInit();
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 OsSwtmrInit(VOID)
|
||||
{
|
||||
UINT32 size;
|
||||
UINT16 index;
|
||||
UINT32 ret;
|
||||
SWTMR_CTRL_S *swtmr = NULL;
|
||||
UINT32 swtmrHandlePoolSize;
|
||||
UINT32 cpuid = ArchCurrCpuid();
|
||||
UINT32 swtmrTaskID;
|
||||
|
||||
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 */
|
||||
if (swtmr == NULL) {
|
||||
ret = LOS_ERRNO_SWTMR_NO_MEMORY;
|
||||
goto ERROR;
|
||||
}
|
||||
|
||||
(VOID)memset_s(swtmr, size, 0, size);
|
||||
g_swtmrCBArray = swtmr;
|
||||
LOS_ListInit(&g_swtmrFreeList);
|
||||
for (index = 0; index < LOSCFG_BASE_CORE_SWTMR_LIMIT; index++, swtmr++) {
|
||||
swtmr->usTimerID = index;
|
||||
LOS_ListTailInsert(&g_swtmrFreeList, &swtmr->stSortList.sortLinkNode);
|
||||
}
|
||||
|
||||
swtmrHandlePoolSize = LOS_MEMBOX_SIZE(sizeof(SwtmrHandlerItem), OS_SWTMR_HANDLE_QUEUE_SIZE);
|
||||
|
||||
g_swtmrHandlerPool = (UINT8 *)LOS_MemAlloc(m_aucSysMem1, swtmrHandlePoolSize); /* system resident resource */
|
||||
if (g_swtmrHandlerPool == NULL) {
|
||||
ret = LOS_ERRNO_SWTMR_NO_MEMORY;
|
||||
goto ERROR;
|
||||
}
|
||||
|
||||
ret = LOS_MemboxInit(g_swtmrHandlerPool, swtmrHandlePoolSize, sizeof(SwtmrHandlerItem));
|
||||
if (ret != LOS_OK) {
|
||||
ret = LOS_ERRNO_SWTMR_HANDLER_POOL_NO_MEM;
|
||||
goto ERROR;
|
||||
}
|
||||
|
||||
ret = OsSchedSwtmrScanRegister((SchedScan)OsSwtmrScan);
|
||||
ret = SwtmrBaseInit();
|
||||
if (ret != LOS_OK) {
|
||||
goto ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
ret = LOS_QueueCreate(NULL, OS_SWTMR_HANDLE_QUEUE_SIZE, &g_percpu[cpuid].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;
|
||||
}
|
||||
|
||||
SwtmrRunqueue *srq = &g_swtmrRunqueue[cpuid];
|
||||
srq->swtmrTask = OsGetTaskCB(swtmrTaskID);
|
||||
return LOS_OK;
|
||||
|
||||
ERROR:
|
||||
PRINT_ERR("OsSwtmrInit error! ret = %u\n", ret);
|
||||
(VOID)LOS_MemFree(m_aucSysMem0, g_swtmrCBArray);
|
||||
g_swtmrCBArray = NULL;
|
||||
(VOID)LOS_MemFree(m_aucSysMem1, g_swtmrHandlerPool);
|
||||
g_swtmrHandlerPool = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Description: Start Software Timer
|
||||
* Input : swtmr --- Need to start software timer
|
||||
*/
|
||||
LITE_OS_SEC_TEXT VOID OsSwtmrStart(UINT64 currTime, SWTMR_CTRL_S *swtmr)
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
STATIC INLINE VOID FindIdleSwtmrRunqueue(UINT16 *idleCpuid)
|
||||
{
|
||||
SwtmrRunqueue *idleRq = &g_swtmrRunqueue[0];
|
||||
UINT32 nodeNum = OsGetSortLinkNodeNum(&idleRq->swtmrSortLink);
|
||||
UINT16 cpuid = 1;
|
||||
do {
|
||||
SwtmrRunqueue *srq = &g_swtmrRunqueue[cpuid];
|
||||
UINT32 temp = OsGetSortLinkNodeNum(&srq->swtmrSortLink);
|
||||
if (nodeNum > temp) {
|
||||
*idleCpuid = cpuid;
|
||||
nodeNum = temp;
|
||||
}
|
||||
cpuid++;
|
||||
} while (cpuid < LOSCFG_KERNEL_CORE_NUM);
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC INLINE VOID AddSwtmr2TimeList(SortLinkList *node, UINT64 responseTime, UINT16 cpuid)
|
||||
{
|
||||
SwtmrRunqueue *srq = &g_swtmrRunqueue[cpuid];
|
||||
OsAdd2SortLink(&srq->swtmrSortLink, node, responseTime, cpuid);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID DeSwtmrFromTimeList(SortLinkList *node)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
UINT16 cpuid = OsGetSortLinkNodeCpuid(node);
|
||||
#else
|
||||
UINT16 cpuid = 0;
|
||||
#endif
|
||||
SwtmrRunqueue *srq = &g_swtmrRunqueue[cpuid];
|
||||
OsDeleteFromSortLink(&srq->swtmrSortLink, node);
|
||||
return;
|
||||
}
|
||||
|
||||
STATIC VOID SwtmrAdjustCheck(UINT16 cpuid, UINT64 responseTime)
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 intSave;
|
||||
SwtmrRunqueue *srq = &g_swtmrRunqueue[cpuid];
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if ((srq->swtmrTask == NULL) || !OsTaskIsBlocked(srq->swtmrTask)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return;
|
||||
}
|
||||
|
||||
if (responseTime >= GET_SORTLIST_VALUE(&srq->swtmrTask->sortList)) {
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return;
|
||||
}
|
||||
|
||||
ret = OsSchedTimeoutQueueAdjust(srq->swtmrTask, responseTime);
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
if (ret != LOS_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cpuid == ArchCurrCpuid()) {
|
||||
OsSchedExpireTimeUpdate();
|
||||
} else {
|
||||
LOS_MpSchedule(CPUID_TO_AFFI_MASK(cpuid));
|
||||
}
|
||||
}
|
||||
|
||||
STATIC UINT64 SwtmrToStart(SWTMR_CTRL_S *swtmr, UINT16 cpuid)
|
||||
{
|
||||
UINT32 ticks;
|
||||
UINT32 times = 0;
|
||||
|
||||
if ((swtmr->uwOverrun == 0) && ((swtmr->ucMode == LOS_SWTMR_MODE_ONCE) ||
|
||||
(swtmr->ucMode == LOS_SWTMR_MODE_OPP) ||
|
||||
@@ -191,96 +481,124 @@ 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);
|
||||
return;
|
||||
UINT64 period = (UINT64)ticks * OS_CYCLE_PER_TICK;
|
||||
UINT64 responseTime = swtmr->startTime + period;
|
||||
UINT64 currTime = OsGetCurrSchedTimeCycle();
|
||||
if (responseTime < currTime) {
|
||||
times = (UINT32)((currTime - swtmr->startTime) / period);
|
||||
swtmr->startTime += times * period;
|
||||
responseTime = swtmr->startTime + period;
|
||||
PRINT_WARN("Swtmr already timeout! SwtmrID: %u\n", swtmr->usTimerID);
|
||||
}
|
||||
|
||||
AddSwtmr2TimeList(&swtmr->stSortList, responseTime, cpuid);
|
||||
SwtmrDebugDataUpdate(swtmr, ticks, times);
|
||||
return responseTime;
|
||||
}
|
||||
|
||||
/*
|
||||
* Description: Start Software Timer
|
||||
* Input : swtmr --- Need to start software timer
|
||||
*/
|
||||
STATIC INLINE VOID SwtmrStart(SWTMR_CTRL_S *swtmr)
|
||||
{
|
||||
UINT64 responseTime;
|
||||
UINT16 idleCpu = 0;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
FindIdleSwtmrRunqueue(&idleCpu);
|
||||
#endif
|
||||
swtmr->startTime = OsGetCurrSchedTimeCycle();
|
||||
responseTime = SwtmrToStart(swtmr, idleCpu);
|
||||
|
||||
SwtmrDebugDataStart(swtmr, idleCpu);
|
||||
|
||||
SwtmrAdjustCheck(idleCpu, responseTime);
|
||||
}
|
||||
|
||||
/*
|
||||
* Description: Delete Software Timer
|
||||
* Input : swtmr --- Need to delete software timer, When using, Ensure that it can't be NULL.
|
||||
*/
|
||||
STATIC INLINE VOID OsSwtmrDelete(SWTMR_CTRL_S *swtmr)
|
||||
STATIC INLINE VOID SwtmrDelete(SWTMR_CTRL_S *swtmr)
|
||||
{
|
||||
/* insert to free list */
|
||||
LOS_ListTailInsert(&g_swtmrFreeList, &swtmr->stSortList.sortLinkNode);
|
||||
swtmr->ucState = OS_SWTMR_STATUS_UNUSED;
|
||||
swtmr->uwOwnerPid = 0;
|
||||
|
||||
SwtmrDebugDataClear(swtmr->usTimerID);
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsWakePendTimeSwtmr(Percpu *cpu, UINT64 currTime, SWTMR_CTRL_S *swtmr)
|
||||
STATIC INLINE VOID SwtmrRestart(UINT64 startTime, SortLinkList *sortList, UINT16 cpuid)
|
||||
{
|
||||
LOS_SpinLock(&g_swtmrSpin);
|
||||
SwtmrHandlerItemPtr swtmrHandler = (SwtmrHandlerItemPtr)LOS_MemboxAlloc(g_swtmrHandlerPool);
|
||||
if (swtmrHandler != NULL) {
|
||||
swtmrHandler->handler = swtmr->pfnHandler;
|
||||
swtmrHandler->arg = swtmr->uwArg;
|
||||
UINT32 intSave;
|
||||
|
||||
if (LOS_QueueWrite(cpu->swtmrHandlerQueue, swtmrHandler, sizeof(CHAR *), LOS_NO_WAIT)) {
|
||||
(VOID)LOS_MemboxFree(g_swtmrHandlerPool, swtmrHandler);
|
||||
}
|
||||
}
|
||||
|
||||
if (swtmr->ucMode == LOS_SWTMR_MODE_ONCE) {
|
||||
OsSwtmrDelete(swtmr);
|
||||
|
||||
if (swtmr->usTimerID < (OS_SWTMR_MAX_TIMERID - LOSCFG_BASE_CORE_SWTMR_LIMIT)) {
|
||||
swtmr->usTimerID += LOSCFG_BASE_CORE_SWTMR_LIMIT;
|
||||
} else {
|
||||
swtmr->usTimerID %= LOSCFG_BASE_CORE_SWTMR_LIMIT;
|
||||
}
|
||||
} else if (swtmr->ucMode == LOS_SWTMR_MODE_NO_SELFDELETE) {
|
||||
swtmr->ucState = OS_SWTMR_STATUS_CREATED;
|
||||
} else {
|
||||
swtmr->uwOverrun++;
|
||||
OsSwtmrStart(currTime, swtmr);
|
||||
}
|
||||
|
||||
LOS_SpinUnlock(&g_swtmrSpin);
|
||||
SWTMR_CTRL_S *swtmr = LOS_DL_LIST_ENTRY(sortList, SWTMR_CTRL_S, stSortList);
|
||||
SWTMR_LOCK(intSave);
|
||||
swtmr->startTime = startTime;
|
||||
(VOID)SwtmrToStart(swtmr, cpuid);
|
||||
SWTMR_UNLOCK(intSave);
|
||||
}
|
||||
|
||||
/*
|
||||
* 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 OsSwtmrResponseTimeReset(UINT64 startTime)
|
||||
{
|
||||
Percpu *cpu = OsPercpuGet();
|
||||
SortLinkAttribute* swtmrSortLink = &OsPercpuGet()->swtmrSortLink;
|
||||
LOS_DL_LIST *listObject = &swtmrSortLink->sortLink;
|
||||
UINT16 cpuid = ArchCurrCpuid();
|
||||
SortLinkAttribute *swtmrSortLink = &g_swtmrRunqueue[cpuid].swtmrSortLink;
|
||||
LOS_DL_LIST *listHead = &swtmrSortLink->sortLink;
|
||||
LOS_DL_LIST *listNext = listHead->pstNext;
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
if (LOS_ListEmpty(listObject)) {
|
||||
LOS_SpinUnlock(&cpu->swtmrSortLinkSpin);
|
||||
return;
|
||||
}
|
||||
SortLinkList *sortList = LOS_DL_LIST_ENTRY(listObject->pstNext, SortLinkList, sortLinkNode);
|
||||
|
||||
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);
|
||||
LOS_SpinLock(&swtmrSortLink->spinLock);
|
||||
while (listNext != listHead) {
|
||||
SortLinkList *sortList = LOS_DL_LIST_ENTRY(listNext, SortLinkList, sortLinkNode);
|
||||
OsDeleteNodeSortLink(swtmrSortLink, sortList);
|
||||
LOS_SpinUnlock(&cpu->swtmrSortLinkSpin);
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_SWTMR_EXPIRED, swtmr);
|
||||
OsWakePendTimeSwtmr(cpu, currTime, swtmr);
|
||||
LOS_SpinUnlock(&swtmrSortLink->spinLock);
|
||||
|
||||
LOS_SpinLock(&cpu->swtmrSortLinkSpin);
|
||||
if (LOS_ListEmpty(listObject)) {
|
||||
break;
|
||||
SwtmrRestart(startTime, sortList, cpuid);
|
||||
|
||||
LOS_SpinLock(&swtmrSortLink->spinLock);
|
||||
listNext = listNext->pstNext;
|
||||
}
|
||||
LOS_SpinUnlock(&swtmrSortLink->spinLock);
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL SwtmrRunqueueFind(SortLinkAttribute *swtmrSortLink, SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
|
||||
{
|
||||
LOS_DL_LIST *listObject = &swtmrSortLink->sortLink;
|
||||
LOS_DL_LIST *list = listObject->pstNext;
|
||||
|
||||
LOS_SpinLock(&swtmrSortLink->spinLock);
|
||||
while (list != listObject) {
|
||||
SortLinkList *listSorted = LOS_DL_LIST_ENTRY(list, SortLinkList, sortLinkNode);
|
||||
if (checkFunc((UINTPTR)listSorted, arg)) {
|
||||
LOS_SpinUnlock(&swtmrSortLink->spinLock);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
sortList = LOS_DL_LIST_ENTRY(listObject->pstNext, SortLinkList, sortLinkNode);
|
||||
list = list->pstNext;
|
||||
}
|
||||
|
||||
LOS_SpinUnlock(&cpu->swtmrSortLinkSpin);
|
||||
LOS_SpinUnlock(&swtmrSortLink->spinLock);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
STATIC BOOL SwtmrTimeListFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
|
||||
{
|
||||
for (UINT16 cpuid = 0; cpuid < LOSCFG_KERNEL_CORE_NUM; cpuid++) {
|
||||
SortLinkAttribute *swtmrSortLink = &g_swtmrRunqueue[ArchCurrCpuid()].swtmrSortLink;
|
||||
if (SwtmrRunqueueFind(swtmrSortLink, checkFunc, arg)) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOL OsSwtmrWorkQueueFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
|
||||
{
|
||||
UINT32 intSave;
|
||||
|
||||
SWTMR_LOCK(intSave);
|
||||
BOOL find = SwtmrTimeListFind(checkFunc, arg);
|
||||
SWTMR_UNLOCK(intSave);
|
||||
return find;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -289,30 +607,39 @@ LITE_OS_SEC_TEXT VOID OsSwtmrScan(VOID)
|
||||
*/
|
||||
LITE_OS_SEC_TEXT UINT32 OsSwtmrGetNextTimeout(VOID)
|
||||
{
|
||||
return OsSortLinkGetNextExpireTime(&OsPercpuGet()->swtmrSortLink);
|
||||
UINT64 currTime = OsGetCurrSchedTimeCycle();
|
||||
SwtmrRunqueue *srq = &g_swtmrRunqueue[ArchCurrCpuid()];
|
||||
UINT64 time = (OsSortLinkGetNextExpireTime(currTime, &srq->swtmrSortLink) / OS_CYCLE_PER_TICK);
|
||||
if (time > OS_INVALID_VALUE) {
|
||||
time = OS_INVALID_VALUE;
|
||||
}
|
||||
return (UINT32)time;
|
||||
}
|
||||
|
||||
/*
|
||||
* Description: Stop of Software Timer interface
|
||||
* Input : swtmr --- the software timer contrl handler
|
||||
* Input : swtmr --- the software timer control handler
|
||||
*/
|
||||
LITE_OS_SEC_TEXT STATIC VOID OsSwtmrStop(SWTMR_CTRL_S *swtmr)
|
||||
STATIC VOID SwtmrStop(SWTMR_CTRL_S *swtmr)
|
||||
{
|
||||
OsDeleteSortLink(&swtmr->stSortList, OS_SORT_LINK_SWTMR);
|
||||
|
||||
swtmr->ucState = OS_SWTMR_STATUS_CREATED;
|
||||
swtmr->uwOverrun = 0;
|
||||
|
||||
OsSchedUpdateExpireTime(OsGetCurrSchedTimeCycle());
|
||||
DeSwtmrFromTimeList(&swtmr->stSortList);
|
||||
}
|
||||
|
||||
/*
|
||||
* Description: Get next software timer expiretime
|
||||
* Input : swtmr --- the software timer contrl handler
|
||||
* Input : swtmr --- the software timer control handler
|
||||
*/
|
||||
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,
|
||||
@@ -396,11 +723,10 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrStart(UINT16 swtmrID)
|
||||
* then start the swtmr again.
|
||||
*/
|
||||
case OS_SWTMR_STATUS_TICKING:
|
||||
OsSwtmrStop(swtmr);
|
||||
SwtmrStop(swtmr);
|
||||
/* fall-through */
|
||||
case OS_SWTMR_STATUS_CREATED:
|
||||
swtmr->startTime = OsGetCurrSchedTimeCycle();
|
||||
OsSwtmrStart(swtmr->startTime, swtmr);
|
||||
SwtmrStart(swtmr);
|
||||
break;
|
||||
default:
|
||||
ret = LOS_ERRNO_SWTMR_STATUS_INVALID;
|
||||
@@ -440,7 +766,7 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrStop(UINT16 swtmrID)
|
||||
ret = LOS_ERRNO_SWTMR_NOT_STARTED;
|
||||
break;
|
||||
case OS_SWTMR_STATUS_TICKING:
|
||||
OsSwtmrStop(swtmr);
|
||||
SwtmrStop(swtmr);
|
||||
break;
|
||||
default:
|
||||
ret = LOS_ERRNO_SWTMR_STATUS_INVALID;
|
||||
@@ -518,10 +844,10 @@ LITE_OS_SEC_TEXT UINT32 LOS_SwtmrDelete(UINT16 swtmrID)
|
||||
ret = LOS_ERRNO_SWTMR_NOT_CREATED;
|
||||
break;
|
||||
case OS_SWTMR_STATUS_TICKING:
|
||||
OsSwtmrStop(swtmr);
|
||||
SwtmrStop(swtmr);
|
||||
/* fall-through */
|
||||
case OS_SWTMR_STATUS_CREATED:
|
||||
OsSwtmrDelete(swtmr);
|
||||
SwtmrDelete(swtmr);
|
||||
break;
|
||||
default:
|
||||
ret = LOS_ERRNO_SWTMR_STATUS_INVALID;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -54,7 +54,7 @@ extern BOOL OsMemIsHeapNode(const VOID *ptr);
|
||||
extern UINT32 OsShellCmdMemCheck(INT32 argc, const CHAR *argv[]);
|
||||
|
||||
/* memory expand size at least 1/8 of pool size if we can */
|
||||
#define MEM_EXPAND_SIZE(poolSize) (poolSize >> 3)
|
||||
#define MEM_EXPAND_SIZE(poolSize) ((poolSize) >> 3)
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -43,7 +43,7 @@ extern "C" {
|
||||
|
||||
#define OS_MUX_MAGIC 0xEBCFDEA0
|
||||
|
||||
extern VOID OsMuxBitmapRestore(const LosMux *mutex, const LosTaskCB *taskCB, LosTaskCB *owner);
|
||||
extern VOID OsMuxBitmapRestore(const LosMux *mutex, const LOS_DL_LIST *list, const LosTaskCB *runTask);
|
||||
extern UINT32 OsMuxLockUnsafe(LosMux *mutex, UINT32 timeout);
|
||||
extern UINT32 OsMuxTrylockUnsafe(LosMux *mutex, UINT32 timeout);
|
||||
extern UINT32 OsMuxUnlockUnsafe(LosTaskCB *taskCB, LosMux *mutex, BOOL *needSched);
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -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
|
||||
@@ -315,11 +295,6 @@ STATIC INLINE BOOL OsProcessIsUserMode(const LosProcessCB *processCB)
|
||||
return (processCB->processMode == OS_USER_MODE);
|
||||
}
|
||||
|
||||
#define LOS_SCHED_NORMAL 0U
|
||||
#define LOS_SCHED_FIFO 1U
|
||||
#define LOS_SCHED_RR 2U
|
||||
#define LOS_SCHED_IDLE 3U
|
||||
|
||||
#define LOS_PRIO_PROCESS 0U
|
||||
#define LOS_PRIO_PGRP 1U
|
||||
#define LOS_PRIO_USER 2U
|
||||
@@ -374,16 +349,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 +365,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 +461,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 +483,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, SchedParam *param);
|
||||
extern VOID OsDeleteTaskFromProcess(LosTaskCB *taskCB);
|
||||
extern VOID OsProcessThreadGroupDestroy(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -41,7 +41,7 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define OS_RWLOCK_MAGIC 0xBEFDCAU
|
||||
#define OS_RWLOCK_MAGIC 0xEFDCAU
|
||||
|
||||
enum RwlockMode {
|
||||
RWLOCK_NONE_MODE,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -32,12 +32,26 @@
|
||||
#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_statistics_pri.h"
|
||||
#endif
|
||||
#include "los_stackinfo_pri.h"
|
||||
#include "los_futex_pri.h"
|
||||
#ifdef LOSCFG_KERNEL_PM
|
||||
#include "los_pm_pri.h"
|
||||
#endif
|
||||
#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_mp.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -45,25 +59,417 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#define OS_SCHED_MINI_PERIOD (OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI)
|
||||
#define OS_TICK_RESPONSE_PRECISION (UINT32)((OS_SCHED_MINI_PERIOD * 75) / 100)
|
||||
#define OS_SCHED_MAX_RESPONSE_TIME (UINT64)(((UINT64)-1) - 1U)
|
||||
#define OS_SCHED_MINI_PERIOD (OS_SYS_CLOCK / LOSCFG_BASE_CORE_TICK_PER_SECOND_MINI)
|
||||
#define OS_TICK_RESPONSE_PRECISION (UINT32)((OS_SCHED_MINI_PERIOD * 75) / 100)
|
||||
#define OS_SCHED_MAX_RESPONSE_TIME OS_SORT_LINK_INVALID_TIME
|
||||
#define OS_SCHED_TICK_TO_CYCLE(ticks) ((UINT64)ticks * OS_CYCLE_PER_TICK)
|
||||
#define AFFI_MASK_TO_CPUID(mask) ((UINT16)((mask) - 1))
|
||||
|
||||
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 struct TagTaskCB LosTaskCB;
|
||||
typedef BOOL (*SCHED_TL_FIND_FUNC)(UINTPTR, UINTPTR);
|
||||
|
||||
STATIC INLINE UINT64 OsGetCurrSchedTimeCycle(VOID)
|
||||
{
|
||||
if (g_sysSchedStartTime != OS_64BIT_MAX) {
|
||||
return (HalClockGetCycles() - g_sysSchedStartTime);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return HalClockGetCycles();
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedIrqUpdateUsedTime(VOID)
|
||||
typedef enum {
|
||||
INT_NO_RESCH = 0x0, /* no needs to schedule */
|
||||
INT_PEND_RESCH = 0x1, /* pending schedule flag */
|
||||
INT_PEND_TICK = 0x2, /* pending tick */
|
||||
} SchedFlag;
|
||||
|
||||
#define OS_PRIORITY_QUEUE_NUM 32
|
||||
typedef struct {
|
||||
LOS_DL_LIST priQueList[OS_PRIORITY_QUEUE_NUM];
|
||||
UINT32 readyTasks[OS_PRIORITY_QUEUE_NUM];
|
||||
UINT32 queueBitmap;
|
||||
} HPFQueue;
|
||||
|
||||
typedef struct {
|
||||
HPFQueue queueList[OS_PRIORITY_QUEUE_NUM];
|
||||
UINT32 queueBitmap;
|
||||
} HPFRunqueue;
|
||||
|
||||
typedef struct {
|
||||
SortLinkAttribute timeoutQueue; /* task timeout queue */
|
||||
HPFRunqueue *hpfRunqueue;
|
||||
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 schedFlag; /* pending scheduler flag */
|
||||
} SchedRunqueue;
|
||||
|
||||
extern SchedRunqueue g_schedRunqueue[LOSCFG_KERNEL_CORE_NUM];
|
||||
|
||||
VOID OsSchedExpireTimeUpdate(VOID);
|
||||
|
||||
STATIC INLINE SchedRunqueue *OsSchedRunqueue(VOID)
|
||||
{
|
||||
return &g_schedRunqueue[ArchCurrCpuid()];
|
||||
}
|
||||
|
||||
STATIC INLINE SchedRunqueue *OsSchedRunqueueByID(UINT16 id)
|
||||
{
|
||||
return &g_schedRunqueue[id];
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 OsSchedLockCountGet(VOID)
|
||||
{
|
||||
return OsSchedRunqueue()->taskLockCnt;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedLockSet(UINT32 count)
|
||||
{
|
||||
OsSchedRunqueue()->taskLockCnt = count;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedLock(VOID)
|
||||
{
|
||||
OsSchedRunqueue()->taskLockCnt++;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedUnlock(VOID)
|
||||
{
|
||||
OsSchedRunqueue()->taskLockCnt--;
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsSchedUnlockResch(VOID)
|
||||
{
|
||||
SchedRunqueue *rq = OsSchedRunqueue();
|
||||
if (rq->taskLockCnt > 0) {
|
||||
rq->taskLockCnt--;
|
||||
if ((rq->taskLockCnt == 0) && (rq->schedFlag & INT_PEND_RESCH) && OS_SCHEDULER_ACTIVE) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsSchedIsLock(VOID)
|
||||
{
|
||||
return (OsSchedRunqueue()->taskLockCnt != 0);
|
||||
}
|
||||
|
||||
/* Check if preemptible with counter flag */
|
||||
STATIC INLINE BOOL OsPreemptable(VOID)
|
||||
{
|
||||
SchedRunqueue *rq = OsSchedRunqueue();
|
||||
/*
|
||||
* Unlike OsPreemptableInSched, the int may be not disabled when OsPreemptable
|
||||
* is called, needs manually disable interrupt, to prevent current task from
|
||||
* being migrated to another core, and get the wrong preemptable status.
|
||||
*/
|
||||
UINT32 intSave = LOS_IntLock();
|
||||
BOOL preemptible = (rq->taskLockCnt == 0);
|
||||
if (!preemptible) {
|
||||
/* Set schedule flag if preemption is disabled */
|
||||
rq->schedFlag |= INT_PEND_RESCH;
|
||||
}
|
||||
LOS_IntRestore(intSave);
|
||||
return preemptible;
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsPreemptableInSched(VOID)
|
||||
{
|
||||
BOOL preemptible = FALSE;
|
||||
SchedRunqueue *rq = OsSchedRunqueue();
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
/*
|
||||
* For smp systems, schedule must hold the task spinlock, and this counter
|
||||
* will increase by 1 in that case.
|
||||
*/
|
||||
preemptible = (rq->taskLockCnt == 1);
|
||||
|
||||
#else
|
||||
preemptible = (rq->taskLockCnt == 0);
|
||||
#endif
|
||||
if (!preemptible) {
|
||||
/* Set schedule flag if preemption is disabled */
|
||||
rq->schedFlag |= INT_PEND_RESCH;
|
||||
}
|
||||
|
||||
return preemptible;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 OsSchedRunqueueIdleGet(VOID)
|
||||
{
|
||||
return OsSchedRunqueue()->idleTaskID;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedRunqueuePendingSet(VOID)
|
||||
{
|
||||
OsSchedRunqueue()->schedFlag |= INT_PEND_RESCH;
|
||||
}
|
||||
|
||||
#define LOS_SCHED_NORMAL 0U
|
||||
#define LOS_SCHED_FIFO 1U
|
||||
#define LOS_SCHED_RR 2U
|
||||
#define LOS_SCHED_IDLE 3U
|
||||
|
||||
typedef struct {
|
||||
UINT16 policy;
|
||||
UINT16 basePrio;
|
||||
UINT16 priority;
|
||||
UINT32 timeSlice;
|
||||
} SchedParam;
|
||||
|
||||
typedef struct {
|
||||
UINT16 policy; /* This field must be present for all scheduling policies and must be the first in the structure */
|
||||
UINT16 basePrio;
|
||||
UINT16 priority;
|
||||
UINT32 initTimeSlice;
|
||||
UINT32 priBitmap; /**< Bitmap for recording the change of task priority, the priority can not be greater than 31 */
|
||||
} SchedHPF;
|
||||
|
||||
typedef struct {
|
||||
union {
|
||||
SchedHPF hpf;
|
||||
} Policy;
|
||||
} SchedPolicy;
|
||||
|
||||
typedef struct {
|
||||
VOID (*dequeue)(SchedRunqueue *rq, LosTaskCB *taskCB);
|
||||
VOID (*enqueue)(SchedRunqueue *rq, LosTaskCB *taskCB);
|
||||
VOID (*start)(SchedRunqueue *rq, LosTaskCB *taskCB);
|
||||
VOID (*exit)(LosTaskCB *taskCB);
|
||||
UINT32 (*wait)(LosTaskCB *runTask, LOS_DL_LIST *list, UINT32 timeout);
|
||||
VOID (*wake)(LosTaskCB *taskCB);
|
||||
BOOL (*schedParamModify)(LosTaskCB *taskCB, const SchedParam *param);
|
||||
UINT32 (*schedParamGet)(const LosTaskCB *taskCB, SchedParam *param);
|
||||
UINT32 (*delay)(LosTaskCB *taskCB, UINT64 waitTime);
|
||||
VOID (*yield)(LosTaskCB *taskCB);
|
||||
UINT32 (*suspend)(LosTaskCB *taskCB);
|
||||
UINT32 (*resume)(LosTaskCB *taskCB, BOOL *needSched);
|
||||
UINT64 (*deadlineGet)(const LosTaskCB *taskCB);
|
||||
VOID (*timeSliceUpdate)(SchedRunqueue *rq, LosTaskCB *taskCB, UINT64 currTime);
|
||||
INT32 (*schedParamCompare)(const SchedPolicy *sp1, const SchedPolicy *sp2);
|
||||
VOID (*priorityInheritance)(LosTaskCB *owner, const SchedParam *param);
|
||||
VOID (*priorityRestore)(LosTaskCB *owner, const LOS_DL_LIST *list, const SchedParam *param);
|
||||
} SchedOps;
|
||||
|
||||
/**
|
||||
* @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_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 delayed operation of this task is frozen.
|
||||
*/
|
||||
#define OS_TASK_STATUS_FROZEN 0x0200U
|
||||
|
||||
#define OS_TCB_NAME_LEN 32
|
||||
|
||||
typedef struct TagTaskCB {
|
||||
VOID *stackPointer; /**< Task stack pointer */
|
||||
UINT16 taskStatus; /**< Task status */
|
||||
|
||||
UINT64 startTime; /**< The start time of each phase of task */
|
||||
UINT64 waitTime; /**< Task delay time, tick number */
|
||||
UINT64 irqStartTime; /**< Interrupt start time */
|
||||
UINT32 irqUsedTime; /**< Interrupt consumption time */
|
||||
INT32 timeSlice; /**< Task remaining time slice */
|
||||
SortLinkList sortList; /**< Task sortlink node */
|
||||
const SchedOps *ops;
|
||||
SchedPolicy sp;
|
||||
|
||||
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 */
|
||||
#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 OsSchedIrqUsedTimeUpdate(VOID)
|
||||
{
|
||||
LosTaskCB *runTask = OsCurrTaskGet();
|
||||
runTask->irqUsedTime = OsGetCurrSchedTimeCycle() - runTask->irqStartTime;
|
||||
@@ -75,6 +481,123 @@ STATIC INLINE VOID OsSchedIrqStartTime(VOID)
|
||||
runTask->irqStartTime = OsGetCurrSchedTimeCycle();
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
STATIC INLINE VOID IdleRunqueueFind(UINT16 *idleCpuid)
|
||||
{
|
||||
SchedRunqueue *idleRq = OsSchedRunqueueByID(0);
|
||||
UINT32 nodeNum = OsGetSortLinkNodeNum(&idleRq->timeoutQueue);
|
||||
UINT16 cpuid = 1;
|
||||
do {
|
||||
SchedRunqueue *rq = OsSchedRunqueueByID(cpuid);
|
||||
UINT32 temp = OsGetSortLinkNodeNum(&rq->timeoutQueue);
|
||||
if (nodeNum > temp) {
|
||||
*idleCpuid = cpuid;
|
||||
nodeNum = temp;
|
||||
}
|
||||
cpuid++;
|
||||
} while (cpuid < LOSCFG_KERNEL_CORE_NUM);
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC INLINE VOID OsSchedTimeoutQueueAdd(LosTaskCB *taskCB, UINT64 responseTime)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
UINT16 cpuid = AFFI_MASK_TO_CPUID(taskCB->cpuAffiMask);
|
||||
if (cpuid >= LOSCFG_KERNEL_CORE_NUM) {
|
||||
cpuid = 0;
|
||||
IdleRunqueueFind(&cpuid);
|
||||
}
|
||||
#else
|
||||
UINT16 cpuid = 0;
|
||||
#endif
|
||||
|
||||
SchedRunqueue *rq = OsSchedRunqueueByID(cpuid);
|
||||
OsAdd2SortLink(&rq->timeoutQueue, &taskCB->sortList, responseTime, cpuid);
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
if ((cpuid != ArchCurrCpuid()) && (responseTime < rq->responseTime)) {
|
||||
rq->schedFlag |= INT_PEND_TICK;
|
||||
LOS_MpSchedule(CPUID_TO_AFFI_MASK(cpuid));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
STATIC INLINE VOID OsSchedTimeoutQueueDelete(LosTaskCB *taskCB)
|
||||
{
|
||||
SortLinkList *node = &taskCB->sortList;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
SchedRunqueue *rq = OsSchedRunqueueByID(node->cpuid);
|
||||
#else
|
||||
SchedRunqueue *rq = OsSchedRunqueueByID(0);
|
||||
#endif
|
||||
UINT64 oldResponseTime = GET_SORTLIST_VALUE(node);
|
||||
OsDeleteFromSortLink(&rq->timeoutQueue, node);
|
||||
if (oldResponseTime <= rq->responseTime) {
|
||||
rq->responseTime = OS_SCHED_MAX_RESPONSE_TIME;
|
||||
}
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 OsSchedTimeoutQueueAdjust(LosTaskCB *taskCB, UINT64 responseTime)
|
||||
{
|
||||
UINT32 ret;
|
||||
SortLinkList *node = &taskCB->sortList;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
UINT16 cpuid = node->cpuid;
|
||||
#else
|
||||
UINT16 cpuid = 0;
|
||||
#endif
|
||||
SchedRunqueue *rq = OsSchedRunqueueByID(cpuid);
|
||||
ret = OsSortLinkAdjustNodeResponseTime(&rq->timeoutQueue, node, responseTime);
|
||||
if (ret == LOS_OK) {
|
||||
rq->schedFlag |= INT_PEND_TICK;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID SchedTaskFreeze(LosTaskCB *taskCB)
|
||||
{
|
||||
UINT64 responseTime;
|
||||
|
||||
#ifdef LOSCFG_KERNEL_PM
|
||||
if (!OsIsPmMode()) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!(taskCB->taskStatus & (OS_TASK_STATUS_PEND_TIME | OS_TASK_STATUS_DELAY))) {
|
||||
return;
|
||||
}
|
||||
|
||||
responseTime = GET_SORTLIST_VALUE(&taskCB->sortList);
|
||||
OsSchedTimeoutQueueDelete(taskCB);
|
||||
SET_SORTLIST_VALUE(&taskCB->sortList, responseTime);
|
||||
taskCB->taskStatus |= OS_TASK_STATUS_FROZEN;
|
||||
return;
|
||||
}
|
||||
|
||||
STATIC INLINE VOID SchedTaskUnfreeze(LosTaskCB *taskCB)
|
||||
{
|
||||
UINT64 currTime, responseTime;
|
||||
|
||||
if (!(taskCB->taskStatus & OS_TASK_STATUS_FROZEN)) {
|
||||
return;
|
||||
}
|
||||
|
||||
taskCB->taskStatus &= ~OS_TASK_STATUS_FROZEN;
|
||||
currTime = OsGetCurrSchedTimeCycle();
|
||||
responseTime = GET_SORTLIST_VALUE(&taskCB->sortList);
|
||||
if (responseTime > currTime) {
|
||||
OsSchedTimeoutQueueAdd(taskCB, responseTime);
|
||||
return;
|
||||
}
|
||||
|
||||
SET_SORTLIST_VALUE(&taskCB->sortList, OS_SORT_LINK_INVALID_TIME);
|
||||
if (taskCB->taskStatus & OS_TASK_STATUS_PENDING) {
|
||||
LOS_ListDelete(&taskCB->pendList);
|
||||
}
|
||||
taskCB->taskStatus &= ~OS_TASK_STATUS_BLOCKED;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Schedule flag, one bit represents one core.
|
||||
* This flag is used to prevent kernel scheduling before OSStartToRun.
|
||||
@@ -87,137 +610,72 @@ 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)
|
||||
STATIC INLINE LosTaskCB *HPFRunqueueTopTaskGet(HPFRunqueue *rq)
|
||||
{
|
||||
/*
|
||||
* 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;
|
||||
|
||||
LosTaskCB *newTask = NULL;
|
||||
UINT32 baseBitmap = rq->queueBitmap;
|
||||
#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);
|
||||
UINT32 cpuid = ArchCurrCpuid();
|
||||
#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;
|
||||
while (baseBitmap) {
|
||||
UINT32 basePrio = CLZ(baseBitmap);
|
||||
HPFQueue *queueList = &rq->queueList[basePrio];
|
||||
UINT32 bitmap = queueList->queueBitmap;
|
||||
while (bitmap) {
|
||||
UINT32 priority = CLZ(bitmap);
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY(newTask, &queueList->priQueList[priority], LosTaskCB, pendList) {
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
if (newTask->cpuAffiMask & (1U << cpuid)) {
|
||||
#endif
|
||||
return newTask;
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
}
|
||||
#endif
|
||||
}
|
||||
bitmap &= ~(1U << (OS_PRIORITY_QUEUE_NUM - priority - 1));
|
||||
}
|
||||
baseBitmap &= ~(1U << (OS_PRIORITY_QUEUE_NUM - basePrio - 1));
|
||||
}
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
extern UINT32 OsSchedSetTickTimerType(UINT32 timerType);
|
||||
VOID HPFSchedPolicyInit(SchedRunqueue *rq);
|
||||
VOID HPFTaskSchedParamInit(LosTaskCB *taskCB, UINT16 policy,
|
||||
const SchedParam *parentParam, const TSK_INIT_PARAM_S *param);
|
||||
VOID HPFProcessDefaultSchedParamGet(SchedParam *param);
|
||||
|
||||
extern VOID OsSchedSetIdleTaskSchedParam(LosTaskCB *idleTask);
|
||||
VOID IdleTaskSchedParamInit(LosTaskCB *taskCB);
|
||||
|
||||
extern UINT32 OsSchedSwtmrScanRegister(SchedScan func);
|
||||
INT32 OsSchedParamCompare(const LosTaskCB *task1, const LosTaskCB *task2);
|
||||
VOID OsSchedPriorityInheritance(LosTaskCB *owner, const SchedParam *param);
|
||||
UINT32 OsSchedParamInit(LosTaskCB *taskCB, UINT16 policy,
|
||||
const SchedParam *parentParam, const TSK_INIT_PARAM_S *param);
|
||||
VOID OsSchedProcessDefaultSchedParamGet(UINT16 policy, SchedParam *param);
|
||||
|
||||
extern VOID OsSchedResetSchedResponseTime(UINT64 responseTime);
|
||||
VOID OsSchedResponseTimeReset(UINT64 responseTime);
|
||||
VOID OsSchedToUserReleaseLock(VOID);
|
||||
VOID OsSchedTick(VOID);
|
||||
UINT32 OsSchedInit(VOID);
|
||||
VOID OsSchedStart(VOID);
|
||||
|
||||
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 OsSchedRunqueueIdleInit(UINT32 idleTaskID);
|
||||
VOID OsSchedRunqueueInit(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);
|
||||
|
||||
#ifdef LOSCFG_SCHED_TICK_DEBUG
|
||||
extern VOID OsSchedDebugRecordData(VOID);
|
||||
#endif
|
||||
|
||||
extern UINT32 OsShellShowTickRespo(VOID);
|
||||
|
||||
extern UINT32 OsShellShowSchedParam(VOID);
|
||||
LOS_DL_LIST *OsSchedLockPendFindPos(const LosTaskCB *runTask, LOS_DL_LIST *lockList);
|
||||
|
||||
#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,61 @@ 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;
|
||||
|
||||
LOS_SpinLock(&sortHeader->spinLock);
|
||||
if (LOS_ListEmpty(head)) {
|
||||
LOS_SpinUnlock(&sortHeader->spinLock);
|
||||
return OS_SORT_LINK_INVALID_TIME - tickPrecision;
|
||||
}
|
||||
|
||||
SortLinkList *listSorted = LOS_DL_LIST_ENTRY(list, SortLinkList, sortLinkNode);
|
||||
if (listSorted->responseTime <= (startTime + tickPrecision)) {
|
||||
LOS_SpinUnlock(&sortHeader->spinLock);
|
||||
return startTime + tickPrecision;
|
||||
}
|
||||
|
||||
LOS_SpinUnlock(&sortHeader->spinLock);
|
||||
return listSorted->responseTime;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT32 OsGetSortLinkNodeNum(const SortLinkAttribute *head)
|
||||
{
|
||||
return head->nodeNum;
|
||||
}
|
||||
|
||||
STATIC INLINE UINT16 OsGetSortLinkNodeCpuid(const SortLinkList *node)
|
||||
{
|
||||
#ifdef LOSCFG_KERNEL_SMP
|
||||
return node->cpuid;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
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);
|
||||
UINT32 OsSortLinkAdjustNodeResponseTime(SortLinkAttribute *head, SortLinkList *node, UINT64 responseTime);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -48,7 +48,7 @@ typedef struct {
|
||||
} StackInfo;
|
||||
|
||||
#define OS_INVALID_WATERLINE 0xFFFFFFFF
|
||||
#define OS_STACK_MAGIC_CHECK(topstack) (*(UINTPTR *)(topstack) == OS_STACK_MAGIC_WORD) /* 1:magic valid 0:unvalid */
|
||||
#define OS_STACK_MAGIC_CHECK(topstack) (*(UINTPTR *)(topstack) == OS_STACK_MAGIC_WORD) /* 1:magic valid 0:invalid */
|
||||
|
||||
extern VOID OsExcStackInfo(VOID);
|
||||
extern VOID OsExcStackInfoReg(const StackInfo *stackInfo, UINT32 stackNum);
|
||||
@@ -81,4 +81,4 @@ extern UINT32 OsStackWaterLineGet(const UINTPTR *stackBottom, const UINTPTR *sta
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _LOS_STACK_INFO_PRI_H */
|
||||
#endif /* _LOS_STACK_INFO_PRI_H */
|
||||
|
||||
@@ -40,11 +40,6 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct {
|
||||
UINT64 runtime;
|
||||
UINT32 contexSwitch;
|
||||
} SchedPercpu;
|
||||
|
||||
typedef struct {
|
||||
UINT64 allRuntime;
|
||||
UINT64 runTime;
|
||||
@@ -56,9 +51,17 @@ typedef struct {
|
||||
UINT64 pendCount;
|
||||
UINT64 waitSchedTime; /* task status is ready to running times */
|
||||
UINT64 waitSchedCount;
|
||||
SchedPercpu schedPercpu[LOSCFG_KERNEL_CORE_NUM];
|
||||
} SchedStat;
|
||||
|
||||
#ifdef LOSCFG_SCHED_DEBUG
|
||||
#ifdef LOSCFG_SCHED_TICK_DEBUG
|
||||
VOID OsSchedDebugRecordData(VOID);
|
||||
UINT32 OsShellShowTickResponse(VOID);
|
||||
UINT32 OsShellShowSchedStatistics(VOID);
|
||||
UINT32 OsSchedDebugInit(VOID);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#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"
|
||||
@@ -65,6 +66,10 @@ typedef struct {
|
||||
SWTMR_PROC_FUNC handler; /**< Callback function that handles software timer timeout */
|
||||
UINTPTR arg; /**< Parameter passed in when the callback function
|
||||
that handles software timer timeout is called */
|
||||
LOS_DL_LIST node;
|
||||
#ifdef LOSCFG_SWTMR_DEBUG
|
||||
UINT32 swtmrID;
|
||||
#endif
|
||||
} SwtmrHandlerItem;
|
||||
|
||||
/**
|
||||
@@ -75,8 +80,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,11 +103,43 @@ 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 UINT32 OsSwtmrGetNextTimeout(VOID);
|
||||
extern BOOL OsIsSwtmrTask(const LosTaskCB *taskCB);
|
||||
extern VOID OsSwtmrResponseTimeReset(UINT64 startTime);
|
||||
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;
|
||||
extern UINT32 OsSwtmrTaskIDGetByCpuid(UINT16 cpuid);
|
||||
|
||||
#ifdef LOSCFG_SWTMR_DEBUG
|
||||
typedef struct {
|
||||
UINT64 startTime;
|
||||
UINT64 waitTimeMax;
|
||||
UINT64 waitTime;
|
||||
UINT64 waitCount;
|
||||
UINT64 readyStartTime;
|
||||
UINT64 readyTime;
|
||||
UINT64 readyTimeMax;
|
||||
UINT64 runTime;
|
||||
UINT64 runTimeMax;
|
||||
UINT64 runCount;
|
||||
UINT32 times;
|
||||
} SwtmrDebugBase;
|
||||
|
||||
typedef struct {
|
||||
SwtmrDebugBase base;
|
||||
SWTMR_PROC_FUNC handler;
|
||||
UINT32 period;
|
||||
UINT32 cpuid;
|
||||
BOOL swtmrUsed;
|
||||
} SwtmrDebugData;
|
||||
|
||||
extern BOOL OsSwtmrDebugDataUsed(UINT32 swtmrID);
|
||||
extern UINT32 OsSwtmrDebugDataGet(UINT32 swtmrID, SwtmrDebugData *data, UINT32 len, UINT8 *mode);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -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" {
|
||||
@@ -55,9 +43,9 @@ extern "C" {
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Define task siginal types.
|
||||
* Define task signal types.
|
||||
*
|
||||
* Task siginal types.
|
||||
* Task signal types.
|
||||
*/
|
||||
#define SIGNAL_NONE 0U
|
||||
#define SIGNAL_KILL (1U << 0)
|
||||
@@ -79,104 +67,13 @@ 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.
|
||||
*
|
||||
* The task control block is unused.
|
||||
*/
|
||||
#define OS_TASK_STATUS_UNUSED 0x0200U
|
||||
#define OS_TASK_STATUS_UNUSED 0x0400U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
@@ -184,7 +81,15 @@ extern SPIN_LOCK_S g_taskSpin;
|
||||
*
|
||||
* The task is joinable.
|
||||
*/
|
||||
#define OS_TASK_FLAG_PTHREAD_JOIN 0x0400U
|
||||
#define OS_TASK_FLAG_PTHREAD_JOIN 0x0800U
|
||||
|
||||
/**
|
||||
* @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 0x1000U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
@@ -192,7 +97,7 @@ extern SPIN_LOCK_S g_taskSpin;
|
||||
*
|
||||
* The task is system-level task, like idle, swtmr and etc.
|
||||
*/
|
||||
#define OS_TASK_FLAG_SYSTEM_TASK 0x1000U
|
||||
#define OS_TASK_FLAG_SYSTEM_TASK 0x2000U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
@@ -200,7 +105,7 @@ extern SPIN_LOCK_S g_taskSpin;
|
||||
*
|
||||
* The task is no-delete system task, like resourceTask.
|
||||
*/
|
||||
#define OS_TASK_FLAG_NO_DELETE 0x2000U
|
||||
#define OS_TASK_FLAG_NO_DELETE 0x4000U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
@@ -208,15 +113,7 @@ extern SPIN_LOCK_S g_taskSpin;
|
||||
*
|
||||
* Kills the thread during process exit.
|
||||
*/
|
||||
#define OS_TASK_FLAG_EXIT_KILL 0x4000U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
* Flag that indicates the task or task control block status.
|
||||
*
|
||||
* The delayed operation of this task is frozen.
|
||||
*/
|
||||
#define OS_TASK_FLAG_FREEZE 0x8000U
|
||||
#define OS_TASK_FLAG_EXIT_KILL 0x8000U
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
@@ -306,76 +203,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 +243,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 +250,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 +310,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 UINT32 OsUserTaskOperatePermissionsCheck(LosTaskCB *taskCB);
|
||||
extern UINT32 OsUserProcessOperatePermissionsCheck(LosTaskCB *taskCB, UINT32 processID);
|
||||
extern VOID OsRunningTaskToExit(LosTaskCB *runTask, UINT32 status);
|
||||
extern INT32 OsUserTaskOperatePermissionsCheck(const LosTaskCB *taskCB);
|
||||
extern INT32 OsUserProcessOperatePermissionsCheck(const 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
|
||||
|
||||
@@ -59,9 +59,9 @@ extern "C" {
|
||||
const CHAR *OsGetRegionNameOrFilePath(LosVmMapRegion *region);
|
||||
INT32 OsRegionOverlapCheckUnlock(LosVmSpace *space, LosVmMapRegion *region);
|
||||
UINT32 OsShellCmdProcessVmUsage(LosVmSpace *space);
|
||||
VOID OsShellCmdProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm);
|
||||
VOID OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm);
|
||||
VOID OsKProcessPmUsage(LosVmSpace *kAspace, UINT32 *actualPm);
|
||||
UINT32 OsShellCmdProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm);
|
||||
UINT32 OsUProcessPmUsage(LosVmSpace *space, UINT32 *sharePm, UINT32 *actualPm);
|
||||
UINT32 OsKProcessPmUsage(LosVmSpace *kAspace, UINT32 *actualPm);
|
||||
VOID OsDumpAspace(LosVmSpace *space);
|
||||
UINT32 OsCountRegionPages(LosVmSpace *space, LosVmMapRegion *region, UINT32 *pssPages);
|
||||
UINT32 OsCountAspacePages(LosVmSpace *space);
|
||||
|
||||
@@ -50,7 +50,7 @@ extern "C" {
|
||||
#define min(x, y) ((x) < (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#define VM_PAGE_TO_PHYS(page) (page->physAddr)
|
||||
#define VM_PAGE_TO_PHYS(page) ((page)->physAddr)
|
||||
#define VM_ORDER_TO_PAGES(order) (1 << (order))
|
||||
#define VM_ORDER_TO_PHYS(order) (1 << (PAGE_SHIFT + (order)))
|
||||
#define VM_PHYS_TO_ORDER(phys) (min(LOS_LowBitGet((phys) >> PAGE_SHIFT), VM_LIST_ORDER_MAX - 1))
|
||||
|
||||
@@ -86,18 +86,18 @@ extern "C" {
|
||||
#define PERIPH_UNCACHED_SIZE U32_C(PERIPH_PMM_SIZE)
|
||||
#endif
|
||||
|
||||
#define IO_DEVICE_ADDR(paddr) (paddr - PERIPH_PMM_BASE + PERIPH_DEVICE_BASE)
|
||||
#define IO_CACHED_ADDR(paddr) (paddr - PERIPH_PMM_BASE + PERIPH_CACHED_BASE)
|
||||
#define IO_UNCACHED_ADDR(paddr) (paddr - PERIPH_PMM_BASE + PERIPH_UNCACHED_BASE)
|
||||
#define IO_DEVICE_ADDR(paddr) ((paddr) - PERIPH_PMM_BASE + PERIPH_DEVICE_BASE)
|
||||
#define IO_CACHED_ADDR(paddr) ((paddr) - PERIPH_PMM_BASE + PERIPH_CACHED_BASE)
|
||||
#define IO_UNCACHED_ADDR(paddr) ((paddr) - PERIPH_PMM_BASE + PERIPH_UNCACHED_BASE)
|
||||
|
||||
#define MEM_CACHED_ADDR(paddr) (paddr - DDR_MEM_ADDR + KERNEL_VMM_BASE)
|
||||
#define MEM_UNCACHED_ADDR(paddr) (paddr - DDR_MEM_ADDR + UNCACHED_VMM_BASE)
|
||||
#define MEM_CACHED_ADDR(paddr) ((paddr) - DDR_MEM_ADDR + KERNEL_VMM_BASE)
|
||||
#define MEM_UNCACHED_ADDR(paddr) ((paddr) - DDR_MEM_ADDR + UNCACHED_VMM_BASE)
|
||||
|
||||
#define VMM_TO_UNCACHED_ADDR(vaddr) (vaddr - KERNEL_VMM_BASE + UNCACHED_VMM_BASE)
|
||||
#define UNCACHED_TO_VMM_ADDR(vaddr) (vaddr - UNCACHED_VMM_BASE + KERNEL_VMM_BASE)
|
||||
#define VMM_TO_UNCACHED_ADDR(vaddr) ((vaddr) - KERNEL_VMM_BASE + UNCACHED_VMM_BASE)
|
||||
#define UNCACHED_TO_VMM_ADDR(vaddr) ((vaddr) - UNCACHED_VMM_BASE + KERNEL_VMM_BASE)
|
||||
|
||||
#define VMM_TO_DMA_ADDR(vaddr) (vaddr - KERNEL_VMM_BASE + SYS_MEM_BASE)
|
||||
#define DMA_TO_VMM_ADDR(vaddr) (vaddr - SYS_MEM_BASE + KERNEL_VMM_BASE)
|
||||
#define VMM_TO_DMA_ADDR(vaddr) ((vaddr) - KERNEL_VMM_BASE + SYS_MEM_BASE)
|
||||
#define DMA_TO_VMM_ADDR(vaddr) ((vaddr) - SYS_MEM_BASE + KERNEL_VMM_BASE)
|
||||
|
||||
#if (PERIPH_UNCACHED_BASE >= (0xFFFFFFFFU - PERIPH_UNCACHED_SIZE))
|
||||
#error "Kernel virtual memory space has overflowed!"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -147,7 +147,7 @@ LITE_OS_SEC_TEXT STATIC UINT32 OsEventReadImp(PEVENT_CB_S eventCB, UINT32 eventM
|
||||
runTask->eventMode = mode;
|
||||
runTask->taskEvent = eventCB;
|
||||
OsTaskWaitSetPendMask(OS_TASK_WAIT_EVENT, eventMask, timeout);
|
||||
ret = OsSchedTaskWait(&eventCB->stEventList, timeout, TRUE);
|
||||
ret = runTask->ops->wait(runTask, &eventCB->stEventList, timeout);
|
||||
if (ret == LOS_ERRNO_TSK_TIMEOUT) {
|
||||
return LOS_ERRNO_EVENT_READ_TIMEOUT;
|
||||
}
|
||||
@@ -185,7 +185,7 @@ LITE_OS_SEC_TEXT STATIC UINT8 OsEventResume(LosTaskCB *resumedTask, const PEVENT
|
||||
|
||||
resumedTask->taskEvent = NULL;
|
||||
OsTaskWakeClearPendMask(resumedTask);
|
||||
OsSchedTaskWake(resumedTask);
|
||||
resumedTask->ops->wake(resumedTask);
|
||||
}
|
||||
|
||||
return exitFlag;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -112,16 +112,16 @@ STATIC VOID OsFutexShowTaskNodeAttr(const LOS_DL_LIST *futexList)
|
||||
LOS_DL_LIST *queueList = NULL;
|
||||
|
||||
tempNode = OS_FUTEX_FROM_FUTEXLIST(futexList);
|
||||
PRINTK("key(pid) : 0x%x(%d) : ->", tempNode->key, tempNode->pid);
|
||||
PRINTK("key(pid) : 0x%x(%u) : ->", tempNode->key, tempNode->pid);
|
||||
|
||||
for (queueList = &tempNode->queueList; ;) {
|
||||
lastNode = OS_FUTEX_FROM_QUEUELIST(queueList);
|
||||
if (!LOS_ListEmpty(&(lastNode->pendList))) {
|
||||
taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(lastNode->pendList)));
|
||||
PRINTK(" %d(%d) ->", taskCB->taskID, taskCB->priority);
|
||||
PRINTK(" %u ->", taskCB->taskID);
|
||||
} else {
|
||||
taskCB = LOS_DL_LIST_ENTRY(lastNode, LosTaskCB, futex);
|
||||
PRINTK(" %d(%d) ->", taskCB->taskID, -1);
|
||||
PRINTK(" %u ->", taskCB->taskID);
|
||||
}
|
||||
queueList = queueList->pstNext;
|
||||
if (queueList == &tempNode->queueList) {
|
||||
@@ -336,20 +336,19 @@ STATIC INT32 OsFutexInsertFindFormBackToFront(LOS_DL_LIST *queueList, const LosT
|
||||
{
|
||||
LOS_DL_LIST *listHead = queueList;
|
||||
LOS_DL_LIST *listTail = queueList->pstPrev;
|
||||
FutexNode *tempNode = NULL;
|
||||
LosTaskCB *taskTail = NULL;
|
||||
|
||||
for (; listHead != listTail; listTail = listTail->pstPrev) {
|
||||
tempNode = OS_FUTEX_FROM_QUEUELIST(listTail);
|
||||
FutexNode *tempNode = OS_FUTEX_FROM_QUEUELIST(listTail);
|
||||
tempNode = OsFutexDeleteAlreadyWakeTaskAndGetNext(tempNode, NULL, FALSE);
|
||||
if (tempNode == NULL) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
taskTail = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(tempNode->pendList)));
|
||||
if (runTask->priority >= taskTail->priority) {
|
||||
LosTaskCB *taskTail = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(tempNode->pendList)));
|
||||
INT32 ret = OsSchedParamCompare(runTask, taskTail);
|
||||
if (ret >= 0) {
|
||||
LOS_ListHeadInsert(&(tempNode->queueList), &(node->queueList));
|
||||
return LOS_OK;
|
||||
} else if (runTask->priority < taskTail->priority) {
|
||||
} else {
|
||||
if (listTail->pstPrev == listHead) {
|
||||
LOS_ListTailInsert(&(tempNode->queueList), &(node->queueList));
|
||||
return LOS_OK;
|
||||
@@ -364,26 +363,25 @@ STATIC INT32 OsFutexInsertFindFromFrontToBack(LOS_DL_LIST *queueList, const LosT
|
||||
{
|
||||
LOS_DL_LIST *listHead = queueList;
|
||||
LOS_DL_LIST *listTail = queueList->pstPrev;
|
||||
FutexNode *tempNode = NULL;
|
||||
LosTaskCB *taskHead = NULL;
|
||||
|
||||
for (; listHead != listTail; listHead = listHead->pstNext) {
|
||||
tempNode = OS_FUTEX_FROM_QUEUELIST(listHead);
|
||||
FutexNode *tempNode = OS_FUTEX_FROM_QUEUELIST(listHead);
|
||||
tempNode = OsFutexDeleteAlreadyWakeTaskAndGetNext(tempNode, NULL, FALSE);
|
||||
if (tempNode == NULL) {
|
||||
return LOS_NOK;
|
||||
}
|
||||
taskHead = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(tempNode->pendList)));
|
||||
LosTaskCB *taskHead = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(tempNode->pendList)));
|
||||
/* High priority comes before low priority,
|
||||
* in the case of the same priority, after the current node
|
||||
*/
|
||||
if (runTask->priority >= taskHead->priority) {
|
||||
INT32 ret = OsSchedParamCompare(runTask, taskHead);
|
||||
if (ret >= 0) {
|
||||
if (listHead->pstNext == listTail) {
|
||||
LOS_ListHeadInsert(&(tempNode->queueList), &(node->queueList));
|
||||
return LOS_OK;
|
||||
}
|
||||
continue;
|
||||
} else if (runTask->priority < taskHead->priority) {
|
||||
} else {
|
||||
LOS_ListTailInsert(&(tempNode->queueList), &(node->queueList));
|
||||
return LOS_OK;
|
||||
}
|
||||
@@ -414,10 +412,9 @@ STATIC INT32 OsFutexInsertTasktoPendList(FutexNode **firstNode, FutexNode *node,
|
||||
{
|
||||
LosTaskCB *taskHead = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&((*firstNode)->pendList)));
|
||||
LOS_DL_LIST *queueList = &((*firstNode)->queueList);
|
||||
FutexNode *tailNode = NULL;
|
||||
LosTaskCB *taskTail = NULL;
|
||||
|
||||
if (run->priority < taskHead->priority) {
|
||||
INT32 ret1 = OsSchedParamCompare(run, taskHead);
|
||||
if (ret1 < 0) {
|
||||
/* The one with the highest priority is inserted at the top of the queue */
|
||||
LOS_ListTailInsert(queueList, &(node->queueList));
|
||||
OsFutexReplaceQueueListHeadNode(*firstNode, node);
|
||||
@@ -425,16 +422,16 @@ STATIC INT32 OsFutexInsertTasktoPendList(FutexNode **firstNode, FutexNode *node,
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
if (LOS_ListEmpty(queueList) && (run->priority >= taskHead->priority)) {
|
||||
if (LOS_ListEmpty(queueList) && (ret1 >= 0)) {
|
||||
/* Insert the next position in the queue with equal priority */
|
||||
LOS_ListHeadInsert(queueList, &(node->queueList));
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
tailNode = OS_FUTEX_FROM_QUEUELIST(LOS_DL_LIST_LAST(queueList));
|
||||
taskTail = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(tailNode->pendList)));
|
||||
if ((run->priority >= taskTail->priority) ||
|
||||
((run->priority - taskHead->priority) > (taskTail->priority - run->priority))) {
|
||||
FutexNode *tailNode = OS_FUTEX_FROM_QUEUELIST(LOS_DL_LIST_LAST(queueList));
|
||||
LosTaskCB *taskTail = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(tailNode->pendList)));
|
||||
INT32 ret2 = OsSchedParamCompare(taskTail, run);
|
||||
if ((ret2 <= 0) || (ret1 > ret2)) {
|
||||
return OsFutexInsertFindFormBackToFront(queueList, run, node);
|
||||
}
|
||||
|
||||
@@ -524,7 +521,7 @@ STATIC INT32 OsFutexWaitParamCheck(const UINT32 *userVaddr, UINT32 flags, UINT32
|
||||
}
|
||||
|
||||
if (!absTime) {
|
||||
return LOS_EINVAL;
|
||||
return LOS_ETIMEDOUT;
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
@@ -569,7 +566,7 @@ STATIC INT32 OsFutexInsertTaskToHash(LosTaskCB **taskCB, FutexNode **node, const
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC INT32 OsFutexWaitTask(const UINT32 *userVaddr, const UINT32 flags, const UINT32 val, const UINT32 timeOut)
|
||||
STATIC INT32 OsFutexWaitTask(const UINT32 *userVaddr, const UINT32 flags, const UINT32 val, const UINT32 timeout)
|
||||
{
|
||||
INT32 futexRet;
|
||||
UINT32 intSave, lockVal;
|
||||
@@ -600,20 +597,20 @@ 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();
|
||||
OsTaskWaitSetPendMask(OS_TASK_WAIT_FUTEX, futexKey, timeout);
|
||||
taskCB->ops->wait(taskCB, &(node->pendList), timeout);
|
||||
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
|
||||
@@ -639,17 +636,17 @@ EXIT_UNLOCK_ERR:
|
||||
INT32 OsFutexWait(const UINT32 *userVaddr, UINT32 flags, UINT32 val, UINT32 absTime)
|
||||
{
|
||||
INT32 ret;
|
||||
UINT32 timeOut = LOS_WAIT_FOREVER;
|
||||
UINT32 timeout = LOS_WAIT_FOREVER;
|
||||
|
||||
ret = OsFutexWaitParamCheck(userVaddr, flags, absTime);
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
if (absTime != LOS_WAIT_FOREVER) {
|
||||
timeOut = OsNS2Tick((UINT64)absTime * OS_SYS_NS_PER_US);
|
||||
timeout = OsNS2Tick((UINT64)absTime * OS_SYS_NS_PER_US);
|
||||
}
|
||||
|
||||
return OsFutexWaitTask(userVaddr, flags, val, timeOut);
|
||||
return OsFutexWaitTask(userVaddr, flags, val, timeout);
|
||||
}
|
||||
|
||||
STATIC INT32 OsFutexWakeParamCheck(const UINT32 *userVaddr, UINT32 flags)
|
||||
@@ -693,7 +690,7 @@ STATIC VOID OsFutexCheckAndWakePendTask(FutexNode *headNode, const INT32 wakeNum
|
||||
node = *nextNode;
|
||||
taskCB = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(node->pendList)));
|
||||
OsTaskWakeClearPendMask(taskCB);
|
||||
OsSchedTaskWake(taskCB);
|
||||
taskCB->ops->wake(taskCB);
|
||||
*wakeAny = TRUE;
|
||||
*nextNode = OS_FUTEX_FROM_QUEUELIST(LOS_DL_LIST_FIRST(&(node->queueList)));
|
||||
if (node != headNode) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-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:
|
||||
@@ -257,40 +257,36 @@ LITE_OS_SEC_TEXT UINT32 LOS_MuxDestroy(LosMux *mutex)
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
STATIC VOID OsMuxBitmapSet(const LosMux *mutex, const LosTaskCB *runTask, LosTaskCB *owner)
|
||||
STATIC VOID OsMuxBitmapSet(const LosMux *mutex, const LosTaskCB *runTask)
|
||||
{
|
||||
if ((owner->priority > runTask->priority) && (mutex->attr.protocol == LOS_MUX_PRIO_INHERIT)) {
|
||||
LOS_BitmapSet(&(owner->priBitMap), owner->priority);
|
||||
(VOID)OsSchedModifyTaskSchedParam(owner, owner->policy, runTask->priority);
|
||||
}
|
||||
}
|
||||
|
||||
VOID OsMuxBitmapRestore(const LosMux *mutex, const LosTaskCB *taskCB, LosTaskCB *owner)
|
||||
{
|
||||
UINT16 bitMapPri;
|
||||
|
||||
if (mutex->attr.protocol != LOS_MUX_PRIO_INHERIT) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (owner->priority >= taskCB->priority) {
|
||||
bitMapPri = LOS_LowBitGet(owner->priBitMap);
|
||||
if (bitMapPri != LOS_INVALID_BIT_INDEX) {
|
||||
LOS_BitmapClr(&(owner->priBitMap), bitMapPri);
|
||||
OsSchedModifyTaskSchedParam(owner, owner->policy, bitMapPri);
|
||||
}
|
||||
} else {
|
||||
if (LOS_HighBitGet(owner->priBitMap) != taskCB->priority) {
|
||||
LOS_BitmapClr(&(owner->priBitMap), taskCB->priority);
|
||||
}
|
||||
SchedParam param = { 0 };
|
||||
LosTaskCB *owner = (LosTaskCB *)mutex->owner;
|
||||
INT32 ret = OsSchedParamCompare(owner, runTask);
|
||||
if (ret > 0) {
|
||||
runTask->ops->schedParamGet(runTask, ¶m);
|
||||
owner->ops->priorityInheritance(owner, ¶m);
|
||||
}
|
||||
}
|
||||
|
||||
VOID OsMuxBitmapRestore(const LosMux *mutex, const LOS_DL_LIST *list, const LosTaskCB *runTask)
|
||||
{
|
||||
if (mutex->attr.protocol != LOS_MUX_PRIO_INHERIT) {
|
||||
return;
|
||||
}
|
||||
|
||||
SchedParam param = { 0 };
|
||||
LosTaskCB *owner = (LosTaskCB *)mutex->owner;
|
||||
runTask->ops->schedParamGet(runTask, ¶m);
|
||||
owner->ops->priorityRestore(owner, list, ¶m);
|
||||
}
|
||||
|
||||
STATIC UINT32 OsMuxPendOp(LosTaskCB *runTask, LosMux *mutex, UINT32 timeout)
|
||||
{
|
||||
UINT32 ret;
|
||||
LOS_DL_LIST *node = NULL;
|
||||
LosTaskCB *owner = NULL;
|
||||
|
||||
if ((mutex->muxList.pstPrev == NULL) || (mutex->muxList.pstNext == NULL)) {
|
||||
/* This is for mutex macro initialization. */
|
||||
@@ -303,9 +299,11 @@ STATIC UINT32 OsMuxPendOp(LosTaskCB *runTask, LosMux *mutex, UINT32 timeout)
|
||||
mutex->muxCount++;
|
||||
mutex->owner = (VOID *)runTask;
|
||||
LOS_ListTailInsert(&runTask->lockList, &mutex->holdList);
|
||||
if ((mutex->attr.protocol == LOS_MUX_PRIO_PROTECT) && (runTask->priority > mutex->attr.prioceiling)) {
|
||||
LOS_BitmapSet(&runTask->priBitMap, runTask->priority);
|
||||
(VOID)OsSchedModifyTaskSchedParam(runTask, runTask->policy, mutex->attr.prioceiling);
|
||||
if (mutex->attr.protocol == LOS_MUX_PRIO_PROTECT) {
|
||||
SchedParam param = { 0 };
|
||||
runTask->ops->schedParamGet(runTask, ¶m);
|
||||
param.priority = mutex->attr.prioceiling;
|
||||
runTask->ops->priorityInheritance(runTask, ¶m);
|
||||
}
|
||||
return LOS_OK;
|
||||
}
|
||||
@@ -323,27 +321,23 @@ STATIC UINT32 OsMuxPendOp(LosTaskCB *runTask, LosMux *mutex, UINT32 timeout)
|
||||
return LOS_EDEADLK;
|
||||
}
|
||||
|
||||
OsMuxBitmapSet(mutex, runTask, (LosTaskCB *)mutex->owner);
|
||||
OsMuxBitmapSet(mutex, runTask);
|
||||
|
||||
owner = (LosTaskCB *)mutex->owner;
|
||||
runTask->taskMux = (VOID *)mutex;
|
||||
node = OsSchedLockPendFindPos(runTask, &mutex->muxList);
|
||||
LOS_DL_LIST *node = OsSchedLockPendFindPos(runTask, &mutex->muxList);
|
||||
if (node == NULL) {
|
||||
ret = LOS_NOK;
|
||||
return ret;
|
||||
}
|
||||
|
||||
OsTaskWaitSetPendMask(OS_TASK_WAIT_MUTEX, (UINTPTR)mutex, timeout);
|
||||
ret = OsSchedTaskWait(node, timeout, TRUE);
|
||||
ret = runTask->ops->wait(runTask, node, timeout);
|
||||
if (ret == LOS_ERRNO_TSK_TIMEOUT) {
|
||||
OsMuxBitmapRestore(mutex, NULL, runTask);
|
||||
runTask->taskMux = NULL;
|
||||
ret = LOS_ETIMEDOUT;
|
||||
}
|
||||
|
||||
if (timeout != LOS_WAIT_FOREVER) {
|
||||
OsMuxBitmapRestore(mutex, runTask, owner);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -440,50 +434,23 @@ LITE_OS_SEC_TEXT UINT32 LOS_MuxTrylock(LosMux *mutex)
|
||||
return ret;
|
||||
}
|
||||
|
||||
STATIC VOID OsMuxPostOpSub(LosTaskCB *taskCB, LosMux *mutex)
|
||||
{
|
||||
LosTaskCB *pendedTask = NULL;
|
||||
UINT16 bitMapPri;
|
||||
|
||||
if (!LOS_ListEmpty(&mutex->muxList)) {
|
||||
bitMapPri = LOS_HighBitGet(taskCB->priBitMap);
|
||||
LOS_DL_LIST_FOR_EACH_ENTRY(pendedTask, (&mutex->muxList), LosTaskCB, pendList) {
|
||||
if (bitMapPri != pendedTask->priority) {
|
||||
LOS_BitmapClr(&taskCB->priBitMap, pendedTask->priority);
|
||||
}
|
||||
}
|
||||
}
|
||||
bitMapPri = LOS_LowBitGet(taskCB->priBitMap);
|
||||
LOS_BitmapClr(&taskCB->priBitMap, bitMapPri);
|
||||
(VOID)OsSchedModifyTaskSchedParam((LosTaskCB *)mutex->owner, ((LosTaskCB *)mutex->owner)->policy, bitMapPri);
|
||||
}
|
||||
|
||||
STATIC UINT32 OsMuxPostOp(LosTaskCB *taskCB, LosMux *mutex, BOOL *needSched)
|
||||
{
|
||||
LosTaskCB *resumedTask = NULL;
|
||||
|
||||
if (LOS_ListEmpty(&mutex->muxList)) {
|
||||
LOS_ListDelete(&mutex->holdList);
|
||||
mutex->owner = NULL;
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
resumedTask = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(mutex->muxList)));
|
||||
if (mutex->attr.protocol == LOS_MUX_PRIO_INHERIT) {
|
||||
if (resumedTask->priority > taskCB->priority) {
|
||||
if (LOS_HighBitGet(taskCB->priBitMap) != resumedTask->priority) {
|
||||
LOS_BitmapClr(&taskCB->priBitMap, resumedTask->priority);
|
||||
}
|
||||
} else if (taskCB->priBitMap != 0) {
|
||||
OsMuxPostOpSub(taskCB, mutex);
|
||||
}
|
||||
}
|
||||
LosTaskCB *resumedTask = OS_TCB_FROM_PENDLIST(LOS_DL_LIST_FIRST(&(mutex->muxList)));
|
||||
OsMuxBitmapRestore(mutex, &mutex->muxList, resumedTask);
|
||||
|
||||
mutex->muxCount = 1;
|
||||
mutex->owner = (VOID *)resumedTask;
|
||||
LOS_ListDelete(&mutex->holdList);
|
||||
LOS_ListTailInsert(&resumedTask->lockList, &mutex->holdList);
|
||||
OsTaskWakeClearPendMask(resumedTask);
|
||||
OsSchedTaskWake(resumedTask);
|
||||
resumedTask->ops->wake(resumedTask);
|
||||
resumedTask->taskMux = NULL;
|
||||
if (needSched != NULL) {
|
||||
*needSched = TRUE;
|
||||
@@ -494,8 +461,6 @@ STATIC UINT32 OsMuxPostOp(LosTaskCB *taskCB, LosMux *mutex, BOOL *needSched)
|
||||
|
||||
UINT32 OsMuxUnlockUnsafe(LosTaskCB *taskCB, LosMux *mutex, BOOL *needSched)
|
||||
{
|
||||
UINT16 bitMapPri;
|
||||
|
||||
if (mutex->magic != OS_MUX_MAGIC) {
|
||||
return LOS_EBADF;
|
||||
}
|
||||
@@ -517,11 +482,9 @@ UINT32 OsMuxUnlockUnsafe(LosTaskCB *taskCB, LosMux *mutex, BOOL *needSched)
|
||||
}
|
||||
|
||||
if (mutex->attr.protocol == LOS_MUX_PRIO_PROTECT) {
|
||||
bitMapPri = LOS_HighBitGet(taskCB->priBitMap);
|
||||
if (bitMapPri != LOS_INVALID_BIT_INDEX) {
|
||||
LOS_BitmapClr(&taskCB->priBitMap, bitMapPri);
|
||||
(VOID)OsSchedModifyTaskSchedParam(taskCB, taskCB->policy, bitMapPri);
|
||||
}
|
||||
SchedParam param = { 0 };
|
||||
taskCB->ops->schedParamGet(taskCB, ¶m);
|
||||
taskCB->ops->priorityRestore(taskCB, NULL, ¶m);
|
||||
}
|
||||
|
||||
/* Whether a task block the mutex lock. */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user