summaryrefslogtreecommitdiff
path: root/cesar/maximus/prototest
diff options
context:
space:
mode:
Diffstat (limited to 'cesar/maximus/prototest')
-rw-r--r--cesar/maximus/prototest/fcall/src/test_fcall.c24
-rw-r--r--cesar/maximus/prototest/integration/Makefile4
-rw-r--r--cesar/maximus/prototest/integration/src/cl_stub.c112
-rw-r--r--cesar/maximus/prototest/integration/src/test_integration.c49
4 files changed, 179 insertions, 10 deletions
diff --git a/cesar/maximus/prototest/fcall/src/test_fcall.c b/cesar/maximus/prototest/fcall/src/test_fcall.c
index d7a9290342..b346b9dabb 100644
--- a/cesar/maximus/prototest/fcall/src/test_fcall.c
+++ b/cesar/maximus/prototest/fcall/src/test_fcall.c
@@ -14,11 +14,13 @@
*/
#include <cyg/infra/diag.h>
#include <cyg/kernel/kapi.h>
+#include <malloc.h>
#include <errno.h>
#include "common/std.h"
#include "interface/fcall/interface_fcall.h"
#include "interface/fcall/inc/interface_fcall.h"
#include "lib/read_word.h"
+#include "lib/swap.h" // for 'swap16()'
#include "maximus/prototest/fcall/inc/syscall.h"
#define MY_THREAD_STACK_SIZE (8192 / sizeof(int))
@@ -33,21 +35,19 @@ int proto_in_fd = -1, proto_out_fd = -1;
void my_thread(cyg_addrword_t index)
{
- static u8 my_mme[SCI_MSG_MAX_SIZE];
- static u8 my_buffer[SCI_MSG_MAX_SIZE];
int len = 0, data_length = 0;
+ u8 *my_mme;
diag_write_string("=> my_thread\n");
while(1)
{
- memset(my_mme, 0x00, SCI_MSG_MAX_SIZE);
- memset(my_buffer, 0x00, SCI_MSG_MAX_SIZE);
+ my_mme = malloc(SCI_MSG_MAX_SIZE);
while (INTERFACE_FCALL_PAYLOAD_OFFSET != len)
{
len = read(proto_in_fd, my_mme, INTERFACE_FCALL_PAYLOAD_OFFSET);
}
dbg_assert(INTERFACE_FCALL_PAYLOAD_OFFSET == len);
- data_length = read_u16_from_word(my_mme + INTERFACE_FCALL_PAYLOAD_OFFSET - sizeof(u16));
+ data_length = swap16(read_u16_from_word(my_mme + INTERFACE_FCALL_PAYLOAD_OFFSET - sizeof(u16)));
if ((len = read(proto_in_fd, my_mme + INTERFACE_FCALL_PAYLOAD_OFFSET, data_length)) < 0)
{
diag_write_string("error when reading proto in file\n");
@@ -56,7 +56,7 @@ void my_thread(cyg_addrword_t index)
diag_printf("READ len = %d - data length = %d\n", len, data_length);
dbg_assert(len == data_length);
diag_write_string("=> interface_fcall_mme_recv\n");
- interface_fcall_mme_recv (ctx, my_mme, my_buffer);
+ interface_fcall_mme_recv (ctx, my_mme);
}
}
@@ -82,6 +82,7 @@ my_interface_hle_send (void *user_data, uint *message, uint length)
diag_printf("WRITE len = %d - data length = %d\n", len, data_length);
diag_write_string("END interface_hle_send\n");
+ free(data);
return;
}
@@ -92,10 +93,20 @@ my_interface_hle_send_done (void *user_data, u8 *message)
dbg_assert_ptr(message);
diag_write_string("=> interface_hle_send_done\n");
+ free(message);
+ diag_write_string("END interface_hle_send_done\n");
return;
}
+u8 *
+my_interface_fcall_get_buffer_cb (void *user_data)
+{
+ u8 *buffer;
+ buffer = malloc(SCI_MSG_MAX_SIZE);
+ return buffer;
+}
+
typedef struct my_struct
{
int i1;
@@ -288,6 +299,7 @@ cyg_user_start(void)
int user_data = 123;
ctx = interface_fcall_init (&my_interface_hle_send,
&my_interface_hle_send_done,
+ &my_interface_fcall_get_buffer_cb,
&user_data);
fcall_register(ctx->fcall_ctx, "function_1", (void*)&my_function1, NULL);
diff --git a/cesar/maximus/prototest/integration/Makefile b/cesar/maximus/prototest/integration/Makefile
index f11e373035..91d16e46ef 100644
--- a/cesar/maximus/prototest/integration/Makefile
+++ b/cesar/maximus/prototest/integration/Makefile
@@ -8,7 +8,7 @@ EXTRA_TARGET_CFLAGS+= -DFCALL_PROTO
TARGET_PROGRAMS = test_integration
-test_integration_SOURCES = test_integration.c
-test_integration_MODULES = lib hal/phy interface interface/fcall hal/hle hle mac cl
+test_integration_SOURCES = test_integration.c cl_stub.c
+test_integration_MODULES = lib hal/phy interface interface/fcall hal/hle hle mac
include $(BASE)/common/make/top.mk \ No newline at end of file
diff --git a/cesar/maximus/prototest/integration/src/cl_stub.c b/cesar/maximus/prototest/integration/src/cl_stub.c
new file mode 100644
index 0000000000..9b65288d2f
--- /dev/null
+++ b/cesar/maximus/prototest/integration/src/cl_stub.c
@@ -0,0 +1,112 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file cl_stub.c
+ * \brief cl stub for integration test program
+ * \ingroup maximus/prototest/integration
+ *
+ *
+ */
+#include "common/std.h"
+#include "cl/cl.h"
+#include "cl/inc/cl.h"
+#include <stdlib.h>
+
+static cl_t cl_global;
+
+cl_t *cl_init (mac_store_t *mac_store, sar_t *sar, mac_config_t *mac_config)
+{
+ return &cl_global;
+}
+
+void cl_uninit (cl_t *ctx)
+{
+}
+
+void cl_mme_ul_init_send_done (cl_t *ctx, cl_mme_ul_recv_done_cb_t cb,
+ void *user)
+{
+ dbg_assert (ctx);
+ dbg_assert (cb);
+
+ ctx->mme.ul_mme_recv_done = cb;
+ ctx->mme.ul_mme_recv_done_user_data = user;
+}
+
+void cl_mme_recv_init (cl_t *ctx, cl_mme_recv_cb_t mme_recv_cb, void *user)
+{
+}
+
+void cl_mme_init_ul_as_data (cl_t *ctx, cl_mme_ul_send_done_cb_t cb,
+ void *user)
+{
+}
+
+void cl_mme_init_buffer_add_cb (cl_t *cl, cl_mme_buffer_add_cb_t cb,
+ void *user_data)
+{
+}
+
+
+void cl_mme_send_as_mme (cl_t *ctx, u8 *buffer, uint length, mfs_tx_t *mfs)
+{
+}
+
+void cl_mme_send_as_data (cl_t *ctx, u8 *buffer, uint length)
+{
+}
+
+void cl_mme_sar_send_done (cl_t *ctx, u8 *buffer)
+{
+}
+
+void cl_mme_recv (cl_t *ctx, u8 *buffer, uint length, mfs_rx_t *mfs, bool
+ encryption)
+{
+}
+
+void cl_mme_recv_done (cl_t *ctx, cl_mme_recv_t *mme_recv)
+{
+}
+
+void cl_data_send_done_init (cl_t *cl, cl_data_send_done_cb_t cb, void *user)
+{
+ dbg_assert (cl);
+ dbg_assert (cb);
+
+ cl->data_tx.cb = cb;
+ cl->data_tx.user = user;
+}
+
+void cl_data_send_done (cl_t *ctx, u8 *buffer)
+{
+}
+
+void cl_data_send (cl_t *cl, u8 *buffer, uint length)
+{
+ dbg_assert (cl);
+ dbg_assert (buffer);
+}
+
+void cl_data_recv_init (cl_t *cl, cl_data_recv_cb_t cb, void *user)
+{
+ dbg_assert (cl);
+ dbg_assert (cb);
+}
+
+void cl_data_recv (cl_t *ctx, u8 *buffer, uint length, mfs_rx_t *mfs)
+{
+}
+
+void cl_mme_buffer_add (cl_t *cl, u8 *buffer)
+{
+}
+
+void cl_data_buffer_add (cl_t *cl, u8 *buffer)
+{
+}
diff --git a/cesar/maximus/prototest/integration/src/test_integration.c b/cesar/maximus/prototest/integration/src/test_integration.c
index 033358ed0f..62dcf11c57 100644
--- a/cesar/maximus/prototest/integration/src/test_integration.c
+++ b/cesar/maximus/prototest/integration/src/test_integration.c
@@ -67,6 +67,7 @@ my_return_function (void *data)
/* now make the return parameter list */
fcall_param_reset(&return_param);
+ //my_param4 = (swap32((u32)(my_param4 >> 32)) << 32) | swap32((u32)my_param4);
fcall_param_add(&return_param, &return_msg, "result_2", sizeof(my_type_t), &my_param4);
fcall_return(interface_ctx->fcall->fcall_ctx, &return_param, &return_msg);
@@ -87,7 +88,15 @@ my_function1 (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *
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);
-
+/*
+ my_param1.i1 = swap32(my_param1.i1);
+ my_param1.i2 = swap32(my_param1.i2);
+ for (i=0; i<10; i++)
+ {
+ my_param2[i] = swap32(my_param2[i]);
+ }
+ my_param4 = (swap32((u32)(my_param4 >> 32)) << 32) | swap32((u32)my_param4);
+*/
/* do other tasks ... */
diag_write_string("=> my_function1\n");
diag_printf("param 1 . i1 = %d\n", my_param1.i1);
@@ -215,16 +224,52 @@ my_function5 (fcall_ctx_t *fcall, fcall_param_t **param, sci_msg_t **msg, void *
return 0;
}
+/**
+* CP receives a new MME.
+* \param user_data the data registered by the actor in the init function
+* \param mfs the mfs
+* \param buffer the buffer containing the MME
+* \param length the MME length
+* \param mme_recv data use by the data plane
+* \param encryption inform if the packet comes from the PWL if it had been crypted or not
+*/
+void
+cp_mme_recv (void *user_data,
+ mfs_rx_t *mfs,
+ u8 *buffer,
+ uint length,
+ void *mme_recv,
+ bool encryption)
+{
+ interface_mme_recv_done (interface_ctx, mme_recv);
+}
+
+/**
+* CP receives a empty buffer.
+* \param user_data the data registered by the actor in the init function
+* \param buffer the buffer to add
+*/
+void
+cp_mme_buffer_add (void *user_data, u8 *buffer)
+{
+ /* nothing to do */
+}
+
void
cyg_user_start(void)
{
hle_ctx = hle_init (&cl_ctx);
-
interface_ctx = interface_init (hle_ctx,
&cl_ctx,
&sar_ctx,
&mac_config_ctx);
+ /* stub the interface communication with the CP */
+ interface_callback_init (interface_ctx,
+ cp_mme_recv,
+ cp_mme_buffer_add,
+ NULL);
+
ipmbox_activate(NULL, true);
fcall_register(interface_ctx->fcall->fcall_ctx, "function_1", (void*)&my_function1, NULL);