Android Framework Basics - System Initialization

        The previous article introduced the startup of the init process. Here we analyze in detail what the init process mainly initializes. Here we mainly analyze the source code of Android 12.

1. System initialization

        First of all, through the previous content, we understand that the content that needs to be initialized is divided into modules in main.cpp, among which SubcontextMain mainly initializes the context, SetupSelinux mainly initializes SELinux, and the first stage of FirstStageMain mainly initializes the basic Hardware initialization and file system mounting, SecondStageMain The second stage initialization is for system services, loading device configuration, parsing init.rc files, and other system startup tasks. Here we mainly analyze the specific content of SecondStageMain.

1、InitKernelLogging

        Used to initialize kernel logging.

util.cpp

Source location: /system/core/init/util.cpp

void InitKernelLogging(char** argv) {
    // 设置致命错误的重启目标
    SetFatalRebootTarget();
    // 初始化 Android 日志系统
    android::base::InitLogging(argv, &android::base::KernelLogger, InitAborter);
}

logging.cpp  

Source location: /system/libbase/logging.cpp 

void InitLogging(char* argv[], LogFunction&& logger, AbortFunction&& aborter) {
    // 设置日志记录函数
    

Guess you like

Origin blog.csdn.net/c19344881x/article/details/131943335