/* Cesar project {{{ * * Copyright (C) 2007 Spidcom * * <<>> * * }}} */ /** * \file hal/phy/maximus/src/maximus_tmdma.c * \brief HAL Phy Tone Map DMA functions for Maximus. * \ingroup hal_phy_maximus */ #include "common/std.h" #include "hal/phy/maximus/inc/maximus_phy_ctx.h" #include "hal/phy/maximus/inc/maximus_phy_ctrl.h" #include "mac/common/defs.h" // for 'MAC_PB520_BYTES' #include /** * set errno to: * - EINVAL if ctx or tonemask are null */ void phy_set_tonemask (phy_t *ctx, u32 *tonemask, uint carrier_nb) { /* Set the carrier_nb value of PHY context. * Copy tonemask contents into PHY context. */ dbg_assert_ptr(ctx); dbg_assert_ptr(tonemask); if ((NULL == ctx) || (NULL == tonemask)) { errno = EINVAL; station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_PHY, "%s: errno = %d", __FUNCTION__, errno); } else { MAXIMUS_PHY_TRACE (SET_TONEMASK, carrier_nb); // set number of carriers ctx->tmdma.carrier_nb = carrier_nb; // copy tonemask (1 bit per carrier) memcpy(ctx->tmdma.tonemask, tonemask, (PHY_CARRIER_NB+7)/8); /* Send carrier_nb and tonemask to Maximus. */ if (0 != maximus_phy_send_tonemask(ctx)) { station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_PHY, "%s: errno = %d", __FUNCTION__, errno); dbg_assert_print(false, "errno = %d because TONEMASK message has not been correctly sent", errno); } } } /** * set errno to: * - EINVAL if ctx or tonemap are null, * or if arguments are out-of-range or incorrect */ void phy_set_tonemap (phy_t *ctx, blk_t *tonemap) { uint tonemap_index = 0; /* Set the tonemap_index value of PHY context. * Copy tonemap contents into PHY context. */ dbg_assert_ptr(ctx); dbg_assert(TONEMAP_INDEX_NB > tonemap_index); dbg_assert_ptr(tonemap); dbg_assert_ptr(tonemap->next); dbg_assert_ptr(tonemap->data); dbg_assert(NULL == tonemap->next->next); dbg_assert_ptr(tonemap->next->data); if ((NULL == ctx) || (TONEMAP_INDEX_NB <= tonemap_index) || (NULL == tonemap) || (NULL == tonemap->next) // tonemap uses two blocks || (NULL == tonemap->data) || (NULL != tonemap->next->next) // tonemap uses two blocks || (NULL == tonemap->next->data)) { errno = EINVAL; station_log(&my_station, STATION_LOG_ERROR, STATION_LOGTYPE_PHY, "%s: errno = %d", __FUNCTION__, errno); } else { MAXIMUS_PHY_TRACE (SET_TONEMAP, tonemap_index, tonemap); // copy tonemap memcpy(ctx->tmdma.tonemap[tonemap_index]->data, tonemap->data, MAC_PB520_BYTES); memcpy(ctx->tmdma.tonemap[tonemap_index]->next->data, tonemap->next->data, (PHY_CARRIER_NB+1)/2-MAC_PB520_BYTES); } }