Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Typedefs | Functions
csr_wifi_fsm.h File Reference
#include "csr_prim_defs.h"
#include "csr_log_text.h"
#include "csr_wifi_fsm_event.h"
#include "csr_wifi_common.h"

Go to the source code of this file.

Macros

#define CSR_WIFI_FSM_ENV   (0xFFFF)
 
#define CsrWifiFsmSendAlienEventExternal(_context, _alienEvent, _source, _destination, _primtype, _id)
 Adds an Alien event to the FSM context's external event queue for processing.
 

Typedefs

typedef struct CsrWifiFsmContext CsrWifiFsmContext
 Toplevel FSM context data.
 
typedef void(* CsrWifiFsmExternalWakupCallbackPtr )(void *context)
 FSM External Wakeup CallbackFunction Pointer.
 

Functions

CsrWifiFsmContextCsrWifiFsmInit (void *applicationContext, void *externalContext, u16 maxProcesses, CsrLogTextTaskId loggingTaskId)
 Initialises a top level FSM context.
 
void CsrWifiFsmReset (CsrWifiFsmContext *context)
 Resets the FSM's back to first conditions.
 
void CsrWifiFsmShutdown (CsrWifiFsmContext *context)
 Frees resources allocated by CsrWifiFsmInit.
 
u32 CsrWifiFsmExecute (CsrWifiFsmContext *context)
 Executes the fsm context.
 
void CsrWifiFsmSendEventExternal (CsrWifiFsmContext *context, CsrWifiFsmEvent *event, u16 source, u16 destination, CsrPrim primtype, u16 id)
 Adds an event to the FSM context's external event queue for processing.
 
u32 CsrWifiFsmGetTimeOfDayMs (CsrWifiFsmContext *context)
 Current time of day in ms.
 
u32 CsrWifiFsmGetNextTimeout (CsrWifiFsmContext *context)
 Gets the time until the next FSM timer expiry.
 
void CsrWifiFsmFastForward (CsrWifiFsmContext *context, u16 ms)
 Fast forwards the fsm timers by ms Milliseconds.
 
void CsrWifiFsmTestAdvanceTime (CsrWifiFsmContext *context, u32 ms)
 shift the current time of day by ms amount
 
u8 CsrWifiFsmHasEvents (CsrWifiFsmContext *context)
 Check if the fsm has events to process.
 
void CsrWifiFsmInstallWakeupCallback (CsrWifiFsmContext *context, CsrWifiFsmExternalWakupCallbackPtr callback)
 function that installs the contexts wakeup function
 

Macro Definition Documentation

#define CSR_WIFI_FSM_ENV   (0xFFFF)

Definition at line 25 of file csr_wifi_fsm.h.

#define CsrWifiFsmSendAlienEventExternal (   _context,
  _alienEvent,
  _source,
  _destination,
  _primtype,
  _id 
)
Value:
{ \
_evt->alienEvent = _alienEvent; \
CsrWifiFsmSendEventExternal(_context, (CsrWifiFsmEvent *)_evt, _source, _destination, _primtype, _id); \
}

Adds an Alien event to the FSM context's external event queue for processing.

Description
Adds an event to the contexts external queue This is thread safe and adds an event to the fsm's external event queue.
Parameters
[in]context: FSM context
[in]event: event to add to the event queue
[in]source: source of the event (this can be a synergy task queue or an fsm instance id)
[in]destination: destination of the event (This can be a fsm instance id or CSR_WIFI_FSM_ENV)
[in]id: event id

Definition at line 160 of file csr_wifi_fsm.h.

Typedef Documentation

Toplevel FSM context data.

Description
Holds ALL FSM static and dynamic data for a FSM

Definition at line 34 of file csr_wifi_fsm.h.

typedef void(* CsrWifiFsmExternalWakupCallbackPtr)(void *context)

FSM External Wakeup CallbackFunction Pointer.

Description
Defines the external wakeup function for the FSM to call when an external event is injected into the systen
Parameters
[in]context: External context
Returns
void

Definition at line 49 of file csr_wifi_fsm.h.

Function Documentation

u32 CsrWifiFsmExecute ( CsrWifiFsmContext context)

Executes the fsm context.

