18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Author Karsten Keil <kkeil@novell.com> 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * Thanks to Jan den Ouden 78c2ecf20Sopenharmony_ci * Fritz Elfert 88c2ecf20Sopenharmony_ci * Copyright 2008 by Karsten Keil <kkeil@novell.com> 98c2ecf20Sopenharmony_ci */ 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef _MISDN_FSM_H 128c2ecf20Sopenharmony_ci#define _MISDN_FSM_H 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci#include <linux/timer.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* Statemachine */ 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_cistruct FsmInst; 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_citypedef void (*FSMFNPTR)(struct FsmInst *, int, void *); 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_cistruct Fsm { 238c2ecf20Sopenharmony_ci FSMFNPTR *jumpmatrix; 248c2ecf20Sopenharmony_ci int state_count, event_count; 258c2ecf20Sopenharmony_ci char **strEvent, **strState; 268c2ecf20Sopenharmony_ci}; 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_cistruct FsmInst { 298c2ecf20Sopenharmony_ci struct Fsm *fsm; 308c2ecf20Sopenharmony_ci int state; 318c2ecf20Sopenharmony_ci int debug; 328c2ecf20Sopenharmony_ci void *userdata; 338c2ecf20Sopenharmony_ci int userint; 348c2ecf20Sopenharmony_ci void (*printdebug) (struct FsmInst *, char *, ...); 358c2ecf20Sopenharmony_ci}; 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_cistruct FsmNode { 388c2ecf20Sopenharmony_ci int state, event; 398c2ecf20Sopenharmony_ci void (*routine) (struct FsmInst *, int, void *); 408c2ecf20Sopenharmony_ci}; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistruct FsmTimer { 438c2ecf20Sopenharmony_ci struct FsmInst *fi; 448c2ecf20Sopenharmony_ci struct timer_list tl; 458c2ecf20Sopenharmony_ci int event; 468c2ecf20Sopenharmony_ci void *arg; 478c2ecf20Sopenharmony_ci}; 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ciextern int mISDN_FsmNew(struct Fsm *, struct FsmNode *, int); 508c2ecf20Sopenharmony_ciextern void mISDN_FsmFree(struct Fsm *); 518c2ecf20Sopenharmony_ciextern int mISDN_FsmEvent(struct FsmInst *, int , void *); 528c2ecf20Sopenharmony_ciextern void mISDN_FsmChangeState(struct FsmInst *, int); 538c2ecf20Sopenharmony_ciextern void mISDN_FsmInitTimer(struct FsmInst *, struct FsmTimer *); 548c2ecf20Sopenharmony_ciextern int mISDN_FsmAddTimer(struct FsmTimer *, int, int, void *, int); 558c2ecf20Sopenharmony_ciextern void mISDN_FsmRestartTimer(struct FsmTimer *, int, int, void *, int); 568c2ecf20Sopenharmony_ciextern void mISDN_FsmDelTimer(struct FsmTimer *, int); 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#endif 59