Compare commits
22 Commits
weekly_202
...
weekly_202
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0057fb0dd5 | ||
|
|
bcf7e8ee02 | ||
|
|
fa6b2d352c | ||
|
|
7f57e11ef9 | ||
|
|
1097d41a40 | ||
|
|
90d6ff9a6f | ||
|
|
eebe85fe31 | ||
|
|
b126f1cb5f | ||
|
|
639160f517 | ||
|
|
7fef6ac8d9 | ||
|
|
2f44d18618 | ||
|
|
fbc81cd821 | ||
|
|
a6e17fea9b | ||
|
|
18f7ab1380 | ||
|
|
d205cfa65a | ||
|
|
11b35fe795 | ||
|
|
b086195e97 | ||
|
|
b90531e366 | ||
|
|
a1a6286500 | ||
|
|
e1027b5902 | ||
|
|
b9a445ca44 | ||
|
|
338044cd9c |
37
BUILD.gn
37
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
|
||||
}
|
||||
|
||||
@@ -316,14 +318,16 @@ group("kernel") {
|
||||
}
|
||||
|
||||
group("liteos_a") {
|
||||
deps = [
|
||||
":apps",
|
||||
":kernel",
|
||||
":tests",
|
||||
"//prebuilts/lite/sysroot/build:strip",
|
||||
]
|
||||
if (liteos_skip_make == false) {
|
||||
deps += [ ":make" ]
|
||||
deps = [ ":kernel" ]
|
||||
if (!liteos_is_mini) {
|
||||
deps += [
|
||||
":apps",
|
||||
":tests",
|
||||
"//prebuilts/lite/sysroot/build:strip",
|
||||
]
|
||||
if (liteos_skip_make == false) {
|
||||
deps += [ ":make" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,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")
|
||||
@@ -351,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
OAT.xml
6
OAT.xml
@@ -15,7 +15,7 @@
|
||||
-->
|
||||
|
||||
<!--
|
||||
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>
|
||||
@@ -23,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>
|
||||
@@ -38,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"/-->
|
||||
|
||||
11
README.md
11
README.md
@@ -62,19 +62,18 @@ 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.
|
||||
|
||||
- [Setting Up Ubuntu Development Environment](https://gitee.com/openharmony/docs/blob/master/en/device-dev/quick-start/quickstart-lite-env-setup-linux.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-hi3518-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,8 +84,6 @@ 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-hi3518-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>
|
||||
|
||||
@@ -62,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/quickstart-lite-introduction-hi3518.md))、Hi3516DV300([介紹](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.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上搭建編譯環境:
|
||||
|
||||
- [編譯環境凖備](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.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>
|
||||
@@ -85,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>
|
||||
|
||||
13
README_zh.md
13
README_zh.md
@@ -61,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/quickstart-lite-introduction-hi3518.md))、Hi3516DV300([介绍](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-introduction-hi3516.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上搭建编译环境:
|
||||
|
||||
- [编译环境准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-lite-package-environment.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>
|
||||
@@ -82,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)。
|
||||
|
||||
|
||||
@@ -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]);
|
||||
@@ -125,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;
|
||||
@@ -165,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);
|
||||
|
||||
@@ -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);
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,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
|
||||
@@ -516,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)));
|
||||
@@ -645,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;
|
||||
@@ -655,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++) {
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
"bounds_checking_function",
|
||||
"toybox",
|
||||
"NuttX",
|
||||
"Linux_Kernel",
|
||||
"FatFs",
|
||||
"mksh",
|
||||
"musl",
|
||||
@@ -63,4 +62,4 @@
|
||||
"test": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -163,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
|
||||
|
||||
|
||||
@@ -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,23 +28,89 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/Linux_Kernel/Linux_Kernel.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_JFFS)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
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 += LINUX_KERNEL_FS_JFFS2_SRC_FILES
|
||||
sources += [
|
||||
"${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 = LINUX_KERNEL_FS_JFFS2_INCLUDE_DIRS
|
||||
include_dirs = [
|
||||
"${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
@@ -995,7 +995,6 @@ LITE_OS_SEC_TEXT INT32 LOS_SetProcessPriority(INT32 pid, UINT16 prio)
|
||||
|
||||
LITE_OS_SEC_TEXT INT32 OsGetProcessPriority(INT32 which, INT32 pid)
|
||||
{
|
||||
INT32 prio;
|
||||
UINT32 intSave;
|
||||
SchedParam param = { 0 };
|
||||
(VOID)which;
|
||||
@@ -1011,14 +1010,13 @@ LITE_OS_SEC_TEXT INT32 OsGetProcessPriority(INT32 which, INT32 pid)
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(pid);
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (OsProcessIsUnused(processCB)) {
|
||||
prio = -LOS_ESRCH;
|
||||
goto OUT;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return -LOS_ESRCH;
|
||||
}
|
||||
|
||||
LosTaskCB *taskCB = OS_TCB_FROM_TID(processCB->threadGroupID);
|
||||
taskCB->ops->schedParamGet(taskCB, ¶m);
|
||||
|
||||
OUT:
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return param.basePrio;
|
||||
}
|
||||
|
||||
@@ -226,6 +226,9 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsIdleTaskCreate(VOID)
|
||||
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());
|
||||
#endif
|
||||
ret = LOS_TaskCreateOnly(&idleTaskID, &taskInitParam);
|
||||
if (ret != LOS_OK) {
|
||||
return ret;
|
||||
}
|
||||
LosTaskCB *idleTask = OS_TCB_FROM_TID(idleTaskID);
|
||||
idleTask->taskStatus |= OS_TASK_FLAG_SYSTEM_TASK;
|
||||
OsSchedRunqueueIdleInit(idleTaskID);
|
||||
|
||||
@@ -41,7 +41,9 @@
|
||||
#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"
|
||||
@@ -555,9 +557,11 @@ 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;
|
||||
|
||||
@@ -198,6 +198,7 @@ __attribute__((noinline)) VOID UartPrintf(const CHAR *fmt, ...)
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
#ifndef LOSCFG_LIBC_NEWLIB
|
||||
__attribute__((noinline)) VOID dprintf(const CHAR *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
@@ -210,6 +211,7 @@ __attribute__((noinline)) VOID dprintf(const CHAR *fmt, ...)
|
||||
#endif
|
||||
va_end(ap);
|
||||
}
|
||||
#endif
|
||||
|
||||
VOID LkDprintf(const CHAR *fmt, va_list ap)
|
||||
{
|
||||
@@ -279,7 +281,7 @@ VOID LOS_LkPrint(INT32 level, const CHAR *func, INT32 line, const CHAR *fmt, ...
|
||||
}
|
||||
|
||||
if ((level != LOS_COMMON_LEVEL) && ((level > LOS_EMG_LEVEL) && (level <= LOS_TRACE_LEVEL))) {
|
||||
dprintf("[%s][%s:%s]", g_logString[level],
|
||||
PRINTK("[%s][%s:%s]", g_logString[level],
|
||||
((OsCurrProcessGet() == NULL) ? "NULL" : OsCurrProcessGet()->processName),
|
||||
((OsCurrTaskGet() == NULL) ? "NULL" : OsCurrTaskGet()->taskName));
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ static ssize_t HiLogRead(struct file *filep, char *buffer, size_t bufLen)
|
||||
}
|
||||
|
||||
if (bufLen < header.len + sizeof(header)) {
|
||||
dprintf("buffer too small,bufLen=%d, header.len=%d,%d\n", bufLen, header.len, header.hdrSize);
|
||||
PRINTK("buffer too small,bufLen=%d, header.len=%d,%d\n", bufLen, header.len, header.hdrSize);
|
||||
retval = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
@@ -238,7 +238,7 @@ static void HiLogHeadInit(struct HiLogEntry *header, size_t len)
|
||||
|
||||
ret = clock_gettime(CLOCK_REALTIME, &now);
|
||||
if (ret != 0) {
|
||||
dprintf("In %s line %d,clock_gettime fail\n", __FUNCTION__, __LINE__);
|
||||
PRINTK("In %s line %d,clock_gettime fail\n", __FUNCTION__, __LINE__);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ static void HiLogCoverOldLog(size_t bufLen)
|
||||
if (isLastTimeFull == 1 && isThisTimeFull == 0) {
|
||||
/* so we can only print one log if hilog ring buffer is full in a short time */
|
||||
if (dropLogLines > 0) {
|
||||
dprintf("hilog ringbuffer full, drop %d line(s) log\n", dropLogLines);
|
||||
PRINTK("hilog ringbuffer full, drop %d line(s) log\n", dropLogLines);
|
||||
}
|
||||
isLastTimeFull = 0;
|
||||
dropLogLines = 0;
|
||||
@@ -319,7 +319,7 @@ out:
|
||||
wake_up_interruptible(&g_hiLogDev.wq);
|
||||
}
|
||||
if (retval < 0) {
|
||||
dprintf("write fail retval=%d\n", retval);
|
||||
PRINTK("write fail retval=%d\n", retval);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
@@ -328,7 +328,7 @@ static ssize_t HiLogWrite(struct file *filep, const char *buffer, size_t bufLen)
|
||||
{
|
||||
(void)filep;
|
||||
if (bufLen + sizeof(struct HiLogEntry) > HILOG_BUFFER) {
|
||||
dprintf("input too large\n");
|
||||
PRINTK("input too large\n");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ static void HiLogDeviceInit(void)
|
||||
{
|
||||
g_hiLogDev.buffer = LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, HILOG_BUFFER);
|
||||
if (g_hiLogDev.buffer == NULL) {
|
||||
dprintf("In %s line %d,LOS_MemAlloc fail\n", __FUNCTION__, __LINE__);
|
||||
PRINTK("In %s line %d,LOS_MemAlloc fail\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
init_waitqueue_head(&g_hiLogDev.wq);
|
||||
|
||||
@@ -63,6 +63,10 @@
|
||||
#define LITEIPC_TIMEOUT_MS 5000UL
|
||||
#define LITEIPC_TIMEOUT_NS 5000000000ULL
|
||||
|
||||
#define MAJOR_VERSION (2)
|
||||
#define MINOR_VERSION (0)
|
||||
#define DRIVER_VERSION (MAJOR_VERSION | MINOR_VERSION << 16)
|
||||
|
||||
typedef struct {
|
||||
LOS_DL_LIST list;
|
||||
VOID *ptr;
|
||||
@@ -479,6 +483,7 @@ LITE_OS_SEC_TEXT STATIC UINT32 AddServiceAccess(UINT32 taskID, UINT32 serviceHan
|
||||
PRINT_ERR("Liteipc AddServiceAccess GetTid failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
LosTaskCB *tcb = OS_TCB_FROM_TID(serviceTid);
|
||||
UINT32 processID = OS_TCB_FROM_TID(taskID)->processID;
|
||||
LosProcessCB *pcb = OS_PCB_FROM_PID(processID);
|
||||
@@ -758,22 +763,45 @@ LITE_OS_SEC_TEXT STATIC UINT32 HandlePtr(UINT32 processID, SpecialObj *obj, BOOL
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT STATIC UINT32 HandleSvc(UINT32 dstTid, const SpecialObj *obj, BOOL isRollback)
|
||||
LITE_OS_SEC_TEXT STATIC UINT32 HandleSvc(UINT32 dstTid, SpecialObj *obj, BOOL isRollback)
|
||||
{
|
||||
UINT32 taskID = 0;
|
||||
if (isRollback == FALSE) {
|
||||
if (obj->content.svc.handle == -1) {
|
||||
if (obj->content.svc.token != 1) {
|
||||
PRINT_ERR("Liteipc HandleSvc wrong svc token\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
UINT32 selfTid = LOS_CurTaskIDGet();
|
||||
LosTaskCB *tcb = OS_TCB_FROM_TID(selfTid);
|
||||
if (tcb->ipcTaskInfo == NULL) {
|
||||
tcb->ipcTaskInfo = LiteIpcTaskInit();
|
||||
}
|
||||
uint32_t serviceHandle = 0;
|
||||
UINT32 ret = GenerateServiceHandle(selfTid, HANDLE_REGISTED, &serviceHandle);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("Liteipc GenerateServiceHandle failed.\n");
|
||||
return ret;
|
||||
}
|
||||
obj->content.svc.handle = serviceHandle;
|
||||
(VOID)LOS_MuxLock(&g_serviceHandleMapMux, LOS_WAIT_FOREVER);
|
||||
AddServiceAccess(dstTid, serviceHandle);
|
||||
(VOID)LOS_MuxUnlock(&g_serviceHandleMapMux);
|
||||
}
|
||||
if (IsTaskAlive(obj->content.svc.handle) == FALSE) {
|
||||
PRINT_ERR("Liteipc HandleSvc wrong svctid\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (HasServiceAccess(obj->content.svc.handle) == FALSE) {
|
||||
PRINT_ERR("Liteipc %s, %d\n", __FUNCTION__, __LINE__);
|
||||
PRINT_ERR("Liteipc %s, %d, svchandle:%d, tid:%d\n", __FUNCTION__, __LINE__, obj->content.svc.handle, LOS_CurTaskIDGet());
|
||||
return -EACCES;
|
||||
}
|
||||
LosTaskCB *taskCb = OS_TCB_FROM_TID(obj->content.svc.handle);
|
||||
if (taskCb->ipcTaskInfo == NULL) {
|
||||
taskCb->ipcTaskInfo = LiteIpcTaskInit();
|
||||
}
|
||||
if (GetTid(obj->content.svc.handle, &taskID) == 0) {
|
||||
if (taskID == OS_PCB_FROM_PID(OS_TCB_FROM_TID(taskID)->processID)->ipcInfo->ipcTaskID) {
|
||||
AddServiceAccess(dstTid, obj->content.svc.handle);
|
||||
}
|
||||
AddServiceAccess(dstTid, obj->content.svc.handle);
|
||||
}
|
||||
}
|
||||
return LOS_OK;
|
||||
@@ -791,7 +819,7 @@ LITE_OS_SEC_TEXT STATIC UINT32 HandleObj(UINT32 dstTid, SpecialObj *obj, BOOL is
|
||||
ret = HandlePtr(processID, obj, isRollback);
|
||||
break;
|
||||
case OBJ_SVC:
|
||||
ret = HandleSvc(dstTid, (const SpecialObj *)obj, isRollback);
|
||||
ret = HandleSvc(dstTid, (SpecialObj *)obj, isRollback);
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
@@ -1288,6 +1316,22 @@ LITE_OS_SEC_TEXT STATIC UINT32 HandleCmsCmd(CmsCmdContent *content)
|
||||
return ret;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT STATIC UINT32 HandleGetVersion(IpcVersion *version)
|
||||
{
|
||||
UINT32 ret = LOS_OK;
|
||||
IpcVersion localIpcVersion;
|
||||
if (version == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
localIpcVersion.driverVersion = DRIVER_VERSION;
|
||||
ret = copy_to_user((void *)version, (const void *)(&localIpcVersion), sizeof(IpcVersion));
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("%s, %d\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT int LiteIpcIoctl(struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
UINT32 ret = LOS_OK;
|
||||
@@ -1309,6 +1353,8 @@ LITE_OS_SEC_TEXT int LiteIpcIoctl(struct file *filep, int cmd, unsigned long arg
|
||||
return (INT32)SetCms(arg);
|
||||
case IPC_CMS_CMD:
|
||||
return (INT32)HandleCmsCmd((CmsCmdContent *)(UINTPTR)arg);
|
||||
case IPC_GET_VERSION:
|
||||
return (INT32)HandleGetVersion((IpcVersion *)(UINTPTR)arg);
|
||||
case IPC_SET_IPC_THREAD:
|
||||
if (IsCmsSet() == FALSE) {
|
||||
PRINT_ERR("Liteipc ServiceManager not set!\n");
|
||||
|
||||
@@ -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:
|
||||
@@ -114,12 +114,17 @@ typedef enum {
|
||||
MT_NUM
|
||||
} MsgType;
|
||||
|
||||
typedef struct {
|
||||
int32_t driverVersion;
|
||||
} IpcVersion;
|
||||
|
||||
/* lite ipc ioctl */
|
||||
#define IPC_IOC_MAGIC 'i'
|
||||
#define IPC_SET_CMS _IO(IPC_IOC_MAGIC, 1)
|
||||
#define IPC_CMS_CMD _IOWR(IPC_IOC_MAGIC, 2, CmsCmdContent)
|
||||
#define IPC_SET_IPC_THREAD _IO(IPC_IOC_MAGIC, 3)
|
||||
#define IPC_SEND_RECV_MSG _IOWR(IPC_IOC_MAGIC, 4, IpcContent)
|
||||
#define IPC_GET_VERSION _IOR(IPC_IOC_MAGIC, 5, IpcVersion)
|
||||
|
||||
typedef enum {
|
||||
CMS_GEN_HANDLE,
|
||||
|
||||
@@ -87,9 +87,9 @@ typedef VOID (*pf_OUTPUT)(const CHAR *fmt, ...);
|
||||
* <ul><li>los_printf.h: the header file that contains the API declaration.</li></ul>
|
||||
* @see printf
|
||||
*/
|
||||
#ifndef LOSCFG_LIBC_NEWLIB
|
||||
extern void dprintf(const char *fmt, ...);
|
||||
|
||||
#define diag_printf dprintf
|
||||
#endif
|
||||
|
||||
#define PRINT_DEBUG(fmt, args...) LOS_LkPrint(LOS_DEBUG_LEVEL, __FUNCTION__, __LINE__, fmt, ##args)
|
||||
#define PRINT_INFO(fmt, args...) LOS_LkPrint(LOS_INFO_LEVEL, __FUNCTION__, __LINE__, fmt, ##args)
|
||||
|
||||
14
lib/Kconfig
14
lib/Kconfig
@@ -5,6 +5,20 @@ config LIB_LIBC
|
||||
help
|
||||
Answer Y to enable libc for full code.
|
||||
|
||||
choice
|
||||
prompt "choose libc"
|
||||
default LIBC_MUSL
|
||||
depends on LIB_LIBC
|
||||
help
|
||||
Choose libc.
|
||||
|
||||
config LIBC_NEWLIB
|
||||
bool "newlibc"
|
||||
|
||||
config LIBC_MUSL
|
||||
bool "musl libc"
|
||||
endchoice
|
||||
|
||||
config LIB_ZLIB
|
||||
bool "Enable Zlib"
|
||||
default y
|
||||
|
||||
@@ -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:
|
||||
@@ -29,93 +29,16 @@
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
MUSLDIR = "$LITEOSTHIRDPARTY/musl"
|
||||
|
||||
import("//third_party/optimized-routines/optimized-routines.gni")
|
||||
import("$MUSLDIR/porting/liteos_a/kernel/musl.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_LIB_LIBC)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = MUSL_SRC_COMMON
|
||||
|
||||
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
|
||||
sources += MUSL_SRC_ARM
|
||||
foreach(f, MUSL_SRC_ARM) {
|
||||
sources -= [ string_replace(f, "/arm/", "/") ]
|
||||
}
|
||||
}
|
||||
|
||||
if (LOSCFG_ARCH_ARM_VER == "armv7-a") {
|
||||
sources -= [
|
||||
"$MUSLPORTINGDIR/src/string/memchr.c",
|
||||
"$MUSLPORTINGDIR/src/string/memcpy.c",
|
||||
"$MUSLPORTINGDIR/src/string/strcmp.c",
|
||||
"$MUSLPORTINGDIR/src/string/strcpy.c",
|
||||
"$MUSLPORTINGDIR/src/string/strlen.c",
|
||||
]
|
||||
sources += [
|
||||
"src/arch/arm/memcmp.S",
|
||||
"src/arch/arm/memset.S",
|
||||
]
|
||||
sources += OPTRT_STRING_ARM_SRC_FILES_FOR_ARMV7_A
|
||||
asmflags = [
|
||||
"-D__strlen_armv6t2=strlen",
|
||||
"-D__strcmp_arm=strcmp",
|
||||
"-D__memchr_arm=memchr",
|
||||
]
|
||||
if (defined(LOSCFG_KERNEL_LMS)) {
|
||||
asmflags += [
|
||||
"-D__memcpy_arm=__memcpy",
|
||||
"-D__strcpy_arm=__strcpy",
|
||||
]
|
||||
} else {
|
||||
asmflags += [
|
||||
"-D__memcpy_arm=memcpy",
|
||||
"-D__strcpy_arm=strcpy",
|
||||
]
|
||||
}
|
||||
} else {
|
||||
# arch is not armv7-a
|
||||
sources += [
|
||||
"src/memcmp.c",
|
||||
"src/memset.c",
|
||||
]
|
||||
}
|
||||
|
||||
include_dirs = [
|
||||
"$MUSLPORTINGDIR/src/include",
|
||||
"$MUSLPORTINGDIR/src/internal",
|
||||
group("libc") {
|
||||
deps = [
|
||||
"musl",
|
||||
"newlib",
|
||||
]
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
configs += [ ":private" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
cflags = [
|
||||
"-isystem",
|
||||
rebase_path("$MUSLPORTINGDIR/include"),
|
||||
]
|
||||
}
|
||||
|
||||
config("private") {
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags = [
|
||||
"-Wno-char-subscripts",
|
||||
"-Wno-unknown-pragmas",
|
||||
]
|
||||
} else {
|
||||
cflags = [
|
||||
"-frounding-math",
|
||||
"-Wno-unused-but-set-variable",
|
||||
"-Wno-unknown-pragmas",
|
||||
]
|
||||
}
|
||||
|
||||
cflags += [
|
||||
"-Wno-shift-op-parentheses",
|
||||
"-Wno-logical-op-parentheses",
|
||||
"-Wno-bitwise-op-parentheses",
|
||||
configs = [
|
||||
"musl:public",
|
||||
"newlib:public",
|
||||
]
|
||||
}
|
||||
|
||||
121
lib/libc/musl/BUILD.gn
Normal file
121
lib/libc/musl/BUILD.gn
Normal file
@@ -0,0 +1,121 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies 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:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
|
||||
MUSLDIR = "$LITEOSTHIRDPARTY/musl"
|
||||
|
||||
import("//third_party/optimized-routines/optimized-routines.gni")
|
||||
import("$MUSLDIR/porting/liteos_a/kernel/musl.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_LIBC_MUSL)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = MUSL_SRC_COMMON
|
||||
|
||||
if (defined(LOSCFG_ARCH_ARM_AARCH32)) {
|
||||
sources += MUSL_SRC_ARM
|
||||
foreach(f, MUSL_SRC_ARM) {
|
||||
sources -= [ string_replace(f, "/arm/", "/") ]
|
||||
}
|
||||
}
|
||||
|
||||
if (LOSCFG_ARCH_ARM_VER == "armv7-a") {
|
||||
sources -= [
|
||||
"$MUSLPORTINGDIR/src/string/memchr.c",
|
||||
"$MUSLPORTINGDIR/src/string/memcpy.c",
|
||||
"$MUSLPORTINGDIR/src/string/strcmp.c",
|
||||
"$MUSLPORTINGDIR/src/string/strcpy.c",
|
||||
"$MUSLPORTINGDIR/src/string/strlen.c",
|
||||
]
|
||||
sources += [
|
||||
"src/arch/arm/memcmp.S",
|
||||
"src/arch/arm/memset.S",
|
||||
]
|
||||
sources += OPTRT_STRING_ARM_SRC_FILES_FOR_ARMV7_A
|
||||
asmflags = [
|
||||
"-D__strlen_armv6t2=strlen",
|
||||
"-D__strcmp_arm=strcmp",
|
||||
"-D__memchr_arm=memchr",
|
||||
]
|
||||
if (defined(LOSCFG_KERNEL_LMS)) {
|
||||
asmflags += [
|
||||
"-D__memcpy_arm=__memcpy",
|
||||
"-D__strcpy_arm=__strcpy",
|
||||
]
|
||||
} else {
|
||||
asmflags += [
|
||||
"-D__memcpy_arm=memcpy",
|
||||
"-D__strcpy_arm=strcpy",
|
||||
]
|
||||
}
|
||||
} else {
|
||||
# arch is not armv7-a
|
||||
sources += [
|
||||
"src/memcmp.c",
|
||||
"src/memset.c",
|
||||
]
|
||||
}
|
||||
|
||||
include_dirs = [
|
||||
"$MUSLPORTINGDIR/src/include",
|
||||
"$MUSLPORTINGDIR/src/internal",
|
||||
]
|
||||
|
||||
public_configs = [ ":public" ]
|
||||
configs += [ ":private" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
cflags = [
|
||||
"-isystem",
|
||||
rebase_path("$MUSLPORTINGDIR/include"),
|
||||
]
|
||||
}
|
||||
|
||||
config("private") {
|
||||
if (defined(LOSCFG_COMPILER_CLANG_LLVM)) {
|
||||
cflags = [
|
||||
"-Wno-char-subscripts",
|
||||
"-Wno-unknown-pragmas",
|
||||
]
|
||||
} else {
|
||||
cflags = [
|
||||
"-frounding-math",
|
||||
"-Wno-unused-but-set-variable",
|
||||
"-Wno-unknown-pragmas",
|
||||
]
|
||||
}
|
||||
|
||||
cflags += [
|
||||
"-Wno-shift-op-parentheses",
|
||||
"-Wno-logical-op-parentheses",
|
||||
"-Wno-bitwise-op-parentheses",
|
||||
]
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2021-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:
|
||||
@@ -31,6 +31,9 @@
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define SIZE_U64 (sizeof(uint64_t))
|
||||
#define SIZE_U32 (sizeof(uint32_t))
|
||||
|
||||
int memcmp(const void *str1, const void *str2, size_t n)
|
||||
{
|
||||
|
||||
@@ -38,26 +41,26 @@ int memcmp(const void *str1, const void *str2, size_t n)
|
||||
const unsigned char *s2 = str2;
|
||||
size_t num = n;
|
||||
|
||||
while (num >= 8) { /* 8, compare size, the number of chars of one uint64_t data */
|
||||
while (num >= SIZE_U64) {
|
||||
if (*(const uint64_t *)(s1) != *(const uint64_t *)(s2)) {
|
||||
goto L8_byte_diff;
|
||||
goto L4_byte_cmp;
|
||||
}
|
||||
s1 += 8; /* 8, compare size, the number of chars of one uint64_t data */
|
||||
s2 += 8; /* 8, compare size, the number of chars of one uint64_t data */
|
||||
num -= 8; /* 8, compare size, the number of chars of one uint64_t data */
|
||||
s1 += SIZE_U64;
|
||||
s2 += SIZE_U64;
|
||||
num -= SIZE_U64;
|
||||
}
|
||||
if (num == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* L4_byte_cmp */
|
||||
if (num >= 4) { /* 4, compare size, the number of chars of one uint32_t data */
|
||||
L4_byte_cmp:
|
||||
if (num >= SIZE_U32) {
|
||||
if (*(const uint32_t *)(s1) != *(const uint32_t *)(s2)) {
|
||||
goto L4_byte_diff;
|
||||
}
|
||||
s1 += 4; /* 4, compare size, the number of chars of one uint32_t data */
|
||||
s2 += 4; /* 4, compare size, the number of chars of one uint32_t data */
|
||||
num -= 4; /* 4, compare size, the number of chars of one uint32_t data */
|
||||
s1 += SIZE_U32;
|
||||
s2 += SIZE_U32;
|
||||
num -= SIZE_U32;
|
||||
}
|
||||
if (num == 0) {
|
||||
return 0;
|
||||
@@ -66,13 +69,4 @@ L4_byte_diff:
|
||||
for (; num && (*s1 == *s2); num--, s1++, s2++) {
|
||||
}
|
||||
return num ? *s1 - *s2 : 0;
|
||||
|
||||
L8_byte_diff:
|
||||
if (*(const uint32_t *)(s1) != *(const uint32_t *)(s2)) {
|
||||
goto L4_byte_diff;
|
||||
}
|
||||
s1 += 4; /* 4, compare size, the number of chars of one uint32_t data */
|
||||
s2 += 4; /* 4, compare size, the number of chars of one uint32_t data */
|
||||
num -= 4; /* 4, compare size, the number of chars of one uint32_t data */
|
||||
goto L4_byte_diff;
|
||||
}
|
||||
58
lib/libc/newlib/BUILD.gn
Normal file
58
lib/libc/newlib/BUILD.gn
Normal file
@@ -0,0 +1,58 @@
|
||||
# Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
# conditions and the following disclaimer.
|
||||
#
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
# of conditions and the following disclaimer in the documentation and/or other materials
|
||||
# provided with the distribution.
|
||||
#
|
||||
# 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
# to endorse or promote products derived from this software without specific prior written
|
||||
# permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/musl/porting/liteos_a_newlib/kernel/newlib.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_LIBC_NEWLIB)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = NEWLIB_ADAPT_SRC_COMMON
|
||||
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||
|
||||
configs += [ ":private" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "porting/include" ]
|
||||
include_dirs += NEWLIB_ADAPT_INCLUDE_DIRS
|
||||
}
|
||||
|
||||
config("private") {
|
||||
cflags = [
|
||||
"-frounding-math",
|
||||
"-Wno-unused-but-set-variable",
|
||||
"-Wno-unknown-pragmas",
|
||||
]
|
||||
|
||||
cflags += [
|
||||
"-Wno-shift-op-parentheses",
|
||||
"-Wno-logical-op-parentheses",
|
||||
"-Wno-bitwise-op-parentheses",
|
||||
]
|
||||
}
|
||||
@@ -204,7 +204,7 @@ LIB_SUBDIRS += lib/libscrew
|
||||
LITEOS_LIBSCREW_INCLUDE += -I $(LITEOSTOPDIR)/lib/libscrew/include
|
||||
|
||||
ifeq ($(LOSCFG_LIB_LIBC), y)
|
||||
LIB_SUBDIRS += lib/libc
|
||||
LIB_SUBDIRS += lib/libc/musl
|
||||
LITEOS_BASELIB += -lc
|
||||
LITEOS_LIBC_INCLUDE += \
|
||||
-isystem $(LITEOSTHIRDPARTY)/musl/porting/liteos_a/kernel/include
|
||||
@@ -306,8 +306,8 @@ endif
|
||||
|
||||
|
||||
ifeq ($(LOSCFG_FS_JFFS), y)
|
||||
LITEOS_BASELIB += -ljffs2
|
||||
LIB_SUBDIRS += fs/jffs2
|
||||
# LITEOS_BASELIB += -ljffs2
|
||||
# LIB_SUBDIRS += fs/jffs2
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_PLATFORM_ROOTFS), y)
|
||||
|
||||
Reference in New Issue
Block a user