Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
8d419bb0
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看板
提交
8d419bb0
编写于
5月 14, 2021
作者:
O
openharmony_ci
提交者:
Gitee
5月 14, 2021
浏览文件
操作
浏览文件
下载
差异文件
!239 quickstart节点实现优化
Merge pull request !239 from boxi/master
上级
d724a975
4abd2e02
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
24 addition
and
34 deletion
+24
-34
drivers/char/quickstart/include/los_dev_quickstart.h
drivers/char/quickstart/include/los_dev_quickstart.h
+5
-7
drivers/char/quickstart/src/quickstart.c
drivers/char/quickstart/src/quickstart.c
+19
-27
未找到文件。
drivers/char/quickstart/include/los_dev_quickstart.h
浏览文件 @
8d419bb0
...
...
@@ -49,21 +49,19 @@ typedef enum {
}
QuickstartStage
;
typedef
enum
{
QS_UNREGISTER
=
QS_STAGE_LIMIT
,
/* quickstart dev unregister */
QS_NOTIFY
,
/* quickstart notify */
QS_LISTEN
,
/* quickstart listen */
QS_NOTIFY
=
QS_STAGE_LIMIT
,
/* quickstart notify */
QS_LISTEN
,
/* quickstart listen */
QS_CTL_LIMIT
}
QuickstartConctrl
;
typedef
struct
{
unsigned
int
pid
;
unsigned
int
events
;
}
QuickstartMask
;
unsigned
int
wait
;
}
QuickstartListenArgs
;
#define QUICKSTART_IOC_MAGIC 'T'
#define QUICKSTART_UNREGISTER _IO(QUICKSTART_IOC_MAGIC, QS_UNREGISTER)
#define QUICKSTART_NOTIFY _IO(QUICKSTART_IOC_MAGIC, QS_NOTIFY)
#define QUICKSTART_LISTEN _IOR(QUICKSTART_IOC_MAGIC, QS_LISTEN, Quickstart
Mask
)
#define QUICKSTART_LISTEN _IOR(QUICKSTART_IOC_MAGIC, QS_LISTEN, Quickstart
ListenArgs
)
#define QUICKSTART_STAGE(x) _IO(QUICKSTART_IOC_MAGIC, (x))
#define QUICKSTART_NODE "/dev/quickstart"
...
...
drivers/char/quickstart/src/quickstart.c
浏览文件 @
8d419bb0
...
...
@@ -33,7 +33,7 @@
#include "fcntl.h"
#include "linux/kernel.h"
#include "los_process_pri.h"
#include "fs/fs.h"
EVENT_CB_S
g_qsEvent
;
static
SysteminitHook
g_systemInitFunc
[
QS_STAGE_CNT
]
=
{
0
};
...
...
@@ -51,10 +51,7 @@ static int QuickstartClose(struct file *filep)
static
int
QuickstartNotify
(
unsigned
int
events
)
{
unsigned
int
pid
=
LOS_GetCurrProcessID
();
/* 16:low 16 bits for eventMask, high 16 bits for pid */
unsigned
int
notifyEvent
=
(
pid
<<
16
)
|
events
;
int
ret
=
LOS_EventWrite
((
PEVENT_CB_S
)
&
g_qsEvent
,
notifyEvent
);
int
ret
=
LOS_EventWrite
((
PEVENT_CB_S
)
&
g_qsEvent
,
events
);
if
(
ret
!=
0
)
{
PRINT_ERR
(
"%s,%d:0x%x
\n
"
,
__FUNCTION__
,
__LINE__
,
ret
);
ret
=
-
EINVAL
;
...
...
@@ -62,17 +59,21 @@ static int QuickstartNotify(unsigned int events)
return
ret
;
}
#define WAITLIMIT 300000
/* 5min = 5*60*1000*1tick(1ms) */
static
int
QuickstartListen
(
unsigned
long
arg
)
{
Quickstart
Mask
listenMask
;
if
(
copy_from_user
(
&
listenMask
,
(
struct
QuickstartMask
__user
*
)
arg
,
sizeof
(
QuickstartMask
))
!=
LOS_OK
)
{
PRINT_ERR
(
"%s,%d
\n
"
,
__FUNCTION__
,
__LINE__
);
Quickstart
ListenArgs
args
;
if
(
copy_from_user
(
&
args
,
(
QuickstartListenArgs
__user
*
)
arg
,
sizeof
(
QuickstartListenArgs
))
!=
LOS_OK
)
{
PRINT_ERR
(
"%s,%d
,failed!
\n
"
,
__FUNCTION__
,
__LINE__
);
return
-
EINVAL
;
}
/* 16:low 16 bits for eventMask, high 16 bits for pid */
unsigned
int
mask
=
(
listenMask
.
pid
<<
16
)
|
listenMask
.
events
;
int
ret
=
LOS_EventRead
((
PEVENT_CB_S
)
&
g_qsEvent
,
mask
,
LOS_WAITMODE_AND
|
LOS_WAITMODE_CLR
,
LOS_WAIT_FOREVER
);
if
(
ret
!=
mask
)
{
if
(
args
.
wait
>
WAITLIMIT
)
{
args
.
wait
=
WAITLIMIT
;
PRINT_ERR
(
"%s wait arg is too longer, set to WAITLIMIT!
\n
"
,
__FUNCTION__
);
}
int
ret
=
LOS_EventRead
((
PEVENT_CB_S
)
&
g_qsEvent
,
args
.
events
,
LOS_WAITMODE_AND
|
LOS_WAITMODE_CLR
,
args
.
wait
);
if
(
ret
!=
args
.
events
&&
ret
!=
0
)
{
/* 0: nowait is normal case */
PRINT_ERR
(
"%s,%d:0x%x
\n
"
,
__FUNCTION__
,
__LINE__
,
ret
);
ret
=
-
EINVAL
;
}
...
...
@@ -97,8 +98,9 @@ static int QuickstartStageWorking(unsigned int level)
return
0
;
}
static
int
QuickstartDevUn
register
(
void
)
static
int
QuickstartDevUn
link
(
struct
Vnode
*
node
)
{
(
void
)
node
;
return
unregister_driver
(
QUICKSTART_NODE
);
}
...
...
@@ -114,9 +116,6 @@ static ssize_t QuickstartIoctl(struct file *filep, int cmd, unsigned long arg)
return
-
EACCES
;
}
switch
(
cmd
)
{
case
QUICKSTART_UNREGISTER
:
ret
=
QuickstartDevUnregister
();
break
;
case
QUICKSTART_LISTEN
:
ret
=
QuickstartListen
(
arg
);
break
;
...
...
@@ -128,17 +127,10 @@ static ssize_t QuickstartIoctl(struct file *filep, int cmd, unsigned long arg)
}
static
const
struct
file_operations_vfs
g_quickstartDevOps
=
{
QuickstartOpen
,
/* open */
QuickstartClose
,
/* close */
NULL
,
/* read */
NULL
,
/* write */
NULL
,
/* seek */
QuickstartIoctl
,
/* ioctl */
NULL
,
/* mmap */
#ifndef CONFIG_DISABLE_POLL
NULL
,
/* poll */
#endif
NULL
,
/* unlink */
.
open
=
QuickstartOpen
,
/* open */
.
close
=
QuickstartClose
,
/* close */
.
ioctl
=
QuickstartIoctl
,
/* ioctl */
.
unlink
=
QuickstartDevUnlink
,
/* unlink */
};
int
QuickstartDevRegister
(
void
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录