Thursday, 29 November 2012

Update to Removing Process & Thread IDs from WEC 7.0 Serial Debug Output

Following my earlier post I've found that setting

    g_pOemGlobal->pfnWriteDebugString = NULL;

has an unfortunate side-effect during suspend & resume in that any debug prints during OEMPowerOff will use the NULL function pointer and cause the system to crash.

The solution is to restore the kernel to use the default serial debug during OEMPowerOff()...

VOID BSPPowerOff()
    // If OEMInit() cleared g_pOemGlobal->pfnWriteDebugString to remove VID/PID
    // from debug output, g_pNKGlobal->pfnWriteDebugString will now be NULL (see
    // NKPowerOffSystem() in WINCE700\private\winceos\COREOS\nk\kernel\kwin32.c)
    if (NULL == g_pNKGlobal->pfnWriteDebugString)
        // Set kernel pfnWriteDebugString so that debug prints in OEMPowerOff()
        // do not crash the system.
        // NKPowerOffSystem() will restore the orginal value following return
        // from OEMPowerOff()
        g_pNKGlobal->pfnWriteDebugString = (PFN_WriteDebugString)OEMWriteDebugString;

No comments: