blob: 4e2d0e15e9473be92070ab0deb01e166f1a1e7e2 [file] [log] [blame]
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001/****************************************************************************
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 NMT-Kernelspace-Module
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: EplNmtk.c,v $
53
54 $Author: D.Krueger $
55
56 $Revision: 1.12 $ $Date: 2008/11/13 17:13:09 $
57
58 $State: Exp $
59
60 Build Environment:
61 GCC V3.4
62
63 -------------------------------------------------------------------------
64
65 Revision History:
66
67 2006/06/09 k.t.: start of the implementation
68
69****************************************************************************/
70
71#include "kernel/EplNmtk.h"
72#include "kernel/EplTimerk.h"
73
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -080074#include "kernel/EplDllk.h" // for EplDllkProcess()
Daniel Krueger9d7164c2008-12-19 11:41:57 -080075
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/***************************************************************************/
84
85//---------------------------------------------------------------------------
86// const defines
87//---------------------------------------------------------------------------
88
89// TracePoint support for realtime-debugging
90#ifdef _DBG_TRACE_POINTS_
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -080091void PUBLIC TgtDbgSignalTracePoint(BYTE bTracePointNumber_p);
92void PUBLIC TgtDbgPostTraceValue(DWORD dwTraceValue_p);
93#define TGT_DBG_SIGNAL_TRACE_POINT(p) TgtDbgSignalTracePoint(p)
94#define TGT_DBG_POST_TRACE_VALUE(v) TgtDbgPostTraceValue(v)
Daniel Krueger9d7164c2008-12-19 11:41:57 -080095#else
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -080096#define TGT_DBG_SIGNAL_TRACE_POINT(p)
97#define TGT_DBG_POST_TRACE_VALUE(v)
Daniel Krueger9d7164c2008-12-19 11:41:57 -080098#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))
103
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800104//---------------------------------------------------------------------------
105// local types
106//---------------------------------------------------------------------------
107// struct for instance table
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800108INSTANCE_TYPE_BEGIN EPL_MCO_DECL_INSTANCE_MEMBER()
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800109
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800110STATIC volatile tEplNmtState INST_FAR m_NmtState;
111STATIC volatile BOOL INST_FAR m_fEnableReadyToOperate;
112STATIC volatile BOOL INST_FAR m_fAppReadyToOperate;
113STATIC volatile BOOL INST_FAR m_fTimerMsPreOp2;
114STATIC volatile BOOL INST_FAR m_fAllMandatoryCNIdent;
115STATIC volatile BOOL INST_FAR m_fFrozen;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800116
117INSTANCE_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 MEM*
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800125EPL_MCO_DECL_INSTANCE_VAR()
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800126//---------------------------------------------------------------------------
127// local function prototypes
128//---------------------------------------------------------------------------
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800129EPL_MCO_DEFINE_INSTANCE_FCT()
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800130
131/***************************************************************************/
132/* */
133/* */
134/* C L A S S <NMT_Kernel-Module> */
135/* */
136/* */
137/***************************************************************************/
138//
139// Description: This module realize the NMT-State-Machine of the EPL-Stack
140//
141//
142/***************************************************************************/
143//=========================================================================//
144// //
145// P U B L I C F U N C T I O N S //
146// //
147//=========================================================================//
148//---------------------------------------------------------------------------
149//
150// Function: EplNmtkInit
151//
152// Description: initializes the first instance
153//
154//
155//
156// Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR = Instance pointer
157// uiNodeId_p = Node Id of the lokal node
158//
159//
160// Returns: tEplKernel = Errorcode
161//
162//
163// State:
164//
165//---------------------------------------------------------------------------
166EPLDLLEXPORT tEplKernel PUBLIC EplNmtkInit(EPL_MCO_DECL_PTR_INSTANCE_PTR)
167{
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800168 tEplKernel Ret;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800169
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800170 Ret = EplNmtkAddInstance(EPL_MCO_PTR_INSTANCE_PTR);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800171
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800172 return Ret;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800173}
174
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800175//---------------------------------------------------------------------------
176//
177// Function: EplNmtkAddInstance
178//
179// Description: adds a new instance
180//
181//
182//
183// Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR = Instance pointer
184//
185//
186// Returns: tEplKernel = Errorcode
187//
188//
189// State:
190//
191//---------------------------------------------------------------------------
192EPLDLLEXPORT tEplKernel PUBLIC EplNmtkAddInstance(EPL_MCO_DECL_PTR_INSTANCE_PTR)
193{
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800194 EPL_MCO_DECL_INSTANCE_PTR_LOCAL tEplKernel Ret;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800195//tEplEvent Event;
196//tEplEventNmtStateChange NmtStateChange;
197
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800198 // 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();
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800204
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800205 // sign instance as used
206 EPL_MCO_WRITE_INSTANCE_STATE(kStateUsed);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800207
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800208 Ret = kEplSuccessful;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800209
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800210 // 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;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800215
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800216 // 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;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800222
223// EPL_MCO_GLB_VAR(m_TimerHdl) = 0;
224
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800225 // 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.
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800231/* 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);
239*/
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800240 return Ret;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800241}
242
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800243//---------------------------------------------------------------------------
244//
245// Function: EplNmtkDelInstance
246//
247// Description: delete instance
248//
249//
250//
251// Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR = Instance pointer
252//
253//
254// Returns: tEplKernel = Errorcode
255//
256//
257// State:
258//
259//---------------------------------------------------------------------------
260#if (EPL_USE_DELETEINST_FUNC != FALSE)
261EPLDLLEXPORT tEplKernel PUBLIC EplNmtkDelInstance(EPL_MCO_DECL_PTR_INSTANCE_PTR)
262{
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800263 tEplKernel Ret = kEplSuccessful;
264 // check for all API function if instance is valid
265 EPL_MCO_CHECK_INSTANCE_STATE();
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800266
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800267 // set NMT-State to kEplNmtGsOff
268 EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsOff;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800269
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800270 // sign instance as unused
271 EPL_MCO_WRITE_INSTANCE_STATE(kStateUnused);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800272
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800273 // delete timer
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800274// Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
275
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800276 return Ret;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800277}
278#endif // (EPL_USE_DELETEINST_FUNC != FALSE)
279
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800280//---------------------------------------------------------------------------
281//
282// Function: EplNmtkProcess
283//
284// Description: main process function
285// -> process NMT-State-Maschine und read NMT-Events from Queue
286//
287//
288//
289// Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR_ = Instance pointer
290// pEvent_p = Epl-Event with NMT-event to process
291//
292//
293// Returns: tEplKernel = Errorcode
294//
295//
296// State:
297//
298//---------------------------------------------------------------------------
299EPLDLLEXPORT tEplKernel PUBLIC EplNmtkProcess(EPL_MCO_DECL_PTR_INSTANCE_PTR_
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800300 tEplEvent * pEvent_p)
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800301{
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800302 tEplKernel Ret;
303 tEplNmtState OldNmtState;
304 tEplNmtEvent NmtEvent;
305 tEplEvent Event;
306 tEplEventNmtStateChange NmtStateChange;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800307
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800308 // check for all API function if instance is valid
309 EPL_MCO_CHECK_INSTANCE_STATE();
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800310
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800311 Ret = kEplSuccessful;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800312
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800313 switch (pEvent_p->m_EventType) {
314 case kEplEventTypeNmtEvent:
315 {
316 NmtEvent = *((tEplNmtEvent *) pEvent_p->m_pArg);
317 break;
318 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800319
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800320 case kEplEventTypeTimer:
321 {
322 NmtEvent =
323 (tEplNmtEvent) ((tEplTimerEventArg *) pEvent_p->
324 m_pArg)->m_ulArg;
325 break;
326 }
327 default:
328 {
329 Ret = kEplNmtInvalidEvent;
330 goto Exit;
331 }
332 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800333
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800334 // save NMT-State
335 // needed for later comparison to
336 // inform hgher layer about state change
337 OldNmtState = EPL_MCO_GLB_VAR(m_NmtState);
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800338
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800339 // NMT-State-Maschine
340 switch (EPL_MCO_GLB_VAR(m_NmtState)) {
341 //-----------------------------------------------------------
342 // general part of the statemaschine
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800343
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800344 // first init of the hardware
345 case kEplNmtGsOff:
346 {
347 // leave this state only if higher layer says so
348 if (NmtEvent == kEplNmtEventSwReset) { // new state kEplNmtGsInitialising
349 EPL_MCO_GLB_VAR(m_NmtState) =
350 kEplNmtGsInitialising;
351 }
352 break;
353 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800354
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800355 // first init of the hardware
356 case kEplNmtGsInitialising:
357 {
358 // leave this state only if higher layer says so
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800359
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800360 // check events
361 switch (NmtEvent) {
362 // 2006/07/31 d.k.: react also on NMT reset commands in ResetApp state
363 // NMT Command SwitchOff
364 case kEplNmtEventCriticalError:
365 case kEplNmtEventSwitchOff:
366 {
367 EPL_MCO_GLB_VAR(m_NmtState) =
368 kEplNmtGsOff;
369 break;
370 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800371
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800372 // new state kEplNmtGsResetApplication
373 case kEplNmtEventEnterResetApp:
374 {
375 EPL_MCO_GLB_VAR(m_NmtState) =
376 kEplNmtGsResetApplication;
377 break;
378 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800379
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800380 default:
381 {
382 break;
383 }
384 }
385 break;
386 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800387
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800388 // init of the manufacturer-specific profile area and the
389 // standardised device profile area
390 case kEplNmtGsResetApplication:
391 {
392 // check events
393 switch (NmtEvent) {
394 // 2006/07/31 d.k.: react also on NMT reset commands in ResetApp state
395 // NMT Command SwitchOff
396 case kEplNmtEventCriticalError:
397 case kEplNmtEventSwitchOff:
398 {
399 EPL_MCO_GLB_VAR(m_NmtState) =
400 kEplNmtGsOff;
401 break;
402 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800403
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800404 // NMT Command SwReset
405 case kEplNmtEventSwReset:
406 {
407 EPL_MCO_GLB_VAR(m_NmtState) =
408 kEplNmtGsInitialising;
409 break;
410 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800411
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800412 // leave this state only if higher layer
413 // say so
414 case kEplNmtEventEnterResetCom:
415 {
416 // new state kEplNmtGsResetCommunication
417 EPL_MCO_GLB_VAR(m_NmtState) =
418 kEplNmtGsResetCommunication;
419 break;
420 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800421
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800422 default:
423 {
424 break;
425 }
426 }
427 break;
428 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800429
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800430 // init of the communication profile area
431 case kEplNmtGsResetCommunication:
432 {
433 // check events
434 switch (NmtEvent) {
435 // 2006/07/31 d.k.: react also on NMT reset commands in ResetComm state
436 // NMT Command SwitchOff
437 case kEplNmtEventCriticalError:
438 case kEplNmtEventSwitchOff:
439 {
440 EPL_MCO_GLB_VAR(m_NmtState) =
441 kEplNmtGsOff;
442 break;
443 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800444
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800445 // NMT Command SwReset
446 case kEplNmtEventSwReset:
447 {
448 EPL_MCO_GLB_VAR(m_NmtState) =
449 kEplNmtGsInitialising;
450 break;
451 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800452
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800453 // NMT Command ResetNode
454 case kEplNmtEventResetNode:
455 {
456 EPL_MCO_GLB_VAR(m_NmtState) =
457 kEplNmtGsResetApplication;
458 break;
459 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800460
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800461 // leave this state only if higher layer
462 // say so
463 case kEplNmtEventEnterResetConfig:
464 {
465 // new state kEplNmtGsResetCommunication
466 EPL_MCO_GLB_VAR(m_NmtState) =
467 kEplNmtGsResetConfiguration;
468 break;
469 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800470
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800471 default:
472 {
473 break;
474 }
475 }
476 break;
477 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800478
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800479 // build the configuration with infos from OD
480 case kEplNmtGsResetConfiguration:
481 {
482 // reset flags
483 EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) = FALSE;
484 EPL_MCO_GLB_VAR(m_fAppReadyToOperate) = FALSE;
485 EPL_MCO_GLB_VAR(m_fFrozen) = FALSE;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800486
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800487 // check events
488 switch (NmtEvent) {
489 // 2006/07/31 d.k.: react also on NMT reset commands in ResetConf state
490 // NMT Command SwitchOff
491 case kEplNmtEventCriticalError:
492 case kEplNmtEventSwitchOff:
493 {
494 EPL_MCO_GLB_VAR(m_NmtState) =
495 kEplNmtGsOff;
496 break;
497 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800498
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800499 // NMT Command SwReset
500 case kEplNmtEventSwReset:
501 {
502 EPL_MCO_GLB_VAR(m_NmtState) =
503 kEplNmtGsInitialising;
504 break;
505 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800506
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800507 // NMT Command ResetNode
508 case kEplNmtEventResetNode:
509 {
510 EPL_MCO_GLB_VAR(m_NmtState) =
511 kEplNmtGsResetApplication;
512 break;
513 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800514
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800515 // NMT Command ResetCommunication
516 case kEplNmtEventResetCom:
517 {
518 EPL_MCO_GLB_VAR(m_NmtState) =
519 kEplNmtGsResetCommunication;
520 break;
521 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800522
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800523 // leave this state only if higher layer says so
524 case kEplNmtEventEnterCsNotActive:
525 { // Node should be CN
526 EPL_MCO_GLB_VAR(m_NmtState) =
527 kEplNmtCsNotActive;
528 break;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800529
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800530 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800531
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800532 case kEplNmtEventEnterMsNotActive:
533 { // Node should be CN
534#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) == 0)
535 // no MN functionality
536 // TODO: -create error E_NMT_BA1_NO_MN_SUPPORT
537 EPL_MCO_GLB_VAR(m_fFrozen) = TRUE;
538#else
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800539
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800540 EPL_MCO_GLB_VAR(m_NmtState) =
541 kEplNmtMsNotActive;
542#endif
543 break;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800544
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800545 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800546
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800547 default:
548 {
549 break;
550 }
551 }
552 break;
553 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800554
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800555 //-----------------------------------------------------------
556 // CN part of the statemaschine
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800557
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800558 // node liste for EPL-Frames and check timeout
559 case kEplNmtCsNotActive:
560 {
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800561
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800562 // check events
563 switch (NmtEvent) {
564 // 2006/07/31 d.k.: react also on NMT reset commands in NotActive state
565 // NMT Command SwitchOff
566 case kEplNmtEventCriticalError:
567 case kEplNmtEventSwitchOff:
568 {
569 EPL_MCO_GLB_VAR(m_NmtState) =
570 kEplNmtGsOff;
571 break;
572 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800573
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800574 // NMT Command SwReset
575 case kEplNmtEventSwReset:
576 {
577 EPL_MCO_GLB_VAR(m_NmtState) =
578 kEplNmtGsInitialising;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800579// Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800580 break;
581 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800582
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800583 // NMT Command ResetNode
584 case kEplNmtEventResetNode:
585 {
586 EPL_MCO_GLB_VAR(m_NmtState) =
587 kEplNmtGsResetApplication;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800588// Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800589 break;
590 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800591
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800592 // NMT Command ResetCommunication
593 // or internal Communication error
594 case kEplNmtEventResetCom:
595 case kEplNmtEventInternComError:
596 {
597 EPL_MCO_GLB_VAR(m_NmtState) =
598 kEplNmtGsResetCommunication;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800599// Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800600 break;
601 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800602
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800603 // NMT Command Reset Configuration
604 case kEplNmtEventResetConfig:
605 {
606 EPL_MCO_GLB_VAR(m_NmtState) =
607 kEplNmtGsResetConfiguration;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800608// Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800609 break;
610 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800611
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800612 // see if SoA or SoC received
613 // k.t. 20.07.2006: only SoA forces change of state
614 // see EPL V2 DS 1.0.0 p.267
615 // case kEplNmtEventDllCeSoc:
616 case kEplNmtEventDllCeSoa:
617 { // new state PRE_OPERATIONAL1
618 EPL_MCO_GLB_VAR(m_NmtState) =
619 kEplNmtCsPreOperational1;
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800620// Ret = EplTimerkDeleteTimer(&EPL_MCO_GLB_VAR(m_TimerHdl));
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800621 break;
622 }
623 // timeout for SoA and Soc
624 case kEplNmtEventTimerBasicEthernet:
625 {
626 // new state BASIC_ETHERNET
627 EPL_MCO_GLB_VAR(m_NmtState) =
628 kEplNmtCsBasicEthernet;
629 break;
630 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800631
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800632 default:
633 {
634 break;
635 }
636 } // end of switch(NmtEvent)
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800637
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800638 break;
639 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800640
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800641 // node processes only async frames
642 case kEplNmtCsPreOperational1:
643 {
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800644
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800645 // check events
646 switch (NmtEvent) {
647 // NMT Command SwitchOff
648 case kEplNmtEventCriticalError:
649 case kEplNmtEventSwitchOff:
650 {
651 EPL_MCO_GLB_VAR(m_NmtState) =
652 kEplNmtGsOff;
653 break;
654 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800655
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800656 // NMT Command SwReset
657 case kEplNmtEventSwReset:
658 {
659 EPL_MCO_GLB_VAR(m_NmtState) =
660 kEplNmtGsInitialising;
661 break;
662 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800663
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800664 // NMT Command ResetNode
665 case kEplNmtEventResetNode:
666 {
667 EPL_MCO_GLB_VAR(m_NmtState) =
668 kEplNmtGsResetApplication;
669 break;
670 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800671
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800672 // NMT Command ResetCommunication
673 // or internal Communication error
674 case kEplNmtEventResetCom:
675 case kEplNmtEventInternComError:
676 {
677 EPL_MCO_GLB_VAR(m_NmtState) =
678 kEplNmtGsResetCommunication;
679 break;
680 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800681
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800682 // NMT Command Reset Configuration
683 case kEplNmtEventResetConfig:
684 {
685 EPL_MCO_GLB_VAR(m_NmtState) =
686 kEplNmtGsResetConfiguration;
687 break;
688 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800689
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800690 // NMT Command StopNode
691 case kEplNmtEventStopNode:
692 {
693 EPL_MCO_GLB_VAR(m_NmtState) =
694 kEplNmtCsStopped;
695 break;
696 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800697
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800698 // check if SoC received
699 case kEplNmtEventDllCeSoc:
700 {
701 EPL_MCO_GLB_VAR(m_NmtState) =
702 kEplNmtCsPreOperational2;
703 break;
704 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800705
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800706 default:
707 {
708 break;
709 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800710
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800711 } // end of switch(NmtEvent)
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800712
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800713 break;
714 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800715
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800716 // node processes isochronous and asynchronous frames
717 case kEplNmtCsPreOperational2:
718 {
719 // check events
720 switch (NmtEvent) {
721 // NMT Command SwitchOff
722 case kEplNmtEventCriticalError:
723 case kEplNmtEventSwitchOff:
724 {
725 EPL_MCO_GLB_VAR(m_NmtState) =
726 kEplNmtGsOff;
727 break;
728 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800729
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800730 // NMT Command SwReset
731 case kEplNmtEventSwReset:
732 {
733 EPL_MCO_GLB_VAR(m_NmtState) =
734 kEplNmtGsInitialising;
735 break;
736 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800737
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800738 // NMT Command ResetNode
739 case kEplNmtEventResetNode:
740 {
741 EPL_MCO_GLB_VAR(m_NmtState) =
742 kEplNmtGsResetApplication;
743 break;
744 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800745
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800746 // NMT Command ResetCommunication
747 // or internal Communication error
748 case kEplNmtEventResetCom:
749 case kEplNmtEventInternComError:
750 {
751 EPL_MCO_GLB_VAR(m_NmtState) =
752 kEplNmtGsResetCommunication;
753 break;
754 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800755
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800756 // NMT Command Reset Configuration
757 case kEplNmtEventResetConfig:
758 {
759 EPL_MCO_GLB_VAR(m_NmtState) =
760 kEplNmtGsResetConfiguration;
761 break;
762 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800763
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800764 // NMT Command StopNode
765 case kEplNmtEventStopNode:
766 {
767 // reset flags
768 EPL_MCO_GLB_VAR(m_fEnableReadyToOperate)
769 = FALSE;
770 EPL_MCO_GLB_VAR(m_fAppReadyToOperate) =
771 FALSE;
772 EPL_MCO_GLB_VAR(m_NmtState) =
773 kEplNmtCsStopped;
774 break;
775 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800776
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800777 // error occured
778 case kEplNmtEventNmtCycleError:
779 {
780 // reset flags
781 EPL_MCO_GLB_VAR(m_fEnableReadyToOperate)
782 = FALSE;
783 EPL_MCO_GLB_VAR(m_fAppReadyToOperate) =
784 FALSE;
785 EPL_MCO_GLB_VAR(m_NmtState) =
786 kEplNmtCsPreOperational1;
787 break;
788 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800789
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800790 // check if application is ready to operate
791 case kEplNmtEventEnterReadyToOperate:
792 {
793 // check if command NMTEnableReadyToOperate from MN was received
794 if (EPL_MCO_GLB_VAR(m_fEnableReadyToOperate) == TRUE) { // reset flags
795 EPL_MCO_GLB_VAR
796 (m_fEnableReadyToOperate) =
797 FALSE;
798 EPL_MCO_GLB_VAR
799 (m_fAppReadyToOperate) =
800 FALSE;
801 // change state
802 EPL_MCO_GLB_VAR(m_NmtState) =
803 kEplNmtCsReadyToOperate;
804 } else { // set Flag
805 EPL_MCO_GLB_VAR
806 (m_fAppReadyToOperate) =
807 TRUE;
808 }
809 break;
810 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800811
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800812 // NMT Commando EnableReadyToOperate
813 case kEplNmtEventEnableReadyToOperate:
814 {
815 // check if application is ready
816 if (EPL_MCO_GLB_VAR(m_fAppReadyToOperate) == TRUE) { // reset flags
817 EPL_MCO_GLB_VAR
818 (m_fEnableReadyToOperate) =
819 FALSE;
820 EPL_MCO_GLB_VAR
821 (m_fAppReadyToOperate) =
822 FALSE;
823 // change state
824 EPL_MCO_GLB_VAR(m_NmtState) =
825 kEplNmtCsReadyToOperate;
826 } else { // set Flag
827 EPL_MCO_GLB_VAR
828 (m_fEnableReadyToOperate) =
829 TRUE;
830 }
831 break;
832 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800833
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800834 default:
835 {
836 break;
837 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800838
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800839 } // end of switch(NmtEvent)
840 break;
841 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800842
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800843 // node should be configured und application is ready
844 case kEplNmtCsReadyToOperate:
845 {
846 // check events
847 switch (NmtEvent) {
848 // NMT Command SwitchOff
849 case kEplNmtEventCriticalError:
850 case kEplNmtEventSwitchOff:
851 {
852 EPL_MCO_GLB_VAR(m_NmtState) =
853 kEplNmtGsOff;
854 break;
855 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800856
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800857 // NMT Command SwReset
858 case kEplNmtEventSwReset:
859 {
860 EPL_MCO_GLB_VAR(m_NmtState) =
861 kEplNmtGsInitialising;
862 break;
863 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800864
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800865 // NMT Command ResetNode
866 case kEplNmtEventResetNode:
867 {
868 EPL_MCO_GLB_VAR(m_NmtState) =
869 kEplNmtGsResetApplication;
870 break;
871 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800872
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800873 // NMT Command ResetCommunication
874 // or internal Communication error
875 case kEplNmtEventResetCom:
876 case kEplNmtEventInternComError:
877 {
878 EPL_MCO_GLB_VAR(m_NmtState) =
879 kEplNmtGsResetCommunication;
880 break;
881 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800882
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800883 // NMT Command ResetConfiguration
884 case kEplNmtEventResetConfig:
885 {
886 EPL_MCO_GLB_VAR(m_NmtState) =
887 kEplNmtGsResetConfiguration;
888 break;
889 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800890
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800891 // NMT Command StopNode
892 case kEplNmtEventStopNode:
893 {
894 EPL_MCO_GLB_VAR(m_NmtState) =
895 kEplNmtCsStopped;
896 break;
897 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800898
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800899 // error occured
900 case kEplNmtEventNmtCycleError:
901 {
902 EPL_MCO_GLB_VAR(m_NmtState) =
903 kEplNmtCsPreOperational1;
904 break;
905 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800906
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800907 // NMT Command StartNode
908 case kEplNmtEventStartNode:
909 {
910 EPL_MCO_GLB_VAR(m_NmtState) =
911 kEplNmtCsOperational;
912 break;
913 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800914
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800915 default:
916 {
917 break;
918 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800919
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800920 } // end of switch(NmtEvent)
921 break;
922 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800923
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800924 // normal work state
925 case kEplNmtCsOperational:
926 {
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800927
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800928 // check events
929 switch (NmtEvent) {
930 // NMT Command SwitchOff
931 case kEplNmtEventCriticalError:
932 case kEplNmtEventSwitchOff:
933 {
934 EPL_MCO_GLB_VAR(m_NmtState) =
935 kEplNmtGsOff;
936 break;
937 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800938
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800939 // NMT Command SwReset
940 case kEplNmtEventSwReset:
941 {
942 EPL_MCO_GLB_VAR(m_NmtState) =
943 kEplNmtGsInitialising;
944 break;
945 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800946
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800947 // NMT Command ResetNode
948 case kEplNmtEventResetNode:
949 {
950 EPL_MCO_GLB_VAR(m_NmtState) =
951 kEplNmtGsResetApplication;
952 break;
953 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800954
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800955 // NMT Command ResetCommunication
956 // or internal Communication error
957 case kEplNmtEventResetCom:
958 case kEplNmtEventInternComError:
959 {
960 EPL_MCO_GLB_VAR(m_NmtState) =
961 kEplNmtGsResetCommunication;
962 break;
963 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800964
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800965 // NMT Command ResetConfiguration
966 case kEplNmtEventResetConfig:
967 {
968 EPL_MCO_GLB_VAR(m_NmtState) =
969 kEplNmtGsResetConfiguration;
970 break;
971 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800972
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800973 // NMT Command StopNode
974 case kEplNmtEventStopNode:
975 {
976 EPL_MCO_GLB_VAR(m_NmtState) =
977 kEplNmtCsStopped;
978 break;
979 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800980
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800981 // NMT Command EnterPreOperational2
982 case kEplNmtEventEnterPreOperational2:
983 {
984 EPL_MCO_GLB_VAR(m_NmtState) =
985 kEplNmtCsPreOperational2;
986 break;
987 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800988
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800989 // error occured
990 case kEplNmtEventNmtCycleError:
991 {
992 EPL_MCO_GLB_VAR(m_NmtState) =
993 kEplNmtCsPreOperational1;
994 break;
995 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -0800996
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -0800997 default:
998 {
999 break;
1000 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001001
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001002 } // end of switch(NmtEvent)
1003 break;
1004 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001005
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001006 // node stopped by MN
1007 // -> only process asynchronous frames
1008 case kEplNmtCsStopped:
1009 {
1010 // check events
1011 switch (NmtEvent) {
1012 // NMT Command SwitchOff
1013 case kEplNmtEventCriticalError:
1014 case kEplNmtEventSwitchOff:
1015 {
1016 EPL_MCO_GLB_VAR(m_NmtState) =
1017 kEplNmtGsOff;
1018 break;
1019 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001020
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001021 // NMT Command SwReset
1022 case kEplNmtEventSwReset:
1023 {
1024 EPL_MCO_GLB_VAR(m_NmtState) =
1025 kEplNmtGsInitialising;
1026 break;
1027 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001028
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001029 // NMT Command ResetNode
1030 case kEplNmtEventResetNode:
1031 {
1032 EPL_MCO_GLB_VAR(m_NmtState) =
1033 kEplNmtGsResetApplication;
1034 break;
1035 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001036
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001037 // NMT Command ResetCommunication
1038 // or internal Communication error
1039 case kEplNmtEventResetCom:
1040 case kEplNmtEventInternComError:
1041 {
1042 EPL_MCO_GLB_VAR(m_NmtState) =
1043 kEplNmtGsResetCommunication;
1044 break;
1045 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001046
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001047 // NMT Command ResetConfiguration
1048 case kEplNmtEventResetConfig:
1049 {
1050 EPL_MCO_GLB_VAR(m_NmtState) =
1051 kEplNmtGsResetConfiguration;
1052 break;
1053 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001054
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001055 // NMT Command EnterPreOperational2
1056 case kEplNmtEventEnterPreOperational2:
1057 {
1058 EPL_MCO_GLB_VAR(m_NmtState) =
1059 kEplNmtCsPreOperational2;
1060 break;
1061 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001062
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001063 // error occured
1064 case kEplNmtEventNmtCycleError:
1065 {
1066 EPL_MCO_GLB_VAR(m_NmtState) =
1067 kEplNmtCsPreOperational1;
1068 break;
1069 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001070
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001071 default:
1072 {
1073 break;
1074 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001075
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001076 } // end of switch(NmtEvent)
1077 break;
1078 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001079
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001080 // no epl cycle
1081 // -> normal ethernet communication
1082 case kEplNmtCsBasicEthernet:
1083 {
1084 // check events
1085 switch (NmtEvent) {
1086 // NMT Command SwitchOff
1087 case kEplNmtEventCriticalError:
1088 case kEplNmtEventSwitchOff:
1089 {
1090 EPL_MCO_GLB_VAR(m_NmtState) =
1091 kEplNmtGsOff;
1092 break;
1093 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001094
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001095 // NMT Command SwReset
1096 case kEplNmtEventSwReset:
1097 {
1098 EPL_MCO_GLB_VAR(m_NmtState) =
1099 kEplNmtGsInitialising;
1100 break;
1101 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001102
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001103 // NMT Command ResetNode
1104 case kEplNmtEventResetNode:
1105 {
1106 EPL_MCO_GLB_VAR(m_NmtState) =
1107 kEplNmtGsResetApplication;
1108 break;
1109 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001110
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001111 // NMT Command ResetCommunication
1112 // or internal Communication error
1113 case kEplNmtEventResetCom:
1114 case kEplNmtEventInternComError:
1115 {
1116 EPL_MCO_GLB_VAR(m_NmtState) =
1117 kEplNmtGsResetCommunication;
1118 break;
1119 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001120
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001121 // NMT Command ResetConfiguration
1122 case kEplNmtEventResetConfig:
1123 {
1124 EPL_MCO_GLB_VAR(m_NmtState) =
1125 kEplNmtGsResetConfiguration;
1126 break;
1127 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001128
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001129 // error occured
1130 // d.k.: how does this error occur? on CRC errors
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001131/* case kEplNmtEventNmtCycleError:
1132 {
1133 EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1;
1134 break;
1135 }
1136*/
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001137 case kEplNmtEventDllCeSoc:
1138 case kEplNmtEventDllCePreq:
1139 case kEplNmtEventDllCePres:
1140 case kEplNmtEventDllCeSoa:
1141 { // Epl-Frame on net -> stop any communication
1142 EPL_MCO_GLB_VAR(m_NmtState) =
1143 kEplNmtCsPreOperational1;
1144 break;
1145 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001146
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001147 default:
1148 {
1149 break;
1150 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001151
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001152 } // end of switch(NmtEvent)
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001153
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001154 break;
1155 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001156
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001157 //-----------------------------------------------------------
1158 // MN part of the statemaschine
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001159
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001160 // MN listen to network
1161 // -> if no EPL traffic go to next state
1162 case kEplNmtMsNotActive:
1163 {
1164#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) == 0)
1165 // no MN functionality
1166 // TODO: -create error E_NMT_BA1_NO_MN_SUPPORT
1167 EPL_MCO_GLB_VAR(m_fFrozen) = TRUE;
1168#else
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001169
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001170 // check events
1171 switch (NmtEvent) {
1172 // NMT Command SwitchOff
1173 case kEplNmtEventCriticalError:
1174 case kEplNmtEventSwitchOff:
1175 {
1176 EPL_MCO_GLB_VAR(m_NmtState) =
1177 kEplNmtGsOff;
1178 break;
1179 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001180
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001181 // NMT Command SwReset
1182 case kEplNmtEventSwReset:
1183 {
1184 EPL_MCO_GLB_VAR(m_NmtState) =
1185 kEplNmtGsInitialising;
1186 break;
1187 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001188
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001189 // NMT Command ResetNode
1190 case kEplNmtEventResetNode:
1191 {
1192 EPL_MCO_GLB_VAR(m_NmtState) =
1193 kEplNmtGsResetApplication;
1194 break;
1195 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001196
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001197 // NMT Command ResetCommunication
1198 // or internal Communication error
1199 case kEplNmtEventResetCom:
1200 case kEplNmtEventInternComError:
1201 {
1202 EPL_MCO_GLB_VAR(m_NmtState) =
1203 kEplNmtGsResetCommunication;
1204 break;
1205 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001206
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001207 // NMT Command ResetConfiguration
1208 case kEplNmtEventResetConfig:
1209 {
1210 EPL_MCO_GLB_VAR(m_NmtState) =
1211 kEplNmtGsResetConfiguration;
1212 break;
1213 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001214
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001215 // EPL frames received
1216 case kEplNmtEventDllCeSoc:
1217 case kEplNmtEventDllCeSoa:
1218 { // other MN in network
1219 // $$$ d.k.: generate error history entry
1220 EPL_MCO_GLB_VAR(m_fFrozen) = TRUE;
1221 break;
1222 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001223
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001224 // timeout event
1225 case kEplNmtEventTimerBasicEthernet:
1226 {
1227 if (EPL_MCO_GLB_VAR(m_fFrozen) == FALSE) { // new state BasicEthernet
1228 EPL_MCO_GLB_VAR(m_NmtState) =
1229 kEplNmtMsBasicEthernet;
1230 }
1231 break;
1232 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001233
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001234 // timeout event
1235 case kEplNmtEventTimerMsPreOp1:
1236 {
1237 if (EPL_MCO_GLB_VAR(m_fFrozen) == FALSE) { // new state PreOp1
1238 EPL_MCO_GLB_VAR(m_NmtState) =
1239 kEplNmtMsPreOperational1;
1240 EPL_MCO_GLB_VAR
1241 (m_fTimerMsPreOp2) = FALSE;
1242 EPL_MCO_GLB_VAR
1243 (m_fAllMandatoryCNIdent) =
1244 FALSE;
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001245
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001246 }
1247 break;
1248 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001249
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001250 default:
1251 {
1252 break;
1253 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001254
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001255 } // end of switch(NmtEvent)
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001256
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001257#endif // ((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) == 0)
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001258
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001259 break;
1260 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001261#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001262 // MN process reduces epl cycle
1263 case kEplNmtMsPreOperational1:
1264 {
1265 // check events
1266 switch (NmtEvent) {
1267 // NMT Command SwitchOff
1268 case kEplNmtEventCriticalError:
1269 case kEplNmtEventSwitchOff:
1270 {
1271 EPL_MCO_GLB_VAR(m_NmtState) =
1272 kEplNmtGsOff;
1273 break;
1274 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001275
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001276 // NMT Command SwReset
1277 case kEplNmtEventSwReset:
1278 {
1279 EPL_MCO_GLB_VAR(m_NmtState) =
1280 kEplNmtGsInitialising;
1281 break;
1282 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001283
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001284 // NMT Command ResetNode
1285 case kEplNmtEventResetNode:
1286 {
1287 EPL_MCO_GLB_VAR(m_NmtState) =
1288 kEplNmtGsResetApplication;
1289 break;
1290 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001291
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001292 // NMT Command ResetCommunication
1293 // or internal Communication error
1294 case kEplNmtEventResetCom:
1295 case kEplNmtEventInternComError:
1296 {
1297 EPL_MCO_GLB_VAR(m_NmtState) =
1298 kEplNmtGsResetCommunication;
1299 break;
1300 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001301
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001302 // NMT Command ResetConfiguration
1303 case kEplNmtEventResetConfig:
1304 {
1305 EPL_MCO_GLB_VAR(m_NmtState) =
1306 kEplNmtGsResetConfiguration;
1307 break;
1308 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001309
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001310 // EPL frames received
1311 case kEplNmtEventDllCeSoc:
1312 case kEplNmtEventDllCeSoa:
1313 { // other MN in network
1314 // $$$ d.k.: generate error history entry
1315 EPL_MCO_GLB_VAR(m_NmtState) =
1316 kEplNmtGsResetCommunication;
1317 break;
1318 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001319
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001320 // error occured
1321 // d.k. MSPreOp1->CSPreOp1: nonsense -> keep state
1322 /*
1323 case kEplNmtEventNmtCycleError:
1324 {
1325 EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1;
1326 break;
1327 }
1328 */
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001329
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001330 case kEplNmtEventAllMandatoryCNIdent:
1331 { // all mandatory CN identified
1332 if (EPL_MCO_GLB_VAR(m_fTimerMsPreOp2) !=
1333 FALSE) {
1334 EPL_MCO_GLB_VAR(m_NmtState) =
1335 kEplNmtMsPreOperational2;
1336 } else {
1337 EPL_MCO_GLB_VAR
1338 (m_fAllMandatoryCNIdent) =
1339 TRUE;
1340 }
1341 break;
1342 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001343
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001344 case kEplNmtEventTimerMsPreOp2:
1345 { // residence time for PreOp1 is elapsed
1346 if (EPL_MCO_GLB_VAR
1347 (m_fAllMandatoryCNIdent) != FALSE) {
1348 EPL_MCO_GLB_VAR(m_NmtState) =
1349 kEplNmtMsPreOperational2;
1350 } else {
1351 EPL_MCO_GLB_VAR
1352 (m_fTimerMsPreOp2) = TRUE;
1353 }
1354 break;
1355 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001356
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001357 default:
1358 {
1359 break;
1360 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001361
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001362 } // end of switch(NmtEvent)
1363 break;
1364 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001365
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001366 // MN process full epl cycle
1367 case kEplNmtMsPreOperational2:
1368 {
1369 // check events
1370 switch (NmtEvent) {
1371 // NMT Command SwitchOff
1372 case kEplNmtEventCriticalError:
1373 case kEplNmtEventSwitchOff:
1374 {
1375 EPL_MCO_GLB_VAR(m_NmtState) =
1376 kEplNmtGsOff;
1377 break;
1378 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001379
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001380 // NMT Command SwReset
1381 case kEplNmtEventSwReset:
1382 {
1383 EPL_MCO_GLB_VAR(m_NmtState) =
1384 kEplNmtGsInitialising;
1385 break;
1386 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001387
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001388 // NMT Command ResetNode
1389 case kEplNmtEventResetNode:
1390 {
1391 EPL_MCO_GLB_VAR(m_NmtState) =
1392 kEplNmtGsResetApplication;
1393 break;
1394 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001395
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001396 // NMT Command ResetCommunication
1397 // or internal Communication error
1398 case kEplNmtEventResetCom:
1399 case kEplNmtEventInternComError:
1400 {
1401 EPL_MCO_GLB_VAR(m_NmtState) =
1402 kEplNmtGsResetCommunication;
1403 break;
1404 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001405
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001406 // NMT Command ResetConfiguration
1407 case kEplNmtEventResetConfig:
1408 {
1409 EPL_MCO_GLB_VAR(m_NmtState) =
1410 kEplNmtGsResetConfiguration;
1411 break;
1412 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001413
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001414 // EPL frames received
1415 case kEplNmtEventDllCeSoc:
1416 case kEplNmtEventDllCeSoa:
1417 { // other MN in network
1418 // $$$ d.k.: generate error history entry
1419 EPL_MCO_GLB_VAR(m_NmtState) =
1420 kEplNmtGsResetCommunication;
1421 break;
1422 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001423
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001424 // error occured
1425 case kEplNmtEventNmtCycleError:
1426 {
1427 EPL_MCO_GLB_VAR(m_NmtState) =
1428 kEplNmtMsPreOperational1;
1429 break;
1430 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001431
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001432 case kEplNmtEventEnterReadyToOperate:
1433 {
1434 EPL_MCO_GLB_VAR(m_NmtState) =
1435 kEplNmtMsReadyToOperate;
1436 break;
1437 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001438
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001439 default:
1440 {
1441 break;
1442 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001443
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001444 } // end of switch(NmtEvent)
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001445
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001446 break;
1447 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001448
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001449 // all madatory nodes ready to operate
1450 // -> MN process full epl cycle
1451 case kEplNmtMsReadyToOperate:
1452 {
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001453
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001454 // check events
1455 switch (NmtEvent) {
1456 // NMT Command SwitchOff
1457 case kEplNmtEventCriticalError:
1458 case kEplNmtEventSwitchOff:
1459 {
1460 EPL_MCO_GLB_VAR(m_NmtState) =
1461 kEplNmtGsOff;
1462 break;
1463 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001464
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001465 // NMT Command SwReset
1466 case kEplNmtEventSwReset:
1467 {
1468 EPL_MCO_GLB_VAR(m_NmtState) =
1469 kEplNmtGsInitialising;
1470 break;
1471 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001472
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001473 // NMT Command ResetNode
1474 case kEplNmtEventResetNode:
1475 {
1476 EPL_MCO_GLB_VAR(m_NmtState) =
1477 kEplNmtGsResetApplication;
1478 break;
1479 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001480
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001481 // NMT Command ResetCommunication
1482 // or internal Communication error
1483 case kEplNmtEventResetCom:
1484 case kEplNmtEventInternComError:
1485 {
1486 EPL_MCO_GLB_VAR(m_NmtState) =
1487 kEplNmtGsResetCommunication;
1488 break;
1489 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001490
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001491 // NMT Command ResetConfiguration
1492 case kEplNmtEventResetConfig:
1493 {
1494 EPL_MCO_GLB_VAR(m_NmtState) =
1495 kEplNmtGsResetConfiguration;
1496 break;
1497 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001498
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001499 // EPL frames received
1500 case kEplNmtEventDllCeSoc:
1501 case kEplNmtEventDllCeSoa:
1502 { // other MN in network
1503 // $$$ d.k.: generate error history entry
1504 EPL_MCO_GLB_VAR(m_NmtState) =
1505 kEplNmtGsResetCommunication;
1506 break;
1507 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001508
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001509 // error occured
1510 case kEplNmtEventNmtCycleError:
1511 {
1512 EPL_MCO_GLB_VAR(m_NmtState) =
1513 kEplNmtMsPreOperational1;
1514 break;
1515 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001516
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001517 case kEplNmtEventEnterMsOperational:
1518 {
1519 EPL_MCO_GLB_VAR(m_NmtState) =
1520 kEplNmtMsOperational;
1521 break;
1522 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001523
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001524 default:
1525 {
1526 break;
1527 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001528
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001529 } // end of switch(NmtEvent)
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001530
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001531 break;
1532 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001533
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001534 // normal eplcycle processing
1535 case kEplNmtMsOperational:
1536 {
1537 // check events
1538 switch (NmtEvent) {
1539 // NMT Command SwitchOff
1540 case kEplNmtEventCriticalError:
1541 case kEplNmtEventSwitchOff:
1542 {
1543 EPL_MCO_GLB_VAR(m_NmtState) =
1544 kEplNmtGsOff;
1545 break;
1546 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001547
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001548 // NMT Command SwReset
1549 case kEplNmtEventSwReset:
1550 {
1551 EPL_MCO_GLB_VAR(m_NmtState) =
1552 kEplNmtGsInitialising;
1553 break;
1554 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001555
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001556 // NMT Command ResetNode
1557 case kEplNmtEventResetNode:
1558 {
1559 EPL_MCO_GLB_VAR(m_NmtState) =
1560 kEplNmtGsResetApplication;
1561 break;
1562 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001563
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001564 // NMT Command ResetCommunication
1565 // or internal Communication error
1566 case kEplNmtEventResetCom:
1567 case kEplNmtEventInternComError:
1568 {
1569 EPL_MCO_GLB_VAR(m_NmtState) =
1570 kEplNmtGsResetCommunication;
1571 break;
1572 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001573
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001574 // NMT Command ResetConfiguration
1575 case kEplNmtEventResetConfig:
1576 {
1577 EPL_MCO_GLB_VAR(m_NmtState) =
1578 kEplNmtGsResetConfiguration;
1579 break;
1580 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001581
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001582 // EPL frames received
1583 case kEplNmtEventDllCeSoc:
1584 case kEplNmtEventDllCeSoa:
1585 { // other MN in network
1586 // $$$ d.k.: generate error history entry
1587 EPL_MCO_GLB_VAR(m_NmtState) =
1588 kEplNmtGsResetCommunication;
1589 break;
1590 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001591
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001592 // error occured
1593 case kEplNmtEventNmtCycleError:
1594 {
1595 EPL_MCO_GLB_VAR(m_NmtState) =
1596 kEplNmtMsPreOperational1;
1597 break;
1598 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001599
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001600 default:
1601 {
1602 break;
1603 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001604
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001605 } // end of switch(NmtEvent)
1606 break;
1607 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001608
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001609 // normal ethernet traffic
1610 case kEplNmtMsBasicEthernet:
1611 {
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001612
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001613 // check events
1614 switch (NmtEvent) {
1615 // NMT Command SwitchOff
1616 case kEplNmtEventCriticalError:
1617 case kEplNmtEventSwitchOff:
1618 {
1619 EPL_MCO_GLB_VAR(m_NmtState) =
1620 kEplNmtGsOff;
1621 break;
1622 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001623
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001624 // NMT Command SwReset
1625 case kEplNmtEventSwReset:
1626 {
1627 EPL_MCO_GLB_VAR(m_NmtState) =
1628 kEplNmtGsInitialising;
1629 break;
1630 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001631
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001632 // NMT Command ResetNode
1633 case kEplNmtEventResetNode:
1634 {
1635 EPL_MCO_GLB_VAR(m_NmtState) =
1636 kEplNmtGsResetApplication;
1637 break;
1638 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001639
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001640 // NMT Command ResetCommunication
1641 // or internal Communication error
1642 case kEplNmtEventResetCom:
1643 case kEplNmtEventInternComError:
1644 {
1645 EPL_MCO_GLB_VAR(m_NmtState) =
1646 kEplNmtGsResetCommunication;
1647 break;
1648 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001649
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001650 // NMT Command ResetConfiguration
1651 case kEplNmtEventResetConfig:
1652 {
1653 EPL_MCO_GLB_VAR(m_NmtState) =
1654 kEplNmtGsResetConfiguration;
1655 break;
1656 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001657
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001658 // EPL frames received
1659 case kEplNmtEventDllCeSoc:
1660 case kEplNmtEventDllCeSoa:
1661 { // other MN in network
1662 // $$$ d.k.: generate error history entry
1663 EPL_MCO_GLB_VAR(m_NmtState) =
1664 kEplNmtGsResetCommunication;
1665 break;
1666 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001667
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001668 // error occured
1669 // d.k. BE->PreOp1 on cycle error? No
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001670/* case kEplNmtEventNmtCycleError:
1671 {
1672 EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtCsPreOperational1;
1673 break;
1674 }
1675*/
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001676 default:
1677 {
1678 break;
1679 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001680
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001681 } // end of switch(NmtEvent)
1682 break;
1683 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001684#endif //#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMT_MN)) != 0)
1685
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001686 default:
1687 {
1688 //DEBUG_EPL_DBGLVL_NMTK_TRACE0(EPL_DBGLVL_NMT ,"Error in EplNmtProcess: Unknown NMT-State");
1689 //EPL_MCO_GLB_VAR(m_NmtState) = kEplNmtGsResetApplication;
1690 Ret = kEplNmtInvalidState;
1691 goto Exit;
1692 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001693
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001694 } // end of switch(NmtEvent)
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001695
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001696 // inform higher layer about State-Change if needed
1697 if (OldNmtState != EPL_MCO_GLB_VAR(m_NmtState)) {
1698 EPL_NMTK_DBG_POST_TRACE_VALUE(NmtEvent, OldNmtState,
1699 EPL_MCO_GLB_VAR(m_NmtState));
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001700
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001701 // d.k.: memorize NMT state before posting any events
1702 NmtStateChange.m_NewNmtState = EPL_MCO_GLB_VAR(m_NmtState);
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001703
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001704 // inform DLL
1705 if ((OldNmtState > kEplNmtGsResetConfiguration)
1706 && (EPL_MCO_GLB_VAR(m_NmtState) <=
1707 kEplNmtGsResetConfiguration)) {
1708 // send DLL DEINIT
1709 Event.m_EventSink = kEplEventSinkDllk;
1710 Event.m_EventType = kEplEventTypeDllkDestroy;
1711 EPL_MEMSET(&Event.m_NetTime, 0x00,
1712 sizeof(Event.m_NetTime));
1713 Event.m_pArg = &OldNmtState;
1714 Event.m_uiSize = sizeof(OldNmtState);
1715 // d.k.: directly call DLLk process function, because
1716 // 1. execution of process function is still synchonized and serialized,
1717 // 2. it is the same as without event queues (i.e. well tested),
1718 // 3. DLLk will get those necessary events even if event queue is full,
1719 // 4. event queue is very inefficient
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001720#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001721 Ret = EplDllkProcess(&Event);
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001722#else
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001723 Ret = EplEventkPost(&Event);
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001724#endif
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001725 } else if ((OldNmtState <= kEplNmtGsResetConfiguration)
1726 && (EPL_MCO_GLB_VAR(m_NmtState) >
1727 kEplNmtGsResetConfiguration)) {
1728 // send DLL INIT
1729 Event.m_EventSink = kEplEventSinkDllk;
1730 Event.m_EventType = kEplEventTypeDllkCreate;
1731 EPL_MEMSET(&Event.m_NetTime, 0x00,
1732 sizeof(Event.m_NetTime));
1733 Event.m_pArg = &NmtStateChange.m_NewNmtState;
1734 Event.m_uiSize = sizeof(NmtStateChange.m_NewNmtState);
1735 // d.k.: directly call DLLk process function, because
1736 // 1. execution of process function is still synchonized and serialized,
1737 // 2. it is the same as without event queues (i.e. well tested),
1738 // 3. DLLk will get those necessary events even if event queue is full
1739 // 4. event queue is very inefficient
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001740#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001741 Ret = EplDllkProcess(&Event);
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001742#else
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001743 Ret = EplEventkPost(&Event);
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001744#endif
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001745 } else
1746 if ((EPL_MCO_GLB_VAR(m_NmtState) == kEplNmtCsBasicEthernet)
1747 || (EPL_MCO_GLB_VAR(m_NmtState) ==
1748 kEplNmtMsBasicEthernet)) {
1749 tEplDllAsyncReqPriority AsyncReqPriority;
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001750
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001751 // send DLL Fill Async Tx Buffer, because state BasicEthernet was entered
1752 Event.m_EventSink = kEplEventSinkDllk;
1753 Event.m_EventType = kEplEventTypeDllkFillTx;
1754 EPL_MEMSET(&Event.m_NetTime, 0x00,
1755 sizeof(Event.m_NetTime));
1756 AsyncReqPriority = kEplDllAsyncReqPrioGeneric;
1757 Event.m_pArg = &AsyncReqPriority;
1758 Event.m_uiSize = sizeof(AsyncReqPriority);
1759 // d.k.: directly call DLLk process function, because
1760 // 1. execution of process function is still synchonized and serialized,
1761 // 2. it is the same as without event queues (i.e. well tested),
1762 // 3. DLLk will get those necessary events even if event queue is full
1763 // 4. event queue is very inefficient
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001764#if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_DLLK)) != 0)
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001765 Ret = EplDllkProcess(&Event);
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001766#else
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001767 Ret = EplEventkPost(&Event);
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001768#endif
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001769 }
1770 // inform higher layer about state change
1771 NmtStateChange.m_NmtEvent = NmtEvent;
1772 Event.m_EventSink = kEplEventSinkNmtu;
1773 Event.m_EventType = kEplEventTypeNmtStateChange;
1774 EPL_MEMSET(&Event.m_NetTime, 0x00, sizeof(Event.m_NetTime));
1775 Event.m_pArg = &NmtStateChange;
1776 Event.m_uiSize = sizeof(NmtStateChange);
1777 Ret = EplEventkPost(&Event);
1778 EPL_DBGLVL_NMTK_TRACE2
1779 ("EplNmtkProcess(NMT-Event = 0x%04X): New NMT-State = 0x%03X\n",
1780 NmtEvent, NmtStateChange.m_NewNmtState);
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001781
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001782 }
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001783
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001784 Exit:
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001785
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001786 return Ret;
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001787}
1788
1789//---------------------------------------------------------------------------
1790//
1791// Function: EplNmtkGetNmtState
1792//
1793// Description: return the actuell NMT-State and the bits
1794// to for MN- or CN-mode
1795//
1796//
1797//
1798// Parameters: EPL_MCO_DECL_PTR_INSTANCE_PTR_ = Instancepointer
1799//
1800//
1801// Returns: tEplNmtState = NMT-State
1802//
1803//
1804// State:
1805//
1806//---------------------------------------------------------------------------
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001807EPLDLLEXPORT tEplNmtState PUBLIC
1808EplNmtkGetNmtState(EPL_MCO_DECL_PTR_INSTANCE_PTR)
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001809{
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001810 tEplNmtState NmtState;
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001811
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001812 NmtState = EPL_MCO_GLB_VAR(m_NmtState);
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001813
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001814 return NmtState;
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001815
1816}
1817
1818//=========================================================================//
1819// //
1820// P R I V A T E D E F I N I T I O N S //
1821// //
1822//=========================================================================//
Greg Kroah-Hartman833dfbe2008-12-19 17:11:52 -08001823EPL_MCO_DECL_INSTANCE_FCT()
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001824//---------------------------------------------------------------------------
1825//
1826// Function:
1827//
1828// Description:
1829//
1830//
1831//
1832// Parameters:
1833//
1834//
1835// Returns:
1836//
1837//
1838// State:
1839//
1840//---------------------------------------------------------------------------
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001841#endif // #if(((EPL_MODULE_INTEGRATION) & (EPL_MODULE_NMTK)) != 0)
Daniel Krueger9d7164c2008-12-19 11:41:57 -08001842// EOF