Share via


Implementing the GenBltCpuInitialize Function (Windows Embedded CE 6.0)

1/6/2010

The GenBltCpuInitialize function retrieves the translation and optimization functions. An example implementation of GenBltCpuInitialize is in the %_WINCEROOT%\Public\Common\OAK\Cpulibs\%_TGTCPUFAMILY%\Genblt_cpu directory.

GenBltCpuInitialize detects the microprocessor and places the microprocessor-specific translation and optimization functions in memory. Use the IsProcessorFeaturePresent function and the QueryInstructionSet function to determine the characteristics of the current microprocessor.

The function that calls GenBltCpuInitialize initializes all entries of the GenBltCpuFuncs structure to invalid values. When initializing the GenBltCpuFuncs structure, set individual members to valid values only if you will use the individual members.

GenBltCpuInitialize ARM Implementation

The following code example shows the ARM implementation of the GenBltCpuInitialize function. This code is located in %_WINCEROOT%\Public\Common\OAK\Cpulibs\ARM\Genblt_cpu\Genblt_arm.cpp.

BOOL GenBltCpuInitialize(GenBltCpuFuncs * pCpuFuncs)
{
    BOOL fResult = FALSE;

    //
    // Detect various ARM variants and select the best translator
    // and optimizer.
    //

    if (IsProcessorFeaturePresent(PF_ARM_V4))
    {
        pCpuFuncs->pfnPCodeToCpuCode = GenBltArmV4Translate;
        pCpuFuncs->pfnCpuOptimize    = GenBltArmV4Optimize;

        fResult = TRUE;
    }
    else
    {
        RETAILMSG(1, (L"GenBlt: Attempting to use ARM specific" \
                       "code on an unsupported CPU"));
    }

    //
    // Returning FALSE here means that GeneratedBlts will not be
    // used.
    //

    return fResult;
}

GenBltCpuInitialize ARMV5 Implementation

The following code example shows the ARM implementation of the GenBltCpuInitialize function that uses ARMV5-specific translation and optimization functions. This code is located in %_WINCEROOT%\Public\Common\OAK\Cpulibs\ARM\Genblt_cpu\Genblt_arm.cpp.

The GenBltArmV5Translate function is the ARMV5-specific translation function and the GenBltArmV5Optimize function is the ARMV5-specific optimization function. The optimization function supports two passes. One pass executes after 10 blits, and one pass executes after 25 blits.

BOOL GenBltCpuInitialize(GenBltCpuFuncs * pCpuFuncs)
{
    BOOL fResult = FALSE;

    //
    // Detect various ARM variants and select the best translator
    // and optimizer.
    //

    if (IsProcessorFeaturePresent(PF_ARM_V5))
    {
        pCpuFuncs->pfnPCodeToCpuCode = GenBltArmV5Translate;
        pCpuFuncs->pfnCpuOptimize    = GenBltArmV5Optimize;

        pCpuFuncs->dwOptimizeTimes[0] = 10;
        pCpuFuncs->dwOptimizeTimes[1] = 25;
    }
    if (IsProcessorFeaturePresent(PF_ARM_V4))
    {
        pCpuFuncs->pfnPCodeToCpuCode = GenBltArmV4Translate;
        pCpuFuncs->pfnCpuOptimize    = GenBltArmV4Optimize;

        fResult = TRUE;
    }
    else
    {
        RETAILMSG(1, (L"GenBlt: Attempting to use ARM specific" \
                       "code on an unsupported CPU"));
    }

    //
    // Returning FALSE here means that GeneratedBlts will not be
    // used.
    //

    return fResult;
}

See Also

Concepts

Improving the Performance of Software Blits by Generating Blit Functions at Run Time
Implementing the Translation Function
Implementing the Optimization Function