Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
b43f461a
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
接近 2 年 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b43f461a
编写于
5月 18, 2021
作者:
O
openharmony_ci
提交者:
Gitee
5月 18, 2021
浏览文件
操作
浏览文件
下载
差异文件
!29 优化startup_init_lite同步机制,在init主流程中添加job进行分阶段启动。
Merge pull request !29 from boxi/master
上级
b0c12975
509667fc
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
75 addition
and
30 deletion
+75
-30
initsync/BUILD.gn
initsync/BUILD.gn
+10
-8
initsync/include/init_stage.h
initsync/include/init_stage.h
+12
-9
initsync/src/init_sync.c
initsync/src/init_sync.c
+18
-10
interfaces/kits/init_sync.h
interfaces/kits/init_sync.h
+12
-1
services/BUILD.gn
services/BUILD.gn
+7
-1
services/src/init_read_cfg.c
services/src/init_read_cfg.c
+16
-1
未找到文件。
inits
tage
/BUILD.gn
→
inits
ync
/BUILD.gn
浏览文件 @
b43f461a
...
@@ -13,24 +13,26 @@
...
@@ -13,24 +13,26 @@
import("//build/lite/config/component/lite_component.gni")
import("//build/lite/config/component/lite_component.gni")
lite_component("inits
tage
") {
lite_component("inits
ync
") {
features = [ "//base/startup/init_lite/inits
tage:libinitstage
_shared" ]
features = [ "//base/startup/init_lite/inits
ync:libinitsync
_shared" ]
}
}
shared_library("libinits
tage
_shared") {
shared_library("libinits
ync
_shared") {
sources = [ "src/init_s
tage
.c" ]
sources = [ "src/init_s
ync
.c" ]
cflags = [ "-Wall" ]
cflags = [ "-Wall" ]
include_dirs = [
include_dirs = [
"//base/startup/init_lite/initstage/include",
"//base/startup/init_lite/initsync/include",
"//base/startup/init_lite/interfaces/kits",
]
]
public_deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
public_deps = [ "//third_party/bounds_checking_function:libsec_shared" ]
}
}
static_library("libinits
tage
_static") {
static_library("libinits
ync
_static") {
sources = [ "src/init_s
tage
.c" ]
sources = [ "src/init_s
ync
.c" ]
cflags = [ "-Wall" ]
cflags = [ "-Wall" ]
include_dirs = [
include_dirs = [
"//base/startup/init_lite/initstage/include",
"//base/startup/init_lite/initsync/include",
"//base/startup/init_lite/interfaces/kits",
]
]
public_deps = [ "//third_party/bounds_checking_function:libsec_static" ]
public_deps = [ "//third_party/bounds_checking_function:libsec_static" ]
}
}
inits
tage
/include/init_stage.h
→
inits
ync
/include/init_stage.h
浏览文件 @
b43f461a
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#ifndef BASE_STARTUP_INITLITE_STAGE_H
#ifndef BASE_STARTUP_INITLITE_STAGE_H
#define BASE_STARTUP_INITLITE_STAGE_H
#define BASE_STARTUP_INITLITE_STAGE_H
#include "init_sync.h"
#include <sys/ioctl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <unistd.h>
...
@@ -33,21 +34,19 @@ typedef enum {
...
@@ -33,21 +34,19 @@ typedef enum {
}
QuickstartStage
;
}
QuickstartStage
;
typedef
enum
{
typedef
enum
{
QS_UNREGISTER
=
QS_STAGE_LIMIT
,
/* quickstart dev unregister */
QS_NOTIFY
=
QS_STAGE_LIMIT
,
/* quickstart notify */
QS_NOTIFY
,
/* quickstart notify */
QS_LISTEN
,
/* quickstart listen */
QS_LISTEN
,
/* quickstart listen */
QS_CTL_LIMIT
QS_CTL_LIMIT
}
QuickstartConctrl
;
}
QuickstartConctrl
;
typedef
struct
{
typedef
struct
{
unsigned
int
pid
;
unsigned
int
events
;
unsigned
int
events
;
}
QuickstartMask
;
unsigned
int
wait
;
}
QuickstartListenArgs
;
#define QUICKSTART_IOC_MAGIC 'T'
#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_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_STAGE(x) _IO(QUICKSTART_IOC_MAGIC, (x))
#define QUICKSTART_NODE "/dev/quickstart"
#define QUICKSTART_NODE "/dev/quickstart"
...
@@ -67,9 +66,8 @@ typedef struct {
...
@@ -67,9 +66,8 @@ typedef struct {
* Listen the events of a specific pid process by Init process.
* Listen the events of a specific pid process by Init process.
* Only be called by Init process.
* Only be called by Init process.
* eventMask: There needs to be a consensus between the listener and the notifier.
* eventMask: There needs to be a consensus between the listener and the notifier.
*/
*/
extern
int
InitListen
(
pid_t
pid
,
unsigned
short
eventMask
);
extern
int
InitListen
(
unsigned
long
eventMask
,
unsigned
int
wait
);
/*
/*
* Trigger the SystemInit stage.
* Trigger the SystemInit stage.
...
@@ -83,6 +81,11 @@ extern int SystemInitStage(QuickstartStage stage);
...
@@ -83,6 +81,11 @@ extern int SystemInitStage(QuickstartStage stage);
*/
*/
extern
int
InitStageFinished
(
void
);
extern
int
InitStageFinished
(
void
);
/*
* Listen event and trigger the SystemInit stage.
* Only be called by Init process.
*/
extern
void
TriggerStage
(
unsigned
int
event
,
unsigned
int
wait
,
QuickstartStage
stagelevel
);
#ifdef __cplusplus
#ifdef __cplusplus
#if __cplusplus
#if __cplusplus
}
}
...
...
inits
tage/src/init_stage
.c
→
inits
ync/src/init_sync
.c
浏览文件 @
b43f461a
...
@@ -30,24 +30,24 @@ static int SendCmd(int cmd, unsigned long arg)
...
@@ -30,24 +30,24 @@ static int SendCmd(int cmd, unsigned long arg)
if
(
fd
!=
-
1
)
{
if
(
fd
!=
-
1
)
{
int
ret
=
ioctl
(
fd
,
cmd
,
arg
);
int
ret
=
ioctl
(
fd
,
cmd
,
arg
);
if
(
ret
==
-
1
)
{
if
(
ret
==
-
1
)
{
printf
(
"[
%s][%d]Err:
%s!
\n
"
,
__FUNCTION__
,
__LINE__
,
strerror
(
errno
));
printf
(
"[
ERR][%s,%d]
%s!
\n
"
,
__FUNCTION__
,
__LINE__
,
strerror
(
errno
));
}
}
close
(
fd
);
close
(
fd
);
return
ret
;
return
ret
;
}
}
printf
(
"[
%s][%d]Err:
%s!
\n
"
,
__FUNCTION__
,
__LINE__
,
strerror
(
errno
));
printf
(
"[
ERR][%s,%d]
%s!
\n
"
,
__FUNCTION__
,
__LINE__
,
strerror
(
errno
));
return
fd
;
return
fd
;
}
}
int
InitListen
(
pid_t
pid
,
unsigned
short
eventMask
)
int
InitListen
(
unsigned
long
eventMask
,
unsigned
int
wait
)
{
{
Quickstart
Mask
listenMask
;
Quickstart
ListenArgs
args
;
listenMask
.
pid
=
pid
;
args
.
wait
=
wait
;
listenMask
.
events
=
eventMask
;
args
.
events
=
eventMask
;
return
SendCmd
(
QUICKSTART_LISTEN
,
(
unsigned
long
)
&
listenMask
);
return
SendCmd
(
QUICKSTART_LISTEN
,
(
unsigned
long
)
&
args
);
}
}
int
NotifyInit
(
unsigned
short
event
)
int
NotifyInit
(
unsigned
long
event
)
{
{
return
SendCmd
(
QUICKSTART_NOTIFY
,
event
);
return
SendCmd
(
QUICKSTART_NOTIFY
,
event
);
}
}
...
@@ -55,13 +55,21 @@ int NotifyInit(unsigned short event)
...
@@ -55,13 +55,21 @@ int NotifyInit(unsigned short event)
int
SystemInitStage
(
QuickstartStage
stage
)
int
SystemInitStage
(
QuickstartStage
stage
)
{
{
if
(
stage
>=
QS_STAGE_LIMIT
||
stage
<
QS_STAGE1
)
{
if
(
stage
>=
QS_STAGE_LIMIT
||
stage
<
QS_STAGE1
)
{
printf
(
"[
%s][%d]Err: the stage(%d) is Not expected!
!
\n
"
,
__FUNCTION__
,
__LINE__
,
stage
);
printf
(
"[
ERR][%s,%d] the stage(%d) is not expected
!
\n
"
,
__FUNCTION__
,
__LINE__
,
stage
);
return
-
1
;
return
-
1
;
}
}
return
SendCmd
(
QUICKSTART_STAGE
(
stage
),
0
);
return
SendCmd
(
QUICKSTART_STAGE
(
stage
),
0
);
}
}
void
TriggerStage
(
unsigned
int
event
,
unsigned
int
wait
,
QuickstartStage
stagelevel
)
{
int
ret
=
InitListen
(
event
,
wait
);
if
(
ret
!=
0
)
{
SystemInitStage
(
stagelevel
);
}
}
int
InitStageFinished
(
void
)
int
InitStageFinished
(
void
)
{
{
return
SendCmd
(
QUICKSTART_UNREGISTER
,
0
);
return
unlink
(
QUICKSTART_NODE
);
}
}
in
itstage/include/init_notify
.h
→
in
terfaces/kits/init_sync
.h
浏览文件 @
b43f461a
...
@@ -22,12 +22,23 @@ extern "C" {
...
@@ -22,12 +22,23 @@ extern "C" {
#endif
#endif
#endif
#endif
#define EVENT1 0xf
#define EVENT1_WAITTIME 10000 // 10s = 10*1000 * 1 tick(1ms)
#define EVENT2 0xf0
/* Define EVENT2_WAITTIME 0 means QS_STAGE2 is no used */
#define EVENT2_WAITTIME 0
#define EVENT3 0xf00
/* Define EVENT3_WAITTIME 0 means QS_STAGE3 is no used */
#define EVENT3_WAITTIME 0
/*
/*
* Notify the event to Init process.
* Notify the event to Init process.
* All processes can call. Usually called by the listened process.
* All processes can call. Usually called by the listened process.
* event: There needs to be a consensus between the listener(init process) and the notifier.
* event: There needs to be a consensus between the listener(init process) and the notifier.
*/
*/
extern
int
NotifyInit
(
unsigned
short
event
);
extern
int
NotifyInit
(
unsigned
long
event
);
#ifdef __cplusplus
#ifdef __cplusplus
#if __cplusplus
#if __cplusplus
...
...
services/BUILD.gn
浏览文件 @
b43f461a
...
@@ -40,12 +40,18 @@ if (defined(ohos_lite)) {
...
@@ -40,12 +40,18 @@ if (defined(ohos_lite)) {
deps = [
deps = [
"//base/startup/syspara_lite/frameworks/parameter:parameter",
"//base/startup/syspara_lite/frameworks/parameter:parameter",
"//base/startup/init_lite/initsync:initsync",
"//build/lite/config/component/cJSON:cjson_shared",
"//build/lite/config/component/cJSON:cjson_shared",
"//third_party/bounds_checking_function:libsec_shared",
"//third_party/bounds_checking_function:libsec_shared",
]
]
ldflags = []
ldflags = []
if (ohos_kernel_type == "liteos_a") {
if (ohos_kernel_type == "liteos_a") {
include_dirs += [ "//kernel/liteos_a/syscall" ]
include_dirs += [
"//kernel/liteos_a/syscall",
"//base/startup/init_lite/interfaces/kits",
"//base/startup/init_lite/initsync/include",
]
deps += [ "//base/startup/init_lite/initsync:initsync" ]
}
}
if (ohos_kernel_type == "linux") {
if (ohos_kernel_type == "linux") {
defines += [ "NEED_EXEC_RCS_LINUX" ]
defines += [ "NEED_EXEC_RCS_LINUX" ]
...
...
services/src/init_read_cfg.c
浏览文件 @
b43f461a
...
@@ -27,7 +27,9 @@
...
@@ -27,7 +27,9 @@
#include "init_perms.h"
#include "init_perms.h"
#include "init_service_manager.h"
#include "init_service_manager.h"
#include "securec.h"
#include "securec.h"
#ifndef __LINUX__
#include "init_stage.h"
#endif
static
const
long
MAX_JSON_FILE_LEN
=
102400
;
// max init.cfg size 100KB
static
const
long
MAX_JSON_FILE_LEN
=
102400
;
// max init.cfg size 100KB
static
const
int
MAX_PATH_ARGS_CNT
=
20
;
// max path and args count
static
const
int
MAX_PATH_ARGS_CNT
=
20
;
// max path and args count
...
@@ -350,8 +352,21 @@ void InitReadCfg()
...
@@ -350,8 +352,21 @@ void InitReadCfg()
// do jobs
// do jobs
DoJob
(
"pre-init"
);
DoJob
(
"pre-init"
);
#ifndef __LINUX__
TriggerStage
(
EVENT1
,
EVENT1_WAITTIME
,
QS_STAGE1
);
#endif
DoJob
(
"init"
);
DoJob
(
"init"
);
#ifndef __LINUX__
TriggerStage
(
EVENT2
,
EVENT2_WAITTIME
,
QS_STAGE2
);
#endif
DoJob
(
"post-init"
);
DoJob
(
"post-init"
);
#ifndef __LINUX__
TriggerStage
(
EVENT3
,
EVENT3_WAITTIME
,
QS_STAGE3
);
InitStageFinished
();
#endif
ReleaseAllJobs
();
ReleaseAllJobs
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录