init.c 1.9 KB
Newer Older
1
/*
2
 * Copyright (c) 2020-2021 Huawei Device Co., Ltd.
3 4 5 6 7 8 9 10 11 12 13 14 15
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
#include "init.h"
X
xionglei6 已提交
16
#include "init_group_manager.h"
Z
zhong_ning 已提交
17
#include "init_jobs_internal.h"
X
xionglei6 已提交
18
#include "init_log.h"
19
#include "init_utils.h"
20 21 22
#ifndef __LINUX__
#include "init_stage.h"
#endif
23
#include "loop_event.h"
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
#include "parameter.h"
#include "securec.h"

static void PrintSysInfo(void)
{
    const char *sysInfo = GetVersionId();
    if (sysInfo != NULL) {
        INIT_LOGE("%s", sysInfo);
        return;
    }
}

void SystemInit(void)
{
    SignalInit();
39
    MakeDirRecursive("/dev/unix/socket", S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
40 41 42 43
}

void LogInit(void)
{
S
sun_fan 已提交
44
    return;
45 46 47 48 49 50 51 52 53
}

void SystemPrepare(void)
{
    PrintSysInfo();
}

void SystemConfig(void)
{
X
xionglei6 已提交
54
    InitServiceSpace();
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
    // read config
    ReadConfig();

    // dump config
#ifdef OHOS_SERVICE_DUMP
    DumpAllServices();
#endif

    // execute init
    DoJob("pre-init");
#ifndef __LINUX__
    TriggerStage(EVENT1, EVENT1_WAITTIME, QS_STAGE1);
#endif

    DoJob("init");
#ifndef __LINUX__
    TriggerStage(EVENT2, EVENT2_WAITTIME, QS_STAGE2);
#endif

    DoJob("post-init");
#ifndef __LINUX__
    TriggerStage(EVENT3, EVENT3_WAITTIME, QS_STAGE3);
    InitStageFinished();
#endif
    ReleaseAllJobs();
}

void SystemRun(void)
{
84
    LE_RunLoop(LE_GetDefaultLoop());
Z
zhong_ning 已提交
85
}