Merge branch 'dma' into devel
[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 PUBLIC TgtDbgSignalTracePoint(BYTE bTracePointNumber_p);
100 void PUBLIC TgtDbgPostTraceValue(DWORD 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 PUBLIC 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 PUBLIC EplEventuAddInstance(tEplProcessEventCb
203                                        pfnApiProcessEventCb_p)
204 {
205         tEplKernel Ret;
206 #ifndef EPL_NO_FIFO
207         tShbError ShbError;
208         unsigned int fShbNewCreated;
209 #endif
210
211         Ret = kEplSuccessful;
212
213         // init instance variables
214         EplEventuInstance_g.m_pfnApiProcessEventCb = pfnApiProcessEventCb_p;
215
216 #ifndef EPL_NO_FIFO
217         // init shared loop buffer
218         // kernel -> user
219         ShbError = ShbCirAllocBuffer(EPL_EVENT_SIZE_SHB_KERNEL_TO_USER,
220                                      EPL_EVENT_NAME_SHB_KERNEL_TO_USER,
221                                      &EplEventuInstance_g.
222                                      m_pShbKernelToUserInstance,
223                                      &fShbNewCreated);
224         if (ShbError != kShbOk) {
225                 EPL_DBGLVL_EVENTK_TRACE1
226                     ("EplEventuAddInstance(): ShbCirAllocBuffer(K2U) -> 0x%X\n",
227                      ShbError);
228                 Ret = kEplNoResource;
229                 goto Exit;
230         }
231
232         // user -> kernel
233         ShbError = ShbCirAllocBuffer(EPL_EVENT_SIZE_SHB_USER_TO_KERNEL,
234                                      EPL_EVENT_NAME_SHB_USER_TO_KERNEL,
235                                      &EplEventuInstance_g.
236                                      m_pShbUserToKernelInstance,
237                                      &fShbNewCreated);
238         if (ShbError != kShbOk) {
239                 EPL_DBGLVL_EVENTK_TRACE1
240                     ("EplEventuAddInstance(): ShbCirAllocBuffer(U2K) -> 0x%X\n",
241                      ShbError);
242                 Ret = kEplNoResource;
243                 goto Exit;
244         }
245         // register eventhandler
246         ShbError =
247             ShbCirSetSignalHandlerNewData(EplEventuInstance_g.
248                                           m_pShbKernelToUserInstance,
249                                           EplEventuRxSignalHandlerCb,
250                                           kShbPriorityNormal);
251         if (ShbError != kShbOk) {
252                 EPL_DBGLVL_EVENTK_TRACE1
253                     ("EplEventuAddInstance(): ShbCirSetSignalHandlerNewData(K2U) -> 0x%X\n",
254                      ShbError);
255                 Ret = kEplNoResource;
256                 goto Exit;
257         }
258
259       Exit:
260 #endif
261
262         return Ret;
263
264 }
265
266 //---------------------------------------------------------------------------
267 //
268 // Function:    EplEventuDelInstance
269 //
270 // Description: function delete instance an free the bufferstructure
271 //
272 //
273 //
274 // Parameters:
275 //
276 //
277 // Returns:      tEpKernel  = errorcode
278 //
279 //
280 // State:
281 //
282 //---------------------------------------------------------------------------
283 tEplKernel PUBLIC EplEventuDelInstance()
284 {
285         tEplKernel Ret;
286 #ifndef EPL_NO_FIFO
287         tShbError ShbError;
288 #endif
289
290         Ret = kEplSuccessful;
291
292 #ifndef EPL_NO_FIFO
293         // set eventhandler to NULL
294         ShbError =
295             ShbCirSetSignalHandlerNewData(EplEventuInstance_g.
296                                           m_pShbKernelToUserInstance, NULL,
297                                           kShbPriorityNormal);
298         if (ShbError != kShbOk) {
299                 EPL_DBGLVL_EVENTK_TRACE1
300                     ("EplEventuDelInstance(): ShbCirSetSignalHandlerNewData(K2U) -> 0x%X\n",
301                      ShbError);
302                 Ret = kEplNoResource;
303         }
304         // free buffer User -> Kernel
305         ShbError =
306             ShbCirReleaseBuffer(EplEventuInstance_g.m_pShbUserToKernelInstance);
307         if ((ShbError != kShbOk) && (ShbError != kShbMemUsedByOtherProcs)) {
308                 EPL_DBGLVL_EVENTK_TRACE1
309                     ("EplEventuDelInstance(): ShbCirReleaseBuffer(U2K) -> 0x%X\n",
310                      ShbError);
311                 Ret = kEplNoResource;
312         } else {
313                 EplEventuInstance_g.m_pShbUserToKernelInstance = NULL;
314         }
315
316         // free buffer  Kernel -> User
317         ShbError =
318             ShbCirReleaseBuffer(EplEventuInstance_g.m_pShbKernelToUserInstance);
319         if ((ShbError != kShbOk) && (ShbError != kShbMemUsedByOtherProcs)) {
320                 EPL_DBGLVL_EVENTK_TRACE1
321                     ("EplEventuDelInstance(): ShbCirReleaseBuffer(K2U) -> 0x%X\n",
322                      ShbError);
323                 Ret = kEplNoResource;
324         } else {
325                 EplEventuInstance_g.m_pShbKernelToUserInstance = NULL;
326         }
327
328 #endif
329
330         return Ret;
331
332 }
333
334 //---------------------------------------------------------------------------
335 //
336 // Function:    EplEventuProcess
337 //
338 // Description: Kernelthread that dispatches events in kernelspace
339 //
340 //
341 //
342 // Parameters:  pEvent_p = pointer to event-structur from buffer
343 //
344 //
345 // Returns:      tEpKernel  = errorcode
346 //
347 //
348 // State:
349 //
350 //---------------------------------------------------------------------------
351 tEplKernel PUBLIC EplEventuProcess(tEplEvent * pEvent_p)
352 {
353         tEplKernel Ret;
354         tEplEventSource EventSource;
355
356         Ret = kEplSuccessful;
357
358         // check m_EventSink
359         switch (pEvent_p->m_EventSink) {
360                 // NMT-User-Module
361         case kEplEventSinkNmtu:
362                 {
363 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTU)) != 0)
364                         Ret = EplNmtuProcessEvent(pEvent_p);
365                         if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) {
366                                 EventSource = kEplEventSourceNmtu;
367
368                                 // Error event for API layer
369                                 EplEventuPostError(kEplEventSourceEventu,
370                                                    Ret,
371                                                    sizeof(EventSource),
372                                                    &EventSource);
373                         }
374 #endif
375                         break;
376                 }
377
378 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
379                 // NMT-MN-User-Module
380         case kEplEventSinkNmtMnu:
381                 {
382                         Ret = EplNmtMnuProcessEvent(pEvent_p);
383                         if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) {
384                                 EventSource = kEplEventSourceNmtMnu;
385
386                                 // Error event for API layer
387                                 EplEventuPostError(kEplEventSourceEventu,
388                                                    Ret,
389                                                    sizeof(EventSource),
390                                                    &EventSource);
391                         }
392                         break;
393                 }
394 #endif
395
396 #if ((((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOC)) != 0)   \
397      || (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOS)) != 0))
398                 // events for asynchronus SDO Sequence Layer
399         case kEplEventSinkSdoAsySeq:
400                 {
401                         Ret = EplSdoAsySeqProcessEvent(pEvent_p);
402                         if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) {
403                                 EventSource = kEplEventSourceSdoAsySeq;
404
405                                 // Error event for API layer
406                                 EplEventuPostError(kEplEventSourceEventu,
407                                                    Ret,
408                                                    sizeof(EventSource),
409                                                    &EventSource);
410                         }
411                         break;
412                 }
413 #endif
414
415                 // LED user part module
416         case kEplEventSinkLedu:
417                 {
418 #if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_LEDU)) != 0)
419                         Ret = EplLeduProcessEvent(pEvent_p);
420                         if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) {
421                                 EventSource = kEplEventSourceLedu;
422
423                                 // Error event for API layer
424                                 EplEventuPostError(kEplEventSourceEventu,
425                                                    Ret,
426                                                    sizeof(EventSource),
427                                                    &EventSource);
428                         }
429 #endif
430                         break;
431                 }
432
433                 // event for EPL api
434         case kEplEventSinkApi:
435                 {
436                         if (EplEventuInstance_g.m_pfnApiProcessEventCb != NULL) {
437                                 Ret =
438                                     EplEventuInstance_g.
439                                     m_pfnApiProcessEventCb(pEvent_p);
440                                 if ((Ret != kEplSuccessful)
441                                     && (Ret != kEplShutdown)) {
442                                         EventSource = kEplEventSourceEplApi;
443
444                                         // Error event for API layer
445                                         EplEventuPostError
446                                             (kEplEventSourceEventu, Ret,
447                                              sizeof(EventSource), &EventSource);
448                                 }
449                         }
450                         break;
451
452                 }
453
454         case kEplEventSinkDlluCal:
455                 {
456                         Ret = EplDlluCalProcess(pEvent_p);
457                         if ((Ret != kEplSuccessful) && (Ret != kEplShutdown)) {
458                                 EventSource = kEplEventSourceDllu;
459
460                                 // Error event for API layer
461                                 EplEventuPostError(kEplEventSourceEventu,
462                                                    Ret,
463                                                    sizeof(EventSource),
464                                                    &EventSource);
465                         }
466                         break;
467
468                 }
469
470         case kEplEventSinkErru:
471                 {
472                         /*
473                            Ret = EplErruProcess(pEvent_p);
474                            if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
475                            {
476                            EventSource = kEplEventSourceErru;
477
478                            // Error event for API layer
479                            EplEventuPostError(kEplEventSourceEventu,
480                            Ret,
481                            sizeof(EventSource),
482                            &EventSource);
483                            }
484                          */
485                         break;
486
487                 }
488
489                 // unknown sink
490         default:
491                 {
492                         Ret = kEplEventUnknownSink;
493                 }
494
495         }                       // end of switch(pEvent_p->m_EventSink)
496
497         return Ret;
498
499 }
500
501 //---------------------------------------------------------------------------
502 //
503 // Function:    EplEventuPost
504 //
505 // Description: post events from userspace
506 //
507 //
508 //
509 // Parameters:  pEvent_p = pointer to event-structur from buffer
510 //
511 //
512 // Returns:      tEpKernel  = errorcode
513 //
514 //
515 // State:
516 //
517 //---------------------------------------------------------------------------
518 tEplKernel PUBLIC EplEventuPost(tEplEvent * pEvent_p)
519 {
520         tEplKernel Ret;
521 #ifndef EPL_NO_FIFO
522         tShbError ShbError;
523         tShbCirChunk ShbCirChunk;
524         unsigned long ulDataSize;
525         unsigned int fBufferCompleted;
526 #endif
527
528         Ret = kEplSuccessful;
529
530 #ifndef EPL_NO_FIFO
531         // 2006/08/03 d.k.: Event and argument are posted as separate chunks to the event queue.
532         ulDataSize =
533             sizeof(tEplEvent) +
534             ((pEvent_p->m_pArg != NULL) ? pEvent_p->m_uiSize : 0);
535 #endif
536
537         // decide in which buffer the event have to write
538         switch (pEvent_p->m_EventSink) {
539                 // kernelspace modules
540         case kEplEventSinkSync:
541         case kEplEventSinkNmtk:
542         case kEplEventSinkDllk:
543         case kEplEventSinkDllkCal:
544         case kEplEventSinkPdok:
545         case kEplEventSinkErrk:
546                 {
547 #ifndef EPL_NO_FIFO
548                         // post message
549                         ShbError =
550                             ShbCirAllocDataBlock(EplEventuInstance_g.
551                                                  m_pShbUserToKernelInstance,
552                                                  &ShbCirChunk, ulDataSize);
553                         if (ShbError != kShbOk) {
554                                 EPL_DBGLVL_EVENTK_TRACE1
555                                     ("EplEventuPost(): ShbCirAllocDataBlock(U2K) -> 0x%X\n",
556                                      ShbError);
557                                 Ret = kEplEventPostError;
558                                 goto Exit;
559                         }
560                         ShbError =
561                             ShbCirWriteDataChunk(EplEventuInstance_g.
562                                                  m_pShbUserToKernelInstance,
563                                                  &ShbCirChunk, pEvent_p,
564                                                  sizeof(tEplEvent),
565                                                  &fBufferCompleted);
566                         if (ShbError != kShbOk) {
567                                 EPL_DBGLVL_EVENTK_TRACE1
568                                     ("EplEventuPost(): ShbCirWriteDataChunk(U2K) -> 0x%X\n",
569                                      ShbError);
570                                 Ret = kEplEventPostError;
571                                 goto Exit;
572                         }
573                         if (fBufferCompleted == FALSE) {
574                                 ShbError =
575                                     ShbCirWriteDataChunk(EplEventuInstance_g.
576                                                          m_pShbUserToKernelInstance,
577                                                          &ShbCirChunk,
578                                                          pEvent_p->m_pArg,
579                                                          (unsigned long)
580                                                          pEvent_p->m_uiSize,
581                                                          &fBufferCompleted);
582                                 if ((ShbError != kShbOk)
583                                     || (fBufferCompleted == FALSE)) {
584                                         EPL_DBGLVL_EVENTK_TRACE1
585                                             ("EplEventuPost(): ShbCirWriteDataChunk2(U2K) -> 0x%X\n",
586                                              ShbError);
587                                         Ret = kEplEventPostError;
588                                         goto Exit;
589                                 }
590                         }
591 #else
592                         Ret = EplEventkProcess(pEvent_p);
593 #endif
594
595                         break;
596                 }
597
598                 // userspace modules
599         case kEplEventSinkNmtMnu:
600         case kEplEventSinkNmtu:
601         case kEplEventSinkSdoAsySeq:
602         case kEplEventSinkApi:
603         case kEplEventSinkDlluCal:
604         case kEplEventSinkErru:
605         case kEplEventSinkLedu:
606                 {
607 #ifndef EPL_NO_FIFO
608                         // post message
609                         ShbError =
610                             ShbCirAllocDataBlock(EplEventuInstance_g.
611                                                  m_pShbKernelToUserInstance,
612                                                  &ShbCirChunk, ulDataSize);
613                         if (ShbError != kShbOk) {
614                                 EPL_DBGLVL_EVENTK_TRACE1
615                                     ("EplEventuPost(): ShbCirAllocDataBlock(K2U) -> 0x%X\n",
616                                      ShbError);
617                                 Ret = kEplEventPostError;
618                                 goto Exit;
619                         }
620                         ShbError =
621                             ShbCirWriteDataChunk(EplEventuInstance_g.
622                                                  m_pShbKernelToUserInstance,
623                                                  &ShbCirChunk, pEvent_p,
624                                                  sizeof(tEplEvent),
625                                                  &fBufferCompleted);
626                         if (ShbError != kShbOk) {
627                                 EPL_DBGLVL_EVENTK_TRACE1
628                                     ("EplEventuPost(): ShbCirWriteDataChunk(K2U) -> 0x%X\n",
629                                      ShbError);
630                                 Ret = kEplEventPostError;
631                                 goto Exit;
632                         }
633                         if (fBufferCompleted == FALSE) {
634                                 ShbError =
635                                     ShbCirWriteDataChunk(EplEventuInstance_g.
636                                                          m_pShbKernelToUserInstance,
637                                                          &ShbCirChunk,
638                                                          pEvent_p->m_pArg,
639                                                          (unsigned long)
640                                                          pEvent_p->m_uiSize,
641                                                          &fBufferCompleted);
642                                 if ((ShbError != kShbOk)
643                                     || (fBufferCompleted == FALSE)) {
644                                         EPL_DBGLVL_EVENTK_TRACE1
645                                             ("EplEventuPost(): ShbCirWriteDataChunk2(K2U) -> 0x%X\n",
646                                              ShbError);
647                                         Ret = kEplEventPostError;
648                                         goto Exit;
649                                 }
650                         }
651 #else
652                         Ret = EplEventuProcess(pEvent_p);
653 #endif
654
655                         break;
656                 }
657
658         default:
659                 {
660                         Ret = kEplEventUnknownSink;
661                 }
662
663         }                       // end of switch(pEvent_p->m_EventSink)
664
665 #ifndef EPL_NO_FIFO
666       Exit:
667 #endif
668         return Ret;
669
670 }
671
672 //---------------------------------------------------------------------------
673 //
674 // Function:    EplEventuPostError
675 //
676 // Description: post errorevent from userspace
677 //
678 //
679 //
680 // Parameters:  EventSource_p   = source-module of the errorevent
681 //              EplError_p     = code of occured error
682 //              uiArgSize_p     = size of the argument
683 //              pArg_p          = pointer to the argument
684 //
685 //
686 // Returns:      tEpKernel  = errorcode
687 //
688 //
689 // State:
690 //
691 //---------------------------------------------------------------------------
692 tEplKernel PUBLIC EplEventuPostError(tEplEventSource EventSource_p,
693                                      tEplKernel EplError_p,
694                                      unsigned int uiArgSize_p, void *pArg_p)
695 {
696         tEplKernel Ret;
697         BYTE abBuffer[EPL_MAX_EVENT_ARG_SIZE];
698         tEplEventError *pEventError = (tEplEventError *) abBuffer;
699         tEplEvent EplEvent;
700
701         Ret = kEplSuccessful;
702
703         // create argument
704         pEventError->m_EventSource = EventSource_p;
705         pEventError->m_EplError = EplError_p;
706         EPL_MEMCPY(&pEventError->m_Arg, pArg_p, uiArgSize_p);
707
708         // create event
709         EplEvent.m_EventType = kEplEventTypeError;
710         EplEvent.m_EventSink = kEplEventSinkApi;
711         EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(EplEvent.m_NetTime));
712         EplEvent.m_uiSize =
713             (sizeof(EventSource_p) + sizeof(EplError_p) + uiArgSize_p);
714         EplEvent.m_pArg = &abBuffer[0];
715
716         // post errorevent
717         Ret = EplEventuPost(&EplEvent);
718
719         return Ret;
720 }
721
722 //=========================================================================//
723 //                                                                         //
724 //          P R I V A T E   F U N C T I O N S                              //
725 //                                                                         //
726 //=========================================================================//
727
728 //---------------------------------------------------------------------------
729 //
730 // Function:    EplEventuRxSignalHandlerCb()
731 //
732 // Description: Callback-function for evets from kernelspace
733 //
734 //
735 //
736 // Parameters:  pShbRxInstance_p    = Instance-pointer for buffer
737 //              ulDataSize_p        = size of data
738 //
739 //
740 // Returns: void
741 //
742 //
743 // State:
744 //
745 //---------------------------------------------------------------------------
746 #ifndef EPL_NO_FIFO
747 static void EplEventuRxSignalHandlerCb(tShbInstance pShbRxInstance_p,
748                                        unsigned long ulDataSize_p)
749 {
750         tEplEvent *pEplEvent;
751         tShbError ShbError;
752 //unsigned long   ulBlockCount;
753 //unsigned long   ulDataSize;
754         BYTE abDataBuffer[sizeof(tEplEvent) + EPL_MAX_EVENT_ARG_SIZE];
755         // d.k.: abDataBuffer contains the complete tEplEvent structure
756         //       and behind this the argument
757
758         TGT_DBG_SIGNAL_TRACE_POINT(21);
759
760 // d.k. not needed because it is already done in SharedBuff
761 /*    do
762     {
763         BENCHMARK_MOD_28_SET(1);    // 4 µs until reset
764         // get messagesize
765         ShbError = ShbCirGetReadDataSize (pShbRxInstance_p, &ulDataSize);
766         if(ShbError != kShbOk)
767         {
768             // error goto exit
769             goto Exit;
770         }
771
772         BENCHMARK_MOD_28_RESET(1);  // 14 µs until set
773 */
774         // copy data from event queue
775         ShbError = ShbCirReadDataBlock(pShbRxInstance_p,
776                                        &abDataBuffer[0],
777                                        sizeof(abDataBuffer), &ulDataSize_p);
778         if (ShbError != kShbOk) {
779                 // error goto exit
780                 goto Exit;
781         }
782         // resolve the pointer to the event structure
783         pEplEvent = (tEplEvent *) abDataBuffer;
784         // set Datasize
785         pEplEvent->m_uiSize = (ulDataSize_p - sizeof(tEplEvent));
786         if (pEplEvent->m_uiSize > 0) {
787                 // set pointer to argument
788                 pEplEvent->m_pArg = &abDataBuffer[sizeof(tEplEvent)];
789         } else {
790                 //set pointer to NULL
791                 pEplEvent->m_pArg = NULL;
792         }
793
794         BENCHMARK_MOD_28_SET(1);
795         // call processfunction
796         EplEventuProcess(pEplEvent);
797
798         BENCHMARK_MOD_28_RESET(1);
799         // read number of left messages to process
800 // d.k. not needed because it is already done in SharedBuff
801 /*        ShbError = ShbCirGetReadBlockCount (pShbRxInstance_p, &ulBlockCount);
802         if (ShbError != kShbOk)
803         {
804             // error goto exit
805             goto Exit;
806         }
807     } while (ulBlockCount > 0);
808 */
809       Exit:
810         return;
811 }
812 #endif
813
814 // EOF