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

📄 intprismend.c

📁 vworks 下wlan的实现代码
💻 C
📖 第 1 页 / 共 5 页
字号:
    (FUNCPTR) intPrismStart,   	/* Function to start the device. */    (FUNCPTR) intPrismStop,  	/* Function to stop the device. */    (FUNCPTR) intPrismUnload,	/* Unloading function for the driver. */    (FUNCPTR) intPrismIoctl,	/* Ioctl function for the driver. */    (FUNCPTR) intPrismSend,	    /* Send function for the driver. */    (FUNCPTR) intPrismMCastAdd,	/* Multicast add function for the  driver. */    (FUNCPTR) intPrismMCastDel,	/* Multicast delete function*/    (FUNCPTR) intPrismMCastGet,	/* Multicast retrieve function*/    (FUNCPTR) intPrismPollSend,	/* Polling send function */    (FUNCPTR) intPrismPollRcv,	/* Polling receive function */    endEtherAddressForm,	/* put address info into a NET_BUFFER */    endEtherPacketDataGet,	/* get pointer to data in NET_BUFFER */    endEtherPacketAddrGet  	/* Get packet addresses. */    };/***************************************************************************** intPrismLoad - END load function for the WLAN driver** This routine is an END load routine.  It is designed to be called twice* per instance of the driver.  The first time, it is called with a null * (empty) initString and the device name is copied into the init string.* The second time, a proper init string is passed in.  The routine examines* the linked list of existing instances to determine if the unit number * already exists - if not it creates a new instance of the driver.** These parameters are passed to the WLAN Load routine in an initialization* string of the form:* <baseAddr>:<iVector>:<iLevel>:<offset>* *    baseAddr:  Base address of the card. Determined by the PCI/PCMCIA module*    iVector :  Interrupt vector for the card.  System dependent*    iLevel  :  Interrupt level for the card.  System dependent*    offset  :  a value of 2 enables word alignment.  Always 2 in this driver* ** RETURNS: Pointer to the device handle created or NULL on error** ERRNO: N/A** SEE ALSO: muxLib, muxDevLoad()*/END_OBJ *intPrismLoad    (    char *initString,    /* Initial parameters to initialize device with */    void * pBSP          /* Ptr. to a UINT8 value that identifies card access                             method */    )    {    WLAN_DEV *pWlanDev;    int unitNum;    STATUS result;    int i;    /* identifies card as IO or Memory mapped, PCI or PCMCIA */    void * accessType = pBSP;     WLAN_DEBUG(DEBUG_INFO, ("intPrismLoad : Loading Wireless Local Area "                            "Network Driver \n"));    /* Check that we got a valid init string.  "Null string" for the first    pass means it contains no data.  The string must still exist */    if (initString == NULL)        {        WLAN_DEBUG(DEBUG_FATAL, ("intPrismLoad : NULL initString\n"));        return NULL;        }    /* If we're on the first pass, then the first character of the initstring    must be 0x00 */    if (initString[0] == 0x00)        {        WLAN_DEBUG(DEBUG_INFO, ("intPrismLoad : First Pass.  Returning i/f "                                "name %s\n",WLAN_IFNAME));        bcopy(WLAN_IFNAME, initString, strlen(WLAN_IFNAME));         /* Add a terminating NULL char, so we don't have to rely on the init        string to be initially zeroed */        initString[strlen(WLAN_IFNAME)] = 0x00;        return NULL;        }    WLAN_DEBUG(DEBUG_INFO, ("intPrismLoad : Second Pass Init String = %s\n",                            initString));      /* If we got this far, then we're on our second pass, and the unit number    is the first character of the string (assuming we have <10 devices,     which is probably a reasonable assumption */    unitNum = (int)initString[0] - 0x30;    /* Search the list of instances of this driver, to see if a device with    this unit num already exists */    for (pWlanDev = pWlanHead; (pWlanDev != NULL) && (pWlanDev->pNext != NULL);          pWlanDev = pWlanDev->pNext)        if (pWlanDev->unitNum == unitNum)            {            WLAN_DEBUG(DEBUG_FATAL,("intPrismLoad : driver with unitnum %d "                                    "already exists.\n", unitNum));            return NULL;            }    /*     Since one doesn't exist, we need to create one.  Go to the end of the    list and do so.  Check if this is the first node, handle that     specially.    */    if (pWlanHead == (WLAN_DEV *)NULL) /* Check for empty list */        {        WLAN_DEBUG(DEBUG_INFO, ("intPrismLoad: Creating initial node\n"));        pWlanDev = (WLAN_DEV *)calloc(1, sizeof(WLAN_DEV));        pWlanHead = pWlanDev;        WLAN_DEBUG(DEBUG_INFO,("pWlanHead = 0x%08x\n", (UINT32)pWlanHead));        if (pWlanDev == NULL )            {            WLAN_DEBUG(DEBUG_FATAL, ("intPrismLoad : Error allocating "                                     "memory\n"));            return NULL;            }                }        else /* Add instance at end of linked list */        {        WLAN_DEBUG(DEBUG_INFO, ("intPrismLoad: Adding new node\n"));        for (pWlanDev = pWlanHead; pWlanDev->pNext != NULL;              pWlanDev = pWlanDev->pNext);               pWlanDev->pNext = (WLAN_DEV *)calloc(1, sizeof(WLAN_DEV));        if (pWlanDev->pNext == NULL)            {            WLAN_DEBUG(DEBUG_FATAL, ("intPrismLoad : Error allocating "                                     "memory\n"));            return NULL;            }        pWlanDev = pWlanDev->pNext;        }    /* Set the new next pointer to Null,because we're at the end of the list */    pWlanDev->pNext = NULL;    /* Card status is not fully started */    pWlanDev->cardStatus = WLAN_STATUS_DOWN;    WLAN_DEBUG(DEBUG_INFO, ("intPrismLoad: Structure Allocated\n"));    /* configure the card access function ptr's */    pWlanDev->accessType = (UINT32) accessType;    if ( (pWlanDev->accessType & WLAN_ACCESS_TYPE_MASK) == WLAN_IO_ACCESS)         {        /* set card access function ptr's to the BSP specific I/O        access routines */        pWlanDev->IN_8 =   sysWlanIOInByte;        pWlanDev->IN_16 =  sysWlanIOInWord;        pWlanDev->IN_32 =  sysWlanIOInLong;        pWlanDev->OUT_8 =  sysWlanIOOutByte;        pWlanDev->OUT_16 = sysWlanIOOutWord;        pWlanDev->OUT_32 = sysWlanIOOutLong;#if (_BYTE_ORDER == _BIG_ENDIAN)         {        pWlanDev->IN_16_ENDIAN = sysWlanIOEndianInWord;        pWlanDev->OUT_16_ENDIAN = sysWlanIOEndianOutWord;        }#else         {        pWlanDev->IN_16_ENDIAN = sysWlanIOInWord;        pWlanDev->OUT_16_ENDIAN = sysWlanIOOutWord;        }#endif        WLAN_DEBUG(DEBUG_FLOOD,("intPrismLoad: configuring card access "                                "routines as I/O based\n"));        }    else if ( (pWlanDev->accessType & WLAN_ACCESS_TYPE_MASK) == WLAN_MEM_ACCESS)         {        /* set card access function ptr's to the BSP specific direct         Memory access routines */                pWlanDev->IN_8 = sysWlanMemInByte;        pWlanDev->IN_16 = sysWlanMemInWord;        pWlanDev->IN_32 = sysWlanMemInLong;        pWlanDev->OUT_8 = sysWlanMemOutByte;        pWlanDev->OUT_16 = sysWlanMemOutWord;        pWlanDev->OUT_32 = sysWlanMemOutLong;        #if (_BYTE_ORDER == _BIG_ENDIAN)         {        pWlanDev->IN_16_ENDIAN = sysWlanMemEndianInWord;        pWlanDev->OUT_16_ENDIAN = sysWlanMemEndianOutWord;        }#else         {        pWlanDev->IN_16_ENDIAN = sysWlanMemInWord;        pWlanDev->OUT_16_ENDIAN = sysWlanMemOutWord;        }#endif        WLAN_DEBUG(DEBUG_FLOOD,("intPrismLoad: configuring card access "                                "routines as Mem mapped\n"));        }    else         {        WLAN_DEBUG(DEBUG_ERROR, ("intPrismLoad: Undetermined card access type:"                                 " 0x%x\n", pWlanDev->accessType));        return NULL;        }    if ((pWlanDev->accessType & WLAN_PHY_CARD_TYPE_MASK) == WLAN_PCMCIA_CARD)         {        /* set the register definition's to the PCMCIA values */        pWlanDev->regs = pcmciaRegisters;         WLAN_DEBUG(DEBUG_FLOOD,                   ("intPrismEndLoad: using Pcmcia register offsets\n"));        }    else if ((pWlanDev->accessType & WLAN_PHY_CARD_TYPE_MASK) == WLAN_PCI_CARD)         {        /* set the register definition's to the MiniPCI values */        pWlanDev->regs = miniPciRegisters;                WLAN_DEBUG(DEBUG_FLOOD,                   ("intPrismEndLoad: using PCI register offsets\n"));        }    else         {        WLAN_DEBUG(DEBUG_ERROR, ("intPrismLoad: Undetermined card access type:"                                 " 0x%x\n", pWlanDev->accessType));        return NULL;        }    /* Fill the structure with data gleaned from the initString */    if (intPrismParse(pWlanDev, initString) == ERROR)        {        WLAN_DEBUG(DEBUG_FATAL,("intPrismLoad: Error in intPrismParse\n"));        return NULL;        }    WLAN_DEBUG(DEBUG_INFO,("intPrismLoad: pWlanDev = 0x%08x\n",                            (UINT32)pWlanDev));    /* Card is set into station mode initially */    pWlanDev->cardMode = WLAN_CARDMODE_STA;     for (i=0; i<WLAN_MAX_TX_BUF; i++)        {        pWlanDev->txPool[i].empty = semBCreate(SEM_Q_FIFO, SEM_FULL);        }    pWlanDev->curTx = 0;    /* Semaphore used to signal CMD events back to intPrismCommandAsync */    if ((pWlanDev->commandComplete = semBCreate(SEM_Q_FIFO, SEM_EMPTY)) == NULL)        {        WLAN_DEBUG(DEBUG_FATAL, ("intPrismLoad: semBCreate on commandComplete"                                 " failed\n"));        return NULL;        }    /* Semaphore used to ensure only one command runs at a time */    if ((pWlanDev->commandProt = semMCreate(SEM_Q_PRIORITY)) == NULL)        {        WLAN_DEBUG(DEBUG_FATAL, ("intPrismLoad: semBCreate on commandComplete"                                 " failed\n"));        return NULL;        }    /* Initialize the semaphores */    if((pWlanDev->BAP1Sem = semMCreate(SEM_Q_FIFO)) == NULL)        {        WLAN_DEBUG(DEBUG_FATAL, ("intPrismLoad: semMCreate on BAP1sem "                                 "failed\n"));        return NULL;        }    /* Set the IOCTL extension to use our extended IOCTLs */    pWlanDev->pIoctl = (FUNCPTR)intPrismManage;    /* Set the default WEP key number */    pWlanDev->defaultKey = 0;    /* Set buffer depletion flag  */    pWlanDev->txBlocked = FALSE;    /* Set the card up, initialize it and run diagnostics.  Interrupts are    disabled, but the card is left in the enabled state */    if (intPrismInit(pWlanDev) == ERROR)        {        WLAN_DEBUG(DEBUG_FATAL,("intPrismLoad: Error in intPrismInit\n"));        return NULL;        }    /* Set the default mask (this modifies the structure only.  The actual    enabling of card interrupts is done in intPrismStart() */    pWlanDev->intMask = WLAN_EV_RX | WLAN_EV_ALLOC | WLAN_EV_INFO | WLAN_EV_CMD;    pWlanDev->unitNum = unitNum;    /* Do standard END structure initialization.  Must be done after card    initialization, as we need the MAC address to initialize MIB2 stuff*/    if ((END_OBJ_INIT (&pWlanDev->endObj, (DEV_OBJ *)pWlanDev,                        (char *)WLAN_IFNAME,                       pWlanDev->unitNum,                        &intPrismFuncTable,                       "Wind River Systems WLAN END driver") == ERROR))        {        WLAN_DEBUG(DEBUG_FATAL,("intPrismLoad: END or MIB2 init failed\n"));        return NULL;        }    /* Clear statistics */    bzero((char*)&pWlanDev->stats, sizeof(WLAN_STATS));    /* Clear the WEP key table */    bzero((char *)pWlanDev->keyTable, WLAN_WEP_NUM_KEYS * WLAN_WEP_MAX_KEYSIZE);    /* Init the MIB-II table */    if (mib2Init(&(pWlanDev->endObj.mib2Tbl), M2_ifType_ethernet_csmacd,                 pWlanDev->MACAddr, WLAN_ENET_ADDR_LEN, ETHERMTU,                 WLAN_END_SPEED) == ERROR)        {        WLAN_DEBUG(DEBUG_FATAL, ("intPrismLoad: Failed MIB-II init.\n"));        return NULL;        }    /* Allocate memory for clusters, net pool */    if (intPrismMemInit(pWlanDev) == ERROR)        {        WLAN_DEBUG(DEBUG_FATAL, ("intPrismLoad: Memory Error\n"));        return NULL;        }    /* Now that memory for the MUX is initialized, complete END init*/    END_OBJ_READY(&pWlanDev->endObj, IFF_NOTRAILERS | IFF_BROADCAST |                   IFF_MULTICAST | IFF_UP | IFF_RUNNING);

⌨️ 快捷键说明

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