| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /* $Id: fsm.h,v 1.3.2.2 2001/09/23 22:24:47 kai Exp $
 | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Finite state machine | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Author       Karsten Keil | 
					
						
							|  |  |  |  * Copyright    by Karsten Keil      <keil@isdn4linux.de> | 
					
						
							|  |  |  |  *              by Kai Germaschewski <kai.germaschewski@gmx.de> | 
					
						
							| 
									
										
										
										
											2012-02-19 19:52:38 -08:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  |  * This software may be used and distributed according to the terms | 
					
						
							|  |  |  |  * of the GNU General Public License, incorporated herein by reference. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifndef __FSM_H__
 | 
					
						
							|  |  |  | #define __FSM_H__
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <linux/timer.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct FsmInst; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-02-19 19:52:38 -08:00
										 |  |  | typedef void (*FSMFNPTR)(struct FsmInst *, int, void *); | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | struct Fsm { | 
					
						
							|  |  |  | 	FSMFNPTR *jumpmatrix; | 
					
						
							|  |  |  | 	int state_count, event_count; | 
					
						
							|  |  |  | 	char **strEvent, **strState; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct FsmInst { | 
					
						
							|  |  |  | 	struct Fsm *fsm; | 
					
						
							|  |  |  | 	int state; | 
					
						
							|  |  |  | 	int debug; | 
					
						
							|  |  |  | 	void *userdata; | 
					
						
							|  |  |  | 	int userint; | 
					
						
							|  |  |  | 	void (*printdebug) (struct FsmInst *, char *, ...); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct FsmNode { | 
					
						
							|  |  |  | 	int state, event; | 
					
						
							|  |  |  | 	void (*routine) (struct FsmInst *, int, void *); | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | struct FsmTimer { | 
					
						
							|  |  |  | 	struct FsmInst *fi; | 
					
						
							|  |  |  | 	struct timer_list tl; | 
					
						
							|  |  |  | 	int event; | 
					
						
							|  |  |  | 	void *arg; | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | int FsmNew(struct Fsm *fsm, struct FsmNode *fnlist, int fncount); | 
					
						
							|  |  |  | void FsmFree(struct Fsm *fsm); | 
					
						
							|  |  |  | int FsmEvent(struct FsmInst *fi, int event, void *arg); | 
					
						
							|  |  |  | void FsmChangeState(struct FsmInst *fi, int newstate); | 
					
						
							|  |  |  | void FsmInitTimer(struct FsmInst *fi, struct FsmTimer *ft); | 
					
						
							|  |  |  | int FsmAddTimer(struct FsmTimer *ft, int millisec, int event, | 
					
						
							|  |  |  | 		void *arg, int where); | 
					
						
							|  |  |  | void FsmRestartTimer(struct FsmTimer *ft, int millisec, int event, | 
					
						
							|  |  |  | 		     void *arg, int where); | 
					
						
							|  |  |  | void FsmDelTimer(struct FsmTimer *ft, int where); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif
 |