Merge branch 'for-linus' of git://oss.sgi.com/xfs/xfs
[linux-2.6] / drivers / staging / epl / EplEventu.c
1 /****************************************************************************
2
3   (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4       www.systec-electronic.com
5
6   Project:      openPOWERLINK
7
8   Description:  source file for Epl-Userspace-Event-Modul
9
10   License:
11
12     Redistribution and use in source and binary forms, with or without
13     modification, are permitted provided that the following conditions
14     are met:
15
16     1. Redistributions of source code must retain the above copyright
17        notice, this list of conditions and the following disclaimer.
18
19     2. Redistributions in binary form must reproduce the above copyright
20        notice, this list of conditions and the following disclaimer in the
21        documentation and/or other materials provided with the distribution.
22
23     3. Neither the name of SYSTEC electronic GmbH nor the names of its
24        contributors may be used to endorse or promote products derived
25        from this software without prior written permission. For written
26        permission, please contact info@systec-electronic.com.
27
28     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
31     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
32     COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
33     INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
36     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
38     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39     POSSIBILITY OF SUCH DAMAGE.
40
41     Severability Clause:
42
43         If a provision of this License is or becomes illegal, invalid or
44         unenforceable in any jurisdiction, that shall not affect:
45         1. the validity or enforceability in that jurisdiction of any other
46            provision of this License; or
47         2. the validity or enforceability in other jurisdictions of that or
48            any other provision of this License.
49
50   -------------------------------------------------------------------------
51
52                 $RCSfile: EplEventu.c,v $
53
54                 $Author: D.Krueger $
55
56                 $Revision: 1.8 $  $Date: 2008/11/17 16:40:39 $
57
58                 $State: Exp $
59
60                 Build Environment:
61                     GCC V3.4
62
63   -------------------------------------------------------------------------
64
65   Revision History:
66
67   2006/06/20 k.t.:   start of the implementation
68
69 ****************************************************************************/
70
71 #include "user/EplEventu.h"
72 #include "user/EplNmtu.h"
73 #include "user/EplNmtMnu.h"
74 #include "user/EplSdoAsySequ.h"
75 #include "user/EplDlluCal.h"
76 #include "user/EplLedu.h"
77 #include "Benchmark.h"
78
79 #ifdef EPL_NO_FIFO
80 #include "kernel/EplEventk.h"
81 #else
82 #include "SharedBuff.h"
83 #endif
84
85 /***************************************************************************/
86 /*                                                                         */
87 /*                                                                         */
88 /*          G L O B A L   D E F I N I T I O N S                            */
89 /*                                                                         */
90 /*                                                                         */
91 /***************************************************************************/
92
93 //---------------------------------------------------------------------------
94 // const defines
95 //---------------------------------------------------------------------------
96
97 // TracePoint support for realtime-debugging
98 #ifdef _DBG_TRACE_POINTS_
99 void TgtDbgSignalTracePoint(u8 bTracePointNumber_p);
100 void TgtDbgPostTraceValue(u32 dwTraceValue_p);
101 #define TGT_DBG_SIGNAL_TRACE_POINT(p)   TgtDbgSignalTracePoint(p)
102 #define TGT_DBG_POST_TRACE_VALUE(v)     TgtDbgPostTraceValue(v)
103 #else
104 #define TGT_DBG_SIGNAL_TRACE_POINT(p)
105 #define TGT_DBG_POST_TRACE_VALUE(v)
106 #endif
107
108 //---------------------------------------------------------------------------
109 // local types
110 //---------------------------------------------------------------------------
111
112 typedef struct {
113 #ifndef EPL_NO_FIFO
114         tShbInstance m_pShbKernelToUserInstance;
115         tShbInstance m_pShbUserToKernelInstance;
116 #endif
117         tEplProcessEventCb m_pfnApiProcessEventCb;
118
119 } tEplEventuInstance;
120
121 //---------------------------------------------------------------------------
122 // modul globale vars
123 //---------------------------------------------------------------------------
124
125 //#ifndef EPL_NO_FIFO
126 static tEplEventuInstance EplEventuInstance_g;
127 //#endif
128
129 //---------------------------------------------------------------------------
130 // local function prototypes
131 //---------------------------------------------------------------------------
132
133 #ifndef EPL_NO_FIFO
134 // callback function for incomming events
135 static void EplEventuRxSignalHandlerCb(tShbInstance pShbRxInstance_p,
136                                        unsigned long ulDataSize_p);
137 #endif
138
139 /***************************************************************************/
140 /*                                                                         */
141 /*                                                                         */
142 /*          C L A S S  <Epl-User-Event>                                    */
143 /*                                                                         */
144 /*                                                                         */
145 /***************************************************************************/
146 //
147 // Description:
148 //
149 //
150 /***************************************************************************/
151
152 //=========================================================================//
153 //                                                                         //
154 //          P U B L I C   F U N C T I O N S                                //
155 //                                                                         //
156 //=========================================================================//
157
158 //---------------------------------------------------------------------------
159 //
160 // Function:    EplEventuInit
161 //
162 // Description: function initialize the first instance
163 //
164 //
165 //
166 // Parameters:  pfnApiProcessEventCb_p  = function pointer for API event callback
167 //
168 //
169 // Returns:      tEpKernel  = errorcode
170 //
171 //
172 // State:
173 //
174 //---------------------------------------------------------------------------
175 tEplKernel EplEventuInit(tEplProcessEventCb pfnApiProcessEventCb_p)
176 {
177         tEplKernel Ret;
178
179         Ret = EplEventuAddInstance(pfnApiProcessEventCb_p);
180
181         return Ret;
182
183 }
184
185 //---------------------------------------------------------------------------
186 //
187 // Function:    EplEventuAddInstance
188 //
189 // Description: function add one more instance
190 //
191 //
192 //
193 // Parameters:  pfnApiProcessEventCb_p  = function pointer for API event callback
194 //
195 //
196 // Returns:      tEpKernel  = errorcode
197 //
198 //
199 // State:
200 //
201 //---------------------------------------------------------------------------
202 tEplKernel EplEventuAddInstance(tEplProcessEventCb pfnApiProcessEventCb_p)
203 {
204         tEplKernel Ret;
205 #ifndef EPL_NO_FIFO
206         tShbError ShbError;
207         unsigned int fShbNewCreated;
208 #endif
209
210         Ret = kEplSuccessful;
211
212         // init instance variables
213         EplEventuInstance_g.m_pfnApiProcessEventCb = pfnApiProcessEventCb_p;
214
215 #ifndef EPL_NO_FIFO
216         // init shared loop buffer
217         // kernel -> user
218         ShbError = ShbCirAllocBuffer(EPL_EVENT_SIZE_SHB_KERNEL_TO_USER,
219                                      EPL_EVENT_NAME_SHB_KERNEL_TO_USER,
220                                      &EplEventuInstance_g.
221                                      m_pShbKernelToUserInstance,
222                                      &fShbNewCreated);
223         if (ShbError != kShbOk) {
224                 EPL_DBGLVL_EVENTK_TRACE1
225                     ("EplEventuAddInstance(): ShbCirAllocBuffer(K2U) -> 0x%X\n",
226                      ShbError);
227                 Ret = kEplNoResource;
228                 goto Exit;
229         }
230
231         // user -> kernel
232         ShbError = ShbCirAllocBuffer(EPL_EVENT_SIZE_SHB_USER_TO_KERNEL,
233                                      EPL_EVENT_NAME_SHB_USER_TO_KERNEL,
234                                      &EplEventuInstance_g.
235                                      m_pShbUserToKernelInstance,
236                                      &fShbNewCreated);
237         if (ShbError != kShbOk) {
238                 EPL_DBGLVL_EVENTK_TRACE1
239                     ("EplEventuAddInstance(): ShbCirAllocBuffer(U2K) -> 0x%X\n",
240                      ShbError);
241                 Ret = kEplNoResource;
242                 goto Exit;
243         }
244         // register eventhandler
245         ShbError =
246             ShbCirSetSignalHandlerNewData(EplEventuInstance_g.
247                                           m_pShbKernelToUserInstance,
248                                           EplEventuRxSignalHandlerCb,
249                                           kShbPriorityNormal);
250         if (ShbError != kShbOk) {
251                 EPL_DBGLVL_EVENTK_TRACE1
252                     ("EplEventuAddInstance(): ShbCirSetSignalHandlerNewData(K2U) -> 0x%X\n",
253                      ShbError);
254                 Ret = kEplNoResource;
255                 goto Exit;
256         }
257
258       Exit:
259 #endif
260
261         return Ret;
262
263 }
264
265 //---------------------------------------------------------------------------
266 //
267 // Function:    EplEventuDelInstance
268 //
269 // Description: function delete instance an free the bufferstructure
270 //
271 //
272 //
273 // Parameters:
274 //
275 //
276 // Returns:      tEpKernel  = errorcode
277 //
278 //
279 // State:
280 //
281 //---------------------------------------------------------------------------
282 tEplKernel EplEventuDelInstance(void)
283 {
284         tEplKernel Ret;
285 #ifndef EPL_NO_FIFO
286         tShbError ShbError;
287 #endif
288
289         Ret = kEplSuccessful;
290
291 #ifndef EPL_NO_FIFO
292         // set eventhandler to NULL
293         ShbError =
294             ShbCirSetSignalHandlerNewData(EplEventuInstance_g.
295                                           m_pShbKernelToUserInstance, NULL,
296                                           kShbPriorityNormal);
297         if (ShbError != kShbOk) {
298                 EPL_DBGLVL_EVENTK_TRACE1
299                     ("EplEventuDelInstance(): ShbCirSetSignalHandlerNewData(K2U) -> 0x%X\n",
300                      ShbError);
301                 Ret = kEplNoResource;
302         }
303         // free buffer User -> Kernel
304         ShbError =
305             ShbCirReleaseBuffer(EplEventuInstance_g.m_pShbUserToKernelInstance);
306         if ((ShbError != kShbOk) && (ShbError != kShbMemUsedByOtherProcs)) {
307                 EPL_DBGLVL_EVENTK_TRACE1
308                     ("EplEventuDelInstance(): ShbCirReleaseBuffer(U2K) -> 0x%X\n",
309                      ShbError);
310                 Ret = kEplNoResource;
311         } else {
312                 EplEventuInstance_g.m_pShbUserToKernelInstance = NULL;
313         }
314
315         // free buffer  Kernel -> User
316         ShbError =
317             ShbCirReleaseBuffer(EplEventuInstance_g.m_pShbKernelToUserInstance);
318         if ((ShbError != kShbOk) && (ShbError != kShbMemUsedByOtherProcs)) {
319                 EPL_DBGLVL_EVENTK_TRACE1
320                     ("EplEventuDelInstance(): ShbCirReleaseBuffer(K2U) -> 0x%X\n",
321                      ShbError);
322                 Ret = kEplNoResource;
323         } else {
324                 EplEventuInstance_g.m_pShbKernelToUserInstance = NULL;
325         }
326
327 #endif
328
329         return Ret;
330
331 }
332
333 //---------------------------------------------------------------------------
334 //
335 // Function:    EplEventuProcess
336 //
337 // Description: Kernelthread that dispatches events in kernelspace
338 //
339 //
340 //
341 // Parameters:  pEvent_p = pointer to event-structur from buffer
342 //
343 //
344 // Returns:      tEpKernel  = errorcode
345 //
346 //
347 // State:
348 //
349 //---------------------------------------------------------------------------
350 tEplKernel EplEventuProcess(tEplEvent *pEvent_p)
351 {
352         tEplKernel Ret;
353         tEplEventSource EventSource;
354
355         Ret = kEplSuccessful;
356
357         // check m_EventSink
358         switch (pEvent_p->m_EventSink) {
359                 // NMT-User-Module
360         case kEplEventSinkNmtu:
361                 {
362 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
363                         Ret = EplNmtuProcessEvent(pEvent_p);
364                         if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) {
365                                 EventSource = kEplEventSourceNmtu;
366
367                                 // Error event for API layer
368                                 EplEventuPostError(kEplEventSourceEventu,
369                                                    Ret,
370                                                    sizeof(EventSource),
371                                                    &EventSource);
372                         }
373 #endif
374                         break;
375                 }
376
377 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
378                 // NMT-MN-User-Module
379         case kEplEventSinkNmtMnu:
380                 {
381                         Ret = EplNmtMnuProcessEvent(pEvent_p);
382                         if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) {
383                                 EventSource = kEplEventSourceNmtMnu;
384
385                                 // Error event for API layer
386                                 EplEventuPostError(kEplEventSourceEventu,
387                                                    Ret,
388                                                    sizeof(EventSource),
389                                                    &EventSource);
390                         }
391                         break;
392                 }
393 #endif
394
395 #if ((((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOC)) != 0)   \
396      || (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOS)) != 0))
397                 // events for asynchronus SDO Sequence Layer
398         case kEplEventSinkSdoAsySeq:
399                 {
400                         Ret = EplSdoAsySeqProcessEvent(pEvent_p);
401                         if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) {
402                                 EventSource = kEplEventSourceSdoAsySeq;
403
404                                 // Error event for API layer
405                                 EplEventuPostError(kEplEventSourceEventu,
406                                                    Ret,
407                                                    sizeof(EventSource),
408                                                    &EventSource);
409                         }
410                         break;
411                 }
412 #endif
413
414                 // LED user part module
415         case kEplEventSinkLedu:
416                 {
417 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_LEDU)) != 0)
418                         Ret = EplLeduProcessEvent(pEvent_p);
419                         if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) {
420                                 EventSource = kEplEventSourceLedu;
421
422                                 // Error event for API layer
423                                 EplEventuPostError(kEplEventSourceEventu,
424                                                    Ret,
425                                                    sizeof(EventSource),
426                                                    &EventSource);
427                         }
428 #endif
429                         break;
430                 }
431
432                 // event for EPL api
433         case kEplEventSinkApi:
434                 {
435                         if (EplEventuInstance_g.m_pfnApiProcessEventCb != NULL) {
436                                 Ret =
437                                     EplEventuInstance_g.
438                                     m_pfnApiProcessEventCb(pEvent_p);
439                                 if ((Ret != kEplSuccessful)
440                                     && (Ret != kEplShutdown)) {
441                                         EventSource = kEplEventSourceEplApi;
442
443                                         // Error event for API layer
444                                         EplEventuPostError
445                                             (kEplEventSourceEventu, Ret,
446                                              sizeof(EventSource), &EventSource);
447                                 }
448                         }
449                         break;
450
451                 }
452
453         case kEplEventSinkDlluCal:
454                 {
455                         Ret = EplDlluCalProcess(pEvent_p);
456                         if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) {
457                                 EventSource = kEplEventSourceDllu;
458
459                                 // Error event for API layer
460                                 EplEventuPostError(kEplEventSourceEventu,
461                                                    Ret,
462                                                    sizeof(EventSource),
463                                                    &EventSource);
464                         }
465                         break;
466
467                 }
468
469         case kEplEventSinkErru:
470                 {
471                         /*
472                            Ret = EplErruProcess(pEvent_p);
473                            if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
474                            {
475                            EventSource = kEplEventSourceErru;
476
477                            // Error event for API layer
478                            EplEventuPostError(kEplEventSourceEventu,
479                            Ret,
480                            sizeof(EventSource),
481                            &EventSource);
482                            }
483                          */
484                         break;
485
486                 }
487
488                 // unknown sink
489         default:
490                 {
491                         Ret = kEplEventUnknownSink;
492                 }
493
494         }                       // end of switch(pEvent_p->m_EventSink)
495
496         return Ret;
497
498 }
499
500 //---------------------------------------------------------------------------
501 //
502 // Function:    EplEventuPost
503 //
504 // Description: post events from userspace
505 //
506 //
507 //
508 // Parameters:  pEvent_p = pointer to event-structur from buffer
509 //
510 //
511 // Returns:      tEpKernel  = errorcode
512 //
513 //
514 // State:
515 //
516 //---------------------------------------------------------------------------
517 tEplKernel EplEventuPost(tEplEvent *pEvent_p)
518 {
519         tEplKernel Ret;
520 #ifndef EPL_NO_FIFO
521         tShbError ShbError;
522         tShbCirChunk ShbCirChunk;
523         unsigned long ulDataSize;
524         unsigned int fBufferCompleted;
525 #endif
526
527         Ret = kEplSuccessful;
528
529 #ifndef EPL_NO_FIFO
530         // 2006/08/03 d.k.: Event and argument are posted as separate chunks to the event queue.
531         ulDataSize =
532             sizeof(tEplEvent) +
533             ((pEvent_p->m_pArg != NULL) ? pEvent_p->m_uiSize : 0);
534 #endif
535
536         // decide in which buffer the event have to write
537         switch (pEvent_p->m_EventSink) {
538                 // kernelspace modules
539         case kEplEventSinkSync:
540         case kEplEventSinkNmtk:
541         case kEplEventSinkDllk:
542         case kEplEventSinkDllkCal:
543         case kEplEventSinkPdok:
544         case kEplEventSinkErrk:
545                 {
546 #ifndef EPL_NO_FIFO
547                         // post message
548                         ShbError =
549                             ShbCirAllocDataBlock(EplEventuInstance_g.
550                                                  m_pShbUserToKernelInstance,
551                                                  &ShbCirChunk, ulDataSize);
552                         if (ShbError != kShbOk) {
553                                 EPL_DBGLVL_EVENTK_TRACE1
554                                     ("EplEventuPost(): ShbCirAllocDataBlock(U2K) -> 0x%X\n",
555                                      ShbError);
556                                 Ret = kEplEventPostError;
557                                 goto Exit;
558                         }
559                         ShbError =
560                             ShbCirWriteDataChunk(EplEventuInstance_g.
561                                                  m_pShbUserToKernelInstance,
562                                                  &ShbCirChunk, pEvent_p,
563                                                  sizeof(tEplEvent),
564                                                  &fBufferCompleted);
565                         if (ShbError != kShbOk) {
566                                 EPL_DBGLVL_EVENTK_TRACE1
567                                     ("EplEventuPost(): ShbCirWriteDataChunk(U2K) -> 0x%X\n",
568                                      ShbError);
569                                 Ret = kEplEventPostError;
570                                 goto Exit;
571                         }
572                         if (fBufferCompleted == FALSE) {
573                                 ShbError =
574                                     ShbCirWriteDataChunk(EplEventuInstance_g.
575                                                          m_pShbUserToKernelInstance,
576                                                          &ShbCirChunk,
577                                                          pEvent_p->m_pArg,
578                                                          (unsigned long)
579                                                          pEvent_p->m_uiSize,
580                                                          &fBufferCompleted);
581                                 if ((ShbError != kShbOk)
582                                     || (fBufferCompleted == FALSE)) {
583                                         EPL_DBGLVL_EVENTK_TRACE1
584                                             ("EplEventuPost(): ShbCirWriteDataChunk2(U2K) -> 0x%X\n",
585                                              ShbError);
586                                         Ret = kEplEventPostError;
587                                         goto Exit;
588                                 }
589                         }
590 #else
591                         Ret = EplEventkProcess(pEvent_p);
592 #endif
593
594                         break;
595                 }
596
597                 // userspace modules
598         case kEplEventSinkNmtMnu:
599         case kEplEventSinkNmtu:
600         case kEplEventSinkSdoAsySeq:
601         case kEplEventSinkApi:
602         case kEplEventSinkDlluCal:
603         case kEplEventSinkErru:
604         case kEplEventSinkLedu:
605                 {
606 #ifndef EPL_NO_FIFO
607                         // post message
608                         ShbError =
609                             ShbCirAllocDataBlock(EplEventuInstance_g.
610                                                  m_pShbKernelToUserInstance,
611                                                  &ShbCirChunk, ulDataSize);
612                         if (ShbError != kShbOk) {
613                                 EPL_DBGLVL_EVENTK_TRACE1
614                                     ("EplEventuPost(): ShbCirAllocDataBlock(K2U) -> 0x%X\n",
615                                      ShbError);
616                                 Ret = kEplEventPostError;
617                                 goto Exit;
618                         }
619                         ShbError =
620                             ShbCirWriteDataChunk(EplEventuInstance_g.
621                                                  m_pShbKernelToUserInstance,
622                                                  &ShbCirChunk, pEvent_p,
623                                                  sizeof(tEplEvent),
624                                                  &fBufferCompleted);
625                         if (ShbError != kShbOk) {
626                                 EPL_DBGLVL_EVENTK_TRACE1
627                                     ("EplEventuPost(): ShbCirWriteDataChunk(K2U) -> 0x%X\n",
628                                      ShbError);
629                                 Ret = kEplEventPostError;
630                                 goto Exit;
631                         }
632                         if (fBufferCompleted == FALSE) {
633                                 ShbError =
634                                     ShbCirWriteDataChunk(EplEventuInstance_g.
635                                                          m_pShbKernelToUserInstance,
636                                                          &ShbCirChunk,
637                                                          pEvent_p->m_pArg,
638                                                          (unsigned long)
639                                                          pEvent_p->m_uiSize,
640                                                          &fBufferCompleted);
641                                 if ((ShbError != kShbOk)
642                                     || (fBufferCompleted == FALSE)) {
643                                         EPL_DBGLVL_EVENTK_TRACE1
644                                             ("EplEventuPost(): ShbCirWriteDataChunk2(K2U) -> 0x%X\n",
645                                              ShbError);
646                                         Ret = kEplEventPostError;
647                                         goto Exit;
648                                 }
649                         }
650 #else
651                         Ret = EplEventuProcess(pEvent_p);
652 #endif
653
654                         break;
655                 }
656
657         default:
658                 {
659                         Ret = kEplEventUnknownSink;
660                 }
661
662         }                       // end of switch(pEvent_p->m_EventSink)
663
664 #ifndef EPL_NO_FIFO
665       Exit:
666 #endif
667         return Ret;
668
669 }
670
671 //---------------------------------------------------------------------------
672 //
673 // Function:    EplEventuPostError
674 //
675 // Description: post errorevent from userspace
676 //
677 //
678 //
679 // Parameters:  EventSource_p   = source-module of the errorevent
680 //              EplError_p     = code of occured error
681 //              uiArgSize_p     = size of the argument
682 //              pArg_p          = pointer to the argument
683 //
684 //
685 // Returns:      tEpKernel  = errorcode
686 //
687 //
688 // State:
689 //
690 //---------------------------------------------------------------------------
691 tEplKernel EplEventuPostError(tEplEventSource EventSource_p,
692                               tEplKernel EplError_p,
693                               unsigned int uiArgSize_p, void *pArg_p)
694 {
695         tEplKernel Ret;
696         u8 abBuffer[EPL_MAX_EVENT_ARG_SIZE];
697         tEplEventError *pEventError = (tEplEventError *) abBuffer;
698         tEplEvent EplEvent;
699
700         Ret = kEplSuccessful;
701
702         // create argument
703         pEventError->m_EventSource = EventSource_p;
704         pEventError->m_EplError = EplError_p;
705         EPL_MEMCPY(&pEventError->m_Arg, pArg_p, uiArgSize_p);
706
707         // create event
708         EplEvent.m_EventType = kEplEventTypeError;
709         EplEvent.m_EventSink = kEplEventSinkApi;
710         EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(EplEvent.m_NetTime));
711         EplEvent.m_uiSize =
712             (sizeof(EventSource_p) + sizeof(EplError_p) + uiArgSize_p);
713         EplEvent.m_pArg = &abBuffer[0];
714
715         // post errorevent
716         Ret = EplEventuPost(&EplEvent);
717
718         return Ret;
719 }
720
721 //=========================================================================//
722 //                                                                         //
723 //          P R I V A T E   F U N C T I O N S                              //
724 //                                                                         //
725 //=========================================================================//
726
727 //---------------------------------------------------------------------------
728 //
729 // Function:    EplEventuRxSignalHandlerCb()
730 //
731 // Description: Callback-function for evets from kernelspace
732 //
733 //
734 //
735 // Parameters:  pShbRxInstance_p    = Instance-pointer for buffer
736 //              ulDataSize_p        = size of data
737 //
738 //
739 // Returns: void
740 //
741 //
742 // State:
743 //
744 //---------------------------------------------------------------------------
745 #ifndef EPL_NO_FIFO
746 static void EplEventuRxSignalHandlerCb(tShbInstance pShbRxInstance_p,
747                                        unsigned long ulDataSize_p)
748 {
749         tEplEvent *pEplEvent;
750         tShbError ShbError;
751 //unsigned long   ulBlockCount;
752 //unsigned long   ulDataSize;
753         u8 abDataBuffer[sizeof(tEplEvent) + EPL_MAX_EVENT_ARG_SIZE];
754         // d.k.: abDataBuffer contains the complete tEplEvent structure
755         //       and behind this the argument
756
757         TGT_DBG_SIGNAL_TRACE_POINT(21);
758
759 // d.k. not needed because it is already done in SharedBuff
760 /*    do
761     {
762         BENCHMARK_MOD_28_SET(1);    // 4 µs until reset
763         // get messagesize
764         ShbError = ShbCirGetReadDataSize (pShbRxInstance_p, &ulDataSize);
765         if(ShbError != kShbOk)
766         {
767             // error goto exit
768             goto Exit;
769         }
770
771         BENCHMARK_MOD_28_RESET(1);  // 14 µs until set
772 */
773         // copy data from event queue
774         ShbError = ShbCirReadDataBlock(pShbRxInstance_p,
775                                        &abDataBuffer[0],
776                                        sizeof(abDataBuffer), &ulDataSize_p);
777         if (ShbError != kShbOk) {
778                 // error goto exit
779                 goto Exit;
780         }
781         // resolve the pointer to the event structure
782         pEplEvent = (tEplEvent *) abDataBuffer;
783         // set Datasize
784         pEplEvent->m_uiSize = (ulDataSize_p - sizeof(tEplEvent));
785         if (pEplEvent->m_uiSize > 0) {
786                 // set pointer to argument
787                 pEplEvent->m_pArg = &abDataBuffer[sizeof(tEplEvent)];
788         } else {
789                 //set pointer to NULL
790                 pEplEvent->m_pArg = NULL;
791         }
792
793         BENCHMARK_MOD_28_SET(1);
794         // call processfunction
795         EplEventuProcess(pEplEvent);
796
797         BENCHMARK_MOD_28_RESET(1);
798         // read number of left messages to process
799 // d.k. not needed because it is already done in SharedBuff
800 /*        ShbError = ShbCirGetReadBlockCount (pShbRxInstance_p, &ulBlockCount);
801         if (ShbError != kShbOk)
802         {
803             // error goto exit
804             goto Exit;
805         }
806     } while (ulBlockCount > 0);
807 */
808       Exit:
809         return;
810 }
811 #endif
812
813 // EOF