1
2
3
4
5
6
7
8
9
10
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