src/occ_405/errl/errl.c
// Function Specification
//
// Name:  addErrHistory
//
// Description: Add error trace history to log
//
// End Function Specification
Function Specification
Name:  addErrHistory

Add error trace history to log

End Function Specification
Function Specification Name : addErrHistory Add error trace history to log End Function Specification
void addErrHistory(errlHndl_t io_err)
{
    if( (io_err != NULL) &&
        (io_err != INVALID_ERR_HNDL) &&
        (io_err->iv_userDetails.iv_committed == 0) &&
        ((io_err->iv_userDetails.iv_entrySize + sizeof(ErrlUserDetailsEntry_t) + sizeof(G_error_history)) < MAX_ERRL_ENTRY_SZ ) )
    {
        void * l_errPtr = io_err;
        ErrlUserDetailsEntry_t l_usrDtlsEntry;
        const uint16_t l_usrDtlsHeaderSz = sizeof(l_usrDtlsEntry);
        l_usrDtlsEntry.iv_size = sizeof(G_error_history);
        l_usrDtlsEntry.iv_type = (uint8_t) ERRL_USR_DTL_HISTORY_DATA;
        l_usrDtlsEntry.iv_version = 1;
        void * l_dataAddr = l_errPtr + io_err->iv_userDetails.iv_entrySize + l_usrDtlsHeaderSz;
        memcpy(l_dataAddr, G_error_history, sizeof(G_error_history));
        const uint16_t l_sizeOfUsrDtls = l_usrDtlsHeaderSz + l_usrDtlsEntry.iv_size;
        memcpy(l_errPtr+((io_err->iv_userDetails.iv_entrySize)), &l_usrDtlsEntry, l_usrDtlsHeaderSz);
        io_err->iv_userDetails.iv_userDetailEntrySize += l_sizeOfUsrDtls;
        io_err->iv_userDetails.iv_entrySize += l_sizeOfUsrDtls;
    }
}
void addErrHistory ( errlHndl_t io_err ) { if ( ( io_err != NULL ) && ( io_err != INVALID_ERR_HNDL ) && ( io_err -> iv_userDetails . iv_committed == 0 ) && ( ( io_err -> iv_userDetails . iv_entrySize + sizeof ( ErrlUserDetailsEntry_t ) + sizeof ( G_error_history ) ) < MAX_ERRL_ENTRY_SZ ) ) { void * l_errPtr = io_err ; ErrlUserDetailsEntry_t l_usrDtlsEntry ; const uint16_t l_usrDtlsHeaderSz = sizeof ( l_usrDtlsEntry ) ; l_usrDtlsEntry . iv_size = sizeof ( G_error_history ) ; l_usrDtlsEntry . iv_type = ( uint8_t ) ERRL_USR_DTL_HISTORY_DATA ; l_usrDtlsEntry . iv_version = 1 ; void * l_dataAddr = l_errPtr + io_err -> iv_userDetails . iv_entrySize + l_usrDtlsHeaderSz ; memcpy ( l_dataAddr , G_error_history , sizeof ( G_error_history ) ) ; const uint16_t l_sizeOfUsrDtls = l_usrDtlsHeaderSz + l_usrDtlsEntry . iv_size ; memcpy ( l_errPtr + ( ( io_err -> iv_userDetails . iv_entrySize ) ) , & l_usrDtlsEntry , l_usrDtlsHeaderSz ) ; io_err -> iv_userDetails . iv_userDetailEntrySize += l_sizeOfUsrDtls ; io_err -> iv_userDetails . iv_entrySize += l_sizeOfUsrDtls ; } }
Function Specification
Name:  addErrHistory
Function Specification Name : addErrHistory
// 1. Check if error log is not null // 2. error log is not invalid // 3. error log has not been commited // 4. free space is enough (to hold new user detail header + data) //  io_err  |-----------------------------------------| //          | ErrlEntry_t                             | //          | {iv_userDetails.iv_userDetailEntrySize, | <== elog header and optional user details sections, need to add length //          |       ... other elements ...           }|     of new usrdtl section(ErrlUserDetailsEntry_t + data len) //          |-----------------------------------------| //          | ErrlUserDetailsEntry_t                  | <== new user detail header (l_usrDtlsEntry) //          |-----------------------------------------| //          | data ...                                | <== new user detail data (G_error_history) //          |      ...                                | // Calculate trace data address (err address + sizeof(ErrlEntry_t + existing usrDtls) + sizeof(ErrlUserDetailsEntry_t)) // Calculate entire data length including usrDtl header. // Copy new user details header into log //update master user details size with new data //update error log with new size