fuchsia学习_启动过程

KernelZircon的启动:首先运行boot-shim.ld的ENTRY(_start);//boot-shim.S的FUNCTION(_start);//start.S汇编代码,之后到lk_main();
~~//内调zircon/kernel/top/main.cc的lk_main();
~~//创建"bootstrap2"线程,从init.cc的lk_init_level(),参数"global_prng_thread_safe";//内调global_prng.cc的BecomeThreadSafe();
~~//线程"bootstrap2"创建成功后执行bootstrap2()函数;
~~//创建userboot(内核线程),main.cc的lk_main();//内调init.h的lk_primary_cpu_init_level(),参数LK_INIT_LEVEL_LAST;//内调init.cc的lk_init_level(),遍历找到"userboot";
~~//内调userboot.cc的userboot_init();//创建,启动;
~~//运行userboot(由内核创建;创建bootsvc进程),内调userboot/start.cc的bootstrap();//内调userboot/option.cc的parse_options();之后调用userboot/loader-service.cc的LoaderService::Serve();
~~//转到HandleRequest();//转到LoadObject();//转到TryLoadObject();//内调userboot/bootfs.cc的bootfs_open(),传入参数"bin/bootsvc";
~~//内调userboot/start.cc的bootstrap(),创建进程"bin/bootsvc",创建线程;//转到load_child_process();//内调userboot/userboot-elf.cc的elf_load_bootfs();
~~//运行bootsvc进程(由userboot进程创建;创建devmgr进程),bootsvc/main.cc的main();
~~//创建devmgr进程(由bootsvc创建),bootsvc/main.cc的main();//内调LaunchNextProcess(),传入参数"bin/component_manager";
~~//运行devmgr进程,zircon/system/core/devmgr/fshost/main.cc的main();//内调fs-manager.cc的FsManager::WatchExit();
~~//创建driver_manager进程(由bootsvc创建)//...//devmgr-launcher/launcher.cc的Launch();//新建进程,传入"/boot/bin/driver_manager";
~~//运行driver_manager进程,driver_manager/main.cc的main();//内调driver_manager/system_instance.cc的start_console_shell();创建进程;
~~//线程运行,driver_manager/system_instance.cc的console_starter();//转到SystemInstance::ConsoleStarter();
~~//内调driver_manager/fdio.cc的DevmgrLauncher::LaunchWithLoader(),传入参数"/boot/bin/svchost","/boot/bin/netsvc","/boot/bin/sh","/boot/bin/miscsvc";
~~//"service-starter"运行(由driver_manager/main.cc的main()创建),运行driver_manager/system_instance.cc的SystemInstance::service_starter();//内调SystemInstance::ServiceStarter();
~~//driver的初始化(由driver_manager进程发起),driver_manager/main.cc的main();//内调system_instance.cc的PrepareProxy();//内调coordinator.cc的Coordinator::NewDevhost();
~~//转到dc_launch_devhost(),传入参数"driver_host:sys","driver_host:root","driver_host:misc","driver_host:pci",参数由coordinator.cc的InitCoreDevices()初始化;
~~//"driver_host:sys"进程运行,driver_host/devhost.cc的CreateDevice();//内调,传入参数"/boot/driver/platform-bus.so";//转到dh_find_driver(),dlopen_vmo(),dlsym();
~~//内调devhost.h的CreateOp();//内调create(),执行驱动so库的create();
~~//驱动so库执行,platform/platform-bus.cc的platform_bus_create();//内调PlatformBus::Init();//内调PlatformBus::GetBoardInfo();
====
处理服务进程的crsah:启动时svchost/svchost.cc的main();//内调svchost/crashsvc.cc的start_crashsvc();//内调thrd_create_with_name(),传入crash_svc函数地址;
~~//当出现服务crash时,svchost/crashsvc.cc的crash_svc();//内调channel.h的wait_one(),read();
添加服务:garnet/examples/fidl/echo_server_cpp/echo_server_app.cc的构造函数;//内调sdk/lib/sys/cpp/outgoing_directory.cc的AddPublicService();
~~//内调outgoing_directory.h的AddEntry();其中,根是通过PseudoDir->Lookup("svc")获取;//内核zircon/system/ulib/fs/pseudo_dir.cc的AddEntry();//内调EntryByNameMap的insert();
获取服务:garnet/examples/fidl/echo_client_cpp/echo_client_app.cc的Start();
~~//内调component_context.h的Create(),ComponentContext的svc();//service_directory.cc的ServiceDirectory::Connect();
~~//内调zircon/system/ulib/fdio/remoteio.cc的fdio_service_connect_at();//内调local-filesystem.cc的fdio_namespace::Open();
~~//转到fdio_namespace::WalkLocked();//内核zircon/system/ulib/fs/pseudo_dir.cc中PseudoDir继承LocalVnode的Lookup();//内调EntryByNameMap的find();

你可能感兴趣的:(技术实践)