Android init initialization program analysis

Source: Internet
Author: User

/System/CORE/init initialization program

 

1. Execute the sigaction function to process the sigchild signal. Actually temporarily blocked

2. Set umask to clear the mask of the created File

3. Create a file system mount point & Mount memory File System

4. open_devnull_stdio 0 1 2 is the FD. They are all the file descriptor of/dev/_ null __

5. Open/dev/_ kmsg _ as log FD.

6. parse_config_file

First Open/init. RC, read all the data to the memory, and then call the parse_config function for analysis. Put Comand and service into the linked list for medium processing.

7. import_kernel_cmdline obtains bootargs from/proc/cmdline, analyzes it, and fills qemu, console, bootmode, serialno, baseband, carrier, bootloader, and hardware variables with import_kernel_nv. If you have set the Android. RIL parameter, you also need to set the corresponding permissions, that is, UID and GID.

8. get_hardware_name: Get the hardware and Rev Parameters Based on/dev/cpuinfo and put them in the hardware and revision global variables.

9. parse the init. Hardware. RC config file, execute the action in early init, and use drain_action_queue

10. Execute device_init. First, open_uevent_socket and then set the socket attributes. Finally, run coldboot on/sys/class,/sys/block, And/sys/devices.

11. after "Add/N" is written to uevent files in the/sys/class directory, messages are received from the uevent socket and parsed to assign values to the uevent structure. Then, create directories and device nodes under each Dev Based on the uevent and the predefined permissions of global devperms.

12. initialize _ system_property_area _ (open the ashmem device, apply for memory, and initialize it to the prop_area structure)

13. Execute property_init, read buid. Prop, and set it to property.

14. Determine whether open_keychord is based on Ro. debuggerable set in build. Prop.

15. Open the console. If the console array is set, the console array is used. If not,/dev/console is used as the console by default. If you have a console device, the variable have_console is 1.

16. Set some properties, such as Ro. serialno, Ro. bootmode, Ro. baseband, Ro. Carrier, Ro. bootloader, Ro. Hardware, Ro. Revision

17. Execute the init group in init. RC and init. Hardware. RC.

18. from/system/build. prop, system/default. prop, data/local. in prop, read and set the property, read the persist values in data/propery, and set the property according to the file name and content.

19. Create and listen to property_service socket

20. Create a paired socket

21. Ensure that the FD of socket FD and property_service of uevent and signal_receive are all valid.

22. Run all property triggers based on current state of the Properties

23. Create and open the following log files.

# Define log_root "/data/bootchart"

# Define log_stat log_root "/proc_stat.log"

# Define log_procs log_root "/proc_ps.log"

# Define log_disk log_root "/proc_diskstats.log"

24. Call the Acct function to record the terminate message of each kernel process. Write log_root "/kernel_pacct"

25. Write/proc/cmdline,/proc/version,/proc/cpuinfo to log_root "/Header ". Bootchart records the time set by # define log_startfile "/data/bootchart-start ".

26. Enter the endless loop, perform poll operations on several FD mentioned above internally, and after poll is successful, handle_device_fd, handle_property_set_fd, or handle_keychord

 

 

 

 

The above analysis shows several precautions, such as permissions. You can also analyze log information based on several log files under data/bootchard. You can also find out the reason for untracket PID. The loading sequence of several prop files, how to enable the system to start from ramdisk and load the loop device. More options for RC files. Socket communication, how to automatically create a device node.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.