📄 intprismend.c
字号:
/* Connect here, but don't enable until intPrismStart */ WLAN_INT_CONNECT(pWlanDev->iVec, (INT32)(FUNCPTR)intPrismInt, (INT32)pWlanDev, &result); if (result != OK) { WLAN_DEBUG(DEBUG_FATAL,("intPrismLoad:Error connecting interrupts\n")); return NULL; } /* NULL out the pointer for WDS devices - set in intPrismWDSEnd.c */ pWlanDev->pWds = NULL; /* Set the RX queue pointers to NULL */ pWlanDev->pRxTail = NULL; pWlanDev->pRxHead = NULL; /* Return the address of the control structure we've just allocated and initialized */ return (END_OBJ *)(&pWlanDev->endObj); }/****************************************************************************** intPrismParse - Parses the initString and fills in the device structure** This function parses the init string, which is colon delimited. The * default station name and BSS name are also setup here.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS intPrismParse ( WLAN_DEV* pDrvCtrl, /* Pointer to device structure */ char *initString /* Initialization string to parse */ ) { WLAN_DEV * pWlanDev = pDrvCtrl; char* tok; char* holder = NULL; /* Unit number. */ tok = strtok_r (initString, ":", &holder); if (tok == NULL) return ERROR; pWlanDev->unitNum = atoi (tok); /* Base Address */ tok = strtok_r (NULL, ":", &holder); if (tok == NULL) return ERROR; pWlanDev->baseAddr = strtoul (tok, NULL, 16); /* iVec */ tok = strtok_r (NULL, ":", &holder); if (tok == NULL) return ERROR; pWlanDev->iVec = strtoul (tok, NULL, 16); /* iLevel - skip this one*/ tok = strtok_r (NULL, ":", &holder); if (tok == NULL) return ERROR; pWlanDev->iLevel = strtoul (tok, NULL, 16); /* Get the SSID */ (void) sysWlanCfgParamGet (WLAN_SSID, (INT32) pWlanDev->networkName); /* Get the default station name */ (void) sysWlanCfgParamGet (WLAN_STATION_NAME, (INT32) pWlanDev->stationName); return OK; }/****************************************************************************** intPrismMemInit - Initializes global memory structures for END** Allocates the netPool and sets up the buffer management library as* specified in the NPT: User's guide** RETURNS: OK or ERROR** ERRNO: N/A* * SEE ALSO: netPoolInit(), Network Protocol Toolkit User's Guide*/LOCAL STATUS intPrismMemInit ( WLAN_DEV* pWlanDev /* Pointer to device handle */ ) { pWlanDev->mClBlkConfig.mBlkNum = WLAN_NUMCL; pWlanDev->mClBlkConfig.clBlkNum = WLAN_NUMCL; pWlanDev->mClBlkConfig.memSize = (pWlanDev->mClBlkConfig.mBlkNum * (M_BLK_SZ + sizeof(long))) + (pWlanDev->mClBlkConfig.clBlkNum * (CL_BLK_SZ)); if ((pWlanDev->mClBlkConfig.memArea = (char *) memalign (sizeof(INT32), pWlanDev->mClBlkConfig.memSize)) == NULL) { WLAN_DEBUG(DEBUG_FATAL,("intPrismMemInit: Error allocating" " mClBlkConfig.memarea\n")); return ERROR; } pWlanDev->clDescTbl.clSize = WLAN_MAX_PACKET; pWlanDev->clDescTbl.clNum = WLAN_NUMCL; pWlanDev->clDescTbl.memSize = pWlanDev->clDescTbl.clNum * (WLAN_MAX_PACKET + sizeof(INT32)); /* The clusters should be from cache safe memory */ if ((pWlanDev->clDescTbl.memArea = (char*) cacheDmaMalloc(pWlanDev->clDescTbl.memSize)) == NULL) { WLAN_DEBUG(DEBUG_FATAL, ("intPrismMemInit: Error allocating" "clDescTbl.memArea\n")); return ERROR; } /* Initialize the memory pool, with one entry in the cluster table */ pWlanDev->endObj.pNetPool = & pWlanDev->netPool; if (netPoolInit(pWlanDev->endObj.pNetPool, &pWlanDev->mClBlkConfig, &pWlanDev->clDescTbl, 1, NULL) == ERROR) { WLAN_DEBUG(DEBUG_FATAL,("intPrismMemInit: Could not init net pool\n")); return (ERROR); } if ((pWlanDev->pClPool = netClPoolIdGet (pWlanDev->endObj.pNetPool, WLAN_MAX_PACKET, FALSE)) == NULL) { WLAN_DEBUG(DEBUG_FATAL,("intPrismMemInit: Could not read net pool\n")); return (ERROR); } return OK; }/***************************************************************************** intPrismStart - MUX routine to start card operation** Called via muxDevStart(), this function enables interrupts on the card, then* enables system interrupts. On successful completion of this routine the * card is in a fully operational state.** RETURNS: OK or ERROR** ERRNO: N/A*/LOCAL STATUS intPrismStart ( END_OBJ* pDrvCtrl /* Pointer to END object structure */ ) { WLAN_DEV * pWlanDev = (WLAN_DEV *)pDrvCtrl; STATUS result; WLAN_DEBUG(DEBUG_INFO,("intPrismStart: Start of routine\n")); /* Ensure that the card is using tested firmware, print a warning message if not. Still allow the driver to start, regardless */ intPrismFirmwareCheck(pWlanDev); /* Make sure all card interrupts are clear and all events acknowledged before we enable system interrupts */ WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_INT_EN, 0x0000); WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_EVENT_ACK, 0xffff); WLAN_INT_ENABLE(pWlanDev->iLevel, &result); if (result != OK) { WLAN_DEBUG(DEBUG_FATAL, ("intPrismStart: Error enabling interrupts")); } /* OK. Now that all the interrupt infrastrucure is in place, setup our interrupts */ if (intPrismCommand(pWlanDev, WLAN_CMD_ENABLE | WLAN_PORT_0, 0,0,0)) { return ERROR; } WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_INT_EN, ((WLAN_DEV *)pWlanDev)->intMask);#if (CPU==STRONGARM) || (CPU==XSCALE) || (CPU==ARMARCH4) taskSpawn ("tWlanPoll", 60, 0, 2048, (FUNCPTR)intPrismKeepalive, (int)pWlanDev, 2,3,4,5,6,7,8,9,0xa); taskDelay(sysClkRateGet()/2);#endif pWlanDev->cardStatus = WLAN_STATUS_UP; return OK; }/***************************************************************************** intPrismStop - MUX Routine to stop card operation** This function, called via muxDevStop(), disables system and card interrupts.* The card is still enabled, but without interrupts ceases to function.** RETURNS: OK or ERROR** ERRNO: N/A*/STATUS intPrismStop ( END_OBJ* pDrvCtrl /* Pointer to device handle */ ) { WLAN_DEV * pWlanDev = (WLAN_DEV*)pDrvCtrl; STATUS result; if (intPrismCommand(pWlanDev, WLAN_CMD_DISABLE | WLAN_PORT_0,0,0,0) != OK) { return ERROR; } pWlanDev->cardStatus = WLAN_STATUS_DOWN; /* Make sure there's no spurious events */ WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_EVENT_ACK, 0xffff); /* Disable card interrupts */ WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_INT_EN, 0x0000);#if (CPU==STRONGARM) || (CPU==XSCALE) || (CPU==ARMARCH4) if (taskDelete (taskNameToId("tWlanPoll")) != OK) { WLAN_DEBUG(DEBUG_ERROR,("intPrismStop: Error del task tWlanPoll\n")); result |= ERROR; }#endif /* Disable system interrupts*/ WLAN_INT_DISABLE(pWlanDev->iLevel, &result); if (result != OK) { WLAN_DEBUG(DEBUG_FATAL, ("intPrismStop: Error disabling interrupts")); return ERROR; } return OK; }/***************************************************************************** NOMANUAL* intPrismIoctl - MUX Ioctl routine for the WLAN Driver** Handles the basic END IOCTL calls required to support a network device. * If the IOCTL call is not recognized, it is passed to intPrismManage(), which* handles private (WLAN only) IOCTL calls used to manage the card. These* private IOCTLs are defined in intPrismEnd.h and documented in intPrismIoctl.c** RETURNS: OK, EINVAL if cmd not found, or ERROR** ERRNO: N/A*/int intPrismIoctl ( END_OBJ* pDrvCtrl, /* Device handle for this card */ unsigned int cmd, /* IOCTL command */ caddr_t data /* Generic data pointer */ ) { INT32 status = 0; /* return code of IOCTL */ INT32 value; /* temp variable */ LTV_RECORD ltv; /* temp ltv record */ if (pDrvCtrl == NULL) { WLAN_DEBUG(DEBUG_FATAL, ("intPrismIoctl: Null device pointer\n")); return ERROR; } switch(cmd) { case EIOCSADDR: /* Set the MAC addr */ /* This is extremely dangerous and a security risk. Make sure the developer knows what's going on */ WLAN_DEBUG(DEBUG_FATAL, ("WARNING: MAC address change!!!!\n")); if (data == NULL) { return (EINVAL); } bcopy ((char *)data, (char *)END_HADDR(pDrvCtrl), END_HADDR_LEN(pDrvCtrl)); /* Tell the card to modify the station address */ ltv.type = WLAN_RID_OWN_MAC_ADDRESS; ltv.length = 4; bcopy((char *) data, (char *)ltv.data, WLAN_ENET_ADDR_LEN); if (intPrismLTVWrite((WLAN_DEV *)pDrvCtrl, <v) != OK) { WLAN_DEBUG(DEBUG_FATAL, ("intPrismIoctl: Error setting MAC " "address")); return ERROR; } break; case EIOCGADDR: /* Get the MAC addr */ if (data == NULL) return (EINVAL); bcopy ( (char *)END_HADDR(pDrvCtrl), (char *)data, END_HADDR_LEN(pDrvCtrl)); break; case EIOCSFLAGS: /* Set device flags */ value = (long)data; /* A negative flag means remove the flag */ if (value < 0) { value = -(--value); /* Convert from two's complement */ END_FLAGS_CLR (pDrvCtrl, value); } else { END_FLAGS_SET (pDrvCtrl, value); } intPrismFlags((WLAN_DEV *)pDrvCtrl); break; case EIOCGFLAGS: /* Retrieve device flags */ *(int *)data = END_FLAGS_GET(pDrvCtrl); break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -