コード例 #1
0
ファイル: eventfdDev.c プロジェクト: Ga-vin/libsylixos
/*********************************************************************************************************
** 函数名称: API_EventfdDrvInstall
** 功能描述: 安装 eventfd 设备驱动程序
** 输 入  : NONE
** 输 出  : 驱动是否安装成功
** 全局变量: 
** 调用模块: 
                                           API 函数
*********************************************************************************************************/
LW_API  
INT  API_EventfdDrvInstall (VOID)
{
    if (_G_iEvtfdDrvNum <= 0) {
        _G_iEvtfdDrvNum  = iosDrvInstall(LW_NULL,
                                         LW_NULL,
                                         _evtfdOpen,
                                         _evtfdClose,
                                         _evtfdRead,
                                         _evtfdWrite,
                                         _evtfdIoctl);
        DRIVER_LICENSE(_G_iEvtfdDrvNum,     "Dual BSD/GPL->Ver 1.0");
        DRIVER_AUTHOR(_G_iEvtfdDrvNum,      "Han.hui");
        DRIVER_DESCRIPTION(_G_iEvtfdDrvNum, "eventfd driver.");
    }
    
    if (_G_hEvtfdSelMutex == LW_OBJECT_HANDLE_INVALID) {
        _G_hEvtfdSelMutex =  API_SemaphoreMCreate("evtfdsel_lock", LW_PRIO_DEF_CEILING, 
                                                  LW_OPTION_WAIT_PRIORITY | LW_OPTION_DELETE_SAFE |
                                                  LW_OPTION_INHERIT_PRIORITY | LW_OPTION_OBJECT_GLOBAL,
                                                  LW_NULL);
    }
    
    return  ((_G_iEvtfdDrvNum == (PX_ERROR)) ? (PX_ERROR) : (ERROR_NONE));
}
コード例 #2
0
ファイル: dac3550drv.c プロジェクト: rgmabs19357/gameseer
/* Device creation routines...
 */
STATUS dac3550Drv (void)
{

  if (DrvNum > 0) return OK;

  DrvNum = iosDrvInstall (sndCreate, NULL, sndOpen, sndClose,
			  sndRead, sndWrite, sndIoctl);

  return (DrvNum == ERROR) ? ERROR : OK;
}
コード例 #3
0
/* Entry point of driver */
int DSL_DRV_DeviceCreate(void)
{
   DSL_int_t i;
   DSL_char_t name[32];

   printf(DSL_DRV_CRLF DSL_DRV_CRLF "Lantiq CPE API Driver version: %s" DSL_DRV_CRLF,
      &(dsl_cpe_api_version[4]));

   DSL_DRV_MemSet( &ifxDevices, 0, sizeof(DSL_devCtx_t) * DSL_DRV_MAX_ENTITIES );

   /* Apply initial debug levels. The lines below should be updated in case of
      new modules insert */
#ifndef DSL_DEBUG_DISABLE
   DSL_DRV_DebugInit();
#endif

   DSL_DRV_DrvNum = iosDrvInstall(IFX_NULL, IFX_NULL,
                                (FUNCPTR)DSL_DRV_Open,
                                (FUNCPTR)DSL_DRV_Close,
                                IFX_NULL,
                                (FUNCPTR)DSL_DRV_Write,
                                (FUNCPTR)DSL_DRV_Ioctls);

   /* Get handles for lower level driver */
   for (i = 0; i < DSL_DRV_MAX_ENTITIES; i++)
   {
      ifxDevices[i].lowHandle = DSL_DRV_DEV_DriverHandleGet(0,i);
      if (ifxDevices[i].lowHandle == DSL_NULL)
      {
         printf("Get BSP Driver Handle Fail!"DSL_DRV_CRLF);
      }
#ifdef INCLUDE_DSL_NFC_HANDLE
      ifxDevices[i].nfc_lowHandle = DSL_DRV_DEV_DriverHandleGet(0,i);
      if (ifxDevices[i].lowHandle == DSL_NULL)
      {
         printf("Get BSP Driver NFC Handle Fail!"DSL_DRV_CRLF);
      }
#endif /* INCLUDE_DSL_NFC_HANDLE*/

      ifxDevices[i].nUsageCount = 0;
      ifxDevices[i].bFirstPowerOn = DSL_TRUE;
      DSL_DEBUG(DSL_DBG_MSG, (DSL_NULL, SYS_DBG_MSG"ifxDevices[%d].lowHandle=0x%0X"
         DSL_DRV_CRLF, i, ifxDevices[i].lowHandle));

      /* Set device number*/
      DSL_DevHeader[i].deviceNum = i;

      sprintf(name, "/dev/%s/%d", DRV_DSL_CPE_API_DEV_NAME, i);
      DSL_DRV_DevNodeInit(&DSL_DevHeader[i], name, DSL_DRV_DrvNum);
   }

   return 0;
}
コード例 #4
0
ファイル: ttyDrv.c プロジェクト: andy345/vxworks5
STATUS ttyDrv (void)

    {
    /* check if driver already installed */

    if (ttyDrvNum > 0)
        return (OK);

    ttyDrvNum = iosDrvInstall (ttyOpen, (FUNCPTR) NULL, ttyOpen,
                                ttyClose, tyRead, tyWrite, ttyIoctl);

    return (ttyDrvNum == ERROR ? ERROR : OK);
    }