Description
Executes the FSM context and runs until ALL events in the context are processed. When no more events are left to process then CsrWifiFsmExecute() returns to a time specifying when to next call the CsrWifiFsmExecute() Scheduling, threading, blocking and external event notification are outside the scope of the FSM and CsrWifiFsmExecute().
Parameters
[in]context: FSM context
Returns
u32 Time in ms until next timeout or 0xFFFFFFFF for no timer set
void CsrWifiFsmFastForward ( CsrWifiFsmContext context,
u16  ms 
)

Fast forwards the fsm timers by ms Milliseconds.

Parameters
[in]context: FSM context
[in]ms: Milliseconds to fast forward by
Returns
void
u32 CsrWifiFsmGetNextTimeout ( CsrWifiFsmContext context)

Gets the time until the next FSM timer expiry.

Description
Returns the next timeout time or 0 if no timers are set.
Parameters
[in]context: FSM context
Returns
u32 Time in ms until next timeout or 0xFFFFFFFF for no timer set
u32 CsrWifiFsmGetTimeOfDayMs ( CsrWifiFsmContext context)

Current time of day in ms.

Parameters
[in]context: FSM context
Returns
u32 32 bit ms tick
u8 CsrWifiFsmHasEvents ( CsrWifiFsmContext context)

Check if the fsm has events to process.

Parameters
[in]context: FSM context
Returns
u8 returns TRUE if there are events for the FSM to process
CsrWifiFsmContext* CsrWifiFsmInit ( void applicationContext,
void externalContext,
u16  maxProcesses,
CsrLogTextTaskId  loggingTaskId 
)

Initialises a top level FSM context.

Description
Initialises the FSM Context to an initial state and allocates space for "maxProcesses" number of instances
Parameters
[in]osaContext: OSA context
[in]applicationContext: Internal fsm application context
[in]externalContext: External context
[in]maxProcesses: Max processes to allocate room for
Returns
CsrWifiFsmContext* fsm context
void CsrWifiFsmInstallWakeupCallback ( CsrWifiFsmContext context,
CsrWifiFsmExternalWakupCallbackPtr  callback 
)

function that installs the contexts wakeup function

Parameters
[in]context: FSM context
[in]callback: Callback function pointer
Returns
void
void CsrWifiFsmReset ( CsrWifiFsmContext context)

Resets the FSM's back to first conditions.

Description
This function is used to free any dynamic resources allocated for the given context by CsrWifiFsmInit(). The FSM's reset function is called to cleanup any fsm specific memory The reset funtion does NOT need to free the fsm data pointer as CsrWifiFsmShutdown() will do it. the FSM's init function is call again to reinitialise the FSM context. CsrWifiFsmReset() should NEVER be called when CsrWifiFsmExecute() is running.
Parameters
[in]context: FSM context
Returns
void
void CsrWifiFsmSendEventExternal ( CsrWifiFsmContext context,
CsrWifiFsmEvent event,
u16  source,
u16  destination,
CsrPrim  primtype,
u16  id 
)

Adds an event to the FSM context's external event queue for processing.

Description
Adds an event to the contexts external queue This is thread safe and adds an event to the fsm's external event queue.
Parameters
[in]context: FSM context
[in]event: event to add to the event queue
[in]source: source of the event (this can be a synergy task queue or an fsm instance id)
[in]destination: destination of the event (This can be a fsm instance id or CSR_WIFI_FSM_ENV)
[in]id: event id
Returns
void
void CsrWifiFsmShutdown ( CsrWifiFsmContext context)

Frees resources allocated by CsrWifiFsmInit.

Description
This function is used to free any dynamic resources allocated for the given context by CsrWifiFsmInit(), prior to complete termination of the program. The FSM's reset function is called to cleanup any fsm specific memory. The reset funtion does NOT need to free the fsm data pointer as CsrWifiFsmShutdown() will do it. CsrWifiFsmShutdown() should NEVER be called when CsrWifiFsmExecute() is running.
Parameters
[in]context: FSM context
Returns
void
void CsrWifiFsmTestAdvanceTime ( CsrWifiFsmContext context,
u32  ms 
)

shift the current time of day by ms amount

Description
usefull to speed up tests where time needs to pass
Parameters
[in]context: FSM context
[in]ms: ms to adjust time by
Returns
void