tEplKernel PUBLIC EplEventkPost(tEplEvent * pEvent_p)
{
tEplKernel      Ret;
#if EPL_USE_SHAREDBUFF != FALSE
tShbError       ShbError;
tShbCirChunk    ShbCirChunk;
unsigned long   ulDataSize;
unsigned int    fBufferCompleted;
#endif

    Ret = kEplSuccessful;


    // the event must be posted by using the abBuffer
    // it is neede because the Argument must by copied
    // to the buffer too and not only the pointer

#if EPL_USE_SHAREDBUFF != FALSE
    // 2006/08/03 d.k.: Event and argument are posted as separate chunks to the event queue.
    ulDataSize = sizeof(tEplEvent) + ((pEvent_p->m_pArg != NULL) ? pEvent_p->m_uiSize : 0);
#endif

    // decide in which buffer the event have to write
    switch(pEvent_p->m_EventSink)
    {
        // kernelspace modules
        case kEplEventSinkSync:
        case kEplEventSinkNmtk:
        case kEplEventSinkDllk:
        case kEplEventSinkDllkCal:
        case kEplEventSinkPdok:
        case kEplEventSinkPdokCal:
        case kEplEventSinkErrk:
        {
            BENCHMARK_MOD_27_SET(2);
#if (EPL_USE_SHAREDBUFF != FALSE) \
    && (EPL_EVENT_USE_KERNEL_QUEUE != FALSE)
            // post message
            ShbError = ShbCirAllocDataBlock (EplEventkInstance_g.m_pShbKernelInternalInstance,
                                   &ShbCirChunk,
                                   ulDataSize);
            switch (ShbError)
            {
                case kShbOk:
                    break;

                case kShbBufferFull:
                {
                    EplEventkInstance_g.m_uiUserToKernelFullCount++;
                    Ret = kEplEventPostError;
                    goto Exit;
                }

                default:
                {
                    EPL_DBGLVL_EVENTK_TRACE("EplEventkPost(): ShbCirAllocDataBlock(U2K) -> 0x%X\n", ShbError);
                    Ret = kEplEventPostError;
                    goto Exit;
                }
            }
            ShbError = ShbCirWriteDataChunk (EplEventkInstance_g.m_pShbKernelInternalInstance,
                                   &ShbCirChunk,
                                   pEvent_p,
                                   sizeof (tEplEvent),
                                   &fBufferCompleted);
            if (ShbError != kShbOk)
            {
                EPL_DBGLVL_EVENTK_TRACE("EplEventkPost(): ShbCirWriteDataChunk(U2K) -> 0x%X\n", ShbError);
                Ret = kEplEventPostError;
                goto Exit;
            }
            if (fBufferCompleted == FALSE)
            {
                ShbError = ShbCirWriteDataChunk (EplEventkInstance_g.m_pShbKernelInternalInstance,
                                       &ShbCirChunk,
                                       pEvent_p->m_pArg,
                                       (unsigned long) pEvent_p->m_uiSize,
                                       &fBufferCompleted);
                if ((ShbError != kShbOk) || (fBufferCompleted == FALSE))
                {
                    EPL_DBGLVL_EVENTK_TRACE("EplEventkPost(): ShbCirWriteDataChunk2(U2K) -> 0x%X\n", ShbError);
                    Ret = kEplEventPostError;
                    goto Exit;
                }
            }

#else
            #if EPL_EVENT_USE_KERNEL_QUEUE == FALSE
                EplTgtEnableGlobalInterrupt(FALSE);
            #endif
            Ret = EplEventkProcess(pEvent_p);
            #if EPL_EVENT_USE_KERNEL_QUEUE == FALSE
                EplTgtEnableGlobalInterrupt(TRUE);
            #endif
#endif
            BENCHMARK_MOD_27_RESET(2);

            break;
        }

        // userspace modules
        case kEplEventSinkNmtu:
        case kEplEventSinkNmtMnu:
        case kEplEventSinkSdoAsySeq:
        case kEplEventSinkApi:
        case kEplEventSinkDlluCal:
        case kEplEventSinkErru:
        {
#if EPL_USE_SHAREDBUFF != FALSE
            // post message
//            BENCHMARK_MOD_27_SET(3);    // 74 µs until reset
            ShbError = ShbCirAllocDataBlock (EplEventkInstance_g.m_pShbKernelToUserInstance,
                                   &ShbCirChunk,
                                   ulDataSize);
            if(ShbError != kShbOk)
            {
                EPL_DBGLVL_EVENTK_TRACE("EplEventkPost(): ShbCirAllocDataBlock(K2U) -> 0x%X\n", ShbError);
                Ret = kEplEventPostError;
                goto Exit;
            }
            ShbError = ShbCirWriteDataChunk (EplEventkInstance_g.m_pShbKernelToUserInstance,
                                   &ShbCirChunk,
                                   pEvent_p,
                                   sizeof (tEplEvent),
                                   &fBufferCompleted);
            if(ShbError != kShbOk)
            {
                EPL_DBGLVL_EVENTK_TRACE("EplEventkPost(): ShbCirWriteDataChunk(K2U) -> 0x%X\n", ShbError);
                Ret = kEplEventPostError;
                goto Exit;
            }
            if (fBufferCompleted == FALSE)
            {
                ShbError = ShbCirWriteDataChunk (EplEventkInstance_g.m_pShbKernelToUserInstance,
                                       &ShbCirChunk,
                                       pEvent_p->m_pArg,
                                       (unsigned long) pEvent_p->m_uiSize,
                                       &fBufferCompleted);
                if ((ShbError != kShbOk) || (fBufferCompleted == FALSE))
                {
                    EPL_DBGLVL_EVENTK_TRACE("EplEventkPost(): ShbCirWriteDataChunk2(K2U) -> 0x%X\n", ShbError);
                    Ret = kEplEventPostError;
                    goto Exit;
                }
            }
//            BENCHMARK_MOD_27_RESET(3);  // 82 µs until ShbCirGetReadDataSize() in EplEventu

#else
            Ret = EplEventuProcess(pEvent_p);
#endif

            break;
        }

        default:
        {
            Ret = kEplEventUnknownSink;
        }


    }// end of switch(pEvent_p->m_EventSink)

#if EPL_USE_SHAREDBUFF != FALSE
Exit:
#endif
    return Ret;
}
Beispiel #2
0
//---------------------------------------------------------------------------
//
// Function:    EplEventuPost
//
// Description: post events from userspace
//
//
//
// Parameters:  pEvent_p = pointer to event-structur from buffer
//
//
// Returns:      tEpKernel  = errorcode
//
//
// State:
//
//---------------------------------------------------------------------------
tEplKernel PUBLIC EplEventuPost(tEplEvent * pEvent_p)
{
tEplKernel      Ret;
#if EPL_USE_SHAREDBUFF != FALSE
tShbError       ShbError;
tShbCirChunk    ShbCirChunk;
unsigned long   ulDataSize;
unsigned int    fBufferCompleted;
#endif

    Ret = kEplSuccessful;


#if EPL_USE_SHAREDBUFF != FALSE
    // 2006/08/03 d.k.: Event and argument are posted as separate chunks to the event queue.
    ulDataSize = sizeof(tEplEvent) + ((pEvent_p->m_pArg != NULL) ? pEvent_p->m_uiSize : 0);
#endif

    // decide in which buffer the event have to write
    switch(pEvent_p->m_EventSink)
    {
        // kernelspace modules
        case kEplEventSinkSync:
        case kEplEventSinkNmtk:
        case kEplEventSinkDllk:
        case kEplEventSinkDllkCal:
        case kEplEventSinkPdok:
        case kEplEventSinkPdokCal:
        case kEplEventSinkErrk:
        {
#if (EPL_USE_SHAREDBUFF != FALSE) \
    && (EPL_EVENT_USE_KERNEL_QUEUE != FALSE)
            // post message
            ShbError = ShbCirAllocDataBlock (EplEventuInstance_g.m_pShbUserToKernelInstance,
                                   &ShbCirChunk,
                                   ulDataSize);
            if (ShbError != kShbOk)
            {
                //EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirAllocDataBlock(U2K) -> 0x%X\n", ShbError);
                Ret = kEplEventPostError;
                goto Exit;
            }
            ShbError = ShbCirWriteDataChunk (EplEventuInstance_g.m_pShbUserToKernelInstance,
                                   &ShbCirChunk,
                                   pEvent_p,
                                   sizeof (tEplEvent),
                                   &fBufferCompleted);
            if (ShbError != kShbOk)
            {
                //EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirWriteDataChunk(U2K) -> 0x%X\n", ShbError);
                Ret = kEplEventPostError;
                goto Exit;
            }
            if (fBufferCompleted == FALSE)
            {
                ShbError = ShbCirWriteDataChunk (EplEventuInstance_g.m_pShbUserToKernelInstance,
                                       &ShbCirChunk,
                                       pEvent_p->m_pArg,
                                       (unsigned long) pEvent_p->m_uiSize,
                                       &fBufferCompleted);
                if ((ShbError != kShbOk) || (fBufferCompleted == FALSE))
                {
                    //EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirWriteDataChunk2(U2K) -> 0x%X\n", ShbError);
                    Ret = kEplEventPostError;
                    goto Exit;
                }
            }
#else
            #if EPL_EVENT_USE_KERNEL_QUEUE == FALSE && TARGET_SYSTEM == _NO_OS_
                EplTgtEnableGlobalInterrupt(FALSE);
            #endif

                Ret = EplEventkProcess(pEvent_p);

            #if EPL_EVENT_USE_KERNEL_QUEUE == FALSE && TARGET_SYSTEM == _NO_OS_
                EplTgtEnableGlobalInterrupt(TRUE);
            #endif
#endif

            break;
        }

        // userspace modules
        case kEplEventSinkNmtMnu:
        case kEplEventSinkNmtu:
        case kEplEventSinkSdoAsySeq:
        case kEplEventSinkApi:
        case kEplEventSinkDlluCal:
        case kEplEventSinkErru:
        case kEplEventSinkLedu:
        {
#if EPL_USE_SHAREDBUFF != FALSE
            // post message
            ShbError = ShbCirAllocDataBlock (EplEventuInstance_g.m_pShbKernelToUserInstance,
                                   &ShbCirChunk,
                                   ulDataSize);
            if(ShbError != kShbOk)
            {
                //EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirAllocDataBlock(K2U) -> 0x%X\n", ShbError);
                Ret = kEplEventPostError;
                goto Exit;
            }
            ShbError = ShbCirWriteDataChunk (EplEventuInstance_g.m_pShbKernelToUserInstance,
                                   &ShbCirChunk,
                                   pEvent_p,
                                   sizeof (tEplEvent),
                                   &fBufferCompleted);
            if(ShbError != kShbOk)
            {
                //EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirWriteDataChunk(K2U) -> 0x%X\n", ShbError);
                Ret = kEplEventPostError;
                goto Exit;
            }
            if (fBufferCompleted == FALSE)
            {
                ShbError = ShbCirWriteDataChunk (EplEventuInstance_g.m_pShbKernelToUserInstance,
                                       &ShbCirChunk,
                                       pEvent_p->m_pArg,
                                       (unsigned long) pEvent_p->m_uiSize,
                                       &fBufferCompleted);
                if ((ShbError != kShbOk) || (fBufferCompleted == FALSE))
                {
                    //EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirWriteDataChunk2(K2U) -> 0x%X\n", ShbError);
                    Ret = kEplEventPostError;
                    goto Exit;
                }
            }

#else

            Ret = EplEventuProcess(pEvent_p);
#endif

            break;
        }

        default:
        {
            Ret = kEplEventUnknownSink;
        }


    }// end of switch(pEvent_p->m_EventSink)

#if EPL_USE_SHAREDBUFF != FALSE
Exit:
#endif

return Ret;

}