fsm.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. *
  4. * Author Karsten Keil <[email protected]>
  5. *
  6. * Thanks to Jan den Ouden
  7. * Fritz Elfert
  8. * Copyright 2008 by Karsten Keil <[email protected]>
  9. */
  10. #ifndef _MISDN_FSM_H
  11. #define _MISDN_FSM_H
  12. #include <linux/timer.h>
  13. /* Statemachine */
  14. struct FsmInst;
  15. typedef void (*FSMFNPTR)(struct FsmInst *, int, void *);
  16. struct Fsm {
  17. FSMFNPTR *jumpmatrix;
  18. int state_count, event_count;
  19. char **strEvent, **strState;
  20. };
  21. struct FsmInst {
  22. struct Fsm *fsm;
  23. int state;
  24. int debug;
  25. void *userdata;
  26. int userint;
  27. void (*printdebug) (struct FsmInst *, char *, ...);
  28. };
  29. struct FsmNode {
  30. int state, event;
  31. void (*routine) (struct FsmInst *, int, void *);
  32. };
  33. struct FsmTimer {
  34. struct FsmInst *fi;
  35. struct timer_list tl;
  36. int event;
  37. void *arg;
  38. };
  39. extern int mISDN_FsmNew(struct Fsm *, struct FsmNode *, int);
  40. extern void mISDN_FsmFree(struct Fsm *);
  41. extern int mISDN_FsmEvent(struct FsmInst *, int , void *);
  42. extern void mISDN_FsmChangeState(struct FsmInst *, int);
  43. extern void mISDN_FsmInitTimer(struct FsmInst *, struct FsmTimer *);
  44. extern int mISDN_FsmAddTimer(struct FsmTimer *, int, int, void *, int);
  45. extern void mISDN_FsmRestartTimer(struct FsmTimer *, int, int, void *, int);
  46. extern void mISDN_FsmDelTimer(struct FsmTimer *, int);
  47. #endif