同步官方源码 标准库(musl , newlib) 目录调整

    百图画鸿蒙 + 百文说内核 + 百万注源码  => 挖透鸿蒙内核源码
    鸿蒙研究站 | http://weharmonyos.com (国内)
              | https://weharmony.github.io (国外)
    oschina | https://my.oschina.net/weharmony
    博客园 | https://www.cnblogs.com/weharmony/
    知乎 | https://www.zhihu.com/people/weharmonyos
    csdn | https://blog.csdn.net/kuangyufei
    51cto | https://harmonyos.51cto.com/column/34
    掘金 | https://juejin.cn/user/756888642000808
    公众号 | 鸿蒙研究站 (weharmonyos)
上级 aa42ba36
......@@ -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" ]
}
......
......@@ -198,6 +198,7 @@
### 四大码仓发布 | 源码同步官方
内核注解同时在 [gitee](https://gitee.com/weharmony/kernel_liteos_a_note) | [github](https://github.com/kuangyufei/kernel_liteos_a_note) | [coding](https://weharmony.coding.net/public/harmony/kernel_liteos_a_note/git/files) | [gitcode](https://gitcode.net/kuangyufei/kernel_liteos_a_note) 发布,并与官方源码按月保持同步,同步历史如下:
* `2022/05/09` -- 标准库(musl , newlib) 目录调整
* `2022/04/16` -- 任务调度模块有很大更新
* `2022/03/23` -- 新增各CPU核自主管理中断, 定时器模块较大调整
* `2022/02/18` -- 官方无代码更新, 只有测试用例的完善
......
......@@ -137,6 +137,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
......@@ -612,13 +613,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)));
......@@ -742,6 +752,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) {//当前CPU在用户态执行发生异常
taskCB = OsCurrTaskGet();
stackStart = taskCB->userMapBase; //用户态栈基地址,即用户态栈顶
......@@ -752,6 +763,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",
......
......@@ -397,7 +397,6 @@ int gettimeofday64(struct timeval64 *tv, struct timezone *tz)
return OsGetTimeOfDay(tv, tz);
}
#endif
/*!
* @brief gettimeofday
@verbatim
......@@ -416,9 +415,17 @@ int gettimeofday64(struct timeval64 *tv, struct timezone *tz)
*
* @see
*/
#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);
......@@ -747,6 +754,7 @@ typedef struct {
static VOID SwtmrProc(UINTPTR tmrArg)
{
#ifdef LOSCFG_KERNEL_VM
INT32 sig, ret;
UINT32 intSave;
pid_t pid;
......@@ -790,9 +798,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;
......@@ -852,6 +898,7 @@ int timer_delete(timer_t timerID)
{
UINT16 swtmrID = (UINT16)(UINTPTR)timerID;
VOID *arg = NULL;
UINTPTR swtmrProc;
#ifdef LOSCFG_SECURITY_VID
swtmrID = GetRidByVid(swtmrID);
......@@ -861,10 +908,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);
}
......@@ -1008,7 +1056,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
......
......@@ -33,7 +33,6 @@ group("fs") {
deps = [
"fat",
"fat/virpart",
"jffs2",
"nfs",
"patchfs",
"proc",
......
......@@ -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"
\ No newline at end of file
......@@ -28,7 +28,6 @@
# 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")
......
......@@ -32,11 +32,11 @@ include $(LITEOSTOPDIR)/config.mk
MODULE_NAME := $(notdir $(shell pwd))
LOCAL_SRCS := $(wildcard src/*.c) \
$(wildcard $(LITEOSTHIRDPARTY)/Linux_Kernel/fs/jffs2/*.c)
$(wildcard $(LITEOSTOPDIR)/../linux/linux-5.10/fs/jffs2/*.c)
LOCAL_INCLUDE := \
-I $(LITEOSTOPDIR)/fs/jffs2/include \
-I $(LITEOSTHIRDPARTY)/Linux_Kernel/fs/jffs2 \
-I $(LITEOSTHIRDPARTY)/Linux_Kernel/fs
-I $(LITEOSTOPDIR)/../linux/linux-5.10/fs/jffs2 \
-I $(LITEOSTOPDIR)/../linux/linux-5.10/fs
LOCAL_FLAGS := $(LOCAL_INCLUDE)
include $(MODULE)
......
......@@ -1054,7 +1054,6 @@ LITE_OS_SEC_TEXT INT32 LOS_SetProcessPriority(INT32 pid, UINT16 prio)
/// 接口封装 - 获取进程优先级 which:标识进程,进程组,用户
LITE_OS_SEC_TEXT INT32 OsGetProcessPriority(INT32 which, INT32 pid)
{
INT32 prio;
UINT32 intSave;
SchedParam param = { 0 };
(VOID)which;
......@@ -1070,14 +1069,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, &param);
OUT:
SCHEDULER_UNLOCK(intSave);
return param.basePrio;
}
......
......@@ -314,6 +314,9 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsIdleTaskCreate(VOID)
taskInitParam.usCpuAffiMask = CPUID_TO_AFFI_MASK(ArchCurrCpuid());//每个idle任务只在单独的cpu上运行
#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; //标记为系统任务,idle任务是给CPU休息用的,当然是个系统任务
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"
......@@ -219,7 +221,7 @@ typedef struct {
UINT32 timeSlice;
} SchedParam;
typedef struct {
typedef struct {//记录任务调度信息
UINT16 policy; /* This field must be present for all scheduling policies and must be the first in the structure
| 所有调度策略都必须存在此字段,并且必须是结构中的第一个字段*/
UINT16 basePrio; ///< 起始优先级
......@@ -261,7 +263,7 @@ typedef struct {//调度接口函数
*
* Highest task priority.
*/
#define OS_TASK_PRIORITY_HIGHEST 0
#define OS_TASK_PRIORITY_HIGHEST 0 /// 任务最高优先级
/**
* @ingroup los_sched
......@@ -269,7 +271,7 @@ typedef struct {//调度接口函数
*
* Lowest task priority.
*/
#define OS_TASK_PRIORITY_LOWEST 31
#define OS_TASK_PRIORITY_LOWEST 31 /// 任务最低优先级
/**
* @ingroup los_sched
......@@ -277,7 +279,7 @@ typedef struct {//调度接口函数
*
* The task is init.
*/
#define OS_TASK_STATUS_INIT 0x0001U
#define OS_TASK_STATUS_INIT 0x0001U /// 任务初始状态
/**
* @ingroup los_sched
......@@ -558,9 +560,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;
......@@ -596,6 +600,7 @@ STATIC INLINE VOID SchedTaskUnfreeze(LosTaskCB *taskCB)
taskCB->taskStatus &= ~OS_TASK_STATUS_BLOCKED;
return;
}
/*
* Schedule flag, one bit represents one core.
* This flag is used to prevent kernel scheduling before OSStartToRun.
......
此差异已折叠。
......@@ -199,6 +199,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;
......@@ -211,6 +212,7 @@ __attribute__ ((noinline)) VOID dprintf(const CHAR *fmt, ...)
#endif
va_end(ap);
}
#endif
///LK 注者的理解是 log kernel(内核日志)
VOID LkDprintf(const CHAR *fmt, va_list ap)
{
......@@ -280,7 +282,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));
}
......
......@@ -180,7 +180,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;
}
......@@ -239,7 +239,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;
}
......@@ -275,7 +275,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;
......@@ -320,7 +320,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;
}
......@@ -329,7 +329,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;
}
......@@ -340,7 +340,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__);
}
//初始化waitqueue头,请确保输入参数wait有效,否则系统将崩溃。
init_waitqueue_head(&g_hiLogDev.wq);//见于..\third_party\FreeBSD\sys\compat\linuxkpi\common\src\linux_semaphore.c
......
......@@ -96,6 +96,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)
/// 注意 ipc节点和消息是两个概念, 一个消息会包含多个节点
typedef struct {//已使用节点链表
LOS_DL_LIST list; ///< 通过它挂到对应 ProcIpcInfo.ipUsedNodeList 上
......@@ -840,22 +844,45 @@ LITE_OS_SEC_TEXT STATIC UINT32 HandlePtr(UINT32 processID, SpecialObj *obj, BOOL
return LOS_OK;
}
/// 按服务的方式处理,此处推断 Svc 应该是 service 的简写 @note_thinking
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) {//获取参数消息服务ID所属任务
if (taskID == OS_PCB_FROM_PID(OS_TCB_FROM_TID(taskID)->processID)->ipcInfo->ipcTaskID) {//如果任务ID一样,即任务ID为ServiceManager
AddServiceAccess(dstTid, obj->content.svc.handle);
}
AddServiceAccess(dstTid, obj->content.svc.handle);
}
}
return LOS_OK;
......@@ -873,7 +900,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;
......@@ -1371,6 +1398,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;
}
///真正的 IPC 控制操作
LITE_OS_SEC_TEXT int LiteIpcIoctl(struct file *filep, int cmd, unsigned long arg)
{
......@@ -1394,6 +1437,8 @@ LITE_OS_SEC_TEXT int LiteIpcIoctl(struct file *filep, int cmd, unsigned long arg
return (INT32)SetCms(arg); //设置ServiceManager , 整个系统只能有一个ServiceManager
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) {//如果还没有指定 ServiceManager
PRINT_ERR("Liteipc ServiceManager not set!\n");
......
......@@ -140,12 +140,16 @@ 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) ///< 设置ServiceManager的命令
#define IPC_CMS_CMD _IOWR(IPC_IOC_MAGIC, 2, CmsCmdContent)///< 控制命令,创建/删除 服务 添加服务权限
#define IPC_SET_IPC_THREAD _IO(IPC_IOC_MAGIC, 3) ///< 为进程设置IPC任务
#define IPC_SEND_RECV_MSG _IOWR(IPC_IOC_MAGIC, 4, IpcContent) ///< 对IPC的读写处理
#define IPC_GET_VERSION _IOR(IPC_IOC_MAGIC, 5, IpcVersion)
typedef enum {//CMS 命令类型
CMS_GEN_HANDLE, ///< 创建/注册服务
......
......@@ -88,9 +88,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)
......
......@@ -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
......
# 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",
]
}
# 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",
]
}
# 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)
......
git add -A
git commit -m ' 新调度算法(HPF)上线,需重新注解任务调度模块
git commit -m ' 同步官方源码 标准库(musl , newlib) 目录调整
百图画鸿蒙 + 百文说内核 + 百万注源码 => 挖透鸿蒙内核源码
鸿蒙研究站 | http://weharmonyos.com (国内)
| https://weharmony.github.io (国外)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册