2009-04-17 03:15:34 -06:00
|
|
|
/* from src/prism2/download/prism2dl.c
|
|
|
|
*
|
|
|
|
* utility for downloading prism2 images moved into kernelspace
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
|
|
|
|
* --------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* linux-wlan
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the
|
|
|
|
* terms of the GNU Public License version 2 (the "GPL"), in which
|
|
|
|
* case the provisions of the GPL are applicable instead of the
|
|
|
|
* above. If you wish to allow the use of your version of this file
|
|
|
|
* only under the terms of the GPL and not to allow others to use
|
|
|
|
* your version of this file under the MPL, indicate your decision
|
|
|
|
* by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this
|
|
|
|
* file under either the MPL or the GPL.
|
|
|
|
*
|
|
|
|
* --------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Inquiries regarding the linux-wlan Open Source project can be
|
|
|
|
* made directly to:
|
|
|
|
*
|
|
|
|
* AbsoluteValue Systems Inc.
|
|
|
|
* info@linux-wlan.com
|
|
|
|
* http://www.linux-wlan.com
|
|
|
|
*
|
|
|
|
* --------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* Portions of the development of this software were funded by
|
|
|
|
* Intersil Corporation as part of PRISM(R) chipset product development.
|
|
|
|
*
|
|
|
|
* --------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*================================================================*/
|
|
|
|
/* System Includes */
|
2009-08-19 01:06:39 -06:00
|
|
|
#include <linux/ihex.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 02:04:11 -06:00
|
|
|
#include <linux/slab.h>
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/*================================================================*/
|
|
|
|
/* Local Constants */
|
|
|
|
|
2009-08-19 01:06:39 -06:00
|
|
|
#define PRISM2_USB_FWFILE "prism2_ru.fw"
|
2010-01-13 16:36:09 -07:00
|
|
|
MODULE_FIRMWARE(PRISM2_USB_FWFILE);
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
#define S3DATA_MAX 5000
|
|
|
|
#define S3PLUG_MAX 200
|
|
|
|
#define S3CRC_MAX 200
|
|
|
|
#define S3INFO_MAX 50
|
|
|
|
|
|
|
|
#define S3ADDR_PLUG (0xff000000UL)
|
|
|
|
#define S3ADDR_CRC (0xff100000UL)
|
|
|
|
#define S3ADDR_INFO (0xff200000UL)
|
2009-08-19 01:06:39 -06:00
|
|
|
#define S3ADDR_START (0xff400000UL)
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
#define CHUNKS_MAX 100
|
|
|
|
|
|
|
|
#define WRITESIZE_MAX 4096
|
|
|
|
|
|
|
|
/*================================================================*/
|
|
|
|
/* Local Types */
|
|
|
|
|
2009-05-25 07:36:16 -06:00
|
|
|
typedef struct s3datarec {
|
|
|
|
u32 len;
|
|
|
|
u32 addr;
|
|
|
|
u8 checksum;
|
|
|
|
u8 *data;
|
2009-04-17 03:15:34 -06:00
|
|
|
} s3datarec_t;
|
|
|
|
|
2009-05-25 07:36:16 -06:00
|
|
|
typedef struct s3plugrec {
|
|
|
|
u32 itemcode;
|
|
|
|
u32 addr;
|
|
|
|
u32 len;
|
2009-04-17 03:15:34 -06:00
|
|
|
} s3plugrec_t;
|
|
|
|
|
2009-05-25 07:36:16 -06:00
|
|
|
typedef struct s3crcrec {
|
|
|
|
u32 addr;
|
|
|
|
u32 len;
|
|
|
|
unsigned int dowrite;
|
2009-04-17 03:15:34 -06:00
|
|
|
} s3crcrec_t;
|
|
|
|
|
2009-05-25 07:36:16 -06:00
|
|
|
typedef struct s3inforec {
|
|
|
|
u16 len;
|
|
|
|
u16 type;
|
2009-04-17 03:15:34 -06:00
|
|
|
union {
|
2009-05-25 07:36:16 -06:00
|
|
|
hfa384x_compident_t version;
|
|
|
|
hfa384x_caplevel_t compat;
|
|
|
|
u16 buildseq;
|
|
|
|
hfa384x_compident_t platform;
|
|
|
|
} info;
|
2009-04-17 03:15:34 -06:00
|
|
|
} s3inforec_t;
|
|
|
|
|
2009-05-25 07:36:16 -06:00
|
|
|
typedef struct pda {
|
|
|
|
u8 buf[HFA384x_PDA_LEN_MAX];
|
|
|
|
hfa384x_pdrec_t *rec[HFA384x_PDA_RECS_MAX];
|
|
|
|
unsigned int nrec;
|
2009-04-17 03:15:34 -06:00
|
|
|
} pda_t;
|
|
|
|
|
2009-05-25 07:36:16 -06:00
|
|
|
typedef struct imgchunk {
|
2010-02-18 15:56:12 -07:00
|
|
|
u32 addr; /* start address */
|
|
|
|
u32 len; /* in bytes */
|
|
|
|
u16 crc; /* CRC value (if it falls at a chunk boundary) */
|
2009-05-25 07:36:16 -06:00
|
|
|
u8 *data;
|
2009-04-17 03:15:34 -06:00
|
|
|
} imgchunk_t;
|
|
|
|
|
|
|
|
/*================================================================*/
|
|
|
|
/* Local Static Definitions */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------*/
|
|
|
|
/* s-record image processing */
|
|
|
|
|
|
|
|
/* Data records */
|
2009-06-10 08:06:11 -06:00
|
|
|
unsigned int ns3data;
|
2009-05-25 07:36:16 -06:00
|
|
|
s3datarec_t s3data[S3DATA_MAX];
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* Plug records */
|
2009-06-10 08:06:11 -06:00
|
|
|
unsigned int ns3plug;
|
2009-05-25 07:36:16 -06:00
|
|
|
s3plugrec_t s3plug[S3PLUG_MAX];
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* CRC records */
|
2009-06-10 08:06:11 -06:00
|
|
|
unsigned int ns3crc;
|
2009-05-25 07:36:16 -06:00
|
|
|
s3crcrec_t s3crc[S3CRC_MAX];
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* Info records */
|
2009-06-10 08:06:11 -06:00
|
|
|
unsigned int ns3info;
|
2009-05-25 07:36:16 -06:00
|
|
|
s3inforec_t s3info[S3INFO_MAX];
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* S7 record (there _better_ be only one) */
|
2009-05-25 07:36:16 -06:00
|
|
|
u32 startaddr;
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* Load image chunks */
|
2009-05-25 07:36:16 -06:00
|
|
|
unsigned int nfchunks;
|
|
|
|
imgchunk_t fchunk[CHUNKS_MAX];
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* Note that for the following pdrec_t arrays, the len and code */
|
|
|
|
/* fields are stored in HOST byte order. The mkpdrlist() function */
|
|
|
|
/* does the conversion. */
|
|
|
|
/*----------------------------------------------------------------*/
|
|
|
|
/* PDA, built from [card|newfile]+[addfile1+addfile2...] */
|
|
|
|
|
2009-05-25 07:36:16 -06:00
|
|
|
pda_t pda;
|
2009-04-17 03:15:34 -06:00
|
|
|
hfa384x_compident_t nicid;
|
2009-05-25 07:36:16 -06:00
|
|
|
hfa384x_caplevel_t rfid;
|
|
|
|
hfa384x_caplevel_t macid;
|
|
|
|
hfa384x_caplevel_t priid;
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/*================================================================*/
|
|
|
|
/* Local Function Declarations */
|
|
|
|
|
2009-08-19 01:06:39 -06:00
|
|
|
int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev);
|
|
|
|
int read_fwfile(const struct ihex_binrec *rfptr);
|
2009-06-10 08:06:11 -06:00
|
|
|
int mkimage(imgchunk_t *clist, unsigned int *ccnt);
|
|
|
|
int read_cardpda(pda_t *pda, wlandevice_t *wlandev);
|
|
|
|
int mkpdrlist(pda_t *pda);
|
|
|
|
int plugimage(imgchunk_t *fchunk, unsigned int nfchunks,
|
|
|
|
s3plugrec_t *s3plug, unsigned int ns3plug, pda_t * pda);
|
|
|
|
int crcimage(imgchunk_t *fchunk, unsigned int nfchunks,
|
|
|
|
s3crcrec_t *s3crc, unsigned int ns3crc);
|
|
|
|
int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk,
|
2009-05-25 07:36:16 -06:00
|
|
|
unsigned int nfchunks);
|
2009-06-10 08:06:11 -06:00
|
|
|
void free_chunks(imgchunk_t *fchunk, unsigned int *nfchunks);
|
2009-05-25 07:36:16 -06:00
|
|
|
void free_srecs(void);
|
|
|
|
|
|
|
|
int validate_identity(void);
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/*================================================================*/
|
|
|
|
/* Function Definitions */
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------
|
|
|
|
* prism2_fwtry
|
|
|
|
*
|
|
|
|
* Try and get firmware into memory
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* udev usb device structure
|
|
|
|
* wlandev wlan device structure
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* 0 - success
|
|
|
|
* ~0 - failure
|
|
|
|
----------------------------------------------------------------*/
|
2009-06-10 08:06:11 -06:00
|
|
|
int prism2_fwtry(struct usb_device *udev, wlandevice_t *wlandev)
|
2009-04-17 03:15:34 -06:00
|
|
|
{
|
|
|
|
const struct firmware *fw_entry = NULL;
|
|
|
|
|
2009-05-25 07:36:16 -06:00
|
|
|
printk(KERN_INFO "prism2_usb: Checking for firmware %s\n",
|
|
|
|
PRISM2_USB_FWFILE);
|
2009-08-19 01:06:39 -06:00
|
|
|
if (request_ihex_firmware(&fw_entry, PRISM2_USB_FWFILE, &udev->dev) != 0) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_INFO
|
|
|
|
"prism2_usb: Firmware not available, but not essential\n");
|
|
|
|
printk(KERN_INFO
|
|
|
|
"prism2_usb: can continue to use card anyway.\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-02-25 10:55:03 -07:00
|
|
|
printk(KERN_INFO "prism2_usb: %s will be processed, size %zu\n",
|
2009-05-25 07:36:16 -06:00
|
|
|
PRISM2_USB_FWFILE, fw_entry->size);
|
2009-08-19 01:06:39 -06:00
|
|
|
prism2_fwapply((const struct ihex_binrec *)fw_entry->data, wlandev);
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
release_firmware(fw_entry);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------
|
|
|
|
* prism2_fwapply
|
|
|
|
*
|
|
|
|
* Apply the firmware loaded into memory
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* rfptr firmware image in kernel memory
|
|
|
|
* wlandev device
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* 0 - success
|
|
|
|
* ~0 - failure
|
|
|
|
----------------------------------------------------------------*/
|
2009-08-19 01:06:39 -06:00
|
|
|
int prism2_fwapply(const struct ihex_binrec *rfptr, wlandevice_t *wlandev)
|
2009-04-17 03:15:34 -06:00
|
|
|
{
|
2009-05-25 07:36:16 -06:00
|
|
|
signed int result = 0;
|
2009-04-17 03:15:34 -06:00
|
|
|
p80211msg_dot11req_mibget_t getmsg;
|
|
|
|
p80211itemd_t *item;
|
2009-05-25 07:36:16 -06:00
|
|
|
u32 *data;
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* Initialize the data structures */
|
|
|
|
ns3data = 0;
|
|
|
|
memset(s3data, 0, sizeof(s3data));
|
|
|
|
ns3plug = 0;
|
|
|
|
memset(s3plug, 0, sizeof(s3plug));
|
|
|
|
ns3crc = 0;
|
|
|
|
memset(s3crc, 0, sizeof(s3crc));
|
|
|
|
ns3info = 0;
|
|
|
|
memset(s3info, 0, sizeof(s3info));
|
|
|
|
startaddr = 0;
|
|
|
|
|
|
|
|
nfchunks = 0;
|
2009-05-25 07:36:16 -06:00
|
|
|
memset(fchunk, 0, sizeof(fchunk));
|
|
|
|
memset(&nicid, 0, sizeof(nicid));
|
|
|
|
memset(&rfid, 0, sizeof(rfid));
|
|
|
|
memset(&macid, 0, sizeof(macid));
|
|
|
|
memset(&priid, 0, sizeof(priid));
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* clear the pda and add an initial END record */
|
|
|
|
memset(&pda, 0, sizeof(pda));
|
2009-05-25 07:36:16 -06:00
|
|
|
pda.rec[0] = (hfa384x_pdrec_t *) pda.buf;
|
|
|
|
pda.rec[0]->len = cpu_to_le16(2); /* len in words *//* len in words */
|
2009-04-17 03:15:34 -06:00
|
|
|
pda.rec[0]->code = cpu_to_le16(HFA384x_PDR_END_OF_PDA);
|
|
|
|
pda.nrec = 1;
|
|
|
|
|
|
|
|
/*-----------------------------------------------------*/
|
|
|
|
/* Put card into fwload state */
|
|
|
|
prism2sta_ifstate(wlandev, P80211ENUM_ifstate_fwload);
|
|
|
|
|
|
|
|
/* Build the PDA we're going to use. */
|
|
|
|
if (read_cardpda(&pda, wlandev)) {
|
|
|
|
printk(KERN_ERR "load_cardpda failed, exiting.\n");
|
2010-02-14 10:59:00 -07:00
|
|
|
return 1;
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* read the card's PRI-SUP */
|
|
|
|
memset(&getmsg, 0, sizeof(getmsg));
|
|
|
|
getmsg.msgcode = DIDmsg_dot11req_mibget;
|
|
|
|
getmsg.msglen = sizeof(getmsg);
|
|
|
|
strcpy(getmsg.devname, wlandev->name);
|
|
|
|
|
|
|
|
getmsg.mibattribute.did = DIDmsg_dot11req_mibget_mibattribute;
|
|
|
|
getmsg.mibattribute.status = P80211ENUM_msgitem_status_data_ok;
|
|
|
|
getmsg.resultcode.did = DIDmsg_dot11req_mibget_resultcode;
|
|
|
|
getmsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
|
|
|
|
|
|
|
|
item = (p80211itemd_t *) getmsg.mibattribute.data;
|
|
|
|
item->did = DIDmib_p2_p2NIC_p2PRISupRange;
|
|
|
|
item->status = P80211ENUM_msgitem_status_no_value;
|
|
|
|
|
2009-05-25 07:36:16 -06:00
|
|
|
data = (u32 *) item->data;
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* DIDmsg_dot11req_mibget */
|
|
|
|
prism2mgmt_mibset_mibget(wlandev, &getmsg);
|
2010-02-14 10:59:00 -07:00
|
|
|
if (getmsg.resultcode.data != P80211ENUM_resultcode_success)
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR "Couldn't fetch PRI-SUP info\n");
|
|
|
|
|
|
|
|
/* Already in host order */
|
|
|
|
priid.role = *data++;
|
|
|
|
priid.id = *data++;
|
|
|
|
priid.variant = *data++;
|
|
|
|
priid.bottom = *data++;
|
|
|
|
priid.top = *data++;
|
|
|
|
|
|
|
|
/* Read the S3 file */
|
2009-08-19 01:06:39 -06:00
|
|
|
result = read_fwfile(rfptr);
|
2009-05-25 07:36:16 -06:00
|
|
|
if (result) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR "Failed to read the data exiting.\n");
|
2010-02-14 10:59:00 -07:00
|
|
|
return 1;
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
result = validate_identity();
|
|
|
|
|
2009-05-25 07:36:16 -06:00
|
|
|
if (result) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR "Incompatible firmware image.\n");
|
2010-02-14 10:59:00 -07:00
|
|
|
return 1;
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if (startaddr == 0x00000000) {
|
|
|
|
printk(KERN_ERR "Can't RAM download a Flash image!\n");
|
2010-02-14 10:59:00 -07:00
|
|
|
return 1;
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Make the image chunks */
|
|
|
|
result = mkimage(fchunk, &nfchunks);
|
|
|
|
|
|
|
|
/* Do any plugging */
|
2009-05-25 07:36:16 -06:00
|
|
|
result = plugimage(fchunk, nfchunks, s3plug, ns3plug, &pda);
|
|
|
|
if (result) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR "Failed to plug data.\n");
|
2010-02-14 10:59:00 -07:00
|
|
|
return 1;
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Insert any CRCs */
|
2009-05-25 07:36:16 -06:00
|
|
|
if (crcimage(fchunk, nfchunks, s3crc, ns3crc)) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR "Failed to insert all CRCs\n");
|
2010-02-14 10:59:00 -07:00
|
|
|
return 1;
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Write the image */
|
|
|
|
result = writeimage(wlandev, fchunk, nfchunks);
|
2009-05-25 07:36:16 -06:00
|
|
|
if (result) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR "Failed to ramwrite image data.\n");
|
2010-02-14 10:59:00 -07:00
|
|
|
return 1;
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* clear any allocated memory */
|
|
|
|
free_chunks(fchunk, &nfchunks);
|
|
|
|
free_srecs();
|
|
|
|
|
|
|
|
printk(KERN_INFO "prism2_usb: firmware loading finished.\n");
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------
|
|
|
|
* crcimage
|
|
|
|
*
|
|
|
|
* Adds a CRC16 in the two bytes prior to each block identified by
|
|
|
|
* an S3 CRC record. Currently, we don't actually do a CRC we just
|
|
|
|
* insert the value 0xC0DE in hfa384x order.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* fchunk Array of image chunks
|
|
|
|
* nfchunks Number of image chunks
|
|
|
|
* s3crc Array of crc records
|
|
|
|
* ns3crc Number of crc records
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* 0 success
|
|
|
|
* ~0 failure
|
|
|
|
----------------------------------------------------------------*/
|
2009-06-10 08:06:11 -06:00
|
|
|
int crcimage(imgchunk_t *fchunk, unsigned int nfchunks, s3crcrec_t *s3crc,
|
2009-04-17 03:15:34 -06:00
|
|
|
unsigned int ns3crc)
|
|
|
|
{
|
2009-05-25 07:36:16 -06:00
|
|
|
int result = 0;
|
|
|
|
int i;
|
|
|
|
int c;
|
|
|
|
u32 crcstart;
|
|
|
|
u32 crcend;
|
|
|
|
u32 cstart = 0;
|
|
|
|
u32 cend;
|
|
|
|
u8 *dest;
|
|
|
|
u32 chunkoff;
|
|
|
|
|
|
|
|
for (i = 0; i < ns3crc; i++) {
|
|
|
|
if (!s3crc[i].dowrite)
|
|
|
|
continue;
|
2009-04-17 03:15:34 -06:00
|
|
|
crcstart = s3crc[i].addr;
|
2009-05-25 07:36:16 -06:00
|
|
|
crcend = s3crc[i].addr + s3crc[i].len;
|
2009-04-17 03:15:34 -06:00
|
|
|
/* Find chunk */
|
2009-05-25 07:36:16 -06:00
|
|
|
for (c = 0; c < nfchunks; c++) {
|
2009-04-17 03:15:34 -06:00
|
|
|
cstart = fchunk[c].addr;
|
2009-05-25 07:36:16 -06:00
|
|
|
cend = fchunk[c].addr + fchunk[c].len;
|
2009-04-17 03:15:34 -06:00
|
|
|
/* the line below does an address & len match search */
|
|
|
|
/* unfortunately, I've found that the len fields of */
|
|
|
|
/* some crc records don't match with the length of */
|
|
|
|
/* the actual data, so we're not checking right */
|
|
|
|
/* now */
|
2009-05-25 07:36:16 -06:00
|
|
|
/* if ( crcstart-2 >= cstart && crcend <= cend ) break; */
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* note the -2 below, it's to make sure the chunk has */
|
|
|
|
/* space for the CRC value */
|
2009-05-25 07:36:16 -06:00
|
|
|
if (crcstart - 2 >= cstart && crcstart < cend)
|
|
|
|
break;
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
2009-05-25 07:36:16 -06:00
|
|
|
if (c >= nfchunks) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR
|
2009-05-25 07:36:16 -06:00
|
|
|
"Failed to find chunk for "
|
|
|
|
"crcrec[%d], addr=0x%06x len=%d , "
|
|
|
|
"aborting crc.\n",
|
|
|
|
i, s3crc[i].addr, s3crc[i].len);
|
2009-04-17 03:15:34 -06:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Insert crc */
|
2009-05-25 07:36:16 -06:00
|
|
|
pr_debug("Adding crc @ 0x%06x\n", s3crc[i].addr - 2);
|
2009-04-17 03:15:34 -06:00
|
|
|
chunkoff = crcstart - cstart - 2;
|
|
|
|
dest = fchunk[c].data + chunkoff;
|
2009-05-25 07:36:16 -06:00
|
|
|
*dest = 0xde;
|
|
|
|
*(dest + 1) = 0xc0;
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------
|
|
|
|
* free_chunks
|
|
|
|
*
|
|
|
|
* Clears the chunklist data structures in preparation for a new file.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* nothing
|
|
|
|
----------------------------------------------------------------*/
|
2009-06-10 08:06:11 -06:00
|
|
|
void free_chunks(imgchunk_t *fchunk, unsigned int *nfchunks)
|
2009-04-17 03:15:34 -06:00
|
|
|
{
|
|
|
|
int i;
|
2009-05-25 07:36:16 -06:00
|
|
|
for (i = 0; i < *nfchunks; i++) {
|
2010-02-14 10:59:00 -07:00
|
|
|
if (fchunk[i].data != NULL)
|
2009-04-17 03:15:34 -06:00
|
|
|
kfree(fchunk[i].data);
|
|
|
|
}
|
|
|
|
*nfchunks = 0;
|
2009-12-09 12:25:04 -07:00
|
|
|
memset(fchunk, 0, sizeof(*fchunk));
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------
|
|
|
|
* free_srecs
|
|
|
|
*
|
|
|
|
* Clears the srec data structures in preparation for a new file.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* none
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* nothing
|
|
|
|
----------------------------------------------------------------*/
|
|
|
|
void free_srecs(void)
|
|
|
|
{
|
|
|
|
ns3data = 0;
|
|
|
|
memset(s3data, 0, sizeof(s3data));
|
|
|
|
ns3plug = 0;
|
|
|
|
memset(s3plug, 0, sizeof(s3plug));
|
|
|
|
ns3crc = 0;
|
|
|
|
memset(s3crc, 0, sizeof(s3crc));
|
|
|
|
ns3info = 0;
|
|
|
|
memset(s3info, 0, sizeof(s3info));
|
|
|
|
startaddr = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------
|
|
|
|
* mkimage
|
|
|
|
*
|
|
|
|
* Scans the currently loaded set of S records for data residing
|
|
|
|
* in contiguous memory regions. Each contiguous region is then
|
|
|
|
* made into a 'chunk'. This function assumes that we're building
|
|
|
|
* a new chunk list. Assumes the s3data items are in sorted order.
|
|
|
|
*
|
|
|
|
* Arguments: none
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* 0 - success
|
|
|
|
* ~0 - failure (probably an errno)
|
|
|
|
----------------------------------------------------------------*/
|
2009-06-10 08:06:11 -06:00
|
|
|
int mkimage(imgchunk_t *clist, unsigned int *ccnt)
|
2009-04-17 03:15:34 -06:00
|
|
|
{
|
2009-05-25 07:36:16 -06:00
|
|
|
int result = 0;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
int currchunk = 0;
|
|
|
|
u32 nextaddr = 0;
|
|
|
|
u32 s3start;
|
|
|
|
u32 s3end;
|
|
|
|
u32 cstart = 0;
|
|
|
|
u32 cend;
|
|
|
|
u32 coffset;
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* There may already be data in the chunklist */
|
|
|
|
*ccnt = 0;
|
|
|
|
|
|
|
|
/* Establish the location and size of each chunk */
|
2009-05-25 07:36:16 -06:00
|
|
|
for (i = 0; i < ns3data; i++) {
|
|
|
|
if (s3data[i].addr == nextaddr) {
|
2009-04-17 03:15:34 -06:00
|
|
|
/* existing chunk, grow it */
|
|
|
|
clist[currchunk].len += s3data[i].len;
|
|
|
|
nextaddr += s3data[i].len;
|
|
|
|
} else {
|
|
|
|
/* New chunk */
|
|
|
|
(*ccnt)++;
|
|
|
|
currchunk = *ccnt - 1;
|
|
|
|
clist[currchunk].addr = s3data[i].addr;
|
|
|
|
clist[currchunk].len = s3data[i].len;
|
|
|
|
nextaddr = s3data[i].addr + s3data[i].len;
|
|
|
|
/* Expand the chunk if there is a CRC record at */
|
|
|
|
/* their beginning bound */
|
2009-05-25 07:36:16 -06:00
|
|
|
for (j = 0; j < ns3crc; j++) {
|
|
|
|
if (s3crc[j].dowrite &&
|
|
|
|
s3crc[j].addr == clist[currchunk].addr) {
|
2009-04-17 03:15:34 -06:00
|
|
|
clist[currchunk].addr -= 2;
|
|
|
|
clist[currchunk].len += 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We're currently assuming there aren't any overlapping chunks */
|
|
|
|
/* if this proves false, we'll need to add code to coalesce. */
|
|
|
|
|
|
|
|
/* Allocate buffer space for chunks */
|
2009-05-25 07:36:16 -06:00
|
|
|
for (i = 0; i < *ccnt; i++) {
|
2009-04-17 03:15:34 -06:00
|
|
|
clist[i].data = kmalloc(clist[i].len, GFP_KERNEL);
|
2009-05-25 07:36:16 -06:00
|
|
|
if (clist[i].data == NULL) {
|
|
|
|
printk(KERN_ERR
|
|
|
|
"failed to allocate image space, exitting.\n");
|
2010-02-14 10:59:00 -07:00
|
|
|
return 1;
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
|
|
|
memset(clist[i].data, 0, clist[i].len);
|
|
|
|
pr_debug("chunk[%d]: addr=0x%06x len=%d\n",
|
2009-05-25 07:36:16 -06:00
|
|
|
i, clist[i].addr, clist[i].len);
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy srec data to chunks */
|
2009-05-25 07:36:16 -06:00
|
|
|
for (i = 0; i < ns3data; i++) {
|
2009-04-17 03:15:34 -06:00
|
|
|
s3start = s3data[i].addr;
|
2009-05-25 07:36:16 -06:00
|
|
|
s3end = s3start + s3data[i].len - 1;
|
|
|
|
for (j = 0; j < *ccnt; j++) {
|
2009-04-17 03:15:34 -06:00
|
|
|
cstart = clist[j].addr;
|
|
|
|
cend = cstart + clist[j].len - 1;
|
2010-02-14 10:59:00 -07:00
|
|
|
if (s3start >= cstart && s3end <= cend)
|
2009-04-17 03:15:34 -06:00
|
|
|
break;
|
|
|
|
}
|
2009-05-25 07:36:16 -06:00
|
|
|
if (((unsigned int)j) >= (*ccnt)) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR
|
2009-05-25 07:36:16 -06:00
|
|
|
"s3rec(a=0x%06x,l=%d), no chunk match, exiting.\n",
|
|
|
|
s3start, s3data[i].len);
|
2010-02-14 10:59:00 -07:00
|
|
|
return 1;
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
|
|
|
coffset = s3start - cstart;
|
2009-05-25 07:36:16 -06:00
|
|
|
memcpy(clist[j].data + coffset, s3data[i].data, s3data[i].len);
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------
|
|
|
|
* mkpdrlist
|
|
|
|
*
|
|
|
|
* Reads a raw PDA and builds an array of pdrec_t structures.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* pda buffer containing raw PDA bytes
|
|
|
|
* pdrec ptr to an array of pdrec_t's. Will be filled on exit.
|
|
|
|
* nrec ptr to a variable that will contain the count of PDRs
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* 0 - success
|
|
|
|
* ~0 - failure (probably an errno)
|
|
|
|
----------------------------------------------------------------*/
|
2009-06-10 08:06:11 -06:00
|
|
|
int mkpdrlist(pda_t *pda)
|
2009-04-17 03:15:34 -06:00
|
|
|
{
|
2009-05-25 07:36:16 -06:00
|
|
|
int result = 0;
|
|
|
|
u16 *pda16 = (u16 *) pda->buf;
|
|
|
|
int curroff; /* in 'words' */
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
pda->nrec = 0;
|
|
|
|
curroff = 0;
|
2009-05-25 07:36:16 -06:00
|
|
|
while (curroff < (HFA384x_PDA_LEN_MAX / 2) &&
|
|
|
|
le16_to_cpu(pda16[curroff + 1]) != HFA384x_PDR_END_OF_PDA) {
|
2010-02-14 10:59:00 -07:00
|
|
|
pda->rec[pda->nrec] = (hfa384x_pdrec_t *) &(pda16[curroff]);
|
2009-04-17 03:15:34 -06:00
|
|
|
|
2009-05-25 07:36:16 -06:00
|
|
|
if (le16_to_cpu(pda->rec[pda->nrec]->code) == HFA384x_PDR_NICID) {
|
2009-04-17 03:15:34 -06:00
|
|
|
memcpy(&nicid, &pda->rec[pda->nrec]->data.nicid,
|
|
|
|
sizeof(nicid));
|
|
|
|
nicid.id = le16_to_cpu(nicid.id);
|
|
|
|
nicid.variant = le16_to_cpu(nicid.variant);
|
|
|
|
nicid.major = le16_to_cpu(nicid.major);
|
|
|
|
nicid.minor = le16_to_cpu(nicid.minor);
|
|
|
|
}
|
|
|
|
if (le16_to_cpu(pda->rec[pda->nrec]->code) ==
|
2009-05-25 07:36:16 -06:00
|
|
|
HFA384x_PDR_MFISUPRANGE) {
|
2009-04-17 03:15:34 -06:00
|
|
|
memcpy(&rfid, &pda->rec[pda->nrec]->data.mfisuprange,
|
|
|
|
sizeof(rfid));
|
|
|
|
rfid.id = le16_to_cpu(rfid.id);
|
|
|
|
rfid.variant = le16_to_cpu(rfid.variant);
|
|
|
|
rfid.bottom = le16_to_cpu(rfid.bottom);
|
|
|
|
rfid.top = le16_to_cpu(rfid.top);
|
|
|
|
}
|
|
|
|
if (le16_to_cpu(pda->rec[pda->nrec]->code) ==
|
2009-05-25 07:36:16 -06:00
|
|
|
HFA384x_PDR_CFISUPRANGE) {
|
2009-04-17 03:15:34 -06:00
|
|
|
memcpy(&macid, &pda->rec[pda->nrec]->data.cfisuprange,
|
|
|
|
sizeof(macid));
|
|
|
|
macid.id = le16_to_cpu(macid.id);
|
|
|
|
macid.variant = le16_to_cpu(macid.variant);
|
|
|
|
macid.bottom = le16_to_cpu(macid.bottom);
|
|
|
|
macid.top = le16_to_cpu(macid.top);
|
|
|
|
}
|
|
|
|
|
|
|
|
(pda->nrec)++;
|
|
|
|
curroff += le16_to_cpu(pda16[curroff]) + 1;
|
|
|
|
|
|
|
|
}
|
2009-05-25 07:36:16 -06:00
|
|
|
if (curroff >= (HFA384x_PDA_LEN_MAX / 2)) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR
|
2009-05-25 07:36:16 -06:00
|
|
|
"no end record found or invalid lengths in "
|
|
|
|
"PDR data, exiting. %x %d\n", curroff, pda->nrec);
|
2010-02-14 10:59:00 -07:00
|
|
|
return 1;
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
2009-05-25 07:36:16 -06:00
|
|
|
if (le16_to_cpu(pda16[curroff + 1]) == HFA384x_PDR_END_OF_PDA) {
|
2010-02-14 10:59:00 -07:00
|
|
|
pda->rec[pda->nrec] = (hfa384x_pdrec_t *) &(pda16[curroff]);
|
2009-04-17 03:15:34 -06:00
|
|
|
(pda->nrec)++;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------
|
|
|
|
* plugimage
|
|
|
|
*
|
|
|
|
* Plugs the given image using the given plug records from the given
|
|
|
|
* PDA and filename.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* fchunk Array of image chunks
|
|
|
|
* nfchunks Number of image chunks
|
|
|
|
* s3plug Array of plug records
|
|
|
|
* ns3plug Number of plug records
|
|
|
|
* pda Current pda data
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* 0 success
|
|
|
|
* ~0 failure
|
|
|
|
----------------------------------------------------------------*/
|
2009-06-10 08:06:11 -06:00
|
|
|
int plugimage(imgchunk_t *fchunk, unsigned int nfchunks,
|
|
|
|
s3plugrec_t *s3plug, unsigned int ns3plug, pda_t * pda)
|
2009-04-17 03:15:34 -06:00
|
|
|
{
|
2009-05-25 07:36:16 -06:00
|
|
|
int result = 0;
|
|
|
|
int i; /* plug index */
|
|
|
|
int j; /* index of PDR or -1 if fname plug */
|
|
|
|
int c; /* chunk index */
|
|
|
|
u32 pstart;
|
|
|
|
u32 pend;
|
|
|
|
u32 cstart = 0;
|
|
|
|
u32 cend;
|
|
|
|
u32 chunkoff;
|
|
|
|
u8 *dest;
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* for each plug record */
|
2009-05-25 07:36:16 -06:00
|
|
|
for (i = 0; i < ns3plug; i++) {
|
2009-04-17 03:15:34 -06:00
|
|
|
pstart = s3plug[i].addr;
|
2009-05-25 07:36:16 -06:00
|
|
|
pend = s3plug[i].addr + s3plug[i].len;
|
2009-04-17 03:15:34 -06:00
|
|
|
/* find the matching PDR (or filename) */
|
2009-05-25 07:36:16 -06:00
|
|
|
if (s3plug[i].itemcode != 0xffffffffUL) { /* not filename */
|
|
|
|
for (j = 0; j < pda->nrec; j++) {
|
|
|
|
if (s3plug[i].itemcode ==
|
|
|
|
le16_to_cpu(pda->rec[j]->code))
|
|
|
|
break;
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
j = -1;
|
|
|
|
}
|
2009-05-25 07:36:16 -06:00
|
|
|
if (j >= pda->nrec && j != -1) { /* if no matching PDR, fail */
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_WARNING
|
2009-05-25 07:36:16 -06:00
|
|
|
"warning: Failed to find PDR for "
|
|
|
|
"plugrec 0x%04x.\n", s3plug[i].itemcode);
|
|
|
|
continue; /* and move on to the next PDR */
|
2009-04-17 03:15:34 -06:00
|
|
|
#if 0
|
|
|
|
/* MSM: They swear that unless it's the MAC address,
|
|
|
|
* the serial number, or the TX calibration records,
|
|
|
|
* then there's reasonable defaults in the f/w
|
|
|
|
* image. Therefore, missing PDRs in the card
|
|
|
|
* should only be a warning, not fatal.
|
|
|
|
* TODO: add fatals for the PDRs mentioned above.
|
|
|
|
*/
|
|
|
|
result = 1;
|
|
|
|
continue;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Validate plug len against PDR len */
|
2009-05-25 07:36:16 -06:00
|
|
|
if (j != -1 && s3plug[i].len < le16_to_cpu(pda->rec[j]->len)) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR
|
2009-05-25 07:36:16 -06:00
|
|
|
"error: Plug vs. PDR len mismatch for "
|
|
|
|
"plugrec 0x%04x, abort plugging.\n",
|
|
|
|
s3plug[i].itemcode);
|
2009-04-17 03:15:34 -06:00
|
|
|
result = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Validate plug address against chunk data and identify chunk */
|
2009-05-25 07:36:16 -06:00
|
|
|
for (c = 0; c < nfchunks; c++) {
|
2009-04-17 03:15:34 -06:00
|
|
|
cstart = fchunk[c].addr;
|
2009-05-25 07:36:16 -06:00
|
|
|
cend = fchunk[c].addr + fchunk[c].len;
|
|
|
|
if (pstart >= cstart && pend <= cend)
|
|
|
|
break;
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
2009-05-25 07:36:16 -06:00
|
|
|
if (c >= nfchunks) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR
|
2009-05-25 07:36:16 -06:00
|
|
|
"error: Failed to find image chunk for "
|
|
|
|
"plugrec 0x%04x.\n", s3plug[i].itemcode);
|
2009-04-17 03:15:34 -06:00
|
|
|
result = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Plug data */
|
|
|
|
chunkoff = pstart - cstart;
|
|
|
|
dest = fchunk[c].data + chunkoff;
|
|
|
|
pr_debug("Plugging item 0x%04x @ 0x%06x, len=%d, "
|
2009-05-25 07:36:16 -06:00
|
|
|
"cnum=%d coff=0x%06x\n",
|
|
|
|
s3plug[i].itemcode, pstart, s3plug[i].len,
|
|
|
|
c, chunkoff);
|
2009-04-17 03:15:34 -06:00
|
|
|
|
2009-05-25 07:36:16 -06:00
|
|
|
if (j == -1) { /* plug the filename */
|
2009-04-17 03:15:34 -06:00
|
|
|
memset(dest, 0, s3plug[i].len);
|
|
|
|
strncpy(dest, PRISM2_USB_FWFILE, s3plug[i].len - 1);
|
2009-05-25 07:36:16 -06:00
|
|
|
} else { /* plug a PDR */
|
|
|
|
memcpy(dest, &(pda->rec[j]->data), s3plug[i].len);
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------
|
|
|
|
* read_cardpda
|
|
|
|
*
|
|
|
|
* Sends the command for the driver to read the pda from the card
|
|
|
|
* named in the device variable. Upon success, the card pda is
|
|
|
|
* stored in the "cardpda" variables. Note that the pda structure
|
|
|
|
* is considered 'well formed' after this function. That means
|
|
|
|
* that the nrecs is valid, the rec array has been set up, and there's
|
|
|
|
* a valid PDAEND record in the raw PDA data.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* pda pda structure
|
|
|
|
* wlandev device
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* 0 - success
|
|
|
|
* ~0 - failure (probably an errno)
|
|
|
|
----------------------------------------------------------------*/
|
2009-06-10 08:06:11 -06:00
|
|
|
int read_cardpda(pda_t *pda, wlandevice_t *wlandev)
|
2009-04-17 03:15:34 -06:00
|
|
|
{
|
2009-05-25 07:36:16 -06:00
|
|
|
int result = 0;
|
|
|
|
p80211msg_p2req_readpda_t msg;
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* set up the msg */
|
|
|
|
msg.msgcode = DIDmsg_p2req_readpda;
|
|
|
|
msg.msglen = sizeof(msg);
|
|
|
|
strcpy(msg.devname, wlandev->name);
|
|
|
|
msg.pda.did = DIDmsg_p2req_readpda_pda;
|
|
|
|
msg.pda.len = HFA384x_PDA_LEN_MAX;
|
|
|
|
msg.pda.status = P80211ENUM_msgitem_status_no_value;
|
|
|
|
msg.resultcode.did = DIDmsg_p2req_readpda_resultcode;
|
|
|
|
msg.resultcode.len = sizeof(u32);
|
|
|
|
msg.resultcode.status = P80211ENUM_msgitem_status_no_value;
|
|
|
|
|
2009-05-25 07:36:16 -06:00
|
|
|
if (prism2mgmt_readpda(wlandev, &msg) != 0) {
|
2009-04-17 03:15:34 -06:00
|
|
|
/* prism2mgmt_readpda prints an errno if appropriate */
|
|
|
|
result = -1;
|
2009-05-25 07:36:16 -06:00
|
|
|
} else if (msg.resultcode.data == P80211ENUM_resultcode_success) {
|
2009-04-17 03:15:34 -06:00
|
|
|
memcpy(pda->buf, msg.pda.data, HFA384x_PDA_LEN_MAX);
|
|
|
|
result = mkpdrlist(pda);
|
|
|
|
} else {
|
|
|
|
/* resultcode must've been something other than success */
|
|
|
|
result = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------
|
2009-08-19 01:06:39 -06:00
|
|
|
* read_fwfile
|
2009-04-17 03:15:34 -06:00
|
|
|
*
|
2009-08-19 01:06:39 -06:00
|
|
|
* Reads the given fw file which should have been compiled from an srec
|
|
|
|
* file. Each record in the fw file will either be a plain data record,
|
|
|
|
* a start address record, or other records used for plugging.
|
2009-04-17 03:15:34 -06:00
|
|
|
*
|
2009-08-19 01:06:39 -06:00
|
|
|
* Note that data records are expected to be sorted into
|
|
|
|
* ascending address order in the fw file.
|
2009-04-17 03:15:34 -06:00
|
|
|
*
|
2009-08-19 01:06:39 -06:00
|
|
|
* Note also that the start address record, originally an S7 record in
|
|
|
|
* the srec file, is expected in the fw file to be like a data record but
|
|
|
|
* with a certain address to make it identiable.
|
2009-04-17 03:15:34 -06:00
|
|
|
*
|
2009-08-19 01:06:39 -06:00
|
|
|
* Here's the SREC format that the fw should have come from:
|
2009-04-17 03:15:34 -06:00
|
|
|
* S[37]nnaaaaaaaaddd...dddcc
|
|
|
|
*
|
|
|
|
* nn - number of bytes starting with the address field
|
|
|
|
* aaaaaaaa - address in readable (or big endian) format
|
|
|
|
* dd....dd - 0-245 data bytes (two chars per byte)
|
|
|
|
* cc - checksum
|
|
|
|
*
|
|
|
|
* The S7 record's (there should be only one) address value gets
|
2009-08-19 01:06:39 -06:00
|
|
|
* converted to an S3 record with address of 0xff400000, with the
|
|
|
|
* start address being stored as a 4 byte data word. That address is
|
|
|
|
* the start execution address used for RAM downloads.
|
2009-04-17 03:15:34 -06:00
|
|
|
*
|
|
|
|
* The S3 records have a collection of subformats indicated by the
|
|
|
|
* value of aaaaaaaa:
|
|
|
|
* 0xff000000 - Plug record, data field format:
|
|
|
|
* xxxxxxxxaaaaaaaassssssss
|
|
|
|
* x - PDR code number (little endian)
|
|
|
|
* a - Address in load image to plug (little endian)
|
|
|
|
* s - Length of plug data area (little endian)
|
|
|
|
*
|
|
|
|
* 0xff100000 - CRC16 generation record, data field format:
|
|
|
|
* aaaaaaaassssssssbbbbbbbb
|
|
|
|
* a - Start address for CRC calculation (little endian)
|
|
|
|
* s - Length of data to calculate over (little endian)
|
|
|
|
* b - Boolean, true=write crc, false=don't write
|
|
|
|
*
|
|
|
|
* 0xff200000 - Info record, data field format:
|
|
|
|
* ssssttttdd..dd
|
|
|
|
* s - Size in words (little endian)
|
|
|
|
* t - Info type (little endian), see #defines and
|
|
|
|
* s3inforec_t for details about types.
|
|
|
|
* d - (s - 1) little endian words giving the contents of
|
|
|
|
* the given info type.
|
|
|
|
*
|
2009-08-19 01:06:39 -06:00
|
|
|
* 0xff400000 - Start address record, data field format:
|
|
|
|
* aaaaaaaa
|
|
|
|
* a - Address in load image to plug (little endian)
|
|
|
|
*
|
2009-04-17 03:15:34 -06:00
|
|
|
* Arguments:
|
2009-08-19 01:06:39 -06:00
|
|
|
* record firmware image (ihex record structure) in kernel memory
|
2009-04-17 03:15:34 -06:00
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* 0 - success
|
|
|
|
* ~0 - failure (probably an errno)
|
|
|
|
----------------------------------------------------------------*/
|
2009-08-19 01:06:39 -06:00
|
|
|
int read_fwfile(const struct ihex_binrec *record)
|
2009-04-17 03:15:34 -06:00
|
|
|
{
|
2009-08-19 01:06:39 -06:00
|
|
|
int i;
|
|
|
|
int rcnt = 0;
|
|
|
|
u16 *tmpinfo;
|
|
|
|
u16 *ptr16;
|
|
|
|
u32 *ptr32, len, addr;
|
2009-04-17 03:15:34 -06:00
|
|
|
|
2009-08-19 01:06:39 -06:00
|
|
|
pr_debug("Reading fw file ...\n");
|
2009-04-17 03:15:34 -06:00
|
|
|
|
2009-08-19 01:06:39 -06:00
|
|
|
while (record) {
|
|
|
|
|
|
|
|
rcnt++;
|
|
|
|
|
|
|
|
len = be16_to_cpu(record->len);
|
|
|
|
addr = be32_to_cpu(record->addr);
|
|
|
|
|
|
|
|
/* Point into data for different word lengths */
|
|
|
|
ptr32 = (u32 *) record->data;
|
|
|
|
ptr16 = (u16 *) record->data;
|
|
|
|
|
|
|
|
/* parse what was an S3 srec and put it in the right array */
|
2010-02-14 10:59:00 -07:00
|
|
|
switch (addr) {
|
2009-08-19 01:06:39 -06:00
|
|
|
case S3ADDR_START:
|
|
|
|
startaddr = *ptr32;
|
|
|
|
pr_debug(" S7 start addr, record=%d "
|
|
|
|
" addr=0x%08x\n",
|
|
|
|
rcnt,
|
|
|
|
startaddr);
|
|
|
|
break;
|
|
|
|
case S3ADDR_PLUG:
|
|
|
|
s3plug[ns3plug].itemcode = *ptr32;
|
|
|
|
s3plug[ns3plug].addr = *(ptr32 + 1);
|
|
|
|
s3plug[ns3plug].len = *(ptr32 + 2);
|
|
|
|
|
|
|
|
pr_debug(" S3 plugrec, record=%d "
|
|
|
|
"itemcode=0x%08x addr=0x%08x len=%d\n",
|
|
|
|
rcnt,
|
|
|
|
s3plug[ns3plug].itemcode,
|
|
|
|
s3plug[ns3plug].addr,
|
|
|
|
s3plug[ns3plug].len);
|
|
|
|
|
|
|
|
ns3plug++;
|
2010-02-14 10:59:00 -07:00
|
|
|
if (ns3plug == S3PLUG_MAX) {
|
2009-08-19 01:06:39 -06:00
|
|
|
printk(KERN_ERR "S3 plugrec limit reached - aborting\n");
|
|
|
|
return 1;
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
2009-08-19 01:06:39 -06:00
|
|
|
break;
|
|
|
|
case S3ADDR_CRC:
|
|
|
|
s3crc[ns3crc].addr = *ptr32;
|
|
|
|
s3crc[ns3crc].len = *(ptr32 + 1);
|
|
|
|
s3crc[ns3crc].dowrite = *(ptr32 + 2);
|
|
|
|
|
|
|
|
pr_debug(" S3 crcrec, record=%d "
|
|
|
|
"addr=0x%08x len=%d write=0x%08x\n",
|
|
|
|
rcnt,
|
|
|
|
s3crc[ns3crc].addr,
|
|
|
|
s3crc[ns3crc].len,
|
|
|
|
s3crc[ns3crc].dowrite);
|
|
|
|
ns3crc++;
|
2010-02-14 10:59:00 -07:00
|
|
|
if (ns3crc == S3CRC_MAX) {
|
2009-08-19 01:06:39 -06:00
|
|
|
printk(KERN_ERR "S3 crcrec limit reached - aborting\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case S3ADDR_INFO:
|
|
|
|
s3info[ns3info].len = *ptr16;
|
|
|
|
s3info[ns3info].type = *(ptr16 + 1);
|
|
|
|
|
|
|
|
pr_debug(" S3 inforec, record=%d "
|
|
|
|
"len=0x%04x type=0x%04x\n",
|
|
|
|
rcnt,
|
|
|
|
s3info[ns3info].len,
|
|
|
|
s3info[ns3info].type);
|
2010-02-14 10:59:00 -07:00
|
|
|
if (((s3info[ns3info].len - 1) * sizeof(u16)) > sizeof(s3info[ns3info].info)) {
|
2009-08-19 01:06:39 -06:00
|
|
|
printk(KERN_ERR " S3 inforec length too long - aborting\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2010-02-14 10:59:00 -07:00
|
|
|
tmpinfo = (u16 *)&(s3info[ns3info].info.version);
|
2009-08-19 01:06:39 -06:00
|
|
|
pr_debug(" info=");
|
|
|
|
for (i = 0; i < s3info[ns3info].len - 1; i++) {
|
|
|
|
tmpinfo[i] = *(ptr16 + 2 + i);
|
|
|
|
pr_debug("%04x ", tmpinfo[i]);
|
|
|
|
}
|
|
|
|
pr_debug("\n");
|
|
|
|
|
|
|
|
ns3info++;
|
2010-02-14 10:59:00 -07:00
|
|
|
if (ns3info == S3INFO_MAX) {
|
2009-08-19 01:06:39 -06:00
|
|
|
printk(KERN_ERR "S3 inforec limit reached - aborting\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: /* Data record */
|
|
|
|
s3data[ns3data].addr = addr;
|
|
|
|
s3data[ns3data].len = len;
|
|
|
|
s3data[ns3data].data = (uint8_t *) record->data;
|
|
|
|
ns3data++;
|
2010-02-14 10:59:00 -07:00
|
|
|
if (ns3data == S3DATA_MAX) {
|
2009-08-19 01:06:39 -06:00
|
|
|
printk(KERN_ERR "S3 datarec limit reached - aborting\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
break;
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
2009-08-19 01:06:39 -06:00
|
|
|
record = ihex_next_binrec(record);
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
2009-08-19 01:06:39 -06:00
|
|
|
return 0;
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*----------------------------------------------------------------
|
|
|
|
* writeimage
|
|
|
|
*
|
|
|
|
* Takes the chunks, builds p80211 messages and sends them down
|
|
|
|
* to the driver for writing to the card.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* wlandev device
|
|
|
|
* fchunk Array of image chunks
|
|
|
|
* nfchunks Number of image chunks
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* 0 success
|
|
|
|
* ~0 failure
|
|
|
|
----------------------------------------------------------------*/
|
2009-06-10 08:06:11 -06:00
|
|
|
int writeimage(wlandevice_t *wlandev, imgchunk_t *fchunk,
|
2009-05-25 07:36:16 -06:00
|
|
|
unsigned int nfchunks)
|
2009-04-17 03:15:34 -06:00
|
|
|
{
|
2009-05-25 07:36:16 -06:00
|
|
|
int result = 0;
|
|
|
|
p80211msg_p2req_ramdl_state_t rstatemsg;
|
|
|
|
p80211msg_p2req_ramdl_write_t rwritemsg;
|
|
|
|
p80211msg_t *msgp;
|
|
|
|
u32 resultcode;
|
|
|
|
int i;
|
|
|
|
int j;
|
|
|
|
unsigned int nwrites;
|
|
|
|
u32 curroff;
|
|
|
|
u32 currlen;
|
|
|
|
u32 currdaddr;
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* Initialize the messages */
|
|
|
|
memset(&rstatemsg, 0, sizeof(rstatemsg));
|
|
|
|
strcpy(rstatemsg.devname, wlandev->name);
|
2009-05-25 07:36:16 -06:00
|
|
|
rstatemsg.msgcode = DIDmsg_p2req_ramdl_state;
|
|
|
|
rstatemsg.msglen = sizeof(rstatemsg);
|
|
|
|
rstatemsg.enable.did = DIDmsg_p2req_ramdl_state_enable;
|
|
|
|
rstatemsg.exeaddr.did = DIDmsg_p2req_ramdl_state_exeaddr;
|
|
|
|
rstatemsg.resultcode.did = DIDmsg_p2req_ramdl_state_resultcode;
|
|
|
|
rstatemsg.enable.status = P80211ENUM_msgitem_status_data_ok;
|
|
|
|
rstatemsg.exeaddr.status = P80211ENUM_msgitem_status_data_ok;
|
|
|
|
rstatemsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
|
|
|
|
rstatemsg.enable.len = sizeof(u32);
|
|
|
|
rstatemsg.exeaddr.len = sizeof(u32);
|
|
|
|
rstatemsg.resultcode.len = sizeof(u32);
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
memset(&rwritemsg, 0, sizeof(rwritemsg));
|
|
|
|
strcpy(rwritemsg.devname, wlandev->name);
|
2009-05-25 07:36:16 -06:00
|
|
|
rwritemsg.msgcode = DIDmsg_p2req_ramdl_write;
|
|
|
|
rwritemsg.msglen = sizeof(rwritemsg);
|
|
|
|
rwritemsg.addr.did = DIDmsg_p2req_ramdl_write_addr;
|
|
|
|
rwritemsg.len.did = DIDmsg_p2req_ramdl_write_len;
|
|
|
|
rwritemsg.data.did = DIDmsg_p2req_ramdl_write_data;
|
|
|
|
rwritemsg.resultcode.did = DIDmsg_p2req_ramdl_write_resultcode;
|
|
|
|
rwritemsg.addr.status = P80211ENUM_msgitem_status_data_ok;
|
|
|
|
rwritemsg.len.status = P80211ENUM_msgitem_status_data_ok;
|
|
|
|
rwritemsg.data.status = P80211ENUM_msgitem_status_data_ok;
|
|
|
|
rwritemsg.resultcode.status = P80211ENUM_msgitem_status_no_value;
|
|
|
|
rwritemsg.addr.len = sizeof(u32);
|
|
|
|
rwritemsg.len.len = sizeof(u32);
|
|
|
|
rwritemsg.data.len = WRITESIZE_MAX;
|
|
|
|
rwritemsg.resultcode.len = sizeof(u32);
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* Send xxx_state(enable) */
|
|
|
|
pr_debug("Sending dl_state(enable) message.\n");
|
|
|
|
rstatemsg.enable.data = P80211ENUM_truth_true;
|
|
|
|
rstatemsg.exeaddr.data = startaddr;
|
|
|
|
|
2010-02-14 10:59:00 -07:00
|
|
|
msgp = (p80211msg_t *) &rstatemsg;
|
2009-04-17 03:15:34 -06:00
|
|
|
result = prism2mgmt_ramdl_state(wlandev, msgp);
|
2009-05-25 07:36:16 -06:00
|
|
|
if (result) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR
|
2009-05-25 07:36:16 -06:00
|
|
|
"writeimage state enable failed w/ result=%d, "
|
|
|
|
"aborting download\n", result);
|
2009-04-17 03:15:34 -06:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
resultcode = rstatemsg.resultcode.data;
|
2009-05-25 07:36:16 -06:00
|
|
|
if (resultcode != P80211ENUM_resultcode_success) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR
|
2009-05-25 07:36:16 -06:00
|
|
|
"writeimage()->xxxdl_state msg indicates failure, "
|
|
|
|
"w/ resultcode=%d, aborting download.\n", resultcode);
|
2009-04-17 03:15:34 -06:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Now, loop through the data chunks and send WRITESIZE_MAX data */
|
2009-05-25 07:36:16 -06:00
|
|
|
for (i = 0; i < nfchunks; i++) {
|
2009-04-17 03:15:34 -06:00
|
|
|
nwrites = fchunk[i].len / WRITESIZE_MAX;
|
|
|
|
nwrites += (fchunk[i].len % WRITESIZE_MAX) ? 1 : 0;
|
|
|
|
curroff = 0;
|
2009-05-25 07:36:16 -06:00
|
|
|
for (j = 0; j < nwrites; j++) {
|
2009-04-17 03:15:34 -06:00
|
|
|
currlen =
|
2009-05-25 07:36:16 -06:00
|
|
|
(fchunk[i].len - (WRITESIZE_MAX * j)) >
|
|
|
|
WRITESIZE_MAX ? WRITESIZE_MAX : (fchunk[i].len -
|
|
|
|
(WRITESIZE_MAX *
|
|
|
|
j));
|
2009-04-17 03:15:34 -06:00
|
|
|
curroff = j * WRITESIZE_MAX;
|
|
|
|
currdaddr = fchunk[i].addr + curroff;
|
|
|
|
/* Setup the message */
|
|
|
|
rwritemsg.addr.data = currdaddr;
|
|
|
|
rwritemsg.len.data = currlen;
|
|
|
|
memcpy(rwritemsg.data.data,
|
2009-05-25 07:36:16 -06:00
|
|
|
fchunk[i].data + curroff, currlen);
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* Send flashdl_write(pda) */
|
2009-05-25 07:36:16 -06:00
|
|
|
pr_debug
|
|
|
|
("Sending xxxdl_write message addr=%06x len=%d.\n",
|
|
|
|
currdaddr, currlen);
|
2009-04-17 03:15:34 -06:00
|
|
|
|
2010-02-14 10:59:00 -07:00
|
|
|
msgp = (p80211msg_t *) &rwritemsg;
|
2009-04-17 03:15:34 -06:00
|
|
|
result = prism2mgmt_ramdl_write(wlandev, msgp);
|
|
|
|
|
|
|
|
/* Check the results */
|
2009-05-25 07:36:16 -06:00
|
|
|
if (result) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR
|
2009-05-25 07:36:16 -06:00
|
|
|
"writeimage chunk write failed w/ result=%d, "
|
|
|
|
"aborting download\n", result);
|
2009-04-17 03:15:34 -06:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
resultcode = rstatemsg.resultcode.data;
|
2009-05-25 07:36:16 -06:00
|
|
|
if (resultcode != P80211ENUM_resultcode_success) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR
|
2009-05-25 07:36:16 -06:00
|
|
|
"writeimage()->xxxdl_write msg indicates failure, "
|
|
|
|
"w/ resultcode=%d, aborting download.\n",
|
|
|
|
resultcode);
|
2009-04-17 03:15:34 -06:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Send xxx_state(disable) */
|
|
|
|
pr_debug("Sending dl_state(disable) message.\n");
|
|
|
|
rstatemsg.enable.data = P80211ENUM_truth_false;
|
|
|
|
rstatemsg.exeaddr.data = 0;
|
|
|
|
|
2010-02-14 10:59:00 -07:00
|
|
|
msgp = (p80211msg_t *) &rstatemsg;
|
2009-04-17 03:15:34 -06:00
|
|
|
result = prism2mgmt_ramdl_state(wlandev, msgp);
|
2009-05-25 07:36:16 -06:00
|
|
|
if (result) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR
|
2009-05-25 07:36:16 -06:00
|
|
|
"writeimage state disable failed w/ result=%d, "
|
|
|
|
"aborting download\n", result);
|
2009-04-17 03:15:34 -06:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
resultcode = rstatemsg.resultcode.data;
|
2009-05-25 07:36:16 -06:00
|
|
|
if (resultcode != P80211ENUM_resultcode_success) {
|
2009-04-17 03:15:34 -06:00
|
|
|
printk(KERN_ERR
|
2009-05-25 07:36:16 -06:00
|
|
|
"writeimage()->xxxdl_state msg indicates failure, "
|
|
|
|
"w/ resultcode=%d, aborting download.\n", resultcode);
|
2009-04-17 03:15:34 -06:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
int validate_identity(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int result = 1;
|
2009-08-19 01:06:39 -06:00
|
|
|
int trump = 0;
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
pr_debug("NIC ID: %#x v%d.%d.%d\n",
|
2009-05-25 07:36:16 -06:00
|
|
|
nicid.id, nicid.major, nicid.minor, nicid.variant);
|
2009-04-17 03:15:34 -06:00
|
|
|
pr_debug("MFI ID: %#x v%d %d->%d\n",
|
2009-05-25 07:36:16 -06:00
|
|
|
rfid.id, rfid.variant, rfid.bottom, rfid.top);
|
2009-04-17 03:15:34 -06:00
|
|
|
pr_debug("CFI ID: %#x v%d %d->%d\n",
|
2009-05-25 07:36:16 -06:00
|
|
|
macid.id, macid.variant, macid.bottom, macid.top);
|
2009-04-17 03:15:34 -06:00
|
|
|
pr_debug("PRI ID: %#x v%d %d->%d\n",
|
2009-05-25 07:36:16 -06:00
|
|
|
priid.id, priid.variant, priid.bottom, priid.top);
|
2009-04-17 03:15:34 -06:00
|
|
|
|
2009-05-25 07:36:16 -06:00
|
|
|
for (i = 0; i < ns3info; i++) {
|
2009-04-17 03:15:34 -06:00
|
|
|
switch (s3info[i].type) {
|
|
|
|
case 1:
|
|
|
|
pr_debug("Version: ID %#x %d.%d.%d\n",
|
2009-05-25 07:36:16 -06:00
|
|
|
s3info[i].info.version.id,
|
|
|
|
s3info[i].info.version.major,
|
|
|
|
s3info[i].info.version.minor,
|
|
|
|
s3info[i].info.version.variant);
|
2009-04-17 03:15:34 -06:00
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
pr_debug("Compat: Role %#x Id %#x v%d %d->%d\n",
|
2009-05-25 07:36:16 -06:00
|
|
|
s3info[i].info.compat.role,
|
|
|
|
s3info[i].info.compat.id,
|
|
|
|
s3info[i].info.compat.variant,
|
|
|
|
s3info[i].info.compat.bottom,
|
|
|
|
s3info[i].info.compat.top);
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
/* MAC compat range */
|
|
|
|
if ((s3info[i].info.compat.role == 1) &&
|
|
|
|
(s3info[i].info.compat.id == 2)) {
|
|
|
|
if (s3info[i].info.compat.variant !=
|
|
|
|
macid.variant) {
|
|
|
|
result = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* PRI compat range */
|
|
|
|
if ((s3info[i].info.compat.role == 1) &&
|
|
|
|
(s3info[i].info.compat.id == 3)) {
|
2009-05-25 07:36:16 -06:00
|
|
|
if ((s3info[i].info.compat.bottom > priid.top)
|
|
|
|
|| (s3info[i].info.compat.top <
|
|
|
|
priid.bottom)) {
|
2009-04-17 03:15:34 -06:00
|
|
|
result = 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* SEC compat range */
|
|
|
|
if ((s3info[i].info.compat.role == 1) &&
|
|
|
|
(s3info[i].info.compat.id == 4)) {
|
2010-03-04 09:14:54 -07:00
|
|
|
/* FIXME: isn't something missing here? */
|
2009-04-17 03:15:34 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 3:
|
2009-05-25 07:36:16 -06:00
|
|
|
pr_debug("Seq: %#x\n", s3info[i].info.buildseq);
|
2009-04-17 03:15:34 -06:00
|
|
|
|
2009-05-25 07:36:16 -06:00
|
|
|
break;
|
2009-04-17 03:15:34 -06:00
|
|
|
case 4:
|
|
|
|
pr_debug("Platform: ID %#x %d.%d.%d\n",
|
2009-05-25 07:36:16 -06:00
|
|
|
s3info[i].info.version.id,
|
|
|
|
s3info[i].info.version.major,
|
|
|
|
s3info[i].info.version.minor,
|
|
|
|
s3info[i].info.version.variant);
|
2009-04-17 03:15:34 -06:00
|
|
|
|
|
|
|
if (nicid.id != s3info[i].info.version.id)
|
|
|
|
continue;
|
|
|
|
if (nicid.major != s3info[i].info.version.major)
|
|
|
|
continue;
|
|
|
|
if (nicid.minor != s3info[i].info.version.minor)
|
|
|
|
continue;
|
|
|
|
if ((nicid.variant != s3info[i].info.version.variant) &&
|
|
|
|
(nicid.id != 0x8008))
|
|
|
|
continue;
|
|
|
|
|
2009-08-19 01:06:39 -06:00
|
|
|
trump = 1;
|
2009-04-17 03:15:34 -06:00
|
|
|
break;
|
|
|
|
case 0x8001:
|
|
|
|
pr_debug("name inforec len %d\n", s3info[i].len);
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pr_debug("Unknown inforec type %d\n", s3info[i].type);
|
|
|
|
}
|
|
|
|
}
|
2010-02-14 10:59:00 -07:00
|
|
|
/* walk through */
|
2009-04-17 03:15:34 -06:00
|
|
|
|
2010-02-14 10:59:00 -07:00
|
|
|
if (trump && (result != 2))
|
|
|
|
result = 0;
|
2009-04-17 03:15:34 -06:00
|
|
|
return result;
|
|
|
|
}
|