コード例 #5
0
ファイル: can.c プロジェクト: Ga-vin/libsylixos
/*********************************************************************************************************
** 函数名称: API_CanDrvInstall
** 功能描述: 安装 can 驱动程序
** 输 入  : NONE
**
** 输 出  : NONE
** 全局变量:
** 调用模块:
**                                            API 函数
*********************************************************************************************************/
LW_API
INT  API_CanDrvInstall (void)
{
    if (_G_iCanDrvNum > 0) {
        return  (ERROR_NONE);
    }

    _G_iCanDrvNum = iosDrvInstall(__canOpen, LW_NULL, __canOpen, __canClose,
                                  __canRead, __canWrite, __canIoctl);

    DRIVER_LICENSE(_G_iCanDrvNum,     "Dual BSD/GPL->Ver 1.0");
    DRIVER_AUTHOR(_G_iCanDrvNum,      "Wang.feng");
    DRIVER_DESCRIPTION(_G_iCanDrvNum, "CAN Bus driver.");

    return  (_G_iCanDrvNum > 0) ? (ERROR_NONE) : (PX_ERROR);
}
コード例 #6
0
ファイル: hotplugDev.c プロジェクト: Ryanxjl/libsylixos-mips
/*********************************************************************************************************
** 函数名称: _hotplugDrvInstall
** 功能描述: 安装 hotplug 消息设备驱动程序
** 输 入  : NONE
** 输 出  : 驱动是否安装成功
** 全局变量: 
** 调用模块: 
*********************************************************************************************************/
INT  _hotplugDrvInstall (VOID)
{
    if (_G_iHotplugDrvNum <= 0) {
        _G_iHotplugDrvNum  = iosDrvInstall(_hotplugOpen,
                                           LW_NULL,
                                           _hotplugOpen,
                                           _hotplugClose,
                                           _hotplugRead,
                                           _hotplugWrite,
                                           _hotplugIoctl);
        DRIVER_LICENSE(_G_iHotplugDrvNum,     "GPL->Ver 2.0");
        DRIVER_AUTHOR(_G_iHotplugDrvNum,      "Han.hui");
        DRIVER_DESCRIPTION(_G_iHotplugDrvNum, "hotplug message driver.");
    }
    
    return  ((_G_iHotplugDrvNum == (PX_ERROR)) ? (PX_ERROR) : (ERROR_NONE));
}
コード例 #7
0
ファイル: pipe.c プロジェクト: Ga-vin/libsylixos
LW_API 
INT  API_PipeDrvInstall (VOID)
{
    if (_G_iPipeDrvNum <= 0) {
        _G_iPipeDrvNum  = iosDrvInstall( (LONGFUNCPTR)LW_NULL,          /*  CREATE                      */
                                         (FUNCPTR)LW_NULL,              /*  DELETE                      */
                                         _PipeOpen,                     /*  OPEN                        */
                                         _PipeClose,                    /*  CLOSE                       */
                                         _PipeRead,                     /*  READ                        */
                                         _PipeWrite,                    /*  WRITE                       */
                                         _PipeIoctl);                   /*  IOCTL                       */
                                          
        DRIVER_LICENSE(_G_iPipeDrvNum,     "Dual BSD/GPL->Ver 1.0");
        DRIVER_AUTHOR(_G_iPipeDrvNum,      "Han.hui");
        DRIVER_DESCRIPTION(_G_iPipeDrvNum, "VxWorks pipe driver.");
    }
    
    return  ((_G_iPipeDrvNum == (PX_ERROR)) ? (PX_ERROR) : (ERROR_NONE));
}
コード例 #8
0
ファイル: driver.c プロジェクト: hermixy/driver
/*
 * Admin functions API: install of driver and then of devices.
 *						uninstall of devices and then of driver
 *						direct driver uninstall is also supported
 */
int drvInstall()
{
	if (semMAdmin==0)
	{//The semaphore hasn't been created yet : the driver has not been installed yet,
	 //let's do it
		semMAdmin = semMCreate(SEM_Q_FIFO);
		if(semMAdmin==0)
		{
			errnoSet(SEM_ERR);
			return -1;
		}
	} else {
		errnoSet(ALREADY_INSTALLED);
		return -1;
	}
	isrmq = msgQCreate(10,4,0); //Create a msg queue with 10 msg max,
								//4 byte per msg max, and msgs filled up in fifo order
	if (isrmq == NULL)
	{
		errnoSet(MSGQ_ERR);
		return -1;
	}
	tMsgDispatchID = taskSpawn("tMsgDispatch",0,0,1000,msgDispatch,(int)semMAdmin,0,0,0,0,0,0,0,0,0);
	//This task will dispatch a msg received by the isr and sleep the rest of the time.
	//It needs to be fast to prevent isr msg queue to fill up, hence the high priority
	//It's also nice for tests if his priority is superior than the shell's one, which
	//is set to 1
	if (tMsgDispatchID==-1)
	{
		msgQDelete(isrmq);
		errnoSet(TASK_ERR);
		return -1;
	}
	numPilote=iosDrvInstall(0,0,devOpen,devClose,devRead,0,0); //Register device in ios
	if (numPilote == -1)
	{
		msgQDelete(isrmq);
		taskDelete(tMsgDispatchID);
		errnoSet(INSTALL_ERR);
		return -1;
	}
	return 0;
}
コード例 #9
0
ファイル: i8042KbdMse.c プロジェクト: phoboz/vmx
int i8042MseDevCreate(
    char *name
    )
{
    int               result;
    int               drvNum;
    I8042_MSE_DEVICE *pDev;

    drvNum = iosDrvInstall(
        (FUNCPTR) i8042MseOpen,
        (FUNCPTR) i8042MseDelete,
        (FUNCPTR) i8042MseOpen,
        (FUNCPTR) i8042MseClose,
        (FUNCPTR) i8042MseRead,
        (FUNCPTR) i8042MseWrite,
        (FUNCPTR) i8042MseIoctl
        );
    if (drvNum == ERROR)
    {
       result = ERROR;
    }
    else
    {
        pDev = (I8042_MSE_DEVICE *) malloc(sizeof(I8042_MSE_DEVICE));
        if (pDev == NULL)
        {
            result = ERROR;
        }
        else
        {
            if (tyDevInit(
                    &pDev->tyDev,
                    512,
                    512,
                    (FUNCPTR) i8042MseTxStart) != OK)
            {
                free(pDev);
                result = ERROR;
            }
            else
            {
                /* Initialize device registers */
                pDev->dataReg = I8042_KBD_DATA_REG;
                pDev->statReg = I8042_KBD_STAT_REG;
                pDev->cmdReg  = I8042_KBD_CMD_REG;

                /* Connect interrupt handler */
                intConnectDefault(I8042_MSE_INT, (VOIDFUNCPTR) i8042Intr, pDev);

                i8042MseHwInit(pDev);

                /* Enable interrupt level */
                sysIntEnablePIC(I8042_MSE_INT_LVL);

                if (iosDevAdd(&pDev->tyDev.devHeader, name, drvNum) != OK)
                {
                    free(pDev);
                    result = ERROR;
                }
                else
                {
                    result = drvNum;
                }
            }
        }
    }

    return result;
}
コード例 #10
0
ファイル: driverl.c プロジェクト: boysb25/VxWorks-Driver
/**
 * @brief Installation du périphérique.
 * 
 * @param dev_count Le nombre de périphériques à créer.
 * 
 * @return OK si la fonction s'est executé normalement, ERROR sinon.
 */
