summaryrefslogtreecommitdiff
path: root/cesar/ce/test
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/ce/test')
-rwxr-xr-xcesar/ce/test/common/Module1
-rw-r--r--cesar/ce/test/common/ecos_overide/cyg/kernel/Module1
-rw-r--r--cesar/ce/test/common/ecos_overide/cyg/kernel/kapi.h45
-rw-r--r--cesar/ce/test/common/ecos_overide/cyg/kernel/src/kapi.c62
-rw-r--r--cesar/ce/test/common/gaussian.h23
-rwxr-xr-xcesar/ce/test/common/print_utils.h60
-rw-r--r--cesar/ce/test/common/src/gaussian.c29
-rwxr-xr-xcesar/ce/test/common/src/print_utils.c145
-rw-r--r--cesar/ce/test/common/tonemap_utils.h135
-rwxr-xr-xcesar/ce/test/cov/cov_all_run.sh42
-rwxr-xr-xcesar/ce/test/cov/cov_one_run.sh63
-rwxr-xr-xcesar/ce/test/rx/Config5
-rw-r--r--cesar/ce/test/rx/general/Makefile8
-rwxr-xr-xcesar/ce/test/rx/general/host-Makefile33
-rw-r--r--cesar/ce/test/rx/general/overide/cp/Module1
-rw-r--r--cesar/ce/test/rx/general/overide/cp/cp.h50
-rw-r--r--cesar/ce/test/rx/general/overide/cp/interf/Module1
-rwxr-xr-xcesar/ce/test/rx/general/overide/cp/interf/interf.h65
-rwxr-xr-xcesar/ce/test/rx/general/overide/cp/interf/src/interf.c52
-rw-r--r--cesar/ce/test/rx/general/overide/cp/src/cp.c92
-rwxr-xr-xcesar/ce/test/rx/general/src/test_bitloading.c235
-rwxr-xr-xcesar/ce/test/rx/general/src/test_cei.c80
-rwxr-xr-xcesar/ce/test/rx/general/src/test_cei_param.c86
-rwxr-xr-xcesar/ce/test/rx/general/src/test_mpdu_measure_store.c294
-rwxr-xr-xcesar/ce/test/rx/general/src/test_rx.c281
-rwxr-xr-xcesar/ce/test/rx/general/src/test_sar_integration.c303
-rw-r--r--cesar/ce/test/rx/general/target-Makefile26
-rwxr-xr-xcesar/ce/test/rx/general/target-ecos.ecc.sh5
-rwxr-xr-xcesar/ce/test/rx/host_linux_sparc/Makefile17
-rw-r--r--cesar/ce/test/rx/host_linux_sparc/src/test_speed.c152
-rwxr-xr-xcesar/ce/test/rx/inc/test_rx.h37
-rw-r--r--cesar/ce/test/rx/maximus/Makefile21
-rw-r--r--cesar/ce/test/rx/maximus/ecos.ecc.sh104
-rw-r--r--cesar/ce/test/rx/maximus/overide/mac/pbproc/Module1
-rw-r--r--cesar/ce/test/rx/maximus/overide/mac/pbproc/pbproc.h145
-rw-r--r--cesar/ce/test/rx/maximus/overide/mac/pbproc/src/pbproc.c261
-rw-r--r--cesar/ce/test/rx/maximus/send_noise.py102
-rw-r--r--cesar/ce/test/rx/maximus/src/test_rx.c187
-rw-r--r--cesar/ce/test/rx/tonemap_refresh/Makefile18
-rwxr-xr-xcesar/ce/test/rx/tonemap_refresh/ecos.ecc.sh5
-rw-r--r--cesar/ce/test/rx/tonemap_refresh/src/test_tonemaps_refresh.c117
-rw-r--r--cesar/ce/test/tx/Makefile8
-rwxr-xr-xcesar/ce/test/tx/host-Makefile17
-rw-r--r--cesar/ce/test/tx/src/test_expiration.c121
-rwxr-xr-xcesar/ce/test/tx/src/test_tx.c150
-rw-r--r--cesar/ce/test/tx/target-Makefile22
-rwxr-xr-xcesar/ce/test/tx/target-ecos.ecc.sh5
-rw-r--r--cesar/ce/test/tx/test.h18
48 files changed, 3731 insertions, 0 deletions
diff --git a/cesar/ce/test/common/Module b/cesar/ce/test/common/Module
new file mode 100755
index 0000000000..ad8c4aa85e
--- /dev/null
+++ b/cesar/ce/test/common/Module
@@ -0,0 +1 @@
+SOURCES := print_utils.c gaussian.c
diff --git a/cesar/ce/test/common/ecos_overide/cyg/kernel/Module b/cesar/ce/test/common/ecos_overide/cyg/kernel/Module
new file mode 100644
index 0000000000..86ae567be7
--- /dev/null
+++ b/cesar/ce/test/common/ecos_overide/cyg/kernel/Module
@@ -0,0 +1 @@
+SOURCES := kapi.c
diff --git a/cesar/ce/test/common/ecos_overide/cyg/kernel/kapi.h b/cesar/ce/test/common/ecos_overide/cyg/kernel/kapi.h
new file mode 100644
index 0000000000..07bfa4e3ec
--- /dev/null
+++ b/cesar/ce/test/common/ecos_overide/cyg/kernel/kapi.h
@@ -0,0 +1,45 @@
+#ifndef kapi_h
+#define kapi_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file kapi.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+#define CYGNUM_HAL_RTC_DENOMINATOR 100
+
+typedef u64 cyg_tick_count_t;
+typedef u64 cyg_handle_t;
+typedef u64 cyg_alarm;
+typedef void* cyg_addrword_t;
+typedef void (cyg_alarm_t) (cyg_handle_t hdl, cyg_addrword_t data);
+
+cyg_tick_count_t
+cyg_current_time (void);
+
+cyg_handle_t
+cyg_real_time_clock (void);
+
+void
+cyg_clock_to_counter (cyg_handle_t clock_hdl, cyg_handle_t *counter_hdl);
+
+void
+cyg_alarm_create (cyg_handle_t counter_hld, cyg_alarm_t alarm_cb, cyg_addrword_t data, cyg_handle_t *alarm_hdl, cyg_alarm *alarm);
+
+void
+cyg_thread_delay (uint p);
+
+void
+cyg_alarm_initialize (cyg_handle_t alarm, cyg_tick_count_t trigger, cyg_tick_count_t interval);
+
+
+#endif /* kapi_h */
diff --git a/cesar/ce/test/common/ecos_overide/cyg/kernel/src/kapi.c b/cesar/ce/test/common/ecos_overide/cyg/kernel/src/kapi.c
new file mode 100644
index 0000000000..1f9a9d71ec
--- /dev/null
+++ b/cesar/ce/test/common/ecos_overide/cyg/kernel/src/kapi.c
@@ -0,0 +1,62 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/kapi.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include "sys/time.h"
+#include "stdio.h"
+#include "string.h"
+#include "cyg/kernel/kapi.h"
+
+#define PERIOD_RTC_US (1000000/CYGNUM_HAL_RTC_DENOMINATOR)
+
+cyg_tick_count_t
+cyg_current_time (void)
+{
+ u64 ret;
+ struct timeval tv0;
+ gettimeofday (&tv0, NULL);
+ u64 date_us = (tv0.tv_sec*1000000 + tv0.tv_usec);
+ ret = date_us / PERIOD_RTC_US;
+ return ( ret);
+}
+
+cyg_handle_t
+cyg_real_time_clock (void)
+{
+ return (cyg_handle_t )NULL;
+}
+
+void
+cyg_clock_to_counter (cyg_handle_t clock_hdl, cyg_handle_t *counter_hdl)
+{
+ return;
+}
+
+void
+cyg_alarm_create (cyg_handle_t counter_hld, cyg_alarm_t alarm_cb, cyg_addrword_t data, cyg_handle_t *alarm_hdl, cyg_alarm *alarm)
+{
+ return;
+}
+
+void
+cyg_thread_delay (uint p)
+{
+ return;
+}
+
+void
+cyg_alarm_initialize (cyg_handle_t alarm, cyg_tick_count_t trigger, cyg_tick_count_t interval)
+{
+ return;
+}
diff --git a/cesar/ce/test/common/gaussian.h b/cesar/ce/test/common/gaussian.h
new file mode 100644
index 0000000000..454c5417d5
--- /dev/null
+++ b/cesar/ce/test/common/gaussian.h
@@ -0,0 +1,23 @@
+#ifndef ce_test_common_gaussian_h
+#define ce_test_common_gaussian_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/test/common/gaussian.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+#include "lib/rnd.h"
+
+double
+lib_rnd_gaussian (lib_rnd_t *ctx, double lambda, double sigma);
+
+#endif /* ce_test_common_gaussian_h */
diff --git a/cesar/ce/test/common/print_utils.h b/cesar/ce/test/common/print_utils.h
new file mode 100755
index 0000000000..1f0fe63bb0
--- /dev/null
+++ b/cesar/ce/test/common/print_utils.h
@@ -0,0 +1,60 @@
+#ifndef ce_test_common_print_utils_h
+#define ce_test_common_print_utils_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/test/common/print_utils.h
+ * \brief print function header for test
+ * \ingroup ce_test
+ */
+#include "mac/common/tonemap.h"
+#include "hal/phy/pbdma.h"
+#include "ce/inc/mpdu_measure_store.h"
+
+#ifdef CE_DBG
+BEGIN_DECLS
+
+void
+ce_print (const char *msg, ...);
+
+void
+ce_print_byte (u8 c);
+
+void
+ce_print_nibble (u32 c);
+
+void
+ce_print_buffer (u8 *buf, int length);
+
+void
+ce_print_tonemap (tonemap_t *tm);
+
+void
+ce_print_tonemaps (tonemaps_t *tms);
+
+void
+ce_print_chandata (phy_chandata_t *chandata);
+
+void
+ce_print_frame_measurement (frame_measurement_t *fm);
+
+END_DECLS
+
+
+#else
+#define ce_print(expr,r...) ((void) 0)
+#define ce_print_byte(expr) ((void)0)
+#define ce_print_nibble(expr) ((void)0)
+#define ce_print_buffer(expr,r) ((void)0)
+#define ce_print_tonemap(expr) ((void)0)
+#define ce_print_tonemaps(expr) ((void)0)
+#define ce_print_chandata(expr) ((void)0)
+#define ce_print_frame_measurement(expr) ((void)0)
+#endif
+
+#endif /* ce_test_common_print_utils_h */
diff --git a/cesar/ce/test/common/src/gaussian.c b/cesar/ce/test/common/src/gaussian.c
new file mode 100644
index 0000000000..4d2ca63e93
--- /dev/null
+++ b/cesar/ce/test/common/src/gaussian.c
@@ -0,0 +1,29 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/test/common/src/gaussian.c
+ * \brief generate double float number with a normal repartition (gaussian).
+ * \ingroup ce/test/common
+ *
+ */
+#include "common/std.h"
+#include <math.h>
+#include "ce/test/common/gaussian.h"
+
+double
+lib_rnd_gaussian (lib_rnd_t *ctx, double lambda, double sigma)
+{
+ double a_rnd = 0;
+ while (a_rnd == 0) a_rnd=lib_rnd_uniform (ctx,100000);
+ a_rnd = a_rnd / 100000.0;
+ double b_rnd = lib_rnd_uniform (ctx,100000)/100000.0;
+ double lna = log (a_rnd);
+ double gauss_rnd = sqrt (-2*lna)* cos (2*3.14*b_rnd);
+ return (lambda + sigma *gauss_rnd);
+}
+
diff --git a/cesar/ce/test/common/src/print_utils.c b/cesar/ce/test/common/src/print_utils.c
new file mode 100755
index 0000000000..8fdba1ecb6
--- /dev/null
+++ b/cesar/ce/test/common/src/print_utils.c
@@ -0,0 +1,145 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/test/common/src/print_utils.c
+ * \brief provides print function for test
+ * \ingroup ce_test
+ */
+
+#include "common/std.h"
+#include "ce/test/common/print_utils.h"
+#include <stdio.h>
+
+#ifdef CE_DBG
+void
+ce_print (const char *msg, ...)
+{
+ va_list ap;
+ va_start (ap, msg);
+ vfprintf (stderr, msg, ap);
+ va_end (ap);
+}
+
+void
+ce_print_byte (u8 c)
+{
+ ce_print("%1x%1x",(c>>4),(c&0xF));
+}
+
+void
+ce_print_nibble (u32 w)
+{
+ int i;
+ for (i=0; i<8; i++)
+ {
+ ce_print("%1x", w&0xF);
+ w = w>>4;
+ }
+}
+
+void
+ce_print_buffer (u8 *buf, int length)
+{
+ int i, l32 = (length+3)/4;
+ if (buf)
+ {
+ u32 *browser = (u32 *) buf;
+ ce_print (" BUFFER :\n");
+
+ for (i=0; i<l32; i++)
+ {
+ if ((i%8)==0) ce_print("\n%d\t|", i);
+ //ce_print_byte (*(buf+i));
+ ce_print ("%8x|", *(browser++));
+ }
+ ce_print("\n\n");
+ }
+ else ce_print (" BUFFER NULL !\n");
+}
+
+void
+ce_print_tonemap (tonemap_t *tm)
+{
+ uint i;
+ if(tm)
+ {
+ ce_print("strict:%d ",tm->strict);
+ ce_print("cpf:%d ",tm->cpf);
+ ce_print("fecratio : %d ",tm->fecrate);
+ ce_print("guard : %d ",tm->gil);
+ ce_print("ble = %d \n",tm->ble);
+ u32 *tm_data = (u32 *) tm->tmdma_desc_head->data;
+ for (i=0; i<(PHY_CARRIER_NB+7)/8; i++)
+ {
+ if (i == 128 ) tm_data = (u32 *) tm->tmdma_desc_head->next->data;
+ ce_print_nibble (*(tm_data++));
+ if((i+1)%16==0) ce_print("\n");
+ }
+ ce_print ("\n");
+ }
+}
+
+void
+ce_print_tonemaps (tonemaps_t *tms)
+{
+ int i;
+
+ ce_print ("MAX_FL_AV = %x ",tms->max_fl_av);
+ ce_print ("RIFS %x:%x:%x ",tms->rifs_av_one_sym_tck, tms->rifs_av_two_sym_tck, tms->rifs_av_g2_sym_tck);
+ ce_print ("MAX_TM = %x ",tms->max_tm);
+ ce_print ("Default_tmi = %x ",tms->default_tmi);
+ ce_print ("scl_cp = %x ",tms->scl_cp);
+ ce_print ("scl_cfp = %x ",tms->scl_cfp);
+ ce_print ("expir = %x ",tms->expiration_rtc_date);
+ ce_print ("valid tm nb = %d \n",tonemap_valid_nb (tms));
+
+ for (i=0; i<TONEMAP_INDEX_NB; i++)
+ {
+ if (tms->tm[i])
+ {
+ ce_print("indice %d (%d) ",i,i+4);
+ ce_print_tonemap(tms->tm[i]);
+ }
+ }
+
+ tonemap_intervals_t *intervals = tms->intervals;
+ ce_print ("intervals nb = %d ",intervals->intervals_nb);
+ for (i=0; i<(int)intervals->intervals_nb; i++)
+ {
+ ce_print ("interval[%d]={%.0f,%d} ", i,intervals->interval[i].end_offset_atu*10.24,
+ intervals->interval[i].tmi);
+ }
+ ce_print ("\n");
+}
+
+void
+ce_print_chandata (phy_chandata_t *f)
+{
+ uint i;
+ for(i=0; i<PHY_CHANDATA_BLK_NB; i++)
+ //while (f)
+ {
+ ce_print("{size:%d, last:%d, type:%d, @0x%x}",f->size, f->last, f->type, f->address);
+ if( (i+1) < PHY_CHANDATA_BLK_NB) ce_print ("->\n");
+ f = (phy_chandata_t *) f->blk.next;
+ }
+ ce_print ("\n");
+}
+
+void
+ce_print_frame_measurement (frame_measurement_t *fm)
+{
+ int j;
+ ce_print ("rx_params @ 0x%x -> 0x%x\n", &fm->rx_params, fm->rx_params);
+ ce_print ("ber_stock @ 0x%x -> 0x%x\n", &fm->ber_measurement, fm->ber_measurement);
+ for (j=0; j<PHY_CHANDATA_TYPE_NB; j++)
+ {
+ ce_print ("noise[%d] is @ 0x%x -> 0x%x\n", j, &fm->type_head[j], fm->type_head[j]);
+ }
+}
+#endif
diff --git a/cesar/ce/test/common/tonemap_utils.h b/cesar/ce/test/common/tonemap_utils.h
new file mode 100644
index 0000000000..7d214c6e5a
--- /dev/null
+++ b/cesar/ce/test/common/tonemap_utils.h
@@ -0,0 +1,135 @@
+#ifndef ___common_tonemap_utils_h
+#define ___common_tonemap_utils_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ../common/tonemap_utils.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "mac/common/tonemap.h"
+#include "lib/test.h"
+#include "lib/rnd.h"
+#include "lib/bitstream.h"
+
+lib_rnd_t rnd;
+
+#ifndef MAXIMUS_TEST
+static void
+create_tm (tonemaps_t *tms, u8 *mask, uint tmi, uint max_rnd, uint offset)
+{
+ int i;
+ bitstream_t stream;
+ tms->default_tmi = 0;
+ tms->tm[tmi] = tonemap_alloc ();
+ tms->tm[tmi]->cpf = 1;
+ tms->tm[tmi]->fecrate = 2;
+ tms->tm[tmi]->gil = 3;
+ bitstream_init (&stream, tms->tm[tmi]->tmdma_desc_head->data, 512, BITSTREAM_WRITE);
+ for (i=0; i<PHY_CARRIER_NB+1; i++)
+ {
+ int n = i/8;
+ int r = i%8;
+ int pos = 1<<r;
+ uint to_write;
+ if (i==1024)
+ {
+ bitstream_finalise (&stream);
+ bitstream_init (&stream, tms->tm[tmi]->tmdma_desc_head->next->data, 512, BITSTREAM_WRITE);
+ }
+ if ( (mask[n] & pos) == 0)
+ {
+ to_write = 0; bitstream_access (&stream, &to_write, 4);
+ }
+ else
+ {
+ if (max_rnd != 0 )
+ {
+ to_write = offset+lib_rnd_uniform(&rnd,max_rnd); bitstream_access (&stream, &to_write, 4);
+ }
+ else
+ {
+ to_write = (i&0x07); bitstream_access (&stream, &to_write, 4);
+ }
+ }
+ bitstream_finalise (&stream);
+ }
+}
+#endif
+
+/**
+ * Compare two tonemaps in the test environment
+ * \param t test
+ * \param tms1 tonemaps 1
+ * \param tms2 tonemaps 2
+ *
+ * Check all tonemap (TONEMAP_INDEX_NB)
+ */
+static void
+compare_tonemaps (test_t t, tonemaps_t *tms1, tonemaps_t *tms2, u8 *mask)
+{
+ test_begin (t, "tonemap compare")
+ {
+ int i,j;
+ test_fail_if (tms1->max_fl_av != tms2->max_fl_av);
+ test_fail_if (tms1->rifs_av_one_sym_tck != tms2->rifs_av_one_sym_tck);
+ test_fail_if (tms1->rifs_av_two_sym_tck != tms2->rifs_av_two_sym_tck);
+ test_fail_if (tms1->rifs_av_g2_sym_tck != tms2->rifs_av_g2_sym_tck);
+ test_fail_if (tms1->max_tm != tms2->max_tm);
+ test_fail_if (tms1->default_tmi != tms2->default_tmi);
+ test_fail_if (tms1->scl_cp != tms2->scl_cp);
+ test_fail_if (tms1->scl_cfp != tms2->scl_cfp);
+
+ for (i=0; i<TONEMAP_INDEX_NB; i++)
+ {
+ if(tms1->tm[i] && tms2->tm[i])
+ {
+ //my_print ("test tm[%d]\n",i);
+ tonemap_t *tm1=tms1->tm[i];
+ tonemap_t *tm2=tms2->tm[i];
+ bitstream_t stream1;
+ bitstream_t stream2;
+ bitstream_init (&stream1, tm1->tmdma_desc_head->data, BLK_SIZE, BITSTREAM_READ);
+ bitstream_init (&stream2, tm2->tmdma_desc_head->data, BLK_SIZE, BITSTREAM_READ);
+ test_fail_if (tm1->cpf != tm2->cpf);
+ test_fail_if (tm1->fecrate != tm2->fecrate);
+ test_fail_if (tm1->gil != tm2->gil);
+ for(j=0; j<PHY_CARRIER_NB; j++)
+ {
+
+ if (j==1024)
+ {
+ bitstream_init (&stream1, tm1->tmdma_desc_head->next->data, BLK_SIZE, BITSTREAM_READ);
+ bitstream_init (&stream2, tm2->tmdma_desc_head->next->data, BLK_SIZE, BITSTREAM_READ);
+ }
+
+ u8 d1,d2;
+ bitstream_access (&stream1, &d1, 4);
+ bitstream_access (&stream2, &d2, 4);
+ //ce_print ("c%d : m1-%d m2-%d\n",j, d1, d2);
+ test_fail_if ( d1 != d2 && ((mask[j/8] & (1<<(j%8))) != 0) );
+ }
+ tonemap_intervals_t *intervals1 = tms1->intervals;
+ tonemap_intervals_t *intervals2 = tms2->intervals;
+ test_fail_if (intervals1->intervals_nb != intervals2->intervals_nb);
+ for (j=0; j<(int)intervals1->intervals_nb; j++)
+ {
+ tonemap_interval_t tmi1=intervals1->interval[j];
+ tonemap_interval_t tmi2=intervals2->interval[j];
+ test_fail_if ( tmi1.end_offset_atu != tmi2.end_offset_atu );
+ test_fail_if ( tmi1.tmi != tmi2.tmi );
+ }
+ }
+ else test_fail_if (tms1->tm[i] != tms2->tm[i]);
+ }
+ } test_end;
+}
+
+#endif /* ___common_tonemap_utils_h */
diff --git a/cesar/ce/test/cov/cov_all_run.sh b/cesar/ce/test/cov/cov_all_run.sh
new file mode 100755
index 0000000000..f405ec2a79
--- /dev/null
+++ b/cesar/ce/test/cov/cov_all_run.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+clean=
+firefox=0
+MAXIMUS_ARG=
+run=
+
+while getopts cfm:et: opt
+do
+ case "$opt" in
+ c) clean="-c";;
+ e) run="-e";;
+ f) firefox=1;;
+ m) MAXIMUS_ARG="-x $OPTARG";;
+ t) test_path="$OPTARG";;
+ [?]) print >&2 "Usage: $0 [-c] [-e] [-f] [-m maximus_path] [-t test_path] "
+ exit 1;;
+ esac
+done
+
+cov_path=`dirname $0`
+if [ "$run" != "" ]
+then
+ echo "Erase coverage result"
+ rm -rf $cov_path/result
+ mkdir $cov_path/result
+fi
+
+$cov_path/cov_one_run.sh -t $test_path -s tx -m host-Makefile -o obj/host $clean $run -h host
+$cov_path/cov_one_run.sh -t $test_path -s tx -m target-Makefile -o obj/target $clean $run -h target
+$cov_path/cov_one_run.sh -t $test_path -s rx/general -m host-Makefile -o obj/host $clean $run -h host
+$cov_path/cov_one_run.sh -t $test_path -s rx/general -m target-Makefile -o obj/target $clean $run -h target
+$cov_path/cov_one_run.sh -t $test_path -s rx/tonemap_refresh -m Makefile -o obj $clean $run -h target
+$cov_path/cov_one_run.sh -t $test_path -s rx/maximus -m Makefile -o obj $clean $run -p send_noise.py $MAXIMUS_ARG -h target
+
+if [ "$firefox" = "1" ]
+then
+ ls -l $cov_path/result
+ genhtml -q -o $cov_path/result -s $cov_path/result/*.info
+ firefox $cov_path/result/index.html
+fi
+
diff --git a/cesar/ce/test/cov/cov_one_run.sh b/cesar/ce/test/cov/cov_one_run.sh
new file mode 100755
index 0000000000..ecb2530e4e
--- /dev/null
+++ b/cesar/ce/test/cov/cov_one_run.sh
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+py=
+maximus_path=
+clean=
+run=
+cross=target
+
+echo "$0 $@"
+while getopts t:s:m:o:cep:x:h: opt
+do
+ case "$opt" in
+ t) TEST_PATH="$OPTARG";;
+ s) SUBTEST_PATH="$OPTARG";;
+ m) MAKEFILE_NAME="$OPTARG";;
+ o) OBJ_PATH="$OPTARG";;
+ c) clean=1;;
+ p) py="$OPTARG";;
+ x) maximus_path="$OPTARG";;
+ e) run=1;;
+ h) cross="$OPTARG";;
+ [?]) print >&2 "Usage: $0 -t test_path -s subtest_path -m makefile -o objpath [-c(clean)] [-e(exec)] [-p] python_file [-x] maximus_path [-h] host/target"
+ exit 1;;
+ esac
+done
+
+SUBTEST_PATH=$TEST_PATH/$SUBTEST_PATH
+OBJ_PATH=$SUBTEST_PATH/$OBJ_PATH
+
+if [ "$clean" != "" ]
+then
+ echo "Make Clean @ $SUBTEST_PATH..."
+ rm -rf $SUBTEST_PATH/obj
+ rm -f $SUBTEST_PATH/*.da; rm -f $SUBTEST_PATH/*.bb*;rm -f $SUBTEST_PATH/*.log
+fi
+
+if [ "$run" != "" ]
+then
+ echo "Compiling $MAKEFILE_NAME in $SUBTEST_PATH ..."
+ make COV=Y -C $SUBTEST_PATH --file=$MAKEFILE_NAME --no-print-directory > $SUBTEST_PATH/$MAKEFILE_NAME.log
+ #for i in `ls $OBJ_PATH | grep "\.elf$"`
+ for i in `ls -l $OBJ_PATH | grep "^-rwxr-xr-x" | cut -d " " -f8`
+ do
+ if [ "$py" != "" ]
+ then
+ echo "Running python $SUBTEST_PATH/$py -e $OBJ_PATH/$i -d false -l 1"
+ python $SUBTEST_PATH/$py -e $OBJ_PATH/$i -d false -l 1 --maximus_path $maximus_path
+ else
+ echo "Running " $OBJ_PATH/$i;
+ ./$OBJ_PATH/$i
+ fi
+ echo "Make coverage report ..."
+ if [ "$cross" = "target" ]
+ then
+ sleep 1
+ lcov -q -d $SUBTEST_PATH -b $SUBTEST_PATH -c -o $OBJ_PATH/$i.info -g /usr/local/toolchains/gnutools/i386-elf/bin/i386-elf-gcov
+ else
+ lcov -q -d $OBJ_PATH -b $SUBTEST_PATH -c -o $OBJ_PATH/$i.info
+ fi
+ echo "Copying files .info"
+ cp $OBJ_PATH/$i.info $TEST_PATH/cov/result
+ done
+fi
diff --git a/cesar/ce/test/rx/Config b/cesar/ce/test/rx/Config
new file mode 100755
index 0000000000..f3da7ad972
--- /dev/null
+++ b/cesar/ce/test/rx/Config
@@ -0,0 +1,5 @@
+CONFIG_DEBUG_FATAL_CATCH=y
+#CONFIG_RESTRACK=y
+#CONFIG_RESTRACK_KEEP=y
+CONFIG_TRACE=y
+
diff --git a/cesar/ce/test/rx/general/Makefile b/cesar/ce/test/rx/general/Makefile
new file mode 100644
index 0000000000..b0e6e8d3fa
--- /dev/null
+++ b/cesar/ce/test/rx/general/Makefile
@@ -0,0 +1,8 @@
+all :
+ $(MAKE) -f host-Makefile --no-print-directory
+ $(MAKE) -f target-Makefile --no-print-directory
+
+clean :
+ $(MAKE) -f host-Makefile clean
+ $(MAKE) -f target-Makefile clean
+
diff --git a/cesar/ce/test/rx/general/host-Makefile b/cesar/ce/test/rx/general/host-Makefile
new file mode 100755
index 0000000000..296fad4b8d
--- /dev/null
+++ b/cesar/ce/test/rx/general/host-Makefile
@@ -0,0 +1,33 @@
+BASE = ../../../..
+
+INCLUDES=ce/test/rx
+INCLUDES+=ce/test/common
+INCLUDES+=ce/test/common/ecos_overide
+
+EXTRA_HOST_LDFLAGS=-lm
+HOST_PROGRAMS = test_cei_host_linux_i386
+test_cei_host_linux_i386_SOURCES = test_cei.c
+test_cei_host_linux_i386_MODULES = lib mac/common ce ce/test/common ce/test/common/ecos_overide/cyg/kernel
+HOST_PROGRAMS += test_cei_param_host_linux_i386
+test_cei_param_host_linux_i386_SOURCES = test_cei_param.c
+test_cei_param_host_linux_i386_MODULES = lib mac/common ce ce/test/common ce/test/common/ecos_overide/cyg/kernel
+HOST_PROGRAMS += test_measure_store_host_linux_i386
+test_measure_store_host_linux_i386_SOURCES = test_mpdu_measure_store.c
+test_measure_store_host_linux_i386_MODULES = lib mac/common ce ce/test/common ce/test/common/ecos_overide/cyg/kernel
+HOST_PROGRAMS += test_bitloading_host_linux_i386
+test_bitloading_host_linux_i386_SOURCES = test_bitloading.c
+test_bitloading_host_linux_i386_MODULES = lib mac/common ce ce/test/common ce/test/common/ecos_overide/cyg/kernel
+
+#HOST_PROGRAMS += test_speed_host_linux_i386
+#test_speed_host_linux_i386_SOURCES = test_speed.c
+#test_speed_host_linux_i386_MODULES = lib mac/common ce ce/test/common
+
+
+ce_MODULE_SOURCES = cei_param.c mpdu_measure_store.c bitloading.c
+ce_test_common_MODULE_SOURCES = print_utils.c gaussian.c
+mac_common_MODULE_SOURCES = tonemap.c tonemask.c store.c mfs.c sta.c
+
+VARIANT = host
+
+include $(BASE)/common/make/top.mk
+
diff --git a/cesar/ce/test/rx/general/overide/cp/Module b/cesar/ce/test/rx/general/overide/cp/Module
new file mode 100644
index 0000000000..3983e4ac20
--- /dev/null
+++ b/cesar/ce/test/rx/general/overide/cp/Module
@@ -0,0 +1 @@
+SOURCES := cp.c
diff --git a/cesar/ce/test/rx/general/overide/cp/cp.h b/cesar/ce/test/rx/general/overide/cp/cp.h
new file mode 100644
index 0000000000..f2094aa56f
--- /dev/null
+++ b/cesar/ce/test/rx/general/overide/cp/cp.h
@@ -0,0 +1,50 @@
+#ifndef ___rx_general_overide_cp_cp_h
+#define ___rx_general_overide_cp_cp_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ../rx/general/overide/cp/cp.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "mac/common/tonemap.h"
+#include "mac/common/store.h"
+#include "mac/common/config.h"
+#include "cyg/kernel/kapi.h"
+#include "ce/inc/tx.h"
+
+struct cp_t
+{
+ mac_store_t *mac_store_ctx;
+ mac_config_t *mac_config;
+ u8 *tonemask;
+ uint has_event;
+ u8 cei_buffer[1536];
+ bool stop_rcv_mme;
+ txce_t *txce_ctx;
+};
+typedef struct cp_t cp_t;
+
+void
+cp_process (cyg_addrword_t data);
+
+void
+cp_stop (cp_t *ctx);
+
+cp_t *
+cp_init (mac_store_t *mac_store_ctx, mac_config_t *mac_config);
+
+void
+cp_event_add (cp_t *ctx, uint type_event);
+
+void
+cp_emul_cei_reception (cp_t *ctx);
+
+#endif /* ___rx_general_overide_cp_cp_h */
diff --git a/cesar/ce/test/rx/general/overide/cp/interf/Module b/cesar/ce/test/rx/general/overide/cp/interf/Module
new file mode 100644
index 0000000000..5950fd7d38
--- /dev/null
+++ b/cesar/ce/test/rx/general/overide/cp/interf/Module
@@ -0,0 +1 @@
+SOURCES := interf.c
diff --git a/cesar/ce/test/rx/general/overide/cp/interf/interf.h b/cesar/ce/test/rx/general/overide/cp/interf/interf.h
new file mode 100755
index 0000000000..8c3545604e
--- /dev/null
+++ b/cesar/ce/test/rx/general/overide/cp/interf/interf.h
@@ -0,0 +1,65 @@
+#ifndef cp_interf_interf_h
+#define cp_interf_interf_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ./overide/cp/cp.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+#include "common/defs/ethernet.h"
+#include "mac/sar/inc/sar_mf.h"
+#include "cyg/kernel/kapi.h"
+
+#define TXCE_EVENT 0
+
+u8 buf[ETH_PACKET_MAX_SIZE];
+
+typedef void (*interf_event_add_cb_t) (void *userdata, uint type_event);
+
+struct interf_t
+{
+ interf_event_add_cb_t event_add_cb;
+ void *event_add_userdata;
+};
+typedef struct interf_t interf_t;
+
+struct mme_t
+{
+ /** Destination TEI of the MME.*/
+ uint dtei;
+ /** Length of the MM_ENTRY.*/
+ uint length;
+ /** Type of the MME.*/
+ uint mm_type;
+ /** Pointer to the start of the MM_ENTRY.*/
+ u8 * mm_entry;
+};
+typedef struct mme_t mme_t;
+
+BEGIN_DECLS
+
+interf_t *
+interf_init ( interf_event_add_cb_t event_add_cb, void* userdata);
+
+mme_t *
+interf_mme_get (void);
+
+void
+interf_mme_send (mme_t *mme);
+
+void
+interf_event_add (interf_t *interf, uint type_event);
+
+
+END_DECLS
+
+#endif /* cp_interf_interf_h */
diff --git a/cesar/ce/test/rx/general/overide/cp/interf/src/interf.c b/cesar/ce/test/rx/general/overide/cp/interf/src/interf.c
new file mode 100755
index 0000000000..424b9426b3
--- /dev/null
+++ b/cesar/ce/test/rx/general/overide/cp/interf/src/interf.c
@@ -0,0 +1,52 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ./overide/cp/src/cp.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include "cp/interf/interf.h"
+#include "ce/inc/tx.h"
+#include "ce/inc/cei.h"
+
+static interf_t interf_global;
+mme_t mme;
+
+interf_t *
+interf_init ( interf_event_add_cb_t event_add_cb, void* userdata)
+{
+ interf_t *interf = &interf_global;
+ interf->event_add_cb = event_add_cb;
+ interf->event_add_userdata = userdata;
+ return (interf);
+}
+
+mme_t *
+interf_mme_get (void)
+{
+ mme.mm_entry = buf;
+ return &mme;
+}
+
+void
+interf_mme_send (mme_t *mme_to_send)
+{
+ dbg_assert (mme_to_send = &mme);
+ return;
+}
+
+void
+interf_event_add (interf_t *ctx, uint type_event)
+{
+ ctx->event_add_cb (ctx->event_add_userdata, type_event);
+ return;
+}
+
diff --git a/cesar/ce/test/rx/general/overide/cp/src/cp.c b/cesar/ce/test/rx/general/overide/cp/src/cp.c
new file mode 100644
index 0000000000..c810c1d82c
--- /dev/null
+++ b/cesar/ce/test/rx/general/overide/cp/src/cp.c
@@ -0,0 +1,92 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ../rx/general/overide/cp/src/cp.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include "cp/cp.h"
+#include "cp/interf/interf.h"
+#include "tonemap_utils.h"
+#include "lib/rnd.h"
+#include "ce/inc/cei_param.h"
+#define RXCE
+#include "ce/inc/cei.h"
+
+
+static cp_t cp_global;
+
+void
+cp_process (cyg_addrword_t data)
+{
+ cp_t *ctx = (cp_t *) data;
+ ctx->stop_rcv_mme = false;
+ while (true)
+ {
+ cyg_thread_delay (100);
+ if (ctx->has_event)
+ {
+ txce (ctx->txce_ctx, 0, 0, NULL);
+ ctx->has_event--;
+ }
+ if (!ctx->stop_rcv_mme) cp_emul_cei_reception (ctx);
+ }
+}
+
+void
+cp_stop (cp_t *ctx)
+{
+ ctx->stop_rcv_mme = true;
+}
+
+cp_t *
+cp_init (mac_store_t *mac_store_ctx, mac_config_t *mac_config)
+{
+ cp_t *ctx = &cp_global;
+ ctx->mac_store_ctx = mac_store_ctx;
+ ctx->mac_config = mac_config;
+ interf_t *interf = interf_init(&cp_event_add, (void *) ctx);
+ ctx->txce_ctx = txce_init (mac_store_ctx, mac_config, interf);
+ lib_rnd_init (&rnd, 123);
+ ctx->tonemask = (ctx->mac_config->tonemask_info.tonemask);
+ return ctx;
+}
+
+void
+cp_emul_cei_reception (cp_t *ctx)
+{
+ uint i;
+ uint alea_new_mme = lib_rnd_uniform (&rnd, 20);
+ if (alea_new_mme > 5)
+ {
+ return;
+ }
+ for (i=0; i<alea_new_mme; i++)
+ {
+ uint rnd_tmi = lib_rnd_uniform (&rnd, TONEMAP_INDEX_NB);
+ uint rnd_tei = lib_rnd_uniform (&rnd, MAC_TEI_STA_MAX) + MAC_TEI_STA_MIN;
+ mac_store_sta_add (ctx->mac_store_ctx, rnd_tei);
+ sta_t *lsta = mac_store_sta_get (ctx->mac_store_ctx, rnd_tei);
+ if (lsta->tx_tonemaps->tm[rnd_tmi] == NULL)
+ {
+ create_tm (lsta->tx_tonemaps, ctx->tonemask, rnd_tmi, 1, 4);
+ cei_create (ctx->cei_buffer, ctx->tonemask, lsta->tx_tonemaps, rnd_tmi, TONEMAP_INDEX_NULL);
+ txce (ctx->txce_ctx, rnd_tei, CM_CHAN_EST_IND, ctx->cei_buffer);
+ }
+ }
+}
+
+void
+cp_event_add (cp_t *ctx, uint type)
+{
+ if (type == TXCE_EVENT) ctx->has_event++;
+ return;
+}
diff --git a/cesar/ce/test/rx/general/src/test_bitloading.c b/cesar/ce/test/rx/general/src/test_bitloading.c
new file mode 100755
index 0000000000..319b06ca48
--- /dev/null
+++ b/cesar/ce/test/rx/general/src/test_bitloading.c
@@ -0,0 +1,235 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ./src/test_tx.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+
+#include "common/std.h"
+#include "lib/bitstream.h"
+#include "mac/common/tonemap.h"
+#include "ce/test/common/print_utils.h"
+#include "ce/inc/bitloading.h"
+#include "lib/rnd.h"
+#include "ce/test/common/gaussian.h"
+#include "mac/common/timings.h"
+#include "lib/test.h"
+
+lib_rnd_t rnd;
+
+void
+test_is_time_noise_stable (test_t t)
+{
+ test_begin (t, "is_time_noise_stable")
+ {
+ int i,j,k;
+ phy_chandata_t *test = (phy_chandata_t *) blk_alloc_desc ();
+ test->type = PHY_CHANDATA_TYPE_NRJ_SYMBOL;
+ test->size = 113 ;
+ double var;
+ double sigma_lambda=0.00;
+ uint stable_nb=0;
+ for (k = 1 ; k < 20; k++)
+ {
+ sigma_lambda += 0.01;
+ stable_nb = 0;
+ for (j=0; j<100; j++)
+ {
+ lib_rnd_init (&rnd, j);
+ phy_noise_energy_t *data = (phy_noise_energy_t *) test->blk.data;
+ for (i=0; i<113; i++)
+ {
+ int l = 2*UND_CODE;
+ var = lib_rnd_gaussian (&rnd, l, sigma_lambda*l);
+ if (var < 0) var = 2*l-var;
+ if (var > MAX_UND_CODE) var = 2*l -var;
+ if (var < 0) var = 0;
+ if (var > MAX_UND_CODE) var = MAX_UND_CODE;
+ *(data++) = (int) (var);
+ }
+ if (bitloading_mpdu_noise_stability (test)) stable_nb++;
+
+ }
+ test_fail_if (k < 10 && stable_nb < 80 );
+ test_fail_if (k > 10 && stable_nb > 20 );
+ test_fail_if (k == 10 && (stable_nb < 20 || stable_nb > 80) );
+ }
+ blk_release_desc ((blk_t *) test);
+ } test_end;
+}
+
+void
+test_noise2mod (test_t t)
+{
+ test_begin (t, "noise to modulation")
+ {
+ uint accu = 1 ; // DSP provides directly the average
+ uint noise_CODE;
+ uint mod;
+ uint mod_measurement;
+ //mpdu_measure_store_init ();
+ bitloading_update_threshold (accu, 1);
+ for (noise_CODE=0; noise_CODE<=UND_CODE; noise_CODE++)
+ {
+ mod_measurement = 1; // ONLY THR-QPSK TODO others
+ {
+ mod = bitloading_noise2mod (noise_CODE);
+ if (mod == 7 ) test_verbose_print ("mod = %d : %d <= %d?", mod, noise_CODE, THR3[mod_measurement][mod-1]);
+ if (mod == 0 ) test_verbose_print ("mod = %d : %d > %d?", mod, noise_CODE, THR3[mod_measurement][mod]);
+ if (mod != 0 && mod != 7 ) test_verbose_print ("mod = %d : %d E ]%d,%d]?", mod, noise_CODE, THR3[mod_measurement][mod], THR3[mod_measurement][mod-1]);
+ if (mod == 7 ) test_fail_if (noise_CODE > accu*THR3[mod_measurement][mod-1]);
+ else
+ {
+ test_fail_if (noise_CODE <= accu*THR3[mod_measurement][mod]);
+ if (mod != 0) test_fail_if (noise_CODE > accu*THR3[mod_measurement][mod-1]);
+ }
+ }
+ }
+ } test_end;
+}
+
+void
+test_compute_worst_tonemap (test_t t)
+{
+ test_begin (t, "update or new worst tonemap")
+ {
+ uint c;
+
+ phy_chandata_t *b, *l;
+ phy_chandata_t *freq_noise = (phy_chandata_t *) blk_alloc_desc_range (mpdu_measure_chandata_blk_nb[PHY_CHANDATA_TYPE_NRJ], (blk_t **) &l);
+ tonemap_t *tm = NULL;
+
+ l->blk.next = NULL;
+ l->last = 1;
+
+ int carrier_uninit = PHY_CARRIER_NB;
+ int carrier_init = 0;
+ int carrier_index = -1;
+ int k=0;
+ uint noise1[PHY_CARRIER_NB];
+ for (b = freq_noise; b; b = (phy_chandata_t *) b->blk.next)
+ {
+ if (carrier_uninit > 128) b->size = 128;
+ else b->size = carrier_uninit;
+ b->type = PHY_CHANDATA_TYPE_NRJ;
+ phy_noise_energy_t *data = (phy_noise_energy_t *) b->blk.data;
+ for (c=0; c<PHY_NOISE_NB_PER_BLK; c++)
+ {
+ carrier_index++;
+ carrier_uninit--;
+ carrier_init++;
+ *(data+c) = THR3[1][k%7];
+ k++;
+ noise1[carrier_index] = *(data+c);
+ if (carrier_uninit == 0) break;
+ }
+ }
+ bitloading_worst_tonemap_compute (&tm, freq_noise);
+ test_fail_if (!tm);
+ bitstream_t stream;
+ bitstream_init(&stream, tm->tmdma_desc_head->data, BLK_SIZE, BITSTREAM_READ);
+ for (c=0; c< PHY_CARRIER_NB; c++)
+ {
+ if (c == 1024)
+ {
+ bitstream_init(&stream, tm->tmdma_desc_head->next->data, BLK_SIZE, BITSTREAM_READ);
+ }
+ uint mod;
+ bitstream_access (&stream, &mod, 4);
+ uint noise = noise1[c];
+ if (mod == 0) test_fail_if (noise < THR3[1][0]);
+ if (mod == 7) test_fail_if (noise > THR3[1][6]);
+ if (mod>0 && mod<7)
+ {
+ test_fail_if (noise > THR3[1][mod-1]);
+ test_fail_if (noise <= THR3[1][mod]);
+ }
+ }
+
+ lib_rnd_init (&rnd, 23);
+
+ carrier_uninit = PHY_CARRIER_NB;
+ carrier_init = 0;
+ carrier_index = -1;
+ uint noise2[PHY_CARRIER_NB];
+ for (b = freq_noise; b; b = (phy_chandata_t *) b->blk.next)
+ {
+ phy_noise_energy_t *data = (phy_noise_energy_t *) b->blk.data;
+ for (c=0; c<PHY_NOISE_NB_PER_BLK; c++)
+ {
+ carrier_index++;
+ carrier_uninit--;
+ carrier_init++;
+ *(data+c) = lib_rnd_uniform (&rnd, 2*noise1[carrier_index]+1);
+ noise2[carrier_index] = *(data+c);
+ if (carrier_uninit == 0) break;
+ }
+ }
+ bitloading_worst_tonemap_compute (&tm, freq_noise);
+ test_fail_if (!tm);
+ bitstream_init(&stream, tm->tmdma_desc_head->data, BLK_SIZE, BITSTREAM_READ);
+ for (c=0; c< PHY_CARRIER_NB; c++)
+ {
+ if (c == 1024)
+ {
+ bitstream_init(&stream, tm->tmdma_desc_head->next->data, BLK_SIZE, BITSTREAM_READ);
+ }
+ uint mod;
+ bitstream_access (&stream, &mod, 4);
+ uint noise = noise2[c]; if (noise1[c]>noise2[c]) noise = noise1[c];
+ if (mod == 0) test_fail_if (noise < THR3[1][0]);
+ if (mod == 7) test_fail_if (noise > THR3[1][6]);
+ if (mod>0 && mod<7)
+ {
+ test_fail_if (noise > THR3[1][mod-1]);
+ test_fail_if (noise <= THR3[1][mod]);
+ }
+ }
+ blk_release_desc_range ((blk_t *) freq_noise,(blk_t *) l);
+ blk_t *f = tm->tmdma_desc_head;
+ blk_release_desc_range (f, f->next);
+ tm = NULL;
+
+ } test_end;
+ }
+
+void
+test_date_in_beacon_atu_get (test_t t)
+{
+ test_begin (t, "check date_atu_get")
+ {
+ int i;
+ for (i=0; i<MAC_MS_TO_TCK(40)/2; i++)
+ {
+ uint ans = bitloading_date_in_beacon_atu_get (i, (0xFFFFFFFF)-i);
+ test_fail_if (ans != (uint) MAC_TCK_TO_ATU(2*i+1));
+ ans = bitloading_date_in_beacon_atu_get (1000000-i, i);
+ test_fail_if (ans != (uint) MAC_TCK_TO_ATU(1000000-2*i));
+ }
+ } test_end;
+}
+
+int
+main (int argc, char **argv)
+{
+ test_t test;
+ mpdu_measure_store_init ();
+ test_init (test, argc, argv);
+ test_case_begin (test, "CE-computation");
+ test_is_time_noise_stable (test);
+ test_noise2mod (test);
+ test_compute_worst_tonemap (test);
+ test_date_in_beacon_atu_get (test);
+ test_result (test);
+ return (test_nb_failed (test) == 0 ? 0 : 1);
+}
+
diff --git a/cesar/ce/test/rx/general/src/test_cei.c b/cesar/ce/test/rx/general/src/test_cei.c
new file mode 100755
index 0000000000..3c883cbd71
--- /dev/null
+++ b/cesar/ce/test/rx/general/src/test_cei.c
@@ -0,0 +1,80 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ./src/test_cei.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#define RXCE
+#define TXCE
+#include "ce/inc/cei.h"
+#include "lib/test.h"
+#include "mac/common/tonemask.h"
+#include "ce/test/common/tonemap_utils.h"
+#include "ce/test/common/print_utils.h"
+
+void
+test_exchange (test_t test, tonemaps_t *rx_tms, tonemaps_t *tx_tms,
+ u8 *mask, uint tmi, uint max_rnd, uint offset)
+{
+ u8 buffer[1536];
+ int i; for (i=0; i<1536; i++) buffer[i]=0;
+ create_tm (rx_tms, mask, tmi, max_rnd, offset);
+ ce_print_tonemaps (rx_tms);
+ cei_create (buffer, mask, rx_tms, tmi, TONEMAP_INDEX_NULL);
+ ce_print_buffer (buffer, 512);
+ cei_decode (tx_tms, CM_CHAN_EST_IND, buffer, mask);
+ ce_print_tonemaps (tx_tms);
+ compare_tonemaps (test, rx_tms, tx_tms, mask);
+}
+
+int
+main (int argc, char **argv)
+{
+ int i;
+ u8 mask[(PHY_CARRIER_NB+7)/8];
+ for (i=0; i<(PHY_CARRIER_NB+7)/8; i++) mask[i] = 0xFF;
+ mask[i-1] = ((1<<(PHY_CARRIER_NB%8))-1);
+ test_t test;
+ lib_rnd_init (&rnd, 12);
+ test_init (test, argc, argv);
+ tonemaps_t *rx_tms = tonemaps_alloc();
+ tonemaps_t *tx_tms = tonemaps_alloc();
+ test_case_begin (test, "CE-cei-full mask");
+ test_exchange (test, rx_tms, tx_tms, mask, 0, 3, 1);
+ test_exchange (test, rx_tms, tx_tms, mask, 1, 2, 6);
+ test_exchange (test, rx_tms, tx_tms, mask, 2, 1, 3);
+ test_exchange (test, rx_tms, tx_tms, mask, 3, 0, 3);
+ tonemaps_release (rx_tms);
+ tonemaps_release (tx_tms);
+ test_begin (test, "check alloc/free")
+ {
+ test_fail_unless (blk_check_memory());
+ } test_end;
+
+ rx_tms = tonemaps_alloc();
+ tx_tms = tonemaps_alloc();
+ tonemask_default (mask);
+ test_case_begin (test, "CE-cei-default mask");
+ test_exchange (test, rx_tms, tx_tms, mask, 0, 3, 1);
+ test_exchange (test, rx_tms, tx_tms, mask, 1, 2, 6);
+ test_exchange (test, rx_tms, tx_tms, mask, 2, 1, 3);
+ test_exchange (test, rx_tms, tx_tms, mask, 3, 0, 3);
+ tonemaps_release (rx_tms);
+ tonemaps_release (tx_tms);
+ test_begin (test, "check alloc/free")
+ {
+ test_fail_unless (blk_check_memory());
+ } test_end;
+ test_result (test);
+ return (test_nb_failed (test) == 0 ? 0 : 1);
+}
+
diff --git a/cesar/ce/test/rx/general/src/test_cei_param.c b/cesar/ce/test/rx/general/src/test_cei_param.c
new file mode 100755
index 0000000000..66a869d4d2
--- /dev/null
+++ b/cesar/ce/test/rx/general/src/test_cei_param.c
@@ -0,0 +1,86 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ./src/test_tx.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+
+#include "common/std.h"
+#include "ce/test/common/print_utils.h"
+#include "ce/inc/cei_param.h"
+
+#include "lib/rnd.h"
+#include "lib/test.h"
+
+lib_rnd_t rnd;
+
+void
+test_cei_param (test_t test, uint read_percent)
+{
+ test_begin (test, "test_cei_param")
+ {
+ int n;
+ //test_debug_print ("%d%% of read %d%% of write ", read_percent, 100-read_percent);
+ lib_rnd_init (&rnd, 23);
+ //cei_param_t cei_param;
+ cei_param_fifo_init ();
+ cei_param_t cei_param;
+ cei_param.tms = NULL;
+ cei_param.new_tmi = 0;
+ cei_param.old_tmi = 0;
+ cei_param.priority = 0xFF;
+ cei_param.dtei = 0xFF;
+ uint cpt = 0;
+ for (n=0; n<1000; n++)
+ {
+ uint alea = lib_rnd_uniform (&rnd, 100);
+ //my_print ("%d\n" ,alea);
+ test_fail_if (cpt>CEI_WANTED_MAX);
+ if (alea > read_percent)
+ {
+ //my_print (" get %d <=> %d\n", cpt, cei_param_fifo.number);
+ uint reader_index = cei_param_fifo.reader_index;
+ test_fail_if (cpt != cei_param_fifo.number);
+ cei_param_t *param = cei_param_get ();
+ //if (!param) my_print ("param = NULL\n");
+ test_fail_if (!param && cpt!=0);
+ if (param)
+ {
+ //my_print ("%d <==> %d\n", reader_index, 0);
+ test_fail_if (reader_index != param->priority);
+ cpt--;
+ }
+ }
+ else
+ {
+ //my_print (" add\n");
+ cei_param.priority = cei_param_fifo.writer_index;
+ if (cei_param_add (&cei_param)) cpt++;
+ }
+ }
+ } test_end;
+}
+
+int
+main (int argc, char **argv)
+{
+ test_t test;
+ test_init (test, argc, argv);
+ test_case_begin (test, "CE-mme 75% of read");
+ test_cei_param (test, 75);
+ test_case_begin (test, "CE-mme 25% of read");
+ test_cei_param (test, 25);
+ test_case_begin (test, "CE-mme 50% of read");
+ test_cei_param (test, 50);
+ test_result (test);
+ return (test_nb_failed (test) == 0 ? 0 : 1);
+}
diff --git a/cesar/ce/test/rx/general/src/test_mpdu_measure_store.c b/cesar/ce/test/rx/general/src/test_mpdu_measure_store.c
new file mode 100755
index 0000000000..8b95e3cafd
--- /dev/null
+++ b/cesar/ce/test/rx/general/src/test_mpdu_measure_store.c
@@ -0,0 +1,294 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ./src/test_tx.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+
+#include "common/std.h"
+#include "mac/common/tonemap.h"
+#include "ce/test/common/print_utils.h"
+#include "lib/rnd.h"
+#include "lib/test.h"
+
+lib_rnd_t rnd;
+
+void
+test_alloc_release (test_t test)
+{
+ test_begin (test, "mpdu_measure allocation and release")
+ {
+ if (!blk_check_memory()) blk_print_memory();
+ test_fail_unless (blk_check_memory ());
+ } test_end;
+}
+
+void
+sar_fill_ber (blk_t *first, uint n, uint ber_init_value, uint offset)
+{
+ uint i;
+ u32 *wrdata = (u32 *) first->data;
+ uint cpt = offset;
+ for (i=0; i<n; i++)
+ {
+ if (cpt == BLK_SIZE/4)
+ {
+ dbg_assert (first->next);
+ first = first->next;
+ wrdata = (u32 *) first->data;
+ cpt=0;
+ }
+ *(wrdata+cpt) = i+ber_init_value;
+ cpt++;
+ }
+}
+
+void
+test_mpdu_measure_pb_add (test_t t, mpdu_measure_store_t *ctx)
+{
+ test_begin (t, "add pb measures")
+ {
+ uint sar_call_nb, pb_nb_per_call;
+ for (sar_call_nb=1; sar_call_nb < MAC_MAX_PB_PER_MPDU; sar_call_nb++)
+ {
+ uint max_pb_nb_per_call = MAC_MAX_PB_PER_MPDU / sar_call_nb;
+ for (pb_nb_per_call=1; pb_nb_per_call<max_pb_nb_per_call ; pb_nb_per_call ++)
+ {
+ uint N = sar_call_nb;
+ uint pb_nb_to_add = pb_nb_per_call;
+ uint n,i;
+ uint offset;
+ pb_measure_blk_t *first_ber =NULL;
+ pb_measure_blk_t *last_ber = NULL;
+
+ pbproc_rx_params_t *rx_params = (pbproc_rx_params_t *) blk_alloc();
+ mpdu_measure_store_append (ctx, rx_params, 0, &first_ber, &last_ber, NULL, 0, NULL);
+ mpdu_measure_t *measure = mpdu_measure_store_get(ctx);
+ for (n=0; n<N; n++)
+ {
+ mpdu_measure_pb_add (measure, pb_nb_to_add, &first_ber, &last_ber, &offset);
+ sar_fill_ber ((blk_t *)first_ber, pb_nb_to_add, n * pb_nb_to_add, offset);
+ }
+ pb_measure_blk_t *rd = measure->pb_head;
+ u32 *rddata = (u32 *) rd->data;
+ test_fail_if (!measure);
+ test_fail_if (!rd);
+ uint k=0;
+ uint cpt = 1;
+ do
+ {
+ for (i=0; i<BLK_SIZE/4; i++)
+ {
+ test_fail_if ( (i<rd->pb_nb) && *(rddata+i)!=k);
+ k++;
+ }
+ if (rd->next)
+ {
+ rd = rd->next;
+ rddata = (u32 *) rd->data;
+ cpt++;
+ }
+ else
+ {
+ test_fail_if (rd != last_ber);
+ rd = rd->next;
+ }
+ } while (rd);
+ uint comp = (N*pb_nb_to_add)/(BLK_SIZE/4);
+ if ((N*pb_nb_to_add)%(BLK_SIZE/4) >0) comp++;
+ test_fail_if (cpt != comp);
+ mpdu_measure_store_release (ctx, measure);
+ }
+ }
+ } test_end;
+}
+
+phy_chandata_t *
+chandata_init (int type)
+{
+ phy_chandata_t *last;
+ phy_chandata_t *chandata = (phy_chandata_t *) blk_alloc_desc_range (
+ mpdu_measure_chandata_blk_nb[type], (blk_t **) &last);
+ chandata->type = type;
+ last->blk.next = NULL;
+ phy_chandata_t *ch = chandata;
+ while (ch)
+ {
+ uint i;
+ phy_noise_energy_t * data = (phy_noise_energy_t *) ch->blk.data;
+ for (i=0; i<PHY_NOISE_NB_PER_BLK; i++ ) *(data+i) = (type)*i;
+ ch->last = 0;
+ ch->type = type;
+ ch = (phy_chandata_t *) ch->blk.next;
+ }
+ last->last = 1;
+ return (chandata);
+}
+
+void
+test_mpdu_measure_chandata_add (test_t t, mpdu_measure_store_t *ctx)
+{
+ test_begin (t, "add noise")
+ {
+ uint i;
+ pbproc_rx_params_t *rx_params = (pbproc_rx_params_t *) blk_alloc();
+ bool b = mpdu_measure_store_append (ctx, rx_params, 0, NULL, NULL, NULL, 0, NULL);
+ if (b)
+ {
+ mpdu_measure_t *measure = mpdu_measure_store_get(ctx);
+ for (i=1; i<PHY_CHANDATA_TYPE_NB; i++)
+ {
+ phy_chandata_t *chandata = chandata_init (i);
+ mpdu_measure_chandata_add (measure, chandata);
+ }
+ for (i=0; i<PHY_CHANDATA_TYPE_NB; i++)
+ {
+ phy_chandata_t *chandata = measure->chandata_head[i];
+ while (chandata)
+ {
+ phy_noise_energy_t *data = (phy_noise_energy_t *) chandata->blk.data;
+ uint j;
+ for (j=0; j<PHY_NOISE_NB_PER_BLK; j++)
+ {
+ test_fail_if (*(data+j) != i*j);
+ }
+ int last = chandata->last;
+ chandata = (phy_chandata_t *) chandata->blk.next;
+ if (!chandata) test_fail_if (last == 0);
+ else test_fail_if (last == 1);
+ }
+ }
+ mpdu_measure_store_release (ctx, measure);
+ }
+ } test_end;
+}
+
+void
+test_mpdu_measure_add (test_t t, mpdu_measure_store_t *ctx)
+{
+ test_begin (t, "add/remove mpdu measures")
+ {
+ lib_rnd_init (&rnd, 23);
+ int nb_frame_added = 0;
+ int nb_frame_measurement = 0;
+ int alea ;
+ int N = 1000;
+ int i;
+ for (i=0; i<N; i++)
+ {
+ alea = lib_rnd_uniform (&rnd, 100);
+ if (alea > 5 )
+ {
+ pbproc_rx_params_t *rx_params = (pbproc_rx_params_t *) blk_alloc();
+ pb_measure_blk_t **f,**l;
+ f = l = NULL;
+ bool b = mpdu_measure_store_append (ctx, rx_params, 0, f, l, NULL, 0, NULL);
+ if (b)
+ {
+ rx_params->preamble_ntb = nb_frame_added;
+ nb_frame_added++;
+ nb_frame_measurement++;
+ }
+ }
+ else
+ {
+ if (nb_frame_measurement == 0)
+ {
+ test_fail_if (ctx->measure_nb != 0);
+ }
+ else
+ {
+ mpdu_measure_t *first = mpdu_measure_store_get (ctx);
+ int test = first->rx_params->preamble_ntb;
+ test_fail_if (test != (nb_frame_added - nb_frame_measurement));
+ mpdu_measure_store_release (ctx, first);
+ nb_frame_measurement--;
+ }
+ }
+ }
+ while (nb_frame_measurement > 0)
+ {
+ mpdu_measure_t *first = mpdu_measure_store_get (ctx);
+ int test = first->rx_params->preamble_ntb;
+ test_fail_if (test != (nb_frame_added - nb_frame_measurement));
+ mpdu_measure_store_release (ctx, first);
+ nb_frame_measurement--;
+ }
+ test_fail_if (mpdu_measure_store_get (ctx));
+ } test_end;
+}
+
+void
+test_mpdu_measure_store_management (test_t t, mpdu_measure_store_t *ctx)
+{
+ test_begin (t, "store is full get-add-release")
+ {
+ int N = MPDU_MEASURE_STORE_SIZE;
+ int i;
+ // Fill the store.
+ for (i=0; i<N; i++)
+ {
+ pbproc_rx_params_t *rx_params = (pbproc_rx_params_t *) blk_alloc();
+ pb_measure_blk_t **f,**l;
+ f = l = NULL;
+ bool b = mpdu_measure_store_append (ctx, rx_params, 0, f, l, NULL, 0, NULL);
+ if (b)
+ {
+ rx_params->preamble_ntb = i;
+ }
+ }
+ // Get first then add before release.*/
+ mpdu_measure_t *first = mpdu_measure_store_get (ctx);
+ pbproc_rx_params_t *rx_params = (pbproc_rx_params_t *) blk_alloc();
+ pb_measure_blk_t **f,**l;
+ f = l = NULL;
+ bool b = mpdu_measure_store_append (ctx, rx_params, 0, f, l, NULL, 0, NULL);
+ test_fail_if (b);
+ mpdu_measure_store_release (ctx, first);
+ // Release all the store.
+ while (ctx->measure_nb)
+ {
+ mpdu_measure_store_release (ctx, mpdu_measure_store_get (ctx));
+ }
+ } test_end;
+ test_begin (t, "store is empty get-add-get-release")
+ {
+ mpdu_measure_t *first = mpdu_measure_store_get (ctx);
+ pbproc_rx_params_t *rx_params = (pbproc_rx_params_t *) blk_alloc();
+ pb_measure_blk_t **f,**l;
+ f = l = NULL;
+ // Test store empty.
+ first = mpdu_measure_store_get (ctx);
+ test_fail_if (first);
+ mpdu_measure_store_append (ctx, rx_params, 0, f, l, NULL, 0, NULL);
+ first = mpdu_measure_store_get (ctx);
+ test_fail_unless (first->rx_params == rx_params);
+ mpdu_measure_store_release (ctx, first);
+ } test_end;
+}
+
+int
+main (int argc, char **argv)
+{
+ test_t test;
+ mpdu_measure_store_t *ctx = mpdu_measure_store_init();
+ test_init (test, argc, argv);
+ test_case_begin (test, "RXCE-mpdu_measure_store");
+ test_mpdu_measure_pb_add (test, ctx);
+ test_mpdu_measure_chandata_add (test, ctx);
+ test_mpdu_measure_add (test, ctx);
+ test_mpdu_measure_store_management (test, ctx);
+ test_alloc_release (test);
+ test_result (test);
+ return (test_nb_failed (test) == 0 ? 0 : 1);
+}
+
diff --git a/cesar/ce/test/rx/general/src/test_rx.c b/cesar/ce/test/rx/general/src/test_rx.c
new file mode 100755
index 0000000000..e33ca4ec74
--- /dev/null
+++ b/cesar/ce/test/rx/general/src/test_rx.c
@@ -0,0 +1,281 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ./src/test_tx.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include "cyg/hal/hal_intr.h"
+#include "ce/inc/rx.h"
+#include "mac/common/tonemap.h"
+#include "ce/test/common/print_utils.h"
+#include "ce/test/rx/inc/test_rx.h"
+#include "lib/bitstream.h"
+#include "lib/rnd.h"
+#include "lib/test.h"
+#include "cp/interf/interf.h"
+#include "lib/trace.h"
+#include "mac/common/ntb.h"
+#include "ce/inc/trace.h"
+#include "ce/inc/bitloading.h"
+#include "mac/sar/sar.h"
+
+lib_rnd_t rnd;
+test_t test;
+phy_t *phy_ctx;
+rxce_t *rxce_ctx;
+sar_t *sar;
+
+
+#define FRAME_PRIORITY 10
+cyg_thread frame_thread;
+cyg_handle_t frame_handle;
+unsigned char frame_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+#define RXCE_PRIORITY 14
+cyg_thread rxce_thread;
+cyg_handle_t rxce_handle;
+unsigned char rxce_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+uint noise[PHY_CARRIER_NB];
+uint false_bit_nb[MAC_MAX_PB_PER_MPDU];
+
+struct test_status_t
+{
+ mac_store_t *mac_store_ctx;
+ sta_t *sta;
+ uint sound_nb;
+ uint null_ber_frame_nb;
+ uint date;
+};
+typedef struct test_status_t test_status_t;
+test_status_t status;
+
+struct frame_t
+{
+ bool sound;
+ uint sound_reason_code;
+ uint pb_nb;
+ pbproc_rx_params_t *rx_params;
+ uint *noise;
+ uint *false_bit_nb;
+};
+typedef struct frame_t frame_t;
+
+
+bool next_scf;
+
+void
+pbproc_rxce_init (pbproc_need_scf_cb_t need_scf)
+{
+ need_scf_cb = need_scf;
+}
+
+void
+pbproc_scf (void)
+{
+ //my_print ("pbproc scf\n");
+ next_scf = true;
+}
+
+void
+over_pbproc_init (void)
+{
+ next_scf = false;
+}
+
+bool
+pbproc_send_scf (void)
+{
+ ce_print ("\t\t\t\t ACK with scf = %d\n", next_scf);
+ bool ret = next_scf;
+ next_scf = false;
+ return (ret);
+}
+
+void
+sar_noise_new (pbproc_rx_params_t *rx_params, uint noise[], uint symbol_nb)
+{
+ uint i;
+ uint lambda = 0;
+ phy_chandata_t *time_noise;
+ time_noise = (phy_chandata_t *) blk_alloc_desc();
+ time_noise->blk.next = NULL;
+ time_noise->last = 0;
+ time_noise->type = PHY_CHANDATA_TYPE_NRJ_SYMBOL;
+ phy_noise_energy_t *time_data = (phy_noise_energy_t *) time_noise->blk.data;
+ phy_chandata_t *freq_noise, *last;
+ freq_noise = (phy_chandata_t *) blk_alloc_desc_range (mpdu_measure_chandata_blk_nb[PHY_CHANDATA_TYPE_NRJ],
+ (blk_t **) &last);
+ freq_noise->type = PHY_CHANDATA_TYPE_NRJ;
+ phy_chandata_t * ch = freq_noise;
+ phy_noise_energy_t *freq_data = (phy_noise_energy_t *) ch->blk.data;
+ for (i=0; i<PHY_CARRIER_NB; i++)
+ {
+ ch->type = PHY_CHANDATA_TYPE_NRJ;
+ ch->last = 0;
+ if ( ((i%PHY_NOISE_NB_PER_BLK) == 0) && (i!=0) )
+ {
+ ch = (phy_chandata_t *) ch->blk.next;
+ freq_data = (phy_noise_energy_t *) ch->blk.data;
+ }
+ * (freq_data+(i%PHY_NOISE_NB_PER_BLK)) = noise[i];
+ lambda+=noise[i];
+ }
+ lambda = lambda/PHY_CARRIER_NB;
+ last->last = 1;
+ last->blk.next = NULL;
+ for (i=0; i<symbol_nb; i++) *(time_data+i) = lambda;
+ time_noise->blk.next = (blk_t *) freq_noise;
+ ce_print ("\t\t\t\t ADD NOISES\n");
+ rxce_mpdu_measurement_add (rxce_ctx, rx_params, 0, NULL, NULL, (pb_t *) time_noise,
+ mpdu_measure_chandata_blk_nb[PHY_CHANDATA_TYPE_NRJ] +
+ mpdu_measure_chandata_blk_nb[PHY_CHANDATA_TYPE_NRJ_SYMBOL], NULL);
+}
+
+void
+frame_new (frame_t *frame)
+{
+ uint symbol_nb = 0;
+ frame->rx_params->preamble_ntb = status.date;
+ if (frame->sound)
+ {
+ symbol_nb = 19;
+ status.date += (19);
+ status.sound_nb++;
+ need_scf_cb (frame->rx_params->tei, frame->sound_reason_code);
+ cyg_thread_delay (symbol_nb/19);
+ sar_noise_new (frame->rx_params, frame->noise, symbol_nb);
+ }
+ else
+ {
+ ;
+ }
+}
+
+void
+frame_process (cyg_addrword_t data)
+{
+ mac_store_sta_add (status.mac_store_ctx, 1);
+ status.sta = mac_store_sta_get (status.mac_store_ctx, 1);
+ status.sound_nb = 0;
+ test_case_begin (test, "CE-rxce_process with noise reception");
+ test_begin (test, "rxce test1")
+ {
+ uint j;
+ uint nb_frame = 0;
+ uint worst[PHY_CARRIER_NB];
+
+ cyg_thread_delay (1);
+ lib_rnd_init (&rnd, 12);
+ do
+ {
+ frame_t *frame = blk_alloc();
+ pbproc_rx_params_t *rx_params = blk_alloc ();
+ frame->sound = true;
+ frame->sound_reason_code = 0xFD;
+ frame->pb_nb = 0;
+ frame->rx_params = rx_params;
+ frame->rx_params->tei = 1;
+ for (j=0; j<PHY_CARRIER_NB; j++)
+ {
+ if (nb_frame < FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP) noise[j] = j + lib_rnd_uniform(&rnd,(j+1));
+ else noise[j] = 0;
+ if (nb_frame == 0) worst[j] = noise[j];
+ else
+ {
+ if (worst[j]<noise[j]) worst[j] = noise[j];
+ }
+ }
+ frame->noise = noise;
+ frame_new (frame);
+ nb_frame++;
+ test_fail_if (status.sta->rxce.stable_ROBO_nb<FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && status.sta->rx_tonemaps->default_tmi != TONEMAP_INDEX_INITIAL_START);
+ test_fail_if (status.sta->rxce.stable_ROBO_nb>FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && status.sta->rx_tonemaps->default_tmi == TONEMAP_INDEX_INITIAL_START);
+ blk_release (frame);
+ } while (!pbproc_send_scf ());
+ bitstream_t stream;
+ bitstream_init (&stream, status.sta->rx_tonemaps->tm[status.sta->rx_tonemaps->default_tmi]->tmdma_desc_head->data, BLK_SIZE, BITSTREAM_READ);
+ for (j=0; j<PHY_CARRIER_NB; j++)
+ {
+ if (j==1024)
+ {
+ bitstream_init (&stream, status.sta->rx_tonemaps->tm[status.sta->rx_tonemaps->default_tmi]->tmdma_desc_head->next->data, BLK_SIZE, BITSTREAM_READ);
+ }
+ uint mod;
+ bitstream_access (&stream, &mod, 4);
+ if (mod==0)
+ {
+ test_fail_if (worst[j] <=THR3[1][0]);
+ }
+ else
+ {
+ if (mod==7)
+ {
+ test_fail_if (worst[j] > THR3[1][6]);
+ }
+ else
+ {
+ test_fail_if (worst[j]<=THR3[1][mod] || worst[j]>THR3[1][mod-1]);
+ }
+ }
+
+ }
+ } test_end;
+ // rxce_process can end to process and free pending frames.
+ cyg_thread_delay (1);
+
+ blk_release (status.sta);
+ mac_store_sta_remove (status.mac_store_ctx, 1);
+ mac_store_uninit (status.mac_store_ctx);
+ blk_release (phy_ctx);
+ rxce_trace_print(rxce_ctx);
+ rxce_trace_uninit (rxce_ctx);
+ blk_release (sar);
+ trace_uninit();
+ test_begin (test, "check alloc/free")
+ {
+ test_fail_unless (blk_check_memory());
+ } test_end;
+ test_result (test);
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+}
+
+void
+cyg_user_start (int argc, char **argv)
+{
+ trace_init();
+ phy_ctx = blk_alloc();
+ test_init (test, argc, argv);
+ mac_config_t mac_config;
+ mac_config_init (&mac_config);
+ status.mac_store_ctx = mac_store_init ();
+ mac_ntb_init (phy_ctx, &mac_config);
+ sar = blk_alloc();
+ rxce_ctx = rxce_init (sar, status.mac_store_ctx, &mac_config);
+ over_pbproc_init ();
+ pbproc_rxce_init (pbproc_need_scf_cb);
+
+ cyg_thread_create (RXCE_PRIORITY, &rxce_process, (cyg_addrword_t) rxce_ctx, "rxce",
+ rxce_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &rxce_handle, &rxce_thread);
+ cyg_thread_create (FRAME_PRIORITY, &frame_process, 0, "frame_test",
+ frame_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &frame_handle, &frame_thread);
+
+
+ //my_print ("launch rxce process\n");
+ cyg_thread_resume (rxce_handle);
+
+ //my_print ("launch frame process\n");
+ cyg_thread_resume (frame_handle);
+}
+
diff --git a/cesar/ce/test/rx/general/src/test_sar_integration.c b/cesar/ce/test/rx/general/src/test_sar_integration.c
new file mode 100755
index 0000000000..e580928cea
--- /dev/null
+++ b/cesar/ce/test/rx/general/src/test_sar_integration.c
@@ -0,0 +1,303 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ce/test/rx/sar_integration.c
+ * \brief Use sar callback for Channel estimation.
+ * \ingroup ce
+ *
+ */
+#include "common/std.h"
+#include "cyg/hal/hal_intr.h"
+#include "lib/test.h"
+#include "mac/sar/sar.h"
+#include "ce/inc/rx.h"
+#include "mac/common/pb.h" // PB header initialisation
+#include "ce/test/common/print_utils.h"
+#include "cp/interf/interf.h"
+//#include "mac/sar/inc/trace.h"
+#include "mac/common/ntb.h"
+#include "ce/inc/trace.h"
+#include "hal/phy/phy.h"
+#include "ce/inc/bitloading.h"
+
+#define FRAME_PRIORITY 10
+cyg_thread frame_thread;
+cyg_handle_t frame_handle;
+unsigned char frame_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+#define RXCE_PRIORITY 14
+cyg_thread rxce_thread;
+cyg_handle_t rxce_handle;
+unsigned char rxce_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+test_t test;
+mac_store_t *mac_store_ctx;
+mac_config_t mac_config;
+rxce_t *rxce_ctx;
+phy_t *phy;
+
+u32
+phy_date (phy_t *phy)
+{
+ return (cyg_current_time());
+}
+
+void
+pbproc_scf (void)
+{
+ ce_print("pbproc_scf()\n");
+}
+
+void
+emul_reassembly (int pb_nb, uint date, pbproc_rx_params_t **rx_params,
+ pb_t **f, pb_t **l, phy_chandata_t **noise)
+{
+ uint i, j;
+ if (pb_nb > 0)
+ {
+ *f = (pb_t *) blk_alloc_desc_range (pb_nb,(blk_t **)l);
+ (*l)->next = NULL;
+ phy_pb_rx_t *p = (phy_pb_rx_t *) *f;
+ for (i=0; i<(uint) pb_nb; i++)
+ {
+ p->pb_measurement.ber = i;
+ ((pb_t *)p)->header.vpbf = 0;
+ p = (phy_pb_rx_t *) p->blk.next;
+ }
+ }
+ else
+ {
+ *f = *l = NULL;
+ }
+
+ phy_chandata_t *l_noise, *p_noise;
+ phy_chandata_t *f_noise = (phy_chandata_t *) blk_alloc_desc_range (mpdu_measure_chandata_blk_nb[PHY_CHANDATA_TYPE_NRJ], (blk_t **)&l_noise);
+ p_noise = f_noise;
+ phy_noise_energy_t *data;
+ for (i=0; i<mpdu_measure_chandata_blk_nb[PHY_CHANDATA_TYPE_NRJ]; i++)
+ {
+ if (p_noise == l_noise)
+ {
+ p_noise->last = 1;
+ p_noise->blk.next = NULL;
+ dbg_assert (i == (mpdu_measure_chandata_blk_nb[PHY_CHANDATA_TYPE_NRJ]-1));
+ }
+ else
+ {
+ p_noise->last = 0;
+ }
+ p_noise->type = PHY_CHANDATA_TYPE_NRJ;
+ data = (phy_noise_energy_t *) p_noise->blk.data;
+ for (j=0; j<PHY_NOISE_NB_PER_BLK; j++) *data++ = (i+1) * j*3;
+ p_noise = (phy_chandata_t *) p_noise->blk.next;
+ }
+
+ *noise = (phy_chandata_t *) blk_alloc_desc ();
+ data = (phy_noise_energy_t *) (*noise)->blk.data;
+ for (j=0; j<PHY_NOISE_NB_PER_BLK; j++)
+ {
+ *data++ = 1000;
+ }
+ (*noise)->type = PHY_CHANDATA_TYPE_NRJ_SYMBOL;
+ (*noise)->last = 0;
+ (*noise)->blk.next =(blk_t *) f_noise;
+
+ *rx_params = blk_alloc();
+ (*rx_params)->preamble_ntb = date;
+ (*rx_params)->tei = 1;
+ (*rx_params)->lid = 1;
+}
+void
+run_one_reassembly (sar_t *sar_ctx, uint pb_nb)
+{
+ pbproc_rx_params_t *rx_params;
+ pb_t *f, *l;
+ phy_chandata_t *noise;
+
+ emul_reassembly (pb_nb, 0x00, &rx_params, &f, &l, &noise);
+ sar_mpdu_add (sar_ctx, NULL, NULL, rx_params, f, l, pb_nb, (pb_t *) noise,
+ mpdu_measure_chandata_blk_nb[PHY_CHANDATA_TYPE_NRJ] +
+ mpdu_measure_chandata_blk_nb[PHY_CHANDATA_TYPE_NRJ_SYMBOL]
+ );
+ blk_release (rx_params); // pbproc can erase it.
+ sar_launch (sar_ctx);
+}
+
+void
+START (sar_t **sar_ctx, sta_t **sta, ca_t **ca)
+{
+ pbproc_t *pbproc_ctx = pbproc_init (&mac_config, mac_store_ctx);
+ *ca = (ca_t *) blk_alloc();
+ *sar_ctx = sar_init (mac_store_ctx, pbproc_ctx, *ca);
+ sar_init_measure_context (*sar_ctx, rxce_ctx);
+ sar_init_measurement_cb (*sar_ctx, &rxce_mpdu_measurement_add);
+ mac_store_sta_add (mac_store_ctx, 1);
+ *sta = mac_store_sta_get (mac_store_ctx, 1);
+}
+
+void
+END (sar_t *sar_ctx, sta_t *sta, ca_t *ca)
+{
+ //sar_trace_print (sar_ctx);
+ blk_release (sta); // release reference to sta added by mac_store_mfs_get in START.
+ dbg_check (mac_store_sta_remove (mac_store_ctx, 1));
+ blk_release (ca);
+ sar_uninit (sar_ctx);
+}
+
+void
+frame_process (cyg_addrword_t data)
+{
+
+ sar_t *sar_ctx;
+ sta_t *sta;
+ ca_t *ca;
+ int n;
+ int tmi_null;
+ int tmp_exists;
+
+ test_case_begin (test, "One sound frame");
+ START (&sar_ctx, &sta, &ca);
+ run_one_reassembly (sar_ctx, 0);
+ cyg_thread_delay (3); //rxce can process
+ test_begin (test, "check rxce status")
+ {
+ test_fail_if (sta->rx_tonemaps->default_tmi != TONEMAP_INDEX_INITIAL_START);
+ test_fail_if (!sta->rxce.tm_in_build);
+ } test_end;
+ END (sar_ctx, sta, ca);
+
+ test_case_begin (test, "One 1-PB frame");
+ START (&sar_ctx, &sta, &ca);
+ run_one_reassembly (sar_ctx, 1);
+ cyg_thread_delay (3); //rxce can process
+ test_begin (test, "check rxce status")
+ {
+ test_fail_if (sta->rx_tonemaps->default_tmi != TONEMAP_INDEX_INITIAL_START);
+ test_fail_if (!sta->rxce.tm_in_build);
+ } test_end;
+ END (sar_ctx, sta, ca);
+
+ test_case_begin (test, "One 200-PB frame");
+ START (&sar_ctx, &sta, &ca);
+ run_one_reassembly (sar_ctx, 200);
+ cyg_thread_delay (1); //rxce can process
+ test_begin (test, "check rxce status")
+ {
+ test_fail_if (sta->rx_tonemaps->default_tmi != TONEMAP_INDEX_INITIAL_START);
+ test_fail_if (!sta->rxce.tm_in_build);
+ } test_end;
+ END (sar_ctx, sta, ca);
+
+ test_case_begin (test, "Several sound frames processed one by one");
+ START (&sar_ctx, &sta, &ca);
+ test_begin (test, "check rxce status")
+ {
+ for (n=0; n<FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP+10; n++)
+ {
+ run_one_reassembly (sar_ctx, 0);
+ cyg_thread_delay (3); //rxce can process
+ tmi_null = sta->rx_tonemaps->default_tmi == TONEMAP_INDEX_INITIAL_START;
+ tmp_exists = (int) sta->rxce.tm_in_build;
+ test_fail_if (n<FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmi_null);
+ test_fail_if (n<FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmp_exists);
+ test_fail_if (n>=FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmi_null);
+ test_fail_if (n==FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmp_exists);
+ test_fail_if (n>FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmp_exists);
+ }
+ } test_end;
+ END (sar_ctx, sta, ca);
+
+ test_case_begin (test, "Several sound frames and rxce late");
+ START (&sar_ctx, &sta, &ca);
+ test_begin (test, "check rxce status")
+ {
+ for (n=0; n<FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP+10; n++)
+ {
+ run_one_reassembly (sar_ctx, 0);
+ if (n == FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP -5 )
+ {
+ cyg_thread_delay (3); //rxce can process
+ uint frame_nb = sta->rxce.measurement_computed_nb-1;
+ tmi_null = sta->rx_tonemaps->default_tmi == TONEMAP_INDEX_INITIAL_START;
+ tmp_exists = (int) sta->rxce.tm_in_build;
+ //my_print ("%d, tmi_null=%d, tmp_exists=%d\n",frame_nb, tmi_null, tmp_exists);
+ test_fail_if (frame_nb<FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmi_null);
+ test_fail_if (frame_nb<FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmp_exists);
+ test_fail_if (frame_nb>=FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmi_null);
+ test_fail_if (frame_nb==FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmp_exists);
+ test_fail_if (frame_nb>FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmp_exists);
+ }
+ if (n == FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP )
+ {
+ cyg_thread_delay (3); //rxce can process
+ uint frame_nb = sta->rxce.measurement_computed_nb-1;
+ tmi_null = sta->rx_tonemaps->default_tmi == TONEMAP_INDEX_INITIAL_START;
+ tmp_exists = (int) sta->rxce.tm_in_build;
+ //my_print ("%d, tmi_null=%d, tmp_exists=%d\n",frame_nb, tmi_null, tmp_exists);
+ test_fail_if (frame_nb<FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmi_null);
+ test_fail_if (frame_nb<FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmp_exists);
+ test_fail_if (frame_nb>=FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmi_null);
+ test_fail_if (frame_nb==FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmp_exists);
+ test_fail_if (frame_nb>FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmp_exists);
+ }
+ if (n == FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP + 5 -1 )
+ {
+ cyg_thread_delay (3); //rxce can process
+ uint frame_nb = sta->rxce.measurement_computed_nb-1;
+ tmi_null = sta->rx_tonemaps->default_tmi == TONEMAP_INDEX_INITIAL_START;
+ tmp_exists = (int) sta->rxce.tm_in_build;
+ //my_print ("%d, tmi_null=%d, tmp_exists=%d\n",frame_nb, tmi_null, tmp_exists);
+ test_fail_if (frame_nb<FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmi_null);
+ test_fail_if (frame_nb<FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmp_exists);
+ test_fail_if (frame_nb>=FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmi_null);
+ test_fail_if (frame_nb==FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && tmp_exists);
+ test_fail_if (frame_nb>FRAME_NB_TO_COMPUTE_IN_INITIAL_STEP && !tmp_exists);
+ }
+ cyg_thread_delay (3); //rxce can process
+ }
+ } test_end;
+ END (sar_ctx, sta, ca);
+
+ mac_store_uninit (mac_store_ctx);
+ rxce_trace_print (rxce_ctx);
+ rxce_trace_uninit (rxce_ctx);
+ trace_uninit();
+ blk_release (phy);
+ test_begin (test, "check alloc/free")
+ {
+ test_fail_unless (blk_check_memory());
+ } test_end;
+ test_result (test);
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+}
+
+void
+cyg_user_start (int argc, char **argv)
+ {
+ test_init (test, argc, argv);
+ trace_init();
+ phy = (phy_t *) blk_alloc();
+ mac_ntb_init (phy, &mac_config);
+
+ tonemask_default ((u8 *)(&(mac_config.tonemask_info.tonemask)));
+ mac_store_ctx = mac_store_init ();
+ sar_t *sar = blk_alloc();
+ rxce_ctx = rxce_init (sar, mac_store_ctx, &mac_config);
+ cyg_thread_create (RXCE_PRIORITY, &rxce_process,(cyg_addrword_t) rxce_ctx, "rxce",
+ rxce_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &rxce_handle, &rxce_thread);
+ cyg_thread_resume (rxce_handle);
+ cyg_thread_create (FRAME_PRIORITY, &frame_process, 0, "frame_test",
+ frame_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &frame_handle, &frame_thread);
+ cyg_thread_resume (frame_handle);
+ blk_release (sar);
+
+}
+
+
diff --git a/cesar/ce/test/rx/general/target-Makefile b/cesar/ce/test/rx/general/target-Makefile
new file mode 100644
index 0000000000..96f9d8b9d4
--- /dev/null
+++ b/cesar/ce/test/rx/general/target-Makefile
@@ -0,0 +1,26 @@
+BASE = ../../../..
+
+INCLUDES = ce/test/rx/
+INCLUDES += ce/test/rx/general
+INCLUDES += ce/test/rx/general/overide
+INCLUDES += ce/test/common
+
+ECOS = y
+DEFS=-DSAR_UNIT_TEST=1
+
+TARGET_PROGRAMS=test_rx_target_ecos_synth
+test_rx_target_ecos_synth_SOURCES = test_rx.c
+test_rx_target_ecos_synth_MODULES = lib mac/common ce ce/test/common ce/test/rx/general/overide/cp/interf mac/sar mac/sar/test mac/pbproc mac/sar/bridgedma
+TARGET_PROGRAMS += test_sar_target_ecos_synth
+test_sar_target_ecos_synth_SOURCES = test_sar_integration.c
+test_sar_target_ecos_synth_MODULES = lib mac/sar ce mac/common mac/sar/bridgedma mac/pbproc mac/sar/test ce/test/common ce/test/rx/general/overide/cp/interf
+mac_pbproc_MODULE_SOURCES = mfs.c
+
+
+#ce_MODULE_SOURCES = bitloading.c cei_param.c mpdu_measure_store.c rx.c trace.c
+#ce_test_common_MODULE_SOURCES = print_utils.c
+
+VARIANT = target
+
+include $(BASE)/common/make/top.mk
+
diff --git a/cesar/ce/test/rx/general/target-ecos.ecc.sh b/cesar/ce/test/rx/general/target-ecos.ecc.sh
new file mode 100755
index 0000000000..2443d0e40f
--- /dev/null
+++ b/cesar/ce/test/rx/general/target-ecos.ecc.sh
@@ -0,0 +1,5 @@
+config=${1:-ecos-gen.ecc}
+ecosconfig --config=$config new linux default
+cat >> $config <<'EOF'
+EOF
+ecosconfig --config=$config check
diff --git a/cesar/ce/test/rx/host_linux_sparc/Makefile b/cesar/ce/test/rx/host_linux_sparc/Makefile
new file mode 100755
index 0000000000..7c653a0e09
--- /dev/null
+++ b/cesar/ce/test/rx/host_linux_sparc/Makefile
@@ -0,0 +1,17 @@
+BASE = ../../../..
+
+CC=sparc-linux-gcc
+INCLUDES=ce/test/rx
+INCLUDES+=ce/test/rx/host_linux_sparc
+
+EXTRA_HOST_CFLAGS=-O3
+EXTRA_HOST_LDFLAGS=-lm
+HOST_PROGRAMS = test_speed_host_linux_sparc
+test_speed_host_linux_sparc_SOURCES = test_speed.c
+test_speed_host_linux_sparc_MODULES = lib mac/common ce ce/test/common
+
+ce_MODULE_SOURCES = cei_param.c mpdu_measure_store.c bitloading.c
+ce_test_common_MODULE_SOURCES = print_utils.c
+
+include $(BASE)/common/make/top.mk
+
diff --git a/cesar/ce/test/rx/host_linux_sparc/src/test_speed.c b/cesar/ce/test/rx/host_linux_sparc/src/test_speed.c
new file mode 100644
index 0000000000..a469d1e557
--- /dev/null
+++ b/cesar/ce/test/rx/host_linux_sparc/src/test_speed.c
@@ -0,0 +1,152 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ./src/test_speed.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+#include "common/std.h"
+#include "sys/time.h"
+#include "stdio.h"
+#include "string.h"
+#include "ce/inc/mpdu_measure_store.h"
+#include "mac/common/tonemap.h"
+#include "ce/test/common/print_utils.h"
+#include "lib/bitstream.h"
+#define RXCE
+#include "ce/inc/cei.h"
+#include "math.h"
+
+
+int
+main (int argc, char **argv)
+{
+ struct timeval tv0, tv1;
+ uint word = 0x76543210;
+ uint i, test;
+ int nibble;
+ bitstream_t stream_writer;
+ gettimeofday (&tv0, NULL);
+ gettimeofday (&tv1, NULL);
+ printf ("getitmeofday duration %d\n",(int) (tv1.tv_usec - tv0.tv_usec));
+ gettimeofday (&tv0, NULL);
+ for (test=0; test<1000; test++)
+ {
+ word = 0;
+ for (i=0; i<8; i++)
+ {
+ nibble = i+1;
+ word = (word >> 4) | (nibble << 28);
+ }
+ }
+ gettimeofday (&tv1, NULL);
+ printf ("nibble to u32 duration test1 %d /1000\n",(int) (tv1.tv_usec - tv0.tv_usec));
+
+ gettimeofday (&tv0, NULL);
+ for (test=0; test<1000; test++)
+ {
+ word = 0;
+ for (i=0; i<8; i++)
+ {
+ nibble = i+1;
+ word = word | (nibble << (i<<2));
+ }
+ }
+ gettimeofday (&tv1, NULL);
+ printf ("nibble to u32 duration test2 %d /1000\n",(int) (tv1.tv_usec - tv0.tv_usec));
+
+ frame_measurement_init ();
+
+ uint noise = 0;
+ gettimeofday (&tv0, NULL);
+ update_threshold (1, 1);
+ for (i=0; i<1536; i++)
+ {
+ noise2mod (noise);
+ }
+ gettimeofday (&tv1, NULL);
+ printf ("noise2mod duration --worst : %d\n",(int) (tv1.tv_usec - tv0.tv_usec));
+
+ noise = 10000;
+ gettimeofday (&tv0, NULL);
+ update_threshold (1, 1);
+ for (i=0; i<1536; i++)
+ {
+ noise2mod (noise);
+ }
+ gettimeofday (&tv1, NULL);
+ printf ("noise2mod duration --best : %d\n",(int) (tv1.tv_usec - tv0.tv_usec));
+
+
+ gettimeofday (&tv0, NULL);
+ blk_t *blk = blk_alloc_desc ();
+ gettimeofday (&tv1, NULL);
+ printf ("first blk allocation duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec));
+ blk_release_desc (blk);
+ gettimeofday (&tv0, NULL);
+ blk = blk_alloc_desc ();
+ gettimeofday (&tv1, NULL);
+ printf ("second blk allocation duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec));
+ blk_release_desc (blk);
+
+ blk_t *blk_last;
+ gettimeofday (&tv0, NULL);
+ blk_t *blk_first = blk_alloc_desc_range (10, &blk_last);
+ gettimeofday (&tv1, NULL);
+ printf ("multi-blk allocation duration (10) : %d\n",(int) (tv1.tv_usec - tv0.tv_usec));
+ blk_release_desc_range (blk_first, blk_last);
+
+
+ phy_chandata_t *last, *browser;
+ phy_chandata_t *first = (phy_chandata_t *) blk_alloc_desc_range (PHY_CHANDATA_NRJ_BLK_NB, (blk_t **) &last);
+ last->last = 1;
+ last->blk.next = NULL;
+ browser = first;
+ noise = 0;
+ int j, k=0;
+ u32 * data = (u32 * ) browser->blk.data;
+ for (i=0; i<PHY_CHANDATA_NRJ_BLK_NB; i++)
+ {
+ for (j=0; j<BLK_SIZE/4; j++)
+ {
+ data[j] = (THR3[1][k%7]) | ((THR3[1][(k+1)%7])<<16);
+ k+=2;
+ }
+ browser = (phy_chandata_t *) (browser->blk.next);
+ if (browser) data = (u32 * ) browser->blk.data;
+ }
+ tonemap_t *worst_tonemap = NULL;
+ gettimeofday (&tv0, NULL);
+ compute_worst_tonemap (&worst_tonemap, first);
+ gettimeofday (&tv1, NULL);
+ printf ("default tonemap computation duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec));
+ ce_print_tonemap (worst_tonemap);
+ blk_release_desc_range ((blk_t *) first, (blk_t *)last);
+
+ u8 buf[1536];
+ for (i=0; i<1536; i++) buf[i] = 0x00;
+ u8 mask[(PHY_CARRIER_NB+7)/8];
+ for (i=0; i<(PHY_CARRIER_NB+7)/8; i++) mask[i] = 0xFF;
+ mask[i-1] = ((1<<(PHY_CARRIER_NB%8))-1);
+ uint entry_nb;
+ gettimeofday (&tv0, NULL);
+ for (test=0; test<100; test++)
+ {
+ bitstream_init (&stream_writer, buf, 1518, BITSTREAM_WRITE);
+ entry_nb = cei_encode_tm (&stream_writer, worst_tonemap->tmdma_desc_head, mask);
+ }
+ gettimeofday (&tv1, NULL);
+ printf ("cei building duration : %d\n",(int) (tv1.tv_usec - tv0.tv_usec));
+
+ tonemap_free (worst_tonemap);
+ return 0;
+}
+
diff --git a/cesar/ce/test/rx/inc/test_rx.h b/cesar/ce/test/rx/inc/test_rx.h
new file mode 100755
index 0000000000..dc8ee6f637
--- /dev/null
+++ b/cesar/ce/test/rx/inc/test_rx.h
@@ -0,0 +1,37 @@
+#ifndef __test_rx_h
+#define __test_rx_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ./test_rx.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+BEGIN_DECLS
+
+typedef void (*pbproc_need_scf_cb_t) (uint tei, uint src);
+pbproc_need_scf_cb_t need_scf_cb;
+
+void
+pbproc_rxce_init (pbproc_need_scf_cb_t need_scf);
+
+void
+pbproc_scf (void);
+
+void
+over_pbproc_init(void);
+
+bool
+pbproc_send_scf (void);
+
+END_DECLS
+
+#endif /* __test_rx_h */
diff --git a/cesar/ce/test/rx/maximus/Makefile b/cesar/ce/test/rx/maximus/Makefile
new file mode 100644
index 0000000000..ba5c632834
--- /dev/null
+++ b/cesar/ce/test/rx/maximus/Makefile
@@ -0,0 +1,21 @@
+all :
+ $(MAKE) -C ../../../../maximus/python --no-print-directory
+
+BASE = ../../../..
+INCLUDES = ce/test/rx/maximus/overide
+INCLUDES += ce/test/rx/maximus
+INCLUDES += ce/test/rx/general/overide
+INCLUDES += ce/test/common
+ECOS = y
+DEFS=-DSAR_UNIT_TEST=1
+
+EXTRA_TARGET_CFLAGS=-DMAXIMUS_TEST -DRXCE_WITH_SAR
+TARGET_PROGRAMS = test_rx
+test_rx_SOURCES = test_rx.c
+test_rx_MODULES=lib host mac/common hal/phy/maximus mac/sar ce ce/test/rx/maximus/overide/mac/pbproc ce/test/rx/general/overide/cp/interf ce/test/common
+
+ce_MODULE_SOURCES = cei_param.c mpdu_measure_store.c rx.c trace.c bitloading.c
+
+
+include $(BASE)/common/make/top.mk
+
diff --git a/cesar/ce/test/rx/maximus/ecos.ecc.sh b/cesar/ce/test/rx/maximus/ecos.ecc.sh
new file mode 100644
index 0000000000..19597e4621
--- /dev/null
+++ b/cesar/ce/test/rx/maximus/ecos.ecc.sh
@@ -0,0 +1,104 @@
+config=${1:-ecos-gen.ecc}
+ecosconfig --config=$config new maximus default
+cat >> $config <<'EOF'
+cdl_option CYGPKG_HAL_MAXIMUS_CFLAGS_ADD {
+ user_value "-I\$(BASE) -I\$(OBJ_DIR)/inc"
+ # value_source user
+ # Default value: "-I\$(REPOSITORY)/../.."
+}
+cdl_option CYGBLD_GLOBAL_CFLAGS {
+ user_value "-Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Woverloaded-virtual -g -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -finit-priority -finline"
+ # value_source user
+ # Default value: "-Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Woverloaded-virtual -g -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -finit-priority"
+}
+cdl_option CYGDBG_KERNEL_DEBUG_GDB_THREAD_SUPPORT {
+ user_value 0
+ inferred_value 0
+}
+cdl_option CYGBLD_ISO_CTYPE_HEADER {
+ inferred_value 1 <cyg/libc/i18n/ctype.inl>
+}
+cdl_option CYGBLD_ISO_ERRNO_CODES_HEADER {
+ inferred_value 1 <cyg/error/codes.h>
+}
+cdl_option CYGBLD_ISO_ERRNO_HEADER {
+ inferred_value 1 <cyg/error/errno.h>
+}
+cdl_option CYGBLD_ISO_STDIO_FILETYPES_HEADER {
+ inferred_value 1 <cyg/libc/stdio/stdio.h>
+}
+cdl_option CYGBLD_ISO_STDIO_STREAMS_HEADER {
+ inferred_value 1 <cyg/libc/stdio/stdio.h>
+}
+cdl_option CYGBLD_ISO_STDIO_FILEOPS_HEADER {
+ inferred_value 1 <cyg/libc/stdio/stdio.h>
+}
+cdl_option CYGBLD_ISO_STDIO_FILEACCESS_HEADER {
+ inferred_value 1 <cyg/libc/stdio/stdio.h>
+}
+cdl_option CYGBLD_ISO_STDIO_FORMATTED_IO_HEADER {
+ inferred_value 1 <cyg/libc/stdio/stdio.h>
+}
+cdl_option CYGBLD_ISO_STDIO_CHAR_IO_HEADER {
+ inferred_value 1 <cyg/libc/stdio/stdio.h>
+}
+cdl_option CYGBLD_ISO_STDIO_DIRECT_IO_HEADER {
+ inferred_value 1 <cyg/libc/stdio/stdio.h>
+}
+cdl_option CYGBLD_ISO_STDIO_FILEPOS_HEADER {
+ inferred_value 1 <cyg/libc/stdio/stdio.h>
+}
+cdl_option CYGBLD_ISO_STDIO_ERROR_HEADER {
+ inferred_value 1 <cyg/libc/stdio/stdio.h>
+}
+cdl_option CYGBLD_ISO_STDLIB_STRCONV_HEADER {
+ inferred_value 1 <cyg/libc/stdlib/atox.inl>
+}
+cdl_option CYGBLD_ISO_STDLIB_ABS_HEADER {
+ inferred_value 1 <cyg/libc/stdlib/abs.inl>
+}
+cdl_option CYGBLD_ISO_STDLIB_DIV_HEADER {
+ inferred_value 1 <cyg/libc/stdlib/div.inl>
+}
+cdl_option CYGBLD_ISO_STRERROR_HEADER {
+ inferred_value 1 <cyg/error/strerror.h>
+}
+cdl_option CYGBLD_ISO_STRTOK_R_HEADER {
+ inferred_value 1 <cyg/libc/string/string.h>
+}
+cdl_option CYGBLD_ISO_STRING_LOCALE_FUNCS_HEADER {
+ inferred_value 1 <cyg/libc/string/string.h>
+}
+cdl_option CYGBLD_ISO_STRING_BSD_FUNCS_HEADER {
+ inferred_value 1 <cyg/libc/string/bsdstring.h>
+}
+cdl_option CYGBLD_ISO_STRING_MEMFUNCS_HEADER {
+ inferred_value 1 <cyg/libc/string/string.h>
+}
+cdl_option CYGBLD_ISO_STRING_STRFUNCS_HEADER {
+ inferred_value 1 <cyg/libc/string/string.h>
+}
+cdl_option CYGBLD_ISO_C_TIME_TYPES_HEADER {
+ inferred_value 1 <cyg/libc/time/time.h>
+}
+cdl_option CYGBLD_ISO_C_CLOCK_FUNCS_HEADER {
+ inferred_value 1 <cyg/libc/time/time.h>
+}
+cdl_option CYGBLD_ISO_SIGNAL_NUMBERS_HEADER {
+ inferred_value 1 <cyg/libc/signals/signal.h>
+}
+cdl_option CYGBLD_ISO_SIGNAL_IMPL_HEADER {
+ inferred_value 1 <cyg/libc/signals/signal.h>
+}
+cdl_option CYGBLD_ISO_SETJMP_HEADER {
+ inferred_value 1 <cyg/libc/setjmp/setjmp.h>
+}
+cdl_option CYGNUM_LIBC_MAIN_DEFAULT_STACK_SIZE {
+ user_value 16384
+ inferred_value 16384
+}
+cdl_option CYGSEM_ERROR_PER_THREAD_ERRNO {
+ user_value 0
+}
+EOF
+ecosconfig --config=$config check
diff --git a/cesar/ce/test/rx/maximus/overide/mac/pbproc/Module b/cesar/ce/test/rx/maximus/overide/mac/pbproc/Module
new file mode 100644
index 0000000000..e9f0167e68
--- /dev/null
+++ b/cesar/ce/test/rx/maximus/overide/mac/pbproc/Module
@@ -0,0 +1 @@
+SOURCES := pbproc.c
diff --git a/cesar/ce/test/rx/maximus/overide/mac/pbproc/pbproc.h b/cesar/ce/test/rx/maximus/overide/mac/pbproc/pbproc.h
new file mode 100644
index 0000000000..57d28489fa
--- /dev/null
+++ b/cesar/ce/test/rx/maximus/overide/mac/pbproc/pbproc.h
@@ -0,0 +1,145 @@
+#ifndef overide_pbproc_h
+#define overide_pbproc_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file overide/pbproc.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "host/station.h"
+#include "hal/phy/maximus/inc/maximus_phy_ctx.h" // 'phy_t'
+#include "mac/common/mfs.h"
+#include "mac/common/pb.h"
+#include "mac/ca/ca.h"
+
+
+struct pbproc_rx_params_t
+{
+ /** Preamble start NTB. */
+ u32 preamble_ntb;
+ /** TEI of the transmitter. */
+ u8 tei;
+ /** Link ID of this MPDU. */
+ u8 lid;
+ /** Short network identifier. */
+ uint snid:4;
+ /** Whether this is a multicast frame. */
+ bool bcast:1;
+ /** Multi-network broadcast flag. */
+ bool multi_net_bcast:1;
+ /** Network encryption key select. */
+ uint eks:4;
+ /** Pending PB. */
+ uint pending_seg_nb:8;
+ /** Bit loading estimate. */
+ uint ble:8;
+ /** Tone map index. */
+ uint tmi_av:5;
+ /** Beacon detect flag. */
+ bool bdf:1;
+ /** Homeplug 1.0.1 detect flag. */
+ bool hp10df:1;
+ /** Homeplug 1.1 detect flag. */
+ bool hp11df:1;
+};
+typedef struct pbproc_rx_params_t pbproc_rx_params_t;
+
+typedef void (*pbproc_rx_cb_t) (void *user, mfs_t *mfs, mfs_t *mfs_mme,
+ const pbproc_rx_params_t *rx_params,
+ pb_t *pb_first, pb_t *pb_last,
+ uint pb_nb, pb_t *chandata_first, uint chandata_nb);
+
+struct pbproc_t
+{
+ pbproc_rx_cb_t rx_cb;
+ mac_config_t *config;
+};
+typedef struct pbproc_t pbproc_t;
+
+struct pbproc_rx_beacon_params_t
+{
+ /** Preamble start NTB. */
+ u32 preamble_ntb;
+ /** Beacon Time Stamp. */
+ u32 bts;
+ /** Beacon Transmission Offset. */
+ u16 bto[4];
+ /** Short network identifier. */
+ u8 snid;
+};
+typedef struct pbproc_rx_beacon_params_t pbproc_rx_beacon_params_t;
+
+typedef void (*pbproc_rx_beacon_cb_t) (void *user, pb_beacon_t *pb,
+ pbproc_rx_beacon_params_t *params);
+
+typedef struct pbproc_tx_beacon_params_t pbproc_tx_beacon_params_t;
+
+BEGIN_DECLS
+
+bool phy_rx_fc_cb (void *user, u32 rx_date, const u32 *fc_av);
+
+bool phy_access_cb (void *user);
+
+bool phy_access_conf_cb (void *user);
+
+bool phy_pbdma_cb (void *user, u32 status_word);
+
+void phy_deferred_cb (void *user);
+
+bool phy_extra_timer_cb (void *user);
+
+int set_tonemask (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data);
+
+int prepare_rx (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data);
+
+pbproc_t *
+pbproc_init (mac_config_t *config, mac_store_t *store);
+
+void
+pbproc_init_cb (pbproc_t *ctx, void *user_data, pbproc_rx_cb_t rx_cb, pbproc_rx_beacon_cb_t rx_beacon_cb);
+
+void
+pbproc_uninit (pbproc_t *ctx);
+
+void
+pbproc_rx_segment_refill (pbproc_t *ctx, pb_t *first, pb_t *last,
+ uint nb);
+
+pb_t *
+pbproc_mfs_extract_tail (mfs_tx_t *mfs);
+
+void
+pbproc_mfs_insert (mfs_tx_t *mfs, pb_t *first, pb_t *last, uint nb, uint cap);
+
+void
+pbproc_mfs_provide (mfs_tx_t *mfs, uint nb);
+
+/** set SCF in pbproc ctx */
+void
+pbproc_scf (void);
+
+void
+pbproc_set_config (mac_config_t *config);
+
+
+bool
+ca_mfs_remove (ca_t *ctx, mfs_tx_t *mfs);
+
+void
+ca_mfs_update (ca_t *ctx, mfs_tx_t *mfs);
+
+void
+pbproc_mfs_beacon_prepare (pbproc_t *ctx, mfs_tx_t *mfs, pb_beacon_t *pb,
+ const pbproc_tx_beacon_params_t *params);
+
+END_DECLS
+
+#endif /* overide_pbproc_h */
diff --git a/cesar/ce/test/rx/maximus/overide/mac/pbproc/src/pbproc.c b/cesar/ce/test/rx/maximus/overide/mac/pbproc/src/pbproc.c
new file mode 100644
index 0000000000..3801433efa
--- /dev/null
+++ b/cesar/ce/test/rx/maximus/overide/mac/pbproc/src/pbproc.c
@@ -0,0 +1,261 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ./overide/src/pbproc.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include <cyg/infra/diag.h>
+#include "common/std.h"
+#include "mac/pbproc/pbproc.h"
+#include "mac/common/tonemask.h"
+#include "hal/phy/maximus/dur/inc/maximus_dur.h"
+#include "ce/test/common/print_utils.h"
+#include "mac/common/ntb.h"
+
+phy_t * phy_ctx;
+int user_data = 123;
+bool short_ppdu = false;
+unsigned short mod = 0;
+unsigned short fecrate = 0;
+unsigned short pb_size = 0;
+unsigned short gil = 0;
+//u8 tonemask[(PHY_CARRIER_NB+7)/8];
+
+static pbproc_t pbproc_global;
+phy_chandata_t *rx_chandata_first;
+phy_pb_t *rx_pb_first;
+phy_pb_t *rx_pb_last;
+uint rx_pb_nb;
+pbproc_rx_params_t rx_params;
+void *sar_ctx;
+uint rx_symbol_nb;
+uint rx_chandata_nb;
+
+bool phy_rx_fc_cb (void *user, u32 rx_date, const u32 *fc_av)
+{
+ // When the FC is received, prepare RX
+ rx_symbol_nb = maximus_dur_symbol_nb ((phy_fecrate_t) fecrate,
+ (phy_pb_size_t) pb_size,
+ maximus_dur_bits_per_symbol ( (phy_mod_t) mod,
+ pbproc_global.config->tonemask_info.tonemask,
+ NULL,
+ maximus_dur_carrier_nb (pbproc_global.config->tonemask_info.tonemask)
+ ),
+ rx_pb_nb
+ );
+
+
+ ce_print ("phy_rx_fc_cb ******* symbol NB = %d\n",rx_symbol_nb);
+ phy_rx_prepare(phy_ctx, short_ppdu, (phy_mod_t)mod,
+ (phy_fecrate_t)fecrate, (phy_pb_size_t)pb_size, (phy_gil_t)gil,
+ 0 /* tonemap_index */, rx_symbol_nb);
+
+ return true;
+}
+
+bool phy_access_cb (void *user)
+{
+ return true;
+}
+
+bool phy_access_conf_cb (void *user)
+{
+ return true;
+}
+
+bool phy_pbdma_cb (void *user, u32 status_word)
+{
+ ce_print ("phy_pbdma_cb ******* PB NB = %d\n",rx_pb_nb);
+ phy_pbdma_status_t status = *(phy_pbdma_status_t *)&status_word;
+ rx_params.tei = 1;
+ rx_params.lid = 0;
+ if (1 == status.end_chandata)
+ {
+ pbproc_global.rx_cb (sar_ctx, NULL, NULL, &rx_params, (pb_t *) rx_pb_first,(pb_t *) rx_pb_last, rx_pb_nb,(pb_t *) rx_chandata_first, rx_chandata_nb);
+ }
+ return true;
+}
+
+bool phy_tx_false_alarm_cb (void *user)
+{
+ return true;
+}
+
+void phy_deferred_cb (void *user)
+{
+ return;
+}
+
+bool phy_extra_timer_cb (void *user)
+{
+ return true;
+}
+
+int prepare_rx (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ unsigned short fc_mode = 0;
+ unsigned short pb_nb = 0;
+ int i = 0;
+ u32 iv[3];
+ u32 nek[4];
+
+ phy_pb_t *pb_last;
+ phy_pb_t *pb_first;
+
+ ce_print("=> prepare_rx\n");
+
+ /* get parameters content */
+ fcall_param_bind_short(*param, *msg, "fc_mode", &fc_mode);
+ fcall_param_bind(*param, *msg, "short_ppdu", sizeof(bool), &short_ppdu);
+ fcall_param_bind_short(*param, *msg, "mod", &mod);
+ fcall_param_bind_short(*param, *msg, "fecrate", &fecrate);
+ fcall_param_bind_short(*param, *msg, "pb_size", &pb_size);
+ fcall_param_bind_short(*param, *msg, "gil", &gil);
+ fcall_param_bind_short(*param, *msg, "pb_nb", &pb_nb);
+
+ dbg_assert (pb_nb);
+ pb_first = (phy_pb_t *) blk_alloc_desc_range (pb_nb, (blk_t **) &pb_last);
+ pb_last->blk.next = NULL;
+
+ // Activate RX
+ phy_rx_activate(phy_ctx, true /* now */, my_station.current_tick_tck, true /* pre_detection */);
+
+ // Set RX parameters
+ phy_rx_param(phy_ctx, (phy_fc_mode_t)fc_mode);
+
+ for (i=0; i<3; i++)
+ {
+ iv[i] = i;
+ }
+ for (i=0; i<4; i++)
+ {
+ nek[i] = i;
+ }
+ phy_pbdma_start(phy_ctx, true /* bypass_aes */, iv,
+ nek, (uint)pb_nb /* nb_total */, (uint)pb_nb /* nb_ready */,
+ (uint)pb_nb /* nb_pb_it */, pb_first);
+
+ phy_chandata_t *time_noise = (phy_chandata_t *) blk_alloc_desc();
+ time_noise->blk.next = NULL;
+ time_noise->last=0;
+ time_noise->type = PHY_CHANDATA_TYPE_NRJ_SYMBOL;
+ time_noise->size = (pb_nb * sizeof(phy_noise_energy_t)+ 3)/4;
+
+ phy_chandata_t *last_chan;
+ phy_chandata_t *freq_noise = (phy_chandata_t *) blk_alloc_desc_range(mpdu_measure_chandata_blk_nb[PHY_CHANDATA_TYPE_NRJ], (blk_t **) &last_chan);
+ last_chan->blk.next = NULL;
+ last_chan->last = 1;
+ last_chan->type = PHY_CHANDATA_TYPE_NRJ;
+ last_chan->size = ((PHY_CARRIER_NB*sizeof(phy_noise_energy_t) % PHY_NOISE_NB_PER_BLK) + 3)/4;
+ phy_chandata_t *browser = freq_noise;
+ uint address=0;
+ while (browser != last_chan)
+ {
+ browser->last = 0;
+ browser->type = PHY_CHANDATA_TYPE_NRJ;
+ browser->size = 128;
+ browser->address = address;
+ browser = (phy_chandata_t *)browser->blk.next;
+ address+= 128;
+ }
+ last_chan->address = address;
+
+
+
+ /** registering reception status to be able to run pbproc_rx_cb that wake
+ * up the sar */
+ rx_pb_first = pb_first;
+ rx_pb_last = pb_last;
+ //rx_chandata_first = freq_noise;
+ //last_chan->blk.next = time_noise;
+ rx_chandata_first = time_noise;
+ time_noise->blk.next = (blk_t *) freq_noise;
+ rx_pb_nb = pb_nb;
+
+ ce_print_chandata (time_noise);
+ rx_chandata_nb = 6;
+
+ phy_pbdma_start_chandata(phy_ctx, time_noise);
+ //phy_pbdma_start_chandata(ctx, freq_noise);
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+pbproc_t *
+pbproc_init (mac_config_t *config, mac_store_t *store)
+{
+ pbproc_t *pbproc_ctx = &pbproc_global;
+ pbproc_ctx->config = config;
+ // Initialize the HAL PHY
+ phy_ctx = phy_init ((void *)&user_data, &phy_rx_fc_cb, &phy_access_cb, &phy_access_conf_cb, &phy_pbdma_cb, &phy_tx_false_alarm_cb, &phy_deferred_cb);
+ mac_ntb_init (phy_ctx, config);
+
+ // Enable assertions on warnings
+ phy_ctx->warning_assert = true;
+
+ // Set TONEMASK
+ phy_set_tonemask(phy_ctx, config->tonemask_info.tonemask, PHY_CARRIER_NB);
+ return(pbproc_ctx);
+}
+
+void
+pbproc_init_cb (pbproc_t *ctx, void *user_data, pbproc_rx_cb_t rx_cb, pbproc_rx_beacon_cb_t rx_beacon_cb)
+{
+ dbg_assert (ctx);
+ dbg_assert (rx_cb);
+ dbg_assert (rx_beacon_cb);
+ //ctx->user_data = user_data;
+ ctx->rx_cb = rx_cb;
+ //ctx->rx_beacon_cb = rx_beacon_cb;
+}
+
+void
+pbproc_rx_segment_refill (pbproc_t *ctx, pb_t *f, pb_t *l, uint nb)
+{
+ return;
+}
+
+pb_t *
+pbproc_mfs_extract_tail (mfs_tx_t *mfs) {return NULL;}
+
+void
+pbproc_mfs_insert (mfs_tx_t *mfs, pb_t *first, pb_t *last, uint nb, uint cap) {return;}
+
+void
+pbproc_mfs_provide (mfs_tx_t *mfs, uint nb) {return;}
+
+void
+pbproc_scf (void)
+{
+ return;
+}
+
+bool
+ca_mfs_remove (ca_t *ctx, mfs_tx_t *mfs)
+{
+ return true;
+}
+
+void
+ca_mfs_update (ca_t *ctx, mfs_tx_t *mfs)
+{
+
+}
+
+void
+pbproc_mfs_beacon_prepare (pbproc_t *ctx, mfs_tx_t *mfs, pb_beacon_t *pb,
+ const pbproc_tx_beacon_params_t *params)
+{
+ return;
+}
diff --git a/cesar/ce/test/rx/maximus/send_noise.py b/cesar/ce/test/rx/maximus/send_noise.py
new file mode 100644
index 0000000000..7c8666ce56
--- /dev/null
+++ b/cesar/ce/test/rx/maximus/send_noise.py
@@ -0,0 +1,102 @@
+#!/usr/bin/python
+
+#print __name__
+
+import sys
+
+maximus_path = '../../../../maximus'
+pos_maximus_path = -1
+for i in range(len(sys.argv)):
+ if sys.argv[i] == '--maximus_path':
+ pos_maximus_path = i
+ maximus_path = sys.argv[i+1]
+if pos_maximus_path > 0:
+ sys.argv = sys.argv[0:pos_maximus_path] + sys.argv[pos_maximus_path+2:len(sys.argv)]
+sys.path.append (maximus_path+'/python')
+sys.path.append (maximus_path+'/python/obj')
+
+from interface import *
+from maximus.macframe import *
+from maximus.macframe.msdu import MAX_SIZE_OF_MSDU
+from struct import *
+
+# Create and initializes Maximus
+maximus = Maximus()
+maximus.init(sys.argv)
+
+# Create a station
+sta = maximus.create_sta ()
+sta.debug()
+maximus.disturb_channel()
+
+pb_nb = 200
+frame_nb = 22
+
+ce_init_fcall = maximus.create_fcall ('ce_init')
+ce_init_fcall.send(sta)
+sar_start_fcall = maximus.create_fcall ('sar_start')
+sar_start_fcall.send(sta)
+
+ce_check_stock_fcall = maximus.create_fcall ('ce_check_stock')
+ce_check_stock_fcall.add_param_ushort ('frame_nb', frame_nb);
+ce_check_stock_fcall.add_param_ushort ('pb_nb', pb_nb);
+ce_start_fcall = maximus.create_fcall ('ce_start')
+ce_check_computation_fcall = maximus.create_fcall ('ce_check_computation')
+
+
+def prepare_rx_param_init():
+ prepare_rx_fcall = maximus.create_fcall('prepare_rx')
+ fc_mode = 2 # PHY_FC_MODE_AV_1
+ prepare_rx_fcall.add_param_ushort("fc_mode", fc_mode)
+ prepare_rx_fcall.add_param_bool("short_ppdu", False)
+ mod = 0 # PHY_MOD_ROBO
+ prepare_rx_fcall.add_param_ushort("mod", mod)
+ fecrate = 0 # PHY_FEC_RATE_1_2
+ prepare_rx_fcall.add_param_ushort("fecrate", fecrate)
+ pb_size = 1
+ prepare_rx_fcall.add_param_ushort("pb_size", pb_size)
+ gil = 1 # PHY_GIL_567
+ prepare_rx_fcall.add_param_ushort("gil", gil)
+ #pb_nb = 1
+ prepare_rx_fcall.add_param_ushort("pb_nb", pb_nb)
+ #prepare_rx_fcall.send(sta)
+ return prepare_rx_fcall
+
+test_result_fcall = maximus.create_fcall('test_result_get')
+
+queue = MACFrameQueue()
+queue.set_fc_av(pack('IIII', 0, 456, 789, 10))
+payload = 512*'X'+(pb_nb-1)*512*'Y'
+macframe_nb = (len(payload) + (MAX_SIZE_OF_MSDU-1)) / MAX_SIZE_OF_MSDU
+payload = payload[macframe_nb*6:]
+
+def create_msdu():
+ msdu = MACFrame()
+ msdu.set_macframeheader ('MF')
+ msdu.set_icv ('CRC0')
+ return msdu
+
+def send_queue():
+ for i in range (macframe_nb):
+ macFrame = create_msdu()
+ macFrame.set_msdu(payload[i*MAX_SIZE_OF_MSDU:min((i+1)*MAX_SIZE_OF_MSDU, len(payload))])
+ queue.add(macFrame)
+ queue.send(maximus)
+
+for i in range(frame_nb) :
+ prepare_rx_param_init().send(sta)
+ send_queue()
+
+ce_check_stock_fcall.send(sta)
+ce_start_fcall.send(sta)
+ce_check_computation_fcall.send(sta)
+
+maximus.wait(10000000)
+
+res = test_result_fcall.send(sta)
+result = res.bind_param_ushort ("test_result")
+#print "test has returned ", hex(result)
+sta.remove()
+
+sys.exit(result)
+
diff --git a/cesar/ce/test/rx/maximus/src/test_rx.c b/cesar/ce/test/rx/maximus/src/test_rx.c
new file mode 100644
index 0000000000..06ab584c51
--- /dev/null
+++ b/cesar/ce/test/rx/maximus/src/test_rx.c
@@ -0,0 +1,187 @@
+#include <cyg/infra/diag.h>
+#include "common/std.h"
+#include "host/station.h"
+#include "mac/pbproc/pbproc.h"
+#include "mac/sar/sar.h"
+#include "cyg/kernel/kapi.h"
+#include "cyg/hal/hal_arch.h"
+#include "ce/inc/rx.h"
+#include "ce/test/common/print_utils.h"
+#define TXCE
+#include "lib/test.h"
+#include "ce/test/common/tonemap_utils.h"
+#include "lib/trace.h"
+
+extern station_ctx_t my_station;
+test_t test;
+
+#define SAR_PRIORITY 14
+cyg_thread sar_thread;
+cyg_handle_t sar_handle;
+unsigned char sar_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+#define RXCE_PRIORITY 15
+cyg_thread rxce_thread;
+cyg_handle_t rxce_handle;
+unsigned char rxce_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+mac_store_t *mac_store_ctx;
+mac_config_t mac_config_ctx;
+sar_t *sar_ctx;
+sta_t *sta;
+ca_t *ca;
+rxce_t *rxce_ctx;
+
+bool
+local_sar_mpdu_measurement_cb (void *user, pbproc_rx_params_t *rx_params,
+ uint pb_nb, blk_t **f, blk_t **l, pb_t *noise, uint chandata_nb)
+{
+
+ uint i,j;
+ diag_printf ("pb_nb = %d\n",pb_nb);
+ diag_printf ("noise @Ox%x\n",(unsigned int) noise);
+ phy_chandata_t *chandata = (phy_chandata_t *) noise;
+ phy_noise_energy_t *data_noise;
+ for (i=0;
+ i < mpdu_measure_chandata_blk_nb[PHY_CHANDATA_TYPE_NRJ] +
+ mpdu_measure_chandata_blk_nb[PHY_CHANDATA_TYPE_NRJ_SYMBOL];
+ i++)
+ {
+ diag_printf ("chandata%d @0x%x : type=%d size=%d last=%d\n", i,
+ (uint) chandata,
+ chandata->type,
+ chandata->size,
+ chandata->last);
+ data_noise = (phy_noise_energy_t *) chandata->blk.data;
+ for (j=0; j<PHY_NOISE_NB_PER_BLK; j++)
+ {
+ diag_printf ("0x%x ",*data_noise);
+ data_noise++;
+ }
+ diag_printf ("\n");
+
+ chandata = (phy_chandata_t *) chandata->blk.next;
+ }
+
+ return true;
+}
+
+void
+sar_start (void)
+{
+ mac_store_sta_add (mac_store_ctx, 1);
+ sta = mac_store_sta_get (mac_store_ctx, 1);
+ cyg_thread_create (SAR_PRIORITY, &sar_process, (cyg_addrword_t)sar_ctx, "sar_test",
+ sar_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &sar_handle, &sar_thread);
+ cyg_thread_resume (sar_handle);
+}
+
+void
+sar_end (void)
+{
+ blk_release (sta); // release reference to sta added by mac_store_mfs_get in START.
+ dbg_check (mac_store_sta_remove (mac_store_ctx, 1));
+ blk_release(ca);
+ sar_uninit (sar_ctx);
+}
+
+void
+ce_init (void)
+{
+ pbproc_t *pbproc_ctx = pbproc_init (&mac_config_ctx, mac_store_ctx);
+ ca = blk_alloc();
+ sar_ctx = sar_init (mac_store_ctx, pbproc_ctx, ca);
+ rxce_ctx = rxce_init (sar_ctx, mac_store_ctx, &mac_config_ctx);
+ cyg_thread_create (RXCE_PRIORITY, &rxce_process, (cyg_addrword_t) rxce_ctx, "rxce",
+ rxce_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &rxce_handle, &rxce_thread);
+}
+
+void
+ce_check_stock (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ unsigned short pb_nb;
+ unsigned short fm_nb;
+ uint pb_ix, fm_ix;
+
+ fcall_param_bind_short(*param, *msg, "pb_nb", &pb_nb);
+ fcall_param_bind_short(*param, *msg, "frame_nb", &fm_nb);
+
+ test_begin (test, "check pb measurement")
+ {
+ mpdu_measure_store_t *measure_store_ctx = rxce_ctx->mpdu_measure_store_ctx;
+ dbg_assert (measure_store_ctx->measure_nb == fm_nb);
+ for (fm_ix=0; fm_ix<fm_nb; fm_ix++)
+ {
+ pb_measure_blk_t *ber_blk = measure_store_ctx->store[fm_ix].pb_head;
+ for (pb_ix=0; pb_ix<pb_nb; pb_ix++)
+ {
+ if (pb_ix == MPDU_MEASURE_PB_NB_PER_BLK)
+ {
+ ber_blk = ber_blk->next;
+ }
+ pb_measurement_t m = *(ber_blk->data+(pb_ix%MPDU_MEASURE_PB_NB_PER_BLK));
+ test_fail_if (m.halfit != 0x04);
+ test_fail_if ( m.ber != (1<< (pb_ix%16)) );
+ test_fail_if ( m.crc_error != (pb_ix%2) );
+ }
+ }
+ } test_end;
+ fcall_param_reset(*param);
+ return;
+}
+
+void
+ce_check_computation (void)
+{
+ sta_t *sta = mac_store_sta_get (mac_store_ctx, 1);
+ ce_print_tonemaps (sta->rx_tonemaps);
+ ce_print_tonemaps (sta->tx_tonemaps);
+
+ compare_tonemaps (test, sta->rx_tonemaps, sta->tx_tonemaps,
+ (u8 *)(&(mac_config_ctx.tonemask_info.tonemask)));
+ test_result (test);
+ return;
+}
+
+void
+ce_start (void)
+{
+ cyg_thread_resume (rxce_handle);
+}
+
+int
+test_result_get (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ unsigned short result;
+ result = (test_nb_failed (test));
+ fcall_param_reset(*param);
+ fcall_param_add_short(*param, *msg, "test_result", &result);
+ return (result);
+}
+
+int main(void)
+{
+ trace_init();
+ test_init (test, 0, NULL);
+ test_case_begin (test, "RXCE-maximus");
+ station_log_set_level(&my_station, STATION_LOG_ERROR);
+ station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
+ my_station.pipe_log_fd = 1;
+ diag_write_string(" hello by eCos in maximus test\n");
+ fcall_register(my_station.fcall, "sar_start", (void*)&sar_start, NULL);
+ fcall_register(my_station.fcall, "ce_init", (void*)&ce_init, NULL);
+ fcall_register(my_station.fcall, "ce_check_stock", (void*)&ce_check_stock, NULL);
+ fcall_register(my_station.fcall, "ce_start", (void*)&ce_start, NULL);
+ fcall_register(my_station.fcall, "ce_check_computation", (void*)&ce_check_computation, NULL);
+ fcall_register(my_station.fcall, "prepare_rx", (void*)&prepare_rx, NULL);
+ fcall_register(my_station.fcall, "test_result_get", (void*)&test_result_get, NULL);
+
+ mac_config_init (&mac_config_ctx);
+
+ mac_store_ctx = mac_store_init ();
+
+ return 0;
+}
+
diff --git a/cesar/ce/test/rx/tonemap_refresh/Makefile b/cesar/ce/test/rx/tonemap_refresh/Makefile
new file mode 100644
index 0000000000..e0fe57d3b4
--- /dev/null
+++ b/cesar/ce/test/rx/tonemap_refresh/Makefile
@@ -0,0 +1,18 @@
+BASE = ../../../..
+
+INCLUDES = ce/test/rx
+INCLUDES += ce/test/rx/tonemap_refresh
+INCLUDES += ce/test/rx/general/overide
+INCLUDES += ce/test/common
+
+ECOS = y
+
+EXTRA_TARGET_CFLAGS=-DEXPIRATION_TEST
+TARGET_PROGRAMS=test_tonemaps_refresh_target_ecos_synth
+test_tonemaps_refresh_target_ecos_synth_SOURCES = test_tonemaps_refresh.c
+test_tonemaps_refresh_target_ecos_synth_MODULES = lib mac/common ce ce/test/common ce/test/rx/general/overide/cp/interf
+
+
+
+include $(BASE)/common/make/top.mk
+
diff --git a/cesar/ce/test/rx/tonemap_refresh/ecos.ecc.sh b/cesar/ce/test/rx/tonemap_refresh/ecos.ecc.sh
new file mode 100755
index 0000000000..2443d0e40f
--- /dev/null
+++ b/cesar/ce/test/rx/tonemap_refresh/ecos.ecc.sh
@@ -0,0 +1,5 @@
+config=${1:-ecos-gen.ecc}
+ecosconfig --config=$config new linux default
+cat >> $config <<'EOF'
+EOF
+ecosconfig --config=$config check
diff --git a/cesar/ce/test/rx/tonemap_refresh/src/test_tonemaps_refresh.c b/cesar/ce/test/rx/tonemap_refresh/src/test_tonemaps_refresh.c
new file mode 100644
index 0000000000..d6a7e2d296
--- /dev/null
+++ b/cesar/ce/test/rx/tonemap_refresh/src/test_tonemaps_refresh.c
@@ -0,0 +1,117 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ./src/test_tonemaps_expiration.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include "lib/rnd.h"
+#include "lib/test.h"
+#include "ce/inc/rx.h"
+#include "ce/test/common/print_utils.h"
+#include "ce/inc/ecos_time.h"
+
+#define TEST_REFRESH_NUMBER 5000
+#define CPU_LOAD_PRIORITY 10
+cyg_thread cpu_load_thread;
+cyg_handle_t cpu_load_handle;
+unsigned char cpu_load_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+#define RXCE_PRIORITY 14
+cyg_thread rxce_thread;
+cyg_handle_t rxce_handle;
+unsigned char rxce_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+test_t test;
+mac_store_t *mac_store_ctx;
+mac_config_t mac_config;
+rxce_t *rxce_ctx;
+lib_rnd_t rnd;
+bool stop = false;
+int refresh_number = 0;
+cyg_tick_count_t date[255];
+
+// Just for commpilation. Not used.
+void
+pbproc_scf (void)
+{;}
+
+void
+test_expiration_cb (int dtei)
+{
+ cyg_tick_count_t current = cyg_current_time ();
+ sta_t *lsta = mac_store_sta_get (mac_store_ctx, dtei);
+ test_begin (test, "Check date of cei creation\n")
+ {
+ test_fail_if (current > date[dtei] + S_TO_RTC (TONEMAPS_LIFE_DURATION_S));
+ } test_end;
+ blk_release (lsta);
+ date[dtei] = current;
+ if (refresh_number > TEST_REFRESH_NUMBER ) stop = true;
+ else refresh_number++;
+ if (refresh_number % 100 == 0) test_result(test);
+}
+
+void
+cpu_load_process (cyg_addrword_t data)
+{
+ int i;
+ int r;
+ while (!stop)
+ {
+ double z;
+ r = lib_rnd_uniform (&rnd, 2000000);
+ for (i=0; i< r; i++)
+ {
+ z = (i*1.0)/r;
+ }
+ cyg_thread_delay(1);
+ }
+ test_result (test);
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+}
+
+void
+cyg_user_start (int argc, char **argv)
+{
+ int i;
+ test_init (test, argc, argv);
+ test_case_begin (test, "Expiration");
+ trace_init();
+ lib_rnd_init (&rnd, 123);
+ mac_store_ctx = mac_store_init ();
+ rxce_ctx = rxce_init (NULL, mac_store_ctx, &mac_config);
+ rxce_init_test_cb (&test_expiration_cb);
+ for (i=1; i<= 250; i++)
+ {
+ int b = mac_store_get_free_tei (mac_store_ctx);
+ if (b != -1 )
+ {
+ mac_store_sta_add (mac_store_ctx, b);
+ sta_t *lsta = mac_store_sta_get (mac_store_ctx, b);
+ tonemaps_t *tms = tonemaps_alloc();
+ lsta->rx_tonemaps = tms;
+ int random = lib_rnd_uniform (&rnd, 5000);
+ date[i] = cyg_current_time() + random;
+ tms->expiration_rtc_date = date[i] + S_TO_RTC (RXCE_TONEMAPS_REFRESH_PERIOD_S);
+ blk_release (lsta);
+ }
+ }
+ cyg_thread_create (RXCE_PRIORITY, &rxce_process,(cyg_addrword_t) rxce_ctx, "rxce",
+ rxce_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &rxce_handle, &rxce_thread);
+ cyg_thread_resume (rxce_handle);
+
+ cyg_thread_create (CPU_LOAD_PRIORITY, &cpu_load_process,(cyg_addrword_t) 0, "cpu_load",
+ cpu_load_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &cpu_load_handle, &cpu_load_thread);
+ cyg_thread_resume (cpu_load_handle);
+}
diff --git a/cesar/ce/test/tx/Makefile b/cesar/ce/test/tx/Makefile
new file mode 100644
index 0000000000..b0e6e8d3fa
--- /dev/null
+++ b/cesar/ce/test/tx/Makefile
@@ -0,0 +1,8 @@
+all :
+ $(MAKE) -f host-Makefile --no-print-directory
+ $(MAKE) -f target-Makefile --no-print-directory
+
+clean :
+ $(MAKE) -f host-Makefile clean
+ $(MAKE) -f target-Makefile clean
+
diff --git a/cesar/ce/test/tx/host-Makefile b/cesar/ce/test/tx/host-Makefile
new file mode 100755
index 0000000000..ba9d305904
--- /dev/null
+++ b/cesar/ce/test/tx/host-Makefile
@@ -0,0 +1,17 @@
+BASE = ../../..
+
+INCLUDES = ce/test/tx
+INCLUDES+= ce/test/common
+INCLUDES+= ce/test/common/ecos_overide
+INCLUDES += ce/test/rx/general/overide
+
+HOST_PROGRAMS = test_tx
+test_tx_SOURCES = test_tx.c
+test_tx_MODULES = lib mac/common ce ce/test/common ce/test/common/ecos_overide/cyg/kernel ce/test/rx/general/overide/cp/interf
+
+ce_MODULE_SOURCES = tx.c rxce_stats.c
+ce_test_common_MODULE_SOURCES = print_utils.c
+
+VARIANT = host
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/ce/test/tx/src/test_expiration.c b/cesar/ce/test/tx/src/test_expiration.c
new file mode 100644
index 0000000000..e26a473608
--- /dev/null
+++ b/cesar/ce/test/tx/src/test_expiration.c
@@ -0,0 +1,121 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ./src/test_expiration.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+#include "cyg/kernel/kapi.h"
+#include "ce/inc/tx.h"
+#include "lib/test.h"
+#include "cp/interf/interf.h"
+#include "cp/cp.h"
+#include "mac/common/tonemap.h"
+#include "ce/inc/ecos_time.h"
+
+#define CP_PRIORITY 20
+cyg_thread cp_thread;
+cyg_handle_t cp_handle;
+unsigned char cp_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+#define TEST_PRIORITY 10
+cyg_thread test_thread;
+cyg_handle_t test_handle;
+unsigned char test_stack[CYGNUM_HAL_STACK_SIZE_TYPICAL];
+
+test_t test;
+mac_store_t *mac_store_ctx;
+cp_t *cp_ctx;
+
+void
+test_process (cyg_addrword_t data)
+{
+ int n=0;
+ test_begin (test, "txce expiration")
+ {
+ int i, tmi;
+ bool has_tonemap = false;
+ // Let CP running and simulate CEI reception. Check during 1mn if
+ // tonemap that should have been expirated is still in mac_store.
+ while (n++<S_TO_RTC (TONEMAPS_LIFE_DURATION_S*2))
+ {
+ //printf ("%d\n",n);
+ cyg_thread_delay(1);
+ for (i=MAC_TEI_STA_MIN; i<MAC_TEI_STA_MAX; i++)
+ {
+ sta_t *lsta = mac_store_sta_get (mac_store_ctx, i);
+ if (lsta)
+ {
+ has_tonemap = false;
+ for (tmi=0; tmi<TONEMAP_INDEX_NB; tmi++)
+ {
+ if (lsta->tx_tonemaps->tm[tmi] != NULL)
+ {
+ has_tonemap = true;
+ break;
+ }
+ }
+ test_fail_if ( has_tonemap && (cyg_current_time() > lsta->tx_tonemaps->expiration_rtc_date));
+ blk_release (lsta);
+ }
+ }
+ }
+ // Stop the simulation of received CEI.
+ cp_stop (cp_ctx);
+ // Wait the life of tonemaps duration.
+ // After this, all the tonemaps must have been expirated.
+ cyg_thread_delay (S_TO_RTC(TONEMAPS_LIFE_DURATION_S));
+ has_tonemap = false;
+ for (i=MAC_TEI_STA_MIN; i<MAC_TEI_STA_MAX; i++)
+ {
+ sta_t *lsta = mac_store_sta_get (mac_store_ctx, i);
+ if (lsta)
+ {
+ for (tmi=0; tmi<TONEMAP_INDEX_NB; tmi++)
+ {
+ if (lsta->tx_tonemaps->tm[tmi] != NULL)
+ {
+ has_tonemap = true;
+ break;
+ }
+ }
+ test_fail_if ( has_tonemap );
+ blk_release (lsta);
+ }
+ }
+
+ } test_end;
+ test_result (test);
+ HAL_PLATFORM_EXIT (test_nb_failed (test) == 0 ? 0 : 1);
+}
+
+
+void
+cyg_user_start (int argc, char **argv)
+{
+ test_init (test, argc, argv);
+ mac_config_t mac_config;
+ mac_config_init (&mac_config);
+ mac_store_ctx = mac_store_init();
+ cp_ctx = cp_init (mac_store_ctx, &mac_config);
+ cyg_thread_create (CP_PRIORITY, &cp_process,(cyg_addrword_t) cp_ctx, "cp",
+ cp_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &cp_handle, &cp_thread);
+
+ cyg_thread_create (TEST_PRIORITY, &test_process,(cyg_addrword_t) 0, "test",
+ test_stack, CYGNUM_HAL_STACK_SIZE_TYPICAL,
+ &test_handle, &test_thread);
+
+
+
+ cyg_thread_resume (test_handle);
+ cyg_thread_resume (cp_handle);
+}
diff --git a/cesar/ce/test/tx/src/test_tx.c b/cesar/ce/test/tx/src/test_tx.c
new file mode 100755
index 0000000000..ab47d20c0d
--- /dev/null
+++ b/cesar/ce/test/tx/src/test_tx.c
@@ -0,0 +1,150 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ./src/test_tx.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+#include "common/std.h"
+
+#include <stdio.h>
+#include "ce/test/common/print_utils.h"
+
+#include "mac/common/store.h"
+#include "ce/inc/tx.h"
+#include "mac/common/tonemask.h"
+#include "ce/inc/cei.h"
+#include "mac/common/timings.h"
+#include "lib/test.h"
+
+#define MME_BUFFER_SIZE 1536
+
+#define STEI 1
+
+
+int
+main (int argc, char **argv)
+{
+ int i;
+ test_t test;
+ mac_config_t mac_config;
+ test_init (test, argc, argv);
+ mac_config_init (&mac_config);
+ //for (i=0; i< PHY_CARRIER_NB/8; i++) mac_config.tonemask_info.tonemask[i] = 0xFF;
+ u16 MAX_FL_FL = MAC_MAX_FL_MAX_FL;
+ u8 RIFS1 = MAC_RIFS_AV_ONE_SYM_FL;
+ u8 RIFS2 = MAC_RIFS_AV_TWO_SYM_FL;
+ u8 RIFS3 = MAC_RIFS_AV_G2_SYM_FL;
+ u8 RESPT = 0;
+ u8 MAXTM = TONEMAP_INDEX_NB;
+ u8 DEFAULT_TMI = 0x04;
+ u8 SCL = 0x0;
+ u8 TM_VALID_NB = 0x1;
+ u8 TMI_VALID0 = DEFAULT_TMI;
+ u8 NINT = 0;
+ u8 NEW_TMI = DEFAULT_TMI;
+ u8 CPF = 1;
+ u8 FEC = 0;
+ u8 GI = 0;
+ u8 CBDENC = 0;
+ u8 rx_mm_entry[MME_BUFFER_SIZE];
+ bitstream_t stream;
+ bitstream_t *writer = &stream;
+ bitstream_init (writer, rx_mm_entry, MME_BUFFER_SIZE, BITSTREAM_WRITE);
+ bitstream_access (writer, &MAX_FL_FL, 16);
+ bitstream_access (writer, &RIFS1, 8);
+ bitstream_access (writer, &RIFS2, 8);
+ bitstream_access (writer, &RIFS3, 8);
+ bitstream_access (writer, &RESPT, 8);
+ bitstream_access (writer, &MAXTM, 8);
+ bitstream_access (writer, &DEFAULT_TMI, 8);
+ bitstream_access (writer, &SCL, 8);
+ bitstream_access (writer, &SCL, 8);
+ bitstream_access (writer, &TM_VALID_NB, 8);
+ bitstream_access (writer, &TMI_VALID0, 8);
+ bitstream_access (writer, &NINT, 8);
+ bitstream_access (writer, &NEW_TMI, 8);
+ bitstream_access (writer, &CPF, 8);
+ bitstream_access (writer, &FEC, 8);
+ bitstream_access (writer, &GI, 8);
+ bitstream_access (writer, &CBDENC, 8);
+
+ uint mask_len = mac_config.tonemask_info.carrier_nb;
+ bitstream_access (writer, &mask_len, 16);
+
+ u8 tonemap[PHY_CARRIER_NB];
+ for (i=0; i<PHY_CARRIER_NB; i++) tonemap[i] = (i%7)+1;
+ for (i = 0; i<PHY_CARRIER_NB; i++)
+ {
+ bitstream_access (writer, &tonemap[i], 4);
+ }
+ bitstream_finalise(writer);
+
+ mac_store_t *mac_store_ctx = mac_store_init();
+ mac_store_sta_add (mac_store_ctx, STEI);
+ sta_t *sta = mac_store_sta_get (mac_store_ctx, STEI);
+ txce_t *txce_ctx = txce_init (mac_store_ctx, &mac_config, NULL);
+ txce (txce_ctx, STEI, CM_CHAN_EST_IND, rx_mm_entry);
+ ce_print_tonemaps (sta->tx_tonemaps);
+ test_case_begin (test, "CE-create tonemap from cei received");
+ test_begin (test, "No encodage")
+ {
+ test_fail_if (sta->tx_tonemaps->max_fl_av != MAX_FL_FL);
+ test_fail_if (sta->tx_tonemaps->rifs_av_one_sym_tck != MAC_RIFS_AV_ONE_SYM_TCK);
+ test_fail_if (sta->tx_tonemaps->rifs_av_two_sym_tck != MAC_RIFS_AV_TWO_SYM_TCK);
+ test_fail_if (sta->tx_tonemaps->rifs_av_g2_sym_tck != MAC_RIFS_AV_G2_SYM_TCK);
+ test_fail_if (sta->tx_tonemaps->max_tm != MAXTM);
+ test_fail_if (sta->tx_tonemaps->default_tmi != DEFAULT_TMI);
+ test_fail_if (sta->tx_tonemaps->scl_cp != SCL);
+ test_fail_if (sta->tx_tonemaps->scl_cfp != SCL);
+ int nint = tonemap_valid_nb (sta->tx_tonemaps);
+ test_fail_if (nint != TM_VALID_NB);
+ u8 *mask = (mac_config.tonemask_info.tonemask);
+ u8 tmp[PHY_CARRIER_NB];
+ u8 *tm_data = sta->tx_tonemaps->tm[DEFAULT_TMI-4]->tmdma_desc_head->data;
+ for (i=0; i<PHY_CARRIER_NB; i++)
+ {
+ if (i==1024) tm_data = sta->tx_tonemaps->tm[DEFAULT_TMI-4]->tmdma_desc_head->next->data;
+ uint n1 = (uint) *tm_data++;
+ uint n2 = n1>>4;
+ n1 = n1&0xF;
+ tmp[i++]= n1;
+ tmp[i] = n2;
+ }
+ uint z=0;
+ for (i=0; i<PHY_CARRIER_NB; i++)
+ {
+ //ce_print ("c%d : tone=%d\n",i, tmp[i]);
+ if ((mask[i/8] & (1<<(i%8))) == 0)
+ {
+ //ce_print ("c%d : masked\n",i);
+ test_fail_if (tmp[i] != 0 && tmp[i]<0x08);
+ }
+ else
+ {
+ //ce_print ("c%d : tmp[%d]=%d; previous=%d\n",i,i,tmp[i],z);
+ test_fail_if (tmp[i]!= (z+1));
+ z = tmp[i];
+ if (z==7) z=0;
+ }
+ }
+ test_fail_if (sta->tx_tonemaps->intervals->intervals_nb != NINT);
+ } test_end;
+ blk_release (sta);
+ dbg_check (mac_store_sta_remove (mac_store_ctx, STEI));
+ test_begin (test, "check alloc/free")
+ {
+ test_fail_unless (blk_check_memory());
+ } test_end;
+ test_result (test);
+ return (test_nb_failed (test) == 0 ? 0 : 1);
+}
+
diff --git a/cesar/ce/test/tx/target-Makefile b/cesar/ce/test/tx/target-Makefile
new file mode 100644
index 0000000000..783d886c70
--- /dev/null
+++ b/cesar/ce/test/tx/target-Makefile
@@ -0,0 +1,22 @@
+BASE = ../../..
+
+INCLUDES = ce/test/tx/
+INCLUDES += ce/test/common
+INCLUDES += ce/test/rx/general/overide
+
+ECOS = y
+
+TARGET_PROGRAMS=test_alarm_target_ecos_synth
+test_alarm_target_ecos_synth_SOURCES = essai_alarm.c
+
+TARGET_PROGRAMS=test_expiration_target_ecos_synth
+test_expiration_target_ecos_synth_SOURCES = test_expiration.c
+test_expiration_target_ecos_synth_MODULES = lib ce mac/common ce/test/common ce/test/rx/general/overide/cp/interf ce/test/rx/general/overide/cp
+
+
+ce_MODULE_SOURCES = tx.c
+
+VARIANT = target
+
+include $(BASE)/common/make/top.mk
+
diff --git a/cesar/ce/test/tx/target-ecos.ecc.sh b/cesar/ce/test/tx/target-ecos.ecc.sh
new file mode 100755
index 0000000000..8253d98c9a
--- /dev/null
+++ b/cesar/ce/test/tx/target-ecos.ecc.sh
@@ -0,0 +1,5 @@
+config=${1:-ecos-gen.ecc}
+ecosconfig --config=$config new linux default
+cat >> $config <<EOF
+EOF
+ecosconfig --config=$config check
diff --git a/cesar/ce/test/tx/test.h b/cesar/ce/test/tx/test.h
new file mode 100644
index 0000000000..9d0fde9ad4
--- /dev/null
+++ b/cesar/ce/test/tx/test.h
@@ -0,0 +1,18 @@
+#ifndef ___tx_test_h
+#define ___tx_test_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2008 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ../tx/test.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+#endif /* ___tx_test_h */