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

📄 sysdot11end.c

📁 PNE 3.3 wlan source code, running at more than vxworks6.x version
💻 C
📖 第 1 页 / 共 5 页
字号:
    /* If there is a bsp level end table binding function    then we will us it */    if (binding->bsp->system.endDevTblAdd != NULL)         {        rcode = binding->bsp->system.endDevTblAdd(devNum,                                                  sysDot11EndLoad,                                                  "",                                                  TRUE,                                                  NULL);        }    else        {        volatile UINT32 idx = 0; /* index in endEndTbl  */        /* Find the first free space in the end table */        while (binding->endTbl[idx].endLoadFunc != END_TBL_END)            {            idx++;            }        /* bind in the end driver parameters */        if (binding->endTbl[idx].unit == -1)            {            /* The space we have found is valid so lets             add the entry */            binding->endTbl[idx].unit = devNum;            binding->endTbl[idx].endLoadFunc = sysDot11EndLoad;             binding->endTbl[idx].endLoadString = "";            binding->endTbl[idx].endLoan = TRUE;            binding->endTbl[idx].processed = FALSE;            }        else            {            /* No more space left in the table */            rcode = ERROR;            }        }            /* Return call status to callee */    return(rcode);    }/****************************************************************************** sysDot11EndLoad - load an instance of the END driver** This routine loads the End driver with a pointer to the parameter * structure .** RETURNS: pointer to END object or ERROR.*/END_OBJ* sysDot11EndLoad    (    char* initString,   /* Initial parameters to initialize device with */    void* pBsp          /* unused */    )    {    /*     * The End driver END_LOAD_STRING should be:     * "<unitNum>:<ptr to the param struc>". The format looks like "%d:0x%X".     *  Note that the unit number is prepended by mux.     */    char paramStr[END_INIT_STR_MAX];  /* from end.h */    END_OBJ* pEnd = NULL;    char* cp = NULL; 	    char* token = NULL;    UINT16 unitNum = 0;    UINT32 clSize = 0;     /* Sanity check */    if (initString == NULL)        {        /* Error */        return(NULL);        }    if (strlen(initString) == 0)        {        /* muxDevLoad() calls us twice.  If the string is        zero length, then this is the first time through        this routine, so we just return. */        pEnd = binding->endLoad(initString, pBsp);        }    else        {        DOT11_BSP_INFO nfo;        DOT11_BSP_INFO* card = &nfo;        /* On the second pass though here, we actually create          the initialization parameter string on the fly.            Note that we will be handed our unit number on the          second pass through and we need to preserve that information.         So we use the unit number handed from the input string. */            /* get the unit num from init string */        cp = strcpy(paramStr, initString);                 token = strtok(cp, ":");        /* Sanity check */        if (token == NULL)             {            /* Cannot find the start token so return and error  */            return(NULL);            }        /* Assing a unit number base on the init string */        unitNum = atoi(token);        /* Make sure that there is support for the physical device */        if (unitNum > (binding->nDevs - 1))            {            /* Illegal unit number so return an error to the callee */            return(NULL);            }        /* Validate the desired resource */        if (binding->resource[unitNum].used == FALSE)            {            /* The desired resouce is not available */            return(NULL);            }         /* cp points to paramStr */        cp = strcpy(paramStr, initString);         /* Now, we advance cp, by finding the end the string */        cp += strlen(paramStr);        /* Init the required bsp to end driver */        card->magicNum = binding->resource[unitNum].magicNum;        card->memBaseAddr = binding->resource[unitNum].membaseCsr;        card->ivec = binding->resource[unitNum].irqVector;        card->ilevel = binding->resource[unitNum].irqLevel;        card->pciVendorId = binding->resource[unitNum].vendorId;        card->pciDeviceId = binding->resource[unitNum].deviceId;        card->pciSubVendorId = binding->resource[unitNum].subVenId;        card->pciSubDeviceId = binding->resource[unitNum].subDevId;        card->pciChipSetRev = binding->resource[unitNum].pciChipSetRev;        card->cacheLineSz = _CACHE_ALIGN_SIZE;        card->binding = &binding->support;        card->config = binding->wlanConfig;        /* Calcluate the minumun cluster size */        clSize = ROUND_UP(DOT11_MAX_PACKET, card->cacheLineSz)            - sizeof(ULONG);        /* Now calculate the total buffer requirements */        card->dmaBufSize = (DOT11_NUMCL * (clSize + sizeof(ULONG)))             + (clSize + (1024*128));        /* Allocate buffer of DMA accessible cache safe memory */        if (binding->bsp->cpu.useCacheDrv == TRUE)            {            card->dmaBuffAddr = (UINT32)cacheDmaMalloc(card->dmaBufSize);            }        else            {            /* Device probally supports DMA from cacheable memory */            card->dmaBuffAddr = (UINT32)memalign(card->cacheLineSz,                                                  card->dmaBufSize);            }        /* Sanity check */        if (card->dmaBuffAddr == (UINT32)NULL)            {            /* Indicates memory allocation error */            return(NULL);            }        /* Save a copy of the memory base address for the         deallocation process */        binding->resource[unitNum].allocatedMemBase = card->dmaBuffAddr;        /* Now that the reference is saved make sure the buffer is         aligned properly */        card->dmaBuffAddr = ROUND_UP(card->dmaBuffAddr, card->cacheLineSz);                /* Now that we have allocated a block of DMA accessible memory         from the heap we must now set up the SOC DMA engine to allow         the device on the PCI bus to access the newly allocated memory         space */        if (binding->bsp->cpu.dmaMappingAdd != NULL)            {            /* In this case we need to map the memory into            the mmu table */            if (binding->bsp->cpu.dmaMappingAdd                (card->dmaBuffAddr,                  card->dmaBufSize)                 != OK)                {                /* Indicates DMA mapping error */                return(NULL);                }            }                /* finish off the initialization parameter string */        (void)sprintf(cp, "0x%X", (UINT32)card);        /* Make sure there is a valid endLoad function to call */        if (binding->endLoad != NULL)            {            if ((pEnd = binding->endLoad(paramStr, pBsp))                 == (END_OBJ*)ERROR)                {                logMsg("sysDot11EndLoad: Device load routine failed.\n",                       1,2,3,4,5,6);                }            }        }        /* Return a pointer to the end object */    return(pEnd);    }/**************************************************************************** sysDot11DeviceFind - detect the bus devices** This function detects the existence of bus devices, and passes back * the PCI bus/device/func parameters.* Since each BSP can have its own mechamism for gathering device * information from the bus, this function supports the various BSP * specific mechanisms.** RETURN: OK or ERROR if not found*/LOCAL STATUS sysDot11DeviceFind     (    UINT32  vendorId, /* Vendor ID */    UINT32  deviceId, /* Device ID */    INT32   instance, /* Device instance */    UINT32* bus,      /* Bus number */    UINT32* device,   /* Bus device */    UINT32* function  /* Bus function */    )    {       STATUS rcode = ERROR;    /* This conditional is required to resolve a bug in the    ixdp425 BSP regarding multiple card support */    if (binding->bsp->type == IS_IXDP425)        {        rcode = sysDot11DeviceFind2(vendorId,                                    deviceId,                                    instance,                                    bus,                                    device,                                    function);        }    else        {        /*  Check for a valid binding */        if (binding->bsp->bus.findDevice != NULL)            {            /* Check to see if the bus access needs to get            modified prior to probing the bus */            if (binding->bsp->bus.errDisable != NULL)                {                /* Disable bus probe errors */                binding->bsp->bus.errDisable();                }                        /* Find the device on the bus */            rcode = binding->bsp->bus.findDevice(vendorId,                                                  deviceId,                                                  instance,                                                  bus,                                                  device,                                                 function);                        /* Set the bus access level to the previous state */            if (binding->bsp->bus.errEnable != NULL)                {                /* Re-enable bus probe errors */                binding->bsp->bus.errEnable();                }            }        }    /* Return the status of the call */    return(rcode);    }/**************************************************************************** sysDot11DeviceFind2 - detect the bus devices** This function detects the existence of bus devices, and passes back * the PCI bus/device/func parameters.* Since each BSP can have its own mechamism for gathering device * information from the bus, this function supports the various BSP * specific mechanisms. Note that this function is only used with the * intel IXDP425 bsp since the current BSP level driver does not support* mutilple device instansiations. Also note that on the IXDP the device* and bus number and function number are always set to 0.** RETURN: OK or ERROR if not found*/LOCAL STATUS sysDot11DeviceFind2     (    UINT32  vendorId, /* Vendor ID */    UINT32  deviceId, /* Device ID */    INT32   instance, /* Device instance */    UINT32* bus,      /* Bus number */    UINT32* device,   /* Bus device */    UINT32* function  /* Bus function */    )    {    static struct bus_devid_s        {        UINT32 bus;        UINT32 device;        UINT32 function;        UINT16 vendorId;        UINT16 deviceId;        } busDevId[4];    static UINT32 init = FALSE;    UINT32 cardData;    UINT32 devNum;    UINT16 devId, venId;    UINT32 inst = 0;    BOOL (*deviceProbe)();    /* Make sure that the we are bound to the bus probe and     error clearing function */    if (binding->bsp->bus.errDisable == NULL)        {        /* Non valid binding */        return(ERROR);        }    /* Get a binding to the bus probing method */    deviceProbe = (BOOL(*)())binding->bsp->bus.errDisable;        /* Create a device table the first time this     function is called */    if (init == FALSE)        {        STATUS status;        /* Create a list of all the devices on the bus */        devNum = 0;        while (devNum < binding->bsp->system.busSlots)             {            /* Probe the bus to determine the existence of a             device in the each slot */            if (deviceProbe(0, devNum, 0) == TRUE)                {                /* Query the bus controller to get a packed                 value that contains both the vendor and device IDs */                status = pciConfigInLong(0,                                          devNum,                                          0,                                          PCI_CFG_VENDOR_ID,                                         &cardData);                                /* Now that we have received a packed 32 bi

⌨️ 快捷键说明

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