📄 intprismsym.c
字号:
/* intPrismSym.c - Initiates F/W download to Symbol Wireless Networker card *//* Copyright 2001-2002 Wind River Systems, Inc. *//*modification history --------------------01l,17may02,rb Removed warning message01k,13may02,dxb Removed static values for taskDelay().01j,06may02,cjl Changes for diab compiler01i,06may02,ss update refgen comments01h,06may02,ss fixed bug - do not swap MAC addr byte order ever01g,03may02,rb Updated comments as per doc review01f,08apr02,ss Updated to use pWlanDev and WLAN_BASE_ADDR everywhere01e,12feb02,ss Updated for intPrismDownload API changes01d,11feb02,ss Byte swap MAC addr for BIG ENDIAN machine01c,05feb02,dxb Updated to include changes to wlanEnd.h.01b,21dec01,ss Add routine for retrieving MAC addr of card (via Info records)01a,19dec01,ss Created*//*DESCRIPTIONThese routines download Primary and Secondary Firmware onto a Symbol WirelessNetworker Compact Flash card. */#include <vxWorks.h>#include <taskLib.h>#include <sysLib.h>#include "intPrismSymPrim.c" /* The Primary firmware exists in here */#include "intPrismSymSec.c" /* The Secondary firmware exists in here */#include "wrn/wlan/wlanEnd.h"#include "wrn/wlan/intPrismHw.h"#include "wrn/wlan/intPrismDownload.h"#define WLAN_SYM_PDA_ADDR 0x3000 /* the PDA start address for the card */#define NUM_PDA_WORDS 256 /* max size of PDA */#define PDA_START_INDEX 130 /* ignore the first x num of words read from PDA */#define COR_REG 0x40 /* COR register offset */#define HCR_REG 0x42 /* HCR register offset */#define HCR_EEHOLD 0xDE /* puts card into HOLD mode, for writing F/W */#define HCR_RUN 0x17 /* puts card into RUN mode, for running F/W */#define FOUR_WIRE_INTERFACE 0x10LOCAL void intPrismSymModeSet(WLAN_DEV *, UINT16);LOCAL STATUS intPrismSymPdaRead(WLAN_DEV * );LOCAL UINT16 * macAddr = NULL; /* the MAC addr of the card, as read from PDA *//****************************************************************************** intPrismSymDownload - Download Primary and Secondary firmware to a Symbol Wireless Networker card* * This routine loads Primary Firmware onto the Symbol Wireless Networker card* by placing the card into HOLD mode, then writing the firmware (loaded and * parsed from a global array in intPrismSymPrim.c) to the card memory. The * card is then put into RUN mode and the primary firmware begins operating. * The Secondary firmware (read from a global array in intPrismSymSec.c) is * then loaded to the card, at which point the card becomes a fully * functioning 802.11b device.** RETURNS: OK if the firmware download was successful, else ERROR*/STATUS intPrismSymDownload ( WLAN_DEV * pWlanDev /* dev. ptr to Symbol CF card */ ) { if (pWlanDev == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSymDownload: Error NULL WLAN_DEV " "ptr\n")); return ERROR; } /* prepare the Primary F/W image (lots of messy grunt work done in the parse routine) */ if (intPrismHexArrayParse((UINT16 *)primsym, primsymLEN) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSymDownload: Error parsing primary firmware\n")); return ERROR; } /* put card into HOLD mode, then write the Primary data */ intPrismSymModeSet(pWlanDev, HCR_EEHOLD); taskDelay(sysClkRateGet()/10); /* wait 100 msec */ if (intPrismDataRecordsWrite(pWlanDev) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR,("intPrismSymDownload: Error writing primary " "data records\n")); return ERROR; } /* clean up the primary parsed data before we parse the secondary */ intPrismDownloadCleanup(); /* run the primary */ intPrismSymModeSet(pWlanDev, HCR_RUN); /* Issue ReadMIF command before we can read the PDA */ WLAN_OUT_16(WLAN_BASE_ADDR + WLAN_COMMAND, WLAN_CMD_READ_MIF); /* read the PDA */ if (intPrismSymPdaRead(pWlanDev) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR,("intPrismSymDownload: Error reading PDA\n")); return ERROR; } /* write the Secondary F/W image */ if (intPrismHexArrayParse((UINT16 *)secsym, secsymLEN) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSymDownload: Error parsing " "secondary firmware\n")); return ERROR; } if (intPrismDataRecordsWrite(pWlanDev) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR,("intPrismSymDownload: Error writing " "secondary data records\n")); return ERROR; } /* Plug the Secondary image */ if (intPrismPlugRecordsWrite(pWlanDev) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSymDownload: Error writing plug data\n")); return ERROR; } /* clean up all allocated memory for the parsing of the firmware */ intPrismDownloadCleanup(); return OK; }/******************************************************************************* intPrismSymModeSet - Set the state of the card* */LOCAL void intPrismSymModeSet ( WLAN_DEV * pWlanDev, /* ptr. to card struct */ UINT16 mode /* the mode to apply to card via HCR register */ ) { UINT8 hcrFlags; /* Issue a COR Reset */ WLAN_OUT_8(WLAN_BASE_ADDR + COR_REG, 0x80); taskDelay(sysClkRateGet()/10); /* wait 100 msec */ /* determine the type of interface to SRAM we have */ hcrFlags = WLAN_IN_8(WLAN_BASE_ADDR + HCR_REG); if ( (hcrFlags & FOUR_WIRE_INTERFACE) == 0) { /* set up as a 5 wire interface */ mode = mode & 0xEF; } /* set the mode of the card via HCR register */ WLAN_OUT_8(WLAN_BASE_ADDR + HCR_REG, mode); taskDelay(sysClkRateGet()/10); /* wait 100 msec */ /* Set COR to IO MODE */ WLAN_OUT_8(WLAN_BASE_ADDR + COR_REG, 0x41); taskDelay(sysClkRateGet()/10); /* wait 100 msec */ }/******************************************************************************* intPrismSymPdaRead - Reads the PDA of the card* * RETURNS: OK if the read was successful, else ERROR*/LOCAL STATUS intPrismSymPdaRead(WLAN_DEV * pWlanDev) { UINT32 i, j, k; UINT16 pdabuf[256]; UINT32 len; UINT32 itemCode; UINT16 * pData; /* enable the aux port */ if (intPrismAuxPortSet(pWlanDev, TRUE) == ERROR) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSymPdaRead: Error - could not " "enable Aux Port\n")); return ERROR; } /* set the address of the PDA */ intPrismAuxAddrSet(pWlanDev, WLAN_SYM_PDA_ADDR); /* read the PDA into a buffer */ for (i = 0; i < NUM_PDA_WORDS; i++) { pdabuf[i] = WLAN_IN_16(WLAN_BASE_ADDR + WLAN_AUX_DATA); } /* Ignore the first PDA_START_INDEX words read from the PDA. why? I don't know, because Symbol said so. */ j = PDA_START_INDEX; k = 0; while (1) { /* check for itemCode == 0 (end record) */ if (pdabuf[j+1] == 0) { break; } /* handle the very first record */ len = pdabuf[j++]; itemCode = pdabuf[j++]; pData = (UINT16 *) malloc((len - 1) * sizeof(UINT16)); if (pData == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSymPdaRead: Error - could not " "malloc space for pda record data\n")); return ERROR; } for (k = 0; k < len - 1; k++) { pData[k] = pdabuf[j]; j++; } intPrismPdaRecordAdd(itemCode, len, pData); /* save the MAC addr */ if (itemCode == PDA_CODE_MAC_ADDR) { macAddr = (UINT16 *) malloc(3 * sizeof(UINT16)); if (macAddr == NULL) { WLANDL_DEBUG(DEBUG_ERROR, ("intPrismSymPdaRead: Error - could not " "malloc space for card MAC addr\n")); return ERROR; } else { macAddr[0] = pData[0]; macAddr[1] = pData[1]; macAddr[2] = pData[2]; } } } return OK; }/****************************************************************************** NOMANUAL* intPrismSymMacAddrGet - Provides the MAC address of the card** The MAC address is read from the PDA, thus a call to intPrismSymPdaRead (or * intPrismSymDownload) is required before this routine returns anything other * than NULL.** RETURNS: Pointer to an array of three 16 bit words representing the MAC addr,* or NULL if it is unknown. */UINT16 * intPrismSymMacAddrGet(void) { return macAddr; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -