GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> PBS / V2-12-1 > pbs / rhel4-32
#include <PBS/WUT.h>
#include <PBS/WUT_tmr.h>
#include <PBS/TOV.h>
#include <PBS/FPA.h>
#include <PBS/MBA.h>
#include <PBS/Q.h>
#include <PBS/Q.ih>
#include <PBS/PTS.h>
#include <WCT_pvtdefs.h>
#include <PBI/PTR.h>
#include <WUT_debug.c>
Classes | |
struct | _WUT_keepalive_ctx |
Callback structure for the keepalive callbacks. More... | |
struct | _WUT_keepalive |
Captures the keepalive timer entry and context parameter. More... | |
struct | _WCB_common |
WakeUp Control Block. More... | |
Defines | |
#define | WUT_DEBUG |
Used to include debugging code. | |
#define | STATIC static |
Kludge for Doxygen,. | |
#define | MEMBER_OFFSET(_structure, _member) ((int) &(((_structure *) 0) -> _member)) |
Calculates the offset, in bytes, of the specified _member in _structure. | |
#define | WUT_M_KEY 1 |
WUT key used to allow some normally prohibited actions. | |
Typedefs | |
typedef struct _WUT_keepalive_ctx | WUT_keepalive_ctx |
Typedef for WUT_keepalive_ctx. | |
typedef struct _WUT_keepalive | WUT_keepalive |
Typedef for struct _WUT_keepalive. | |
typedef struct _WCB_common | WCB_common |
Typedef for struct _WCB. | |
typedef struct _WCB | WCB |
Typedef for struct _WCB. | |
Functions | |
STATIC WUT_tmr * | add_key (const WUT_tmr *wut) |
Adds an special key to the timer entry handle. Operations which are normally prohibited are allowed in special circumstances. | |
STATIC int | has_key (const WUT_tmr *wut) |
Tests whether the WUT timer entry has the special key attached. | |
STATIC WUT_tmr * | remove_key (const WUT_tmr *wut) |
Removes the special key from a WUT timer entry. | |
STATIC WUT_tmr * | get_wut (const Q_node *node) |
Returns a pointer to top of the WUT timer structure. | |
STATIC WUT_state | add_wut (WUT_tmr *wut, register TOV tov) |
Adds the specified WUT timer entry into the active que. | |
STATIC const Q_node * | find (const Q_head *que, register TOV tov) |
Scans the que to find the last timer entry with a timeout value smaller than tov. | |
STATIC int | cmp_lt_tov (TOV tov_a, TOV tov_b) |
Platform implementation dependent routine to compare to timeout values. | |
STATIC int | lock_que (WCB *wcb) |
Platform implementation dependent routine to lock the WUT timer que. | |
STATIC void | unlock_que (WCB *wcb, int key) |
Platform implementation dependent routine to unlock the WUT timer que. | |
STATIC void | arm_handler (WCB *wcb, TOV tov) |
Seeds the timer interrupt to handle expire a tov. | |
STATIC void | arm_handler_nxt_wut (WCB *wcb, const WUT_tmr *wut) |
Seeds the timer interrupt to handle expire at the timeout associated with the specified WUT timer entry. | |
STATIC int | wut_sys_connect (WCB *wcb) |
Platform dependent part of the WUT system connection process. | |
STATIC int | wut_sys_shutdown (WCB *wcb) |
Platform dependent shutdown of the WUT system. | |
STATIC void | wut_spc_init (WCB *wcb) |
Initializes the processor specific portion of the control block. | |
WUT_cb_status | WUT_keepalive_rtn (WUT_keepalive_ctx *keepalive, WUT_tmr *wut) |
Simple WUT timer callback routine used to drive the VxWorks system clock. | |
WUT_cb_status | WUT_keepalive_update (WUT_keepalive_ctx *keepalive, WUT_tmr *wut) |
Simple WUT timer callback routine used to update the WCT clock. | |
STATIC void | init_wut (void *unused, WUT_tmr *wut, int pckt_size, int pcb_offset) |
Initializes each timer entry as it is added to the Free Packet Pool. | |
WUT_state | WUT_cancel (WUT_tmr *wut) |
Cancels a WUT timer entry. | |
WUT_tmr * | WUT_create () |
Allocate a WUT timer entry. | |
WUT_state | WUT_destroy (WUT_tmr *wut) |
Destroys, ie frees, an unused WUT timer entry. | |
WUT_state | WUT_expire (WUT_tmr *wut) |
Marks a wut timer as expire. | |
WUT_state | WUT_restart (WUT_tmr *wut, register TOV tov) |
Restarts a WUT timer entry. | |
WUT_state | WUT_start (WUT_tmr *wut, register TOV tov, WUT_cb_routine cb, void *prm) |
Establishes and starts a WUT timer entry. | |
WUT_state | WUT_state_get (const WUT_tmr *wut) |
Gets the current state of the WUT timer entry. | |
TOV | WUT_tov_get (const WUT_tmr *wut) |
Gets the current TOV of the WUT timer entry. | |
int | WUT_overrun (const WUT_tmr *wut) |
Returns how 'on-time' the timer ISR was serviced. | |
unsigned int | WUT_frequency () |
Gets frequency, in Hertz of the WUT clock. | |
int | WUT_sys_adjust (long long int dnsecx) |
Adjusts all the current entries on the WUT timer que in response to a change in the base time. | |
int | WUT_sys_init (int count) |
One time WUT services initialization routine. | |
int | WUT_sys_connect (unsigned int keepalive, unsigned int update) |
One time WUT connection routine to start WUT system. | |
int | WUT_sys_reset (unsigned int keepalive, unsigned int update) |
Resets the keepalive and update times. | |
int | WUT_sys_shutdown () |
Shuts down the WUT routine. |
CVS $Id: WUT.c,v 1.14 2011/03/24 23:05:47 apw Exp $
#define MEMBER_OFFSET | ( | _structure, | |||
_member | ) | ((int) &(((_structure *) 0) -> _member)) |
Calculates the offset, in bytes, of the specified _member in _structure.
_structure | The name or typedef of the structure | |
_member | The member name |
Referenced by get_wut().
#define STATIC static |
Kludge for Doxygen,.
#define WUT_M_KEY 1 |
WUT key used to allow some normally prohibited actions.
Referenced by add_key(), has_key(), and remove_key().
Typedef for struct _WCB.
Typedef for struct _WCB.
Typedef for struct _WUT_keepalive.
Simple WUT timer callback routine used as a periodic keepalive.
period | Pointer to the period (in nanoseconds) | |
wut | The WUT timer entry |
WUT_K_STATE_CHANGE_YES | This is provided mainly for symmetry with the VxWorks implementation. In that implementation, this routine drives the system clock. In the POSIX implementation, it is just a periodic heartbeat. |
Typedef for WUT_keepalive_ctx.
Adds an special key to the timer entry handle. Operations which are normally prohibited are allowed in special circumstances.
wut | The WUT timer entry to modify. |
References WUT_M_KEY.
Referenced by WUT_sys_handler().
Adds the specified WUT timer entry into the active que.
wut | The WUT timer entry to add | |
tov | The timeout value. |
WUT_K_QUEUED |
References arm_handler(), cmp_lt_tov(), _WCB::com, find(), _Q_node::flnk, get_wut(), lock_que(), _WUT_tmr::node, _Q_head::node, Q__insert(), Q__jam(), _WCB_common::que, _WUT_tmr::state, _WUT_tmr::tov, unlock_que(), Wcb, WUT_K_ACTIVE, and WUT_K_QUEUED.
Referenced by WUT_restart(), and WUT_start().
Seeds the timer interrupt to handle expire a tov.
wcb | The WUT control block | |
tov | The expiration timeout value |
References BUG_check(), _WCB_qlt::cv, _WCB_specific::qlt, and _WCB::spc.
Referenced by add_wut().
Seeds the timer interrupt to handle expire at the timeout associated with the specified WUT timer entry.
wcb | The WUT control block | |
wut | The WUT timer entry. |
References BUG_check(), _WCB_qlt::cv, _WCB_specific::qlt, and _WCB::spc.
Referenced by WUT_cancel().
Platform implementation dependent routine to compare to timeout values.
tov_a | The first of the two timeout values to compare | |
tov_b | The second of the two timeout values to compare |
References _TOV_u::tov, and _TOV_u::ts.
Referenced by add_wut(), find(), and WUT_sys_handler().
Scans the que to find the last timer entry with a timeout value smaller than tov.
que | The active timer que to scan | |
tov | The target expiration time |
References cmp_lt_tov(), _Q_node::flnk, get_wut(), _Q_head::node, and _WUT_tmr::tov.
Referenced by add_wut().
Returns a pointer to top of the WUT timer structure.
node | The node (que links) of the WUT timer entry |
References MEMBER_OFFSET.
Referenced by add_wut(), find(), WUT_cancel(), WUT_sys_adjust(), WUT_sys_handler(), and wut_sys_kill().
STATIC int has_key | ( | const WUT_tmr * | wut | ) | [inline] |
Tests whether the WUT timer entry has the special key attached.
wut | The WUT timer entry to test. |
References WUT_M_KEY.
Referenced by WUT_cancel(), WUT_destroy(), WUT_expire(), WUT_restart(), and WUT_start().
STATIC void init_wut | ( | void * | unused, | |
WUT_tmr * | wut, | |||
int | pckt_size, | |||
int | pcb_offset | |||
) |
Initializes each timer entry as it is added to the Free Packet Pool.
unused | Unused parameter | |
wut | The WUT timer entry to initialize | |
pckt_size | The size of a packet | |
pcb_offset | The offset to the FPA control structure |
References _WUT_tmr::state, and WUT_K_FREE.
Referenced by WUT_sys_init().
int lock_que | ( | WCB * | wcb | ) | [inline] |
Platform implementation dependent routine to lock the WUT timer que.
wcb | Pointer to the WUT control block |
References BUG_check(), _WCB_qlt::mutex, _WCB_specific::qlt, and _WCB::spc.
Referenced by add_wut(), WUT_cancel(), and wut_sys_kill().
Removes the special key from a WUT timer entry.
wut | The WUT timer entry to remove the key from. |
References WUT_M_KEY.
Referenced by WUT_cancel(), WUT_destroy(), WUT_expire(), WUT_keepalive_rtn(), WUT_restart(), WUT_start(), WUT_state_get(), and WUT_tov_get().
void unlock_que | ( | WCB * | wcb, | |
int | key | |||
) | [inline] |
Platform implementation dependent routine to unlock the WUT timer que.
wcb | Pointer to the WUT control block | |
key | The key used to unlock the que (returned from lock_que() |
References BUG_check(), _WCB_qlt::mutex, _WCB_specific::qlt, and _WCB::spc.
Referenced by add_wut(), WUT_cancel(), and wut_sys_kill().
Cancels a WUT timer entry.
wut | The WUT timer entry to cancel |
References arm_handler_nxt_wut(), _WCB::com, _Q_node::flnk, get_wut(), has_key(), lock_que(), _WUT_tmr::node, _Q_head::node, Q__unlink(), _WCB_common::que, remove_key(), _WUT_tmr::state, unlock_que(), Wcb, WUT_K_CANCELLED, and WUT_K_QUEUED.
WUT_tmr* WUT_create | ( | void | ) |
Allocate a WUT timer entry.
References _WCB::com, _WCB_common::fcb, FPA_get(), _WUT_tmr::state, Wcb, and WUT_K_ALLOCATED.
Destroys, ie frees, an unused WUT timer entry.
wut | The WUT timer entry to destroy |
References _WCB::com, _WCB_common::fcb, FPA_free(), has_key(), remove_key(), _WUT_tmr::state, Wcb, WUT_K_ALLOCATED, and WUT_K_FREE.
Marks a wut timer as expire.
wut | The WUT timer entry to expire |
This call is necessary on platforms on POSIX platforms that do not support task priorities. On these platforms, the WUT timer cannot be protected by having the callback routine run in a higher priority thread. This means that WUT driver servicing the timer que cannot touch the WUT timer after the user's callback has been called. If this were allowed, there is a possibility that as soon as the user calls his synchronization routine, the thread waiting on that synchronization mechanism can begin execution. In that case, the user would make the reasonable assumption that the WUT timer handle is no longer property of the WUT facility. This call effectively declares to the WUT timer entry is no longer property of the WUT facility.
References has_key(), remove_key(), _WUT_tmr::state, and WUT_K_EXPIRED.
unsigned int WUT_frequency | ( | void | ) |
Gets frequency, in Hertz of the WUT clock.
References PTS_frequency().
WUT_cb_status WUT_keepalive_rtn | ( | WUT_keepalive_ctx * | keepalive, | |
WUT_tmr * | wut | |||
) |
Simple WUT timer callback routine used to drive the VxWorks system clock.
keepalive | The keepalive control structure. | |
wut | The WUT timer entry |
WUT_K_STATE_CHANGE_YES |
References _WUT_keepalive_ctx::period, remove_key(), _WUT_tmr::tov, TOV_add_nsecx(), WUT_K_STATE_CHANGE_YES, and WUT_restart().
Referenced by WUT_sys_connect(), and WUT_sys_reset().
WUT_cb_status WUT_keepalive_update | ( | WUT_keepalive_ctx * | keepalive, | |
WUT_tmr * | wut | |||
) |
Simple WUT timer callback routine used to update the WCT clock.
keepalive | The keepalive control structure. | |
wut | The WUT timer entry |
WUT_K_STATE_CHANGE_YES |
Referenced by WUT_sys_connect(), and WUT_sys_reset().
int WUT_overrun | ( | const WUT_tmr * | wut | ) |
Returns how 'on-time' the timer ISR was serviced.
Restarts a WUT timer entry.
wut | The WUT timer entry to restart. | |
tov | The timeout value. |
References add_wut(), has_key(), remove_key(), _WUT_tmr::state, and WUT_K_ALLOCATED.
Referenced by WUT_keepalive_rtn().
STATIC void wut_spc_init | ( | WCB * | wcb | ) |
Initializes the processor specific portion of the control block.
wcb | The WUT control block |
Referenced by WUT_sys_init().
WUT_state WUT_start | ( | WUT_tmr * | wut, | |
register TOV | tov, | |||
WUT_cb_routine | cb, | |||
void * | prm | |||
) |
Establishes and starts a WUT timer entry.
wut | The WUT timer entry to restart. | |
tov | The timeout value | |
cb | The address of the WUT timer entry's callback service routine. | |
prm | A user parameter passed transparently through to the timer entry's callback service routine |
References add_wut(), _WUT_tmr::cb, has_key(), _WUT_tmr::prm, remove_key(), _WUT_tmr::state, and WUT_K_ALLOCATED.
Referenced by wut_sys_shutdown().
Gets the current state of the WUT timer entry.
wut | The WUT timer entry to get the state for. |
References remove_key(), and _WUT_tmr::state.
int WUT_sys_adjust | ( | long long int | dnsecx | ) |
Adjusts all the current entries on the WUT timer que in response to a change in the base time.
dnsecx | The number of nanoseconds to shift the timer que entries by. |
It is assumed that interrupts are locked during the course of this execution.
References _WCB::com, _Q_node::flnk, get_wut(), _Q_head::node, _WCB_common::que, _WUT_tmr::tov, TOV_K_FOREVER, and Wcb.
int WUT_sys_connect | ( | unsigned int | keepalive, | |
unsigned int | update | |||
) |
One time WUT connection routine to start WUT system.
keepalive | The timeout period, in nsecs, to run the keepalive timer. | |
update | The update period. If non-zero, the WCT clock will be updated at this rate. If 0, then WCT clock will be update externally. |
References _WUT_tmr::cb, _WCB::com, _WUT_keepalive::ctx, _WUT_keepalive_ctx::elapsed, _WCB_common::keepalive, _WUT_tmr::node, _WUT_keepalive_ctx::period, _WUT_tmr::prm, Q_insert(), _WCB_common::que, _WUT_tmr::state, _WCB_common::terminator, _WUT_keepalive::tmr, _WUT_tmr::tov, TOV_from_nsecs(), TOV_K_FOREVER, _WUT_keepalive_ctx::update, Wcb, WUT_K_QUEUED, WUT_keepalive_rtn(), WUT_keepalive_update(), and wut_sys_connect().
Referenced by PBS_initialize2().
int wut_sys_connect | ( | WCB * | wcb | ) |
Platform dependent part of the WUT system connection process.
wcb | The WUT control block |
References _WCB_qlt::cv, _WCB_qlt::mutex, _WCB_specific::qlt, _WCB::spc, TASK_attr_init(), TASK_attr_priority_set(), TASK_spawn(), _WCB_specific::tcb, WUT_K_TASK_PRIORITY, and WUT_sys_handler().
Referenced by WUT_sys_connect().
int WUT_sys_init | ( | int | count | ) |
One time WUT services initialization routine.
count | The number of available timer entries |
References _WCB_common::cnt, _WCB::com, _WCB_common::fcb, FPA_fcb_sizeof(), FPA_init(), FPA_K_PCB_AT_EOP, FPA_K_TYPE_PENDING_FIFO, init_wut(), MBA_alloc(), Q_init(), _WCB_common::que, Wcb, and wut_spc_init().
Referenced by PBS_initialize2().
int WUT_sys_reset | ( | unsigned int | keepalive, | |
unsigned int | update | |||
) |
Resets the keepalive and update times.
keepalive | The timeout period, in nsecs, to run the keepalive timer. One values is recognized as special
| |
update | The new update period (in nanoseconds). Three values are recognized
|
References _WUT_tmr::cb, _WCB::com, _WUT_keepalive::ctx, _WCB_common::keepalive, _WUT_keepalive_ctx::period, _WUT_keepalive::tmr, _WUT_keepalive_ctx::update, Wcb, WUT_keepalive_rtn(), WUT_keepalive_update(), and wut_period_set().
int WUT_sys_shutdown | ( | void | ) |
Shuts down the WUT routine.
References _WCB::com, _WCB_common::fcb, MBA_free(), Wcb, and wut_sys_shutdown().
Referenced by PBS_shutdown().
int wut_sys_shutdown | ( | WCB * | wcb | ) |
Platform dependent shutdown of the WUT system.
wcb | The WUT control block |
References _WCB::spc, TASK_join(), _WCB_specific::tcb, TOV_from_nsecs(), WUT_INIT, WUT_start(), and wut_sys_kill().
Referenced by WUT_sys_shutdown().
Gets the current TOV of the WUT timer entry.
wut | The WUT timer entry to get the TOV for. |
References remove_key(), and _WUT_tmr::tov.