fsm.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. *
  3. * Author Karsten Keil <kkeil@novell.com>
  4. *
  5. * Thanks to Jan den Ouden
  6. * Fritz Elfert
  7. * Copyright 2008 by Karsten Keil <kkeil@novell.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. */
  19. #ifndef _MISDN_FSM_H
  20. #define _MISDN_FSM_H
  21. #include <linux/timer.h>
  22. /* Statemachine */
  23. struct FsmInst;
  24. typedef void (*FSMFNPTR)(struct FsmInst *, int, void *);
  25. struct Fsm {
  26. FSMFNPTR *jumpmatrix;
  27. int state_count, event_count;
  28. char **strEvent, **strState;
  29. };
  30. struct FsmInst {
  31. struct Fsm *fsm;
  32. int state;
  33. int debug;
  34. void *userdata;
  35. int userint;
  36. void (*printdebug) (struct FsmInst *, char *, ...);
  37. };
  38. struct FsmNode {
  39. int state, event;
  40. void (*routine) (struct FsmInst *, int, void *);
  41. };
  42. struct FsmTimer {
  43. struct FsmInst *fi;
  44. struct timer_list tl;
  45. int event;
  46. void *arg;
  47. };
  48. extern void mISDN_FsmNew(struct Fsm *, struct FsmNode *, int);
  49. extern void mISDN_FsmFree(struct Fsm *);
  50. extern int mISDN_FsmEvent(struct FsmInst *, int , void *);
  51. extern void mISDN_FsmChangeState(struct FsmInst *, int);
  52. extern void mISDN_FsmInitTimer(struct FsmInst *, struct FsmTimer *);
  53. extern int mISDN_FsmAddTimer(struct FsmTimer *, int, int, void *, int);
  54. extern void mISDN_FsmRestartTimer(struct FsmTimer *, int, int, void *, int);
  55. extern void mISDN_FsmDelTimer(struct FsmTimer *, int);
  56. #endif