wince4.2系统启动流程

     在bootloader把nk放到ram的适当位置之后,会跳到其中去执行。
     第一个程序文件(platform/xxx/kernel/hal/arm/fw.s)。首先也是做一些基本的设置操作,之后会走到KernelStart,这个函数也是在(private/winceos/coreos/nk/kernel/arm/armtrap.s)文件中实现。该函数主要处理流程如下: The OEM layer will setup any platform or CPU specific configuration that is; required for the kernel to have access to ROM and DRAM and jump here to start up; the system. Any processor specific cache or MMU initialization should be completed.; The MMU and caches should not enabled.; This routine will initialize the first-level page table based up the contents of; the MemoryMap array and enable the MMU and caches.; NOTE: Until the MMU is enabled, kernel symbolic addresses are not valid and must be; translated via the MemoryMap array to find the correct physical address.; Entry (r0) = pointer to MemoryMap array in physical memory; Exit returns if MemoryMap is invalid。接下来就是在虚拟地址空间的操作了(也是在armtrap.s中),主要的就是3个函数ARMInit;KernelInit;FirstSchedule。
      ARMInit在private/winceos/coreos/nk/kernel/arm/madarm.c中实现。又KernelRelocate了一把(这是一个比较重要的函数,位于\Private\winceos\coreos\nk\kernel\loader.c. 它会把kernel用到的数据copy的ram里面。这里的ram就是在config.bib里面指定的具有ram属性的存储区域,不是ramimage。kernelRelocate以pToc为参数,据说pToc是在makeimage阶段被romimage.exe赋值的,也就是说pToc并不是在代码中被赋值的,是由外力(romimage.exe)改动nk.bin的内容赋值的),初始化了调试串口(oal的OEMInitDebugSerial)等。在此之后的就是调用了OEMInit()。这个函数就非常熟悉了,在platform/xxx/kernel/hal/cfw.c文件中实现。主要完成映射IO_BASE,初始化display,并在其中操作framebuffer显示logo等操作。OEMInit之后是KernelFindMemory(位于WINCEROOT\Private\winceos\coreos\nk\kernel\loader.c),这个函数主要是把ram划分为两部分:object store和应用程序可以使用的部分。object store就是用于存贮wince的ram filesystem的,\windows目录就是位于ram file system。
      KernelInit在private/winceos/coreos/nk/kernel/kwin32.c中实现。主要初始化heap,memory pool,process并为第一次调度做准备。这部分跟cpu无关,是kernel要完成自己的初始化。至此,kernel得初始化全部完成。kernel在完成初始化之后,会以IOCTL_HAL_POSTINIT为参数调用OEMIoControl。
      FirstSchedule在private/winceos/coreos/nk/kernel/arm/armtrap.s中实现,第一次调度,进入相应的模式。我想这第一个调度的程序应该是kern.exe,然后就是传说中的filesys.exe,device.exe,gwes.exe等。

你可能感兴趣的:(系统,启动,流程,休闲,wince4.2)