Author: Fu Linlin Source: NEW YORK I'm glad the company's product development process has not been brought Boot Loader resistance, because we use MSDOS Loadcepc to start CE operating system. Obviously this luck is not always, so there should be enough research and understanding for Boot Loader, and prepare it to do. Boot Loader is an important development link in the process of customizing the Windows CE operating system. Boot loader's role as two words in the name: boot, boot the system, if the CE-based product uses the BIOS to implement hardware initialization and configuration, then Boot Loader simply boots the software system. If BIOS is not adopted, the role of Boot Loader also includes the basic functionality of the BIOS; loader loads both the operating system, and the Boot Loader loads the CE's kernel file nk.bin after the entire system is started. When Boot Loader extracts nk.bin to RAM, the CPU control is handed over to the CE kernel. The Boot Loader of the X86 platform is the most type. Below the X86 platform's boot loader: x86 Rom Boot Loader is also called ROT, remember to mention ROOT in the previous article. The ROM Boot is designed to be stored in Flash / EEPROM, which is the original BIOS location, so when the CPU to the fixed address is executed after power-on, it is to implement the code included in the ROOT, which initializes and detects the entire hardware system. And support the downloading NK.bin from the remote machine or from the local IDE / ATA hard drive from the remote machine. The advantage of ROT is to boot and load speed, and it has completed all the operations, so you don't have to use BIOS, MSDOS, not to loadcepc. The disadvantage is that the CE developer needs to understand its source code and modify it. CE provides all source code for ROT, and readers can find a help document titled "X86 Source Organization", which list all relevant directories and content in this document, and also lists the directory where the driver source code of the four network cards is also enumerated. X86 BIOS Boot Loader BIOS BOOT LOADER and MSDOS loadCepc two ways, BIOS Boot Loader just does not need MSDOS operating systems, it still requires the BIOS and FAT file systems. Let's talk about the boot order of the system using BIOS Boot Loader: After the system is powered on, the BIOS is completed and configured, the BIOS checks the boot order of the boot device, if the boot device is a hard disk, CF card, DOC (Disk-On-CHIP) ) A type of storage device, then perform these code to the real mode code to memory loaded on the master boot sector of these memories. The code mentioned here is called the main boot record (MBR). The MBR first looks for activity partitions in partition tables (equally on the main boot sector). If there is an active partition, the code to memory is loaded on the first sector of this activity partition, and then performs these code. The first sector of the movable partition mentioned herein is referred to as a boot sector. The function of the code on the boot sector is to find and load BiOS boot loader, BIOS Boot Loader, load NK.bin. The source code of the boot sector is located in% _winceroot% / public / common / Oak / CSP / I486 / Biosloader / bootsector directory.
There is a ready-made boot sector image file, its path is% _winceroot% / public / common / oak / csp / i486 / biosloader / diskimages / setupdisk / bsect.img. For BiOS Boot Loader, CE provides two files for SetupDisk.144 and bootdisk.144, with ".144" to decompress the files of the extension, I have said in the previous article. These two files are unwrapped with the motion sector and the Boot Loader mirror file. The "MKDisk C:" batch command writes the two mirror files to the disk. MKDisk will set the boot loader hidden properties so that Boot Loader files will not be displayed when all files are listed in the root directory. MSDOS LOADCEPC This way is very simple. After the MSDOS is started, Loadcepc.exe is executed, so that the loadCepc loads NK.bin to the memory, then hand over the CE kernel program. LoadCepc has been told in the previous article. The following is analyzed according to the general boot loader source code: boot loader consists of two parts: OEM startup code (OEM Startup Code) and main code. OEM startup code is the first part of the first execution, its function is to initialize the memory register, set the CPU frequency, initialize the cache. After it jumps to the main code. General OEM startup code is written with compilation. The primary code is generally written in C language, which is responsible for all other tasks, which can also display the relevant information executed on the screen while executing. Generally add companies logo or other boot logo are modified here. The main code is mainly composed of several parts: mirror download code, through the parallel port or network card to download NK.bin from the remote computer; serial port debug code, including the read / write function of the serial port, the user calls these functions can pass the serial port at the remote computer Communication between local computers; write Flash code, including functions written to Flash; Hardware monitoring code. The general Boot Loader is implemented in the following figure: