aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/epl/EplEventu.c
diff options
context:
space:
mode:
authorDaniel Krueger <daniel.krueger@systec-electronic.com>2008-12-19 14:41:57 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-01-06 16:52:36 -0500
commit9d7164cfdb611c2f864d535ae5794f23db3d84f7 (patch)
tree046847f7d6432f1f3dc8236f62492503f4c9ebdc /drivers/staging/epl/EplEventu.c
parent37bcd24b845abbfd85c838ee9ce07c2b254d3a05 (diff)
Staging: add epl stack
This is the openPOWERLINK network stack from systec electronic. It's a bit messed up as there is a driver mixed into the middle of it, lots of work needs to be done to unwind the different portions to make it sane. Cc: Daniel Krueger <daniel.krueger@systec-electronic.com> Cc: Ronald Sieber <Ronald.Sieber@systec-electronic.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/epl/EplEventu.c')
-rw-r--r--drivers/staging/epl/EplEventu.c813
1 files changed, 813 insertions, 0 deletions
diff --git a/drivers/staging/epl/EplEventu.c b/drivers/staging/epl/EplEventu.c
new file mode 100644
index 00000000000..cb0215a1754
--- /dev/null
+++ b/drivers/staging/epl/EplEventu.c
@@ -0,0 +1,813 @@
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
112typedef struct
113{
114#ifndef EPL_NO_FIFO
115 tShbInstance m_pShbKernelToUserInstance;
116 tShbInstance m_pShbUserToKernelInstance;
117#endif
118 tEplProcessEventCb m_pfnApiProcessEventCb;
119
120}tEplEventuInstance;
121
122//---------------------------------------------------------------------------
123// modul globale vars
124//---------------------------------------------------------------------------
125
126//#ifndef EPL_NO_FIFO
127static tEplEventuInstance EplEventuInstance_g;
128//#endif
129
130//---------------------------------------------------------------------------
131// local function prototypes
132//---------------------------------------------------------------------------
133
134#ifndef EPL_NO_FIFO
135// callback function for incomming events
136static void EplEventuRxSignalHandlerCb (
137 tShbInstance pShbRxInstance_p,
138 unsigned long ulDataSize_p);
139#endif
140
141/***************************************************************************/
142/* */
143/* */
144/* C L A S S <Epl-User-Event> */
145/* */
146/* */
147/***************************************************************************/
148//
149// Description:
150//
151//
152/***************************************************************************/
153
154//=========================================================================//
155// //
156// P U B L I C F U N C T I O N S //
157// //
158//=========================================================================//
159
160//---------------------------------------------------------------------------
161//
162// Function: EplEventuInit
163//
164// Description: function initialize the first instance
165//
166//
167//
168// Parameters: pfnApiProcessEventCb_p = function pointer for API event callback
169//
170//
171// Returns: tEpKernel = errorcode
172//
173//
174// State:
175//
176//---------------------------------------------------------------------------
177tEplKernel PUBLIC EplEventuInit(tEplProcessEventCb pfnApiProcessEventCb_p)
178{
179tEplKernel Ret;
180
181
182 Ret = EplEventuAddInstance(pfnApiProcessEventCb_p);
183
184
185return Ret;
186
187}
188
189
190//---------------------------------------------------------------------------
191//
192// Function: EplEventuAddInstance
193//
194// Description: function add one more instance
195//
196//
197//
198// Parameters: pfnApiProcessEventCb_p = function pointer for API event callback
199//
200//
201// Returns: tEpKernel = errorcode
202//
203//
204// State:
205//
206//---------------------------------------------------------------------------
207tEplKernel PUBLIC EplEventuAddInstance(tEplProcessEventCb pfnApiProcessEventCb_p)
208{
209tEplKernel Ret;
210#ifndef EPL_NO_FIFO
211tShbError ShbError;
212unsigned int fShbNewCreated;
213#endif
214
215 Ret = kEplSuccessful;
216
217
218 // init instance variables
219 EplEventuInstance_g.m_pfnApiProcessEventCb = pfnApiProcessEventCb_p;
220
221#ifndef EPL_NO_FIFO
222 // init shared loop buffer
223 // kernel -> user
224 ShbError = ShbCirAllocBuffer (EPL_EVENT_SIZE_SHB_KERNEL_TO_USER,
225 EPL_EVENT_NAME_SHB_KERNEL_TO_USER,
226 &EplEventuInstance_g.m_pShbKernelToUserInstance,
227 &fShbNewCreated);
228 if(ShbError != kShbOk)
229 {
230 EPL_DBGLVL_EVENTK_TRACE1("EplEventuAddInstance(): ShbCirAllocBuffer(K2U) -> 0x%X\n", ShbError);
231 Ret = kEplNoResource;
232 goto Exit;
233 }
234
235
236 // user -> kernel
237 ShbError = ShbCirAllocBuffer (EPL_EVENT_SIZE_SHB_USER_TO_KERNEL,
238 EPL_EVENT_NAME_SHB_USER_TO_KERNEL,
239 &EplEventuInstance_g.m_pShbUserToKernelInstance,
240 &fShbNewCreated);
241 if(ShbError != kShbOk)
242 {
243 EPL_DBGLVL_EVENTK_TRACE1("EplEventuAddInstance(): ShbCirAllocBuffer(U2K) -> 0x%X\n", ShbError);
244 Ret = kEplNoResource;
245 goto Exit;
246 }
247
248 // register eventhandler
249 ShbError = ShbCirSetSignalHandlerNewData (EplEventuInstance_g.m_pShbKernelToUserInstance,
250 EplEventuRxSignalHandlerCb,
251 kShbPriorityNormal);
252 if(ShbError != kShbOk)
253 {
254 EPL_DBGLVL_EVENTK_TRACE1("EplEventuAddInstance(): ShbCirSetSignalHandlerNewData(K2U) -> 0x%X\n", ShbError);
255 Ret = kEplNoResource;
256 goto Exit;
257 }
258
259Exit:
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//---------------------------------------------------------------------------
283tEplKernel PUBLIC EplEventuDelInstance()
284{
285tEplKernel Ret;
286#ifndef EPL_NO_FIFO
287tShbError ShbError;
288#endif
289
290 Ret = kEplSuccessful;
291
292#ifndef EPL_NO_FIFO
293 // set eventhandler to NULL
294 ShbError = ShbCirSetSignalHandlerNewData (EplEventuInstance_g.m_pShbKernelToUserInstance,
295 NULL,
296 kShbPriorityNormal);
297 if(ShbError != kShbOk)
298 {
299 EPL_DBGLVL_EVENTK_TRACE1("EplEventuDelInstance(): ShbCirSetSignalHandlerNewData(K2U) -> 0x%X\n", ShbError);
300 Ret = kEplNoResource;
301 }
302
303 // free buffer User -> Kernel
304 ShbError = ShbCirReleaseBuffer (EplEventuInstance_g.m_pShbUserToKernelInstance);
305 if((ShbError != kShbOk) && (ShbError != kShbMemUsedByOtherProcs))
306 {
307 EPL_DBGLVL_EVENTK_TRACE1("EplEventuDelInstance(): ShbCirReleaseBuffer(U2K) -> 0x%X\n", ShbError);
308 Ret = kEplNoResource;
309 }
310 else
311 {
312 EplEventuInstance_g.m_pShbUserToKernelInstance = NULL;
313 }
314
315 // free buffer Kernel -> User
316 ShbError = ShbCirReleaseBuffer (EplEventuInstance_g.m_pShbKernelToUserInstance);
317 if((ShbError != kShbOk) && (ShbError != kShbMemUsedByOtherProcs))
318 {
319 EPL_DBGLVL_EVENTK_TRACE1("EplEventuDelInstance(): ShbCirReleaseBuffer(K2U) -> 0x%X\n", ShbError);
320 Ret = kEplNoResource;
321 }
322 else
323 {
324 EplEventuInstance_g.m_pShbKernelToUserInstance = NULL;
325 }
326
327#endif
328
329return 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//---------------------------------------------------------------------------
350tEplKernel PUBLIC EplEventuProcess(tEplEvent* pEvent_p)
351{
352tEplKernel Ret;
353tEplEventSource EventSource;
354
355 Ret = kEplSuccessful;
356
357 // check m_EventSink
358 switch(pEvent_p->m_EventSink)
359 {
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 {
367 EventSource = kEplEventSourceNmtu;
368
369 // Error event for API layer
370 EplEventuPostError(kEplEventSourceEventu,
371 Ret,
372 sizeof(EventSource),
373 &EventSource);
374 }
375#endif
376 break;
377 }
378
379#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
380 // NMT-MN-User-Module
381 case kEplEventSinkNmtMnu:
382 {
383 Ret = EplNmtMnuProcessEvent(pEvent_p);
384 if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
385 {
386 EventSource = kEplEventSourceNmtMnu;
387
388 // Error event for API layer
389 EplEventuPostError(kEplEventSourceEventu,
390 Ret,
391 sizeof(EventSource),
392 &EventSource);
393 }
394 break;
395 }
396#endif
397
398#if ((((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOC)) != 0) \
399 || (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_SDOS)) != 0))
400 // events for asynchronus SDO Sequence Layer
401 case kEplEventSinkSdoAsySeq:
402 {
403 Ret = EplSdoAsySeqProcessEvent(pEvent_p);
404 if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
405 {
406 EventSource = kEplEventSourceSdoAsySeq;
407
408 // Error event for API layer
409 EplEventuPostError(kEplEventSourceEventu,
410 Ret,
411 sizeof(EventSource),
412 &EventSource);
413 }
414 break;
415 }
416#endif
417
418 // LED user part module
419 case kEplEventSinkLedu:
420 {
421#if (((EPL_MODULE_INTEGRATION) & (EPL_MODULE_LEDU)) != 0)
422 Ret = EplLeduProcessEvent(pEvent_p);
423 if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
424 {
425 EventSource = kEplEventSourceLedu;
426
427 // Error event for API layer
428 EplEventuPostError(kEplEventSourceEventu,
429 Ret,
430 sizeof(EventSource),
431 &EventSource);
432 }
433#endif
434 break;
435 }
436
437 // event for EPL api
438 case kEplEventSinkApi:
439 {
440 if (EplEventuInstance_g.m_pfnApiProcessEventCb != NULL)
441 {
442 Ret = EplEventuInstance_g.m_pfnApiProcessEventCb(pEvent_p);
443 if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
444 {
445 EventSource = kEplEventSourceEplApi;
446
447 // Error event for API layer
448 EplEventuPostError(kEplEventSourceEventu,
449 Ret,
450 sizeof(EventSource),
451 &EventSource);
452 }
453 }
454 break;
455
456 }
457
458 case kEplEventSinkDlluCal:
459 {
460 Ret = EplDlluCalProcess(pEvent_p);
461 if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
462 {
463 EventSource = kEplEventSourceDllu;
464
465 // Error event for API layer
466 EplEventuPostError(kEplEventSourceEventu,
467 Ret,
468 sizeof(EventSource),
469 &EventSource);
470 }
471 break;
472
473 }
474
475 case kEplEventSinkErru:
476 {
477 /*
478 Ret = EplErruProcess(pEvent_p);
479 if ((Ret != kEplSuccessful) && (Ret != kEplShutdown))
480 {
481 EventSource = kEplEventSourceErru;
482
483 // Error event for API layer
484 EplEventuPostError(kEplEventSourceEventu,
485 Ret,
486 sizeof(EventSource),
487 &EventSource);
488 }
489 */
490 break;
491
492 }
493
494 // unknown sink
495 default:
496 {
497 Ret = kEplEventUnknownSink;
498 }
499
500 } // end of switch(pEvent_p->m_EventSink)
501
502 return Ret;
503
504}
505
506//---------------------------------------------------------------------------
507//
508// Function: EplEventuPost
509//
510// Description: post events from userspace
511//
512//
513//
514// Parameters: pEvent_p = pointer to event-structur from buffer
515//
516//
517// Returns: tEpKernel = errorcode
518//
519//
520// State:
521//
522//---------------------------------------------------------------------------
523tEplKernel PUBLIC EplEventuPost(tEplEvent * pEvent_p)
524{
525tEplKernel Ret;
526#ifndef EPL_NO_FIFO
527tShbError ShbError;
528tShbCirChunk ShbCirChunk;
529unsigned long ulDataSize;
530unsigned int fBufferCompleted;
531#endif
532
533 Ret = kEplSuccessful;
534
535
536#ifndef EPL_NO_FIFO
537 // 2006/08/03 d.k.: Event and argument are posted as separate chunks to the event queue.
538 ulDataSize = sizeof(tEplEvent) + ((pEvent_p->m_pArg != NULL) ? pEvent_p->m_uiSize : 0);
539#endif
540
541 // decide in which buffer the event have to write
542 switch(pEvent_p->m_EventSink)
543 {
544 // kernelspace modules
545 case kEplEventSinkSync:
546 case kEplEventSinkNmtk:
547 case kEplEventSinkDllk:
548 case kEplEventSinkDllkCal:
549 case kEplEventSinkPdok:
550 case kEplEventSinkErrk:
551 {
552#ifndef EPL_NO_FIFO
553 // post message
554 ShbError = ShbCirAllocDataBlock (EplEventuInstance_g.m_pShbUserToKernelInstance,
555 &ShbCirChunk,
556 ulDataSize);
557 if (ShbError != kShbOk)
558 {
559 EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirAllocDataBlock(U2K) -> 0x%X\n", ShbError);
560 Ret = kEplEventPostError;
561 goto Exit;
562 }
563 ShbError = ShbCirWriteDataChunk (EplEventuInstance_g.m_pShbUserToKernelInstance,
564 &ShbCirChunk,
565 pEvent_p,
566 sizeof (tEplEvent),
567 &fBufferCompleted);
568 if (ShbError != kShbOk)
569 {
570 EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirWriteDataChunk(U2K) -> 0x%X\n", ShbError);
571 Ret = kEplEventPostError;
572 goto Exit;
573 }
574 if (fBufferCompleted == FALSE)
575 {
576 ShbError = ShbCirWriteDataChunk (EplEventuInstance_g.m_pShbUserToKernelInstance,
577 &ShbCirChunk,
578 pEvent_p->m_pArg,
579 (unsigned long) pEvent_p->m_uiSize,
580 &fBufferCompleted);
581 if ((ShbError != kShbOk) || (fBufferCompleted == FALSE))
582 {
583 EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirWriteDataChunk2(U2K) -> 0x%X\n", ShbError);
584 Ret = kEplEventPostError;
585 goto Exit;
586 }
587 }
588#else
589 Ret = EplEventkProcess(pEvent_p);
590#endif
591
592 break;
593 }
594
595 // userspace modules
596 case kEplEventSinkNmtMnu:
597 case kEplEventSinkNmtu:
598 case kEplEventSinkSdoAsySeq:
599 case kEplEventSinkApi:
600 case kEplEventSinkDlluCal:
601 case kEplEventSinkErru:
602 case kEplEventSinkLedu:
603 {
604#ifndef EPL_NO_FIFO
605 // post message
606 ShbError = ShbCirAllocDataBlock (EplEventuInstance_g.m_pShbKernelToUserInstance,
607 &ShbCirChunk,
608 ulDataSize);
609 if(ShbError != kShbOk)
610 {
611 EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirAllocDataBlock(K2U) -> 0x%X\n", ShbError);
612 Ret = kEplEventPostError;
613 goto Exit;
614 }
615 ShbError = ShbCirWriteDataChunk (EplEventuInstance_g.m_pShbKernelToUserInstance,
616 &ShbCirChunk,
617 pEvent_p,
618 sizeof (tEplEvent),
619 &fBufferCompleted);
620 if(ShbError != kShbOk)
621 {
622 EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirWriteDataChunk(K2U) -> 0x%X\n", ShbError);
623 Ret = kEplEventPostError;
624 goto Exit;
625 }
626 if (fBufferCompleted == FALSE)
627 {
628 ShbError = ShbCirWriteDataChunk (EplEventuInstance_g.m_pShbKernelToUserInstance,
629 &ShbCirChunk,
630 pEvent_p->m_pArg,
631 (unsigned long) pEvent_p->m_uiSize,
632 &fBufferCompleted);
633 if ((ShbError != kShbOk) || (fBufferCompleted == FALSE))
634 {
635 EPL_DBGLVL_EVENTK_TRACE1("EplEventuPost(): ShbCirWriteDataChunk2(K2U) -> 0x%X\n", ShbError);
636 Ret = kEplEventPostError;
637 goto Exit;
638 }
639 }
640
641#else
642 Ret = EplEventuProcess(pEvent_p);
643#endif
644
645 break;
646 }
647
648 default:
649 {
650 Ret = kEplEventUnknownSink;
651 }
652
653
654 }// end of switch(pEvent_p->m_EventSink)
655
656#ifndef EPL_NO_FIFO
657Exit:
658#endif
659 return Ret;
660
661}
662//---------------------------------------------------------------------------
663//
664// Function: EplEventuPostError
665//
666// Description: post errorevent from userspace
667//
668//
669//
670// Parameters: EventSource_p = source-module of the errorevent
671// EplError_p = code of occured error
672// uiArgSize_p = size of the argument
673// pArg_p = pointer to the argument
674//
675//
676// Returns: tEpKernel = errorcode
677//
678//
679// State:
680//
681//---------------------------------------------------------------------------
682tEplKernel PUBLIC EplEventuPostError(tEplEventSource EventSource_p,
683 tEplKernel EplError_p,
684 unsigned int uiArgSize_p,
685 void* pArg_p)
686{
687tEplKernel Ret;
688BYTE abBuffer[EPL_MAX_EVENT_ARG_SIZE];
689tEplEventError* pEventError = (tEplEventError*) abBuffer;
690tEplEvent EplEvent;
691
692 Ret = kEplSuccessful;
693
694 // create argument
695 pEventError->m_EventSource = EventSource_p;
696 pEventError->m_EplError = EplError_p;
697 EPL_MEMCPY(&pEventError->m_Arg, pArg_p, uiArgSize_p);
698
699 // create event
700 EplEvent.m_EventType = kEplEventTypeError;
701 EplEvent.m_EventSink = kEplEventSinkApi;
702 EPL_MEMSET(&EplEvent.m_NetTime, 0x00, sizeof(EplEvent.m_NetTime));
703 EplEvent.m_uiSize = (sizeof(EventSource_p)+ sizeof(EplError_p)+ uiArgSize_p);
704 EplEvent.m_pArg = &abBuffer[0];
705
706 // post errorevent
707 Ret = EplEventuPost(&EplEvent);
708
709 return Ret;
710}
711
712
713//=========================================================================//
714// //
715// P R I V A T E F U N C T I O N S //
716// //
717//=========================================================================//
718
719//---------------------------------------------------------------------------
720//
721// Function: EplEventuRxSignalHandlerCb()
722//
723// Description: Callback-function for evets from kernelspace
724//
725//
726//
727// Parameters: pShbRxInstance_p = Instance-pointer for buffer
728// ulDataSize_p = size of data
729//
730//
731// Returns: void
732//
733//
734// State:
735//
736//---------------------------------------------------------------------------
737#ifndef EPL_NO_FIFO
738static void EplEventuRxSignalHandlerCb (
739 tShbInstance pShbRxInstance_p,
740 unsigned long ulDataSize_p)
741{
742tEplEvent *pEplEvent;
743tShbError ShbError;
744//unsigned long ulBlockCount;
745//unsigned long ulDataSize;
746BYTE abDataBuffer[sizeof(tEplEvent) + EPL_MAX_EVENT_ARG_SIZE];
747 // d.k.: abDataBuffer contains the complete tEplEvent structure
748 // and behind this the argument
749
750 TGT_DBG_SIGNAL_TRACE_POINT(21);
751
752// d.k. not needed because it is already done in SharedBuff
753/* do
754 {
755 BENCHMARK_MOD_28_SET(1); // 4 µs until reset
756 // get messagesize
757 ShbError = ShbCirGetReadDataSize (pShbRxInstance_p, &ulDataSize);
758 if(ShbError != kShbOk)
759 {
760 // error goto exit
761 goto Exit;
762 }
763
764 BENCHMARK_MOD_28_RESET(1); // 14 µs until set
765*/
766 // copy data from event queue
767 ShbError = ShbCirReadDataBlock (pShbRxInstance_p,
768 &abDataBuffer[0],
769 sizeof(abDataBuffer),
770 &ulDataSize_p);
771 if(ShbError != kShbOk)
772 {
773 // error goto exit
774 goto Exit;
775 }
776
777 // resolve the pointer to the event structure
778 pEplEvent = (tEplEvent *) abDataBuffer;
779 // set Datasize
780 pEplEvent->m_uiSize = (ulDataSize_p - sizeof(tEplEvent));
781 if(pEplEvent->m_uiSize > 0)
782 {
783 // set pointer to argument
784 pEplEvent->m_pArg = &abDataBuffer[sizeof(tEplEvent)];
785 }
786 else
787 {
788 //set pointer to NULL
789 pEplEvent->m_pArg = NULL;
790 }
791
792 BENCHMARK_MOD_28_SET(1);
793 // call processfunction
794 EplEventuProcess(pEplEvent);
795
796 BENCHMARK_MOD_28_RESET(1);
797 // read number of left messages to process
798// d.k. not needed because it is already done in SharedBuff
799/* ShbError = ShbCirGetReadBlockCount (pShbRxInstance_p, &ulBlockCount);
800 if (ShbError != kShbOk)
801 {
802 // error goto exit
803 goto Exit;
804 }
805 } while (ulBlockCount > 0);
806*/
807Exit:
808 return;
809}
810#endif
811
812// EOF
813