summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorburet2008-03-03 13:03:25 +0000
committerburet2008-03-03 13:03:25 +0000
commitc63876786246cf6a2aef156ec4360af9d21f9bf6 (patch)
tree53088b8139a68ed41c607fc34ef37ae0461bfbfd
parentaeb20d2eb252a410a1c18009c3d5ceb4daa84129 (diff)
Maximus V2: HAL PHY -> initialize the random library once with a constant value.
git-svn-id: svn+ssh://pessac/svn/cesar/trunk@1526 017c9cb6-072f-447c-8318-d5b54f68fe89
-rw-r--r--hal/phy/maximus/inc/maximus_defs.h6
-rw-r--r--hal/phy/maximus/inc/maximus_phy_ctx.h3
-rw-r--r--hal/phy/maximus/src/maximus_phy_ctrl.c19
3 files changed, 22 insertions, 6 deletions
diff --git a/hal/phy/maximus/inc/maximus_defs.h b/hal/phy/maximus/inc/maximus_defs.h
index e544a5edfa..a155fac59e 100644
--- a/hal/phy/maximus/inc/maximus_defs.h
+++ b/hal/phy/maximus/inc/maximus_defs.h
@@ -26,8 +26,12 @@
*/
#define MAXIMUS_PHY_MPDU_RECEPTION_DELAY_TCK ((5 + 5) * 25) // (5 microseconds + 5 microseconds) * 25 ticks per microsecond
-/** Threshold used to determinate if a netclock msg is considered to be programmed in the past
+/** Threshold used to determinate if a netclock msg is considered to be programmed in the past.
*/
#define MAXIMUS_PHY_DATE_TOLERANCE 0x10000000 // 2^28
+/** Init value for random library (u32).
+ */
+#define MAXIMUS_PHY_LIB_RND_SEED 123
+
#endif /* hal_phy_maximus_inc_maximus_defs_h */
diff --git a/hal/phy/maximus/inc/maximus_phy_ctx.h b/hal/phy/maximus/inc/maximus_phy_ctx.h
index c7cba65c7b..a84352130f 100644
--- a/hal/phy/maximus/inc/maximus_phy_ctx.h
+++ b/hal/phy/maximus/inc/maximus_phy_ctx.h
@@ -22,6 +22,7 @@
#include "host/station.h"
#include "host/netclock.h"
#include "hal/phy/maximus/inc/maximus_trace.h"
+#include "lib/rnd.h" // for 'lib_rnd_t'
#ifdef ECOS
#include <cyg/hal/drv_api.h>
#endif /* ECOS */
@@ -199,6 +200,8 @@ struct maximus_phy_ctrl_t
netclock_id_t extra_timer_program_netclock_id;
/** Callback context to insert into callback queue. */
netclock_callback_t *extra_timer_program_netclock_cb;
+ /** Random library context.*/
+ lib_rnd_t *rnd;
#ifdef ECOS
/** phy interrupt descriptor for eCos: relates to rx_fc, access and access_conf and extra_timer events */
cyg_interrupt phy_interrupt;
diff --git a/hal/phy/maximus/src/maximus_phy_ctrl.c b/hal/phy/maximus/src/maximus_phy_ctrl.c
index 2c14a87237..43c4064551 100644
--- a/hal/phy/maximus/src/maximus_phy_ctrl.c
+++ b/hal/phy/maximus/src/maximus_phy_ctrl.c
@@ -24,7 +24,6 @@
#include "lib/swap.h" // for 'ntohl'
#include "mac/common/timings.h" // for 'MAC_PREAMBLE_TCK', 'MAC_PREAMBLE_HYBRID_TCK', 'MAC_FC_10_TCK' and 'MAC_FC_AV_TCK'
#include "mac/common/defs.h" // for 'MAC_PB520_BYTES' and 'MAC_MAX_SYMB_PER_MPDU'
-#include "lib/rnd.h" // for 'lib_rnd_buffer()'
#include <string.h> // for 'memset'
#include <time.h> // for 'time()'
#include <errno.h>
@@ -399,9 +398,7 @@ maximus_phy_recv (sci_msg_t *msg, void *phy)
else
{
// modify message contents
- lib_rnd_t rnd;
- lib_rnd_init(&rnd, time(NULL));
- lib_rnd_buffer(&rnd, msg->data_begin, (uint)msg->length);
+ lib_rnd_buffer(ctx->control.rnd, msg->data_begin, (uint)msg->length);
}
}
@@ -1663,6 +1660,8 @@ phy_init (void *user_data, phy_rx_fc_cb_t rx_fc_cb, phy_access_cb_t access_cb,
static netclock_callback_t extra_timer_program_netclock_cb;
static netclock_callback_t recv_preamble_netclock_cb;
+ static lib_rnd_t rnd;
+
static u8 phy_tonemask[(PHY_CARRIER_NB+7)/8]; // uses 192 bytes (1 bit per carrier)
static blk_t phy_tonemap[2*TONEMAP_INDEX_NB]; // each tonemap uses two blocks
static u8 phy_tonemap1_data[MAC_PB520_BYTES][TONEMAP_INDEX_NB];
@@ -1709,6 +1708,10 @@ phy_init (void *user_data, phy_rx_fc_cb_t rx_fc_cb, phy_access_cb_t access_cb,
ctx.control.rx_param.recv_preamble_netclock_cb = &recv_preamble_netclock_cb;
ctx.access.prp_result = true;
+ // initialize random library
+ ctx.control.rnd = &rnd;
+ lib_rnd_init(ctx.control.rnd, MAXIMUS_PHY_LIB_RND_SEED);
+
// initialize tonemask and tonemap
memset(phy_tonemask, '\0', (PHY_CARRIER_NB+7)/8);
memset(phy_tonemap1_data, '\0', MAC_PB520_BYTES);
@@ -1725,7 +1728,7 @@ phy_init (void *user_data, phy_rx_fc_cb_t rx_fc_cb, phy_access_cb_t access_cb,
// register phy_recv to the sci layer
sci_register_callback(my_station.sci, SCI_MSG_TYPE_PHY, maximus_phy_recv, &ctx);
-
+
#ifdef ECOS
// register the phy ISR and DSR into eCos
cyg_drv_interrupt_create(PHY_HAL_INTERRUPT_PHY,
@@ -1810,6 +1813,9 @@ phy_reset (phy_t *ctx)
netclock_callback_t *extra_timer_program_netclock_cb = ctx->control.extra_timer_program_netclock_cb;
netclock_callback_t *recv_preamble_netclock_cb = ctx->control.rx_param.recv_preamble_netclock_cb;
+ // save random library context
+ lib_rnd_t *rnd = ctx->control.rnd;
+
// save tonemask and tonemap
maximus_tmdma_t tmdma = ctx->tmdma;
@@ -1837,6 +1843,9 @@ phy_reset (phy_t *ctx)
ctx->control.rx_param.recv_preamble_netclock_cb = recv_preamble_netclock_cb;
ctx->access.prp_result = true;
+ // reinitialize random library
+ ctx->control.rnd = rnd;
+
// reinitialize tonemask and tonemap
ctx->tmdma = tmdma;