📄 intprismhw.c
字号:
ltv.type = RID; bcopyswap((UINT8 *) pStr, (UINT8 *)<v.data[1], strlen(pStr)); return intPrismLTVWrite(pWlanDev, <v); }/****************************************************************************** intPrismRIDStringRead - Reads the contents of the specified RID into a string** This function reads the value of the given RID, and dumps it in the * pre-allocated string provided. It is assumed that the string is of* sufficient size to contain the largest possible string returned from the* specified RID.** RETURNS: OK or ERROR if the record could not be written** ERRNO: N/A** SEE ALSO: intPrismLTVWrite()**/STATUS intPrismRIDStringRead ( WLAN_DEV *pWlanDev, /* Pointer to device handle */ UINT16 RID, /* Record ID to read from */ char * pStr /* Pointer to buffer to store data read */ ) { LTV_RECORD ltv; /* LTV record to get request in */ /* Setup the LTV record. This is a GET, so the length and data do not matter */ ltv.type = RID; if (intPrismLTVRead(pWlanDev, <v) == ERROR) { WLAN_DEBUG(DEBUG_ERROR, ("intPrismRIDStringRead: Error\n")); return ERROR; } /* The length of the string is found in the first word, data[0]. The following bytes contain the data, NOT NULL-terminated */ if ((ltv.length == 1) || (ltv.data[0] == 0x00)) { pStr[0] = 0x00; } else { bcopyswap((UINT8 *)<v.data[1], (UINT8 *)pStr, ltv.data[0]); pStr[ltv.data[0]] = 0x00; } return OK; }/****************************************************************************** intPrismLTVWrite - Writes an LTV record to the device.** This function writes the LTV (Length-Type-Value) record pointed to by * <pRecord> to the NIC.** RETURNS: OK or ERROR if the record could not be written** ERRNO: N/A**/STATUS intPrismLTVWrite ( WLAN_DEV* pWlanDev, /* Pointer to device handle */ LTV_RECORD* pRecord /* Pointer to LTV structure w/ type field*/ ) { int i; int intLevel; if ((pRecord == NULL) || (pRecord->type < 0xfc00) ) { WLAN_DEBUG(DEBUG_ERROR,("intPrismLTVWrite: Invalid LTV request\n")); return ERROR; } WLAN_INT_LOCK; if (intPrismBAP1Offset(pWlanDev, pRecord->type, 0) == ERROR) { WLAN_INT_UNLOCK; WLAN_DEBUG(DEBUG_ERROR, ("intPrismLTVWrite : Error opening BAP\n")); return ERROR; } /* Prevent RX interrupt from interrupting us and killing card */ /* The LTV record should now be accessable through the BAP. */ WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_DATA1, pRecord->length); WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_DATA1, pRecord->type); for (i = 0; i < (pRecord->length - 1); i++) { WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_DATA1, pRecord->data[i]); } WLAN_INT_UNLOCK; STORMPAD_INT_FIX(pWlanDev); WLAN_DEBUG(DEBUG_FLOOD,("intPrismLTVWrite : Length = %d\n", pRecord->length)); WLAN_DEBUG(DEBUG_INFO,("intPrismLTVWrite : Type = %04x\n", pRecord->type)); /* Send an ACCESS/WRITE command, with the desired record as PARAM0 */ if (intPrismCommand(pWlanDev, WLAN_CMD_ACCESS | WLAN_ACCESS_WRITE, pRecord->type, 0, 0) == ERROR) { WLAN_DEBUG(DEBUG_ERROR, ("intPrismLTVWrite: ACCESS command failed for" " RID 0x%04x\n", pRecord->type)); return ERROR; } return OK; }/****************************************************************************** NOMANUAL* intPrismBAP1Offset - Sets BAP 1 offset for a data transfer** Sets the offset for BAP1. The mutual exclusion semaphore for BAP 1 should* be taken beforehand.** RETURNS: OK, or ERROR (-1) if semaphore timeout** ERRNO: N/A**/STATUS intPrismBAP1Offset ( WLAN_DEV * pWlanDev, /* Pointer to device handle for this card*/ UINT16 regNum, /* FID to point the BAP at*/ UINT16 offset /* Offset (in BYTES) within FID to start data transfer*/ ) { int i; /* Mkae sure card is present */ if (WLAN_IN_16(WLAN_BASE_ADDR + WLAN_SW0) != WLAN_SW_MAGIC) { WLAN_DEBUG(DEBUG_FATAL, ("intPrismBAP1Offset: Card not found!")); return ERROR; } /* Select the appropriate control registers for BAp 1*/ WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_SEL1, regNum); WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_OFF1, offset); /* Wait for indication the selection was successful */ i = 0; while ( ( WLAN_IN_16(WLAN_BASE_ADDR + WLAN_OFF1) & WLAN_OFF_BUSY) != 0) { if (i++ > WLAN_DEVICE_TIMEOUT) { if (intPrismKickstart(pWlanDev) == ERROR) { WLAN_DEBUG(DEBUG_ERROR, ("intPrismBAP1Offset: Timeout\n")); } else { WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_SEL1, regNum); WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_OFF1, offset); i=0; continue; } } } /* See if the offset was valid */ if ((WLAN_IN_16(WLAN_BASE_ADDR + WLAN_OFF1) & WLAN_OFF_ERR) != 0) { WLAN_DEBUG(DEBUG_ERROR, ("intPrismBAPOffset: Bad offset 0x%04x" " accessing register 0x%04x\n", offset, regNum)); return ERROR; } return OK; }/****************************************************************************** NOMANUAL* intPrismBAP1Open - Opens BAP 1 and sets it up for a data transfer.** This function only works on BAP1 - the task level BAP. It takes the mutex* semaphore guarding the BAP and sets up the data transfer. The ISR BAP,* BAP 0 cannot use a mutex and is used directly in the ISR** RETURNS: OK, or ERROR if semaphore cannot be taken in 1s** ERRNO: N/A**/STATUS intPrismBAP1Open ( WLAN_DEV * pWlanDev, /* Pointer to device handle for this card*/ UINT16 regNum, /* FID to point the BAP at*/ UINT16 offset /* Offset (in BYTES) within FID to start data transfer*/ ) { /* Wait 1 s for a BAP to become available. If it hasn't by then, the card has crashed, and should be reset */ if(semTake(pWlanDev->BAP1Sem, sysClkRateGet()) != OK) { WLAN_DEBUG(DEBUG_ERROR,("intPrismBAPOpen: Timed out waiting for " "BAP\n")); return ERROR; } return(intPrismBAP1Offset(pWlanDev, regNum, offset)); } /****************************************************************************** NOMANUAL* intPrismBAP1Close - Frees BAP1 and gives the semaphore protecting it** Frees BAP1 for use by another process. The semaphore is given, and errors * reported.** RETURNS: OK or ERROR ** ERRNO: N/A**/STATUS intPrismBAP1Close ( WLAN_DEV* pWlanDev /* Pointer to device handle for this card*/ ) { WLAN_DEBUG(DEBUG_FLOOD,("intPrismBAP1Close: Freeing BAP1\n")); if (semGive(pWlanDev->BAP1Sem) == ERROR) { WLAN_DEBUG(DEBUG_FATAL, ("intPrismBAP1Close: Fatal error\n")); return ERROR; } return OK; }/****************************************************************************** NOMANUAL* intPrismReadData - Reads data from the specified frame using BAP1* * intPrismReadData() reads data from the specified frame using BAP1.The amount * of data to be read is specified in 16 bit words, while the offset is* specified in bytes.** This function points a BAP at the appropriate FID (as provided by either the* receive routine or the send routine), and then copies the data from the* BAP, which is then freed. ** RETURNS: OK or ERROR ** ERRNO: N/A**/STATUS intPrismReadData ( WLAN_DEV * pWlanDev, /* Pointer to device control structure */ UINT16 FID, /* Frame ID containing the data to be read*/ UINT16 offset, /* Data offset from start of frame in BYTES*/ UINT16 nWords, /* Number of WORDS of data to read */ UINT16 * pBuf ) { int i; int intLevel; /* Prevent RX event from interrupting us and crashing the card */ WLAN_INT_LOCK; if (intPrismBAP1Offset(pWlanDev, FID, offset) == ERROR) { WLAN_INT_UNLOCK; WLAN_DEBUG(DEBUG_ERROR, ("intPrismReadData: Unable to open BAP1\n")); return ERROR; } for (i=0; i<nWords; i++) { *(pBuf+i) = WLAN_IN_16(WLAN_BASE_ADDR + WLAN_DATA1); } WLAN_INT_UNLOCK; STORMPAD_INT_FIX(pWlanDev); return OK; }/****************************************************************************** NOMANUAL* intPrismWriteData - Writes the specified amount of data to the specified frame** This function is to be called from the task-level only - it is not ISR-safe** RETURNS: OK or ERROR ** ERRNO: N/A**/STATUS intPrismWriteData ( WLAN_DEV * pWlanDev, /* Pointer to device control structure */ UINT16 FID, /* Frame ID containing the data to be written*/ UINT16 offset, /* Data offset from start of frame */ UINT16 nWords, /* Number of WORDS of data to write */ UINT16 * pBuf /* Buffer containing data to write */ ) { int i; if (intPrismBAP1Offset(pWlanDev, FID, offset) == ERROR) { WLAN_DEBUG(DEBUG_ERROR, ("intPrismWriteData: Unable to offset" " BAP1\n")); return ERROR; } for (i=0; i<nWords; i++) { WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_DATA1, *(pBuf+i)); } return (OK); }/****************************************************************************** NOMANUAL* intPrismNICIdentify - Reads the NIC Identity RID and updates the device structure** This function is to be called from the task-level only - it is not ISR-safe** RETURNS: OK or ERROR ** ERRNO: N/A*/STATUS intPrismNICIdentify(WLAN_DEV * pWlanDev) { LTV_RECORD ltv; INT16 count; ltv.type = WLAN_RID_CARD_ID; if (intPrismLTVRead(pWlanDev,<v) == ERROR) { return ERROR; } /* Look up the component ID (ltv.data[0]) in the supported cards table to see if it is supported. We ignore the component variant (ltv.data[1]) at this time. */ pWlanDev->cardType = WLAN_CARDTYPE_UNKNOWN; pWlanDev->compID = ltv.data[0]; /* store this to verify F/W later.. */ for (count = 0; count < (int)CARDS_TABLE_LENGTH; count++) { if (ltv.data[0] == supportedCards[count].compId) { pWlanDev->cardType = supportedCards[count].manufacturer; WLAN_DEBUG(DEBUG_ERROR,("intPrismNICIdentify: " "Detected WLAN card - %s\n", supportedCards[count].name)); return OK; } } /* otherwise the card type was not found, and print the card info */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -