Example #1
0
/**
   \brief API for atm driver to notify led thread a data comming/sending
   This function provide a API used by ATM driver, the atm driver call this
   function once a atm packet sent/received.

   \return  0 success else failed

   \ingroup Internal
 */
static DSL_int_t DSL_DRV_LED_Flash ( DSL_void_t )
{
   DSL_uint32_t flags = 0;
   DSL_Error_t nErrCode = DSL_SUCCESS;

   DSL_Context_t *pContext = pGlobalContext;

   DSL_DEBUG(DSL_DBG_MSG, (pContext, "DSL[%02d]: IN - DSL_DRV_LED_Flash"DSL_DRV_CRLF,
      DSL_DEV_NUM(pContext)));

   DSL_CHECK_POINTER(pContext, pContext->pDevCtx);
   DSL_CHECK_ERR_CODE();

   spin_lock_irqsave(&dsl_led_lock, flags);
   if (!stop_led_module)
   {
      /* asking to flash led */
      pContext->bLedNeedToFlash = DSL_TRUE;
      pContext->bLedStatusOn    = DSL_FALSE;
   }
   spin_unlock_irqrestore(&dsl_led_lock, flags);
#ifndef RTEMS
   if (!stop_led_module)
#else
   if (stop_led_module)
#endif /* RTEMS*/
   {
      DSL_DRV_WAKEUP_EVENT(pContext->ledPollingEvent);
   }

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, "DSL[%02d]: OUT - DSL_DRV_LED_Flash"DSL_DRV_CRLF,
      DSL_DEV_NUM(pContext)));

   return 0;
}
/*
   For a detailed description of the function, its arguments and return value
   please refer to the description in the header file 'drv_dsl_cpe_intern_ceoc.h'
*/
DSL_Error_t DSL_CEOC_Stop(DSL_Context_t *pContext)
{
   DSL_Error_t nErrCode = DSL_SUCCESS;

   DSL_CHECK_CTX_POINTER(pContext);
   DSL_CHECK_ERR_CODE();

   if( !DSL_CEOC_CONTEXT(pContext) )
   {
      return DSL_SUCCESS;
   }

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, SYS_DBG_MSG"DSL[%02d]: Stopping CEOC module..."DSL_DRV_CRLF,
      DSL_DEV_NUM(pContext)));

   if( DSL_CEOC_CONTEXT(pContext)->bInit == DSL_FALSE )
   {
      DSL_DEBUG(DSL_DBG_MSG,
         (pContext, SYS_DBG_MSG"DSL[%02d]: CEOC module not initialized yet!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return DSL_SUCCESS;
   }

   if( DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun == DSL_FALSE )
   {
      DSL_DEBUG(DSL_DBG_WRN,
         (pContext, SYS_DBG_WRN"DSL[%02d]: WARNING - CEOC module thread already stopped"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));
   }
   else
   {
      /* Signal CEOC thread to stop*/
      DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun = DSL_FALSE;

      DSL_DRV_WAKEUP_EVENT(DSL_CEOC_CONTEXT(pContext)->ceocThread.waitEvent);
      DSL_DRV_WAIT_COMPLETION(&DSL_CEOC_CONTEXT(pContext)->ceocThread.Control);

      DSL_DEBUG(DSL_DBG_MSG,
         (pContext, SYS_DBG_MSG"DSL[%02d]: CEOC thread has stopped... (%lu)"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext), DSL_DRV_TimeMSecGet()));
   }

   /* Call device specific CEOC de-initialization stuff*/
   nErrCode = DSL_CEOC_DEV_Stop(pContext);
   if( nErrCode != DSL_SUCCESS )
   {
      DSL_DEBUG(DSL_DBG_ERR,
         (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC module device deinitialization failed!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));
   }

   /* Free CEOC Module resources*/
   if( DSL_CEOC_CONTEXT(pContext) != DSL_NULL )
   {
      DSL_DRV_MemFree( DSL_CEOC_CONTEXT(pContext) );
   }

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, SYS_DBG_MSG"DSL[%02d]: CEOC module has stopped... (%lu)"
      DSL_DRV_CRLF, DSL_DEV_NUM(pContext), DSL_DRV_TimeMSecGet()));

   return nErrCode;
}