android boot process from power on
声明:
原文地址: http://www.androidenea.com/2009/06/android-boot-process-from-power-on.html ,本文章是在基于该文章的翻译,翻译的不好,请笑纳 -):
1. Power on and boot ROM code execution
开机并执行 boot ROM 代码
At power on the CPU will be in a state where no initializations have been done. Internal clocks are not set up and the only memory available is the internal RAM.
When power supplies are stable the execution will start with the Boot ROM code. This is a small piece of code that is hardwired in the CPU ASIC.
才开机时,CPU 处于未初始化状态,还没有设定内部时钟,仅仅只有内部 RAM 可用。当电源稳定后会开始执行 BOOT ROM 代码,这是一小块代码被硬编码在 CPU ASIC 中。
-
A. The Boot ROM code will detect the boot media using a system register that maps to some physical balls on the asic.
This is to determine where to find the first stage of the boot loader.
Boot ROM 代码会引导 boot 媒介使用系统寄存器映射到 ASIC 中一些物理区域,这是为了确定哪里能找到 boot loader 的第一阶段 -
B. Once the boot media sequence is established the boot ROM will try to load the first stage boot loader to internal RAM.
Once the boot loader is in place the boot ROM code will perform a jump and execution continues in the boot loader.
一旦 boot 媒介顺序确定,boot ROM 会试着装载 boot loader 的第一阶段到内部 RAM 中,一旦 boot loader 就位,boot ROM 代码会跳到并执行 boot loader
2. The boot loader
The boot loader is a special program separate from the Linux kernel that is used to set up initial memories and load the kernel to RAM.
On desktop systems the boot loaders are programs like GRUB and in embedded Linux uBoot is often the boot loader of choice.
Device manufacturers often use their own proprietary boot loaders.
boot loader 是一个特殊的独立于 Linux 内核的程序,它用来初始化内存和装载内核到 RAM 中,桌面系统的 boot loader 程序有 GRUB,嵌入式系统常用 uBoot,
设备制造商常常使用自己专有的 boot loader 程序。
-
A. The first boot loader stage will detect and set up external RAM.
boot loader 第一阶段会检测和设置外部 RAM -
B. Once external RAM is available and the system is ready the to run something more significant the first stage will load the main boot loader and place it in external RAM.
一旦外部 RAM 可用,系统会准备装载主 boot loader,把它放到外部 RAM 中 -
C. The second stage of the boot loader is the first major program that will run. This may contain code to set up file systems, additional memory,
network support and other things.On a mobile phone it may also be responsible for loading code for the modem CPU and setting up low level memory
protections and security options.boot loader 第二阶段是运行的第一个重要程序,它包含了设置文件系统,内存,网络支持和其他的代码。在一个移动电话上,
也可能是负责加载调制解调器的CPU代码和设定低级别的内存保护和安全选项 -
D. Once the boot loader is done with any special tasks it will look for a Linux kernel to boot. It will load this from the boot media
(or some other source depending on system configuration) and place it in the RAM.
It will also place some boot parameters in memory for the kernel to read when it starts up.
一旦 boot loader 完成这些特殊任务,开始寻找 linux 内核,它会从 boot 媒介上装载 linux 内核(或者其他地方,这取决于系统配置),把它放到 RAM 中,
它也会在内存中为内核替换一些在内核启动时读取的启动参数 -
E. Once the boot loader is done it will perform a jump to the Linux kernel, usually some decompression routine, and the kernel assumes system responsibility.
一旦 boot loader 完成会跳到 linux 内核,通常通过解压程序解压内核文件,内核将取得系统权限
3. The Linux kernel
linux 内核
The Linux kernel starts up in a similar way on Android as on other systems. It will set up everything that is needed for the system to run. Initialize interrupt controllers,
set up memory protections, caches and scheduling.
linux 内核在 android 上跟在其他系统上的启动方式一样,它将设置系统运行需要的一切,初始化中断控制器,设定内存保护,高速缓存和调度
-
A. Once the memory management units and caches have been initialized the system will be able to use virtual memory and launch user space processes.
一旦内存管理单元和高速缓存初始化完成,系统将可以使用虚拟内存和启动用户空间进程 -
B. The kernel will look in the root file system for the init process (found under system/core/init in the Android open source tree) and launch it as the initial user space process.
内核在根目录寻找初始化程序(代码对应 android source tree: /system/core/init ),启动它作为初始化用户空间进程
4. The init process
初始化进程
The init process is the "grandmother" of all system processes. Every other process in the system will be launched from this process or one of its descendants.
初始化进程是所有其他系统进程的 “祖母 ”,系统的每一个其他进程将从该进程中或者该进程的子进程中启动
-
A. The init process in Android will look for a file called init.rc. This is a script that describes the system services, file system and other parameters that need to be set up.
The init.rc script is placed in system/core/rootdir in the Android open source project.
初始化进程会寻找 init.rc 文件,init.rc 脚本文件描述了系统服务,文件系统和其他需要设定的参数,该文件在代码:system/core/rootdir -
B. The init process will parse the init script and launch the system service processes.
初始化进程解析 init 脚本,启动系统服务进程
5. Zygote and Dalvik
The Zygote is launched by the init process and will basically just start executing and and initialize the Dalvik VM.
Zygote 被初始化进程启动,开始运行和初始化 dalvik 虚拟机
6. The system server
系统服务
The system server is the first java component to run in the system. It will start all the Android services such as telephony manager and bluetooth.
Start up of each service is currently written directly into the run method of the system server. The system server source can be found in the file :
frameworks/base/services/java/com/android/server/SystemServer.java in the open source project.
系统服务是在系统中运行的第一个 java 组件,它会启动所有的 android 服务,比如:电话服务,蓝牙服务,每个服务的启动被直接写在 SystemServer.java 这个类的 run 方法里面
代码: frameworks/base/services/java/com/android/server/SystemServer.java
7. Boot completed
启动完成
Once the System Server is up and running and the system boot has completed there is a standard broadcast action called ACTION_BOOT_COMPLETED.
一旦系统服务启动并运行,android 系统启动就完成了,同时发出 ACTION_BOOT_COMPLETED 广播