xref: /linux/drivers/isdn/mISDN/fsm.h (revision 54a6a043fb8580d5a741774669ef6049f402f228)
11b2b03f8SKarsten Keil /*
21b2b03f8SKarsten Keil  *
31b2b03f8SKarsten Keil  * Author       Karsten Keil <kkeil@novell.com>
41b2b03f8SKarsten Keil  *
51b2b03f8SKarsten Keil  * Thanks to    Jan den Ouden
61b2b03f8SKarsten Keil  *              Fritz Elfert
71b2b03f8SKarsten Keil  * Copyright 2008  by Karsten Keil <kkeil@novell.com>
81b2b03f8SKarsten Keil  *
91b2b03f8SKarsten Keil  * This program is free software; you can redistribute it and/or modify
101b2b03f8SKarsten Keil  * it under the terms of the GNU General Public License version 2 as
111b2b03f8SKarsten Keil  * published by the Free Software Foundation.
121b2b03f8SKarsten Keil  *
131b2b03f8SKarsten Keil  * This program is distributed in the hope that it will be useful,
141b2b03f8SKarsten Keil  * but WITHOUT ANY WARRANTY; without even the implied warranty of
151b2b03f8SKarsten Keil  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
161b2b03f8SKarsten Keil  * GNU General Public License for more details.
171b2b03f8SKarsten Keil  *
181b2b03f8SKarsten Keil  */
191b2b03f8SKarsten Keil 
201b2b03f8SKarsten Keil #ifndef _MISDN_FSM_H
211b2b03f8SKarsten Keil #define _MISDN_FSM_H
221b2b03f8SKarsten Keil 
231b2b03f8SKarsten Keil #include <linux/timer.h>
241b2b03f8SKarsten Keil 
251b2b03f8SKarsten Keil /* Statemachine */
261b2b03f8SKarsten Keil 
271b2b03f8SKarsten Keil struct FsmInst;
281b2b03f8SKarsten Keil 
291b2b03f8SKarsten Keil typedef void (*FSMFNPTR)(struct FsmInst *, int, void *);
301b2b03f8SKarsten Keil 
311b2b03f8SKarsten Keil struct Fsm {
321b2b03f8SKarsten Keil 	FSMFNPTR *jumpmatrix;
331b2b03f8SKarsten Keil 	int state_count, event_count;
341b2b03f8SKarsten Keil 	char **strEvent, **strState;
351b2b03f8SKarsten Keil };
361b2b03f8SKarsten Keil 
371b2b03f8SKarsten Keil struct FsmInst {
381b2b03f8SKarsten Keil 	struct Fsm *fsm;
391b2b03f8SKarsten Keil 	int state;
401b2b03f8SKarsten Keil 	int debug;
411b2b03f8SKarsten Keil 	void *userdata;
421b2b03f8SKarsten Keil 	int userint;
431b2b03f8SKarsten Keil 	void (*printdebug) (struct FsmInst *, char *, ...);
441b2b03f8SKarsten Keil };
451b2b03f8SKarsten Keil 
461b2b03f8SKarsten Keil struct FsmNode {
471b2b03f8SKarsten Keil 	int state, event;
481b2b03f8SKarsten Keil 	void (*routine) (struct FsmInst *, int, void *);
491b2b03f8SKarsten Keil };
501b2b03f8SKarsten Keil 
511b2b03f8SKarsten Keil struct FsmTimer {
521b2b03f8SKarsten Keil 	struct FsmInst *fi;
531b2b03f8SKarsten Keil 	struct timer_list tl;
541b2b03f8SKarsten Keil 	int event;
551b2b03f8SKarsten Keil 	void *arg;
561b2b03f8SKarsten Keil };
571b2b03f8SKarsten Keil 
58*54a6a043SAnton Vasilyev extern int mISDN_FsmNew(struct Fsm *, struct FsmNode *, int);
591b2b03f8SKarsten Keil extern void mISDN_FsmFree(struct Fsm *);
601b2b03f8SKarsten Keil extern int mISDN_FsmEvent(struct FsmInst *, int , void *);
611b2b03f8SKarsten Keil extern void mISDN_FsmChangeState(struct FsmInst *, int);
621b2b03f8SKarsten Keil extern void mISDN_FsmInitTimer(struct FsmInst *, struct FsmTimer *);
631b2b03f8SKarsten Keil extern int mISDN_FsmAddTimer(struct FsmTimer *, int, int, void *, int);
641b2b03f8SKarsten Keil extern void mISDN_FsmRestartTimer(struct FsmTimer *, int, int, void *, int);
651b2b03f8SKarsten Keil extern void mISDN_FsmDelTimer(struct FsmTimer *, int);
661b2b03f8SKarsten Keil 
671b2b03f8SKarsten Keil #endif
68