android Init 相關分析,androidinit

來源:互聯網
上載者:User

android Init 相關分析,androidinit

Init.c主要工作

1. 初始化屬性(包括建立/dev、/proc等目錄、初始化屬性、log、執行init.rc等初始設定檔案中的action等)。

2. 解析設定檔的命令(主要是init.rc檔案),包括處理各種Action。

3. 初始化屬性伺服器

4. 無限迴圈執行command(啟動其他的進程)。

 

需知ramdisk.img中存放init.c檔案

一下分析一些重要函數。

property_init();

  1.import /init.${ro.hardware}.rc匯入其他設定檔。

  2.載入default.prop檔案

  3.把屬性記憶體地區建立在共用記憶體上,(init_workspace()),映射到本地進程空間。

  4.當屬性伺服器收到用戶端請求uevent=POLLIN時

       執行handle_property_set_fd()

       (setprop ctl.start bootanim命令就執行開機動畫。

  5.用戶端發送請求(properties.c)->property_set()中

 

get_hardware_name(hardware, &revision);

  開啟/proc/cpuinfo檔案中擷取Hardware欄位的值(小寫)

  不難看出擷取到的hardware欄位值是用在import /init.${ro.hardware}.rc中。

 

process_kernel_cmdline();

  import CMD命令,通過核心的屬性設定應用程式層設定檔的屬性。

 

Init.rc

1.檔案內容:

    On init: section init

    On boot: section boot

           …

 

   * Class_start defult 這是一個COMMAND,對應函數do_class_start

    service  也是一個section

 

2.解析section的函數:

parse_new_section(state,kw,nargs,args);

   case:K_service: //service section

  parse_service(state, nargs,args);

    service->classname=”default”;

        …

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.