Creating Stubs for the Boot Loader OEM Functions

Stubs are routines that do not contain executable code. They act as placeholders for functions that need to be fully implemented later. When implementing stubs, you can leave comments that describe what you eventually need to do to add functionality to your function.

You need to create stubs for some generic platform routines and flash memory operations because BLCOMMON expects to call these functions, but they have not yet been implemented. You can revisit these functions and then fully implement them later.

To create stubs for boot loader OEM functions

  1. Edit the file Main.c.

  2. Add stubs for the generic platform routines in the file Main.c.

    The following code example shows the stub versions of the generic platform routines:

    #include <windows.h>
    #include <blcommon.h>
    BOOL OEMDebugInit(void) { return(TRUE); }
    BOOL OEMPlatformInit(void) { return(TRUE); }
    DWORD OEMPreDownload(void) { return(0); }
    void OEMLaunch (DWORD dwImageStart, DWORD dwImageLength, DWORD dwLaunchAddr, const ROMHDR *pRomHdr) {}
    BOOL OEMReadData (DWORD cbData, LPBYTE pbData) { return(TRUE); }
    void OEMShowProgress (DWORD dwPacketNum) {}
    void OEMWriteDebugByte(unsigned char c) {}
    

    The stub versions added to Main.c are for the following generic platform routines:

  3. Create a file called Flash.c.

  4. Add stubs for the flash memory-related functions in the file Flash.c.

    The following code example shows the stub versions of the flash memory-related functions:

    #include <windows.h>
    #include <blcommon.h>
    BOOL OEMStartEraseFlash (DWORD dwStartAddr, DWORD dwLength) { return(FALSE); }
    void OEMContinueEraseFlash (void) {}
    BOOL OEMFinishEraseFlash (void) {return(FALSE); }
    BOOL OEMIsFlashAddr (DWORD dwAddr) { return(FALSE); }
    BOOL OEMWriteFlash(DWORD dwStartAddr, DWORD dwLength) { return(FALSE); }
    LPBYTE OEMMapMemAddr (DWORD dwImageStart, DWORD dwAddr) { return((LPBYTE)dwAddr); }
    

    The stub versions added to Flash.c are for the following flash memory-related functions:

    If the boot loader being developed does not need to erase or write to flash memory on your device, the flash memory routines can remain as stub versions and do not have to be fully implemented later.

See Also

How to Develop a Boot Loader

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.