Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Typedefs | Functions
fsm.h File Reference
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/timer.h>
#include <linux/time.h>
#include <linux/slab.h>
#include <linux/sched.h>
#include <linux/string.h>
#include <linux/atomic.h>

Go to the source code of this file.

Data Structures

struct  fsm
 
struct  fsm_instance_t
 
struct  fsm_node
 
struct  fsm_timer
 

Macros

#define FSM_DEBUG   0
 
#define FSM_TIMER_DEBUG   0
 
#define FSM_DEBUG_HISTORY   0
 
#define FSM_HISTORY_SIZE   40
 

Typedefs

typedef void(* fsm_function_t )(struct fsm_instance_t *, int, void *)
 
typedef struct fsm_instance_t fsm_instance
 

Functions

fsm_instanceinit_fsm (char *name, const char **state_names, const char **event_names, int nr_states, int nr_events, const fsm_node *tmpl, int tmpl_len, gfp_t order)
 
void kfree_fsm (fsm_instance *fi)
 
const charfsm_getstate_str (fsm_instance *fi)
 
void fsm_settimer (fsm_instance *fi, fsm_timer *)
 
void fsm_deltimer (fsm_timer *timer)
 
int fsm_addtimer (fsm_timer *timer, int millisec, int event, void *arg)
 
void fsm_modtimer (fsm_timer *timer, int millisec, int event, void *arg)
 

Macro Definition Documentation

#define FSM_DEBUG   0

Define this to get debugging messages.

Definition at line 16 of file fsm.h.

#define FSM_DEBUG_HISTORY   0

Define these to record a history of Events/Statechanges and print it if a action_function is not found.

Definition at line 29 of file fsm.h.

#define FSM_HISTORY_SIZE   40

Definition at line 30 of file fsm.h.

#define FSM_TIMER_DEBUG   0

Define this to get debugging massages for timer handling.

Definition at line 22 of file fsm.h.

Typedef Documentation

typedef void(* fsm_function_t)(struct fsm_instance_t *, int, void *)

Definition of an action function, called by a FSM

Definition at line 37 of file fsm.h.

Representation of a FSM

Function Documentation

int fsm_addtimer ( fsm_timer timer,
int  millisec,
int  event,
void arg 
)

Adds and starts a timer to an FSM instance.

Parameters
timerThe timer to be added. The field fi of that timer must have been set to point to the instance.
millisecDuration, after which the timer should expire.
eventEvent, to trigger if timer expires.
argGeneric argument, provided to expiry function.
Returns
0 on success, -1 if timer is already active.

Definition at line 165 of file fsm.c.

void fsm_deltimer ( fsm_timer timer)

Clears a pending timer of an FSM instance.

Parameters
timerThe timer to clear.

Definition at line 155 of file fsm.c.

const char* fsm_getstate_str ( fsm_instance fi)

Retrieves the name of the state of an FSM

Parameters
fiPointer to FSM
Returns
The current state of the FSM in a human readable form.

Definition at line 123 of file fsm.c.

void fsm_modtimer ( fsm_timer timer,
int  millisec,
int  event,
void arg 
)

Modifies a timer of an FSM.

Parameters
timerThe timer to modify.
millisecDuration, after which the timer should expire.
eventEvent, to trigger if timer expires.
argGeneric argument, provided to expiry function.

Definition at line 185 of file fsm.c.

void fsm_settimer ( fsm_instance fi,
fsm_timer  
)

Initializes a timer for an FSM. This prepares an fsm_timer for usage with fsm_addtimer.

Parameters
fiPointer to FSM
timerThe timer to be initialized.

Definition at line 142 of file fsm.c.

fsm_instance* init_fsm ( char name,
const char **  state_names,
const char **  event_names,
int  nr_states,
int  nr_events,
const fsm_node tmpl,
int  tmpl_len,
gfp_t  order 
)

Creates an FSM

Parameters
nameName of this instance for logging purposes.
state_namesAn array of names for all states for logging purposes.
event_namesAn array of names for all events for logging purposes.
nr_statesNumber of states for this instance.
nr_eventsNumber of events for this instance.
tmplAn array of fsm_nodes, describing this FSM.
tmpl_lenLength of the describing array.
orderParameter for allocation of the FSM data structs.

Definition at line 16 of file fsm.c.

void kfree_fsm ( fsm_instance fi)

Releases an FSM

Parameters
fiPointer to an FSM, previously created with init_fsm.

Definition at line 72 of file fsm.c.