summaryrefslogtreecommitdiff
path: root/cesar/maximus/stationtest
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/maximus/stationtest')
-rw-r--r--cesar/maximus/stationtest/Config2
-rw-r--r--cesar/maximus/stationtest/Makefile47
-rw-r--r--cesar/maximus/stationtest/ecos.ecc.sh104
-rw-r--r--cesar/maximus/stationtest/src/exception.c74
-rw-r--r--cesar/maximus/stationtest/src/hello_world.c28
-rw-r--r--cesar/maximus/stationtest/src/main_example.c392
-rw-r--r--cesar/maximus/stationtest/src/one_thread.c47
-rw-r--r--cesar/maximus/stationtest/src/test_cb.c41
-rw-r--r--cesar/maximus/stationtest/src/test_ether.c143
-rw-r--r--cesar/maximus/stationtest/src/test_false_alarm.c158
-rw-r--r--cesar/maximus/stationtest/src/test_lib_cesar.c93
-rw-r--r--cesar/maximus/stationtest/src/test_send.c231
-rw-r--r--cesar/maximus/stationtest/src/test_station.c91
-rw-r--r--cesar/maximus/stationtest/src/test_tx_rx.c339
-rw-r--r--cesar/maximus/stationtest/src/threaddelay.c50
15 files changed, 1840 insertions, 0 deletions
diff --git a/cesar/maximus/stationtest/Config b/cesar/maximus/stationtest/Config
new file mode 100644
index 0000000000..20950daa9a
--- /dev/null
+++ b/cesar/maximus/stationtest/Config
@@ -0,0 +1,2 @@
+CONFIG_DEBUG = y
+CONFIG_DEBUG_FATAL_CATCH = y \ No newline at end of file
diff --git a/cesar/maximus/stationtest/Makefile b/cesar/maximus/stationtest/Makefile
new file mode 100644
index 0000000000..14d797579d
--- /dev/null
+++ b/cesar/maximus/stationtest/Makefile
@@ -0,0 +1,47 @@
+BASE = ../..
+
+ECOS = y
+
+TARGET_PROGRAMS = exception hello_world one_thread threaddelay \
+ stationtest \
+ test_cb test_ether test_false_alarm test_lib_cesar test_send test_station test_tx_rx
+
+exception_SOURCES = exception.c
+exception_MODULES = lib host
+
+hello_world_SOURCES = hello_world.c
+hello_world_MODULES = lib host
+
+one_thread_SOURCES = one_thread.c
+one_thread_MODULES = lib host
+
+threaddelay_SOURCES = threaddelay.c
+threaddelay_MODULES = lib host
+
+stationtest_SOURCES = main_example.c
+stationtest_MODULES = lib host hal/phy/maximus
+
+test_cb_SOURCES = test_cb.c
+test_cb_MODULES = lib host
+
+test_ether_SOURCES = test_ether.c
+test_ether_MODULES = lib host hal/hle/maximus
+
+test_false_alarm_SOURCES = test_false_alarm.c
+test_false_alarm_MODULES = lib host hal/phy/maximus
+
+cp_beacon_MODULE_SOURCES = beacons.c bentry.c
+test_lib_cesar_SOURCES = test_lib_cesar.c
+test_lib_cesar_MODULES = lib host hal/hle/maximus hal/phy/maximus/dur/maximus interface cp/station/maximus
+
+test_send_SOURCES = test_send.c
+test_send_MODULES = lib host hal/phy/maximus
+
+cp_beacon_MODULE_SOURCES = beacons.c bentry.c
+test_station_SOURCES = test_station.c
+test_station_MODULES = lib host hal/hle/maximus hal/phy/maximus/dur/maximus interface cp/station/maximus
+
+test_tx_rx_SOURCES = test_tx_rx.c
+test_tx_rx_MODULES = lib host hal/phy/maximus
+
+include $(BASE)/common/make/top.mk
diff --git a/cesar/maximus/stationtest/ecos.ecc.sh b/cesar/maximus/stationtest/ecos.ecc.sh
new file mode 100644
index 0000000000..19597e4621
--- /dev/null
+++ b/cesar/maximus/stationtest/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/maximus/stationtest/src/exception.c b/cesar/maximus/stationtest/src/exception.c
new file mode 100644
index 0000000000..cbd0129cd1
--- /dev/null
+++ b/cesar/maximus/stationtest/src/exception.c
@@ -0,0 +1,74 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file exception.c
+ * \brief how to catch an exception
+ * \ingroup
+ *
+ * this is a test program to check eCos well work
+ */
+
+#include <cyg/kernel/kapi.h>
+#include <cyg/infra/diag.h>
+#include <cyg/hal/hal_intr.h>
+#include "common/std.h"
+#include <host/station.h>
+
+extern station_ctx_t my_station;
+
+void system_call_exception(cyg_addrword_t data, cyg_code_t number, cyg_addrword_t info)
+{
+ switch(number)
+ {
+ case CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION:
+ diag_printf("eCos: Exception Error (Illegal Instruction)!!!\n");
+ break;
+
+ case CYGNUM_HAL_EXCEPTION_DATA_ACCESS:
+ diag_printf("eCos: Exception Error (Data Access)!!!\n");
+ break;
+
+ case CYGNUM_HAL_EXCEPTION_FPU:
+ diag_printf("eCos: Exception Error (FPU)!!!\n");
+ break;
+ }
+// station_down(&my_station);
+// cyg_hal_sys_exit(1);
+}
+
+void cyg_user_start(void)
+{
+ char *ptr = 0x0000;
+ cyg_exception_handler_t *oldHandler;
+ cyg_addrword_t oldData;
+
+ diag_write_string("debut du main\n");
+
+ cyg_exception_set_handler(CYGNUM_HAL_EXCEPTION_ILLEGAL_INSTRUCTION,
+ &system_call_exception,
+ 0,
+ &oldHandler,
+ &oldData);
+ cyg_exception_set_handler(CYGNUM_HAL_EXCEPTION_DATA_ACCESS,
+ &system_call_exception,
+ 0,
+ &oldHandler,
+ &oldData);
+ cyg_exception_set_handler(CYGNUM_HAL_EXCEPTION_FPU,
+ &system_call_exception,
+ 0,
+ &oldHandler,
+ &oldData);
+
+ diag_write_string("exception enregistrees\n");
+
+// cyg_thread_delay(10);
+ *ptr = 12;
+ diag_write_string("fin du main\n");
+}
+
diff --git a/cesar/maximus/stationtest/src/hello_world.c b/cesar/maximus/stationtest/src/hello_world.c
new file mode 100644
index 0000000000..2a118d5f2d
--- /dev/null
+++ b/cesar/maximus/stationtest/src/hello_world.c
@@ -0,0 +1,28 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hello_world.c
+ * \brief hello world program
+ * \ingroup
+ */
+
+#include <cyg/infra/diag.h>
+#include "common/std.h"
+#include "host/station.h"
+
+extern station_ctx_t my_station;
+
+int main(void)
+{
+ station_log_set_level(&my_station, STATION_LOG_DEBUG);
+ station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
+ my_station.pipe_log_fd = 1;
+ diag_write_string("hello by eCos\n");
+ return 0;
+}
+
diff --git a/cesar/maximus/stationtest/src/main_example.c b/cesar/maximus/stationtest/src/main_example.c
new file mode 100644
index 0000000000..c9b5b133f7
--- /dev/null
+++ b/cesar/maximus/stationtest/src/main_example.c
@@ -0,0 +1,392 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file main_example.c
+ * \brief example of a main program of a station executable
+ * \ingroup
+ */
+
+#include <cyg/infra/diag.h>
+#include <cyg/kernel/kapi.h>
+#include <errno.h>
+#include "common/std.h"
+#include "host/station.h"
+#include "hal/phy/phy.h"
+#include "hal/phy/maximus/inc/maximus_phy_ctx.h" // for 'phy_t'
+
+extern station_ctx_t my_station;
+phy_t * phy;
+
+bool phy_rx_fc_cb (void *user, u32 rx_date, const u32 *fc_av)
+{
+ diag_write_string("=> phy_rx_fc_cb\n");
+
+ phy_rx_prepare(phy, false, PHY_MOD_MINI_ROBO,
+ PHY_FEC_RATE_1_2, PHY_PB_SIZE_136, PHY_GIL_567,
+ 0 /* tonemap_index */, 0 /* 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)
+{
+ return true;
+}
+
+bool phy_tx_false_alarm_cb (void *user)
+{
+ return true;
+}
+
+bool phy_zero_cross_cb (void *user, u32 zero_cross_date)
+{
+ return true;
+}
+
+void phy_deferred_cb (void *user)
+{
+ return;
+}
+
+bool phy_extra_timer_cb (void *user)
+{
+ return true;
+}
+
+typedef struct my_struct
+{
+ int i1;
+ int i2;
+ bool b;
+} my_struct_t;
+
+typedef long long my_type_t;
+
+my_type_t my_param4;
+
+unsigned int my_param6 = 123; // 0x0000007B
+unsigned int my_param7 = 456; // 0x000001C8
+bool my_param8 = false;
+bool my_param9 = true;
+unsigned short my_param10 = 0xFFEE;
+unsigned long my_param11 = 0xFFEEDDCC;
+
+
+void my_return_function (void *data)
+{
+ static fcall_param_t return_param;
+ static sci_msg_t return_msg;
+ static unsigned char return_buffer[1024];
+ unsigned short *return_msg_id = (unsigned short *)data;
+
+ /* init structures */
+ fcall_param_init(&return_param, "function_1_rsp", *return_msg_id);
+ if (0 != sci_msg_init(&return_msg, return_buffer, 1024))
+ {
+ station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_SCI,
+ "%s: errno = %d", __FUNCTION__, errno);
+ }
+
+ /* do other tasks ... */
+ diag_write_string("=> my_return_function\n");
+
+ /* now make the return parameter list */
+ fcall_param_reset(&return_param);
+ fcall_param_add(&return_param, &return_msg, "result_2", sizeof(my_type_t), &my_param4);
+ fcall_return(my_station.fcall, &return_param, &return_msg);
+
+ return;
+}
+
+
+int my_function1 (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ static unsigned short asynchronous_msg_id = 0;
+ my_struct_t my_param1;
+ int my_param2[10];
+ char my_param3[6];
+ int i;
+
+ // for netclock message
+ netclock_id_t id;
+ static netclock_callback_t my_return_function_cb;
+
+ /* get parameters content */
+ fcall_param_bind(*param, *msg, "param_1", sizeof(my_struct_t), &my_param1);
+ fcall_param_bind(*param, *msg, "param_2", 10*sizeof(int), my_param2);
+ fcall_param_bind(*param, *msg, "param_3", 6, (char*)my_param3);
+ fcall_param_bind(*param, *msg, "param_4", sizeof(my_type_t), &my_param4);
+
+ /* do other tasks ... */
+ diag_write_string("=> my_function1\n");
+ diag_printf("param 1 . i1 = %d\n", my_param1.i1);
+ diag_printf("param 1 . i2 = %d\n", my_param1.i2);
+ diag_printf("param 1 . b = %d\n", my_param1.b);
+ diag_write_string("param 2 = ");
+ for (i=0; i<10; i++)
+ {
+ diag_printf(" %d", my_param2[i]);
+ }
+ diag_write_string("\n");
+ diag_printf("param 3 = %s\n", my_param3);
+ diag_printf("param 4 = %lld\n", my_param4);
+
+ /* prepare the future asynchronous return */
+ fcall_param_set_async(*param, 1);
+ asynchronous_msg_id = (*param)->msg_id;
+
+ /* schedule the future my_return_function() call */
+ // send netclock message to Maximus to call my_return_function()
+ if (-1 == netclock_schedule(my_station.netclock,
+ &my_return_function_cb,
+ NETWORK_CLOCK_TYPE_STATION,
+ my_station.current_tick_tck+10,
+ &my_return_function,
+ (void*)&asynchronous_msg_id,
+ &id))
+ {
+ diag_printf("errno = %d\n", errno);
+ }
+
+ /* now return */
+ return 0;
+}
+
+
+int my_function2 (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ bool my_param5;
+ char my_result1[] = "this is result 1\0";
+
+ /* get parameters content */
+ if (-1 == fcall_param_bind(*param, *msg, "param_5", sizeof(bool), &my_param5))
+ {
+ diag_printf("errno = %d\n", errno);
+ diag_printf("param nb = %d\n", (*param)->param_nb);
+ }
+
+ /* do other tasks ... */
+ diag_write_string("=> my_function2\n");
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+ fcall_param_add(*param, *msg, "result_1", strlen(my_result1)+1, &my_result1);
+
+ return 0;
+}
+
+
+void my_function_rsp (void *data)
+{
+ static fcall_param_t return_param;
+ static sci_msg_t return_msg;
+ static unsigned char return_buffer[1024];
+ unsigned short *return_msg_id = (unsigned short *)data;
+
+ /* init structures */
+ fcall_param_init(&return_param, "function_rsp", *return_msg_id);
+ if (0 != sci_msg_init(&return_msg, return_buffer, 1024))
+ {
+ station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_SCI,
+ "%s: errno = %d", __FUNCTION__, errno);
+ }
+
+ /* do other tasks ... */
+ diag_write_string("=> my_function_rsp\n");
+
+ /* now make the return parameter list */
+ fcall_param_reset(&return_param);
+ fcall_return(my_station.fcall, &return_param, &return_msg);
+
+ return;
+}
+
+
+int my_function3 (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ static unsigned short asynchronous_msg_id = 0;
+
+ /* do other tasks ... */
+ diag_write_string("=> my_function3\n");
+
+ /* prepare the future asynchronous return */
+ fcall_param_set_async(*param, 1);
+ asynchronous_msg_id = (*param)->msg_id;
+
+ /* call my_function_rsp() */
+ my_function_rsp((void*)&asynchronous_msg_id);
+
+ return 0;
+}
+
+
+int my_function4 (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ static unsigned short asynchronous_msg_id = 0;
+
+ /* do other tasks ... */
+ diag_write_string("=> my_function4\n");
+
+ /* prepare the future asynchronous return */
+ fcall_param_set_async(*param, 1);
+ asynchronous_msg_id = (*param)->msg_id;
+
+ /* call my_function_rsp() */
+ my_function_rsp((void*)&asynchronous_msg_id);
+
+ return 0;
+}
+
+
+int my_function5 (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ static unsigned short asynchronous_msg_id = 0;
+
+ /* do other tasks ... */
+ diag_write_string("=> my_function5\n");
+
+ /* prepare the future asynchronous return */
+ fcall_param_set_async(*param, 1);
+ asynchronous_msg_id = (*param)->msg_id;
+
+ /* call my_function_rsp() */
+ my_function_rsp((void*)&asynchronous_msg_id);
+
+ return 0;
+}
+
+
+int set_tonemask (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ int i = 0;
+ u8 tonemask[(PHY_CARRIER_NB+7)/8];
+
+ diag_write_string("=> set_tonemask\n");
+
+ // Initialize the HAL PHY
+ phy = phy_init ((void*)&my_param4, &phy_rx_fc_cb, &phy_access_cb, &phy_access_conf_cb, &phy_pbdma_cb, &phy_tx_false_alarm_cb, &phy_deferred_cb);
+ phy_zero_cross_init (phy, &phy_zero_cross_cb);
+
+ // Enable assertions on warnings
+ phy->warning_assert = true;
+
+ // Set TONEMASK
+ for (i=0; i<(PHY_CARRIER_NB+7)/8; i++)
+ {
+ tonemask[i] = 0xEE;
+ }
+ phy_set_tonemask(phy, tonemask, PHY_CARRIER_NB);
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+
+int prepare_rx (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ // Test with one PB of 128 octets
+ static u8 first_pb_data[128];
+ static phy_pb_t first_pb;
+ static u32 iv[3];
+ static u32 nek[4];
+ int i = 0;
+
+ diag_write_string("=> prepare_rx\n");
+
+ // Activate RX
+ phy_rx_activate(phy, true, my_station.current_tick_tck, true);
+
+ // Set RX parameters
+ phy_rx_param(phy, PHY_FC_MODE_HYBRID_1);
+
+ // Start PBDMA
+ memset(first_pb_data, '1', 128);
+ first_pb.pb_rx.blk.data = first_pb_data;
+ first_pb.pb_rx.blk.next = NULL;
+ for (i=0; i<3; i++)
+ {
+ iv[i] = i;
+ }
+ for (i=0; i<4; i++)
+ {
+ nek[i] = i;
+ }
+ phy_pbdma_start(phy, true /* bypass_aes */, iv,
+ nek, 1 /* nb_total */, 1 /* nb_ready */,
+ 1 /* nb_pb_it */, &first_pb);
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+
+int uninit_phy (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ diag_write_string("=> uninit_phy\n");
+
+ // Uninitialize the HAL PHY
+ phy_uninit (phy);
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+
+int function_to_call (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ diag_write_string("=> function_to_call\n");
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+
+int main (void)
+{
+ station_log_set_level(&my_station, STATION_LOG_DEBUG);
+ station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
+ my_station.pipe_log_fd = 1;
+
+ fcall_register(my_station.fcall, "function_1", (void*)&my_function1, NULL);
+ fcall_register(my_station.fcall, "function_2", (void*)&my_function2, NULL);
+ fcall_register(my_station.fcall, "function_3", (void*)&my_function3, NULL);
+ fcall_register(my_station.fcall, "function_4", (void*)&my_function4, NULL);
+ fcall_register(my_station.fcall, "function_5", (void*)&my_function5, NULL);
+ fcall_register(my_station.fcall, "set_tonemask", (void*)&set_tonemask, NULL);
+ fcall_register(my_station.fcall, "prepare_rx", (void*)&prepare_rx, NULL);
+ fcall_register(my_station.fcall, "uninit_phy", (void*)&uninit_phy, NULL);
+ fcall_register(my_station.fcall, "function_to_call", (void*)&function_to_call, NULL);
+
+ probe_register(my_station.probe, "param_6", sizeof(unsigned int), &my_param6);
+ probe_register(my_station.probe, "param_7", sizeof(unsigned int), &my_param7);
+ probe_register(my_station.probe, "param_8", sizeof(bool), &my_param8);
+ probe_register(my_station.probe, "param_9", sizeof(bool), &my_param9);
+ probe_register(my_station.probe, "param_10", sizeof(unsigned short), &my_param10);
+ probe_register(my_station.probe, "param_11", sizeof(unsigned long), &my_param11);
+
+ return 0;
+}
+
diff --git a/cesar/maximus/stationtest/src/one_thread.c b/cesar/maximus/stationtest/src/one_thread.c
new file mode 100644
index 0000000000..794bacfcb8
--- /dev/null
+++ b/cesar/maximus/stationtest/src/one_thread.c
@@ -0,0 +1,47 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file one_thread.c
+ * \brief test program with only one thread
+ * \ingroup
+ *
+ * this is a test program to check eCos well work
+ */
+
+#include <cyg/kernel/kapi.h>
+#include <cyg/infra/diag.h>
+
+#define MY_THREAD_STACK_SIZE (2048 / sizeof(int))
+
+int my_thread_stack[MY_THREAD_STACK_SIZE];
+cyg_handle_t my_thread_handle;
+cyg_thread my_thread_obj;
+
+void my_thread(cyg_addrword_t index)
+{
+ unsigned int my_counter = 0;
+ while(1)
+ {
+ diag_printf("hello, count=%d\n",my_counter);
+ my_counter++;
+ }
+}
+
+void cyg_user_start(void)
+{
+
+ cyg_thread_create(12, my_thread, (cyg_addrword_t) 0,
+ "My Thread", &my_thread_stack, MY_THREAD_STACK_SIZE,
+ &my_thread_handle, &my_thread_obj);
+
+ cyg_thread_resume(my_thread_handle);
+ diag_write_string("scheduler starting...\n");
+
+ cyg_scheduler_start();
+}
+
diff --git a/cesar/maximus/stationtest/src/test_cb.c b/cesar/maximus/stationtest/src/test_cb.c
new file mode 100644
index 0000000000..83e9f4ce10
--- /dev/null
+++ b/cesar/maximus/stationtest/src/test_cb.c
@@ -0,0 +1,41 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test_cb.c
+ * \brief station executable used for test cb program
+ * \ingroup
+ */
+
+#include <cyg/infra/diag.h>
+#include <cyg/kernel/kapi.h>
+#include <errno.h>
+#include "common/std.h"
+#include "host/station.h"
+
+extern station_ctx_t my_station;
+
+int get_seg (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ diag_write_string("=> get_seg\n");
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+int main(void)
+{
+ station_log_set_level(&my_station, STATION_LOG_DEBUG);
+ station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
+ my_station.pipe_log_fd = 1;
+
+ fcall_register(my_station.fcall, "get_seg", (void*)&get_seg, NULL);
+
+ return 0;
+}
diff --git a/cesar/maximus/stationtest/src/test_ether.c b/cesar/maximus/stationtest/src/test_ether.c
new file mode 100644
index 0000000000..87a00ecebe
--- /dev/null
+++ b/cesar/maximus/stationtest/src/test_ether.c
@@ -0,0 +1,143 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test_ether.c
+ * \brief test ether program
+ * \ingroup
+ */
+
+#include <cyg/infra/diag.h>
+#include <cyg/kernel/kapi.h>
+#include <errno.h>
+#include "common/std.h"
+#include "host/station.h"
+#include "hal/hle/ipmbox.h"
+#include "hal/hle/defs.h" // for 'HLE_MSG_TYPE_...' and 'ipmbox_msg_hdr_t'
+#include "hal/hle/maximus/inc/maximus_ipmbox_ctx.h" // for 'ipmbox_t'
+#include "hal/hle/maximus/inc/maximus_interrupts.h" // for 'HAL_HLE_INTERRUPT_IPMBOX'
+#include "maximus/common/types/ethernet_types.h" // for 'ETHERNET_TYPE_...'
+#include <stdlib.h> // for 'malloc()'
+
+extern station_ctx_t my_station;
+ipmbox_t * ctx;
+int user_data = 123;
+
+
+void ipmbox_rx_cb (void *user_data, u32 *first_msg, uint length)
+{
+ diag_write_string("=> ipmbox_rx_cb\n");
+
+ // Reset IT
+ maximus_pending_isrs &= (0 << HAL_HLE_INTERRUPT_IPMBOX);
+
+ ipmbox_msg_hdr_t *hdr = (ipmbox_msg_hdr_t *)&ctx->rx.mailbox[0];
+ if (HLE_MSG_TYPE_DATA == hdr->type)
+ {
+ /* When receiving an Ether SCI message of type DATA or MME from Maximus,
+ * answer by sending a first Ether SCI message of type DATA,
+ * with an Ether SCI message of type BUFFER_RELEASED,
+ * and a second one of type MME,
+ * with an Ether SCI message of type BUFFER_RELEASED. */
+
+ uint data_length = (uint)(hdr->param >> 1);
+ memcpy(ctx->first_buffer->next->data, (u32 *)ctx->rx.mailbox[1], data_length);
+ memcpy(ctx->first_buffer->next->next->data, (u32 *)ctx->rx.mailbox[1], data_length);
+
+ // Release allocated buffer
+ hdr->type = HLE_MSG_TYPE_SEND_DONE;
+ ipmbox_tx (ctx, ctx->rx.mailbox, 2);
+
+ hdr->type = HLE_MSG_TYPE_DATA;
+ hdr->param &= 0xFFE;
+ ctx->rx.mailbox[1] = (u32)ctx->first_buffer->next->data;
+ ipmbox_tx (ctx, ctx->rx.mailbox, ctx->rx.length);
+
+ hdr->param |= 0x001;
+ ctx->rx.mailbox[1] = (u32)ctx->first_buffer->next->data;
+ ipmbox_tx (ctx, ctx->rx.mailbox, ctx->rx.length);
+ }
+ else if (HLE_MSG_TYPE_BUFFER_ADD == hdr->type)
+ {
+ if (2 == hdr->param)
+ {
+ /* When receiving an Ether SCI message of type INTERFACE_BUFFER_ADD from Maximus,
+ * answer by sending an Ether SCI message of type SNIFFER,
+ * with an Ether SCI message of type BUFFER_RELEASED. */
+
+ uint data_length = 64;
+ char * p_data = malloc(data_length);
+ memset(p_data, '\0', data_length);
+ strcpy(p_data, "This is a sniffed packet coming from the station");
+
+ maximus_hle_buffer_t *p_buffer = (maximus_hle_buffer_t *)malloc(sizeof(maximus_hle_buffer_t));
+ u32 id = ctx->last_buffer->id;
+ ctx->last_buffer->next = p_buffer;
+ ctx->last_buffer = p_buffer;
+ ctx->last_buffer->next = NULL;
+ ctx->last_buffer->id = id;
+ ctx->last_buffer->data = (u32 *)p_data;
+
+ hdr->type = HLE_MSG_TYPE_INTERFACE;
+ hdr->length = 2;
+ hdr->param = ((data_length << 8) & 0x7FF00) | 0x00001;
+ ctx->rx.mailbox[1] = 0x00000007;
+ ctx->rx.mailbox[2] = (u32)p_data;
+ ipmbox_tx (ctx, ctx->rx.mailbox, 3);
+ }
+ }
+
+ return;
+}
+
+
+int init_ether (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ diag_write_string("=> init_ether\n");
+
+ // Initialize the HAL HLE ipmbox
+ ctx = ipmbox_init ((void *)&user_data, &ipmbox_rx_cb);
+
+ // Enable assertions on warnings
+ ctx->warning_assert = true;
+
+ // Activate ipmbox interruptions
+ ipmbox_activate (ctx, true);
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+
+int uninit_ether (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ diag_write_string("=> uninit_ether\n");
+
+ // Uninitialize the HAL HLE ipmbox
+ ipmbox_uninit (ctx);
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+
+int main(void)
+{
+ station_log_set_level(&my_station, STATION_LOG_DEBUG);
+ station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
+ my_station.pipe_log_fd = 1;
+
+ fcall_register(my_station.fcall, "init_ether", (void*)&init_ether, NULL);
+ fcall_register(my_station.fcall, "uninit_ether", (void*)&uninit_ether, NULL);
+
+ return 0;
+}
+
diff --git a/cesar/maximus/stationtest/src/test_false_alarm.c b/cesar/maximus/stationtest/src/test_false_alarm.c
new file mode 100644
index 0000000000..bba0472d79
--- /dev/null
+++ b/cesar/maximus/stationtest/src/test_false_alarm.c
@@ -0,0 +1,158 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test_false_alarm.c
+ * \brief station executable used for test false alarm program
+ * \ingroup
+ */
+
+#include <cyg/infra/diag.h>
+#include <cyg/kernel/kapi.h>
+#include <errno.h>
+#include "common/std.h"
+#include "host/station.h"
+#include "hal/phy/phy.h"
+#include "hal/phy/maximus/inc/maximus_phy_ctx.h" // for 'phy_t'
+#include "hal/phy/maximus/inc/maximus_interrupts.h" // for 'PHY_HAL_INTERRUPT_...'
+
+extern station_ctx_t my_station;
+phy_t * ctx;
+
+bool phy_rx_fc_cb (void *user, u32 rx_date, const u32 *fc_av)
+{
+ diag_write_string("=> phy_rx_fc_cb\n");
+
+ // Reset IT
+ maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
+
+ phy_rx_prepare(ctx, false, PHY_MOD_MINI_ROBO,
+ PHY_FEC_RATE_1_2, PHY_PB_SIZE_136, PHY_GIL_567,
+ 0 /* tonemap_index */, 0 /* symbol_nb */);
+
+ return true;
+}
+
+bool phy_access_cb (void *user)
+{
+ diag_write_string("=> phy_access_cb\n");
+
+ // Reset IT
+ maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
+
+ return true;
+}
+
+bool phy_access_conf_cb (void *user)
+{
+ diag_write_string("=> phy_access_conf_cb\n");
+
+ // Reset IT
+ maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
+
+ return true;
+}
+
+bool phy_pbdma_cb (void *user, u32 status_word)
+{
+ diag_write_string("=> phy_pbdma_cb\n");
+
+ // Reset IT
+ maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PBDMA);
+
+ return true;
+}
+
+bool phy_tx_false_alarm_cb (void *user)
+{
+ diag_write_string("=> phy_tx_false_alarm_cb\n");
+
+ // Reset IT
+ maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
+
+ return true;
+}
+
+void phy_deferred_cb (void *user)
+{
+ diag_write_string("=> phy_deferred_cb\n");
+
+ return;
+}
+
+int init_phy (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ diag_write_string("=> init_phy\n");
+
+ // Initialize the HAL PHY
+ ctx = phy_init ((void*)&my_station, &phy_rx_fc_cb, &phy_access_cb,
+ &phy_access_conf_cb, &phy_pbdma_cb,
+ &phy_tx_false_alarm_cb, &phy_deferred_cb);
+
+ // Enable assertions on warnings
+ ctx->warning_assert = true;
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+int activate_rx (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ unsigned short fc_mode = 0;
+ bool pre_detection = false;
+
+ diag_write_string("=> activate_rx\n");
+
+ /* get parameters content */
+ fcall_param_bind_short(*param, *msg, "fc_mode", &fc_mode);
+ fcall_param_bind(*param, *msg, "pre_detection", 1, &pre_detection);
+
+ // Set medium state
+ ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_IDLE;
+
+ // Activate RX
+ phy_rx_activate(ctx, true /* now */, my_station.current_tick_tck, pre_detection);
+
+ // Set RX parameters
+ phy_rx_param(ctx, (phy_fc_mode_t)fc_mode);
+
+ // Set TX blocked
+ ctx->control.tx_blocked_on_false_alarm = true;
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+int uninit_phy (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ diag_write_string("=> uninit_phy\n");
+
+ // Uninitialize the HAL PHY
+ phy_uninit (ctx);
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+int main(void)
+{
+ station_log_set_level(&my_station, STATION_LOG_DEBUG);
+ station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
+ my_station.pipe_log_fd = 1;
+
+ fcall_register(my_station.fcall, "init_phy", (void*)&init_phy, NULL);
+ fcall_register(my_station.fcall, "activate_rx", (void*)&activate_rx, NULL);
+ fcall_register(my_station.fcall, "uninit_phy", (void*)&uninit_phy, NULL);
+
+ return 0;
+}
diff --git a/cesar/maximus/stationtest/src/test_lib_cesar.c b/cesar/maximus/stationtest/src/test_lib_cesar.c
new file mode 100644
index 0000000000..ca3b5d6d65
--- /dev/null
+++ b/cesar/maximus/stationtest/src/test_lib_cesar.c
@@ -0,0 +1,93 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test_lib_cesar.c
+ * \brief station executable used for the test lib cesar program
+ * \ingroup
+ */
+
+#include "common/std.h"
+#include "host/station.h" // for 'station_ctx_t'
+#include "cp/beacon/beacons.h" // for 'cp_sta_t'
+#include "cp/station/maximus/inc/maximus_cp_station.h" // for 'maximus_cp_station_init()'
+#include "hal/phy/maximus/dur/maximus/inc/maximus_phy_dur.h" // for 'maximus_phy_dur_init()'
+#include "hal/hle/ipmbox.h"
+#include "hal/hle/defs.h" // for 'HLE_MSG_TYPE_...' and 'ipmbox_msg_hdr_t'
+#include "hal/hle/maximus/inc/maximus_ipmbox_ctx.h" // for 'ipmbox_t'
+#include "hal/hle/maximus/inc/maximus_interrupts.h" // for 'HAL_HLE_INTERRUPT_IPMBOX'
+#include "maximus/common/types/ethernet_types.h" // for 'ETHERNET_TYPE_...'
+
+cp_sta_t cp_sta_global;
+extern station_ctx_t my_station;
+ipmbox_t *ctx;
+int user_data = 123;
+
+void ipmbox_rx_cb (void *user_data, u32 *first_msg, uint length)
+{
+ // Reset IT
+ maximus_pending_isrs &= (0 << HAL_HLE_INTERRUPT_IPMBOX);
+
+ ipmbox_msg_hdr_t *hdr = (ipmbox_msg_hdr_t *)&ctx->rx.mailbox[0];
+ if (HLE_MSG_TYPE_DATA == hdr->type)
+ {
+ /* When receiving an Ether SCI message of type MME REQ from Maximus,
+ * send the answer (an Ether SCI message of type MME CNF). */
+
+ uint data_length = (uint)(hdr->param >> 1);
+ memcpy(ctx->first_buffer->next->data, (u32 *)ctx->rx.mailbox[1], data_length);
+ char *data = (char *)ctx->first_buffer->next->data;
+ *(data + 15) = *(data + 15) + 1; // REQ => CNF
+ *(data + 19) = 0x01; // Success
+ memset(data + 20, '\0', data_length - 20);
+
+ // Release allocated buffer
+ hdr->type = HLE_MSG_TYPE_SEND_DONE;
+ ipmbox_tx (ctx, ctx->rx.mailbox, 2);
+
+ hdr->type = HLE_MSG_TYPE_DATA;
+ hdr->param |= 0x001;
+ ctx->rx.mailbox[1] = (u32)ctx->first_buffer->next->data;
+ ipmbox_tx (ctx, ctx->rx.mailbox, ctx->rx.length);
+ }
+
+ return;
+}
+
+int uninit_ether (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ // Uninitialize the HAL HLE ipmbox
+ ipmbox_uninit (ctx);
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+int main (void)
+{
+ station_log_set_level(&my_station, STATION_LOG_WARNING);
+ station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
+ my_station.pipe_log_fd = 1;
+
+ maximus_cp_station_init(&my_station);
+ maximus_phy_dur_init(&my_station);
+
+ // Initialize the HAL HLE ipmbox
+ ctx = ipmbox_init ((void *)&user_data, &ipmbox_rx_cb);
+
+ // Enable assertions on warnings
+ ctx->warning_assert = true;
+
+ // Activate ipmbox interruptions
+ ipmbox_activate (ctx, true);
+
+ fcall_register(my_station.fcall, "uninit_ether", (void*)&uninit_ether, NULL);
+
+ return 0;
+}
diff --git a/cesar/maximus/stationtest/src/test_send.c b/cesar/maximus/stationtest/src/test_send.c
new file mode 100644
index 0000000000..ac9541bb9e
--- /dev/null
+++ b/cesar/maximus/stationtest/src/test_send.c
@@ -0,0 +1,231 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test_send.c
+ * \brief station executable used for the test send program
+ * \ingroup
+ */
+
+#include <cyg/infra/diag.h>
+#include <cyg/kernel/kapi.h>
+#include <errno.h>
+#include "common/std.h"
+#include "host/station.h"
+#include "hal/phy/phy.h"
+#include "mac/common/defs.h"
+#include "hal/phy/maximus/inc/maximus_phy_ctx.h" // for 'phy_t'
+
+extern station_ctx_t my_station;
+phy_t * 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;
+
+// For noise
+phy_chandata_t freq_chan[6];
+phy_chandata_t time_chan;
+u8 freq_chan_data[6][MAC_PB520_BYTES];
+u8 time_chan_data[MAC_PB520_BYTES];
+
+bool phy_rx_fc_cb (void *user, u32 rx_date, const u32 *fc_av)
+{
+ diag_write_string("=> phy_rx_fc_cb\n");
+
+ // When the FC is received, prepare RX
+ phy_rx_prepare(ctx, short_ppdu, (phy_mod_t)mod,
+ (phy_fecrate_t)fecrate, (phy_pb_size_t)pb_size, (phy_gil_t)gil,
+ 0 /* tonemap_index */, 0 /* 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)
+{
+ 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 set_tonemask (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ u8 tonemask[(PHY_CARRIER_NB+7)/8];
+ int i = 0;
+
+ diag_write_string("=> set_tonemask\n");
+
+ // Initialize the HAL 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);
+
+ // Enable assertions on warnings
+ ctx->warning_assert = true;
+
+ // Set TONEMASK
+ for (i=0; i<(PHY_CARRIER_NB+7)/8; i++)
+ {
+ tonemask[i] = 0xEE;
+ }
+ phy_set_tonemask(ctx, tonemask, PHY_CARRIER_NB);
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+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;
+ char c = 0;
+ static u32 iv[3];
+ static u32 nek[4];
+
+ // Test with maximum 10 PBs of 512 octets
+ int pb_length = MAC_MAX_PB_PER_MPDU;
+ static u8 pb_data[MAC_MAX_PB_PER_MPDU][MAC_PB520_BYTES];
+ static phy_pb_t pb[MAC_MAX_PB_PER_MPDU];
+
+ // For noise
+ int transfer_size = 128;
+ int chan_length = ((PHY_CARRIER_NB * sizeof(u16)) + ((4 * transfer_size) - 1 )) / (4 * transfer_size);
+
+ diag_write_string("=> 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);
+ if (!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);
+ }
+
+ // Activate RX
+ phy_rx_activate(ctx, true /* now */, my_station.current_tick_tck, true /* pre_detection */);
+
+ // Set RX parameters
+ phy_rx_param(ctx, (phy_fc_mode_t)fc_mode);
+
+ // Start PBDMA
+ for (i=0; i<pb_length; i++)
+ {
+ memset(&pb_data[i][0], c, MAC_PB520_BYTES);
+ pb[i].pb_rx.blk.data = &pb_data[i][0];
+ if (i != pb_length-1)
+ {
+ pb[i].pb_rx.blk.next = &pb[i+1].pb_rx.blk;
+ }
+ else
+ {
+ pb[i].pb_rx.blk.next = NULL;
+ }
+ c++;
+ }
+ for (i=0; i<3; i++)
+ {
+ iv[i] = i;
+ }
+ for (i=0; i<4; i++)
+ {
+ nek[i] = i;
+ }
+ phy_pbdma_start(ctx, true /* bypass_aes */, iv,
+ nek, (uint)pb_nb /* nb_total */, (uint)pb_nb /* nb_ready */,
+ (uint)pb_nb /* nb_pb_it */, &pb[0]);
+
+ // Start chandata
+ for (i=0; i<chan_length; i++)
+ {
+ memset(&freq_chan_data[i][0], c, MAC_PB520_BYTES);
+ freq_chan[i].blk.data = &freq_chan_data[i][0];
+ if (i != chan_length-1)
+ {
+ freq_chan[i].blk.next = &freq_chan[i+1].blk;
+ }
+ else
+ {
+ freq_chan[i].blk.next = &time_chan.blk;
+ }
+ freq_chan[i].size = transfer_size;
+ freq_chan[i].last = 0;
+ freq_chan[i].type = PHY_CHANDATA_TYPE_NRJ;
+ freq_chan[i].address = 0;
+ c++;
+ }
+ memset(time_chan_data, c, MAC_PB520_BYTES);
+ time_chan.blk.data = time_chan_data;
+ time_chan.blk.next = NULL;
+ time_chan.size = transfer_size;
+ time_chan.last = 1;
+ time_chan.type = PHY_CHANDATA_TYPE_NRJ_SYMBOL;
+ time_chan.address = 0;
+
+ phy_pbdma_start_chandata(ctx, freq_chan);
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+int uninit_phy (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ diag_write_string("=> uninit_phy\n");
+
+ // Uninitialize the HAL PHY
+ phy_uninit (ctx);
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+int main (void)
+{
+ station_log_set_level(&my_station, STATION_LOG_DEBUG);
+ station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
+ my_station.pipe_log_fd = 1;
+
+ fcall_register(my_station.fcall, "set_tonemask", (void*)&set_tonemask, NULL);
+ fcall_register(my_station.fcall, "prepare_rx", (void*)&prepare_rx, NULL);
+ fcall_register(my_station.fcall, "uninit_phy", (void*)&uninit_phy, NULL);
+
+ return 0;
+}
+
diff --git a/cesar/maximus/stationtest/src/test_station.c b/cesar/maximus/stationtest/src/test_station.c
new file mode 100644
index 0000000000..73fe7fcb54
--- /dev/null
+++ b/cesar/maximus/stationtest/src/test_station.c
@@ -0,0 +1,91 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test_station.c
+ * \brief station executable used for the test station program
+ * \ingroup
+ */
+
+#include "common/std.h"
+#include "host/station.h" // for 'station_ctx_t'
+#include "cp/beacon/beacons.h" // for 'cp_sta_t'
+#include "cp/station/maximus/inc/maximus_cp_station.h" // for 'maximus_cp_station_init()'
+#include "hal/hle/ipmbox.h"
+#include "hal/hle/defs.h" // for 'HLE_MSG_TYPE_...' and 'ipmbox_msg_hdr_t'
+#include "hal/hle/maximus/inc/maximus_ipmbox_ctx.h" // for 'ipmbox_t'
+#include "hal/hle/maximus/inc/maximus_interrupts.h" // for 'HAL_HLE_INTERRUPT_IPMBOX'
+#include "maximus/common/types/ethernet_types.h" // for 'ETHERNET_TYPE_...'
+
+cp_sta_t cp_sta_global;
+extern station_ctx_t my_station;
+ipmbox_t *ctx;
+int user_data = 123;
+
+void ipmbox_rx_cb (void *user_data, u32 *first_msg, uint length)
+{
+ // Reset IT
+ maximus_pending_isrs &= (0 << HAL_HLE_INTERRUPT_IPMBOX);
+
+ ipmbox_msg_hdr_t *hdr = (ipmbox_msg_hdr_t *)&ctx->rx.mailbox[0];
+ if (HLE_MSG_TYPE_DATA == hdr->type)
+ {
+ /* When receiving an Ether SCI message of type MME REQ from Maximus,
+ * send the answer (an Ether SCI message of type MME CNF). */
+
+ uint data_length = (uint)(hdr->param >> 1);
+ memcpy(ctx->first_buffer->next->data, (u32 *)ctx->rx.mailbox[1], data_length);
+ char *data = (char *)ctx->first_buffer->next->data;
+ *(data + 15) = *(data + 15) + 1; // REQ => CNF
+ *(data + 19) = 0x01; // Success
+ memset(data + 20, '\0', data_length - 20);
+
+ // Release allocated buffer
+ hdr->type = HLE_MSG_TYPE_SEND_DONE;
+ ipmbox_tx (ctx, ctx->rx.mailbox, 2);
+
+ hdr->type = HLE_MSG_TYPE_DATA;
+ hdr->param |= 0x001;
+ ctx->rx.mailbox[1] = (u32)ctx->first_buffer->next->data;
+ ipmbox_tx (ctx, ctx->rx.mailbox, ctx->rx.length);
+ }
+
+ return;
+}
+
+int uninit_ether (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ // Uninitialize the HAL HLE ipmbox
+ ipmbox_uninit (ctx);
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+int main (void)
+{
+ station_log_set_level(&my_station, STATION_LOG_WARNING);
+ station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
+ my_station.pipe_log_fd = 1;
+
+ maximus_cp_station_init(&my_station);
+
+ // Initialize the HAL HLE ipmbox
+ ctx = ipmbox_init ((void *)&user_data, &ipmbox_rx_cb);
+
+ // Enable assertions on warnings
+ ctx->warning_assert = true;
+
+ // Activate ipmbox interruptions
+ ipmbox_activate (ctx, true);
+
+ fcall_register(my_station.fcall, "uninit_ether", (void*)&uninit_ether, NULL);
+
+ return 0;
+}
diff --git a/cesar/maximus/stationtest/src/test_tx_rx.c b/cesar/maximus/stationtest/src/test_tx_rx.c
new file mode 100644
index 0000000000..ddd3661f87
--- /dev/null
+++ b/cesar/maximus/stationtest/src/test_tx_rx.c
@@ -0,0 +1,339 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test_tx_rx.c
+ * \brief station executable used for the test tx rx program
+ * \ingroup
+ */
+
+#include <cyg/infra/diag.h>
+#include <cyg/kernel/kapi.h>
+#include <errno.h>
+#include "common/std.h"
+#include "host/station.h"
+#include "hal/phy/phy.h"
+#include "mac/common/defs.h"
+#include "hal/phy/maximus/inc/maximus_phy_ctx.h" // for 'phy_t'
+#include "hal/phy/maximus/inc/maximus_interrupts.h" // for 'PHY_HAL_INTERRUPT_...'
+
+extern station_ctx_t my_station;
+phy_t * ctx;
+int user_data = 123;
+
+unsigned short fc_mode = 0;
+bool short_ppdu = false;
+unsigned short mod = 0;
+unsigned short fecrate = 0;
+unsigned short pb_size = 0;
+unsigned short gil = 0;
+unsigned short pb_nb = 0;
+
+// For noise
+phy_chandata_t freq_chan[6];
+phy_chandata_t time_chan;
+u8 freq_chan_data[6][MAC_PB520_BYTES];
+u8 time_chan_data[MAC_PB520_BYTES];
+
+
+void start_pbdma (void)
+{
+ diag_write_string("=> start_pbdma\n");
+
+ int i = 0;
+ char c = 0;
+
+ static u32 iv[3];
+ static u32 nek[4];
+
+ // Test with maximum 10 PBs of 512 octets
+ int pb_length = MAC_MAX_PB_PER_MPDU;
+ static u8 pb_data[MAC_MAX_PB_PER_MPDU][MAC_PB520_BYTES];
+ static phy_pb_t pb[MAC_MAX_PB_PER_MPDU];
+
+ // Start PBDMA
+ for (i=0; i<pb_length; i++)
+ {
+ memset(&pb_data[i][0], c, MAC_PB520_BYTES);
+ pb[i].pb_rx.blk.data = &pb_data[i][0];
+ if (i != pb_length-1)
+ {
+ pb[i].pb_rx.blk.next = &pb[i+1].pb_rx.blk;
+ }
+ else
+ {
+ pb[i].pb_rx.blk.next = NULL;
+ }
+ c++;
+ }
+ for (i=0; i<3; i++)
+ {
+ iv[i] = i;
+ }
+ for (i=0; i<4; i++)
+ {
+ nek[i] = i;
+ }
+ phy_pbdma_start(ctx, true /* bypass_aes */, iv,
+ nek, (uint)pb_nb /* nb_total */, (uint)pb_nb /* nb_ready */,
+ (uint)pb_nb /* nb_pb_it */, &pb[0]);
+}
+
+
+void start_pbdma_chandata (void)
+{
+ diag_write_string("=> start_pbdma_chandata\n");
+
+ int i = 0;
+ char c = 0;
+
+ // For noise
+ int transfer_size = 128;
+ int chan_length = ((PHY_CARRIER_NB * sizeof(u16)) + ((4 * transfer_size) - 1 )) / (4 * transfer_size);
+
+ // Time noise
+ memset(time_chan_data, c, MAC_PB520_BYTES);
+ time_chan.blk.data = time_chan_data;
+ time_chan.blk.next = &freq_chan[0].blk;
+ time_chan.size = transfer_size;
+ time_chan.last = 0;
+ time_chan.type = PHY_CHANDATA_TYPE_NRJ_SYMBOL;
+ time_chan.address = 0;
+
+ // Frequency noise
+ for (i=0; i<chan_length; i++)
+ {
+ memset(&freq_chan_data[i][0], c, MAC_PB520_BYTES);
+ freq_chan[i].blk.data = &freq_chan_data[i][0];
+ if (i != chan_length-1)
+ {
+ freq_chan[i].blk.next = &freq_chan[i+1].blk;
+ freq_chan[i].last = 0;
+ }
+ else
+ {
+ freq_chan[i].blk.next = NULL;
+ freq_chan[i].last = 1;
+ }
+ freq_chan[i].size = transfer_size;
+ freq_chan[i].type = PHY_CHANDATA_TYPE_NRJ;
+ freq_chan[i].address = 0;
+ c++;
+ }
+
+ phy_pbdma_start_chandata(ctx, &time_chan);
+}
+
+
+bool phy_rx_fc_cb (void *user, u32 rx_date, const u32 *fc_av)
+{
+ diag_write_string("=> phy_rx_fc_cb\n");
+
+ // Reset IT
+ maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
+
+ // When the FC is received, prepare RX
+ phy_rx_prepare(ctx, short_ppdu, (phy_mod_t)mod,
+ (phy_fecrate_t)fecrate, (phy_pb_size_t)pb_size, (phy_gil_t)gil,
+ 0 /* tonemap_index */, 0 /* symbol_nb */);
+
+ return true;
+}
+
+
+bool phy_access_cb (void *user)
+{
+ diag_write_string("=> phy_access_cb\n");
+
+ // Reset IT
+ maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
+
+ return true;
+}
+
+
+bool phy_access_conf_cb (void *user)
+{
+ diag_write_string("=> phy_access_conf_cb\n");
+
+ // Reset IT
+ maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
+
+ return true;
+}
+
+
+bool phy_pbdma_cb (void *user, u32 status_word)
+{
+ diag_write_string("=> phy_pbdma_cb\n");
+
+ // Reset IT
+ maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PBDMA);
+
+ phy_pbdma_status_t status = *((phy_pbdma_status_t*)&status_word);
+ if (status.end_rx_pb)
+ {
+ // Set TX parameters
+ phy_tx_param (ctx, ctx->control.rx_param.fc_mode, ctx->control.rx_param.short_ppdu,
+ ctx->control.rx_param.mod, ctx->control.rx_param.fecrate, ctx->control.rx_param.pb_size,
+ ctx->control.rx_param.gil, ctx->control.rx_param.tonemap_index);
+ if (0 != ctx->control.rx_param.fc_10)
+ {
+ phy_tx_fc10 (ctx, ctx->control.rx_param.fc_10);
+ }
+
+ if (!ctx->control.rx_param.short_ppdu)
+ {
+ // Start PBDMA
+ phy_pbdma_start(ctx, ctx->pbdma.bypass_aes, ctx->pbdma.iv,
+ ctx->pbdma.nek, (uint)pb_nb /* nb_total */, (uint)pb_nb /* nb_ready */,
+ (uint)pb_nb /* nb_pb_it */, ctx->pbdma.first_pb);
+ }
+
+ phy_tx_frame (ctx, (u32)my_station.current_tick_tck + PHY_FC_10_PREPARATION_DELAY_TCK,
+ false /* want_conf */, false /* stop_tx_on_prp_lost */, ctx->control.rx_param.fc_av);
+ }
+
+ return true;
+}
+
+
+bool phy_tx_false_alarm_cb (void *user)
+{
+ diag_write_string("=> phy_tx_false_alarm_cb\n");
+
+ // Reset IT
+ maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
+
+ return true;
+}
+
+
+void phy_deferred_cb (void *user)
+{
+ diag_write_string("=> phy_deferred_cb\n");
+
+ return;
+}
+
+
+bool phy_extra_timer_cb (void *user)
+{
+ diag_write_string("=> phy_extra_timer_cb\n");
+
+ // Reset IT
+ maximus_pending_isrs &= (0 << PHY_HAL_INTERRUPT_PHY);
+
+ return true;
+}
+
+
+int set_tonemask (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ u8 tonemask[(PHY_CARRIER_NB+7)/8];
+ blk_t tonemap1;
+ blk_t tonemap2;
+ u8 tonemap1_data[MAC_PB520_BYTES];
+ u8 tonemap2_data[(PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES];
+ int i = 0;
+
+ diag_write_string("=> set_tonemask\n");
+
+ // Initialize the HAL 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);
+
+ // Enable assertions on warnings
+ ctx->warning_assert = true;
+
+ // Set TONEMASK
+ for (i=0; i<(PHY_CARRIER_NB+7)/8; i++)
+ {
+ tonemask[i] = 0xEE;
+ }
+ phy_set_tonemask(ctx, tonemask, PHY_CARRIER_NB);
+
+ // Set TONEMAP
+ memset(tonemap1_data, 'b', MAC_PB520_BYTES*sizeof(u8));
+ memset(tonemap2_data, 'c', ((PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES)*sizeof(u8));
+ tonemap2.next = NULL;
+ tonemap2.data = tonemap2_data;
+ tonemap1.next = &tonemap2;
+ tonemap1.data = tonemap1_data;
+ phy_set_tonemap(ctx, 0 /* tonemap_index */, &tonemap1);
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+
+int prepare_rx (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ diag_write_string("=> 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);
+ if (!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);
+ }
+
+ // Activate RX
+ phy_rx_activate(ctx, true /* now */, my_station.current_tick_tck, true /* pre_detection */);
+
+ // Set RX parameters
+ phy_rx_param(ctx, (phy_fc_mode_t)fc_mode);
+
+ if (!short_ppdu)
+ {
+ // Start PBDMA
+ start_pbdma();
+
+ // Start PBDMA chandata
+ start_pbdma_chandata();
+ }
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+
+int uninit_phy (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *data)
+{
+ diag_write_string("=> uninit_phy\n");
+
+ // Uninitialize the HAL PHY
+ phy_uninit (ctx);
+
+ /* now make the return parameter list */
+ fcall_param_reset(*param);
+
+ return 0;
+}
+
+
+int main (void)
+{
+ station_log_set_level(&my_station, STATION_LOG_DEBUG);
+ station_log_set_mask(&my_station, STATION_LOGTYPE_ALL);
+ my_station.pipe_log_fd = 1;
+
+ fcall_register(my_station.fcall, "set_tonemask", (void*)&set_tonemask, NULL);
+ fcall_register(my_station.fcall, "prepare_rx", (void*)&prepare_rx, NULL);
+ fcall_register(my_station.fcall, "uninit_phy", (void*)&uninit_phy, NULL);
+
+ return 0;
+}
+
diff --git a/cesar/maximus/stationtest/src/threaddelay.c b/cesar/maximus/stationtest/src/threaddelay.c
new file mode 100644
index 0000000000..f03a12f7ad
--- /dev/null
+++ b/cesar/maximus/stationtest/src/threaddelay.c
@@ -0,0 +1,50 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file threaddelay.c
+ * \brief test program for eCos compilation
+ * \ingroup
+ *
+ * this is a test program to check eCos well work with the tick timer
+ */
+
+#include <cyg/kernel/kapi.h>
+#include <cyg/infra/diag.h>
+
+#define MY_THREAD_STACK_SIZE (2048 / sizeof(int))
+
+int my_thread_stack[MY_THREAD_STACK_SIZE];
+cyg_handle_t my_thread_handle;
+cyg_thread my_thread_obj;
+
+void my_thread(cyg_addrword_t index)
+{
+ unsigned long my_counter = 0;
+ diag_write_string("my thread started\n");
+ while(1)
+ {
+ diag_printf("count=%ld, time=%lld\n",my_counter, cyg_current_time());
+ cyg_thread_delay(1000); //wait 10 seconds (1000 ecos ticks)
+ my_counter++;
+ }
+}
+
+void cyg_user_start(void)
+{
+
+ cyg_thread_create(12, my_thread, (cyg_addrword_t) 0,
+ "My Thread", &my_thread_stack, MY_THREAD_STACK_SIZE,
+ &my_thread_handle, &my_thread_obj);
+
+ cyg_thread_resume(my_thread_handle);
+
+ diag_write_string("Starting Scheduler... ");
+
+ cyg_scheduler_start();
+}
+