diff options
Diffstat (limited to 'drivers/staging/epl/EplEventk.c')
-rw-r--r-- | drivers/staging/epl/EplEventk.c | 971 |
1 files changed, 483 insertions, 488 deletions
diff --git a/drivers/staging/epl/EplEventk.c b/drivers/staging/epl/EplEventk.c index ea612c72adb..8068a6c5a0d 100644 --- a/drivers/staging/epl/EplEventk.c +++ b/drivers/staging/epl/EplEventk.c @@ -81,9 +81,9 @@ #endif #ifdef EPL_NO_FIFO - #include "user/EplEventu.h" +#include "user/EplEventu.h" #else - #include "SharedBuff.h" +#include "SharedBuff.h" #endif /***************************************************************************/ @@ -100,29 +100,28 @@ // TracePoint support for realtime-debugging #ifdef _DBG_TRACE_POINTS_ - void PUBLIC TgtDbgSignalTracePoint (BYTE bTracePointNumber_p); - void PUBLIC TgtDbgPostTraceValue (DWORD dwTraceValue_p); - #define TGT_DBG_SIGNAL_TRACE_POINT(p) TgtDbgSignalTracePoint(p) - #define TGT_DBG_POST_TRACE_VALUE(v) TgtDbgPostTraceValue(v) +void PUBLIC TgtDbgSignalTracePoint(BYTE bTracePointNumber_p); +void PUBLIC TgtDbgPostTraceValue(DWORD dwTraceValue_p); +#define TGT_DBG_SIGNAL_TRACE_POINT(p) TgtDbgSignalTracePoint(p) +#define TGT_DBG_POST_TRACE_VALUE(v) TgtDbgPostTraceValue(v) #else - #define TGT_DBG_SIGNAL_TRACE_POINT(p) - #define TGT_DBG_POST_TRACE_VALUE(v) +#define TGT_DBG_SIGNAL_TRACE_POINT(p) +#define TGT_DBG_POST_TRACE_VALUE(v) #endif //--------------------------------------------------------------------------- // local types //--------------------------------------------------------------------------- -typedef struct -{ +typedef struct { #ifndef EPL_NO_FIFO - tShbInstance m_pShbKernelToUserInstance; - tShbInstance m_pShbUserToKernelInstance; + tShbInstance m_pShbKernelToUserInstance; + tShbInstance m_pShbUserToKernelInstance; #else #endif - tEplSyncCb m_pfnCbSync; - unsigned int m_uiUserToKernelFullCount; + tEplSyncCb m_pfnCbSync; + unsigned int m_uiUserToKernelFullCount; } tEplEventkInstance; @@ -136,9 +135,8 @@ static tEplEventkInstance EplEventkInstance_g; // callback function for incoming events #ifndef EPL_NO_FIFO -static void EplEventkRxSignalHandlerCb ( - tShbInstance pShbRxInstance_p, - unsigned long ulDataSize_p); +static void EplEventkRxSignalHandlerCb(tShbInstance pShbRxInstance_p, + unsigned long ulDataSize_p); #endif /***************************************************************************/ @@ -176,15 +174,14 @@ static void EplEventkRxSignalHandlerCb ( tEplKernel PUBLIC EplEventkInit(tEplSyncCb pfnCbSync_p) { -tEplKernel Ret; + tEplKernel Ret; - Ret = EplEventkAddInstance(pfnCbSync_p); + Ret = EplEventkAddInstance(pfnCbSync_p); - return Ret; + return Ret; } - //--------------------------------------------------------------------------- // // Function: EplEventkAddInstance @@ -201,65 +198,69 @@ tEplKernel Ret; tEplKernel PUBLIC EplEventkAddInstance(tEplSyncCb pfnCbSync_p) { -tEplKernel Ret; + tEplKernel Ret; #ifndef EPL_NO_FIFO -tShbError ShbError; -unsigned int fShbNewCreated; + tShbError ShbError; + unsigned int fShbNewCreated; #endif - Ret = kEplSuccessful; + Ret = kEplSuccessful; - // init instance structure - EplEventkInstance_g.m_uiUserToKernelFullCount = 0; + // init instance structure + EplEventkInstance_g.m_uiUserToKernelFullCount = 0; - // save cb-function - EplEventkInstance_g.m_pfnCbSync = pfnCbSync_p; + // save cb-function + EplEventkInstance_g.m_pfnCbSync = pfnCbSync_p; #ifndef EPL_NO_FIFO - // init shared loop buffer - // kernel -> user - ShbError = ShbCirAllocBuffer (EPL_EVENT_SIZE_SHB_KERNEL_TO_USER, - EPL_EVENT_NAME_SHB_KERNEL_TO_USER, - &EplEventkInstance_g.m_pShbKernelToUserInstance, - &fShbNewCreated); - if(ShbError != kShbOk) - { - EPL_DBGLVL_EVENTK_TRACE1("EplEventkAddInstance(): ShbCirAllocBuffer(K2U) -> 0x%X\n", ShbError); - Ret = kEplNoResource; - goto Exit; - } - - // user -> kernel - ShbError = ShbCirAllocBuffer (EPL_EVENT_SIZE_SHB_USER_TO_KERNEL, - EPL_EVENT_NAME_SHB_USER_TO_KERNEL, - &EplEventkInstance_g.m_pShbUserToKernelInstance, - &fShbNewCreated); - if(ShbError != kShbOk) - { - EPL_DBGLVL_EVENTK_TRACE1("EplEventkAddInstance(): ShbCirAllocBuffer(U2K) -> 0x%X\n", ShbError); - Ret = kEplNoResource; - goto Exit; - } - - // register eventhandler - ShbError = ShbCirSetSignalHandlerNewData (EplEventkInstance_g.m_pShbUserToKernelInstance, - EplEventkRxSignalHandlerCb, - kshbPriorityHigh); - if(ShbError != kShbOk) - { - EPL_DBGLVL_EVENTK_TRACE1("EplEventkAddInstance(): ShbCirSetSignalHandlerNewData(U2K) -> 0x%X\n", ShbError); - Ret = kEplNoResource; - goto Exit; - } - -Exit: + // init shared loop buffer + // kernel -> user + ShbError = ShbCirAllocBuffer(EPL_EVENT_SIZE_SHB_KERNEL_TO_USER, + EPL_EVENT_NAME_SHB_KERNEL_TO_USER, + &EplEventkInstance_g. + m_pShbKernelToUserInstance, + &fShbNewCreated); + if (ShbError != kShbOk) { + EPL_DBGLVL_EVENTK_TRACE1 + ("EplEventkAddInstance(): ShbCirAllocBuffer(K2U) -> 0x%X\n", + ShbError); + Ret = kEplNoResource; + goto Exit; + } + // user -> kernel + ShbError = ShbCirAllocBuffer(EPL_EVENT_SIZE_SHB_USER_TO_KERNEL, + EPL_EVENT_NAME_SHB_USER_TO_KERNEL, + &EplEventkInstance_g. + m_pShbUserToKernelInstance, + &fShbNewCreated); + if (ShbError != kShbOk) { + EPL_DBGLVL_EVENTK_TRACE1 + ("EplEventkAddInstance(): ShbCirAllocBuffer(U2K) -> 0x%X\n", + ShbError); + Ret = kEplNoResource; + goto Exit; + } + // register eventhandler + ShbError = + ShbCirSetSignalHandlerNewData(EplEventkInstance_g. + m_pShbUserToKernelInstance, + EplEventkRxSignalHandlerCb, + kshbPriorityHigh); + if (ShbError != kShbOk) { + EPL_DBGLVL_EVENTK_TRACE1 + ("EplEventkAddInstance(): ShbCirSetSignalHandlerNewData(U2K) -> 0x%X\n", + ShbError); + Ret = kEplNoResource; + goto Exit; + } + + Exit: #endif - return Ret; + return Ret; } - //--------------------------------------------------------------------------- // // Function: EplEventkDelInstance @@ -276,54 +277,54 @@ Exit: tEplKernel PUBLIC EplEventkDelInstance() { -tEplKernel Ret; + tEplKernel Ret; #ifndef EPL_NO_FIFO -tShbError ShbError; + tShbError ShbError; #endif - Ret = kEplSuccessful; + Ret = kEplSuccessful; #ifndef EPL_NO_FIFO - // set eventhandler to NULL - ShbError = ShbCirSetSignalHandlerNewData (EplEventkInstance_g.m_pShbUserToKernelInstance, - NULL, - kShbPriorityNormal); - if(ShbError != kShbOk) - { - EPL_DBGLVL_EVENTK_TRACE1("EplEventkDelInstance(): ShbCirSetSignalHandlerNewData(U2K) -> 0x%X\n", ShbError); - Ret = kEplNoResource; - } - - // free buffer User -> Kernel - ShbError = ShbCirReleaseBuffer (EplEventkInstance_g.m_pShbUserToKernelInstance); - if(ShbError != kShbOk) - { - EPL_DBGLVL_EVENTK_TRACE1("EplEventkDelInstance(): ShbCirReleaseBuffer(U2K) -> 0x%X\n", ShbError); - Ret = kEplNoResource; - } - else - { - EplEventkInstance_g.m_pShbUserToKernelInstance = NULL; - } - - // free buffer Kernel -> User - ShbError = ShbCirReleaseBuffer (EplEventkInstance_g.m_pShbKernelToUserInstance); - if(ShbError != kShbOk) - { - EPL_DBGLVL_EVENTK_TRACE1("EplEventkDelInstance(): ShbCirReleaseBuffer(K2U) -> 0x%X\n", ShbError); - Ret = kEplNoResource; - } - else - { - EplEventkInstance_g.m_pShbKernelToUserInstance = NULL; - } + // set eventhandler to NULL + ShbError = + ShbCirSetSignalHandlerNewData(EplEventkInstance_g. + m_pShbUserToKernelInstance, NULL, + kShbPriorityNormal); + if (ShbError != kShbOk) { + EPL_DBGLVL_EVENTK_TRACE1 + ("EplEventkDelInstance(): ShbCirSetSignalHandlerNewData(U2K) -> 0x%X\n", + ShbError); + Ret = kEplNoResource; + } + // free buffer User -> Kernel + ShbError = + ShbCirReleaseBuffer(EplEventkInstance_g.m_pShbUserToKernelInstance); + if (ShbError != kShbOk) { + EPL_DBGLVL_EVENTK_TRACE1 + ("EplEventkDelInstance(): ShbCirReleaseBuffer(U2K) -> 0x%X\n", + ShbError); + Ret = kEplNoResource; + } else { + EplEventkInstance_g.m_pShbUserToKernelInstance = NULL; + } + + // free buffer Kernel -> User + ShbError = + ShbCirReleaseBuffer(EplEventkInstance_g.m_pShbKernelToUserInstance); + if (ShbError != kShbOk) { + EPL_DBGLVL_EVENTK_TRACE1 + ("EplEventkDelInstance(): ShbCirReleaseBuffer(K2U) -> 0x%X\n", + ShbError); + Ret = kEplNoResource; + } else { + EplEventkInstance_g.m_pShbKernelToUserInstance = NULL; + } #endif -return Ret; + return Ret; } - //--------------------------------------------------------------------------- // // Function: EplEventkProcess @@ -338,227 +339,215 @@ return Ret; // //--------------------------------------------------------------------------- -tEplKernel PUBLIC EplEventkProcess(tEplEvent* pEvent_p) +tEplKernel PUBLIC EplEventkProcess(tEplEvent * pEvent_p) { -tEplKernel Ret; -tEplEventSource EventSource; + tEplKernel Ret; + tEplEventSource EventSource; - Ret = kEplSuccessful; + Ret = kEplSuccessful; - // error handling if event queue is full - if (EplEventkInstance_g.m_uiUserToKernelFullCount > 0) - { // UserToKernel event queue has run out of space -> kEplNmtEventInternComError + // error handling if event queue is full + if (EplEventkInstance_g.m_uiUserToKernelFullCount > 0) { // UserToKernel event queue has run out of space -> kEplNmtEventInternComError #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0) - tEplEvent Event; - tEplNmtEvent NmtEvent; + tEplEvent Event; + tEplNmtEvent NmtEvent; #endif #ifndef EPL_NO_FIFO - tShbError ShbError; + tShbError ShbError; #endif - // directly call NMTk process function, because event queue is full + // directly call NMTk process function, because event queue is full #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0) - NmtEvent = kEplNmtEventInternComError; - Event.m_EventSink = kEplEventSinkNmtk; - Event.m_NetTime.m_dwNanoSec = 0; - Event.m_NetTime.m_dwSec = 0; - Event.m_EventType = kEplEventTypeNmtEvent; - Event.m_pArg = &NmtEvent; - Event.m_uiSize = sizeof(NmtEvent); - Ret = EplNmtkProcess(&Event); + NmtEvent = kEplNmtEventInternComError; + Event.m_EventSink = kEplEventSinkNmtk; + Event.m_NetTime.m_dwNanoSec = 0; + Event.m_NetTime.m_dwSec = 0; + Event.m_EventType = kEplEventTypeNmtEvent; + Event.m_pArg = &NmtEvent; + Event.m_uiSize = sizeof(NmtEvent); + Ret = EplNmtkProcess(&Event); #endif - // NMT state machine changed to reset (i.e. NMT_GS_RESET_COMMUNICATION) - // now, it is safe to reset the counter and empty the event queue + // NMT state machine changed to reset (i.e. NMT_GS_RESET_COMMUNICATION) + // now, it is safe to reset the counter and empty the event queue #ifndef EPL_NO_FIFO - ShbError = ShbCirResetBuffer (EplEventkInstance_g.m_pShbUserToKernelInstance, 1000, NULL); + ShbError = + ShbCirResetBuffer(EplEventkInstance_g. + m_pShbUserToKernelInstance, 1000, NULL); #endif - EplEventkInstance_g.m_uiUserToKernelFullCount = 0; - TGT_DBG_SIGNAL_TRACE_POINT(22); - - // also discard the current event (it doesn't matter if we lose another event) - goto Exit; - } - - // check m_EventSink - switch(pEvent_p->m_EventSink) - { - case kEplEventSinkSync: - { - if (EplEventkInstance_g.m_pfnCbSync != NULL) - { - Ret = EplEventkInstance_g.m_pfnCbSync(); - if (Ret == kEplSuccessful) - { + EplEventkInstance_g.m_uiUserToKernelFullCount = 0; + TGT_DBG_SIGNAL_TRACE_POINT(22); + + // also discard the current event (it doesn't matter if we lose another event) + goto Exit; + } + // check m_EventSink + switch (pEvent_p->m_EventSink) { + case kEplEventSinkSync: + { + if (EplEventkInstance_g.m_pfnCbSync != NULL) { + Ret = EplEventkInstance_g.m_pfnCbSync(); + if (Ret == kEplSuccessful) { #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0) - // mark TPDOs as valid - Ret = EplPdokCalSetTpdosValid(TRUE); + // mark TPDOs as valid + Ret = EplPdokCalSetTpdosValid(TRUE); #endif - } - else if ((Ret != kEplReject) && (Ret != kEplShutdown)) - { - EventSource = kEplEventSourceSyncCb; - - // Error event for API layer - EplEventkPostError(kEplEventSourceEventk, - Ret, - sizeof(EventSource), - &EventSource); - } - } - break; - } - - // NMT-Kernel-Modul - case kEplEventSinkNmtk: - { + } else if ((Ret != kEplReject) + && (Ret != kEplShutdown)) { + EventSource = kEplEventSourceSyncCb; + + // Error event for API layer + EplEventkPostError + (kEplEventSourceEventk, Ret, + sizeof(EventSource), &EventSource); + } + } + break; + } + + // NMT-Kernel-Modul + case kEplEventSinkNmtk: + { #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0) - Ret = EplNmtkProcess(pEvent_p); - if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) - { - EventSource = kEplEventSourceNmtk; - - // Error event for API layer - EplEventkPostError(kEplEventSourceEventk, - Ret, - sizeof(EventSource), - &EventSource); - } + Ret = EplNmtkProcess(pEvent_p); + if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { + EventSource = kEplEventSourceNmtk; + + // Error event for API layer + EplEventkPostError(kEplEventSourceEventk, + Ret, + sizeof(EventSource), + &EventSource); + } #endif #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0) - if ((pEvent_p->m_EventType == kEplEventTypeNmtEvent) - && ((*((tEplNmtEvent*)pEvent_p->m_pArg) == kEplNmtEventDllCeSoa) + if ((pEvent_p->m_EventType == kEplEventTypeNmtEvent) + && + ((*((tEplNmtEvent *) pEvent_p->m_pArg) == + kEplNmtEventDllCeSoa) #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0) - || (*((tEplNmtEvent*)pEvent_p->m_pArg) == kEplNmtEventDllMeSoaSent) + || (*((tEplNmtEvent *) pEvent_p->m_pArg) == + kEplNmtEventDllMeSoaSent) #endif - )) - { // forward SoA event to error handler - Ret = EplErrorHandlerkProcess(pEvent_p); - if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) - { - EventSource = kEplEventSourceErrk; - - // Error event for API layer - EplEventkPostError(kEplEventSourceEventk, - Ret, - sizeof(EventSource), - &EventSource); - } - + )) { // forward SoA event to error handler + Ret = EplErrorHandlerkProcess(pEvent_p); + if ((Ret != kEplSuccessful) + && (Ret != kEplShutdown)) { + EventSource = kEplEventSourceErrk; + + // Error event for API layer + EplEventkPostError + (kEplEventSourceEventk, Ret, + sizeof(EventSource), &EventSource); + } #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0) - // forward SoA event to PDO module - pEvent_p->m_EventType = kEplEventTypePdoSoa; - Ret = EplPdokProcess(pEvent_p); - if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) - { - EventSource = kEplEventSourcePdok; - - // Error event for API layer - EplEventkPostError(kEplEventSourceEventk, - Ret, - sizeof(EventSource), - &EventSource); - } + // forward SoA event to PDO module + pEvent_p->m_EventType = kEplEventTypePdoSoa; + Ret = EplPdokProcess(pEvent_p); + if ((Ret != kEplSuccessful) + && (Ret != kEplShutdown)) { + EventSource = kEplEventSourcePdok; + + // Error event for API layer + EplEventkPostError + (kEplEventSourceEventk, Ret, + sizeof(EventSource), &EventSource); + } #endif - } - break; + } + break; #endif - } + } - // events for Dllk module - case kEplEventSinkDllk: - { + // events for Dllk module + case kEplEventSinkDllk: + { #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0) - Ret = EplDllkProcess(pEvent_p); - if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) - { - EventSource = kEplEventSourceDllk; - - // Error event for API layer - EplEventkPostError(kEplEventSourceEventk, - Ret, - sizeof(EventSource), - &EventSource); - } + Ret = EplDllkProcess(pEvent_p); + if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { + EventSource = kEplEventSourceDllk; + + // Error event for API layer + EplEventkPostError(kEplEventSourceEventk, + Ret, + sizeof(EventSource), + &EventSource); + } #endif - break; - } + break; + } - // events for DllkCal module - case kEplEventSinkDllkCal: - { + // events for DllkCal module + case kEplEventSinkDllkCal: + { #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0) - Ret = EplDllkCalProcess(pEvent_p); - if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) - { - EventSource = kEplEventSourceDllk; - - // Error event for API layer - EplEventkPostError(kEplEventSourceEventk, - Ret, - sizeof(EventSource), - &EventSource); - } + Ret = EplDllkCalProcess(pEvent_p); + if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { + EventSource = kEplEventSourceDllk; + + // Error event for API layer + EplEventkPostError(kEplEventSourceEventk, + Ret, + sizeof(EventSource), + &EventSource); + } #endif - break; - } + break; + } - // - case kEplEventSinkPdok: - { - // PDO-Module + // + case kEplEventSinkPdok: + { + // PDO-Module #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_PDOK)) != 0) - Ret = EplPdokProcess(pEvent_p); - if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) - { - EventSource = kEplEventSourcePdok; - - // Error event for API layer - EplEventkPostError(kEplEventSourceEventk, - Ret, - sizeof(EventSource), - &EventSource); - } + Ret = EplPdokProcess(pEvent_p); + if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { + EventSource = kEplEventSourcePdok; + + // Error event for API layer + EplEventkPostError(kEplEventSourceEventk, + Ret, + sizeof(EventSource), + &EventSource); + } #endif - break; - } + break; + } - // events for Error handler module - case kEplEventSinkErrk: - { - // only call error handler if DLL is present + // events for Error handler module + case kEplEventSinkErrk: + { + // only call error handler if DLL is present #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0) - Ret = EplErrorHandlerkProcess(pEvent_p); - if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) - { - EventSource = kEplEventSourceErrk; - - // Error event for API layer - EplEventkPostError(kEplEventSourceEventk, - Ret, - sizeof(EventSource), - &EventSource); - } - break; + Ret = EplErrorHandlerkProcess(pEvent_p); + if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) { + EventSource = kEplEventSourceErrk; + + // Error event for API layer + EplEventkPostError(kEplEventSourceEventk, + Ret, + sizeof(EventSource), + &EventSource); + } + break; #endif - } + } - // unknown sink - default: - { - Ret = kEplEventUnknownSink; - } + // unknown sink + default: + { + Ret = kEplEventUnknownSink; + } - } // end of switch(pEvent_p->m_EventSink) + } // end of switch(pEvent_p->m_EventSink) -Exit: - return Ret; + Exit: + return Ret; } - //--------------------------------------------------------------------------- // // Function: EplEventkPost @@ -575,165 +564,180 @@ Exit: tEplKernel PUBLIC EplEventkPost(tEplEvent * pEvent_p) { -tEplKernel Ret; + tEplKernel Ret; #ifndef EPL_NO_FIFO -tShbError ShbError; -tShbCirChunk ShbCirChunk; -unsigned long ulDataSize; -unsigned int fBufferCompleted; + tShbError ShbError; + tShbCirChunk ShbCirChunk; + unsigned long ulDataSize; + unsigned int fBufferCompleted; #endif - Ret = kEplSuccessful; + 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 + // 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 #ifndef EPL_NO_FIFO - // 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); + // 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 kEplEventSinkErrk: - { + // 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 kEplEventSinkErrk: + { #ifndef EPL_NO_FIFO - // post message - BENCHMARK_MOD_27_SET(2); - ShbError = ShbCirAllocDataBlock (EplEventkInstance_g.m_pShbUserToKernelInstance, - &ShbCirChunk, - ulDataSize); - switch (ShbError) - { - case kShbOk: - break; - - case kShbBufferFull: - { - EplEventkInstance_g.m_uiUserToKernelFullCount++; - Ret = kEplEventPostError; - goto Exit; - } - - default: - { - EPL_DBGLVL_EVENTK_TRACE1("EplEventkPost(): ShbCirAllocDataBlock(U2K) -> 0x%X\n", ShbError); - Ret = kEplEventPostError; - goto Exit; - } - } - ShbError = ShbCirWriteDataChunk (EplEventkInstance_g.m_pShbUserToKernelInstance, - &ShbCirChunk, - pEvent_p, - sizeof (tEplEvent), - &fBufferCompleted); - if (ShbError != kShbOk) - { - EPL_DBGLVL_EVENTK_TRACE1("EplEventkPost(): ShbCirWriteDataChunk(U2K) -> 0x%X\n", ShbError); - Ret = kEplEventPostError; - goto Exit; - } - if (fBufferCompleted == FALSE) - { - ShbError = ShbCirWriteDataChunk (EplEventkInstance_g.m_pShbUserToKernelInstance, - &ShbCirChunk, - pEvent_p->m_pArg, - (unsigned long) pEvent_p->m_uiSize, - &fBufferCompleted); - if ((ShbError != kShbOk) || (fBufferCompleted == FALSE)) - { - EPL_DBGLVL_EVENTK_TRACE1("EplEventkPost(): ShbCirWriteDataChunk2(U2K) -> 0x%X\n", ShbError); - Ret = kEplEventPostError; - goto Exit; - } - } - BENCHMARK_MOD_27_RESET(2); + // post message + BENCHMARK_MOD_27_SET(2); + ShbError = + ShbCirAllocDataBlock(EplEventkInstance_g. + m_pShbUserToKernelInstance, + &ShbCirChunk, ulDataSize); + switch (ShbError) { + case kShbOk: + break; + + case kShbBufferFull: + { + EplEventkInstance_g. + m_uiUserToKernelFullCount++; + Ret = kEplEventPostError; + goto Exit; + } + + default: + { + EPL_DBGLVL_EVENTK_TRACE1 + ("EplEventkPost(): ShbCirAllocDataBlock(U2K) -> 0x%X\n", + ShbError); + Ret = kEplEventPostError; + goto Exit; + } + } + ShbError = + ShbCirWriteDataChunk(EplEventkInstance_g. + m_pShbUserToKernelInstance, + &ShbCirChunk, pEvent_p, + sizeof(tEplEvent), + &fBufferCompleted); + if (ShbError != kShbOk) { + EPL_DBGLVL_EVENTK_TRACE1 + ("EplEventkPost(): ShbCirWriteDataChunk(U2K) -> 0x%X\n", + ShbError); + Ret = kEplEventPostError; + goto Exit; + } + if (fBufferCompleted == FALSE) { + ShbError = + ShbCirWriteDataChunk(EplEventkInstance_g. + m_pShbUserToKernelInstance, + &ShbCirChunk, + pEvent_p->m_pArg, + (unsigned long) + pEvent_p->m_uiSize, + &fBufferCompleted); + if ((ShbError != kShbOk) + || (fBufferCompleted == FALSE)) { + EPL_DBGLVL_EVENTK_TRACE1 + ("EplEventkPost(): ShbCirWriteDataChunk2(U2K) -> 0x%X\n", + ShbError); + Ret = kEplEventPostError; + goto Exit; + } + } + BENCHMARK_MOD_27_RESET(2); #else - Ret = EplEventkProcess(pEvent_p); + Ret = EplEventkProcess(pEvent_p); #endif - break; - } - - // userspace modules - case kEplEventSinkNmtu: - case kEplEventSinkNmtMnu: - case kEplEventSinkSdoAsySeq: - case kEplEventSinkApi: - case kEplEventSinkDlluCal: - case kEplEventSinkErru: - { + break; + } + + // userspace modules + case kEplEventSinkNmtu: + case kEplEventSinkNmtMnu: + case kEplEventSinkSdoAsySeq: + case kEplEventSinkApi: + case kEplEventSinkDlluCal: + case kEplEventSinkErru: + { #ifndef EPL_NO_FIFO - // post message + // 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_TRACE1("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_TRACE1("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_TRACE1("EplEventkPost(): ShbCirWriteDataChunk2(K2U) -> 0x%X\n", ShbError); - Ret = kEplEventPostError; - goto Exit; - } - } + ShbError = + ShbCirAllocDataBlock(EplEventkInstance_g. + m_pShbKernelToUserInstance, + &ShbCirChunk, ulDataSize); + if (ShbError != kShbOk) { + EPL_DBGLVL_EVENTK_TRACE1 + ("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_TRACE1 + ("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_TRACE1 + ("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); + Ret = EplEventuProcess(pEvent_p); #endif - break; - } - - default: - { - Ret = kEplEventUnknownSink; - } + break; + } + default: + { + Ret = kEplEventUnknownSink; + } - }// end of switch(pEvent_p->m_EventSink) + } // end of switch(pEvent_p->m_EventSink) #ifndef EPL_NO_FIFO -Exit: + Exit: #endif - return Ret; + return Ret; } - //--------------------------------------------------------------------------- // // Function: EplEventkPostError @@ -752,36 +756,35 @@ Exit: //--------------------------------------------------------------------------- tEplKernel PUBLIC EplEventkPostError(tEplEventSource EventSource_p, - tEplKernel EplError_p, - unsigned int uiArgSize_p, - void* pArg_p) + tEplKernel EplError_p, + unsigned int uiArgSize_p, void *pArg_p) { -tEplKernel Ret; -BYTE abBuffer[EPL_MAX_EVENT_ARG_SIZE]; -tEplEventError* pEventError = (tEplEventError*) abBuffer; -tEplEvent EplEvent; - - Ret = kEplSuccessful; - - // create argument - pEventError->m_EventSource = EventSource_p; - pEventError->m_EplError = EplError_p; - EPL_MEMCPY(&pEventError->m_Arg, pArg_p, uiArgSize_p); - - // create event - EplEvent.m_EventType = kEplEventTypeError; - EplEvent.m_EventSink = kEplEventSinkApi; - EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(EplEvent.m_NetTime)); - EplEvent.m_uiSize = (sizeof(EventSource_p)+ sizeof(EplError_p)+ uiArgSize_p); - EplEvent.m_pArg = &abBuffer[0]; - - // post errorevent - Ret = EplEventkPost(&EplEvent); - - return Ret; + tEplKernel Ret; + BYTE abBuffer[EPL_MAX_EVENT_ARG_SIZE]; + tEplEventError *pEventError = (tEplEventError *) abBuffer; + tEplEvent EplEvent; + + Ret = kEplSuccessful; + + // create argument + pEventError->m_EventSource = EventSource_p; + pEventError->m_EplError = EplError_p; + EPL_MEMCPY(&pEventError->m_Arg, pArg_p, uiArgSize_p); + + // create event + EplEvent.m_EventType = kEplEventTypeError; + EplEvent.m_EventSink = kEplEventSinkApi; + EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(EplEvent.m_NetTime)); + EplEvent.m_uiSize = + (sizeof(EventSource_p) + sizeof(EplError_p) + uiArgSize_p); + EplEvent.m_pArg = &abBuffer[0]; + + // post errorevent + Ret = EplEventkPost(&EplEvent); + + return Ret; } - //=========================================================================// // // // P R I V A T E F U N C T I O N S // @@ -804,55 +807,47 @@ tEplEvent EplEvent; //--------------------------------------------------------------------------- #ifndef EPL_NO_FIFO -static void EplEventkRxSignalHandlerCb ( - tShbInstance pShbRxInstance_p, - unsigned long ulDataSize_p) +static void EplEventkRxSignalHandlerCb(tShbInstance pShbRxInstance_p, + unsigned long ulDataSize_p) { -tEplEvent *pEplEvent; -tShbError ShbError; + tEplEvent *pEplEvent; + tShbError ShbError; //unsigned long ulBlockCount; //unsigned long ulDataSize; -BYTE abDataBuffer[sizeof(tEplEvent) + EPL_MAX_EVENT_ARG_SIZE]; - // d.k.: abDataBuffer contains the complete tEplEvent structure - // and behind this the argument - - TGT_DBG_SIGNAL_TRACE_POINT(20); - - BENCHMARK_MOD_27_RESET(0); - // copy data from event queue - ShbError = ShbCirReadDataBlock (pShbRxInstance_p, - &abDataBuffer[0], - sizeof(abDataBuffer), - &ulDataSize_p); - if(ShbError != kShbOk) - { - // error goto exit - goto Exit; - } - - // resolve the pointer to the event structure - pEplEvent = (tEplEvent *) abDataBuffer; - // set Datasize - pEplEvent->m_uiSize = (ulDataSize_p - sizeof(tEplEvent)); - if(pEplEvent->m_uiSize > 0) - { - // set pointer to argument - pEplEvent->m_pArg = &abDataBuffer[sizeof(tEplEvent)]; - } - else - { - //set pointer to NULL - pEplEvent->m_pArg = NULL; - } - - BENCHMARK_MOD_27_SET(0); - // call processfunction - EplEventkProcess(pEplEvent); - -Exit: - return; + BYTE abDataBuffer[sizeof(tEplEvent) + EPL_MAX_EVENT_ARG_SIZE]; + // d.k.: abDataBuffer contains the complete tEplEvent structure + // and behind this the argument + + TGT_DBG_SIGNAL_TRACE_POINT(20); + + BENCHMARK_MOD_27_RESET(0); + // copy data from event queue + ShbError = ShbCirReadDataBlock(pShbRxInstance_p, + &abDataBuffer[0], + sizeof(abDataBuffer), &ulDataSize_p); + if (ShbError != kShbOk) { + // error goto exit + goto Exit; + } + // resolve the pointer to the event structure + pEplEvent = (tEplEvent *) abDataBuffer; + // set Datasize + pEplEvent->m_uiSize = (ulDataSize_p - sizeof(tEplEvent)); + if (pEplEvent->m_uiSize > 0) { + // set pointer to argument + pEplEvent->m_pArg = &abDataBuffer[sizeof(tEplEvent)]; + } else { + //set pointer to NULL + pEplEvent->m_pArg = NULL; + } + + BENCHMARK_MOD_27_SET(0); + // call processfunction + EplEventkProcess(pEplEvent); + + Exit: + return; } #endif // EOF - |