summaryrefslogtreecommitdiff
path: root/hal/phy/maximus/src/maximus_phy_ctrl.c
diff options
context:
space:
mode:
Diffstat (limited to 'hal/phy/maximus/src/maximus_phy_ctrl.c')
-rw-r--r--hal/phy/maximus/src/maximus_phy_ctrl.c342
1 files changed, 215 insertions, 127 deletions
diff --git a/hal/phy/maximus/src/maximus_phy_ctrl.c b/hal/phy/maximus/src/maximus_phy_ctrl.c
index 7efc700433..93adf6db3f 100644
--- a/hal/phy/maximus/src/maximus_phy_ctrl.c
+++ b/hal/phy/maximus/src/maximus_phy_ctrl.c
@@ -18,6 +18,7 @@
#include "hal/phy/maximus/inc/maximus_phy_ctrl.h"
#include "hal/phy/maximus/inc/maximus_interrupts.h"
#include "hal/phy/maximus/inc/maximus_dur.h"
+#include <netinet/in.h> // for 'ntohl'
#include <string.h> // for 'memset'
#include <errno.h>
@@ -43,6 +44,7 @@ maximus_phy_tx_fc_cb (void *data)
{
static maximus_phy_tx_frame_t tx_frame_cb_data;
+ dbg_assert_ptr(data);
if (NULL == data)
{
errno = EINVAL;
@@ -51,6 +53,7 @@ maximus_phy_tx_fc_cb (void *data)
{
maximus_phy_tx_fc_t *tx_fc_data = (maximus_phy_tx_fc_t*)data;
+ dbg_assert_ptr(tx_fc_data->ctx);
if (NULL == tx_fc_data->ctx)
{
errno = EINVAL;
@@ -77,124 +80,123 @@ maximus_phy_tx_fc_cb (void *data)
uint32_t tick_high, tick_low;
tick_t schedule_tick;
- if (tx_fc_data->want_conf
- && ((MAXIMUS_PHY_MEDIUM_BUSY != tx_fc_data->ctx->access.medium_state)
- || !tx_fc_data->ctx->control.rx_tx_mode))
+ if ( (MAXIMUS_PHY_MEDIUM_BUSY != tx_fc_data->ctx->access.medium_state)
+ || !tx_fc_data->ctx->control.rx_tx_mode )
{
- if ((*tx_fc_data->ctx->control.access_conf_cb)(tx_fc_data->ctx->control.user_data))
+ if ( (tx_fc_data->want_conf)
+ &&((*tx_fc_data->ctx->control.access_conf_cb)(tx_fc_data->ctx->control.user_data)) )
{
// a DSR is requested
(*tx_fc_data->ctx->control.deferred_cb)(tx_fc_data->ctx->control.user_data);
}
-
- }
- // update medium state
- tx_fc_data->ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY;
+ // update medium state
+ tx_fc_data->ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY;
+
+ // set tx mode
+ tx_fc_data->ctx->control.rx_tx_mode = false;
+
+ // deactivate preamble detection
+ tx_fc_data->ctx->control.pre_detection = false;
- // set tx mode
- tx_fc_data->ctx->control.rx_tx_mode = false;
+ /* Then, this callback has to send a phy message containing fc_av
+ * (and fc_10 in Hybrid Mode). */
+
+ // init for phy message
+ memset(tx_fc_data->ctx->buffer, '\0', SCI_MSG_MAX_SIZE);
- // deactivate preamble detection
- tx_fc_data->ctx->control.pre_detection = false;
+ if (0 == sci_msg_init(&msg, tx_fc_data->ctx->buffer, SCI_MSG_MAX_SIZE))
+ {
+ // for phy header
+ uint8_t type = PHY_TYPE_FC_HYBRID_MODE;
+ uint8_t flags = PHY_FLAG_CRC_OK;
+ uint32_t nek[4];
+ uint32_t pb_measurement[PHY_PB_MAX_NB];
+ uint32_t pb_header[PHY_PB_MAX_NB];
+
+ // set phy header values
+ memset(nek, '\0', 4*sizeof(uint32_t));
+ memset(pb_measurement, '\0', PHY_PB_MAX_NB*sizeof(uint32_t));
+ memset(pb_header, '\0', PHY_PB_MAX_NB*sizeof(uint32_t));
+ if ((PHY_FC_MODE_AV_1 == tx_fc_data->ctx->control.fc_mode)
+ || (PHY_FC_MODE_AV_2 == tx_fc_data->ctx->control.fc_mode))
+ {
+ type = PHY_TYPE_FC_AV_ONLY_MODE;
+ }
+ if (PHY_PB_SIZE_520 == tx_fc_data->ctx->pb_dma.pb_size)
+ {
+ flags &= PHY_FLAG_PB512;
+ }
+
+ // fill sci data
+ if (4*sizeof(u32) == sci_msg_push(&msg, 4*sizeof(u32)))
+ {
+ memcpy(msg.data_begin, tx_fc_data->ctx->control.fc_av, 4*sizeof(u32));
+ }
+ if ((PHY_TYPE_FC_HYBRID_MODE == type)
+ && (sizeof(u32) == sci_msg_push(&msg, sizeof(u32))))
+ {
+ memcpy(msg.data_begin, &tx_fc_data->ctx->control.fc_10, sizeof(u32));
+ }
+
+ // fill phy header
+ maximus_phy_fill_hdr(tx_fc_data->ctx,
+ &msg,
+ type,
+ PHY_MPDU_FORMAT_NONE,
+ 0, // pb_nb
+ (uint8_t)tx_fc_data->ctx->tm_dma.tonemap_index,
+ flags,
+ nek,
+ pb_measurement,
+ pb_header);
- /* Then, this callback has to send a phy message containing fc_av
- * (and fc_10 in Hybrid Mode). */
-
- // init for phy message
- memset(tx_fc_data->ctx->buffer, '\0', SCI_MSG_MAX_SIZE);
+ // fill the sci header
+ sci_fill_hdr(my_station.sci, &msg, SCI_MSG_TYPE_PHY, 0 /* flags */);
- if (0 == sci_msg_init(&msg, tx_fc_data->ctx->buffer, SCI_MSG_MAX_SIZE))
- {
- // for phy header
- uint8_t type = PHY_TYPE_FC_HYBRID_MODE;
- uint8_t flags = PHY_FLAG_CRC_OK;
- uint32_t nek[4];
- uint32_t pb_measurement[PHY_PB_MAX_NB];
- uint32_t pb_header[PHY_PB_MAX_NB];
-
- // set phy header values
- memset(nek, '\0', 4*sizeof(uint32_t));
- memset(pb_measurement, '\0', PHY_PB_MAX_NB*sizeof(uint32_t));
- memset(pb_header, '\0', PHY_PB_MAX_NB*sizeof(uint32_t));
- if ((PHY_FC_MODE_AV_1 == tx_fc_data->ctx->control.fc_mode)
- || (PHY_FC_MODE_AV_2 == tx_fc_data->ctx->control.fc_mode))
- {
- type = PHY_TYPE_FC_AV_ONLY_MODE;
- }
- if (PHY_PB_SIZE_520 == tx_fc_data->ctx->pb_dma.pb_size)
- {
- flags &= PHY_FLAG_PB512;
- }
-
- // fill sci data
- if (4*sizeof(u32) == sci_msg_push(&msg, 4*sizeof(u32)))
- {
- memcpy(msg.data_begin, tx_fc_data->ctx->control.fc_av, 4*sizeof(u32));
- }
- if ((PHY_TYPE_FC_HYBRID_MODE == type)
- && (sizeof(u32) == sci_msg_push(&msg, sizeof(u32))))
- {
- memcpy(msg.data_begin, &tx_fc_data->ctx->control.fc_10, sizeof(u32));
+ // send the message
+ sci_send(my_station.sci, &msg);
}
- // fill phy header
- maximus_phy_fill_hdr(tx_fc_data->ctx,
- &msg,
- type,
- PHY_MPDU_FORMAT_NONE,
- 0, // pb_nb
- (uint8_t)tx_fc_data->ctx->tm_dma.tonemap_index,
- flags,
- nek,
- pb_measurement,
- pb_header);
-
- // fill the sci header
- sci_fill_hdr(my_station.sci, &msg, SCI_MSG_TYPE_PHY, 0 /* flags */);
+ if (!tx_fc_data->ctx->control.short_ppdu)
+ {
+ /* At last, to simulate the transmission time, this callback has to send a netclock message
+ * scheduled at a date calculated depending on PB number, modulation and guard interval. */
+
+ // calculate frame control transimission time
+ bits_per_symbol = maximus_dur_bits_per_symbol(tx_fc_data->ctx->tm_dma.mod,
+ tx_fc_data->ctx->tm_dma.tonemask,
+ tx_fc_data->ctx->tm_dma.tonemap[tx_fc_data->ctx->tm_dma.tonemap_index],
+ tx_fc_data->ctx->tm_dma.carrier_nb); // 4 bits per carrier
+ if ((PHY_FC_MODE_HYBRID_2 == tx_fc_data->ctx->control.fc_mode)
+ || (PHY_FC_MODE_AV_2 == tx_fc_data->ctx->control.fc_mode))
+ {
+ symbol_nb = 2;
+ }
+ duration_in_ticks = maximus_dur_data_tck(tx_fc_data->ctx->tm_dma.gil, symbol_nb);
- // send the message
- sci_send(my_station.sci, &msg);
- }
-
- if (!tx_fc_data->ctx->control.short_ppdu)
- {
- /* At last, to simulate the transmission time, this callback has to send a netclock message
- * scheduled at a date calculated depending on PB number, modulation and guard interval. */
+ // set schedule time
+ tick_high = my_station.current_tick_tck >> 32;
+ tick_low = (uint32_t)my_station.current_tick_tck + duration_in_ticks;
+ schedule_tick = (((unsigned long long)(tick_high)) << 32) | (unsigned long long)(tick_low);
- // calculate frame control transimission time
- bits_per_symbol = maximus_dur_bits_per_symbol(tx_fc_data->ctx->tm_dma.mod,
- tx_fc_data->ctx->tm_dma.tonemask,
- tx_fc_data->ctx->tm_dma.tonemap[tx_fc_data->ctx->tm_dma.tonemap_index],
- tx_fc_data->ctx->tm_dma.carrier_nb); // 4 bits per carrier
- if ((PHY_FC_MODE_HYBRID_2 == tx_fc_data->ctx->control.fc_mode)
- || (PHY_FC_MODE_AV_2 == tx_fc_data->ctx->control.fc_mode))
+ // fill callback data
+ tx_frame_cb_data.isr = tx_fc_data->isr;
+ tx_frame_cb_data.ctx = tx_fc_data->ctx;
+
+ netclock_schedule(my_station.netclock,
+ tx_fc_data->ctx->control.tx_frame_netclock_cb,
+ NETWORK_CLOCK_TYPE_STATION,
+ schedule_tick,
+ &maximus_phy_tx_frame_cb,
+ (void*)&tx_frame_cb_data,
+ &id);
+ }
+ else
{
- symbol_nb = 2;
+ // once phy message has been sent, set medium state to idle
+ tx_fc_data->ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_IDLE;
}
- duration_in_ticks = maximus_dur_data_tck(tx_fc_data->ctx->tm_dma.gil, symbol_nb);
-
- // set schedule time
- tick_high = my_station.current_tick_tck >> 32;
- tick_low = (uint32_t)my_station.current_tick_tck + duration_in_ticks;
- schedule_tick = (((unsigned long long)(tick_high)) << 32) | (unsigned long long)(tick_low);
-
- // fill callback data
- tx_frame_cb_data.isr = tx_fc_data->isr;
- tx_frame_cb_data.ctx = tx_fc_data->ctx;
-
- netclock_schedule(my_station.netclock,
- tx_fc_data->ctx->control.tx_frame_netclock_cb,
- NETWORK_CLOCK_TYPE_STATION,
- schedule_tick,
- &maximus_phy_tx_frame_cb,
- (void*)&tx_frame_cb_data,
- &id);
- }
- else
- {
- // once phy message has been sent, set medium state to idle
- tx_fc_data->ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_IDLE;
}
}
}
@@ -211,6 +213,7 @@ maximus_phy_tx_frame_cb (void *data)
/* At the corresponding event reception, the transfer really starts,
* i.e. this callback has to send a phy message containing MPDU payload. */
+ dbg_assert_ptr(data);
if (NULL == data)
{
errno = EINVAL;
@@ -219,6 +222,8 @@ maximus_phy_tx_frame_cb (void *data)
{
maximus_phy_tx_frame_t *tx_frame_data = (maximus_phy_tx_frame_t*)data;
+ dbg_assert_ptr(tx_frame_data->ctx);
+ dbg_assert_ptr(tx_frame_data->ctx->control.pbdma_cb);
if ((NULL == tx_frame_data->ctx)
|| (NULL == tx_frame_data->ctx->control.pbdma_cb))
{
@@ -413,6 +418,7 @@ maximus_phy_send_tonemap_cb (void *data)
/* At the corresponding event reception, the transfer really starts,
* i.e. this callback has to send a phy message containing tonemap. */
+ dbg_assert_ptr(data);
if (NULL == data)
{
errno = EINVAL;
@@ -511,6 +517,7 @@ maximus_phy_send_noise_cb (void *data)
/* At the corresponding event reception, the transfer really starts,
* i.e. this callback has to send a phy message containing frequency noise and time noise. */
+ dbg_assert_ptr(data);
if (NULL == data)
{
errno = EINVAL;
@@ -636,6 +643,7 @@ maximus_phy_send_spectrum_cb (void *data)
/* At the corresponding event reception, the transfer really starts,
* i.e. this callback has to send a phy message containing spectrum. */
+ dbg_assert_ptr(data);
if (NULL == data)
{
errno = EINVAL;
@@ -758,6 +766,7 @@ maximus_phy_rx_activate_cb (void *data)
{
/* This callback has to set ctx->control.pre_detection with the pre_detection value given as argument. */
+ dbg_assert_ptr(data);
if (NULL == data)
{
errno = EINVAL;
@@ -766,6 +775,7 @@ maximus_phy_rx_activate_cb (void *data)
{
maximus_phy_rx_activate_t *rx_activate_data = (maximus_phy_rx_activate_t*)data;
+ dbg_assert_ptr(rx_activate_data->ctx);
if (NULL == rx_activate_data->ctx)
{
errno = EINVAL;
@@ -806,6 +816,15 @@ maximus_phy_fill_hdr(phy_t *ctx,
{
int ret = -1;
+ dbg_assert_ptr(ctx);
+ dbg_assert_ptr(msg);
+ dbg_assert(PHY_TYPE_NB > type);
+ dbg_assert(PHY_MPDU_FORMAT_NB > mpdu_format);
+ dbg_assert(PHY_PB_MAX_NB >= pb_nb);
+ dbg_assert((PHY_FLAG_ENCRYPTED + PHY_FLAG_CRC_OK + PHY_FLAG_PB512) >= flags);
+ dbg_assert_ptr(nek);
+ dbg_assert_ptr(pb_measurement);
+ dbg_assert_ptr(pb_header);
if ((NULL == ctx)
|| (NULL == msg)
|| (PHY_TYPE_NB <= type)
@@ -860,6 +879,8 @@ maximus_phy_recv (sci_msg_t *msg, void *phy)
phy_t *ctx;
phy_msg_hdr_t phy_hdr;
+ dbg_assert_ptr(msg);
+ dbg_assert_ptr(phy);
if((NULL == msg) || (NULL == phy))
{
errno = EINVAL;
@@ -876,6 +897,15 @@ maximus_phy_recv (sci_msg_t *msg, void *phy)
/* Check phy header. */
+ dbg_assert_ptr(msg->hdr.phy);
+ dbg_assert(PHY_TYPE_NB > msg->hdr.phy->type);
+ dbg_assert(PHY_MPDU_FORMAT_NB > msg->hdr.phy->mpdu_format);
+ dbg_assert(PHY_PB_MAX_NB >= msg->hdr.phy->pb_nb);
+ dbg_assert(PHY_TONEMAP_MAX_NB > msg->hdr.phy->tonemap_index);
+ dbg_assert((PHY_FLAG_ENCRYPTED + PHY_FLAG_CRC_OK + PHY_FLAG_PB512) >= msg->hdr.phy->flags);
+ dbg_assert_ptr(msg->hdr.phy->nek);
+ dbg_assert_ptr(msg->hdr.phy->pb_measurement);
+ dbg_assert_ptr(msg->hdr.phy->pb_header);
if ((NULL == msg->hdr.phy)
|| (PHY_TYPE_NB <= msg->hdr.phy->type)
|| (PHY_MPDU_FORMAT_NB <= msg->hdr.phy->mpdu_format)
@@ -887,6 +917,8 @@ maximus_phy_recv (sci_msg_t *msg, void *phy)
|| (NULL == msg->hdr.phy->pb_header))
{
errno = EPROTO;
+ station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_PHY,
+ "%s EPROTO", __FUNCTION__);
}
else
{
@@ -923,6 +955,9 @@ int
maximus_phy_recv_none (phy_t *ctx, sci_msg_t *msg)
{
errno = EPROTO;
+ station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_PHY,
+ "%s EPROTO", __FUNCTION__);
+
return 0;
}
@@ -934,6 +969,10 @@ maximus_phy_recv_fc_hybrid_mode (phy_t *ctx, sci_msg_t *msg)
int ret = -1;
+ dbg_assert_ptr(ctx);
+ dbg_assert_ptr(msg);
+ dbg_assert_ptr(msg->sci_hdr);
+ dbg_assert_ptr(ctx->control.rx_fc_cb);
if((NULL == ctx)
|| (NULL == msg)
|| (NULL == msg->sci_hdr)
@@ -954,17 +993,20 @@ maximus_phy_recv_fc_hybrid_mode (phy_t *ctx, sci_msg_t *msg)
ctx->access.prp_result = false;
- // update medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY;
-
- // set rx mode
- ctx->control.rx_tx_mode = true;
+ if (!ctx->control.short_ppdu)
+ {
+ // update medium state
+ ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY;
+
+ // set rx mode
+ ctx->control.rx_tx_mode = true;
+
+ // deactivate preamble detection
+ ctx->control.pre_detection = false;
+ }
- // deactivate preamble detection
- ctx->control.pre_detection = false;
-
// PHY raises an IT_RX_FC by calling 'phy_rx_fc_cb'
- if ((*ctx->control.rx_fc_cb)(ctx->control.user_data, msg->sci_hdr->netclock_low, ctx->control.fc_av))
+ if ((*ctx->control.rx_fc_cb)(ctx->control.user_data, ntohl(msg->sci_hdr->netclock_low), ctx->control.fc_av))
{
// a DSR is requested
(*ctx->control.deferred_cb)(ctx->control.user_data);
@@ -984,6 +1026,10 @@ maximus_phy_recv_fc_av_only_mode (phy_t *ctx, sci_msg_t *msg)
int ret = -1;
+ dbg_assert_ptr(ctx);
+ dbg_assert_ptr(msg);
+ dbg_assert_ptr(msg->sci_hdr);
+ dbg_assert_ptr(ctx->control.rx_fc_cb);
if((NULL == ctx)
|| (NULL == msg)
|| (NULL == msg->sci_hdr)
@@ -1002,17 +1048,20 @@ maximus_phy_recv_fc_av_only_mode (phy_t *ctx, sci_msg_t *msg)
ctx->access.prp_result = false;
- // update medium state
- ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY;
-
- // set rx mode
- ctx->control.rx_tx_mode = true;
+ if (!ctx->control.short_ppdu)
+ {
+ // update medium state
+ ctx->access.medium_state = MAXIMUS_PHY_MEDIUM_BUSY;
+
+ // set rx mode
+ ctx->control.rx_tx_mode = true;
+
+ // deactivate preamble detection
+ ctx->control.pre_detection = false;
+ }
- // deactivate preamble detection
- ctx->control.pre_detection = false;
-
// PHY raises an IT_RX_FC by calling 'phy_rx_fc_cb'
- if ((*ctx->control.rx_fc_cb)(ctx->control.user_data, msg->sci_hdr->netclock_low, ctx->control.fc_av))
+ if ((*ctx->control.rx_fc_cb)(ctx->control.user_data, ntohl(msg->sci_hdr->netclock_low), ctx->control.fc_av))
{
// a DSR is requested
(*ctx->control.deferred_cb)(ctx->control.user_data);
@@ -1028,7 +1077,9 @@ int
maximus_phy_recv_prs (phy_t *ctx, sci_msg_t *msg)
{
int ret = -1;
-
+
+ dbg_assert_ptr(ctx);
+ dbg_assert_ptr(msg);
if((NULL == ctx) || (NULL == msg))
{
errno = EINVAL;
@@ -1045,6 +1096,8 @@ maximus_phy_recv_prs (phy_t *ctx, sci_msg_t *msg)
if (1 < prs)
{
errno = EPROTO;
+ station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_PHY,
+ "%s EPROTO", __FUNCTION__);
}
else
{
@@ -1077,6 +1130,8 @@ maximus_phy_recv_mpdu_payload (phy_t *ctx, sci_msg_t *msg)
{
int ret = -1;
+ dbg_assert_ptr(ctx);
+ dbg_assert_ptr(msg);
if((NULL == ctx) || (NULL == msg))
{
errno = EINVAL;
@@ -1089,6 +1144,8 @@ maximus_phy_recv_mpdu_payload (phy_t *ctx, sci_msg_t *msg)
&& (0 == msg->hdr.phy->pb_nb)))
{
errno = EPROTO;
+ station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_PHY,
+ "%s EPROTO", __FUNCTION__);
}
else
{
@@ -1181,6 +1238,10 @@ maximus_phy_recv_tonemap (phy_t *ctx, sci_msg_t *msg)
{
int ret = -1;
+ dbg_assert_ptr(ctx);
+ dbg_assert_ptr(msg);
+ dbg_assert(2 == msg->hdr.phy->pb_nb);
+ dbg_assert(PHY_TONEMAP_MAX_NB > msg->hdr.phy->tonemap_index);
if((NULL == ctx) || (NULL == msg))
{
errno = EINVAL;
@@ -1189,6 +1250,8 @@ maximus_phy_recv_tonemap (phy_t *ctx, sci_msg_t *msg)
|| (PHY_TONEMAP_MAX_NB <= msg->hdr.phy->tonemap_index))
{
errno = EPROTO;
+ station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_PHY,
+ "%s EPROTO", __FUNCTION__);
}
else
{
@@ -1211,6 +1274,8 @@ maximus_phy_recv_noise (phy_t *ctx, sci_msg_t *msg)
{
int ret = -1;
+ dbg_assert_ptr(ctx);
+ dbg_assert_ptr(msg);
if((NULL == ctx) || (NULL == msg))
{
errno = EINVAL;
@@ -1266,7 +1331,9 @@ maximus_phy_recv_noise (phy_t *ctx, sci_msg_t *msg)
}
else
{
- errno = EPROTO;
+ errno = EPROTO;
+ station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_PHY,
+ "%s EPROTO", __FUNCTION__);
}
}
sci_msg_pop(msg, PHY_CARRIER_NB*sizeof(uint16_t));
@@ -1281,6 +1348,9 @@ maximus_phy_recv_spectrum (phy_t *ctx, sci_msg_t *msg)
{
int ret = -1;
+ dbg_assert_ptr(ctx);
+ dbg_assert_ptr(msg);
+ dbg_assert_ptr(msg->hdr.phy);
if((NULL == ctx) || (NULL == msg) || (NULL == msg->hdr.phy))
{
errno = EINVAL;
@@ -1329,7 +1399,9 @@ maximus_phy_recv_spectrum (phy_t *ctx, sci_msg_t *msg)
}
else
{
- errno = EPROTO;
+ errno = EPROTO;
+ station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_PHY,
+ "%s EPROTO", __FUNCTION__);
}
}
sci_msg_pop(msg, PHY_CARRIER_NB*sizeof(uint64_t));
@@ -1374,7 +1446,13 @@ phy_init (void *user_data, phy_rx_fc_cb_t rx_fc_cb, phy_access_cb_t access_cb,
static blk_t phy_tonemap[2*PHY_TONEMAP_MAX_NB]; // each tonemap uses two blocks
static u8 phy_tonemap1_data[PHY_PB_MAX_SIZE][PHY_TONEMAP_MAX_NB];
static u8 phy_tonemap2_data[PHY_CARRIER_NB/2-PHY_PB_MAX_SIZE][PHY_TONEMAP_MAX_NB]; // 4 bits per carrier
-
+
+ dbg_assert_ptr(user_data);
+ dbg_assert_ptr(rx_fc_cb);
+ dbg_assert_ptr(access_cb);
+ dbg_assert_ptr(access_conf_cb);
+ dbg_assert_ptr(pbdma_cb);
+ dbg_assert_ptr(deferred_cb);
if ((NULL == user_data)
|| (NULL == rx_fc_cb)
|| (NULL == access_cb)
@@ -1433,6 +1511,7 @@ phy_reset (phy_t *ctx)
/* After an error detection, PBP can reset the HW to a known sane state.
* Stop Tx/Rx and set PHY context to its initial values. */
+ dbg_assert_ptr(ctx);
if (NULL == ctx)
{
errno = EINVAL;
@@ -1478,6 +1557,7 @@ phy_uninit (phy_t *ctx)
* when modem is deactivated/reactivated.
* Stop Tx/Rx, set PHY context to NULL values. */
+ dbg_assert_ptr(ctx);
if (NULL == ctx)
{
errno = EINVAL;
@@ -1501,7 +1581,8 @@ phy_date (phy_t *ctx)
/* Return the current_date value of PHY context. */
u32 date = 0;
-
+
+ dbg_assert_ptr(ctx);
if (NULL == ctx)
{
errno = EINVAL;
@@ -1527,7 +1608,8 @@ phy_tx_fc10 (phy_t *ctx, u32 fc_10)
* PBP calls this function for HP 1.0 FC encoding
* 25µs before the start date given into 'phy_tx_frame'.
* Set the fc_10 value of PHY context. */
-
+
+ dbg_assert_ptr(ctx);
if (NULL == ctx)
{
errno = EINVAL;
@@ -1566,7 +1648,9 @@ phy_tx_param (phy_t *ctx, phy_fc_mode_t fc_mode, bool short_ppdu,
* Set the pb_size value of PHY context.
* Set the gil value of PHY context.
* Set the tonemap_index value of PHY context. */
-
+
+ dbg_assert_ptr(ctx);
+ dbg_assert(PHY_TONEMAP_MAX_NB > tonemap_index);
if ((NULL == ctx)
|| (PHY_TONEMAP_MAX_NB <= tonemap_index))
{
@@ -1616,6 +1700,7 @@ phy_tx_frame (phy_t *ctx, u32 date, bool want_conf, bool stop_tx_on_prp_lost,
* Set the fc_av[4] value of PHY context.
* Send a netclock message to Maximus simulator scheduled at the given date. */
+ dbg_assert_ptr(ctx);
if (NULL == ctx)
{
errno = EINVAL;
@@ -1708,6 +1793,7 @@ phy_rx_param (phy_t *ctx, phy_fc_mode_t fc_mode)
{
/* Set the fc_mode value of station context. */
+ dbg_assert_ptr(ctx);
if (NULL == ctx)
{
errno = EINVAL;
@@ -1738,6 +1824,7 @@ phy_rx_activate (phy_t *ctx, bool now, u32 date, bool pre_detection)
* - when a Tx starts (i.e. at the start date defined into 'phy_tx_frame').
* If PHY deactivates Rx, PBP has to reactivate it. */
+ dbg_assert_ptr(ctx);
if (NULL == ctx)
{
errno = EINVAL;
@@ -1808,6 +1895,7 @@ phy_rx_prepare (phy_t *ctx, bool short_ppdu, phy_mod_t mod,
* Set the tonemap_index value of PHY context.
* Set the symbol_nb value of PHY context. */
+ dbg_assert_ptr(ctx);
if (NULL == ctx)
{
errno = EINVAL;