OEM flash functions in WinCE eboot

Source: Internet
Author: User
Tags bool

Eboot provides the ability to manipulate flash, and can burn the downloaded wince image into Flash, which requires some flash-related OEM functions.

These OEM functions are invoked in the Blcommon module, which is called in the Downloadimage function of the blcommon.c file. In the Downloadimage function, the header of a generic image file is first downloaded and parsed. Then call OEMISFLASHADDR to determine the area where the image is located, if it is in the flash address space, then download the image file and invoke the flash-related OEM function to erase and write Flash. Here's a quick introduction to these functions:

1.BOOL oemisflashaddr (DWORD dwaddr)

This function is used to determine whether the downloaded WinCE image file is in the Flash area or in the Ram area, DWADDR is the address of the image file, or False if it returns true in the Flash area, giving Microsoft an example:

1. #define Flash_start      0
2 #define flash_length     0x02000000
3.BOOL oemisflashaddr (DWORD dwaddr)
4.{
5.        According to the starting address and length of flash to determine whether the address in the Flash area
6.        if ((dwaddr >= flash_start) && (Dwaddr < (Flash_start + flash_length)))
7.        {
8. Return                (TRUE);
9.
One. return    (FALSE);
13.

2.BOOL Oemstarteraseflash (DWORD dwstartaddr, DWORD dwlength)

This function is used to initialize flash erasure, DWSTARTADDR represents the starting address to erase, and dwlength is the length. Using these two parameters to calculate the starting block and last block to be erased in Flash, and how many blocks to erase, give Microsoft an example:

1.BOOL Oemstarteraseflash (DWORD dwstartaddr, DWORD dwlength) 2.
{3. ULONG i = 0;
4. ULONG nnumblocks = 0;    5.6.    Determine if both the start and end addresses are in the Flash area 7. if (! OEMISFLASHADDR (dwstartaddr) | | !    OEMISFLASHADDR (dwstartaddr + dwLength-1)) 8.
{9. return (FALSE);
10.} 11.    12.//Confirm that the starting address is 13 of the block alignment.    if (dwstartaddr% flash_block_size) 14.
{return (FALSE);    16.} 17.    Verify that the length is 4-byte alignment 18.    if (Dwlength & 0x03) 19.
{return (FALSE);
21.} 22.    23.//Based on the base address of Flash and the block size of Flash, the start block and last 24 are to be erased.    Block and how many blocks 25.
Gnstartblock = (dwstartaddr-flash_base)/flash_block_size;
Gnendblock = ((dwstartaddr + dwlength + (flash_block_size-1)-flash_base)/flash_block_size);
Gnblocks = (int) (gnendblock-gnstartblock);
Gnblockcount = Gnstartblock;    29.30.
Edbgoutputdebugstring ("erasing flash blocks:start blocks =%d end blocks =%d\r\n", Gnstartblock, Gnendblock);
31.32.
return (TRUE); 34.}

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.