summaryrefslogtreecommitdiff
path: root/cesar/ce/src/tx.c
diff options
context:
space:
mode:
authorsave2008-04-07 14:17:42 +0000
committersave2008-04-07 14:17:42 +0000
commit3d58a62727346b7ac1a6cb36fed1a06ed72228dd (patch)
treed7788c3cf9f76426aef0286d0202e2097f0fa0eb /cesar/ce/src/tx.c
parent095dca4b0a8d4924093bab424f71f588fdd84613 (diff)
Moved the complete svn base into the cesar directory.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1769 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/ce/src/tx.c')
-rwxr-xr-xcesar/ce/src/tx.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/cesar/ce/src/tx.c b/cesar/ce/src/tx.c
new file mode 100755
index 0000000000..d6426fce6f
--- /dev/null
+++ b/cesar/ce/src/tx.c
@@ -0,0 +1,106 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file tx.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include <stdio.h>
+#include "ce/inc/tx.h"
+#define TXCE
+#include "ce/inc/cei.h"
+
+static txce_t txce_global;
+
+txce_t *
+txce_init (mac_store_t *mac_store_ctx, mac_config_t *mac_config_ctx, interf_t *interf_ctx)
+{
+ dbg_assert (mac_store_ctx);
+ dbg_assert (mac_config_ctx);
+#if defined (ECOS) && ECOS
+ dbg_assert (interf_ctx);
+#endif
+ txce_t *ctx = &txce_global;
+ ctx->mac_store_ctx = mac_store_ctx;
+ ctx->tonemask = mac_config_ctx->tonemask_info.tonemask;
+ ctx->interf_ctx = interf_ctx;
+ cyg_handle_t sys_clk = cyg_real_time_clock();
+ cyg_handle_t counter_hdl;
+ cyg_clock_to_counter (sys_clk, &counter_hdl);
+ cyg_alarm_create (counter_hdl, alarm_cb, (cyg_addrword_t) ctx, &ctx->alarm_hdl, &ctx->alarm_obj);
+ return (ctx);
+}
+
+cyg_tick_count_t
+txce_expiration_tonemaps_management (txce_t *ctx)
+{
+ dbg_assert (ctx);
+ uint tei;
+ cyg_tick_count_t lowest_expiration_date = 0xFFFFFFFFFFFFFFFFll;
+ for (tei=MAC_TEI_STA_MIN; tei<=MAC_TEI_STA_MAX; tei++)
+ {
+ cyg_tick_count_t current_rtc_date = cyg_current_time();
+ sta_t *lsta = mac_store_sta_get (ctx->mac_store_ctx, tei);
+ if (lsta)
+ {
+ tonemaps_t *tms = lsta->tx_tonemaps;
+ if (tms)
+ {
+ cyg_tick_count_t expiration_date = tms->expiration_rtc_date;
+ if (current_rtc_date >= expiration_date )
+ {
+ int tmi;
+ for (tmi = 0; tmi<TONEMAP_INDEX_NB; tmi++)
+ {
+ if (tms->tm[tmi]) tonemap_release (tms, tmi);
+ //tms->intervals = NULL;
+ tms->expiration_rtc_date = 0xFFFFFFFFFFFFFFFFll;
+ }
+ }
+ else
+ {
+ if (lowest_expiration_date > expiration_date)
+ {
+ lowest_expiration_date = expiration_date;
+ }
+ }
+ }
+ blk_release (lsta);
+ }
+ }
+ return lowest_expiration_date;
+}
+
+void
+txce (txce_t *ctx, uint stei, u32 mmtype, u8 *mm_entry)
+{
+ dbg_assert (ctx);
+ if (mm_entry)
+ {
+ dbg_assert (mmtype == CM_CHAN_EST_IND || mmtype == CM_TM_UPDATE_IND);
+ dbg_assert (stei>=MAC_TEI_STA_MIN && stei<=MAC_TEI_STA_MAX);
+ // Get concerned tonemaps from stei.
+ sta_t *source_sta = mac_store_sta_get (ctx->mac_store_ctx, stei);
+ tonemaps_t *source_tms = source_sta->tx_tonemaps;
+ cei_decode (source_tms, mmtype, mm_entry, ctx->tonemask);
+ blk_release (source_sta);
+ }
+ cyg_tick_count_t next_expiration = txce_expiration_tonemaps_management (ctx);
+ cyg_alarm_initialize (ctx->alarm_hdl, next_expiration, 0);
+}
+
+void
+alarm_cb (cyg_handle_t alarm_hdl, cyg_addrword_t data)
+{
+ dbg_assert (data);
+ txce_t *ctx = (txce_t *) data;
+ interf_event_add (ctx->interf_ctx, TXCE_EVENT);
+}