コード例 #1
0
ファイル: drv_dsl_cpe_os_rtems.c プロジェクト: janfj/dd-wrt
/*
   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;
}
コード例 #2
0
/*****************************************************************************
* 函 数 名     :  cshell_io_ioctl
*
* 功能描述  : cshell控制命令下发
*
* 输入参数  :  SHELL_IO_CHAN *ptr_shell :shell指针
* 输出参数  :  无
*
* 返 回 值     :  无
*
* 修改记录  :
*****************************************************************************/
static int cshell_io_ioctl(SHELL_IO_CHAN *ptr_chan, int request, int arg )
{
    int status = OK;

    switch (request)
    {
        case SIO_BAUD_SET: /* set baudrate */
        {
            break;
        }
        case SIO_BAUD_GET: /* get current baudrate */
        {
            *(int *)arg = ptr_chan->baud_rate;
            status = OK;
            break;
        }
        case SIO_MODE_SET: /* set mode ( POLL or INT ) */
        {
            ptr_chan->channel_mode=arg;
            status = OK;
            break;
        }
        case SIO_MODE_GET: /* get current mode */
        {
            *(int *)arg = ptr_chan->channel_mode;
            return (OK);
        }
        case SIO_AVAIL_MODES_GET: /* get the available mode */
        {
            *(int *)arg = SIO_MODE_INT;
            return (OK);
        }
        case SIO_HW_OPTS_SET: /* set options */
        {
            ptr_chan->options=arg;
            status = OK;
            break;
        }
        case SIO_HW_OPTS_GET: /* get current options */
        {
            *(int *)arg = (int)ptr_chan->options;
            break;
        }
        case SIO_HUP: /* hang up the modem control lines */
        case SIO_IRDA_MODE:
        case UART_DMA_MODE: /* set UART to DMA mode */
        {
            /* check if hupcl option is enabled */
            status=OK;
            break;
        }
        case SIO_OPEN: /* set the modem control lines 100a*/
        {
            if (ptr_chan->options & HUPCL)
            status = OK;
            break;
        }
        case FIOSELECT:
        {
            selNodeAdd (&ptr_chan->sel_wakeup_list, (SEL_WAKEUP_NODE *) arg);
            break;
        }
        case FIOUNSELECT:
        {
            selNodeDelete (&ptr_chan->sel_wakeup_list, (SEL_WAKEUP_NODE *) arg);
            break;
        }
        default:
        {
            status = ENOSYS;
            break;
        }
    }

    return (status);
}