summaryrefslogtreecommitdiff
path: root/cesar/cp2
diff options
context:
space:
mode:
authorchertier2008-05-16 16:23:39 +0000
committerchertier2008-05-16 16:23:39 +0000
commit3c0082f128c3097068ac27a8e0d5b745fc7b5a84 (patch)
tree5c139cc216201f35f49bef9bdf346ac3a112b97a /cesar/cp2
parent87b97e2f50e0e3d8b87e9d0f0add0bcf51fedab2 (diff)
update
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@2014 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/cp2')
-rw-r--r--cesar/cp2/sta/core/core.h24
-rw-r--r--cesar/cp2/sta/core/doc/sta_core.odtbin109818 -> 110060 bytes
-rw-r--r--cesar/cp2/sta/core/inc/core.h29
-rw-r--r--cesar/cp2/sta/core/src/core.c163
4 files changed, 191 insertions, 25 deletions
diff --git a/cesar/cp2/sta/core/core.h b/cesar/cp2/sta/core/core.h
index 3d7c15cab8..ffaf77d9a4 100644
--- a/cesar/cp2/sta/core/core.h
+++ b/cesar/cp2/sta/core/core.h
@@ -78,6 +78,7 @@ struct cp_sta_core_alarm_def_t
cyg_handle_t alarm_handle; // eCos alarm handle
cp_sta_core_event_flag_t event_flag; // the sta core event flag to set (auto or user-specified when creating/launching timer alarm)
SEM_EVENT_TYPE fsm_event; // FSM event specified when creating/launching timer alarm (set if the previous flag is CP_STA_CORE_EVENT_FLAG_FSM)
+ bool cyclic_alarm; // flag indicating a periodic alarm (if set to true) or one-shot alarm (if set to false)
};
typedef struct cp_sta_core_alarm_def_t cp_sta_core_alarm_def_t;
@@ -123,6 +124,24 @@ void
cp_sta_core_signal_recv_mme_event(cp_t *cp_ctx);
/**
+ * create a core alarm that will generate a core event (with FSM event eventually
+ * associated to it and added to the FSM event fifo) after the specified delay.
+ *
+ * \param cp_ctx pointer to control plane context
+ * \param sta_core_alarm pointer to alarm structure where alarm info will be stored
+ * \param event_flag the sta core event flag (CP_STA_CORE_EVENT_FLAG_xxx) when timer elapsed
+ * \param fsm_event the FSM event to set (when core_event_flag == CP_STA_CORE_EVENT_FLAG_FSM)
+ * \param event_period_ms the period of event re-occurrence in millisecond
+ *
+ * each time the alarm occurs, the specified CP_STA_CORE_EVENT_FLAG_xxx
+ * core event flag is set to be taken into account by the wait-event loop
+ * of the cp sta core thread and, if the core event flag was a CP_STA_CORE_EVENT_FLAG_FSM,
+ * the specified FSM event is added to the FSM event fifo
+ */
+void
+cp_sta_core_gen_core_cyclic_event(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm, cp_sta_core_event_flag_t event_flag, SEM_EVENT_TYPE fsm_event, uint event_period_ms);
+
+/**
* create a user alarm that will generate a cp sta core event
* and associated (specified) FSM event after the specified delay.
*
@@ -139,13 +158,14 @@ void
cp_sta_core_gen_user_timed_event(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm, SEM_EVENT_TYPE fsm_event, uint event_delay_ms);
/**
- * will stop an alarm previously created with cp_sta_core_gen_user_timed_event() or cp_sta_core_gen_core_timed_event().
+ * will stop (disable and delete) an alarm previously created with cp_sta_core_gen_user_timed_event(),
+ * cp_sta_core_gen_user_cyclic_event(), cp_sta_core_gen_core_timed_event() or cp_sta_core_gen_core_cyclic_event().
*
* \param cp_ctx pointer to control plane context
* \param sta_core_alarm pointer to alarm info structure
*/
void
-cp_sta_core_stop_timed_event(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm)
+cp_sta_core_stop_timed_or_cyclic_event(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm)
END_DECLS
diff --git a/cesar/cp2/sta/core/doc/sta_core.odt b/cesar/cp2/sta/core/doc/sta_core.odt
index 6458d2bd4e..df40556ab8 100644
--- a/cesar/cp2/sta/core/doc/sta_core.odt
+++ b/cesar/cp2/sta/core/doc/sta_core.odt
Binary files differ
diff --git a/cesar/cp2/sta/core/inc/core.h b/cesar/cp2/sta/core/inc/core.h
index 6f60dc7f13..7c6e0002cf 100644
--- a/cesar/cp2/sta/core/inc/core.h
+++ b/cesar/cp2/sta/core/inc/core.h
@@ -112,6 +112,26 @@ cyg_tick_count_t
cp_sta_core_ms_to_cyg_tick (const uint ms);
/**
+ * create a core alarm that will generate a one-shot or periodic core event
+ * (with FSM event eventually associated to it and added to the FSM event fifo)
+ * after the specified delay or period.
+ *
+ * \param cp_ctx pointer to control plane context
+ * \param sta_core_alarm pointer to alarm structure where alarm info will be stored
+ * \param event_flag the sta core event flag (CP_STA_CORE_EVENT_FLAG_xxx) when timer elapsed
+ * \param fsm_event the FSM event to set (when core_event_flag == CP_STA_CORE_EVENT_FLAG_FSM)
+ * \param period_or_delay_ms the period or delay of event occurrence in millisecond
+ * \param cyclic_alarm flag indicating a periodic alarm (if set to true) or one-shot alarm (if set to false)
+ *
+ * each time the alarm occurs, the specified CP_STA_CORE_EVENT_FLAG_xxx
+ * core event flag is set to be taken into account by the wait-event loop
+ * of the cp sta core thread and, if the core event flag was a CP_STA_CORE_EVENT_FLAG_FSM,
+ * the specified FSM event is added to the FSM event fifo
+ */
+void
+cp_sta_core_gen_core_alarm(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm, cp_sta_core_event_flag_t event_flag, SEM_EVENT_TYPE fsm_event, uint period_or_delay_ms, bool cyclic_alarm);
+
+/**
* create a core alarm that will generate a core event (with FSM event eventually
* associated to it and added to the FSM event fifo) after the specified delay.
*
@@ -131,13 +151,14 @@ void
cp_sta_core_gen_core_timed_event(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm, cp_sta_core_event_flag_t event_flag, SEM_EVENT_TYPE fsm_event, uint event_delay_ms);
/**
- * this function is called when the amount of time specified
- * with cp_sta_core_gen_core_timed_event() or cp_sta_core_gen_user_timed_event()
- * has elapsed.
+ * this function is called when a one-shot alarm created with
+ * cp_sta_core_gen_core_timed_event() or cp_sta_core_gen_user_timed_event(),
+ * has elapsed or when a cyclic alarm created with cp_sta_core_gen_core_cyclic_event()
+ * or cp_sta_core_gen_user_cyclic_event() occurs.
*
* \param cp_ctx pointer to control plane context
* \param alarm handle to the alarm
- * \param data alarm array index
+ * \param data pointer to alarm info structure relating to occurring alarm
*
* see eCos manual about alarm
* warning : this function is called in DSR context
diff --git a/cesar/cp2/sta/core/src/core.c b/cesar/cp2/sta/core/src/core.c
index 6b9ea350b6..37a6af0afe 100644
--- a/cesar/cp2/sta/core/src/core.c
+++ b/cesar/cp2/sta/core/src/core.c
@@ -189,23 +189,24 @@ cp_sta_core_ms_to_cyg_tick (const uint ms)
}
/**
- * create a core alarm that will generate a core event (with FSM event eventually
- * associated to it and added to the FSM event fifo) after the specified delay.
+ * create a core alarm that will generate a one-shot or periodic core event
+ * (with FSM event eventually associated to it and added to the FSM event fifo)
+ * after the specified delay or period.
*
* \param cp_ctx pointer to control plane context
* \param sta_core_alarm pointer to alarm structure where alarm info will be stored
* \param event_flag the sta core event flag (CP_STA_CORE_EVENT_FLAG_xxx) when timer elapsed
* \param fsm_event the FSM event to set (when core_event_flag == CP_STA_CORE_EVENT_FLAG_FSM)
- * \param event_delay_ms the amount of time to wait in millisecond
+ * \param period_or_delay_ms the period or delay of event occurrence in millisecond
+ * \param cyclic_alarm flag indicating a periodic alarm (if set to true) or one-shot alarm (if set to false)
*
- * when timer elapsed, the specified CP_STA_CORE_EVENT_FLAG_xxx
- * core event flag will be set to be taken into account by the
- * wait-event loop of the cp sta core thread and, if the core
- * event flag was a CP_STA_CORE_EVENT_FLAG_FSM, the specified
- * FSM event is added to the FSM event fifo
+ * each time the alarm occurs, the specified CP_STA_CORE_EVENT_FLAG_xxx
+ * core event flag is set to be taken into account by the wait-event loop
+ * of the cp sta core thread and, if the core event flag was a CP_STA_CORE_EVENT_FLAG_FSM,
+ * the specified FSM event is added to the FSM event fifo
*/
void
-cp_sta_core_gen_core_timed_event(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm, cp_sta_core_event_flag_t event_flag, SEM_EVENT_TYPE fsm_event, uint event_delay_ms)
+cp_sta_core_gen_core_alarm(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm, cp_sta_core_event_flag_t event_flag, SEM_EVENT_TYPE fsm_event, uint period_or_delay_ms, bool cyclic_alarm)
{
cyg_tick_count_t trigger_time;
@@ -222,13 +223,109 @@ cp_sta_core_gen_core_timed_event(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core
);
sta_core_alarm->event_flag = event_flag;
sta_core_alarm->fsm_event = fsm_event;
+ sta_core_alarm->cyclic_alarm = cyclic_alarm;
// initialize the alarm
trigger_time = cp_sta_core_ms_to_cyg_tick(event_delay_ms) + cyg_current_time();
- cyg_alarm_initialize(sta_core_alarm->alarm_handle, trigger_time, 0);
+ if (cyclic_alarm)
+ {
+ cyg_alarm_initialize(sta_core_alarm->alarm_handle, trigger_time, cp_sta_core_ms_to_cyg_tick(event_delay_ms));
#ifdef DEBUG
- diag_printf("%u %s() : create %u ms alarm at %i eCos time (end of alarm at %i eCos time)\n",cyg_hal_sys_getpid(),__FUNCTION__, (int) cyg_current_time(), trigger_time);
+ diag_printf("%u %s() : create a %u ms cyclic alarm at %i eCos time\n",cyg_hal_sys_getpid(),__FUNCTION__, (int) cyg_current_time());
#endif
+ }
+ else
+ {
+ cyg_alarm_initialize(sta_core_alarm->alarm_handle, trigger_time, 0);
+#ifdef DEBUG
+ diag_printf("%u %s() : create a %u ms one-shot alarm at %i eCos time (end of alarm at %i eCos time)\n",cyg_hal_sys_getpid(),__FUNCTION__, (int) cyg_current_time(), trigger_time);
+#endif
+ }
+}
+
+/**
+ * create a core alarm that will periodically generate a core event (with FSM event eventually
+ * associated to it and added to the FSM event fifo).
+ *
+ * \param cp_ctx pointer to control plane context
+ * \param sta_core_alarm pointer to alarm structure where alarm info will be stored
+ * \param event_flag the sta core event flag (CP_STA_CORE_EVENT_FLAG_xxx) when timer elapsed
+ * \param fsm_event the FSM event to set (when core_event_flag == CP_STA_CORE_EVENT_FLAG_FSM)
+ * \param event_period_ms the period of event re-occurrence in millisecond
+ *
+ * each time the alarm occurs, the specified CP_STA_CORE_EVENT_FLAG_xxx
+ * core event flag is set to be taken into account by the wait-event loop
+ * of the cp sta core thread and, if the core event flag was a CP_STA_CORE_EVENT_FLAG_FSM,
+ * the specified FSM event is added to the FSM event fifo
+ */
+void
+cp_sta_core_gen_core_cyclic_event(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm, cp_sta_core_event_flag_t event_flag, SEM_EVENT_TYPE fsm_event, uint event_period_ms)
+{
+#ifdef DEBUG
+ diag_printf("%u %s() : create a %u ms cyclic alarm at %i eCos time...\n",cyg_hal_sys_getpid(),__FUNCTION__, (int) cyg_current_time());
+#endif
+ cp_sta_core_gen_core_alarm( cp_ctx,
+ sta_core_alarm,
+ event_flag,
+ fsm_event,
+ period_or_delay_ms,
+ true
+ );
+}
+
+/**
+ * create a core alarm that will generate a core event (with FSM event eventually
+ * associated to it and added to the FSM event fifo) after the specified delay.
+ *
+ * \param cp_ctx pointer to control plane context
+ * \param sta_core_alarm pointer to alarm structure where alarm info will be stored
+ * \param event_flag the sta core event flag (CP_STA_CORE_EVENT_FLAG_xxx) when timer elapsed
+ * \param fsm_event the FSM event to set (when core_event_flag == CP_STA_CORE_EVENT_FLAG_FSM)
+ * \param event_delay_ms the amount of time to wait in millisecond
+ *
+ * when timer elapsed, the specified CP_STA_CORE_EVENT_FLAG_xxx
+ * core event flag will be set to be taken into account by the
+ * wait-event loop of the cp sta core thread and, if the core
+ * event flag was a CP_STA_CORE_EVENT_FLAG_FSM, the specified
+ * FSM event is added to the FSM event fifo
+ */
+void
+cp_sta_core_gen_core_timed_event(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm, cp_sta_core_event_flag_t event_flag, SEM_EVENT_TYPE fsm_event, uint event_delay_ms)
+{
+#ifdef DEBUG
+ diag_printf("%u %s() : create a %u ms one-shot alarm at %i eCos time...\n",cyg_hal_sys_getpid(),__FUNCTION__, (int) cyg_current_time());
+#endif
+ cp_sta_core_gen_core_alarm( cp_ctx,
+ sta_core_alarm,
+ event_flag,
+ fsm_event,
+ period_or_delay_ms,
+ false
+ );
+}
+
+/**
+ * create a user cyclic alarm that will generate a cp sta core event
+ * and associated (specified) FSM event at the given period of occurence.
+ *
+ * \param cp_ctx pointer to control plane context
+ * \param sta_core_alarm pointer to alarm structure where alarm info will be stored
+ * \param fsm_event the FSM event to set (when core_event_flag == CP_STA_CORE_EVENT_FLAG_FSM)
+ * \param event_period_ms the period of event re-occurrence in millisecond
+ *
+ * when timer elapsed the specified FSM event will be added to the FSM fifo
+ * and a CP_STA_CORE_EVENT_FLAG_FSM core event will be set to be taken into account
+ * by the wait-event loop of the cp sta core thread
+ */
+void
+cp_sta_core_gen_user_cyclic_event(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm, SEM_EVENT_TYPE fsm_event, uint event_period_ms)
+{
+ dbg_assert(cp_ctx);
+ dbg_assert(sta_core_alarm);
+#ifdef DEBUG
+ diag_printf("%u %s() : request a %u ms user alarm at %i eCos time (end of alarm at %i eCos time)\n",cyg_hal_sys_getpid(),__FUNCTION__, (int) cyg_current_time(), trigger_time);
+#endif
+ cp_sta_core_gen_core_cyclic_event(cp_ctx, sta_core_alarm, CP_STA_CORE_EVENT_FLAG_FSM, fsm_event, event_period_ms);
}
/**
@@ -249,7 +346,6 @@ cp_sta_core_gen_user_timed_event(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core
{
dbg_assert(cp_ctx);
dbg_assert(sta_core_alarm);
- dbg_assert(cyg_flag);
#ifdef DEBUG
diag_printf("%u %s() : request a %u ms user alarm at %i eCos time (end of alarm at %i eCos time)\n",cyg_hal_sys_getpid(),__FUNCTION__, (int) cyg_current_time(), trigger_time);
#endif
@@ -257,27 +353,36 @@ cp_sta_core_gen_user_timed_event(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core
}
/**
- * will stop an alarm previously created with cp_sta_core_gen_user_timed_event() or cp_sta_core_gen_core_timed_event().
+ * will stop (disable and delete) an alarm previously created with cp_sta_core_gen_user_timed_event(),
+ * cp_sta_core_gen_user_cyclic_event(), cp_sta_core_gen_core_timed_event() or cp_sta_core_gen_core_cyclic_event().
*
* \param cp_ctx pointer to control plane context
* \param sta_core_alarm pointer to alarm info structure
*/
void
-cp_sta_core_stop_timed_event(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm)
+cp_sta_core_stop_timed_or_cyclic_event(cp_t *cp_ctx, cp_sta_core_alarm_def_t *sta_core_alarm)
{
dbg_assert(cp_ctx);
dbg_assert(sta_core_alarm);
+
+ // disable and delete alarm
cyg_alarm_disable(sta_core_alarm->alarm_handle);
+ cyg_alarm_delete(sta_core_alarm->alarm_handle);
+
+ // resetting alarm handle (useful for detection by external garbage collector)
+ sta_core_alarm->alarm_handle = (cyg_handle_t)0;
+
}
/**
- * this function is called when the amount of time specified
- * with cp_sta_core_gen_core_timed_event() or cp_sta_core_gen_user_timed_event()
- * has elapsed.
+ * this function is called when a one-shot alarm created with
+ * cp_sta_core_gen_core_timed_event() or cp_sta_core_gen_user_timed_event(),
+ * has elapsed or when a cyclic alarm created with cp_sta_core_gen_core_cyclic_event()
+ * or cp_sta_core_gen_user_cyclic_event() occurs.
*
* \param cp_ctx pointer to control plane context
* \param alarm handle to the alarm
- * \param data alarm array index
+ * \param data pointer to alarm info structure relating to occurring alarm
*
* see eCos manual about alarm
* warning : this function is called in DSR context
@@ -305,7 +410,7 @@ cp_sta_core_alarm_handler(cp_t *cp_ctx, cyg_handle_t alarm, cyg_addrword_t data)
cp_sta_core_signal_fsm_event(cp_ctx);
break;
- case CP_STA_CORE_EVENT_FLAG_GARBAGE: // garbage collector timer
+ case CP_STA_CORE_EVENT_FLAG_GARBAGE: // sta core garbage collector timer
#if DEBUG
diag_printf("%u %s() : CP_STA_CORE_EVENT_FLAG_GARBAGE\n",cyg_hal_sys_getpid(),__FUNCTION__);
#endif
@@ -319,6 +424,26 @@ cp_sta_core_alarm_handler(cp_t *cp_ctx, cyg_handle_t alarm, cyg_addrword_t data)
#endif
break;
}
+
+ switch (sta_core_alarm->event_flag)
+ {
+ case CP_STA_CORE_EVENT_FLAG_FSM: // user timer
+ case CP_STA_CORE_EVENT_FLAG_GARBAGE: // sta core garbage collector timer
+ // if one-shot alarm, delete it
+ if (!sta_core_alarm->cyclic_alarm)
+ {
+#if DEBUG
+ diag_printf("%u %s() : deleting one-shot alarm\n",cyg_hal_sys_getpid(),__FUNCTION__);
+#endif
+ cyg_alarm_delete(sta_core_alarm->alarm_handle);
+ // resetting alarm handle (useful for detection by external garbage collector)
+ sta_core_alarm->alarm_handle = (cyg_handle_t)0;
+
+ }
+ break;
+ default: // (should never happen !)
+ break;
+ }
}
/**