int pe_driverInstall(int dev_count)
{
	/* iteration pour la création des périphériques */
	int i = 0;
	struct timespec initial_time = {0 , 0};
	
	
	if(dev_count > DEVICE_MAX_COUNT)
	{
		errnoSet(ETOOMUCHDEV);
		return ERROR;
	}
	
	if(driver_id != -1)
	{
		errnoSet(EINSTALLED);
		return ERROR;
	}
	
	/* Driver installation */
	driver_id = iosDrvInstall(pe_open,pe_close, pe_open, pe_close, pe_read, (FUNCPTR) NULL, pe_ioctl);
	if(driver_id < 0)
	{
		errnoSet(EUNKNOW);
		return ERROR;
	}
	
	/* Création du sémaphore d'exclusion mutuelle pour les deux tables (table_capt
	 * et table_buffer, qui sont susceptibl
	 * Les tâches s'enfilent dans l'ordre d'arrivée avec SEM_Q_FIFO, et 
	 * SEM_DELETE_SAFE garantie que la tâche ayant verrouillé un sémaphore ne soit 
	 * pas détruite avant de le libérer.
	 */
	mut_table_capt = semMCreate(SEM_Q_FIFO | SEM_DELETE_SAFE);
	
	if(mut_table_capt == NULL)
	{
		return ERROR;
	}
	
	mut_table_buffer = semMCreate(SEM_Q_FIFO | SEM_DELETE_SAFE);
	
	if(mut_table_buffer == NULL)
	{
		return ERROR;
	}
	
	/* Création de la file de message de communication entre le serveur d'interuption
	 * et la tâche dispatcher
	 */
	msgQ_dispatcher = msgQCreate(10, sizeof(Message), MSG_Q_FIFO );
	
	if(msgQ_dispatcher == NULL)
	{
		return ERROR;
	}	
	
	/* Création de la tâche dispatcher
	 */
	id_pe_task_dispatcher = taskSpawn("pe_task_dispatcher", DISPATCHER_PRIORITY, 0, 512, (FUNCPTR) pe_dispatcher, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
	
	if(id_pe_task_dispatcher == ERROR)
	{
		return ERROR;
	}

	for(i=0 ; i < dev_count; ++i)
	{
		if(pe_deviceAdd(i) == ERROR)
		{
			pe_cleanup_resources();
			errnoSet(ECANNOTADD);
			return ERROR;
		}
	}
	
	for(; i < DEVICE_MAX_COUNT; i++)
	{
		table_capt[i].specific.address = -1;
		table_capt[i].specific.state = notcreated;
		table_buffer[i].id = -1;
	}
	
	/* Initialisation de l'horloge système : elle est placée arbitrairement
	 * à 0:0 à l'installation du pilote. */
	sysClkRateSet(100);
	clock_settime(CLOCK_REALTIME, &initial_time);
	
	return driver_id;
}