1/* $Id: fsm.h,v 1.3.2.2 2001/09/23 22:24:47 kai Exp $
2 *
3 * Finite state machine
4 *
5 * Author       Karsten Keil
6 * Copyright    by Karsten Keil      <keil@isdn4linux.de>
7 *              by Kai Germaschewski <kai.germaschewski@gmx.de>
8 *
9 * This software may be used and distributed according to the terms
10 * of the GNU General Public License, incorporated herein by reference.
11 *
12 */
13
14#ifndef __FSM_H__
15#define __FSM_H__
16
17#include <linux/timer.h>
18
19struct FsmInst;
20
21typedef void (*FSMFNPTR)(struct FsmInst *, int, void *);
22
23struct Fsm {
24	FSMFNPTR *jumpmatrix;
25	int state_count, event_count;
26	char **strEvent, **strState;
27};
28
29struct FsmInst {
30	struct Fsm *fsm;
31	int state;
32	int debug;
33	void *userdata;
34	int userint;
35	void (*printdebug) (struct FsmInst *, char *, ...);
36};
37
38struct FsmNode {
39	int state, event;
40	void (*routine) (struct FsmInst *, int, void *);
41};
42
43struct FsmTimer {
44	struct FsmInst *fi;
45	struct timer_list tl;
46	int event;
47	void *arg;
48};
49
50int FsmNew(struct Fsm *fsm, struct FsmNode *fnlist, int fncount);
51void FsmFree(struct Fsm *fsm);
52int FsmEvent(struct FsmInst *fi, int event, void *arg);
53void FsmChangeState(struct FsmInst *fi, int newstate);
54void FsmInitTimer(struct FsmInst *fi, struct FsmTimer *ft);
55int FsmAddTimer(struct FsmTimer *ft, int millisec, int event,
56		void *arg, int where);
57void FsmRestartTimer(struct FsmTimer *ft, int millisec, int event,
58		     void *arg, int where);
59void FsmDelTimer(struct FsmTimer *ft, int where);
60
61#endif
62