Creating Stubs for OAL Functions (Windows Embedded CE 6.0)


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. By scanning existing sample OAL code, you can easily obtain the function header, such as return type and arguments, for each of these functions.

You can either create the stub functions from scratch or copy an existing boot loader or OAL that is of similar CPU type and board design, and then use #if 0 and #endif tags for the function contents.

  1. Obtain the function header definition for the function to be stubbed by referring to a sample OAL that supports similar hardware. The function header includes a return type and a series of function arguments.

  2. From the function header definition, create an empty function implementation.

  3. If the function header specifies a return type, add a placeholder return value to satisfy the compiler.

    For example, if the function returns a Boolean value, add either return (TRUE); or return (FALSE); to satisfy the compiler. A successful function call is usually signaled by a TRUE or non-zero value, while failure is usually signaled by a FALSE or 0 value. However, this depends on the function and the data being returned.

The following code example shows the stub for the OEMReadData function:

BOOL OEMReadData (DWORD cbData, LPBYTE pbData) { return(TRUE); }

Community Additions