IPC@CHIP® RTOS-PPC – API Documentation

Header image

Main page


BOOL TryDejavu ( sTRY_CATCH try_ptr  ) 

This library function provide an exception handling mechanism.

Some signature patterns and program state information are written into the provided stack object. The signatures signal the system to resume execution after a fault at the return address from this function.

When an MMU or other fault (e.g. invalid opcode) occurs, the system will scan the faulting task's stack in search of the signature pattern written by this function into the sTRY_CATCH stack object at try_ptr. If this signature pattern is detected, the system assumes that this stack memory contains a valid sTRY_CATCH and an attempt will be made to resume execution at the point where this library function was called. This return address was recorded in the sTRY_CATCH::tcRtnAdr member.

The following example shows how this function should be used. In any case, the TRY_ERASE() macro should be used to terminate the try/catch sequence.

    sTRY_CATCH myCatch ;
    if (TryDejavu(&myCatch))
    {
        GoAboutMyNormalBusiness()
    }
    else
    {
        // ... Reach here after a fault,
        // ... clean up after program fault.
    }
    TRY_ERASE()

So for the case where a fault occurs, it appears as if the TryDejavu() has returned a second time. The second time it magically returns with a zero return value to indicate that the fault has occurred. Interrupts will be enabled regardless of their masking state at the time of the fault.

Parameters:
try_ptr Pointer to object on stack used to mark program state information needed for recovery after a fault. (Note that it is essential that this object be on the stack, otherwise this function serves no purpose.)
Returns:
1 on return from preparation call (first return).
0 on resume after fault detected.
Compatibility:
The function does not exists in the SC1x, SC2x and SC1x3 C-Library.
See also:
TRY_ERASE()
Since:
SC2x3 V1.00 - CLIB V1.00





Top of page | Main page

Copyright © 2017 Beck IPC GmbH
Generated on Thu Jan 26 16:21:37 2017 by Doxygen 1.6.1