• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #include "init.h"
16 #include "init_group_manager.h"
17 #include "init_jobs_internal.h"
18 #include "init_log.h"
19 #include "init_utils.h"
20 #ifndef __LINUX__
21 #include "init_stage.h"
22 #endif
23 #include "loop_event.h"
24 #include "parameter.h"
25 
PrintSysInfo(void)26 static void PrintSysInfo(void)
27 {
28     const char *sysInfo = GetVersionId();
29     if (sysInfo != NULL) {
30         INIT_LOGE("%s", sysInfo);
31         return;
32     }
33 }
34 
SystemInit(void)35 void SystemInit(void)
36 {
37     SignalInit();
38     MakeDirRecursive("/dev/unix/socket", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
39 }
40 
LogInit(void)41 void LogInit(void)
42 {
43     return;
44 }
45 
SystemPrepare(void)46 void SystemPrepare(void)
47 {
48     PrintSysInfo();
49 }
50 
SystemConfig(void)51 void SystemConfig(void)
52 {
53     InitServiceSpace();
54     // read config
55     ReadConfig();
56 
57     // dump config
58 #ifdef OHOS_SERVICE_DUMP
59     DumpAllServices();
60 #endif
61 
62     // execute init
63     DoJob("pre-init");
64 #ifndef __LINUX__
65     TriggerStage(EVENT1, EVENT1_WAITTIME, QS_STAGE1);
66 #endif
67 
68     DoJob("init");
69 #ifndef __LINUX__
70     TriggerStage(EVENT2, EVENT2_WAITTIME, QS_STAGE2);
71 #endif
72 
73     DoJob("post-init");
74 #ifndef __LINUX__
75     TriggerStage(EVENT3, EVENT3_WAITTIME, QS_STAGE3);
76     InitStageFinished();
77 #endif
78     ReleaseAllJobs();
79 }
80 
SystemRun(void)81 void SystemRun(void)
82 {
83 #ifndef __LITEOS__
84     LE_RunLoop(LE_GetDefaultLoop());
85 #else
86     while (1) {
87         // pause only returns when a signal was caught and the signal-catching function returned.
88         // pause only returns -1, no need to process the return value.
89         (void)pause();
90     }
91 #endif
92 }
93