为什么29M的wince内核nk.nb0文件在2秒钟就能快速启动,如果你用汇编设计一个从NAND单纯拷贝29M nk.nb0的快速程序,你会发现用200MFCLK的2410或者用400MFCLK的2440都至少需要十几秒,那为什么ce能够启动这么快呢,有什么加速算法吗?答案是肯定的,并不需要一次性将所有nk.nb0数据都加载到内存,应该按需加载,那就是ce的镜像文件image“按需加载”[“段式加载”]方式,TOC就是用来描述ce内核镜像文件image的xipkernel段核心结构体,我们只需加载核文件xipkernel就能正常启动进入wince界面。
------------------------------------------------------------
硬件环境QT2440A:
NAND[K9F1208U0C]-64M(启动)
Block0-加载Block2内容的loader程序
Block1-512字节的TOC结构体存储空间
Block2-加载umon或者结合TOC加载nk.nb0的loader程序
------------------------------------------------------------
typedef struct _TOC {
//和CSW中的认证域类似,只用来验证接下去内容的合法
DWORD dwSignature;
//包含image的索引(我的是1)、启动delay时间、ip地址、MAC地址和掩码等
BOOT_CFG BootCfg;
//用来描述3个之多的ce内核image数组,我用的是id[1]
IMAGE_DESCRIPTOR id[MAX_TOC_DESCRIPTORS];
CHAININFO chainInfo;
} TOC, *PTOC; // 512 字节
typedef struct _IMAGE_DESCRIPTOR {
DWORD dwVersion; //编译时的版本号
DWORD dwSignature; //“EBOOT”或“CFSH”等
UCHAR ucString[IMAGE_STRING_LEN]; //描述字符串:如"eboot.nb0"之类
DWORD dwImageType; //image的类型nk.nb0为0x04
DWORD dwTtlSectors; //image文件用到的NAND的扇区总数
DWORD dwLoadAddress; //image加载时的虚拟地址
DWORD dwJumpAddress; //image加载完成后的跳转地址
SG_SECTOR sgList[MAX_SG_SECTORS]; //image的段描述,包括起始扇区号和所需扇区数目
ULONG dwStoreOffset;
} IMAGE_DESCRIPTOR, *PIMAGE_DESCRIPTOR;
==========================
Loader的输出:
'U' for USBMON
******
Total Sectors:0x0000e800
Sector addr on NAND: 0x000002a0
TotalSector: 0x0000e800
Reading Kernel Image from NAND
dwSector: 0x000002a0
dwLength: 0x0000e800
dwRAM: 0x30200000
==========================
eboot.nb0的输出:
Microsoft Windows CE Ethernet Bootloader Common Library Version 1.0 Built Dec 20 2006 22:35:26
Copyright (c) 2000-2001 Microsoft Corporation
Microsoft Windows CE SMDK2440 Bootloader Version 1.2 Built Dec 20 2006 22:35:23
FMD::FMD_Init
FMD::FMD_Init Done
TOC_Read
TOC {
dwSignature: 0x434F544E
BootCfg {
ConfigFlags: 0x3820
BootDelay: 0xF
ImageIndex: 1
IP: 192.168.1.108
MAC Address: 00:00:00:00:00:00
Port: 0.0.0.0
SubnetMask: 255.255.255.0
}
ID[0] {
dwVersion: 0x10002
dwSignature: 0x45424F54
String: 'eboot.nb0'
dwImageType: 0x2
dwTtlSectors: 0x100
dwLoadAddress: 0x8C038000
dwJumpAddress: 0x8C038000
dwStoreOffset: 0x0
sgList[0].dwSector: 0x40
sgList[0].dwLength: 0x100
}
ID[1] {
dwVersion: 0x1
dwSignature: 0x43465349
String: ''
dwImageType: 0x6
dwTtlSectors: 0xE800
dwLoadAddress: 0x8C200000
dwJumpAddress: 0x8C201000
dwStoreOffset: 0x0
sgList[0].dwSector: 0x2A0
sgList[0].dwLength: 0xE800
}
chainInfo.dwLoadAddress: 0X00000000
chainInfo.dwFlashAddress: 0X00000000
chainInfo.dwLength: 0X00000000
}
-TOC_Read
Press [ENTER] to download image now, or [SPACE] to enter boot monitor.