⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cisaironethw.c

📁 vworks 下wlan的实现代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    (    CARD_CTRL_T * pWlanDev /* Driver control struct */    )    {    STATUS       status  = OK;    CARD_CMD_T * pCmdObj = NULL;    /* sanity check */    if (pWlanDev == NULL)        {        ANET_DEBUG(DEBUG_ERROR,                   ("cisAironetHwScanStart: error NULL pointer\n"));        return (ERROR);        }    /* Get reference to command object */    pCmdObj  = (CARD_CMD_T *) &pWlanDev->macCmd;    /* Send the Init command to the card */    pCmdObj->param0  = 0;    pCmdObj->param1  = 0;    pCmdObj->param2  = 0;    pCmdObj->command = ANET_FSYNC_LOSS;    /* Issue the command */    (void) cisAironetHwCmdIssue (pWlanDev);    /* return - status */    return (status);    }/**************************************************************************** cisAironetHwPwrModeSet - Sets the card power save mode.* * Sets the cards power save mode.* * RETURNS : OK or ERROR on non-valid power save mode.** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual** NOMANUAL*/STATUS cisAironetHwPwrModeSet    (    CARD_CTRL_T * pWlanDev, /* Driver control struct */    UINT16        mode     /* Power save mode to be set */    )    {    /* check if entering power save mode */    if ((mode == ANET_POWERSAVE_PSP) || (mode == ANET_POWERSAVE_FASTPSP))        {        /* First try setting the new powersave mode */        if (cisAironetHwModeSet (pWlanDev, mode) == ERROR)            {            ANET_DEBUG(DEBUG_ERROR,                       ("cisAironetHwPwrModeSet: error setting PSP mode\n"));            return (ERROR);            }                /* Set the driver state variable */        pWlanDev->powerSave = TRUE;                }    /* otherwise check if leaving power save mode */    else if (mode == ANET_POWERSAVE_CAM)        {        /* First try setting the new powersave mode */        if (cisAironetHwModeSet (pWlanDev, mode) == ERROR)            {            ANET_DEBUG(DEBUG_ERROR,                       ("cisAironetHwPwrModeSet: error setting CAM mode\n"));            return (ERROR);            }                       /* Set the driver state variable */        pWlanDev->powerSave = FALSE;        }    /* otherwise the value is invalid */    else        {        return (ERROR);        }        /* return - OK */    return (OK);    }/**************************************************************************** cisAironetHwWakeup - Brings the card out of sleep mode.* * Brings the card out of sleep mode.* * RETURNS : OK or ERROR is NULL pointer passed in as parameter.** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual** NOMANUAL*/STATUS cisAironetHwWakeup     (    CARD_CTRL_T * pWlanDev /* Driver control struct */    )    {    FAST ULONG initialTick = 0;    FAST ULONG numTicks    = 0;    /* Disable board level interrupts */    CISAIR_CARD_INTS_DISABLE (pWlanDev);    WLAN_OUT_16( (UINT32) &pWlanDev->macReg->evAck, ANET_EVENT_AWAKE);    WLAN_OUT_16( (UINT32) &pWlanDev->macReg->evAck, ANET_EVENT_AWAKE);    /*      * Wait for 16ms * 4 = 64ms - The worst case is 50ms to      * come out of sleep mode      */    initialTick = (ULONG) tickGet ();    while ( numTicks < 4)        {        numTicks = initialTick - tickGet ();        }    /* Enable board level interrupts */	    CISAIR_CARD_INTS_ENABLE (pWlanDev);    return (OK);    }/**************************************************************************** cisAironetHwIntEnable - Enables the board level interrupts *                         (ie aironet card level).* * Enables the board level interrupts that were set in the control driver * interrupt mask.* * RETURNS : OK or ERROR if a NULL pointer is passed in.** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual** NOMANUAL*/STATUS cisAironetHwIntEnable    (    CARD_CTRL_T * pWlanDev     )     {    /* sanity check */    if (pWlanDev == NULL)        {        return (ERROR);        }	/* Enable the interrupts */	WLAN_OUT_16( (UINT32) &pWlanDev->macReg->evIntEn,                  pWlanDev->intMask);    /* return - status */    return (OK);    }/**************************************************************************** cisAironetHwIntDisableAll - Disables all interrupt sources on the card.* * Disables all interrupt sources on the card.* * RETURNS : OK or ERROR if a NULL pointer is passed in.** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual** NOMANUAL*/STATUS cisAironetHwIntDisableAll    (    CARD_CTRL_T * pWlanDev     )     {    /* sanity check */    if (pWlanDev == NULL)        {        return (ERROR);        }	/* Enable the interrupts */	WLAN_OUT_16( (UINT32) &pWlanDev->macReg->evIntEn, 0x0000);    /* return - status */    return (OK);    }/**************************************************************************** cisAironetHwIntAckAll - Acknowledge (clear) all pending interrupts on *                         the aironet card.* * clears all pending interrupts on the aironet card.* * RETURNS : OK or ERROR if a NULL pointer is passed in.** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual** NOMANUAL*/STATUS cisAironetHwIntAckAll    (    CARD_CTRL_T * pWlanDev     )     {    /* sanity check */    if (pWlanDev == NULL)        {        return (ERROR);        }    /* Ack any pending interrupts */	WLAN_OUT_16( (UINT32) &pWlanDev->macReg->evAck, 0xFFFF);    /* return - status */    return (OK);        }/**************************************************************************** cisAironetHwModeSet - Issues the aironet mode set command.* * Sets the card into a specified operational mode.* * RETURNS : OK or ERROR if a NULL pointer is passed in or the set mode *           command fails.** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual** NOMANUAL*/STATUS cisAironetHwModeSet    (    CARD_CTRL_T * pWlanDev,    UINT16        mode    )     {    CARD_CMD_T * pCmdObj = NULL;    /* sanity check */    if (pWlanDev == NULL)        {        ANET_DEBUG(DEBUG_ERROR,                   ("cisAironetHwModeSet: error NULL pointer\n"));        return (ERROR);        }    /* Get reference to command object */    pCmdObj  = (CARD_CMD_T *) &pWlanDev->macCmd;    /* populate the CmdObj with the command info */    pCmdObj->param0  = mode;    pCmdObj->param1  = 0;    pCmdObj->param2  = 0;    pCmdObj->command = ANET_SET_MODE;    if ( (cisAironetHwCmdIssue (pWlanDev)   == ERROR)  ||         (cisAironetHwErrorCheck (pWlanDev) != 0) )        {        ANET_DEBUG(DEBUG_ERROR,                   ("cisAironetHwModeSet: command failed %s\n",                    (UINT8 *) cisAironetHwErrorDesc ()));        return (ERROR);        }    ANET_DEBUG(DEBUG_INFO,               ("cisAironetHwModeSet: command success\n"));    return (OK);    }/*=========================================================================*//*                                                                         *//*               CARD BUFFER ACCESS PATH - ACCESS ROUTINES                 *//*                                                                         *//*=========================================================================*//**************************************************************************** cisAironetHwMacAddrGet - Gets the aironet cards ethernet address (MAC).* * Copies the card ethernet address (MAC) into the driver control structure.* * RETURNS : OK or ERROR if a NULL pointer is passed in or it cannot access *           config rid on the card.     ** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual*/LOCAL STATUS cisAironetHwMacAddrGet    (    CARD_CTRL_T * pWlanDev    )    {    CFG_RID_T   cfg;    CFG_RID_T * pCfg = (CFG_RID_T *) &cfg;            /* sanity check */    if (pWlanDev == NULL)        {        ANET_DEBUG(DEBUG_ERROR,                   ("cisAironetHwMacAddrGet: error NULL pointer\n"));        return (ERROR);        }    /* Get the config rid defaults */    if ( bapRead (pWlanDev,             /* Driver control object */                  ANET_RID_CONFIG,     /* Rid to access */                  0,                   /* offset == 0 */                  ANET_BAP1,           /* BAP1 used to access RID's */                  (UINT16 *) pCfg,     /* object to fill up */                  sizeof (CFG_RID_T))  /* number of bytes */         == ERROR )        {        ANET_DEBUG (DEBUG_ERROR,                     ("cisAironetHwMacAddrGet: Error reading CONFIG RID\n"));        return (ERROR);        }    /* Save the mac address into the driver control struct */    (void) cisAironetBcopy ( pWlanDev,                              (const UINT8*) pCfg->macAddr,                              (UINT8*)       pWlanDev->MACAddr,                              NELEMENTS(pWlanDev->MACAddr));        /* return - status */    return (OK);    }/**************************************************************************** cisAironetHwBapSetup - Sets up the buffer access path that is to be *                        accessed.* * Sets up the buffer access path that is to be accessed.* * RETURNS : OK or ERROR if BAP register could not be accessed     ** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual*/LOCAL STATUS cisAironetHwBapSetup    (    CARD_CTRL_T * pWlanDev,  /* Driver control object */    UINT16        rid,      /* RID to access */    UINT16        offset,   /* offset into BAP */    INT32         bap       /* 0-BAP0 and 2-BAP1 */    )    {	UINT32 timeOut   = ANET_BAP_RETRIES;    UINT32 retries   = ANET_BAP_CMD_RETRIES;    INT32  selectReg = (INT32) NULL;    INT32  offsetReg = (INT32) NULL;    UINT16 status    = 0;    INT16  sts       = OK;       /* Setup registers to access */    selectReg = ((INT32) &pWlanDev->macReg->select0) + bap;    offsetReg = ((INT32) &pWlanDev->macReg->offset0) + bap;    	    /* Setup buffer access path */	WLAN_OUT_16( (UINT32) selectReg, rid);   	WLAN_OUT_16( (UINT32) offsetReg, offset);    while (retries-- != 0)         {        status = (UINT16) WLAN_IN_16((UINT32) offsetReg);        if ( (status & ANET_OFF_BUSY)              == ANET_OFF_BUSY )             {            /* Check for a time out */            if ( timeOut-- == 0 )                {                WLAN_OUT_16( (UINT32) selectReg, rid);                   WLAN_OUT_16( (UINT32) offsetReg, offset);                timeOut = ANET_BAP_RETRIES;                }            continue;            }         /* Check for error */        if ( (UINT16) (status & ANET_OFF_ERR)              == ANET_OFF_ERR )             {            sts = ERROR;            break;            }                 /* Check to see if the tranaction is done */        if ( (UINT16) (status & ANET_BAP_DONE)              == ANET_BAP_DONE )             { /* success */            break;            }        /* Card missed command so try again */        WLAN_OUT_16( (UINT32) selectReg, rid);           WLAN_OUT_16( (UINT32) offsetReg, offset);        }    return (sts);    }/**************************************************************************** bapWrite - Writes data to a buffer access path.* * This routine performs all the required initialization so the the user can * tranparently access the desired BAP..* * RETURNS : OK or cmd response or ERROR if a NULL pointer is passed in or if *           required BAP init fails.     ** ERRNO : N/A** SEE ALSO: Cisco Aironet 340/350 Driver Programmer's Manual*/LOCAL INT16 bapWrite    (    CARD_CTRL_T * pWlanDev,  /* Driver control object */    UINT16        rid,      /* RID to access */    UINT32        offset,   /* The offset into RID */    UINT16        bap,      /* BAP to access (0 or 1) */    UINT16 *      pSrc,     /* Source buffer */ 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -