[PATCH] Getting compatibility data directly from PDA

Pavel Roskin proski
Sat Jan 24 00:37:56 PST 2004


On Fri, 23 Jan 2004, Jouni Malinen wrote:

> I added an example script, utils/hostap_fw_load, for making firmware
> loading bit easier. I'm running this from /etc/pcmcia/wireless before
> starting in interface configuration. This script should make it possible
> to plug cards with full flash as well as cards without flash and get
> more or less identical user experience ;-).

It would be nice to get rid of the need to use "-i" when loading primary
firmware.  It's a bad practice.  The attached patch to prism2_srec makes
it possible.

When primary firmware is being loaded and PDA is available, the
compatibility data should be read from PDA rather than requested from the
firmware.  The original primary firmware may return incorrect values if it
wasn't plugged.

-- 
Regards,
Pavel Roskin
-------------- next part --------------
--- prism2_srec.c
+++ prism2_srec.c
@@ -116,6 +116,11 @@ static int s3_comp(const void *a, const 
 	return aa->addr - bb->addr;
 }
 
+static int get_bin16_le(unsigned char *data)
+{
+	return data[0] + (data[1] << 8);
+}
+
 static int hex2int(char c)
 {
 	if (c >= '0' && c <= '9')
@@ -1585,6 +1590,39 @@ int download_srec(const char *iface, str
 }
 
 
+void compat_from_pda(struct wlan_info *wlan)
+{
+	int i;
+
+	for (i = 0; i < wlan->pda.pdr_count; i++) {
+		if ((wlan->pda.pdrs[i].pdr == 6) && (wlan->pda.pdrs[i].len == 10)) {
+			wlan->mfi_pri_sup.role = get_bin16_le(&wlan->pda.pdrs[i].data[0]);
+			wlan->mfi_pri_sup.iface_id = get_bin16_le(&wlan->pda.pdrs[i].data[2]);
+			wlan->mfi_pri_sup.variant = get_bin16_le(&wlan->pda.pdrs[i].data[4]);
+			wlan->mfi_pri_sup.bottom = get_bin16_le(&wlan->pda.pdrs[i].data[6]);
+			wlan->mfi_pri_sup.top = get_bin16_le(&wlan->pda.pdrs[i].data[8]);
+		}
+	}
+	for (i = 0; i < wlan->pda.pdr_count; i++) {
+		if ((wlan->pda.pdrs[i].pdr == 7) && (wlan->pda.pdrs[i].len == 10)) {
+			wlan->cfi_pri_sup.role = get_bin16_le(&wlan->pda.pdrs[i].data[0]);
+			wlan->cfi_pri_sup.iface_id = get_bin16_le(&wlan->pda.pdrs[i].data[2]);
+			wlan->cfi_pri_sup.variant = get_bin16_le(&wlan->pda.pdrs[i].data[4]);
+			wlan->cfi_pri_sup.bottom = get_bin16_le(&wlan->pda.pdrs[i].data[6]);
+			wlan->cfi_pri_sup.top = get_bin16_le(&wlan->pda.pdrs[i].data[8]);
+		}
+	}
+	for (i = 0; i < wlan->pda.pdr_count; i++) {
+		if ((wlan->pda.pdrs[i].pdr == 8) && (wlan->pda.pdrs[i].len == 8)) {
+			wlan->nicid.platform = get_bin16_le(&wlan->pda.pdrs[i].data[0]);
+			wlan->nicid.variant = get_bin16_le(&wlan->pda.pdrs[i].data[2]);
+			wlan->nicid.major = get_bin16_le(&wlan->pda.pdrs[i].data[4]);
+			wlan->nicid.minor = get_bin16_le(&wlan->pda.pdrs[i].data[6]);
+		}
+	}
+}
+
+
 void usage(void)
 {
 	printf("Usage: prism2_srec [-vvrgfd] <interface> <srec file name> "
@@ -1745,6 +1783,11 @@ int main(int argc, char *argv[])
 		exit(1);
 	}
 
+
+	/* If loading primary firmware, trust PDA, not the old firmware */
+	if (!skip_pda_read && (srec->component.component == HFA384X_COMP_ID_PRI))
+		compat_from_pda (&wlan);
+
 	show_wlan(&wlan);
 
 	printf("\nVerifying update compatibility and combining data:\n");



More information about the Hostap mailing list