summaryrefslogtreecommitdiff
path: root/hle
diff options
context:
space:
mode:
Diffstat (limited to 'hle')
-rw-r--r--hle/Module1
-rw-r--r--hle/hle.h135
-rw-r--r--hle/inc/context.h30
-rw-r--r--hle/src/hle.c279
-rw-r--r--hle/test/Makefile17
-rw-r--r--hle/test/overide/cl/Module1
-rw-r--r--hle/test/overide/cl/cl.h173
-rw-r--r--hle/test/overide/cl/inc/cl.h83
-rw-r--r--hle/test/overide/cl/src/cl.c209
-rw-r--r--hle/test/overide/hal/hle/Module1
-rw-r--r--hle/test/overide/hal/hle/ipmbox.h32
-rw-r--r--hle/test/overide/hal/hle/src/ipmbox.c32
-rw-r--r--hle/test/src/hle_add_buffer.c83
-rw-r--r--hle/test/src/hle_recv_from_arm.c102
-rw-r--r--hle/test/src/hle_send_to_arm.c76
15 files changed, 1254 insertions, 0 deletions
diff --git a/hle/Module b/hle/Module
new file mode 100644
index 0000000000..74a5673a11
--- /dev/null
+++ b/hle/Module
@@ -0,0 +1 @@
+SOURCES := hle.c
diff --git a/hle/hle.h b/hle/hle.h
new file mode 100644
index 0000000000..cca4c7b380
--- /dev/null
+++ b/hle/hle.h
@@ -0,0 +1,135 @@
+#ifndef HLE_H_
+#define HLE_H_
+
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hle.h
+ * \brief Public functions
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+#define HLE_MSG_TYPE_DATA 0x00
+#define HLE_MSG_TYPE_MME 0x01
+#define HLE_MSG_TYPE_BUFFER_ADD 0x02
+#define HLE_MSG_TYPE_BUFFER_RELEASE 0x03
+
+#include "cl/cl.h"
+
+/** forward declaration */
+typedef struct hle_t hle_t;
+
+/**
+ * Initialize the HLE.
+ *
+ * \param cl the convergence layer context.
+ * \return the hle context
+ */
+hle_t *hle_init (cl_t *cl);
+
+/**
+ * Unitialize the HLE.
+ *
+ * \param hle the hle context.
+ */
+void hle_uninit (hle_t *hle);
+
+/**
+ * Send a data to the Convergence Layer to be sent over the PWL.
+ *
+ * \param hle the hle context.
+ * \param buffer the buffer containing the data to send.
+ * \param length the data length
+ */
+void hle_data_send (hle_t *hle, u8 *buffer, uint length);
+
+/**
+ * Called by the Convergence layer when the data has been sent to the PWL.
+ * This allows the HLE to know which buffer is newly available to be used or
+ * give it back to the ARM. (the buffer is borrowed by the linux).
+ *
+ * \param hle the hle context.
+ * \param buffer the buffer used to send the data.
+ */
+void hle_data_send_done (hle_t *hle, u8 *buffer);
+
+/**
+ * Receives a data from the Convergence layer.
+ *
+ * \param hle the hle context.
+ * \param buffer the buffer used to receive the data
+ * \param length the length of the data received.
+ */
+void hle_data_recv (hle_t *hle, u8 *buffer, uint length);
+
+/**
+ * Provides a buffer to the CL in order to receive new MMEs from the CP.
+ *
+ * \param hle the hle context.
+ * \param buffer the buffer to provide to the CL.
+ */
+void hle_data_add_buffer (hle_t *hle, u8 *buffer);
+
+/**
+ * Send a MME to the Convergence Layer to be provide to the CP.
+ *
+ * \param hle the hle context.
+ * \param buffer the buffer containing the data to send.
+ * \param length the data length
+ */
+void hle_mme_send (hle_t *hle, u8 *buffer, uint length);
+
+/**
+ * Called by the Convergence layer when the data has been sent to the CP.
+ * This allows the HLE to know which buffer is newly available to be used or
+ * give it back to the ARM. (the buffer is borrowed by the linux).
+ *
+ * \param hle the hle context.
+ * \param buffer the buffer used to send the data.
+ */
+void hle_mme_send_done (hle_t *hle, u8 *buffer);
+
+/**
+ * Receives a data from the Convergence layer.
+ *
+ * \param hle the hle context.
+ * \param buffer the buffer used to receive the data
+ * \param length the length of the data received.
+ */
+void hle_mme_recv (hle_t *hle, u8 *buffer, uint length);
+
+/**
+ * Provides a buffer to the CL in order to receive new MMEs from the CP.
+ *
+ * \param hle the hle context.
+ * \param buffer the buffer to provide to the CL.
+ */
+void hle_mme_add_buffer (hle_t *hle, u8 *buffer);
+
+/**
+ * Receives a message from the Linux.
+ *
+ * \param msgs the pointer of the buffer containing the messages to read
+ * \param length the length of the messages in words.
+ * \param hle the hle context.
+ */
+bool hle_ipmbox_deffered_recv (uint *msgs, uint length, hle_t *hle);
+
+/**
+ * Unused actually
+ *
+ * \param msgs the pointer of the buffer containing the messages to read
+ * \param length the length of the messages in words.
+ * \param user_data the hle context.
+ */
+bool hle_ipmbox_deffered_send_done (u32 *msg_buffer, uint length,
+ void *user_data);
+
+#endif /*HLE_H_*/
diff --git a/hle/inc/context.h b/hle/inc/context.h
new file mode 100644
index 0000000000..668d07dba5
--- /dev/null
+++ b/hle/inc/context.h
@@ -0,0 +1,30 @@
+#ifndef hle_inc_context_h
+#define hle_inc_context_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hle/inc/context.h
+ * \brief HLE context.
+ * \ingroup hle
+ *
+ * « long description »
+ */
+
+#include "lib/read_word.h"
+#include "hal/hle/ipmbox.h"
+
+struct hle_t
+{
+ /** CL context */
+ cl_t *cl;
+
+ /** ipmbox context */
+ ipmbox_t *ipmbox;
+};
+
+#endif /* hle_inc_context_h */
diff --git a/hle/src/hle.c b/hle/src/hle.c
new file mode 100644
index 0000000000..c38ae280bb
--- /dev/null
+++ b/hle/src/hle.c
@@ -0,0 +1,279 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file hle.c
+ * \brief function of the HLE
+ * \ingroup hle
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include "hal/hle/ipmbox.h"
+#include "hle/hle.h"
+#include "cl/cl.h"
+
+#include "hle/inc/context.h"
+
+/** Hle global context */
+static hle_t hle_global;
+
+/**
+ * Initialize the HLE.
+ *
+ * \param cl the convergence layer context.
+ * \return the hle context
+ */
+hle_t *hle_init (cl_t *cl)
+{
+ dbg_assert (cl);
+
+ hle_global.cl = cl;
+
+ /** Intialize the CL data call backs. */
+ cl_data_recv_init (cl, (cl_data_recv_cb_t) hle_data_recv, &hle_global);
+ cl_data_send_done_init (cl, (cl_data_send_done_cb_t) hle_data_send_done,
+ &hle_global);
+
+ /** Intialize the CL MMEs call backs. */
+ cl_mme_init_ul_as_data (cl, (cl_mme_send_ul_cb_t) hle_mme_recv,
+ &hle_global);
+ cl_mme_ul_init_recv_done (cl,
+ (cl_mme_ul_recv_done_cb_t) hle_mme_send_done, &hle_global);
+
+ /** Intialize the ipmbox */
+ hle_global.ipmbox = ipmbox_init (&hle_global,
+ (ipmbox_tx_cb_t) hle_ipmbox_deffered_recv,
+ hle_ipmbox_deffered_send_done,
+ (ipmbox_deferred_cb_t) hle_ipmbox_deffered_recv);
+
+ return &hle_global;
+}
+
+/**
+ * Unitialize the HLE.
+ *
+ * \param hle the hle context.
+ */
+void hle_uninit (hle_t *hle)
+{
+ dbg_assert (hle);
+}
+
+/**
+ * Send a data to the Convergence Layer to be sent over the PWL.
+ *
+ * \param hle the hle context.
+ * \param buffer the buffer containing the data to send.
+ * \param length the data length
+ */
+void hle_data_send (hle_t *hle, u8 *buffer, uint length)
+{
+ dbg_assert (hle);
+ dbg_assert (buffer);
+ dbg_assert (68 <= length && length <= 1518);
+
+ cl_data_send (hle->cl, buffer, length);
+}
+
+/**
+ * Called by the Convergence layer when the data has been sent to the PWL.
+ * This allows the HLE to know which buffer is newly available to be used or
+ * give it back to the ARM. (the buffer is borrowed by the linux).
+ *
+ * \param hle the hle context.
+ * \param buffer the buffer used to send the data.
+ */
+void hle_data_send_done (hle_t *hle, u8 *buffer)
+{
+ dbg_assert (hle);
+ dbg_assert (buffer);
+ dbg_assert (hle->ipmbox);
+
+ uint word[2];
+
+ word[0] = HLE_MSG_TYPE_BUFFER_RELEASE | (1 << 8);
+ word[1] = (uint) buffer;
+
+ ipmbox_tx (hle->ipmbox, word, 2);
+}
+
+/**
+ * Receives a data from the Convergence layer.
+ *
+ * \param hle the hle context.
+ * \param buffer the buffer used to receive the data
+ * \param length the length of the data received.
+ */
+void hle_data_recv (hle_t *hle, u8 *buffer, uint length)
+{
+ dbg_assert (hle);
+ dbg_assert (buffer);
+ dbg_assert (68 <= length && length <= 1518);
+
+ uint word[2];
+
+ word[0] = HLE_MSG_TYPE_DATA | (1 << 8) | (length << 12);
+ word[1] = (uint) buffer;
+
+ ipmbox_tx (hle->ipmbox, word, 2);
+}
+
+/**
+ * Provides a buffer to the CL in order to receive new MMEs from the CP.
+ *
+ * \param hle the hle context.
+ * \param buffer the buffer to provide to the CL.
+ */
+void hle_data_add_buffer (hle_t *hle, u8 *buffer)
+{
+ dbg_assert (hle);
+ dbg_assert (buffer);
+ dbg_assert (hle->cl);
+
+ cl_sar_add_buffer_data (hle->cl, buffer);
+}
+
+/**
+ * Send a MME to the Convergence Layer to be provide to the CP.
+ *
+ * \param hle the hle context.
+ * \param buffer the buffer containing the data to send.
+ * \param length the data length
+ */
+void hle_mme_send (hle_t *hle, u8 *buffer, uint length)
+{
+ dbg_assert (hle);
+ dbg_assert (buffer);
+ dbg_assert (68 <= length && length <= 1518);
+
+ cl_mme_ul_recv (hle->cl, buffer, length);
+}
+
+/**
+ * Called by the Convergence layer when the data has been sent to the CP.
+ * This allows the HLE to know which buffer is newly available to be used or
+ * give it back to the ARM. (the buffer is borrowed by the linux).
+ *
+ * \param hle the hle context.
+ * \param buffer the buffer used to send the data.
+ */
+void hle_mme_send_done (hle_t *hle, u8 *buffer)
+{
+ dbg_assert (hle);
+ dbg_assert (buffer);
+ dbg_assert (hle->ipmbox);
+
+ uint word[2];
+
+ word[0] = HLE_MSG_TYPE_BUFFER_RELEASE | (1 << 8);
+ word[1] = (uint) buffer;
+
+ ipmbox_tx (hle->ipmbox, word, 2);
+}
+
+/**
+ * Receives a MME from the Convergence layer.
+ *
+ * \param hle the hle context.
+ * \param buffer the buffer used to receive the data
+ * \param length the length of the data received.
+ */
+void hle_mme_recv (hle_t *hle, u8 *buffer, uint length)
+{
+ dbg_assert (hle);
+ dbg_assert (buffer);
+ dbg_assert (68 <= length && length <= 1518);
+
+ uint word[2];
+
+ word[0] = HLE_MSG_TYPE_MME | (1 << 8) | (length << 12);
+ word[1] = (uint) buffer;
+
+ ipmbox_tx (hle->ipmbox, word, 2);
+}
+
+/**
+ * Provides a buffer to the CL in order to receive new MMEs from the CP.
+ *
+ * \param hle the hle context.
+ * \param buffer the buffer to provide to the CL.
+ */
+void hle_mme_add_buffer (hle_t *hle, u8 *buffer)
+{
+ dbg_assert (hle);
+ dbg_assert (buffer);
+ dbg_assert (hle->cl);
+
+ cl_sar_add_buffer_mme (hle->cl, buffer);
+}
+
+/**
+ * Receives a message from the Linux.
+ *
+ * \param msgs the pointer of the buffer containing the messages to read
+ * \param length the length of the messages in words.
+ * \param hle the hle context.
+ */
+bool hle_ipmbox_deffered_recv (uint *msgs, uint length, hle_t *hle)
+{
+ dbg_assert (msgs);
+ dbg_assert (hle);
+
+ uint length_processed;
+ uint msg;
+
+ length_processed = 0;
+ while (length_processed < length)
+ {
+ msg = read_u32_from_word ((u8 *) (msgs + length_processed));
+ length_processed ++;
+
+ switch (msg & 0xFF)
+ {
+ case HLE_MSG_TYPE_DATA:
+ msg = (msg >> 12) & 0x7FF;
+ hle_data_send (hle, (u8 *) (msgs + length_processed), msg);
+ length_processed ++;
+ break;
+ case HLE_MSG_TYPE_MME:
+ msg = (msg >> 12) & 0x7FF;
+ hle_mme_send (hle, (u8 *) (msgs + length_processed), msg);
+ length_processed ++;
+ break;
+ case HLE_MSG_TYPE_BUFFER_ADD:
+ if (msg >> 12 == 0)
+ {
+ hle_data_add_buffer (hle, (u8 *) *(msgs
+ + length_processed));
+ }
+ else
+ {
+ hle_mme_add_buffer (hle,
+ (u8 *) *(msgs + length_processed));
+ }
+ length_processed ++;
+ break;
+ }
+ }
+
+ return true;
+}
+
+/**
+ * Unused actually
+ *
+ * \param msgs the pointer of the buffer containing the messages to read
+ * \param length the length of the messages in words.
+ * \param user_data the hle context.
+ */
+bool hle_ipmbox_deffered_send_done (u32 *msg_buffer, uint length,
+ void *user_data)
+{
+ return true;
+}
diff --git a/hle/test/Makefile b/hle/test/Makefile
new file mode 100644
index 0000000000..1ed3d5871e
--- /dev/null
+++ b/hle/test/Makefile
@@ -0,0 +1,17 @@
+BASE = ../..
+
+INCLUDES = hle/test/overide
+
+HOST_PROGRAMS = hle_recv_from_arm hle_add_buffer hle_send_to_arm
+
+hle_recv_from_arm_SOURCES = hle_recv_from_arm.c
+hle_recv_from_arm_MODULES = lib hle hle/test/overide/cl \
+ hle/test/overide/hal/hle
+
+hle_add_buffer_SOURCES = hle_add_buffer.c
+hle_add_buffer_MODULES = lib hle hle/test/overide/cl hle/test/overide/hal/hle
+
+hle_send_to_arm_SOURCES = hle_send_to_arm.c
+hle_send_to_arm_MODULES = lib hle hle/test/overide/cl hle/test/overide/hal/hle
+
+include $(BASE)/common/make/top.mk
diff --git a/hle/test/overide/cl/Module b/hle/test/overide/cl/Module
new file mode 100644
index 0000000000..b0caf505d6
--- /dev/null
+++ b/hle/test/overide/cl/Module
@@ -0,0 +1 @@
+SOURCES := cl.c \ No newline at end of file
diff --git a/hle/test/overide/cl/cl.h b/hle/test/overide/cl/cl.h
new file mode 100644
index 0000000000..525eb3936d
--- /dev/null
+++ b/hle/test/overide/cl/cl.h
@@ -0,0 +1,173 @@
+#ifndef test_overide_cl_cl_h
+#define test_overide_cl_cl_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test/overide/cl/cl.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+typedef struct cl_t cl_t;
+typedef uint cl_mme_recv_t;
+
+// for the tests;
+typedef uint mac_store_t;
+typedef uint sar_t;
+
+/**
+ * Callback to provide a received data to the upper layer comming from the SAR.
+ *
+ * \param user the user data
+ * \param buffer the buffer containing the data
+ * \param length the data length in the buffer.
+ */
+typedef void (*cl_data_recv_cb_t) (void *user, u8 *buffer, uint length);
+
+/**
+ * Callback use to inform the upper layer when a data hab been sent over the
+ * PLC.
+ *
+ * \param user the user data
+ * \param buffer the buffer use to send the data over the PLC.
+ */
+typedef void (*cl_data_send_done_cb_t) (void *user, u8 *buffer);
+
+/**
+ * Call back to use when the CL needs to send a MME to the upper layer.
+ *
+ * \param ul_data the upper layer data provided on the registration.
+ * \param buffer the buffer containig the MME.
+ * \param length the length of the MME
+ */
+typedef void (*cl_mme_send_ul_cb_t) (void *ul_data, u8 *buffer, uint length);
+
+/**
+ * Call back to use once a MME had been sent to the HLE or to the SAR.
+ *
+ * \param user the user data
+ */
+typedef void (*cl_mme_send_done_cb_t) (void *user, u8* buffer);
+
+/**
+ * Callback definition used by the CL when the CP had processed the MME
+ * in the buffer. This will return the buffer to the upper layer.
+ *
+ * \param user_data the upper layer user data
+ * \param buffer the buffer containing the MME.
+ */
+typedef void (*cl_mme_ul_recv_done_cb_t) (void *user_data, u8 *buffer);
+
+
+/**
+ * Init the Convergence Layer and return a pointer on the CL context.
+ *
+ * \param mac_store the mac store.
+ * \param sar the sar context.
+ * \return the convergence layer context.
+ */
+cl_t *cl_init (mac_store_t *mac_store, sar_t *sar);
+
+/**
+ * Initialize the callback to receive the data from the PLC to the upper layer.
+ *
+ * \param cl the CL context
+ * \param cb the function callback to call
+ * \param user the user data to provide on the callback.
+ */
+void cl_data_recv_init (cl_t *cl, cl_data_recv_cb_t cb, void *user);
+
+/**
+ * Initialize the callback to inform the upper layer when a data had been sent
+ * over the PLC.
+ *
+ * \param cl the CL context
+ * \param cb the callback to call once the data had been sent
+ * \param user the user data to provide with the callback call
+ */
+void cl_data_send_done_init (cl_t *cl, cl_data_send_done_cb_t cb, void *user);
+
+/**
+ * Initialize the CL to send MMEs to the Upper layer considered as data.
+ * Used each time the CP needs to send an MME to the upper layer.
+ *
+ * \param ctx the CL context
+ * \param cb the upper layer callback to use to send an MME.
+ * \param user the user data to provide with the callback
+ */
+void cl_mme_init_ul_as_data (cl_t *ctx, cl_mme_send_ul_cb_t cb, void *user);
+
+/**
+ * Send a data from the upper layer to the SAR, this data should be sent over
+ * the PLC.
+ *
+ * \param cl the CL context.
+ * \param buffer the buffer containing the data to send
+ * \param length the data length
+ */
+void cl_data_send (cl_t *cl, u8 *buffer, uint length);
+
+/**
+ * The SAR inform the CL that the data previously provided had been sent over
+ * the PLC.
+ *
+ * \param ctx the CL context.
+ * \param buffer the buffer containing the MME
+ */
+void cl_data_send_done (void *ctx, u8 *buffer);
+
+/**
+ * Provides a buffer to the SAR to reassembly data
+ *
+ * \param cl the CL context
+ * \param buffer the buffer to reassembly some datas
+ * \return true if the buffer has been added, flase otherwise.
+ */
+bool cl_sar_add_buffer_data (cl_t *cl, u8 *buffer);
+
+/**
+ * Receives an MME from the Upper layer.
+ * It will provide this MME to the Control Plane to be processed.
+ *
+ * \param ctx the cl context
+ * \param buffer the MME buffer
+ * \param length the MME length
+ */
+void cl_mme_ul_recv (cl_t *ctx, u8 *buffer, uint length);
+
+/**
+ * Initialize the CL to call the Upper layer once the CP ends processing the
+ * MME.
+ * Used each time the CP needs to send an MME to the upper layer.
+ *
+ * \param ctx the CL context
+ * \param cb the upper layer callback to use to send an MME.
+ * \param user the user data to provide with the callback
+ */
+void cl_mme_ul_init_recv_done (cl_t *ctx, cl_mme_ul_recv_done_cb_t cb,
+ void *user);
+
+/**
+ * Provides a buffer to the SAR to reassembly data
+ *
+ * \param cl the CL context
+ * \param buffer the buffer to reassembly some datas
+ * \return true if the buffer has been added, flase otherwise.
+ */
+bool cl_sar_add_buffer_mme (cl_t *cl, u8 *buffer);
+
+/**
+ * Uninit the Convergence layer context.
+ *
+ * \param ctx the convergence layer context
+ */
+void cl_uninit (cl_t *ctx);
+
+#endif /* test_overide_cl_cl_h */
diff --git a/hle/test/overide/cl/inc/cl.h b/hle/test/overide/cl/inc/cl.h
new file mode 100644
index 0000000000..07cf11ab72
--- /dev/null
+++ b/hle/test/overide/cl/inc/cl.h
@@ -0,0 +1,83 @@
+#ifndef overide_cl_inc_cl_h
+#define overide_cl_inc_cl_h
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file overide/cl/inc/cl.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+/** data tx structure. */
+struct cl_data_tx_t
+{
+ /** the callback function to use once the data hab been sent. */
+ cl_data_send_done_cb_t cb;
+ /** user data to provide with the callback. */
+ void *user;
+};
+typedef struct cl_data_tx_t cl_data_tx_t;
+
+/** data tx structure. */
+struct cl_data_rx_t
+{
+ /** callback to call the upperlayer once the CL receives a data. */
+ cl_data_recv_cb_t cb;
+ /** user value to provide with the function callback. */
+ void *user;
+};
+typedef struct cl_data_rx_t cl_data_rx_t;
+
+/** MME tx structure to the upper layer*/
+struct cl_mme_tx_t
+{
+ /** function to call when a mme is for the driver */
+ cl_data_recv_cb_t cb;
+ /** user data */
+ void *user;
+ /** mme buffer address */
+ u8 *mme_buffer;
+};
+typedef struct cl_mme_tx_t cl_mme_tx_t;
+
+/** cl mme context */
+struct cl_mme_t
+{
+ /** The Call back to inform the upper layer when a MME has been processed
+ * */
+ cl_mme_ul_recv_done_cb_t ul_mme_recv_done;
+ void *ul_mme_recv_done_user_data;
+
+ /** The callback to use once the MME had been sent. */
+ cl_mme_send_done_cb_t mme_send_done_cb;
+ /** The user data to provide with the bellow callback. */
+ void *mme_send_done_user_data;
+
+ /** Data corresponding to the mme_recv message send to the CP. */
+ cl_mme_recv_t mme_recv;
+};
+typedef struct cl_mme_t cl_mme_t;
+
+struct cl_t
+{
+ /** send data context. */
+ cl_data_tx_t data_tx;
+
+ /** recevie data context. */
+ cl_data_rx_t data_rx;
+
+ /** When a MME is send as data to the local tei */
+ cl_mme_tx_t mme_ul_send;
+
+ /** MME module to use to send or receive the MME to the CP. */
+ cl_mme_t mme;
+};
+
+#endif /* overide_cl_inc_cl_h */
diff --git a/hle/test/overide/cl/src/cl.c b/hle/test/overide/cl/src/cl.c
new file mode 100644
index 0000000000..e0cfdee329
--- /dev/null
+++ b/hle/test/overide/cl/src/cl.c
@@ -0,0 +1,209 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file src/cl.c
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include <stdlib.h>
+
+#include "cl/cl.h"
+#include "cl/inc/cl.h"
+
+static cl_t cl_global;
+
+/**
+ * Init the Convergence Layer and return a pointer on the CL context.
+ *
+ * \param mac_store the mac store.
+ * \param sar the sar context.
+ * \return the convergence layer context.
+ */
+cl_t *cl_init (mac_store_t *mac_store, sar_t *sar)
+{
+ return &cl_global;
+}
+
+/**
+ * Initialize the callback to receive the data from the PLC.
+ *
+ * \param cl the CL context
+ * \param cb the function callback to call
+ * \param user the user data to provide on the callback.
+ */
+void cl_data_recv_init (cl_t *cl, cl_data_recv_cb_t cb, void *user)
+{
+ dbg_assert (cl);
+ dbg_assert (cb);
+
+ cl->data_rx.cb = cb;
+ cl->data_rx.user = user;
+}
+
+/**
+ * Initialize the callback to inform the upper layer when a data had been sent
+ * over the PLC.
+ *
+ * \param cl the CL context
+ * \param cb the callback to call once the data had been sent
+ * \param user the user data to provide with the callback call
+ */
+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;
+}
+
+/**
+ * Initialize the CL to send MMEs to the Upper layer considered as data.
+ * Used each time the CP needs to send an MME to the upper layer.
+ *
+ * \param ctx the CL context
+ * \param cb the upper layer callback to use to send an MME.
+ * \param user the user data to provide with the callback
+ */
+void cl_mme_init_ul_as_data (cl_t *ctx, cl_mme_send_ul_cb_t cb, void *user)
+{
+ dbg_assert (ctx);
+ dbg_assert (cb);
+
+ ctx->mme_ul_send.cb = cb;
+ ctx->mme_ul_send.user = user;
+ ctx->mme_ul_send.mme_buffer = NULL;
+}
+
+/**
+ * Send a data from the upper layer to the SAR, this data should be sent over
+ * the PLC.
+ *
+ * \param cl the CL context.
+ * \param buffer the buffer containing the data to send
+ * \param length the data length
+ */
+void cl_data_send (cl_t *cl, u8 *buffer, uint length)
+{
+ dbg_assert (cl);
+
+ cl_data_send_done (cl, buffer);
+}
+
+/**
+ * The SAR inform the CL that the data previously provided had been sent over
+ * the PLC.
+ *
+ * \param ctx the CL context.
+ * \param buffer the buffer containing the MME
+ */
+void cl_data_send_done (void *ctx, u8 *buffer)
+{
+ cl_t *cl;
+ dbg_assert (ctx);
+ dbg_assert (buffer);
+
+ cl = (cl_t *) ctx;
+
+ /* Compare the buffer address with the MME buffer address. */
+ if (cl->mme_ul_send.mme_buffer == buffer)
+ {
+ dbg_assert (cl->mme.mme_send_done_cb);
+ (*cl->mme.mme_send_done_cb) (cl->mme.mme_send_done_user_data, buffer);
+ cl->mme_ul_send.mme_buffer = NULL;
+ }
+ else
+ {
+ dbg_assert (cl->data_tx.cb);
+ (*cl->data_tx.cb) (cl->data_tx.user, buffer);
+ }
+}
+
+/**
+ * Provides a buffer to the SAR to reassembly data
+ *
+ * \param cl the CL context
+ * \param buffer the buffer to reassembly some datas
+ * \return true if the buffer has been added, flase otherwise.
+ */
+bool cl_sar_add_buffer_data (cl_t *cl, u8 *buffer)
+{
+ dbg_assert (cl);
+ dbg_assert (buffer);
+
+ free (buffer);
+
+ return true;
+}
+
+/**
+ * Provides a buffer to the SAR to reassembly data
+ *
+ * \param cl the CL context
+ * \param buffer the buffer to reassembly some datas
+ * \return true if the buffer has been added, flase otherwise.
+ */
+bool cl_sar_add_buffer_mme (cl_t *cl, u8 *buffer)
+{
+ dbg_assert (cl);
+ dbg_assert (buffer);
+
+ free (buffer);
+
+ return true;
+}
+
+/**
+ * Receives an MME from the Upper layer.
+ * It will provide this MME to the Control Plane to be processed.
+ *
+ * \param ctx the cl context
+ * \param buffer the MME buffer
+ * \param length the MME length
+ */
+void cl_mme_ul_recv (cl_t *ctx, u8 *buffer, uint length)
+{
+ dbg_assert (ctx->mme.ul_mme_recv_done);
+
+ (*ctx->mme.ul_mme_recv_done) (ctx->mme.ul_mme_recv_done_user_data,
+ buffer);
+}
+
+/**
+ * Initialize the CL to call the Upper layer once the CP ends processing the
+ * MME.
+ * Used each time the CP needs to send an MME to the upper layer.
+ *
+ * \param ctx the CL context
+ * \param cb the upper layer callback to use to send an MME.
+ * \param user the user data to provide with the callback
+ */
+void cl_mme_ul_init_recv_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;
+}
+
+
+/**
+ * Uninit the Convergence layer context.
+ *
+ * \param ctx the convergence layer context
+ */
+void cl_uninit (cl_t *ctx)
+{
+
+}
diff --git a/hle/test/overide/hal/hle/Module b/hle/test/overide/hal/hle/Module
new file mode 100644
index 0000000000..2a248a2de2
--- /dev/null
+++ b/hle/test/overide/hal/hle/Module
@@ -0,0 +1 @@
+SOURCES := ipmbox.c \ No newline at end of file
diff --git a/hle/test/overide/hal/hle/ipmbox.h b/hle/test/overide/hal/hle/ipmbox.h
new file mode 100644
index 0000000000..ed1f416927
--- /dev/null
+++ b/hle/test/overide/hal/hle/ipmbox.h
@@ -0,0 +1,32 @@
+#ifndef IPMBOX_H_
+#define IPMBOX_H_
+
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file ipmbox.h
+ * \brief « brief description »
+ * \ingroup « module »
+ *
+ * « long description »
+ */
+
+typedef uint ipmbox_t;
+
+typedef bool (*ipmbox_rx_cb_t) (u32 *msg_buffer, uint length, void *user_data);
+
+typedef bool (*ipmbox_tx_cb_t)(u32 *msg_buffer, uint length, void *user_data);
+
+typedef bool (*ipmbox_deferred_cb_t)(u32 *buffer, uint length, void *user_data);
+
+ipmbox_t *ipmbox_init(void *user_data, ipmbox_rx_cb_t rx_cb, ipmbox_tx_cb_t
+ tx_cb, ipmbox_deferred_cb_t deferred_cb);
+
+void ipmbox_tx (ipmbox_t *ctx, u32 *msg_buffer, uint length);
+
+#endif /*IPMBOX_H_*/
diff --git a/hle/test/overide/hal/hle/src/ipmbox.c b/hle/test/overide/hal/hle/src/ipmbox.c
new file mode 100644
index 0000000000..a287b0f803
--- /dev/null
+++ b/hle/test/overide/hal/hle/src/ipmbox.c
@@ -0,0 +1,32 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test/hle_recv.c
+ * \brief unit test to test the hle when it sends a data to the CL.
+ * \ingroup hle
+ *
+ * « long description »
+ */
+
+#include "common/std.h"
+
+#include "hal/hle/ipmbox.h"
+
+static ipmbox_t ipmbox_global;
+
+ipmbox_t *ipmbox_init (void *user_data, ipmbox_rx_cb_t rx_cb,
+ ipmbox_tx_cb_t tx_cb, ipmbox_deferred_cb_t deferred_cb)
+{
+ return &ipmbox_global;
+}
+
+void ipmbox_tx (ipmbox_t *ctx, u32 *msg_buffer, uint length)
+{
+ dbg_assert (ctx);
+ dbg_assert (msg_buffer);
+}
diff --git a/hle/test/src/hle_add_buffer.c b/hle/test/src/hle_add_buffer.c
new file mode 100644
index 0000000000..422ab8176a
--- /dev/null
+++ b/hle/test/src/hle_add_buffer.c
@@ -0,0 +1,83 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test/hle_recv.c
+ * \brief unit test to test the hle when it sends a data to the CL.
+ * \ingroup hle
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "lib/test.h"
+#include "lib/blk.h"
+
+#include "cl/cl.h"
+
+#include "hle/hle.h"
+#include "lib/test.h"
+
+int main (void)
+{
+ test_t test;
+
+ hle_t *hle;
+ cl_t *cl;
+
+ uint msg;
+ uint msgs [10];
+ u8 *buff_packet[2];
+
+ buff_packet[0] = malloc (2048 * sizeof(u8));
+ buff_packet[1] = malloc (2048 * sizeof(u8));
+
+ /** Data allocation */
+ msg = HLE_MSG_TYPE_BUFFER_ADD | (1 << 8);
+ memcpy (&msgs[0], &msg, sizeof(uint));
+ memcpy (&msgs[1], &buff_packet[0], sizeof(uint));
+
+ memcpy (&msgs[2], &msg, sizeof(uint));
+ memcpy (&msgs[3], &buff_packet[1], sizeof(uint));
+
+ test_init (test, 0, NULL);
+
+ // The function cl_init has been overided.
+ cl = cl_init (NULL, NULL);
+ hle = hle_init (cl);
+
+ hle_ipmbox_deffered_recv (msgs, 4, hle);
+
+ /** MME allocation */
+ buff_packet[0] = malloc (2048 * sizeof(u8));
+ buff_packet[1] = malloc (2048 * sizeof(u8));
+
+ msg = HLE_MSG_TYPE_BUFFER_ADD | (1 << 8) | (1 << 12);
+ memcpy (&msgs[0], &msg, sizeof(uint));
+ memcpy (&msgs[1], &buff_packet[0], sizeof(uint));
+
+ memcpy (&msgs[2], &msg, sizeof(uint));
+ memcpy (&msgs[3], &buff_packet[1], sizeof(uint));
+
+ hle_ipmbox_deffered_recv (msgs, 4, hle);
+
+ hle_uninit (hle);
+ cl_uninit (cl);
+
+ test_begin (test, "Memory test")
+ {
+ test_fail_if (blk_check_memory() == false, "Memory not freed");
+ }
+ test_end;
+
+ test_result (test);
+ return test_nb_failed (test) == 0 ? 0 : 1;
+}
diff --git a/hle/test/src/hle_recv_from_arm.c b/hle/test/src/hle_recv_from_arm.c
new file mode 100644
index 0000000000..575c5b3edb
--- /dev/null
+++ b/hle/test/src/hle_recv_from_arm.c
@@ -0,0 +1,102 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test/hle_recv.c
+ * \brief unit test to test the hle when it sends a data to the CL.
+ * \ingroup hle
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "lib/test.h"
+#include "lib/blk.h"
+
+#include "cl/cl.h"
+
+#include "hle/hle.h"
+#include "lib/test.h"
+
+unsigned int packet1 []__attribute__((aligned(2048))) =
+{ 0xa1b2c3d4, 0x00040002, 0x00000000, 0x00000000,
+ 0x0000ffff, 0x00000001, 0x46973299, 0x0007c33e,
+ 0x00000042, 0x00000042, 0x12005452, 0x00080235,
+ 0x4c205227, 0x00450008, 0x4e043400, 0x06400040,
+ 0x000a1917, 0x79cb0f02, 0x1b04d547, 0x6b285000,
+ 0x0000babc, 0x02800000, 0x396bf0fa, 0x04020000,
+ 0x0301b405, 0x01010003, 0x00000204};
+unsigned int packet1_len = 106;
+
+unsigned int packet2[] = { 0xa1b2c3d4, 0x00040002, 0x00000000, 0x00000000,
+ 0x0000ffff, 0x00000001, 0x469732d4, 0x0000da24, 0x0000005d,
+ 0x0000005d, 0x12005452, 0x00080235, 0x4c205227, 0x00450008,
+ 0x09064f00, 0x06400040, 0x000a901c, 0x000a0f02, 0x01040202,
+ 0x46d6bd01, 0x0d0071cf, 0x185072c5, 0x4b65b0f9, 0x00000000,
+ 0x53ff2300, 0x0071424d, 0x18000000, 0x0000c807, 0x00000000,
+ 0x00000000, 0x00010000, 0x0000feff, 0x00000a01, 0x00000000 };
+unsigned int packet2_len = 133;
+
+
+int main (void)
+{
+ test_t test;
+
+ hle_t *hle;
+ cl_t *cl;
+
+ uint msg;
+ uint msgs [10];
+ u8 *buff_packet[2];
+
+ buff_packet[0] = malloc (2048 * sizeof(u8));
+ buff_packet[1] = malloc (2048 * sizeof(u8));
+
+ msg = HLE_MSG_TYPE_DATA | (2 << 8) | (packet1_len << 12);
+ memcpy (&msgs[0], &msg, sizeof(uint));
+ memcpy (&msgs[1], &buff_packet[0], sizeof (uint));
+
+ msg = HLE_MSG_TYPE_DATA | (2 << 8) | (packet2_len << 12);
+ memcpy (&msgs[2], &msg, sizeof(uint));
+ memcpy (&msgs[3], &buff_packet[1], sizeof (uint));
+
+ memcpy (buff_packet[0], packet1, packet1_len);
+ memcpy (buff_packet[1], packet2, packet2_len);
+
+ test_init(test, 0, NULL);
+
+ // The function cl_init has been overided.
+ cl = cl_init (NULL, NULL);
+ hle = hle_init (cl);
+
+ hle_ipmbox_deffered_recv(msgs, 4, hle);
+
+ msg = HLE_MSG_TYPE_MME | (2 << 8) | (packet1_len << 12);
+ memcpy (&msgs[0], &msg, sizeof(uint));
+
+ msg = HLE_MSG_TYPE_MME | (2 << 8) | (packet2_len << 12);
+ memcpy (&msgs[2], &msg, sizeof(uint));
+
+ hle_ipmbox_deffered_recv(msgs, 4, hle);
+
+ hle_uninit (hle);
+ cl_uninit (cl);
+
+ test_begin (test, "Memory test")
+ {
+ test_fail_if (blk_check_memory() == false, "Memory not freed");
+ }
+ test_end;
+
+ test_result (test);
+ return test_nb_failed (test) == 0 ? 0 : 1;
+}
+
diff --git a/hle/test/src/hle_send_to_arm.c b/hle/test/src/hle_send_to_arm.c
new file mode 100644
index 0000000000..2935c1c3dd
--- /dev/null
+++ b/hle/test/src/hle_send_to_arm.c
@@ -0,0 +1,76 @@
+/* Cesar project {{{
+ *
+ * Copyright (C) 2007 Spidcom
+ *
+ * <<<Licence>>>
+ *
+ * }}} */
+/**
+ * \file test/hle_recv.c
+ * \brief unit test to test the hle when it sends a data to the CL.
+ * \ingroup hle
+ *
+ * « long description »
+ */
+#include "common/std.h"
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+#include "lib/test.h"
+#include "lib/blk.h"
+
+#include "cl/cl.h"
+
+#include "hle/hle.h"
+#include "lib/test.h"
+
+unsigned int packet1 []__attribute__((aligned(2048))) =
+{ 0xa1b2c3d4, 0x00040002, 0x00000000, 0x00000000,
+ 0x0000ffff, 0x00000001, 0x46973299, 0x0007c33e,
+ 0x00000042, 0x00000042, 0x12005452, 0x00080235,
+ 0x4c205227, 0x00450008, 0x4e043400, 0x06400040,
+ 0x000a1917, 0x79cb0f02, 0x1b04d547, 0x6b285000,
+ 0x0000babc, 0x02800000, 0x396bf0fa, 0x04020000,
+ 0x0301b405, 0x01010003, 0x00000204};
+unsigned int packet1_len = 106;
+
+unsigned int packet2[] = { 0xa1b2c3d4, 0x00040002, 0x00000000, 0x00000000,
+ 0x0000ffff, 0x00000001, 0x469732d4, 0x0000da24, 0x0000005d,
+ 0x0000005d, 0x12005452, 0x00080235, 0x4c205227, 0x00450008,
+ 0x09064f00, 0x06400040, 0x000a901c, 0x000a0f02, 0x01040202,
+ 0x46d6bd01, 0x0d0071cf, 0x185072c5, 0x4b65b0f9, 0x00000000,
+ 0x53ff2300, 0x0071424d, 0x18000000, 0x0000c807, 0x00000000,
+ 0x00000000, 0x00010000, 0x0000feff, 0x00000a01, 0x00000000 };
+unsigned int packet2_len = 133;
+
+test_t test;
+
+int main (void)
+{
+ hle_t *hle;
+ cl_t *cl;
+
+ test_init(test, 0, NULL);
+
+ // The function cl_init has been overided.
+ cl = cl_init (NULL, NULL);
+ hle = hle_init (cl);
+
+ hle_data_recv(hle, (u8 *) packet1, packet1_len);
+ hle_mme_recv(hle, (u8 *) packet1, packet1_len);
+
+ hle_uninit (hle);
+ cl_uninit (cl);
+
+ test_begin (test, "Memory test")
+ {
+ test_fail_if (blk_check_memory() == false, "Memory not freed");
+ }
+ test_end;
+
+ test_result (test);
+ return test_nb_failed (test) == 0 ? 0 : 1;
+}
+