summaryrefslogtreecommitdiff
path: root/cesar/mac/sar/src/sar.c
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/mac/sar/src/sar.c')
-rw-r--r--cesar/mac/sar/src/sar.c45
1 files changed, 3 insertions, 42 deletions
diff --git a/cesar/mac/sar/src/sar.c b/cesar/mac/sar/src/sar.c
index 6a9462add1..735c56fe79 100644
--- a/cesar/mac/sar/src/sar.c
+++ b/cesar/mac/sar/src/sar.c
@@ -27,15 +27,12 @@
#include "mac/sar/inc/sar_expiration.h"
#include "lib/seq_check.h"
#include "mac/sar/inc/sar_pb_stats.h"
+#include "mac/sar/inc/thread.h"
#include "hal/arch/arch.h"
-#include "common/defs/priority.h"
#include "lib/stats.h"
#include <string.h>
-/** Time SAR thread sleeps. */
-#define SAR_THREAD_DELAY_RTC 10
-
/** Define the JOB length for the second job to avoid bridgedma bug see
* maria:#905. */
#define SAR_BRGBUG_SECOND_JOB_LENGTH 16
@@ -530,18 +527,7 @@ sar_init (mac_store_t *mac_store, pbproc_t *pbproc, ca_t *ca, u32 seed)
#endif
lib_rnd_init (&ctx->rnd_gen, seed ^ 0x19257164);
- /* Resume the thread only if the SAR is not in unit test. */
-#ifndef SAR_UNIT_TEST
- /* Create the Thread for the SAR. */
- cyg_thread_create (MAC_SAR_THREAD_PRIORITY,
- &sar_process,
- (cyg_addrword_t) ctx,
- "MAC_SAR",
- ctx->thread_stack,
- MAC_SAR_THREAD_STACK_SIZE,
- &ctx->thread_handle, &ctx->thread);
- cyg_thread_resume (ctx->thread_handle);
-#endif
+ sar_thread_init (ctx);
/* Initialise the TX static job. */
static sar_job_mfs_t job_tx;
sar_global.job_tx = ARCH_CPU_TO_DMA (&job_tx);
@@ -656,10 +642,7 @@ sar_uninit (sar_t *ctx)
#if CONFIG_SAR_PB_STATS
sar_pb_stats_uninit (&ctx->pb_stats);
#endif
-#ifndef SAR_UNIT_TEST
- cyg_thread_suspend (ctx->thread_handle);
- cyg_thread_delete (ctx->thread_handle);
-#endif
+ sar_thread_uninit ();
phy_bridgedma_uninit(ctx->bridgedma_ctx);
sar_trace_uninit (ctx);
}
@@ -1990,28 +1973,6 @@ sar_mfs_cmd_process (sar_t *ctx, mfs_tx_t *mfs)
}
void
-sar_launch (sar_t *ctx)
-{
- dbg_assert (ctx);
- cyg_thread_delay (SAR_THREAD_DELAY_RTC);
- sar_expiration_mfs (ctx);
- if (ctx->pbs_missing_for_pbproc)
- {
- /* Refill the PB pool if missing block were registered. */
- arch_dsr_lock ();
- sar_pb_pool_refill (ctx, 0);
- arch_dsr_unlock ();
- }
-}
-
-void
-sar_process (cyg_addrword_t data)
-{
- while (true)
- sar_launch ((sar_t *) data);
-}
-
-void
sar_init_beacon_cb (sar_t *sar, void *user_data, sar_beacon_cb_t uf)
{
dbg_assert (sar);