Beispiel #1
0
STATUS ttyDevCreate
    (
    char *      name,           /* name to use for this device      */
    SIO_CHAN *	pSioChan,	/* pointer to core driver structure */
    int         rdBufSize,      /* read buffer size, in bytes       */
    int         wrtBufSize      /* write buffer size, in bytes      */
    )
    {
    TYCO_DEV *pTyCoDev;

    if (ttyDrvNum <= 0)
        {
        errnoSet (S_ioLib_NO_DRIVER);
        return (ERROR);
        }

    if (pSioChan == (SIO_CHAN *) ERROR)
	{
        return (ERROR);
	}

    /* allocate memory for the device */

    if ((pTyCoDev = (TYCO_DEV *) malloc (sizeof (TYCO_DEV))) == NULL)
        return (ERROR);

    /* initialize the ty descriptor */

    if (tyDevInit (&pTyCoDev->tyDev, rdBufSize, wrtBufSize,
                   (FUNCPTR) ttyStartup) != OK)
        {
	free (pTyCoDev);
        return (ERROR);
        }

    /* initialize the SIO_CHAN structure */

    pTyCoDev->pSioChan	= pSioChan;
    sioCallbackInstall (pSioChan, SIO_CALLBACK_GET_TX_CHAR,
			tyITx, (void *)pTyCoDev);
    sioCallbackInstall (pSioChan, SIO_CALLBACK_PUT_RCV_CHAR,
			tyIRd, (void *)pTyCoDev);

    /* start the device cranking */

    sioIoctl (pSioChan, SIO_MODE_SET, (void *)SIO_MODE_INT);

    /* add the device to the I/O system */

    return (iosDevAdd (&pTyCoDev->tyDev.devHdr, name, ttyDrvNum));
    }
Beispiel #2
0
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;
}