예제 #1
0
static DSL_int_t DSL_DRV_LED_Sim(
   DSL_DRV_ThreadParams_t *param)
{
   DSL_int_t nOsRet = 0;
   DSL_Error_t nErrCode = DSL_SUCCESS;
   DSL_Context_t *pContext = (DSL_Context_t *)param->nArg1;
   DSL_uint16_t nPollTimeout = 0;

   /* begin polling ... */
   stop_led_module = 0;

   nPollTimeout = pContext->nDataLedSimControlData.nBlinkTimeout;

   while (!stop_led_module)
   {
      DSL_DRV_WAIT_EVENT_TIMEOUT(pContext->dataLedSimEvent, nPollTimeout);

      if (pContext->nDataLedSimControlData.nLedBehavior == DAL_DATA_LED_BLINK)
      {
         /* Trigger Data LED to blink*/
         DSL_DRV_LED_Flash();
      }

      nPollTimeout = pContext->nDataLedSimControlData.nBlinkTimeout;
   }

   nOsRet = DSL_DRV_ErrorToOS(nErrCode);

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

   return nOsRet;
}
예제 #2
0
/*
   IO controls for user space accessing

   \param   ino      Pointer to the stucture of inode.
   \param   fil      Pointer to the stucture of file.
   \param   command     The ioctl command.
   \param   lon      The address of data.
   \return  Success or failure.
   \ingroup Internal
*/
DSL_int_t DSL_DRV_Ioctls(DSL_DRV_DevHeader_t *pDrvHdr, DSL_uint_t nCommand, DSL_uint32_t nArg)
{
   DSL_int_t nErr=0;
   DSL_boolean_t bIsInKernel;
   DSL_uint32_t nRetCode = 0;
   DSL_Context_t *pContext;
   DSL_devCtx_t *pDevCtx;
   DSL_OpenContext_t *pOpenCtx = pDrvHdr->pOpenCtx;

   DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, "Device will be controled..."DSL_DRV_CRLF));

   DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, "IN - DSL_DRV_Ioctls: The ioctl "
      "command(0x%X) is called" DSL_DRV_CRLF, nCommand));

   if ((pOpenCtx = gv_drv_dsl_pOpenCtx) == DSL_NULL)
   // SchS: orig: if (pOpenCtx == DSL_NULL)
   {
      /* This should never happen */
      DSL_DEBUG(DSL_DBG_ERR, (DSL_NULL, "!!! Ioctl call for file which "
         "was not opened" DSL_DRV_CRLF));

      return -1;
   }
   else
   {
      if ((pDevCtx = pOpenCtx->pDevCtx) == DSL_NULL)
      {
         /* This should never happen */
         DSL_DEBUG(DSL_DBG_ERR, (DSL_NULL, "DSL_DRV_Poll: !!! Ioctl call "
            "for file which was not opened correctly" DSL_DRV_CRLF));

         return -1;
      }
      else
      {
         if ((pContext = pDevCtx->pContext) == DSL_NULL)
         {
            /* This should never happen */
            DSL_DEBUG(DSL_DBG_ERR, (DSL_NULL, "!!! Ioctl call to device "
               "which was not ready" DSL_DRV_CRLF));

            return -1;
         }
      }
   }

   bIsInKernel = DSL_TRUE;

   switch(nCommand)
   {
#if 0
//SchS
      case FIOSELECT:
      if ( DSL_Fifo_isEmpty( pOpenCtx->eventFifo ) == DSL_FALSE )
      {
         selWakeup((SEL_WAKEUP_NODE*) nArg);
      }
      return 0;

      case FIOUNSELECT:
      selNodeDelete(&pOpenCtx->eventWaitQueue, (SEL_WAKEUP_NODE*) nArg);
      return 0;
#endif
   }

   if ( (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API) ||
        (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API_G997) ||
        (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API_PM) ||
        (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API_SAR) ||
        (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_CPE_API_DEP) )
   {
      nRetCode = DSL_DRV_IoctlHandle(pOpenCtx, pContext, bIsInKernel, nCommand, nArg);

      if (nRetCode < DSL_SUCCESS)
      {
         nErr = DSL_DRV_ErrorToOS(nRetCode);
      }
   }
#if defined(INCLUDE_DSL_ADSL_MIB)
   else if (_IOC_TYPE(nCommand) == DSL_IOC_MAGIC_MIB)
   {
      nRetCode = DSL_DRV_MIB_IoctlHandle(pContext, bIsInKernel, nCommand, nArg);
      nErr = nRetCode;
   }
#endif
   else
   {
      DSL_DEBUG(DSL_DBG_ERR, (DSL_NULL, "The ioctl command(0x%X) is not "
         "supported!" DSL_DRV_CRLF, nCommand));
      nErr = -1;
      return nErr;
   }


   DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, "OUT - DSL_DRV_Ioctls(), retCode=%d"
      DSL_DRV_CRLF, nErr));

   return nErr;
}
예제 #3
0
static DSL_int_t DSL_CEOC_Thread(DSL_DRV_ThreadParams_t *param)
{
   DSL_Error_t nErrCode = DSL_SUCCESS;
   DSL_int_t nOsRet = 0;
   DSL_Context_t *pContext = (DSL_Context_t*)param->nArg1;
   DSL_LineStateValue_t nCurrentState = DSL_LINESTATE_UNKNOWN;
   DSL_CEOC_Message_t ceocMsg;
   DSL_uint16_t protIdent = 0x0;

   /* Check DSL CPE context pointer*/
   if( pContext == DSL_NULL || DSL_CEOC_CONTEXT(pContext) == DSL_NULL )
      return -1;

   /* Check if the CEOC was initialized*/
   if( DSL_CEOC_CONTEXT(pContext)->bInit != DSL_TRUE )
   {
      DSL_DEBUG(DSL_DBG_ERR,
         (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC module not initialized!"
         DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

      return -1;
   }

   DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun = DSL_TRUE;

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, SYS_DBG_MSG"DSL[%02d]: CEOC thread started"DSL_DRV_CRLF,
      DSL_DEV_NUM(pContext)));

   /* main CEOC module Task*/
   while( DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun )
   {
      DSL_DRV_WAIT_EVENT_TIMEOUT( DSL_CEOC_CONTEXT(pContext)->ceocThread.waitEvent,
                              DSL_CEOC_CONTEXT(pContext)->ceocThread.nThreadPollTime);

      if (DSL_DRV_SIGNAL_PENDING)
         break;

      /* Only proceed if the specified line is in SHOWTIME state*/
      DSL_CTX_READ_SCALAR(pContext, nErrCode, nLineState, nCurrentState);

      /* Only proceed if the specified line is in SHOWTIME state*/
      if ((nCurrentState != DSL_LINESTATE_SHOWTIME_TC_SYNC) &&
          (nCurrentState != DSL_LINESTATE_SHOWTIME_NO_SYNC))
      {
         continue;
      }

      /* Clear message length*/
      ceocMsg.length = 0x0;
      if( DSL_CEOC_DEV_MessageReceive(pContext, &protIdent, &ceocMsg) < DSL_SUCCESS )
      {
         DSL_DEBUG(DSL_DBG_ERR,
            (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC message receive failed!"
            DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

         nErrCode = DSL_ERROR;

         break;
      }

      if( !ceocMsg.length )
      {
         /* No data available, continue polling*/
         continue;
      }

       /* EOC message available. Write the received message to the internal FIFO*/
      if( DSL_CEOC_FifoMessageWrite(pContext, protIdent, &ceocMsg) < DSL_SUCCESS )
      {
         DSL_DEBUG(DSL_DBG_ERR, (pContext,
            SYS_DBG_ERR"DSL[%02d]: ERROR - CEOC message write failed!"DSL_DRV_CRLF,
            DSL_DEV_NUM(pContext)));

         nErrCode = DSL_ERROR;

         break;
      }

      /* Proceed message for the Internal CEOC API*/
      #ifdef INCLUDE_DSL_CEOC_INTERNAL_API
      if( DSL_CEOC_CallbackHandle(pContext,protIdent,&ceocMsg) < DSL_SUCCESS )
      {
         DSL_DEBUG(DSL_DBG_ERR,
            (pContext, SYS_DBG_ERR"DSL[%02d]: ERROR - CallBack Handle failed!!"
            DSL_DRV_CRLF, DSL_DEV_NUM(pContext)));

         nErrCode = DSL_ERROR;

         break;
      }
      #endif
   }

   /* Clear CEOC module bRun flag*/
   DSL_CEOC_CONTEXT(pContext)->ceocThread.bRun = DSL_FALSE;

   nOsRet = DSL_DRV_ErrorToOS(nErrCode);

   DSL_DEBUG(DSL_DBG_MSG,
      (pContext, SYS_DBG_MSG"DSL[%02d]: CEOC thread stoped"DSL_DRV_CRLF,
      DSL_DEV_NUM(pContext)));

   return nOsRet;
}
예제 #4
0
/*
   Led Thread Main function
*/
static DSL_int_t DSL_DRV_LED_Poll(
   DSL_DRV_ThreadParams_t *param)
{
   DSL_uint32_t flags = 0;
   DSL_int_t nOsRet = 0;
   DSL_Error_t nErrCode = DSL_SUCCESS;
   DSL_Context_t *pContext = (DSL_Context_t *)param->nArg1;
   DSL_LineStateValue_t nCurrentState = DSL_LINESTATE_UNKNOWN;

   /* begin polling ... */
   stop_led_module = 0;

   while (!stop_led_module)
   {
      /* Wake up every 10s */
      while (!(stop_led_module || pContext->bLedNeedToFlash) &&
         !(DSL_DRV_WAIT_EVENT_TIMEOUT(pContext->ledPollingEvent, 10000)));
      /* -ERESTARTSYS or condition evaluates to true */

      /* Only proceed if the specified line is in SHOWTIME state*/
      DSL_CTX_READ_SCALAR(pContext, nErrCode, nLineState, nCurrentState);
      if( nErrCode != DSL_SUCCESS )
      {
         DSL_DEBUG(DSL_DBG_ERR, (pContext, "DSL[%02d]: ERROR - [%s %d]: Failed to get "
            "current line state!"DSL_DRV_CRLF, DSL_DEV_NUM(pContext), __func__, __LINE__));

         spin_lock_irqsave(&dsl_led_lock, flags);
         stop_led_module = 1;
         pContext->bLedNeedToFlash = DSL_FALSE;
         spin_unlock_irqrestore(&dsl_led_lock, flags);
         break;
      }

      /* Only proceed if the specified line is in SHOWTIME state*/
      if ((nCurrentState != DSL_LINESTATE_SHOWTIME_TC_SYNC) &&
         (nCurrentState != DSL_LINESTATE_SHOWTIME_NO_SYNC))
      {
         spin_lock_irqsave(&dsl_led_lock, flags);
         pContext->bLedNeedToFlash = DSL_FALSE;
         spin_unlock_irqrestore(&dsl_led_lock, flags);
         continue;
      }
      
      if (pContext->bLedNeedToFlash && (pContext->bLedStatusOn == DSL_FALSE))
      {
         /* FLASH */
         /* use GPIO9 for TR68 data led off. */
         if (DSL_DRV_DANUBE_CmvWrite(pContext, DSL_CMV_GROUP_INFO,
         DSL_CMV_ADDRESS_INFO_GPIO_CONTROL, 5, 1, &flash) != DSL_SUCCESS)
         {
            DSL_DEBUG(DSL_DBG_ERR, (pContext, "[%s %d]: CMV Write fail!" DSL_DRV_CRLF, __func__, __LINE__));
         }
         /* Let it flash for 1 second */
         if (!stop_led_module)
         {
            nErrCode = (DSL_Error_t)DSL_DRV_WAIT_EVENT_TIMEOUT(pContext->ledPollingEvent, 1000);
            if (nErrCode >= DSL_SUCCESS)
            {
               spin_lock_irqsave(&dsl_led_lock, flags);
               pContext->bLedStatusOn    = DSL_TRUE;
               pContext->bLedNeedToFlash = DSL_FALSE;
               spin_unlock_irqrestore(&dsl_led_lock, flags);
            }
         }
      }
      if ((pContext->bLedNeedToFlash == DSL_FALSE) && pContext->bLedStatusOn)
      {
         /* ON */
         /* use GPIO9 for TR68 data led off. */
         if (DSL_DRV_DANUBE_CmvWrite(pContext, DSL_CMV_GROUP_INFO,
            DSL_CMV_ADDRESS_INFO_GPIO_CONTROL, 5, 1, &on) != DSL_SUCCESS)
         {
            DSL_DEBUG(DSL_DBG_ERR, (pContext, "[%s %d]: CMV Write fail!" DSL_DRV_CRLF, __func__, __LINE__));
         }
         spin_lock_irqsave(&dsl_led_lock, flags);
         pContext->bLedStatusOn    = DSL_FALSE;
         spin_unlock_irqrestore(&dsl_led_lock, flags);
      }
   }

   nOsRet = DSL_DRV_ErrorToOS(nErrCode);

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

   return nOsRet;
}