Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
a6e17fea
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
1 年多 前同步成功
通知
460
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
a6e17fea
编写于
4月 27, 2022
作者:
O
openharmony_ci
提交者:
Gitee
4月 27, 2022
浏览文件
操作
浏览文件
下载
差异文件
!875 LiteIpc驱动增强:增加版本控制命令、增加handle特殊处理机制。
Merge pull request !875 from 万晓庆/master
上级
18f7ab13
11b35fe7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
58 addition
and
7 deletion
+58
-7
kernel/extended/liteipc/hm_liteipc.c
kernel/extended/liteipc/hm_liteipc.c
+52
-6
kernel/extended/liteipc/hm_liteipc.h
kernel/extended/liteipc/hm_liteipc.h
+6
-1
未找到文件。
kernel/extended/liteipc/hm_liteipc.c
浏览文件 @
a6e17fea
...
@@ -63,6 +63,10 @@
...
@@ -63,6 +63,10 @@
#define LITEIPC_TIMEOUT_MS 5000UL
#define LITEIPC_TIMEOUT_MS 5000UL
#define LITEIPC_TIMEOUT_NS 5000000000ULL
#define LITEIPC_TIMEOUT_NS 5000000000ULL
#define MAJOR_VERSION (2)
#define MINOR_VERSION (0)
#define DRIVER_VERSION (MAJOR_VERSION | MINOR_VERSION << 16)
typedef
struct
{
typedef
struct
{
LOS_DL_LIST
list
;
LOS_DL_LIST
list
;
VOID
*
ptr
;
VOID
*
ptr
;
...
@@ -479,6 +483,7 @@ LITE_OS_SEC_TEXT STATIC UINT32 AddServiceAccess(UINT32 taskID, UINT32 serviceHan
...
@@ -479,6 +483,7 @@ LITE_OS_SEC_TEXT STATIC UINT32 AddServiceAccess(UINT32 taskID, UINT32 serviceHan
PRINT_ERR
(
"Liteipc AddServiceAccess GetTid failed
\n
"
);
PRINT_ERR
(
"Liteipc AddServiceAccess GetTid failed
\n
"
);
return
ret
;
return
ret
;
}
}
LosTaskCB
*
tcb
=
OS_TCB_FROM_TID
(
serviceTid
);
LosTaskCB
*
tcb
=
OS_TCB_FROM_TID
(
serviceTid
);
UINT32
processID
=
OS_TCB_FROM_TID
(
taskID
)
->
processID
;
UINT32
processID
=
OS_TCB_FROM_TID
(
taskID
)
->
processID
;
LosProcessCB
*
pcb
=
OS_PCB_FROM_PID
(
processID
);
LosProcessCB
*
pcb
=
OS_PCB_FROM_PID
(
processID
);
...
@@ -758,22 +763,45 @@ LITE_OS_SEC_TEXT STATIC UINT32 HandlePtr(UINT32 processID, SpecialObj *obj, BOOL
...
@@ -758,22 +763,45 @@ LITE_OS_SEC_TEXT STATIC UINT32 HandlePtr(UINT32 processID, SpecialObj *obj, BOOL
return
LOS_OK
;
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
;
UINT32
taskID
=
0
;
if
(
isRollback
==
FALSE
)
{
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
)
{
if
(
IsTaskAlive
(
obj
->
content
.
svc
.
handle
)
==
FALSE
)
{
PRINT_ERR
(
"Liteipc HandleSvc wrong svctid
\n
"
);
PRINT_ERR
(
"Liteipc HandleSvc wrong svctid
\n
"
);
return
-
EINVAL
;
return
-
EINVAL
;
}
}
if
(
HasServiceAccess
(
obj
->
content
.
svc
.
handle
)
==
FALSE
)
{
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
;
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
(
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
;
return
LOS_OK
;
...
@@ -791,7 +819,7 @@ LITE_OS_SEC_TEXT STATIC UINT32 HandleObj(UINT32 dstTid, SpecialObj *obj, BOOL is
...
@@ -791,7 +819,7 @@ LITE_OS_SEC_TEXT STATIC UINT32 HandleObj(UINT32 dstTid, SpecialObj *obj, BOOL is
ret
=
HandlePtr
(
processID
,
obj
,
isRollback
);
ret
=
HandlePtr
(
processID
,
obj
,
isRollback
);
break
;
break
;
case
OBJ_SVC
:
case
OBJ_SVC
:
ret
=
HandleSvc
(
dstTid
,
(
const
SpecialObj
*
)
obj
,
isRollback
);
ret
=
HandleSvc
(
dstTid
,
(
SpecialObj
*
)
obj
,
isRollback
);
break
;
break
;
default:
default:
ret
=
-
EINVAL
;
ret
=
-
EINVAL
;
...
@@ -1288,6 +1316,22 @@ LITE_OS_SEC_TEXT STATIC UINT32 HandleCmsCmd(CmsCmdContent *content)
...
@@ -1288,6 +1316,22 @@ LITE_OS_SEC_TEXT STATIC UINT32 HandleCmsCmd(CmsCmdContent *content)
return
ret
;
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
)
LITE_OS_SEC_TEXT
int
LiteIpcIoctl
(
struct
file
*
filep
,
int
cmd
,
unsigned
long
arg
)
{
{
UINT32
ret
=
LOS_OK
;
UINT32
ret
=
LOS_OK
;
...
@@ -1309,6 +1353,8 @@ LITE_OS_SEC_TEXT int LiteIpcIoctl(struct file *filep, int cmd, unsigned long arg
...
@@ -1309,6 +1353,8 @@ LITE_OS_SEC_TEXT int LiteIpcIoctl(struct file *filep, int cmd, unsigned long arg
return
(
INT32
)
SetCms
(
arg
);
return
(
INT32
)
SetCms
(
arg
);
case
IPC_CMS_CMD
:
case
IPC_CMS_CMD
:
return
(
INT32
)
HandleCmsCmd
((
CmsCmdContent
*
)(
UINTPTR
)
arg
);
return
(
INT32
)
HandleCmsCmd
((
CmsCmdContent
*
)(
UINTPTR
)
arg
);
case
IPC_GET_VERSION
:
return
(
INT32
)
HandleGetVersion
((
IpcVersion
*
)(
UINTPTR
)
arg
);
case
IPC_SET_IPC_THREAD
:
case
IPC_SET_IPC_THREAD
:
if
(
IsCmsSet
()
==
FALSE
)
{
if
(
IsCmsSet
()
==
FALSE
)
{
PRINT_ERR
(
"Liteipc ServiceManager not set!
\n
"
);
PRINT_ERR
(
"Liteipc ServiceManager not set!
\n
"
);
...
...
kernel/extended/liteipc/hm_liteipc.h
浏览文件 @
a6e17fea
/*
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-202
1
Huawei Device Co., Ltd. All rights reserved.
* Copyright (c) 2020-202
2
Huawei Device Co., Ltd. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification,
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* are permitted provided that the following conditions are met:
...
@@ -114,12 +114,17 @@ typedef enum {
...
@@ -114,12 +114,17 @@ typedef enum {
MT_NUM
MT_NUM
}
MsgType
;
}
MsgType
;
typedef
struct
{
int32_t
driverVersion
;
}
IpcVersion
;
/* lite ipc ioctl */
/* lite ipc ioctl */
#define IPC_IOC_MAGIC 'i'
#define IPC_IOC_MAGIC 'i'
#define IPC_SET_CMS _IO(IPC_IOC_MAGIC, 1)
#define IPC_SET_CMS _IO(IPC_IOC_MAGIC, 1)
#define IPC_CMS_CMD _IOWR(IPC_IOC_MAGIC, 2, CmsCmdContent)
#define IPC_CMS_CMD _IOWR(IPC_IOC_MAGIC, 2, CmsCmdContent)
#define IPC_SET_IPC_THREAD _IO(IPC_IOC_MAGIC, 3)
#define IPC_SET_IPC_THREAD _IO(IPC_IOC_MAGIC, 3)
#define IPC_SEND_RECV_MSG _IOWR(IPC_IOC_MAGIC, 4, IpcContent)
#define IPC_SEND_RECV_MSG _IOWR(IPC_IOC_MAGIC, 4, IpcContent)
#define IPC_GET_VERSION _IOR(IPC_IOC_MAGIC, 5, IpcVersion)
typedef
enum
{
typedef
enum
{
CMS_GEN_HANDLE
,
CMS_GEN_HANDLE
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录