Andorid的LK学习

来源:互联网 发布:携程亲子园虐童 知乎 编辑:程序博客网 时间:2024/05/21 09:25

在Android下,LK是CPU(如TCC8803,PRIMAII,QUALCOMM7627A系列)的引导部分,也同样包含了内存,MMU,CPU主频,核心电压值等最小硬件的初始化。

重要的点是要看清源码的结构:此结构与linux的源码结构相差不大,在此不详细解说。

入口点:

kernel - > main.C

void kmain(void)
{
 // get us into some sort of thread context
 thread_init_early();              //线程队列早期初始化。早期往往是初始化结构体。。。以下同样。也很多是无事可干,LK基本就是一个裸机。

 dprintf(INFO,"func:thread_init_early(); end\n");

 // early arch stuff
 arch_early_init();   //内存以及mmu的早期初始化。此处会区分X86与ARM的mmu的初始化,当然,我们用的是ARM
 dprintf(INFO,"func:arch_early_init(); end\n");
 
 // do any super early platform initialization
 platform_early_init();          //一些特殊平台需要特别处理的早期初始化。
 dprintf(INFO,"func:platform_early_init(); end\n");

 // do any super early target initialization
 target_early_init();  //目标早期初始化

 dprintf(INFO, "welcome to lk\n\n");

 // deal with any static constructors
 dprintf(SPEW, "calling constructors\n");
 call_constructors();//处理静态构造函数?暂不知道干啥子用的

 // bring up the kernel heap
 dprintf(SPEW, "initializing heap\n");
 heap_init();//堆栈初始化,

 // initialize the threading system
 dprintf(SPEW, "initializing threads\n");
 thread_init();//初始化线程,也很多是无事可干,LK基本就是一个裸机。

 // initialize the dpc system
 dprintf(SPEW, "initializing dpc\n");
 dpc_init();//暂时不知道DPC干啥用,哪位友人告知?

 // initialize kernel timers
 dprintf(SPEW, "initializing timers\n");
 timer_init();//裸机嘛。时间中断需要么??

#if (!ENABLE_NANDWRITE) //由于本人是采用NANDFLASH的,所以会进去。
 // create a thread to complete system initialization
 dprintf(SPEW, "creating bootstrap completion thread\n");
 thread_resume(thread_create("bootstrap2", &bootstrap2, NULL, DEFAULT_PRIORITY, DEFAULT_STACK_SIZE));//进入bootstrap2的具体函数。

 // enable interrupts
 exit_critical_section();

 // become the idle thread
 thread_become_idle();
#else
        bootstrap_nandwrite();
#endif
}

结合LK的源码存放结构,主函数相当简单明了,几乎都是初始化,然后跳进服务函数bootstrap2进行相应的服务处理;由于早前就了解了LK又那些功能,因此,就很容易明白bootstrap2的基本工作有些;

 

有意思的是LK的功能处理都是在app文件夹进行的,而app一般别认为是系统应用。看来LK的源码是把功能的实现叫做app,把其归类为一类。

 

一天就这样过去了。。。

明天继续。。。写于2013/8/12 广州飞歌汽车音响有限公司大楼。。。

 

今日大体了解了一下LK的功能:1:flash存储空间分配;2:跳进fastboot模式;3:跳入recovery;4:正常启动linux kernel。。。

作为一个工程,flash的大小空间分配时重中之重,为什么外面说的16G ROM,且只有13点多G的空间呢?此就是因为在LK的空间分配给到用户的可使用的空间啦。

因此,一个源码包,为了适合产品的使用,LK修改最常见的就是flash的存储空间分配。

那么LK管理着那些数据的空间呢?userdata、system、persist、recovery等都是要扫写到flash的数据。

 

进度缓慢。。。写于2013/8/12 广州飞歌汽车音响有限公司大楼。。。

 

 

 

 

 

原创粉丝点击