Analysis of Bootpart in WinCE eboot

Source: Internet
Author: User
Tags bool

It should be said that Bootpart is a Microsoft-provided module for partitioning, which can be used in eboot. But to tell the truth, I rarely use it, know that some vendors in the BSP to support this function, but also a part of the eboot, so or introduce. First look at the architecture, as shown in figure:

In Eboot, Blcommon is at the top, as described previously, bootpart modules are invoked by OEM functions, and Bootpart modules need Flash driver support to manipulate storage devices. Here to say is the flash driver refers to the wince under the flash drive, that is, the Fmd_xxx interface driver. So to use the Bootpart module, the first to have flash drive support. Bootpart module can find the source code under "\wince600\public\common\oak\drivers\ethdbg\bootpart", the main implementation is in Bootpart.cpp. The Bootpart module mainly provides partition function and support to BINFS for flash devices. Here's how to use the function:

1. BOOL bp_init (lpbyte pmemory, DWORD dwsize, LPCTSTR Lpactivereg, Ppci_reg_info pregin, Ppci_reg_info pRegOut)

This function can be said to be the initialization function of the Bootpart module, look at the code to know that he will call Fmd_init to initialize the flash device and initialize a piece of memory. This function is typically invoked in the Oemplatforminit function. Pmemory points to a piece of memory to hold MBR information, dwsize is the size of the memory, Lpactivereg,pregin and pregout are used by fmd_init, and can generally be set to null.

2. BOOL Bp_lowlevelformat (DWORD Dwstartblock, DWORD Dwnumblocks, DWORD dwflags)

This function is used for low-level formatting, which formats the block in the flash device, recreate the MBR, and save the MBR to the first sector in the first BLOCKD. Dwstartblock the number of block,dwflags for the starting block,dwnumblocks for the formatted tag bit, indicating what format to use. The function is called in eboot as needed.

3. Ppartentry Bp_getpartitioninfo (HANDLE hpartition)

This function is used to obtain information about a partition. Hpartition is the handle to a partition and returns the appropriate partition information.

4. HANDLE Bp_openpartition (DWORD dwStartSector, DWORD Dwnumsectors, DWORD Dwparttype, BOOL Factive, DWORD dwCreationFlags )

This function is used to open or create a partition from which you can create partitions on a flash device. dwStartSector is the starting logical sector, Dwnumsectors is the number of sectors that the partition contains, Dwparttype represents the type of the partition, factive whether it is an activation partition, and the dwcreationflags means to create or open the partition. Returns a handle to the partition after successful execution.

5. BOOL Bp_writedata (HANDLE hpartition, Lpbyte pbbuffer, DWORD dwlength)

This function is responsible for writing data to a partition, which generally eboot can write wince image to the partition. Hpartition is the handle to the partition being created, pbbuffer the length of the Buffer,dwlength to be written to the data.

6. BOOL Bp_readdata (HANDLE hpartition, Lpbyte pbbuffer, DWORD dwlength)

The function is responsible for reading the data from a partition, Eboot can read wince image into RAM through this function. Hpartition is the handle to the partition being created, pbbuffer the length of the data to be read Buffer,dwlength for the data to be read.

7. BOOL Bp_setdatapointer (HANDLE hpartition, DWORD dwaddress)

This function is used to set the data pointer for a partition, and the data pointer is actually the next read or write location in the partition. Will usually cooperate with Bp_readdata (..) and Bp_writedata (..) Two functions to use. Hpartition is the handle to the partition being created, dwaddress the new position of the data pointer.

These functions are generally more commonly used. Finally, a brief summary, Microsoft provided this module is mainly used to partition on the flash device, or to help us to layout flash. In the eboot to use it, first of all to implement the flash drive can. In fact, look at the code will find that these functions whether the creation of the MBR, or create partitions, in essence, in Flash wrote some markup information, encapsulated some functions for users to use. I rarely use the Bootpart module, I am more accustomed to the entire flash are managed by themselves, feel more clear.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.