IMA: Handle dentry_open failures
[linux-2.6/mini2440.git] / drivers / staging / epl / EplNmtk.c
blob609d5c02bdebe9cdf11ec0b47a1f04ee0a038519
1 /****************************************************************************
3 (c) SYSTEC electronic GmbH, D-07973 Greiz, August-Bebel-Str. 29
4 www.systec-electronic.com
6 Project: openPOWERLINK
8 Description: source file for NMT-Kernelspace-Module
10 License:
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions
14 are met:
16 1. Redistributions of source code must retain the above copyright
17 notice, this list of conditions and the following disclaimer.
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.
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.
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.
41 Severability Clause:
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.
50 -------------------------------------------------------------------------
52 $RCSfile: EplNmtk.c,v $
54 $Author: D.Krueger $
56 $Revision: 1.12 $ $Date: 2008/11/13 17:13:09 $
58 $State: Exp $
60 Build Environment:
61 GCC V3.4
63 -------------------------------------------------------------------------
65 Revision History:
67 2006/06/09 k.t.: start of the implementation
69 ****************************************************************************/
71 #include "kernel/EplNmtk.h"
72 #include "kernel/EplTimerk.h"
74 #include "kernel/EplDllk.h" // for EplDllkProcess()
76 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
77 /***************************************************************************/
78 /* */
79 /* */
80 /* G L O B A L D E F I N I T I O N S */
81 /* */
82 /* */
83 /***************************************************************************/
85 //---------------------------------------------------------------------------
86 // const defines
87 //---------------------------------------------------------------------------
89 // TracePoint support for realtime-debugging
90 #ifdef _DBG_TRACE_POINTS_
91 void TgtDbgSignalTracePoint(u8 bTracePointNumber_p);
92 void TgtDbgPostTraceValue(u32 dwTraceValue_p);
93 #define TGT_DBG_SIGNAL_TRACE_POINT(p) TgtDbgSignalTracePoint(p)
94 #define TGT_DBG_POST_TRACE_VALUE(v) TgtDbgPostTraceValue(v)
95 #else
96 #define TGT_DBG_SIGNAL_TRACE_POINT(p)
97 #define TGT_DBG_POST_TRACE_VALUE(v)
98 #endif
99 #define EPL_NMTK_DBG_POST_TRACE_VALUE(NmtEvent_p, OldNmtState_p, NewNmtState_p) \
100 TGT_DBG_POST_TRACE_VALUE((kEplEventSinkNmtk << 28) | (NmtEvent_p << 16) \
101 | ((OldNmtState_p & 0xFF) << 8) \
102 | (NewNmtState_p & 0xFF))
104 //---------------------------------------------------------------------------
105 // local types
106 //---------------------------------------------------------------------------
107 // struct for instance table
108 INSTANCE_TYPE_BEGIN EPL_MCO_DECL_INSTANCE_MEMBER()
110 STATIC volatile tEplNmtState m_NmtState;
111 STATIC volatile BOOL m_fEnableReadyToOperate;
112 STATIC volatile BOOL m_fAppReadyToOperate;
113 STATIC volatile BOOL m_fTimerMsPreOp2;
114 STATIC volatile BOOL m_fAllMandatoryCNIdent;
115 STATIC volatile BOOL m_fFrozen;
117 INSTANCE_TYPE_END
118 //---------------------------------------------------------------------------
119 // modul globale vars
120 //---------------------------------------------------------------------------
121 // This macro replace the unspecific pointer to an instance through
122 // the modul specific type for the local instance table. This macro
123 // must defined in each modul.
124 //#define tEplPtrInstance tEplInstanceInfo*
125 EPL_MCO_DECL_INSTANCE_VAR()
126 //---------------------------------------------------------------------------
127 // local function prototypes
128 //---------------------------------------------------------------------------
129 EPL_MCO_DEFINE_INSTANCE_FCT()
131 /***************************************************************************/
132 /* */
133 /* */
134 /* C L A S S <NMT_Kernel-Module> */
135 /* */
136 /* */
137 /***************************************************************************/
139 // Description: This module realize the NMT-State-Machine of the EPL-Stack
142 /***************************************************************************/
143 //=========================================================================//
144 // //
145 // P U B L I C F U N C T I O N S //
146 // //
147 //=========================================================================//
148 //---------------------------------------------------------------------------
150 // Function: EplNmtkInit
152 // Description: initializes the first instance
156 // Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR = Instance pointer
157 // uiNodeId_p = Node Id of the lokal node
160 // Returns: tEplKernel = Errorcode
163 // State:
165 //---------------------------------------------------------------------------
166 tEplKernel EplNmtkInit(EPL_MCO_DECL_PTR_INSTANCE_PTR)
168 tEplKernel Ret;
170 Ret = EplNmtkAddInstance(EPL_MCO_PTR_INSTANCE_PTR);
172 return Ret;
175 //---------------------------------------------------------------------------
177 // Function: EplNmtkAddInstance
179 // Description: adds a new instance
183 // Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR = Instance pointer
186 // Returns: tEplKernel = Errorcode
189 // State:
191 //---------------------------------------------------------------------------
192 tEplKernel EplNmtkAddInstance(EPL_MCO_DECL_PTR_INSTANCE_PTR)
194 EPL_MCO_DECL_INSTANCE_PTR_LOCAL tEplKernel Ret;
195 //tEplEvent Event;
196 //tEplEventNmtStateChange NmtStateChange;
198 // check if pointer to instance pointer valid
199 // get free instance and set the globale instance pointer
200 // set also the instance addr to parameterlist
201 EPL_MCO_CHECK_PTR_INSTANCE_PTR();
202 EPL_MCO_GET_FREE_INSTANCE_PTR();
203 EPL_MCO_SET_PTR_INSTANCE_PTR();
205 // sign instance as used
206 EPL_MCO_WRITE_INSTANCE_STATE(kStateUsed);
208 Ret = kEplSuccessful;
210 // initialize intern vaiables
211 // 2006/07/31 d.k.: set NMT-State to kEplNmtGsOff
212 EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff;
213 // set NMT-State to kEplNmtGsInitialising
214 //EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsInitialising;
216 // set flags to FALSE
217 EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) = FALSE;
218 EPL_MCO_GLB_VAR(m_fAppReadyToOperate) = FALSE;
219 EPL_MCO_GLB_VAR(m_fTimerMsPreOp2) = FALSE;
220 EPL_MCO_GLB_VAR(m_fAllMandatoryCNIdent) = FALSE;
221 EPL_MCO_GLB_VAR(m_fFrozen) = FALSE;
223 // EPL_MCO_GLB_VAR(m_TimerHdl) = 0;
225 // inform higher layer about state change
226 // 2006/07/31 d.k.: The EPL API layer/application has to start NMT state
227 // machine via NmtEventSwReset after initialisation of
228 // all modules has been completed. DLL has to be initialised
229 // after NMTk because NMT state shall not be uninitialised
230 // at that time.
231 /* NmtStateChange.m_NewNmtState = EPL_MCO_GLB_VAR(m_NmtState);
232 NmtStateChange.m_NmtEvent = kEplNmtEventNoEvent;
233 Event.m_EventSink = kEplEventSinkNmtu;
234 Event.m_EventType = kEplEventTypeNmtStateChange;
235 EPL_MEMSET(&Event.m_NetTime, 0x00, sizeof(Event.m_NetTime));
236 Event.m_pArg = &NmtStateChange;
237 Event.m_uiSize = sizeof(NmtStateChange);
238 Ret = EplEventkPost(&Event);
240 return Ret;
243 //---------------------------------------------------------------------------
245 // Function: EplNmtkDelInstance
247 // Description: delete instance
251 // Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR = Instance pointer
254 // Returns: tEplKernel = Errorcode
257 // State:
259 //---------------------------------------------------------------------------
260 #if (EPL_USE_DELETEINST_FUNC != FALSE)
261 tEplKernel EplNmtkDelInstance(EPL_MCO_DECL_PTR_INSTANCE_PTR)
263 tEplKernel Ret = kEplSuccessful;
264 // check for all API function if instance is valid
265 EPL_MCO_CHECK_INSTANCE_STATE();
267 // set NMT-State to kEplNmtGsOff
268 EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff;
270 // sign instance as unused
271 EPL_MCO_WRITE_INSTANCE_STATE(kStateUnused);
273 // delete timer
274 // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
276 return Ret;
278 #endif // (EPL_USE_DELETEINST_FUNC != FALSE)
280 //---------------------------------------------------------------------------
282 // Function: EplNmtkProcess
284 // Description: main process function
285 // -> process NMT-State-Maschine und read NMT-Events from Queue
289 // Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR_ = Instance pointer
290 // pEvent_p = Epl-Event with NMT-event to process
293 // Returns: tEplKernel = Errorcode
296 // State:
298 //---------------------------------------------------------------------------
299 tEplKernel EplNmtkProcess(EPL_MCO_DECL_PTR_INSTANCE_PTR_ tEplEvent *pEvent_p)
301 tEplKernel Ret;
302 tEplNmtState OldNmtState;
303 tEplNmtEvent NmtEvent;
304 tEplEvent Event;
305 tEplEventNmtStateChange NmtStateChange;
307 // check for all API function if instance is valid
308 EPL_MCO_CHECK_INSTANCE_STATE();
310 Ret = kEplSuccessful;
312 switch (pEvent_p->m_EventType) {
313 case kEplEventTypeNmtEvent:
315 NmtEvent = *((tEplNmtEvent *) pEvent_p->m_pArg);
316 break;
319 case kEplEventTypeTimer:
321 NmtEvent =
322 (tEplNmtEvent) ((tEplTimerEventArg *) pEvent_p->
323 m_pArg)->m_ulArg;
324 break;
326 default:
328 Ret = kEplNmtInvalidEvent;
329 goto Exit;
333 // save NMT-State
334 // needed for later comparison to
335 // inform hgher layer about state change
336 OldNmtState = EPL_MCO_GLB_VAR(m_NmtState);
338 // NMT-State-Maschine
339 switch (EPL_MCO_GLB_VAR(m_NmtState)) {
340 //-----------------------------------------------------------
341 // general part of the statemaschine
343 // first init of the hardware
344 case kEplNmtGsOff:
346 // leave this state only if higher layer says so
347 if (NmtEvent == kEplNmtEventSwReset) { // new state kEplNmtGsInitialising
348 EPL_MCO_GLB_VAR(m_NmtState) =
349 kEplNmtGsInitialising;
351 break;
354 // first init of the hardware
355 case kEplNmtGsInitialising:
357 // leave this state only if higher layer says so
359 // check events
360 switch (NmtEvent) {
361 // 2006/07/31 d.k.: react also on NMT reset commands in ResetApp state
362 // NMT Command SwitchOff
363 case kEplNmtEventCriticalError:
364 case kEplNmtEventSwitchOff:
366 EPL_MCO_GLB_VAR(m_NmtState) =
367 kEplNmtGsOff;
368 break;
371 // new state kEplNmtGsResetApplication
372 case kEplNmtEventEnterResetApp:
374 EPL_MCO_GLB_VAR(m_NmtState) =
375 kEplNmtGsResetApplication;
376 break;
379 default:
381 break;
384 break;
387 // init of the manufacturer-specific profile area and the
388 // standardised device profile area
389 case kEplNmtGsResetApplication:
391 // check events
392 switch (NmtEvent) {
393 // 2006/07/31 d.k.: react also on NMT reset commands in ResetApp state
394 // NMT Command SwitchOff
395 case kEplNmtEventCriticalError:
396 case kEplNmtEventSwitchOff:
398 EPL_MCO_GLB_VAR(m_NmtState) =
399 kEplNmtGsOff;
400 break;
403 // NMT Command SwReset
404 case kEplNmtEventSwReset:
406 EPL_MCO_GLB_VAR(m_NmtState) =
407 kEplNmtGsInitialising;
408 break;
411 // leave this state only if higher layer
412 // say so
413 case kEplNmtEventEnterResetCom:
415 // new state kEplNmtGsResetCommunication
416 EPL_MCO_GLB_VAR(m_NmtState) =
417 kEplNmtGsResetCommunication;
418 break;
421 default:
423 break;
426 break;
429 // init of the communication profile area
430 case kEplNmtGsResetCommunication:
432 // check events
433 switch (NmtEvent) {
434 // 2006/07/31 d.k.: react also on NMT reset commands in ResetComm state
435 // NMT Command SwitchOff
436 case kEplNmtEventCriticalError:
437 case kEplNmtEventSwitchOff:
439 EPL_MCO_GLB_VAR(m_NmtState) =
440 kEplNmtGsOff;
441 break;
444 // NMT Command SwReset
445 case kEplNmtEventSwReset:
447 EPL_MCO_GLB_VAR(m_NmtState) =
448 kEplNmtGsInitialising;
449 break;
452 // NMT Command ResetNode
453 case kEplNmtEventResetNode:
455 EPL_MCO_GLB_VAR(m_NmtState) =
456 kEplNmtGsResetApplication;
457 break;
460 // leave this state only if higher layer
461 // say so
462 case kEplNmtEventEnterResetConfig:
464 // new state kEplNmtGsResetCommunication
465 EPL_MCO_GLB_VAR(m_NmtState) =
466 kEplNmtGsResetConfiguration;
467 break;
470 default:
472 break;
475 break;
478 // build the configuration with infos from OD
479 case kEplNmtGsResetConfiguration:
481 // reset flags
482 EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) = FALSE;
483 EPL_MCO_GLB_VAR(m_fAppReadyToOperate) = FALSE;
484 EPL_MCO_GLB_VAR(m_fFrozen) = FALSE;
486 // check events
487 switch (NmtEvent) {
488 // 2006/07/31 d.k.: react also on NMT reset commands in ResetConf state
489 // NMT Command SwitchOff
490 case kEplNmtEventCriticalError:
491 case kEplNmtEventSwitchOff:
493 EPL_MCO_GLB_VAR(m_NmtState) =
494 kEplNmtGsOff;
495 break;
498 // NMT Command SwReset
499 case kEplNmtEventSwReset:
501 EPL_MCO_GLB_VAR(m_NmtState) =
502 kEplNmtGsInitialising;
503 break;
506 // NMT Command ResetNode
507 case kEplNmtEventResetNode:
509 EPL_MCO_GLB_VAR(m_NmtState) =
510 kEplNmtGsResetApplication;
511 break;
514 // NMT Command ResetCommunication
515 case kEplNmtEventResetCom:
517 EPL_MCO_GLB_VAR(m_NmtState) =
518 kEplNmtGsResetCommunication;
519 break;
522 // leave this state only if higher layer says so
523 case kEplNmtEventEnterCsNotActive:
524 { // Node should be CN
525 EPL_MCO_GLB_VAR(m_NmtState) =
526 kEplNmtCsNotActive;
527 break;
531 case kEplNmtEventEnterMsNotActive:
532 { // Node should be CN
533 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) == 0)
534 // no MN functionality
535 // TODO: -create error E_NMT_BA1_NO_MN_SUPPORT
536 EPL_MCO_GLB_VAR(m_fFrozen) = TRUE;
537 #else
539 EPL_MCO_GLB_VAR(m_NmtState) =
540 kEplNmtMsNotActive;
541 #endif
542 break;
546 default:
548 break;
551 break;
554 //-----------------------------------------------------------
555 // CN part of the statemaschine
557 // node liste for EPL-Frames and check timeout
558 case kEplNmtCsNotActive:
561 // check events
562 switch (NmtEvent) {
563 // 2006/07/31 d.k.: react also on NMT reset commands in NotActive state
564 // NMT Command SwitchOff
565 case kEplNmtEventCriticalError:
566 case kEplNmtEventSwitchOff:
568 EPL_MCO_GLB_VAR(m_NmtState) =
569 kEplNmtGsOff;
570 break;
573 // NMT Command SwReset
574 case kEplNmtEventSwReset:
576 EPL_MCO_GLB_VAR(m_NmtState) =
577 kEplNmtGsInitialising;
578 // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
579 break;
582 // NMT Command ResetNode
583 case kEplNmtEventResetNode:
585 EPL_MCO_GLB_VAR(m_NmtState) =
586 kEplNmtGsResetApplication;
587 // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
588 break;
591 // NMT Command ResetCommunication
592 // or internal Communication error
593 case kEplNmtEventResetCom:
594 case kEplNmtEventInternComError:
596 EPL_MCO_GLB_VAR(m_NmtState) =
597 kEplNmtGsResetCommunication;
598 // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
599 break;
602 // NMT Command Reset Configuration
603 case kEplNmtEventResetConfig:
605 EPL_MCO_GLB_VAR(m_NmtState) =
606 kEplNmtGsResetConfiguration;
607 // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
608 break;
611 // see if SoA or SoC received
612 // k.t. 20.07.2006: only SoA forces change of state
613 // see EPL V2 DS 1.0.0 p.267
614 // case kEplNmtEventDllCeSoc:
615 case kEplNmtEventDllCeSoa:
616 { // new state PRE_OPERATIONAL1
617 EPL_MCO_GLB_VAR(m_NmtState) =
618 kEplNmtCsPreOperational1;
619 // Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
620 break;
622 // timeout for SoA and Soc
623 case kEplNmtEventTimerBasicEthernet:
625 // new state BASIC_ETHERNET
626 EPL_MCO_GLB_VAR(m_NmtState) =
627 kEplNmtCsBasicEthernet;
628 break;
631 default:
633 break;
635 } // end of switch(NmtEvent)
637 break;
640 // node processes only async frames
641 case kEplNmtCsPreOperational1:
644 // check events
645 switch (NmtEvent) {
646 // NMT Command SwitchOff
647 case kEplNmtEventCriticalError:
648 case kEplNmtEventSwitchOff:
650 EPL_MCO_GLB_VAR(m_NmtState) =
651 kEplNmtGsOff;
652 break;
655 // NMT Command SwReset
656 case kEplNmtEventSwReset:
658 EPL_MCO_GLB_VAR(m_NmtState) =
659 kEplNmtGsInitialising;
660 break;
663 // NMT Command ResetNode
664 case kEplNmtEventResetNode:
666 EPL_MCO_GLB_VAR(m_NmtState) =
667 kEplNmtGsResetApplication;
668 break;
671 // NMT Command ResetCommunication
672 // or internal Communication error
673 case kEplNmtEventResetCom:
674 case kEplNmtEventInternComError:
676 EPL_MCO_GLB_VAR(m_NmtState) =
677 kEplNmtGsResetCommunication;
678 break;
681 // NMT Command Reset Configuration
682 case kEplNmtEventResetConfig:
684 EPL_MCO_GLB_VAR(m_NmtState) =
685 kEplNmtGsResetConfiguration;
686 break;
689 // NMT Command StopNode
690 case kEplNmtEventStopNode:
692 EPL_MCO_GLB_VAR(m_NmtState) =
693 kEplNmtCsStopped;
694 break;
697 // check if SoC received
698 case kEplNmtEventDllCeSoc:
700 EPL_MCO_GLB_VAR(m_NmtState) =
701 kEplNmtCsPreOperational2;
702 break;
705 default:
707 break;
710 } // end of switch(NmtEvent)
712 break;
715 // node processes isochronous and asynchronous frames
716 case kEplNmtCsPreOperational2:
718 // check events
719 switch (NmtEvent) {
720 // NMT Command SwitchOff
721 case kEplNmtEventCriticalError:
722 case kEplNmtEventSwitchOff:
724 EPL_MCO_GLB_VAR(m_NmtState) =
725 kEplNmtGsOff;
726 break;
729 // NMT Command SwReset
730 case kEplNmtEventSwReset:
732 EPL_MCO_GLB_VAR(m_NmtState) =
733 kEplNmtGsInitialising;
734 break;
737 // NMT Command ResetNode
738 case kEplNmtEventResetNode:
740 EPL_MCO_GLB_VAR(m_NmtState) =
741 kEplNmtGsResetApplication;
742 break;
745 // NMT Command ResetCommunication
746 // or internal Communication error
747 case kEplNmtEventResetCom:
748 case kEplNmtEventInternComError:
750 EPL_MCO_GLB_VAR(m_NmtState) =
751 kEplNmtGsResetCommunication;
752 break;
755 // NMT Command Reset Configuration
756 case kEplNmtEventResetConfig:
758 EPL_MCO_GLB_VAR(m_NmtState) =
759 kEplNmtGsResetConfiguration;
760 break;
763 // NMT Command StopNode
764 case kEplNmtEventStopNode:
766 // reset flags
767 EPL_MCO_GLB_VAR(m_fEnableReadyToOperate)
768 = FALSE;
769 EPL_MCO_GLB_VAR(m_fAppReadyToOperate) =
770 FALSE;
771 EPL_MCO_GLB_VAR(m_NmtState) =
772 kEplNmtCsStopped;
773 break;
776 // error occured
777 case kEplNmtEventNmtCycleError:
779 // reset flags
780 EPL_MCO_GLB_VAR(m_fEnableReadyToOperate)
781 = FALSE;
782 EPL_MCO_GLB_VAR(m_fAppReadyToOperate) =
783 FALSE;
784 EPL_MCO_GLB_VAR(m_NmtState) =
785 kEplNmtCsPreOperational1;
786 break;
789 // check if application is ready to operate
790 case kEplNmtEventEnterReadyToOperate:
792 // check if command NMTEnableReadyToOperate from MN was received
793 if (EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) == TRUE) { // reset flags
794 EPL_MCO_GLB_VAR
795 (m_fEnableReadyToOperate) =
796 FALSE;
797 EPL_MCO_GLB_VAR
798 (m_fAppReadyToOperate) =
799 FALSE;
800 // change state
801 EPL_MCO_GLB_VAR(m_NmtState) =
802 kEplNmtCsReadyToOperate;
803 } else { // set Flag
804 EPL_MCO_GLB_VAR
805 (m_fAppReadyToOperate) =
806 TRUE;
808 break;
811 // NMT Commando EnableReadyToOperate
812 case kEplNmtEventEnableReadyToOperate:
814 // check if application is ready
815 if (EPL_MCO_GLB_VAR(m_fAppReadyToOperate) == TRUE) { // reset flags
816 EPL_MCO_GLB_VAR
817 (m_fEnableReadyToOperate) =
818 FALSE;
819 EPL_MCO_GLB_VAR
820 (m_fAppReadyToOperate) =
821 FALSE;
822 // change state
823 EPL_MCO_GLB_VAR(m_NmtState) =
824 kEplNmtCsReadyToOperate;
825 } else { // set Flag
826 EPL_MCO_GLB_VAR
827 (m_fEnableReadyToOperate) =
828 TRUE;
830 break;
833 default:
835 break;
838 } // end of switch(NmtEvent)
839 break;
842 // node should be configured und application is ready
843 case kEplNmtCsReadyToOperate:
845 // check events
846 switch (NmtEvent) {
847 // NMT Command SwitchOff
848 case kEplNmtEventCriticalError:
849 case kEplNmtEventSwitchOff:
851 EPL_MCO_GLB_VAR(m_NmtState) =
852 kEplNmtGsOff;
853 break;
856 // NMT Command SwReset
857 case kEplNmtEventSwReset:
859 EPL_MCO_GLB_VAR(m_NmtState) =
860 kEplNmtGsInitialising;
861 break;
864 // NMT Command ResetNode
865 case kEplNmtEventResetNode:
867 EPL_MCO_GLB_VAR(m_NmtState) =
868 kEplNmtGsResetApplication;
869 break;
872 // NMT Command ResetCommunication
873 // or internal Communication error
874 case kEplNmtEventResetCom:
875 case kEplNmtEventInternComError:
877 EPL_MCO_GLB_VAR(m_NmtState) =
878 kEplNmtGsResetCommunication;
879 break;
882 // NMT Command ResetConfiguration
883 case kEplNmtEventResetConfig:
885 EPL_MCO_GLB_VAR(m_NmtState) =
886 kEplNmtGsResetConfiguration;
887 break;
890 // NMT Command StopNode
891 case kEplNmtEventStopNode:
893 EPL_MCO_GLB_VAR(m_NmtState) =
894 kEplNmtCsStopped;
895 break;
898 // error occured
899 case kEplNmtEventNmtCycleError:
901 EPL_MCO_GLB_VAR(m_NmtState) =
902 kEplNmtCsPreOperational1;
903 break;
906 // NMT Command StartNode
907 case kEplNmtEventStartNode:
909 EPL_MCO_GLB_VAR(m_NmtState) =
910 kEplNmtCsOperational;
911 break;
914 default:
916 break;
919 } // end of switch(NmtEvent)
920 break;
923 // normal work state
924 case kEplNmtCsOperational:
927 // check events
928 switch (NmtEvent) {
929 // NMT Command SwitchOff
930 case kEplNmtEventCriticalError:
931 case kEplNmtEventSwitchOff:
933 EPL_MCO_GLB_VAR(m_NmtState) =
934 kEplNmtGsOff;
935 break;
938 // NMT Command SwReset
939 case kEplNmtEventSwReset:
941 EPL_MCO_GLB_VAR(m_NmtState) =
942 kEplNmtGsInitialising;
943 break;
946 // NMT Command ResetNode
947 case kEplNmtEventResetNode:
949 EPL_MCO_GLB_VAR(m_NmtState) =
950 kEplNmtGsResetApplication;
951 break;
954 // NMT Command ResetCommunication
955 // or internal Communication error
956 case kEplNmtEventResetCom:
957 case kEplNmtEventInternComError:
959 EPL_MCO_GLB_VAR(m_NmtState) =
960 kEplNmtGsResetCommunication;
961 break;
964 // NMT Command ResetConfiguration
965 case kEplNmtEventResetConfig:
967 EPL_MCO_GLB_VAR(m_NmtState) =
968 kEplNmtGsResetConfiguration;
969 break;
972 // NMT Command StopNode
973 case kEplNmtEventStopNode:
975 EPL_MCO_GLB_VAR(m_NmtState) =
976 kEplNmtCsStopped;
977 break;
980 // NMT Command EnterPreOperational2
981 case kEplNmtEventEnterPreOperational2:
983 EPL_MCO_GLB_VAR(m_NmtState) =
984 kEplNmtCsPreOperational2;
985 break;
988 // error occured
989 case kEplNmtEventNmtCycleError:
991 EPL_MCO_GLB_VAR(m_NmtState) =
992 kEplNmtCsPreOperational1;
993 break;
996 default:
998 break;
1001 } // end of switch(NmtEvent)
1002 break;
1005 // node stopped by MN
1006 // -> only process asynchronous frames
1007 case kEplNmtCsStopped:
1009 // check events
1010 switch (NmtEvent) {
1011 // NMT Command SwitchOff
1012 case kEplNmtEventCriticalError:
1013 case kEplNmtEventSwitchOff:
1015 EPL_MCO_GLB_VAR(m_NmtState) =
1016 kEplNmtGsOff;
1017 break;
1020 // NMT Command SwReset
1021 case kEplNmtEventSwReset:
1023 EPL_MCO_GLB_VAR(m_NmtState) =
1024 kEplNmtGsInitialising;
1025 break;
1028 // NMT Command ResetNode
1029 case kEplNmtEventResetNode:
1031 EPL_MCO_GLB_VAR(m_NmtState) =
1032 kEplNmtGsResetApplication;
1033 break;
1036 // NMT Command ResetCommunication
1037 // or internal Communication error
1038 case kEplNmtEventResetCom:
1039 case kEplNmtEventInternComError:
1041 EPL_MCO_GLB_VAR(m_NmtState) =
1042 kEplNmtGsResetCommunication;
1043 break;
1046 // NMT Command ResetConfiguration
1047 case kEplNmtEventResetConfig:
1049 EPL_MCO_GLB_VAR(m_NmtState) =
1050 kEplNmtGsResetConfiguration;
1051 break;
1054 // NMT Command EnterPreOperational2
1055 case kEplNmtEventEnterPreOperational2:
1057 EPL_MCO_GLB_VAR(m_NmtState) =
1058 kEplNmtCsPreOperational2;
1059 break;
1062 // error occured
1063 case kEplNmtEventNmtCycleError:
1065 EPL_MCO_GLB_VAR(m_NmtState) =
1066 kEplNmtCsPreOperational1;
1067 break;
1070 default:
1072 break;
1075 } // end of switch(NmtEvent)
1076 break;
1079 // no epl cycle
1080 // -> normal ethernet communication
1081 case kEplNmtCsBasicEthernet:
1083 // check events
1084 switch (NmtEvent) {
1085 // NMT Command SwitchOff
1086 case kEplNmtEventCriticalError:
1087 case kEplNmtEventSwitchOff:
1089 EPL_MCO_GLB_VAR(m_NmtState) =
1090 kEplNmtGsOff;
1091 break;
1094 // NMT Command SwReset
1095 case kEplNmtEventSwReset:
1097 EPL_MCO_GLB_VAR(m_NmtState) =
1098 kEplNmtGsInitialising;
1099 break;
1102 // NMT Command ResetNode
1103 case kEplNmtEventResetNode:
1105 EPL_MCO_GLB_VAR(m_NmtState) =
1106 kEplNmtGsResetApplication;
1107 break;
1110 // NMT Command ResetCommunication
1111 // or internal Communication error
1112 case kEplNmtEventResetCom:
1113 case kEplNmtEventInternComError:
1115 EPL_MCO_GLB_VAR(m_NmtState) =
1116 kEplNmtGsResetCommunication;
1117 break;
1120 // NMT Command ResetConfiguration
1121 case kEplNmtEventResetConfig:
1123 EPL_MCO_GLB_VAR(m_NmtState) =
1124 kEplNmtGsResetConfiguration;
1125 break;
1128 // error occured
1129 // d.k.: how does this error occur? on CRC errors
1130 /* case kEplNmtEventNmtCycleError:
1132 EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1;
1133 break;
1136 case kEplNmtEventDllCeSoc:
1137 case kEplNmtEventDllCePreq:
1138 case kEplNmtEventDllCePres:
1139 case kEplNmtEventDllCeSoa:
1140 { // Epl-Frame on net -> stop any communication
1141 EPL_MCO_GLB_VAR(m_NmtState) =
1142 kEplNmtCsPreOperational1;
1143 break;
1146 default:
1148 break;
1151 } // end of switch(NmtEvent)
1153 break;
1156 //-----------------------------------------------------------
1157 // MN part of the statemaschine
1159 // MN listen to network
1160 // -> if no EPL traffic go to next state
1161 case kEplNmtMsNotActive:
1163 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) == 0)
1164 // no MN functionality
1165 // TODO: -create error E_NMT_BA1_NO_MN_SUPPORT
1166 EPL_MCO_GLB_VAR(m_fFrozen) = TRUE;
1167 #else
1169 // check events
1170 switch (NmtEvent) {
1171 // NMT Command SwitchOff
1172 case kEplNmtEventCriticalError:
1173 case kEplNmtEventSwitchOff:
1175 EPL_MCO_GLB_VAR(m_NmtState) =
1176 kEplNmtGsOff;
1177 break;
1180 // NMT Command SwReset
1181 case kEplNmtEventSwReset:
1183 EPL_MCO_GLB_VAR(m_NmtState) =
1184 kEplNmtGsInitialising;
1185 break;
1188 // NMT Command ResetNode
1189 case kEplNmtEventResetNode:
1191 EPL_MCO_GLB_VAR(m_NmtState) =
1192 kEplNmtGsResetApplication;
1193 break;
1196 // NMT Command ResetCommunication
1197 // or internal Communication error
1198 case kEplNmtEventResetCom:
1199 case kEplNmtEventInternComError:
1201 EPL_MCO_GLB_VAR(m_NmtState) =
1202 kEplNmtGsResetCommunication;
1203 break;
1206 // NMT Command ResetConfiguration
1207 case kEplNmtEventResetConfig:
1209 EPL_MCO_GLB_VAR(m_NmtState) =
1210 kEplNmtGsResetConfiguration;
1211 break;
1214 // EPL frames received
1215 case kEplNmtEventDllCeSoc:
1216 case kEplNmtEventDllCeSoa:
1217 { // other MN in network
1218 // $$$ d.k.: generate error history entry
1219 EPL_MCO_GLB_VAR(m_fFrozen) = TRUE;
1220 break;
1223 // timeout event
1224 case kEplNmtEventTimerBasicEthernet:
1226 if (EPL_MCO_GLB_VAR(m_fFrozen) == FALSE) { // new state BasicEthernet
1227 EPL_MCO_GLB_VAR(m_NmtState) =
1228 kEplNmtMsBasicEthernet;
1230 break;
1233 // timeout event
1234 case kEplNmtEventTimerMsPreOp1:
1236 if (EPL_MCO_GLB_VAR(m_fFrozen) == FALSE) { // new state PreOp1
1237 EPL_MCO_GLB_VAR(m_NmtState) =
1238 kEplNmtMsPreOperational1;
1239 EPL_MCO_GLB_VAR
1240 (m_fTimerMsPreOp2) = FALSE;
1241 EPL_MCO_GLB_VAR
1242 (m_fAllMandatoryCNIdent) =
1243 FALSE;
1246 break;
1249 default:
1251 break;
1254 } // end of switch(NmtEvent)
1256 #endif // ((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) == 0)
1258 break;
1260 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
1261 // MN process reduces epl cycle
1262 case kEplNmtMsPreOperational1:
1264 // check events
1265 switch (NmtEvent) {
1266 // NMT Command SwitchOff
1267 case kEplNmtEventCriticalError:
1268 case kEplNmtEventSwitchOff:
1270 EPL_MCO_GLB_VAR(m_NmtState) =
1271 kEplNmtGsOff;
1272 break;
1275 // NMT Command SwReset
1276 case kEplNmtEventSwReset:
1278 EPL_MCO_GLB_VAR(m_NmtState) =
1279 kEplNmtGsInitialising;
1280 break;
1283 // NMT Command ResetNode
1284 case kEplNmtEventResetNode:
1286 EPL_MCO_GLB_VAR(m_NmtState) =
1287 kEplNmtGsResetApplication;
1288 break;
1291 // NMT Command ResetCommunication
1292 // or internal Communication error
1293 case kEplNmtEventResetCom:
1294 case kEplNmtEventInternComError:
1296 EPL_MCO_GLB_VAR(m_NmtState) =
1297 kEplNmtGsResetCommunication;
1298 break;
1301 // NMT Command ResetConfiguration
1302 case kEplNmtEventResetConfig:
1304 EPL_MCO_GLB_VAR(m_NmtState) =
1305 kEplNmtGsResetConfiguration;
1306 break;
1309 // EPL frames received
1310 case kEplNmtEventDllCeSoc:
1311 case kEplNmtEventDllCeSoa:
1312 { // other MN in network
1313 // $$$ d.k.: generate error history entry
1314 EPL_MCO_GLB_VAR(m_NmtState) =
1315 kEplNmtGsResetCommunication;
1316 break;
1319 // error occured
1320 // d.k. MSPreOp1->CSPreOp1: nonsense -> keep state
1322 case kEplNmtEventNmtCycleError:
1324 EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1;
1325 break;
1329 case kEplNmtEventAllMandatoryCNIdent:
1330 { // all mandatory CN identified
1331 if (EPL_MCO_GLB_VAR(m_fTimerMsPreOp2) !=
1332 FALSE) {
1333 EPL_MCO_GLB_VAR(m_NmtState) =
1334 kEplNmtMsPreOperational2;
1335 } else {
1336 EPL_MCO_GLB_VAR
1337 (m_fAllMandatoryCNIdent) =
1338 TRUE;
1340 break;
1343 case kEplNmtEventTimerMsPreOp2:
1344 { // residence time for PreOp1 is elapsed
1345 if (EPL_MCO_GLB_VAR
1346 (m_fAllMandatoryCNIdent) != FALSE) {
1347 EPL_MCO_GLB_VAR(m_NmtState) =
1348 kEplNmtMsPreOperational2;
1349 } else {
1350 EPL_MCO_GLB_VAR
1351 (m_fTimerMsPreOp2) = TRUE;
1353 break;
1356 default:
1358 break;
1361 } // end of switch(NmtEvent)
1362 break;
1365 // MN process full epl cycle
1366 case kEplNmtMsPreOperational2:
1368 // check events
1369 switch (NmtEvent) {
1370 // NMT Command SwitchOff
1371 case kEplNmtEventCriticalError:
1372 case kEplNmtEventSwitchOff:
1374 EPL_MCO_GLB_VAR(m_NmtState) =
1375 kEplNmtGsOff;
1376 break;
1379 // NMT Command SwReset
1380 case kEplNmtEventSwReset:
1382 EPL_MCO_GLB_VAR(m_NmtState) =
1383 kEplNmtGsInitialising;
1384 break;
1387 // NMT Command ResetNode
1388 case kEplNmtEventResetNode:
1390 EPL_MCO_GLB_VAR(m_NmtState) =
1391 kEplNmtGsResetApplication;
1392 break;
1395 // NMT Command ResetCommunication
1396 // or internal Communication error
1397 case kEplNmtEventResetCom:
1398 case kEplNmtEventInternComError:
1400 EPL_MCO_GLB_VAR(m_NmtState) =
1401 kEplNmtGsResetCommunication;
1402 break;
1405 // NMT Command ResetConfiguration
1406 case kEplNmtEventResetConfig:
1408 EPL_MCO_GLB_VAR(m_NmtState) =
1409 kEplNmtGsResetConfiguration;
1410 break;
1413 // EPL frames received
1414 case kEplNmtEventDllCeSoc:
1415 case kEplNmtEventDllCeSoa:
1416 { // other MN in network
1417 // $$$ d.k.: generate error history entry
1418 EPL_MCO_GLB_VAR(m_NmtState) =
1419 kEplNmtGsResetCommunication;
1420 break;
1423 // error occured
1424 case kEplNmtEventNmtCycleError:
1426 EPL_MCO_GLB_VAR(m_NmtState) =
1427 kEplNmtMsPreOperational1;
1428 break;
1431 case kEplNmtEventEnterReadyToOperate:
1433 EPL_MCO_GLB_VAR(m_NmtState) =
1434 kEplNmtMsReadyToOperate;
1435 break;
1438 default:
1440 break;
1443 } // end of switch(NmtEvent)
1445 break;
1448 // all madatory nodes ready to operate
1449 // -> MN process full epl cycle
1450 case kEplNmtMsReadyToOperate:
1453 // check events
1454 switch (NmtEvent) {
1455 // NMT Command SwitchOff
1456 case kEplNmtEventCriticalError:
1457 case kEplNmtEventSwitchOff:
1459 EPL_MCO_GLB_VAR(m_NmtState) =
1460 kEplNmtGsOff;
1461 break;
1464 // NMT Command SwReset
1465 case kEplNmtEventSwReset:
1467 EPL_MCO_GLB_VAR(m_NmtState) =
1468 kEplNmtGsInitialising;
1469 break;
1472 // NMT Command ResetNode
1473 case kEplNmtEventResetNode:
1475 EPL_MCO_GLB_VAR(m_NmtState) =
1476 kEplNmtGsResetApplication;
1477 break;
1480 // NMT Command ResetCommunication
1481 // or internal Communication error
1482 case kEplNmtEventResetCom:
1483 case kEplNmtEventInternComError:
1485 EPL_MCO_GLB_VAR(m_NmtState) =
1486 kEplNmtGsResetCommunication;
1487 break;
1490 // NMT Command ResetConfiguration
1491 case kEplNmtEventResetConfig:
1493 EPL_MCO_GLB_VAR(m_NmtState) =
1494 kEplNmtGsResetConfiguration;
1495 break;
1498 // EPL frames received
1499 case kEplNmtEventDllCeSoc:
1500 case kEplNmtEventDllCeSoa:
1501 { // other MN in network
1502 // $$$ d.k.: generate error history entry
1503 EPL_MCO_GLB_VAR(m_NmtState) =
1504 kEplNmtGsResetCommunication;
1505 break;
1508 // error occured
1509 case kEplNmtEventNmtCycleError:
1511 EPL_MCO_GLB_VAR(m_NmtState) =
1512 kEplNmtMsPreOperational1;
1513 break;
1516 case kEplNmtEventEnterMsOperational:
1518 EPL_MCO_GLB_VAR(m_NmtState) =
1519 kEplNmtMsOperational;
1520 break;
1523 default:
1525 break;
1528 } // end of switch(NmtEvent)
1530 break;
1533 // normal eplcycle processing
1534 case kEplNmtMsOperational:
1536 // check events
1537 switch (NmtEvent) {
1538 // NMT Command SwitchOff
1539 case kEplNmtEventCriticalError:
1540 case kEplNmtEventSwitchOff:
1542 EPL_MCO_GLB_VAR(m_NmtState) =
1543 kEplNmtGsOff;
1544 break;
1547 // NMT Command SwReset
1548 case kEplNmtEventSwReset:
1550 EPL_MCO_GLB_VAR(m_NmtState) =
1551 kEplNmtGsInitialising;
1552 break;
1555 // NMT Command ResetNode
1556 case kEplNmtEventResetNode:
1558 EPL_MCO_GLB_VAR(m_NmtState) =
1559 kEplNmtGsResetApplication;
1560 break;
1563 // NMT Command ResetCommunication
1564 // or internal Communication error
1565 case kEplNmtEventResetCom:
1566 case kEplNmtEventInternComError:
1568 EPL_MCO_GLB_VAR(m_NmtState) =
1569 kEplNmtGsResetCommunication;
1570 break;
1573 // NMT Command ResetConfiguration
1574 case kEplNmtEventResetConfig:
1576 EPL_MCO_GLB_VAR(m_NmtState) =
1577 kEplNmtGsResetConfiguration;
1578 break;
1581 // EPL frames received
1582 case kEplNmtEventDllCeSoc:
1583 case kEplNmtEventDllCeSoa:
1584 { // other MN in network
1585 // $$$ d.k.: generate error history entry
1586 EPL_MCO_GLB_VAR(m_NmtState) =
1587 kEplNmtGsResetCommunication;
1588 break;
1591 // error occured
1592 case kEplNmtEventNmtCycleError:
1594 EPL_MCO_GLB_VAR(m_NmtState) =
1595 kEplNmtMsPreOperational1;
1596 break;
1599 default:
1601 break;
1604 } // end of switch(NmtEvent)
1605 break;
1608 // normal ethernet traffic
1609 case kEplNmtMsBasicEthernet:
1612 // check events
1613 switch (NmtEvent) {
1614 // NMT Command SwitchOff
1615 case kEplNmtEventCriticalError:
1616 case kEplNmtEventSwitchOff:
1618 EPL_MCO_GLB_VAR(m_NmtState) =
1619 kEplNmtGsOff;
1620 break;
1623 // NMT Command SwReset
1624 case kEplNmtEventSwReset:
1626 EPL_MCO_GLB_VAR(m_NmtState) =
1627 kEplNmtGsInitialising;
1628 break;
1631 // NMT Command ResetNode
1632 case kEplNmtEventResetNode:
1634 EPL_MCO_GLB_VAR(m_NmtState) =
1635 kEplNmtGsResetApplication;
1636 break;
1639 // NMT Command ResetCommunication
1640 // or internal Communication error
1641 case kEplNmtEventResetCom:
1642 case kEplNmtEventInternComError:
1644 EPL_MCO_GLB_VAR(m_NmtState) =
1645 kEplNmtGsResetCommunication;
1646 break;
1649 // NMT Command ResetConfiguration
1650 case kEplNmtEventResetConfig:
1652 EPL_MCO_GLB_VAR(m_NmtState) =
1653 kEplNmtGsResetConfiguration;
1654 break;
1657 // EPL frames received
1658 case kEplNmtEventDllCeSoc:
1659 case kEplNmtEventDllCeSoa:
1660 { // other MN in network
1661 // $$$ d.k.: generate error history entry
1662 EPL_MCO_GLB_VAR(m_NmtState) =
1663 kEplNmtGsResetCommunication;
1664 break;
1667 // error occured
1668 // d.k. BE->PreOp1 on cycle error? No
1669 /* case kEplNmtEventNmtCycleError:
1671 EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1;
1672 break;
1675 default:
1677 break;
1680 } // end of switch(NmtEvent)
1681 break;
1683 #endif //#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
1685 default:
1687 //DEBUG_EPL_DBGLVL_NMTK_TRACE0(EPL_DBGLVL_NMT ,"Error in EplNmtProcess: Unknown NMT-State");
1688 //EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication;
1689 Ret = kEplNmtInvalidState;
1690 goto Exit;
1693 } // end of switch(NmtEvent)
1695 // inform higher layer about State-Change if needed
1696 if (OldNmtState != EPL_MCO_GLB_VAR(m_NmtState)) {
1697 EPL_NMTK_DBG_POST_TRACE_VALUE(NmtEvent, OldNmtState,
1698 EPL_MCO_GLB_VAR(m_NmtState));
1700 // d.k.: memorize NMT state before posting any events
1701 NmtStateChange.m_NewNmtState = EPL_MCO_GLB_VAR(m_NmtState);
1703 // inform DLL
1704 if ((OldNmtState > kEplNmtGsResetConfiguration)
1705 && (EPL_MCO_GLB_VAR(m_NmtState) <=
1706 kEplNmtGsResetConfiguration)) {
1707 // send DLL DEINIT
1708 Event.m_EventSink = kEplEventSinkDllk;
1709 Event.m_EventType = kEplEventTypeDllkDestroy;
1710 EPL_MEMSET(&Event.m_NetTime, 0x00,
1711 sizeof(Event.m_NetTime));
1712 Event.m_pArg = &OldNmtState;
1713 Event.m_uiSize = sizeof(OldNmtState);
1714 // d.k.: directly call DLLk process function, because
1715 // 1. execution of process function is still synchonized and serialized,
1716 // 2. it is the same as without event queues (i.e. well tested),
1717 // 3. DLLk will get those necessary events even if event queue is full,
1718 // 4. event queue is very inefficient
1719 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
1720 Ret = EplDllkProcess(&Event);
1721 #else
1722 Ret = EplEventkPost(&Event);
1723 #endif
1724 } else if ((OldNmtState <= kEplNmtGsResetConfiguration)
1725 && (EPL_MCO_GLB_VAR(m_NmtState) >
1726 kEplNmtGsResetConfiguration)) {
1727 // send DLL INIT
1728 Event.m_EventSink = kEplEventSinkDllk;
1729 Event.m_EventType = kEplEventTypeDllkCreate;
1730 EPL_MEMSET(&Event.m_NetTime, 0x00,
1731 sizeof(Event.m_NetTime));
1732 Event.m_pArg = &NmtStateChange.m_NewNmtState;
1733 Event.m_uiSize = sizeof(NmtStateChange.m_NewNmtState);
1734 // d.k.: directly call DLLk process function, because
1735 // 1. execution of process function is still synchonized and serialized,
1736 // 2. it is the same as without event queues (i.e. well tested),
1737 // 3. DLLk will get those necessary events even if event queue is full
1738 // 4. event queue is very inefficient
1739 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
1740 Ret = EplDllkProcess(&Event);
1741 #else
1742 Ret = EplEventkPost(&Event);
1743 #endif
1744 } else
1745 if ((EPL_MCO_GLB_VAR(m_NmtState) == kEplNmtCsBasicEthernet)
1746 || (EPL_MCO_GLB_VAR(m_NmtState) ==
1747 kEplNmtMsBasicEthernet)) {
1748 tEplDllAsyncReqPriority AsyncReqPriority;
1750 // send DLL Fill Async Tx Buffer, because state BasicEthernet was entered
1751 Event.m_EventSink = kEplEventSinkDllk;
1752 Event.m_EventType = kEplEventTypeDllkFillTx;
1753 EPL_MEMSET(&Event.m_NetTime, 0x00,
1754 sizeof(Event.m_NetTime));
1755 AsyncReqPriority = kEplDllAsyncReqPrioGeneric;
1756 Event.m_pArg = &AsyncReqPriority;
1757 Event.m_uiSize = sizeof(AsyncReqPriority);
1758 // d.k.: directly call DLLk process function, because
1759 // 1. execution of process function is still synchonized and serialized,
1760 // 2. it is the same as without event queues (i.e. well tested),
1761 // 3. DLLk will get those necessary events even if event queue is full
1762 // 4. event queue is very inefficient
1763 #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
1764 Ret = EplDllkProcess(&Event);
1765 #else
1766 Ret = EplEventkPost(&Event);
1767 #endif
1769 // inform higher layer about state change
1770 NmtStateChange.m_NmtEvent = NmtEvent;
1771 Event.m_EventSink = kEplEventSinkNmtu;
1772 Event.m_EventType = kEplEventTypeNmtStateChange;
1773 EPL_MEMSET(&Event.m_NetTime, 0x00, sizeof(Event.m_NetTime));
1774 Event.m_pArg = &NmtStateChange;
1775 Event.m_uiSize = sizeof(NmtStateChange);
1776 Ret = EplEventkPost(&Event);
1777 EPL_DBGLVL_NMTK_TRACE2
1778 ("EplNmtkProcess(NMT-Event = 0x%04X): New NMT-State = 0x%03X\n",
1779 NmtEvent, NmtStateChange.m_NewNmtState);
1783 Exit:
1785 return Ret;
1788 //---------------------------------------------------------------------------
1790 // Function: EplNmtkGetNmtState
1792 // Description: return the actuell NMT-State and the bits
1793 // to for MN- or CN-mode
1797 // Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR_ = Instancepointer
1800 // Returns: tEplNmtState = NMT-State
1803 // State:
1805 //---------------------------------------------------------------------------
1806 tEplNmtState EplNmtkGetNmtState(EPL_MCO_DECL_PTR_INSTANCE_PTR)
1808 tEplNmtState NmtState;
1810 NmtState = EPL_MCO_GLB_VAR(m_NmtState);
1812 return NmtState;
1816 //=========================================================================//
1817 // //
1818 // P R I V A T E D E F I N I T I O N S //
1819 // //
1820 //=========================================================================//
1821 EPL_MCO_DECL_INSTANCE_FCT()
1822 //---------------------------------------------------------------------------
1824 // Function:
1826 // Description:
1830 // Parameters:
1833 // Returns:
1836 // State:
1838 //---------------------------------------------------------------------------
1839 #endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
1840 // EOF