diff -Nur rt73-cvs-2007071510.orig/Module/rt73.h rt73-cvs-2007071510/Module/rt73.h
--- rt73-cvs-2007071510.orig/Module/rt73.h	2007-05-08 22:06:17.000000000 +0200
+++ rt73-cvs-2007071510/Module/rt73.h	2007-07-16 08:27:51.000000000 +0200
@@ -43,6 +43,7 @@
 // 8051 firmware image - base address = 0x4000
 #define FIRMWARE_IMAGE_BASE     0x800
 #define FIRMWARE_IMAGE_SIZE	2048	// 2k byte
+#define MAX_FIRMWARE_IMAGE_SIZE 2048   // 2kbytes
 
 //
 // Security key table memory, base address = 0x1000
diff -Nur rt73-cvs-2007071510.orig/Module/rt73sta.dat rt73-cvs-2007071510/Module/rt73sta.dat
--- rt73-cvs-2007071510.orig/Module/rt73sta.dat	1970-01-01 01:00:00.000000000 +0100
+++ rt73-cvs-2007071510/Module/rt73sta.dat	2007-07-16 08:49:02.000000000 +0200
@@ -0,0 +1,5 @@
+[Default]
+NetworkType=Adhoc
+IBSS_BSSID=02:ca:ff:ee:ba:be
+Channel=10
+SSID=olsr.freifunk.net
diff -Nur rt73-cvs-2007071510.orig/Module/rt_config.h rt73-cvs-2007071510/Module/rt_config.h
--- rt73-cvs-2007071510.orig/Module/rt_config.h	2007-07-15 17:35:22.000000000 +0200
+++ rt73-cvs-2007071510/Module/rt_config.h	2007-07-16 19:45:02.000000000 +0200
@@ -38,7 +38,7 @@
 
 #define PROFILE_PATH                "/etc/Wireless/RT73STA/rt73sta.dat"
 #define NIC_DEVICE_NAME             "RT73STA"
-#define RT2573_IMAGE_FILE_NAME      "rt73.bin"
+#define RT2573_IMAGE_FILE_NAME      "/etc/Wireless/RT73STA/rt73.bin"
 #define DRIVER_NAME                 "rt73"
 #define DRIVER_VERSION		    "1.0.3.6 CVS"
 #define DRIVER_RELDATE              "2007071510"
@@ -268,5 +268,6 @@
 #define READ_PROFILE_FROM_FILE      //read RaConfig profile parameters from rt73sta.dat
 #define INIT_FROM_EEPROM
 
+#define wireless_send_event(a,b,c,d)
 
 #endif	// __RT_CONFIG_H__
diff -Nur rt73-cvs-2007071510.orig/Module/rtmp.h rt73-cvs-2007071510/Module/rtmp.h
--- rt73-cvs-2007071510.orig/Module/rtmp.h	2007-07-16 07:56:42.000000000 +0200
+++ rt73-cvs-2007071510/Module/rtmp.h	2007-07-16 20:05:13.000000000 +0200
@@ -1707,11 +1707,15 @@
 VOID NICResetFromError(
 	IN	PRTMP_ADAPTER	pAd);
 
-INT LoadFirmware (IN PRTMP_ADAPTER pAd, char *firmName);
+NDIS_STATUS NICLoadFirmware(
+	IN PRTMP_ADAPTER pAd);
 
 PUCHAR RTMPFindSection(
 	IN	PCHAR	buffer);
 
+VOID RTMPReadParametersFromFile(
+	IN	PRTMP_ADAPTER pAd);
+
 #ifndef BIG_ENDIAN
 ULONG	RTMPEqualMemory(
 	IN	PVOID	pSrc1,
diff -Nur rt73-cvs-2007071510.orig/Module/rtmp_init.c rt73-cvs-2007071510/Module/rtmp_init.c
--- rt73-cvs-2007071510.orig/Module/rtmp_init.c	2007-06-26 23:26:02.000000000 +0200
+++ rt73-cvs-2007071510/Module/rtmp_init.c	2007-07-16 20:18:33.000000000 +0200
@@ -155,6 +155,123 @@
 };
 #define	NUM_MAC_REG_PARMS	(sizeof(MACRegTable) / sizeof(RTMP_REG_PAIR))
 
+UCHAR FirmwareImage[] = 
+{
+	//2005/07/22 Suport LED mode #0,#1,#2
+	//2005/07/28 add Version control V1.0
+	//2005/09/14 Update firmware code to prevent buffer not page out while aggregate.
+	//2005/10/04 Firmware support Windows Power Saving.
+	//2005/11/03 V1.3 not release, V1.4 improve Aggregation throughput
+	//			 V1.4 will cause USB1.0 RX Stuck.
+	//			 V1.5 remove RX checking(Special case, fixed on USB1.X Stuck issue)
+	//			 V1.6 High throughput & WMM support (base on V1.4) not release
+	//2005/11/24 V1.7 prevent USB1.0 Stuck issue. (base on V1.5)
+	0x02, 0x13, 0x25, 0x12, 0x10, 0xd9, 0x02, 0x12, 0x58, 0x02, 0x13, 0x58, 0x02, 0x13, 0x5a, 0xc0, 
+	0xd0, 0x75, 0xd0, 0x18, 0x12, 0x13, 0x5c, 0xd0, 0xd0, 0x22, 0x02, 0x14, 0x5c, 0x02, 0x14, 0xe7, 
+	0xed, 0x4c, 0x70, 0x44, 0x90, 0x01, 0xa8, 0x74, 0x80, 0xf0, 0xef, 0x30, 0xe5, 0x07, 0xe4, 0x90, 
+	0x00, 0x0f, 0xf0, 0x80, 0x2c, 0xe5, 0x40, 0x24, 0xc0, 0x60, 0x13, 0x24, 0xc0, 0x60, 0x16, 0x24, 
+	0xc0, 0x60, 0x19, 0x24, 0xc0, 0x70, 0x1a, 0xe4, 0x90, 0x00, 0x0b, 0xf0, 0x80, 0x13, 0xe4, 0x90, 
+	0x00, 0x13, 0xf0, 0x80, 0x0c, 0xe4, 0x90, 0x00, 0x1b, 0xf0, 0x80, 0x05, 0xe4, 0x90, 0x00, 0x23, 
+	0xf0, 0xe4, 0x90, 0x01, 0xa8, 0xf0, 0xd3, 0x22, 0x90, 0x02, 0x02, 0xed, 0xf0, 0x90, 0x02, 0x01, 
+	0xef, 0xf0, 0xd3, 0x22, 0xef, 0x24, 0xc0, 0x60, 0x1f, 0x24, 0xc0, 0x60, 0x2e, 0x24, 0xc0, 0x60, 
+	0x3d, 0x24, 0xc0, 0x70, 0x53, 0x90, 0x00, 0x0b, 0xe0, 0x30, 0xe1, 0x02, 0xc3, 0x22, 0x90, 0x00, 
+	0x09, 0xe0, 0xfe, 0x90, 0x00, 0x08, 0x80, 0x37, 0x90, 0x00, 0x13, 0xe0, 0x30, 0xe1, 0x02, 0xc3, 
+	0x22, 0x90, 0x00, 0x11, 0xe0, 0xfe, 0x90, 0x00, 0x10, 0x80, 0x24, 0x90, 0x00, 0x1b, 0xe0, 0x30, 
+	0xe1, 0x02, 0xc3, 0x22, 0x90, 0x00, 0x19, 0xe0, 0xfe, 0x90, 0x00, 0x18, 0x80, 0x11, 0x90, 0x00, 
+	0x23, 0xe0, 0x30, 0xe1, 0x02, 0xc3, 0x22, 0x90, 0x00, 0x21, 0xe0, 0xfe, 0x90, 0x00, 0x20, 0xe0, 
+	0xfd, 0xee, 0xf5, 0x37, 0xed, 0xf5, 0x38, 0xd3, 0x22, 0x30, 0x09, 0x20, 0x20, 0x04, 0x0b, 0x90, 
+	0x02, 0x08, 0xe0, 0x54, 0x0f, 0x70, 0x03, 0x02, 0x12, 0x57, 0xc2, 0x09, 0x90, 0x02, 0x00, 0xe0, 
+	0x44, 0x04, 0xf0, 0x74, 0x04, 0x12, 0x0c, 0x3a, 0xc2, 0x04, 0xc2, 0x07, 0x90, 0x02, 0x01, 0xe0, 
+	0x30, 0xe0, 0x03, 0x00, 0x80, 0xf6, 0x90, 0x03, 0x26, 0xe0, 0x20, 0xe2, 0x03, 0x02, 0x12, 0x57, 
+	0x90, 0x02, 0x08, 0xe0, 0x70, 0x1b, 0x20, 0x07, 0x03, 0x02, 0x12, 0x57, 0x90, 0x03, 0x12, 0xe0, 
+	0x64, 0x22, 0x60, 0x03, 0x02, 0x12, 0x57, 0xd2, 0x09, 0xc2, 0x07, 0x74, 0x02, 0x12, 0x0c, 0x3a, 
+	0x22, 0x90, 0x02, 0x03, 0xe0, 0x30, 0xe4, 0x47, 0x20, 0x06, 0x44, 0xe5, 0x3c, 0x60, 0x34, 0xe5, 
+	0x40, 0x24, 0xc0, 0x60, 0x14, 0x24, 0xc0, 0x60, 0x18, 0x24, 0xc0, 0x60, 0x1c, 0x24, 0xc0, 0x70, 
+	0x22, 0x90, 0x00, 0x0b, 0xe0, 0x30, 0xe1, 0x1b, 0x22, 0x90, 0x00, 0x13, 0xe0, 0x30, 0xe1, 0x13, 
+	0x22, 0x90, 0x00, 0x1b, 0xe0, 0x30, 0xe1, 0x0b, 0x22, 0x90, 0x00, 0x23, 0xe0, 0x30, 0xe1, 0x03, 
+	0x02, 0x12, 0x57, 0x90, 0x02, 0x03, 0x74, 0x01, 0xf0, 0x00, 0xe0, 0x54, 0xc0, 0xf5, 0x40, 0xe5, 
+	0x40, 0x24, 0xc0, 0x60, 0x20, 0x24, 0xc0, 0x60, 0x30, 0x24, 0xc0, 0x60, 0x40, 0x24, 0xc0, 0x70, 
+	0x56, 0x90, 0x00, 0x0b, 0xe0, 0x30, 0xe1, 0x03, 0x02, 0x12, 0x57, 0x90, 0x00, 0x09, 0xe0, 0xfe, 
+	0x90, 0x00, 0x08, 0x80, 0x3a, 0x90, 0x00, 0x13, 0xe0, 0x30, 0xe1, 0x03, 0x02, 0x12, 0x57, 0x90, 
+	0x00, 0x11, 0xe0, 0xfe, 0x90, 0x00, 0x10, 0x80, 0x26, 0x90, 0x00, 0x1b, 0xe0, 0x30, 0xe1, 0x03, 
+	0x02, 0x12, 0x57, 0x90, 0x00, 0x19, 0xe0, 0xfe, 0x90, 0x00, 0x18, 0x80, 0x12, 0x90, 0x00, 0x23, 
+	0xe0, 0x30, 0xe1, 0x03, 0x02, 0x12, 0x57, 0x90, 0x00, 0x21, 0xe0, 0xfe, 0x90, 0x00, 0x20, 0xe0, 
+	0xfd, 0xee, 0xf5, 0x37, 0xed, 0xf5, 0x38, 0x90, 0x03, 0x27, 0x74, 0x82, 0xf0, 0x90, 0x02, 0x01, 
+	0xe5, 0x40, 0xf0, 0x90, 0x02, 0x06, 0xe0, 0xf5, 0x3c, 0xc3, 0xe5, 0x38, 0x95, 0x3a, 0xe5, 0x37, 
+	0x95, 0x39, 0x50, 0x21, 0xe5, 0x40, 0x44, 0x05, 0xff, 0xe5, 0x37, 0xa2, 0xe7, 0x13, 0xfc, 0xe5, 
+	0x38, 0x13, 0xfd, 0x12, 0x10, 0x20, 0xe5, 0x3c, 0x30, 0xe2, 0x04, 0xd2, 0x06, 0x80, 0x02, 0xc2, 
+	0x06, 0x53, 0x3c, 0x01, 0x22, 0x30, 0x0b, 0x07, 0xe4, 0x90, 0x02, 0x02, 0xf0, 0x80, 0x06, 0x90, 
+	0x02, 0x02, 0x74, 0x20, 0xf0, 0xe5, 0x40, 0x44, 0x01, 0x90, 0x02, 0x01, 0xf0, 0x90, 0x02, 0x01, 
+	0xe0, 0x30, 0xe0, 0x03, 0x00, 0x80, 0xf6, 0x90, 0x03, 0x27, 0x74, 0x02, 0xf0, 0xaf, 0x40, 0x12, 
+	0x10, 0x74, 0x40, 0xa5, 0x00, 0x80, 0xf6, 0x22, 0x90, 0x7f, 0xf8, 0xe0, 0xb4, 0x02, 0x03, 0x12, 
+	0x16, 0x38, 0x90, 0x02, 0x01, 0xe0, 0x30, 0xe0, 0x03, 0x00, 0x80, 0xf6, 0x90, 0x03, 0x26, 0xe0, 
+	0x20, 0xe1, 0x07, 0xe5, 0x3b, 0x70, 0x03, 0x02, 0x13, 0x24, 0xe5, 0x3b, 0x70, 0x15, 0x90, 0x03, 
+	0x24, 0xe0, 0x75, 0xf0, 0x40, 0xa4, 0xf5, 0x36, 0x85, 0xf0, 0x35, 0x75, 0x24, 0x83, 0x75, 0x3b, 
+	0x01, 0x80, 0x03, 0x75, 0x24, 0x03, 0xd3, 0xe5, 0x36, 0x95, 0x3a, 0xe5, 0x35, 0x95, 0x39, 0x40, 
+	0x36, 0x90, 0x02, 0x01, 0xe0, 0x30, 0xe0, 0x03, 0x00, 0x80, 0xf6, 0x90, 0x03, 0x27, 0xe5, 0x24, 
+	0xf0, 0x90, 0x00, 0x0f, 0xe0, 0x30, 0xe1, 0x04, 0x30, 0x0e, 0xf6, 0x22, 0x30, 0x0b, 0x07, 0xe4, 
+	0x90, 0x02, 0x02, 0xf0, 0x80, 0x06, 0x90, 0x02, 0x02, 0x74, 0x20, 0xf0, 0x90, 0x02, 0x01, 0x74, 
+	0x21, 0xf0, 0x75, 0x24, 0x03, 0x80, 0x3d, 0xe5, 0x35, 0xa2, 0xe7, 0x13, 0xfe, 0xe5, 0x36, 0x13, 
+	0xfd, 0xac, 0x06, 0x90, 0x02, 0x01, 0xe0, 0x30, 0xe0, 0x03, 0x00, 0x80, 0xf6, 0x90, 0x03, 0x27, 
+	0xe5, 0x24, 0xf0, 0x90, 0x00, 0x0f, 0xe0, 0x30, 0xe1, 0x04, 0x30, 0x0e, 0xf6, 0x22, 0x7f, 0x25, 
+	0x12, 0x10, 0x20, 0xe5, 0x36, 0xb5, 0x3a, 0x08, 0xe5, 0x35, 0xb5, 0x39, 0x03, 0x00, 0x80, 0x04, 
+	0xe4, 0xf5, 0x3b, 0x22, 0xc3, 0xe5, 0x36, 0x95, 0x3a, 0xf5, 0x36, 0xe5, 0x35, 0x95, 0x39, 0xf5, 
+	0x35, 0x02, 0x12, 0x96, 0x22, 0x75, 0xa8, 0x0f, 0x90, 0x03, 0x06, 0x74, 0x01, 0xf0, 0x90, 0x03, 
+	0x07, 0xf0, 0x90, 0x03, 0x08, 0x04, 0xf0, 0x90, 0x03, 0x09, 0x74, 0x6c, 0xf0, 0x90, 0x03, 0x0a, 
+	0x74, 0xff, 0xf0, 0x90, 0x03, 0x02, 0x74, 0x1f, 0xf0, 0x90, 0x03, 0x00, 0x74, 0x04, 0xf0, 0x90, 
+	0x03, 0x25, 0x74, 0x31, 0xf0, 0xd2, 0xaf, 0x22, 0x00, 0x22, 0x00, 0x22, 0x90, 0x03, 0x05, 0xe0, 
+	0x30, 0xe0, 0x0b, 0xe0, 0x44, 0x01, 0xf0, 0x30, 0x09, 0x02, 0xd2, 0x04, 0xc2, 0x07, 0x22, 0x8d, 
+	0x24, 0xa9, 0x07, 0x90, 0x7f, 0xfc, 0xe0, 0x75, 0x25, 0x00, 0xf5, 0x26, 0xa3, 0xe0, 0x75, 0x27, 
+	0x00, 0xf5, 0x28, 0xa3, 0xe0, 0xff, 0xa3, 0xe0, 0xfd, 0xe9, 0x30, 0xe5, 0x14, 0x54, 0xc0, 0x60, 
+	0x05, 0x43, 0x05, 0x03, 0x80, 0x03, 0x53, 0x05, 0xfc, 0xef, 0x54, 0x3f, 0x44, 0x40, 0xff, 0x80, 
+	0x06, 0x53, 0x07, 0x3f, 0x53, 0x05, 0xf0, 0xe5, 0x24, 0x30, 0xe0, 0x05, 0x43, 0x05, 0x10, 0x80, 
+	0x03, 0x53, 0x05, 0xef, 0x90, 0x7f, 0xfc, 0xe5, 0x26, 0xf0, 0xa3, 0xe5, 0x28, 0xf0, 0xa3, 0xef, 
+	0xf0, 0xa3, 0xed, 0xf0, 0x22, 0x8f, 0x24, 0xa9, 0x05, 0x90, 0x7f, 0xfc, 0xe0, 0x75, 0x25, 0x00, 
+	0xf5, 0x26, 0xa3, 0xe0, 0x75, 0x27, 0x00, 0xf5, 0x28, 0xa3, 0xe0, 0xff, 0xa3, 0xe0, 0xfd, 0xe5, 
+	0x24, 0x30, 0xe5, 0x0b, 0x43, 0x05, 0x0f, 0xef, 0x54, 0x3f, 0x44, 0x40, 0xff, 0x80, 0x06, 0x53, 
+	0x05, 0xf0, 0x53, 0x07, 0x3f, 0xe9, 0x30, 0xe0, 0x05, 0x43, 0x05, 0x10, 0x80, 0x03, 0x53, 0x05, 
+	0xef, 0x90, 0x7f, 0xfc, 0xe5, 0x26, 0xf0, 0xa3, 0xe5, 0x28, 0xf0, 0xa3, 0xef, 0xf0, 0xa3, 0xed, 
+	0xf0, 0x22, 0x90, 0x7f, 0xfc, 0xe0, 0xf9, 0xa3, 0xe0, 0xfe, 0xa3, 0xe0, 0xfc, 0xa3, 0xe0, 0xfb, 
+	0xef, 0x30, 0xe5, 0x0b, 0x43, 0x03, 0x0f, 0xec, 0x54, 0x3f, 0x44, 0x40, 0xfc, 0x80, 0x06, 0x53, 
+	0x03, 0xf0, 0x53, 0x04, 0x3f, 0xed, 0x30, 0xe0, 0x07, 0xef, 0x54, 0xc0, 0x60, 0x07, 0x80, 0x0a, 
+	0xef, 0x54, 0xc0, 0x60, 0x05, 0x43, 0x03, 0x10, 0x80, 0x03, 0x53, 0x03, 0xef, 0x90, 0x7f, 0xfc, 
+	0xe9, 0xf0, 0xa3, 0xee, 0xf0, 0xa3, 0xec, 0xf0, 0xa3, 0xeb, 0xf0, 0x22, 0xe5, 0x4b, 0xfd, 0x54, 
+	0x1f, 0x90, 0x7f, 0xf8, 0xf0, 0xe5, 0x4a, 0xf5, 0x09, 0x90, 0x30, 0x38, 0xe0, 0x90, 0x7f, 0xfc, 
+	0xf0, 0x90, 0x30, 0x39, 0xe0, 0x90, 0x7f, 0xfd, 0xf0, 0x90, 0x30, 0x3a, 0xe0, 0x90, 0x7f, 0xfe, 
+	0xf0, 0x90, 0x30, 0x3b, 0xe0, 0x90, 0x7f, 0xff, 0xf0, 0xed, 0x30, 0xe5, 0x0c, 0x54, 0xc0, 0x60, 
+	0x0d, 0x90, 0x7f, 0xf0, 0xe5, 0x47, 0xf0, 0x80, 0x05, 0xe4, 0x90, 0x7f, 0xf0, 0xf0, 0x90, 0x7f, 
+	0xf8, 0xe0, 0x14, 0x60, 0x08, 0x24, 0xfe, 0x60, 0x0d, 0x24, 0x03, 0x80, 0x12, 0xaf, 0x05, 0xad, 
+	0x09, 0x12, 0x13, 0xc5, 0x80, 0x10, 0xaf, 0x05, 0xad, 0x09, 0x12, 0x14, 0x12, 0x80, 0x07, 0xaf, 
+	0x05, 0xad, 0x09, 0x12, 0x13, 0x6f, 0x90, 0x7f, 0xfc, 0xe0, 0x90, 0x30, 0x38, 0xf0, 0x90, 0x7f, 
+	0xfd, 0xe0, 0x90, 0x30, 0x39, 0xf0, 0x90, 0x7f, 0xfe, 0xe0, 0x90, 0x30, 0x3a, 0xf0, 0x90, 0x7f, 
+	0xff, 0xe0, 0x90, 0x30, 0x3b, 0xf0, 0x22, 0xe5, 0x4b, 0x64, 0x01, 0x60, 0x03, 0x02, 0x15, 0x71, 
+	0xf5, 0x4b, 0xe5, 0x44, 0x45, 0x43, 0x70, 0x03, 0x02, 0x15, 0xa0, 0x12, 0x0c, 0x14, 0x12, 0x0b, 
+	0x86, 0x50, 0xfb, 0x90, 0x00, 0x00, 0xe0, 0xf5, 0x25, 0x12, 0x15, 0xb4, 0xc2, 0x92, 0xe4, 0xf5, 
+	0x24, 0xe5, 0x24, 0xc3, 0x95, 0x25, 0x50, 0x49, 0x7e, 0x00, 0x7f, 0x4c, 0x74, 0x40, 0x25, 0x24, 
+	0xf5, 0x82, 0xe4, 0x34, 0x01, 0xad, 0x82, 0xfc, 0x75, 0x2b, 0x02, 0x7b, 0x10, 0x12, 0x07, 0x1e, 
+	0xc2, 0x93, 0x12, 0x15, 0xa1, 0x7d, 0xa0, 0x12, 0x15, 0xd0, 0xe5, 0x24, 0x54, 0x0f, 0x24, 0x4c, 
+	0xf8, 0xe6, 0xfd, 0xaf, 0x4b, 0xae, 0x4a, 0x12, 0x15, 0xd8, 0x05, 0x4b, 0xe5, 0x4b, 0x70, 0x02, 
+	0x05, 0x4a, 0x12, 0x0a, 0x5f, 0x05, 0x24, 0xe5, 0x24, 0x54, 0x0f, 0x70, 0xd5, 0xd2, 0x93, 0x80, 
+	0xb0, 0xc3, 0xe5, 0x44, 0x95, 0x25, 0xf5, 0x44, 0xe5, 0x43, 0x94, 0x00, 0xf5, 0x43, 0x02, 0x14, 
+	0xf2, 0x12, 0x15, 0xb4, 0xc2, 0x93, 0xc2, 0x92, 0x12, 0x15, 0xa1, 0x7d, 0x80, 0x12, 0x15, 0xd0, 
+	0x7d, 0xaa, 0x74, 0x55, 0xff, 0xfe, 0x12, 0x15, 0xd8, 0x7d, 0x55, 0x7f, 0xaa, 0x7e, 0x2a, 0x12, 
+	0x15, 0xd8, 0x7d, 0x30, 0xaf, 0x4b, 0xae, 0x4a, 0x12, 0x15, 0xd8, 0x12, 0x0a, 0x5f, 0xd2, 0x93, 
+	0x22, 0x7d, 0xaa, 0x74, 0x55, 0xff, 0xfe, 0x12, 0x15, 0xd8, 0x7d, 0x55, 0x7f, 0xaa, 0x7e, 0x2a, 
+	0x12, 0x15, 0xd8, 0x22, 0xad, 0x47, 0x7f, 0x34, 0x7e, 0x30, 0x12, 0x15, 0xd8, 0x7d, 0xff, 0x7f, 
+	0x35, 0x7e, 0x30, 0x12, 0x15, 0xd8, 0xe4, 0xfd, 0x7f, 0x37, 0x7e, 0x30, 0x12, 0x15, 0xd8, 0x22, 
+	0x74, 0x55, 0xff, 0xfe, 0x12, 0x15, 0xd8, 0x22, 0x8f, 0x82, 0x8e, 0x83, 0xed, 0xf0, 0x22, 0xe4, 
+	0xfc, 0x90, 0x7f, 0xf0, 0xe0, 0xaf, 0x09, 0x14, 0x60, 0x14, 0x14, 0x60, 0x15, 0x14, 0x60, 0x16, 
+	0x14, 0x60, 0x17, 0x14, 0x60, 0x18, 0x24, 0x05, 0x70, 0x16, 0xe4, 0xfc, 0x80, 0x12, 0x7c, 0x01, 
+	0x80, 0x0e, 0x7c, 0x03, 0x80, 0x0a, 0x7c, 0x07, 0x80, 0x06, 0x7c, 0x0f, 0x80, 0x02, 0x7c, 0x1f, 
+	0xec, 0x6f, 0xf4, 0x54, 0x1f, 0xfc, 0x90, 0x30, 0x34, 0xe0, 0x54, 0xe0, 0x4c, 0xfd, 0xa3, 0xe0, 
+	0xfc, 0x43, 0x04, 0x1f, 0x7f, 0x34, 0x7e, 0x30, 0x12, 0x15, 0xd8, 0xad, 0x04, 0x0f, 0x12, 0x15, 
+	0xd8, 0xe4, 0xfd, 0x7f, 0x37, 0x02, 0x15, 0xd8, 0x02, 0x15, 0xdf, 0x00, 0x00, 0x00, 0x00, 0x00, 
+};
+
+#define	FIRMAREIMAGE_LENGTH		(sizeof (FirmwareImage) / sizeof(UCHAR))
+#define FIRMWARE_MAJOR_VERSION	1
+#define FIRMWARE_MINOR_VERSION	7
+
 VOID CreateThreads( struct net_device *net_dev )
 {
 	PRTMP_ADAPTER pAd = (PRTMP_ADAPTER) net_dev->priv;
@@ -1508,120 +1625,189 @@
 
 }
 
-INT LoadFirmware (PRTMP_ADAPTER pAd, char *firmName)
-{
-	const struct firmware *fw_entry;
-	struct usb_device *dev = pAd->pUsb_Dev;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-	char udevice[16];
-	snprintf(udevice, sizeof(udevice), "rt73%3.3d%3.3d", dev->bus->busnum, dev->devnum);
-#else
-	struct device *udevice = &dev->dev;
-#endif
+/*
+	========================================================================
+	
+	Routine Description:
+		Load 8051 firmware RT2561.BIN file into MAC ASIC
 
-	size_t size;
-	u8 *data;
-	USHORT i, loaded = 0;
-	ULONG reg;
-	u16 crc = 0;
-	INT status;
-#define BUFFERED_COPY
-#ifdef BUFFERED_COPY
-	u8 buf[64];
-#else
-	u32 buf;
-#endif
-	DBGPRINT(RT_DEBUG_TRACE, "--> LoadFirmware \n");
+	Arguments:
+		Adapter						Pointer to our adapter
 
-	// Access firmware file
-	if ((status = request_firmware(&fw_entry, firmName, udevice))) {
-		printk(KERN_ERR "rt73: Failed to request_firmware. "
-				"Check your firmware file location\n");
-		goto fw_error;
-	}
-
-	if (fw_entry->size != FIRMWARE_IMAGE_SIZE) {
-		printk(KERN_ERR "rt73: Firmware file size error "
-			"(%d instead of %d)\n",
-			fw_entry->size, FIRMWARE_IMAGE_SIZE);
-		status = EBADF;
-		goto error;
-	}
-
-	// Firmware CRC check
-	size = fw_entry->size - 2;
-	data = fw_entry->data;
-
-	for (i=0; i < size; i++)
-		crc = ByteCRC16(*data++, crc);
-	crc = ByteCRC16(0x00, crc);
-	crc = ByteCRC16(0x00, crc);
-
-	if (crc != ((fw_entry->data[size] << 8) | fw_entry->data[size + 1])) {
-		printk(KERN_ERR "rt73: Firmware CRC error "
-				"Check your firmware file integrity\n");
-		status = EBADF;
-		goto error;
-	}
-
-	// Wait for stable hardware
-	for (i = 0; i < 100; i++) {
-		RTUSBReadMACRegister(pAd, MAC_CSR0, &reg);
-		if (reg)
-			break;
-		msleep(1);
-	}
+	Return Value:
+		NDIS_STATUS_SUCCESS 		firmware image load ok
+		NDIS_STATUS_FAILURE 		image not found
 
-	if (!reg) {
-		printk(KERN_ERR "rt73: Unstable hardware\n");
-		status = EBUSY;
-		goto error;
-	}
+	========================================================================
+*/
+NDIS_STATUS NICLoadFirmware(
+	IN PRTMP_ADAPTER pAd)
+{
+	NDIS_STATUS				Status = NDIS_STATUS_SUCCESS;
+	PUCHAR					src = NULL;
+	struct file				*srcf;
+	INT 					retval = 0, orgfsuid, orgfsgid, i;
+	mm_segment_t			orgfs;
+	PUCHAR					pFirmwareImage;
+	UINT					FileLength = 0;
+	INT						ret;					
+
+	
+	DBGPRINT(RT_DEBUG_TRACE,"--> NICLoadFirmware\n");
+	pAd->FirmwareVersion = (FIRMWARE_MAJOR_VERSION << 8) + FIRMWARE_MINOR_VERSION; //default version.
+
+	src = RT2573_IMAGE_FILE_NAME;
+
+	// Save uid and gid used for filesystem access.
+	// Set user and group to 0 (root)	
+	orgfsuid = current->fsuid;
+	orgfsgid = current->fsgid;
+	current->fsuid=current->fsgid = 0;
+	orgfs = get_fs();
+	set_fs(KERNEL_DS);
+		
+	pFirmwareImage = kmalloc(MAX_FIRMWARE_IMAGE_SIZE, MEM_ALLOC_FLAG);
+	if (pFirmwareImage == NULL) 
+	{
+		DBGPRINT(RT_DEBUG_ERROR, "NICLoadFirmware-Memory allocate fail\n");
+		Status = NDIS_STATUS_FAILURE;
+		goto out;
+	}
+
+	if (src && *src) 
+	{
+		srcf = filp_open(src, O_RDONLY, 0);
+		if (IS_ERR(srcf)) 
+		{
+			Status = NDIS_STATUS_FAILURE;
+			DBGPRINT(RT_DEBUG_ERROR, "--> Error %ld opening %s\n", -PTR_ERR(srcf),src);    
+		}
+		else 
+		{
+			// The object must have a read method
+			if (srcf->f_op && srcf->f_op->read) 
+			{
+				memset(pFirmwareImage, 0x00, MAX_FIRMWARE_IMAGE_SIZE);
 
-	// Write firmware to device
-	for (i = 0; i < FIRMWARE_IMAGE_SIZE; i += sizeof(buf)) {
-#ifdef BUFFERED_COPY
-		memcpy(&buf, &fw_entry->data[i], sizeof(buf));
-#else
-		buf = *(u32 *) &fw_entry->data[i];
-#endif
-		if ((status = RTUSBMultiWrite(pAd, FIRMWARE_IMAGE_BASE + i,
-						&buf, sizeof(buf))) < 0) {
-			printk(KERN_ERR "rt73: Firmware loading error\n");
-			goto error;
+				FileLength = srcf->f_op->read(srcf, pFirmwareImage, MAX_FIRMWARE_IMAGE_SIZE, &srcf->f_pos);
+				if (FileLength != MAX_FIRMWARE_IMAGE_SIZE)
+				{
+					DBGPRINT_ERR("NICLoadFirmware: error file length (=%d) in rt73.bin\n",FileLength);
+					Status = NDIS_STATUS_FAILURE;
+				}
+				else
+				{  //FileLength == MAX_FIRMWARE_IMAGE_SIZE
+					PUCHAR ptr = pFirmwareImage;
+					USHORT crc = 0;
+					
+					for (i=0; i<(MAX_FIRMWARE_IMAGE_SIZE-2); i++, ptr++)
+						crc = ByteCRC16(*ptr, crc);
+					crc = ByteCRC16(0x00, crc);
+					crc = ByteCRC16(0x00, crc);
+					
+					if ((pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-2] != (UCHAR)(crc>>8)) ||
+						(pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-1] != (UCHAR)(crc)))
+					{
+						DBGPRINT_ERR("NICLoadFirmware: CRC = 0x%02x 0x%02x error, should be 0x%02x 0x%02x\n",
+							pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-2], pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-1],
+							(UCHAR)(crc>>8), (UCHAR)(crc) );
+
+						if (retval)
+						{
+							DBGPRINT(RT_DEBUG_ERROR, "--> Error %d closing %s\n", -retval, src);
+						}
+
+						Status = NDIS_STATUS_FAILURE;
+					}
+					else
+					{
+
+						if ((pAd->FirmwareVersion) > ((pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-4] << 8) + pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-3]))
+						{
+							DBGPRINT_ERR("NICLoadFirmware: Ver=%d.%d, local Ver=%d.%d, used FirmwareImage talbe instead\n",
+								pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-4], pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-3],
+								FIRMWARE_MAJOR_VERSION, FIRMWARE_MINOR_VERSION);
+
+							Status = NDIS_STATUS_FAILURE;
+						}
+						else
+						{
+							pAd->FirmwareVersion = (pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-4] << 8) + pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-3];
+							DBGPRINT(RT_DEBUG_TRACE,"NICLoadFirmware OK: CRC = 0x%04x ver=%d.%d\n", crc,
+								pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-4], pFirmwareImage[MAX_FIRMWARE_IMAGE_SIZE-3]);
+						}
+
+					}
+				}
+			}
+			else
+			{
+				Status = NDIS_STATUS_FAILURE;
+				DBGPRINT(RT_DEBUG_ERROR, "--> %s does not have a write method\n", src);
+			}
+			
+			retval = filp_close(srcf, NULL);			
+			if (retval)
+			{
+				Status = NDIS_STATUS_FAILURE;
+				DBGPRINT(RT_DEBUG_ERROR, "--> Error %d closing %s\n", -retval, src);
+			}
 		}
-		loaded += status;
 	}
-	DBGPRINT(RT_DEBUG_TRACE, "%d bytes written to device.\n", loaded);
+	else
+	{
+		Status = NDIS_STATUS_FAILURE;
+		DBGPRINT(RT_DEBUG_ERROR, "Error src not available\n");
+	}
+
 
-	if (loaded < FIRMWARE_IMAGE_SIZE) {
-		// Should never happen
-		printk(KERN_ERR "rt73: Firmware loading incomplete\n");
-		status = EIO;
-		goto error;
+	if (Status != NDIS_STATUS_SUCCESS)
+	{	
+		FileLength = FIRMAREIMAGE_LENGTH;
+		memset(pFirmwareImage, 0x00, FileLength);
+		NdisMoveMemory(pFirmwareImage, &FirmwareImage[0], FileLength);
+		Status = NDIS_STATUS_SUCCESS; // change to success
+		
+		DBGPRINT(RT_DEBUG_ERROR, "NICLoadFirmware failed, used local Firmware(v %d.%d) instead\n", 
+				FIRMWARE_MAJOR_VERSION, FIRMWARE_MINOR_VERSION);		
 	}
 
+	// select 8051 program bank; write entire firmware image
+	for (i = 0; i < FileLength; i = i + 4)
+	{
+		ret = RTUSBMultiWrite(pAd, FIRMWARE_IMAGE_BASE + i, pFirmwareImage + i, 4);
 
-	// Send 'run firmware' request to device
-	if ((status = RTUSBFirmwareRun(pAd)) < 0) {
-		printk(KERN_ERR "rt73: Device refuses to run firmware\n");
-		goto error;
+		if (ret < 0)
+		{
+			Status = NDIS_STATUS_FAILURE;
+			break;
+		}
 	}
 
-	// Reset LED
-	RTMPSetLED(pAd, LED_LINK_DOWN);
 
-	// Firmware loaded ok
-	OPSTATUS_SET_FLAG (pAd, fOP_STATUS_FIRMWARE_LOAD );
-	status = 0;
+out:	
+	if (pFirmwareImage != NULL)
+		kfree(pFirmwareImage);
+
+	set_fs(orgfs);
+	current->fsuid = orgfsuid;
+	current->fsgid = orgfsgid;
 
-error:
-	release_firmware(fw_entry);
+	if (Status == NDIS_STATUS_SUCCESS)
+	{
+		RTUSBFirmwareRun(pAd);
+		
+		//
+		// Send LED command to Firmare after RTUSBFirmwareRun;
+		//
+		RTMPSetLED(pAd, LED_LINK_DOWN);
+		OPSTATUS_SET_FLAG (pAd, fOP_STATUS_FIRMWARE_LOAD );
+	}		
 
-fw_error:
-	DBGPRINT(RT_DEBUG_TRACE, "<-- LoadFirmware (status: %d, loaded: %d)\n",
-							status, loaded);
-	return status;
+	DBGPRINT(RT_DEBUG_TRACE,"<-- NICLoadFirmware (src=%s)\n", src);  
+	
+
+	return Status;
 }
 
  /**
@@ -1683,6 +1869,807 @@
 	return (sbegin);
 }
 
+/*
+	========================================================================
+
+	Routine Description:
+		Find key section for Get key parameter.
+
+	Arguments:
+		buffer						Pointer to the buffer to start find the key section
+		section 					the key of the secion to be find
+
+	Return Value:
+		NULL						Fail
+		Others						Success
+	========================================================================
+*/
+PUCHAR RTMPFindSection(
+	IN	PCHAR	buffer)
+{
+	CHAR temp_buf[255];
+	PUCHAR	ptr;
+
+	strcpy(temp_buf, "[");					/*	and the opening bracket [  */
+	strcat(temp_buf, "Default");
+	strcat(temp_buf, "]");
+
+  
+	if((ptr = rtstrstr(buffer, temp_buf)) != NULL)
+			return (ptr+strlen("\n"));
+		else
+			return NULL;
+}
+
+/*
+	========================================================================
+
+	Routine Description:
+		Get key parameter.
+
+	Arguments:
+		key 						Pointer to key string
+		dest						Pointer to destination		
+		destsize					The datasize of the destination
+		buffer						Pointer to the buffer to start find the key
+
+	Return Value:
+		TRUE						Success
+		FALSE						Fail
+
+	Note:
+		This routine get the value with the matched key (case case-sensitive)
+	========================================================================
+*/
+INT RTMPGetKeyParameter(
+	IN	PCHAR	key,
+	OUT PCHAR	dest,	
+	IN	INT 	destsize,
+	IN	PCHAR	buffer)
+{
+    CHAR *temp_buf1;
+    CHAR *temp_buf2;
+	CHAR *start_ptr;
+	CHAR *end_ptr;
+	CHAR *ptr;
+	CHAR *offset = 0;
+	INT  len;
+
+#define MAX_PARAM_BUFFER_SIZE 2048
+
+	temp_buf1 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
+	if(temp_buf1 == NULL)
+        return (FALSE);
+
+	temp_buf2 = kmalloc(MAX_PARAM_BUFFER_SIZE, MEM_ALLOC_FLAG);
+	if(temp_buf2 == NULL)
+	{
+		kfree(temp_buf1);
+        return (FALSE);
+	}
+
+	//find section
+	if((offset = RTMPFindSection(buffer)) == NULL)
+    {
+    	kfree(temp_buf1);
+    	kfree(temp_buf2);
+		return (FALSE);
+    }
+
+	strcpy(temp_buf1, "\n");
+	strcat(temp_buf1, key);
+	strcat(temp_buf1, "=");
+
+	//search key
+	if((start_ptr=rtstrstr(offset, temp_buf1))==NULL)
+    {
+    	kfree(temp_buf1);
+    	kfree(temp_buf2);
+        return (FALSE);
+    }
+
+	start_ptr+=strlen("\n");
+   
+	if((end_ptr=rtstrstr(start_ptr, "\n"))==NULL)
+	   end_ptr=start_ptr+strlen(start_ptr);
+
+	if (end_ptr<start_ptr)
+    {
+    	kfree(temp_buf1);
+    	kfree(temp_buf2);
+        return (FALSE);
+    }
+
+	memcpy(temp_buf2, start_ptr, end_ptr-start_ptr);
+	temp_buf2[end_ptr-start_ptr]='\0';
+	len = strlen(temp_buf2);
+	strcpy(temp_buf1, temp_buf2);
+	if((start_ptr=rtstrstr(temp_buf1, "=")) == NULL)
+    {
+    	kfree(temp_buf1);
+    	kfree(temp_buf2);
+        return (FALSE);
+    }
+
+	strcpy(temp_buf2, start_ptr+1);
+	ptr = temp_buf2;
+	//trim space or tab
+	while(*ptr != 0x00)
+	{
+		if( (*ptr == ' ') || (*ptr == '\t') )
+			ptr++;
+		else
+		   break;
+	}
+
+	len = strlen(ptr);	  
+	memset(dest, 0x00, destsize);
+	strncpy(dest, ptr, len >= destsize ?  destsize: len);
+
+	kfree(temp_buf1);
+   	kfree(temp_buf2);
+	return TRUE;
+}
+
+static void rtmp_read_key_parms_from_file(IN  PRTMP_ADAPTER pAd, char *tmpbuf, char *buffer)
+{
+	char		tok_str[16];					
+	INT			idx;
+	ULONG		KeyType;
+	ULONG		KeyLen;
+	ULONG		KeyIdx;
+	UCHAR		CipherAlg = CIPHER_WEP64;
+
+	//DefaultKeyID
+	if(RTMPGetKeyParameter("DefaultKeyID", tmpbuf, 25, buffer))
+	{
+		KeyIdx = simple_strtol(tmpbuf, 0, 10);
+		if((KeyIdx >= 1 ) && (KeyIdx <= 4))
+			pAd->PortCfg.DefaultKeyId = (UCHAR) (KeyIdx - 1 );
+		else
+			pAd->PortCfg.DefaultKeyId = 0;
+
+		DBGPRINT(RT_DEBUG_TRACE, "  DefaultKeyID(0~3)=%d\n", pAd->PortCfg.DefaultKeyId);
+	}	   
+
+	for (idx=0; idx<4; idx++) 
+	{
+	
+		sprintf(tok_str, "Key%dType", idx+1);
+		//Key%dType
+		if(RTMPGetKeyParameter(tok_str, tmpbuf, 32, buffer))
+		{		   
+			KeyType = simple_strtol(tmpbuf, 0, 10);
+
+			sprintf(tok_str, "Key%dStr", idx+1);
+			//Key%dStr
+			if(RTMPGetKeyParameter(tok_str, tmpbuf, 128, buffer))
+			{
+				KeyLen = strlen(tmpbuf);
+				if(KeyType == 0)
+				{//Hex type
+					if( (KeyLen == 10) || (KeyLen == 26))
+					{
+						pAd->SharedKey[idx].KeyLen = KeyLen / 2;
+						AtoH(tmpbuf, pAd->SharedKey[idx].Key, KeyLen / 2);
+						if (KeyLen == 10)
+							CipherAlg = CIPHER_WEP64;
+						else
+							CipherAlg = CIPHER_WEP128;
+						pAd->SharedKey[idx].CipherAlg = CipherAlg;
+
+						DBGPRINT(RT_DEBUG_TRACE, "  Key%dStr=%s and type=%s\n", idx+1, tmpbuf, (KeyType==0) ? "Hex":"Ascii");
+					}
+					else
+					{ //Invalid key length
+						DBGPRINT(RT_DEBUG_ERROR, "  Key%dStr is Invalid key length!\n", idx+1);
+					}								
+				}
+				else
+				{//Ascii								
+					if( (KeyLen == 5) || (KeyLen == 13))
+					{
+						pAd->SharedKey[idx].KeyLen = KeyLen;
+						NdisMoveMemory(pAd->SharedKey[idx].Key, tmpbuf, KeyLen);
+						if (KeyLen == 5)
+							CipherAlg = CIPHER_WEP64;
+						else
+							CipherAlg = CIPHER_WEP128;
+						pAd->SharedKey[idx].CipherAlg = CipherAlg;
+					
+						DBGPRINT(RT_DEBUG_TRACE, "  Key%dStr=%s and type=%s\n", idx+1, tmpbuf, (KeyType==0) ? "Hex":"Ascii");		
+					}
+					else
+					{ //Invalid key length
+						DBGPRINT(RT_DEBUG_ERROR, "  Key%dStr is Invalid key length!\n", idx+1);
+					}
+				}
+			}        
+		}
+	}
+}
+
+/*
+	========================================================================
+
+	Routine Description:
+		In kernel mode read parameters from file
+
+	Arguments:
+		src 					the location of the file.
+		dest						put the parameters to the destination.
+		Length					size to read.
+
+	Return Value:
+		None
+
+	Note:
+
+	========================================================================
+*/
+VOID RTMPReadParametersFromFile(
+	IN	PRTMP_ADAPTER pAd)
+{
+	NDIS_STATUS								Status = NDIS_STATUS_SUCCESS;
+	PUCHAR									src;
+	struct file 							*srcf;
+	INT 									retval, orgfsuid, orgfsgid;
+	mm_segment_t							orgfs;
+	UCHAR									*buffer, *mpool;
+	CHAR									*tmpbuf; //[640];
+	UCHAR									keyMaterial[40];
+	UCHAR									Channel;
+	ULONG									ulInfo;
+	UCHAR									ucInfo;
+	RT_802_11_PREAMBLE						Preamble;
+
+	
+	src = PROFILE_PATH;
+
+	// Save uid and gid used for filesystem access.
+	// Set user and group to 0 (root)	
+	orgfsuid = current->fsuid;
+	orgfsgid = current->fsgid;
+	current->fsuid=current->fsgid = 0;
+	orgfs = get_fs();
+	set_fs(KERNEL_DS);
+
+	// allocate memory
+	mpool = kmalloc(sizeof(CHAR)*(2*MAX_INI_BUFFER_SIZE+10), MEM_ALLOC_FLAG);  
+	if (mpool == NULL)	
+	{
+		DBGPRINT(RT_DEBUG_ERROR, "Not enough memory\n");
+		goto done;
+	}
+	
+			   
+	if (src && *src)
+	{
+		srcf = filp_open(src, O_RDONLY, 0);
+		if (IS_ERR(srcf))
+		{
+			Status = NDIS_STATUS_FAILURE;
+			DBGPRINT(RT_DEBUG_TRACE, "--> Error %ld opening %s\n", -PTR_ERR(srcf),src);
+		}		
+		else
+		{		 
+			pAd->PortCfg.bGetAPConfig = FALSE;
+			/* The object must have a read method */
+			if (srcf->f_op && srcf->f_op->read) 
+			{		   
+				buffer = (UCHAR *) (((unsigned long)(mpool+3)) & ((unsigned long)~(0x03)));
+				tmpbuf = (UCHAR *) (((unsigned long)(mpool+ MAX_INI_BUFFER_SIZE +3)) & ((unsigned long)~(0x03)));  
+				memset(buffer, 0x00, MAX_INI_BUFFER_SIZE);
+				memset(tmpbuf, 0x00, MAX_INI_BUFFER_SIZE);		
+				retval=srcf->f_op->read(srcf, buffer, MAX_INI_BUFFER_SIZE, &srcf->f_pos);
+				if (retval < 0)
+				{
+					Status = NDIS_STATUS_FAILURE;
+					DBGPRINT(RT_DEBUG_TRACE, "--> Read %s error %d\n", src, -retval);
+				}				 
+				else
+				{					
+					// set file parameter to portcfg
+					//CountryRegion
+					if (RTMPGetKeyParameter("CountryRegion", tmpbuf, 255, buffer))
+					{
+						ucInfo = (UCHAR) simple_strtol(tmpbuf, 0, 10);
+						if (ucInfo <= REGION_MAXIMUM_BG_BAND)
+							pAd->PortCfg.CountryRegion = ucInfo; 
+						else
+						{	
+							ucInfo = 0; // default
+							pAd->PortCfg.CountryRegion = ucInfo;	
+						}
+						DBGPRINT(RT_DEBUG_TRACE, "%s::(CountryRegion=%d)\n", __FUNCTION__, pAd->PortCfg.CountryRegion);
+					} 
+					//CountryRegionABand
+					if(RTMPGetKeyParameter("CountryRegionABand", tmpbuf, 25, buffer))
+					{
+						ucInfo = (UCHAR) simple_strtol(tmpbuf, 0, 10);
+						if (ucInfo <= REGION_MAXIMUM_A_BAND)
+							pAd->PortCfg.CountryRegionForABand = ucInfo;
+						else
+						{
+							ucInfo = 7; // default
+							pAd->PortCfg.CountryRegionForABand = ucInfo;
+						}
+						DBGPRINT(RT_DEBUG_TRACE, "%s::(CountryRegionABand=%d)\n", __FUNCTION__, pAd->PortCfg.CountryRegionForABand);
+					}					
+					//SSID
+					memset(tmpbuf, 0x00, 255);
+					if (RTMPGetKeyParameter("SSID", tmpbuf, 64, buffer))
+					{
+						if (strlen(tmpbuf) <= 32)
+						{
+							pAd->PortCfg.SsidLen = (UCHAR) strlen(tmpbuf);
+							memcpy(pAd->PortCfg.Ssid, tmpbuf, pAd->PortCfg.SsidLen);
+
+							pAd->MlmeAux.AutoReconnectSsidLen = pAd->PortCfg.SsidLen;
+							memcpy(pAd->MlmeAux.AutoReconnectSsid, tmpbuf, pAd->MlmeAux.AutoReconnectSsidLen);
+							pAd->MlmeAux.SsidLen = pAd->PortCfg.SsidLen;
+							memcpy(pAd->MlmeAux.Ssid, tmpbuf, pAd->MlmeAux.SsidLen);
+
+							DBGPRINT(RT_DEBUG_TRACE, "%s::(SSID=%s)\n", __FUNCTION__, tmpbuf);
+
+						}
+					}					
+					//NetworkType
+					if (RTMPGetKeyParameter("NetworkType", tmpbuf, 25, buffer))
+					{
+						pAd->bConfigChanged = TRUE;
+						if (strcmp(tmpbuf, "Adhoc") == 0)
+							pAd->PortCfg.BssType = BSS_ADHOC;
+						else //Default Infrastructure mode
+							pAd->PortCfg.BssType = BSS_INFRA;
+						// Reset Ralink supplicant to not use, it will be set to start when UI set PMK key
+						//pAd->PortCfg.WpaState = SS_NOTUSE;
+						DBGPRINT(RT_DEBUG_TRACE, "%s::(NetworkType=%d)\n", __FUNCTION__, pAd->PortCfg.BssType);
+					}					 
+					//WirelessMode
+					if (RTMPGetKeyParameter("WirelessMode", tmpbuf, 10, buffer))
+					{	
+						ulInfo = (ULONG)simple_strtol(tmpbuf, 0, 10);
+					   
+						if ((ulInfo == PHY_11BG_MIXED) || (ulInfo == PHY_11B) ||
+							(ulInfo == PHY_11A) || (ulInfo == PHY_11ABG_MIXED) ||
+							(ulInfo == PHY_11G))
+						{
+							pAd->PortCfg.PhyMode = 0xff;
+							RTMPSetPhyMode(pAd, ulInfo);
+						 
+							DBGPRINT(RT_DEBUG_TRACE, "%s::(WirelessMode=%d)\n", __FUNCTION__, ulInfo);
+						}
+					}										 
+					//TxRate
+#if 0
+/* Sven-Ola: Seems to be removed in cvs driver */
+					if (RTMPGetKeyParameter("TxRate", tmpbuf, 10, buffer))
+					{
+						ulInfo = (ULONG)simple_strtol(tmpbuf, 0, 10);
+
+						if ((pAd->PortCfg.PhyMode == PHY_11B && ulInfo <= 4) ||\
+							((pAd->PortCfg.PhyMode == PHY_11BG_MIXED || pAd->PortCfg.PhyMode == PHY_11ABG_MIXED) && ulInfo <= 12) ||\
+							((pAd->PortCfg.PhyMode == PHY_11A || pAd->PortCfg.PhyMode == PHY_11G) && (ulInfo == 0 ||(ulInfo > 4 && ulInfo <= 12))))
+						{
+							if (ulInfo == 0)
+								RTMPSetDesiredRates(pAd, -1);
+							else
+								RTMPSetDesiredRates(pAd, (LONG) (RateIdToMbps[ulInfo-1] * 1000000));
+						}
+						else
+						{
+							ulInfo = 0; // default, TxRate=Auto
+							RTMPSetDesiredRates(pAd, -1);
+						}
+						pAd->PortCfg.DefaultMaxDesiredRate = (UCHAR)ulInfo;
+						DBGPRINT(RT_DEBUG_TRACE, "%s::(TxRate=%d)\n", __FUNCTION__, ulInfo);
+					}					 
+#endif
+					//Channel
+					if (RTMPGetKeyParameter("Channel", tmpbuf, 10, buffer))
+					{
+						Channel = (UCHAR) simple_strtol(tmpbuf, 0, 10);
+						pAd->PortCfg.AdhocChannel = Channel;
+						if (ChannelSanity(pAd, Channel) == TRUE)
+						{
+							pAd->PortCfg.Channel = Channel;
+							
+							DBGPRINT(RT_DEBUG_TRACE, "%s::(Channel=%d)\n", __FUNCTION__, Channel);
+						}
+					}					
+					//BGProtection
+					if (RTMPGetKeyParameter("BGProtection", tmpbuf, 10, buffer))
+					{
+						switch (simple_strtol(tmpbuf, 0, 10))
+						{
+							case 1: //Always On
+								pAd->PortCfg.UseBGProtection = 1;
+								break;
+							case 2: //Always OFF
+								pAd->PortCfg.UseBGProtection = 2;
+								break;
+							case 0: //AUTO
+							default:
+								pAd->PortCfg.UseBGProtection = 0;
+								break;
+						}
+						DBGPRINT(RT_DEBUG_TRACE, "%s::(BGProtection=%d)\n", __FUNCTION__, pAd->PortCfg.UseBGProtection);
+					}				   
+					//TxPreamble
+					if (RTMPGetKeyParameter("TxPreamble", tmpbuf, 10, buffer))
+					{
+						Preamble = simple_strtol(tmpbuf, 0, 10);
+						switch (Preamble)
+						{
+							case Rt802_11PreambleShort:
+								pAd->PortCfg.TxPreamble = Preamble;
+								MlmeSetTxPreamble(pAd, Rt802_11PreambleShort);
+								break;
+							case Rt802_11PreambleLong:
+							case Rt802_11PreambleAuto:
+							default:
+								// if user wants AUTO, initialize to LONG here, then change according to AP's
+								// capability upon association.
+								pAd->PortCfg.TxPreamble = Preamble;
+								MlmeSetTxPreamble(pAd, Rt802_11PreambleLong);
+						}
+						DBGPRINT(RT_DEBUG_TRACE, "%s::(TxPreamble=%d)\n", __FUNCTION__, Preamble);
+					}
+					//RTSThreshold
+					if (RTMPGetKeyParameter("RTSThreshold", tmpbuf, 10, buffer))
+					{
+						ulInfo = simple_strtol(tmpbuf, 0, 10);
+
+						if((ulInfo > 0) && (ulInfo <= MAX_RTS_THRESHOLD))
+							pAd->PortCfg.RtsThreshold = (USHORT)ulInfo;
+						else 
+							pAd->PortCfg.RtsThreshold = MAX_RTS_THRESHOLD;
+
+						DBGPRINT(RT_DEBUG_TRACE, "%s::(RTSThreshold=%d)\n", __FUNCTION__, pAd->PortCfg.RtsThreshold);
+					}
+					//FragThreshold
+					if (RTMPGetKeyParameter("FragThreshold", tmpbuf, 10, buffer))
+					{
+						ulInfo = simple_strtol(tmpbuf, 0, 10);
+
+						if ( (ulInfo >= MIN_FRAG_THRESHOLD) && (ulInfo <= MAX_FRAG_THRESHOLD))
+							pAd->PortCfg.FragmentThreshold = (USHORT)ulInfo;
+						else
+							pAd->PortCfg.FragmentThreshold = MAX_FRAG_THRESHOLD;
+
+						if (pAd->PortCfg.FragmentThreshold == MAX_FRAG_THRESHOLD)
+							pAd->PortCfg.bFragmentZeroDisable = TRUE;
+						else
+							pAd->PortCfg.bFragmentZeroDisable = FALSE;
+
+						DBGPRINT(RT_DEBUG_TRACE, "%s::(FragThreshold=%d)\n", __FUNCTION__, ulInfo);
+					}				   
+					//TxBurst
+					if (RTMPGetKeyParameter("TxBurst", tmpbuf, 10, buffer))
+					{
+						ulInfo = simple_strtol(tmpbuf, 0, 10);
+
+						if (ulInfo == 1)
+							pAd->PortCfg.bEnableTxBurst = TRUE;
+						else
+							pAd->PortCfg.bEnableTxBurst = FALSE;
+
+						DBGPRINT(RT_DEBUG_TRACE, "%s::(TxBurst=%d)\n", __FUNCTION__, pAd->PortCfg.bEnableTxBurst);
+					} 
+					
+#ifdef AGGREGATION_SUPPORT
+					//PktAggregate
+					if(RTMPGetKeyParameter("PktAggregate", tmpbuf, 10, buffer))
+					{
+						if(simple_strtol(tmpbuf, 0, 10) != 0)  //Enable
+							pAd->PortCfg.bAggregationCapable = TRUE;
+						else //Disable
+							pAd->PortCfg.bAggregationCapable = FALSE;
+
+						DBGPRINT(RT_DEBUG_TRACE, "%s::(PktAggregate=%d)\n", __FUNCTION__, pAd->PortCfg.bAggregationCapable);
+					}
+#else
+					pAd->PortCfg.bAggregationCapable = FALSE;
+#endif /* !AGGREGATION_SUPPORT */
+
+					//TurboRate
+					if (RTMPGetKeyParameter("TurboRate", tmpbuf, 10, buffer))
+					{
+						ulInfo = simple_strtol(tmpbuf, 0, 10);
+
+						if (ulInfo == 1)
+							pAd->PortCfg.EnableTurboRate = TRUE;
+						else
+							pAd->PortCfg.EnableTurboRate = FALSE;
+
+						DBGPRINT(RT_DEBUG_TRACE, "%s::(TurboRate=%d)\n", __FUNCTION__, pAd->PortCfg.EnableTurboRate);
+					}
+					
+#if 0 
+					//WmmCapable
+					if(RTMPGetKeyParameter("WmmCapable", tmpbuf, 32, buffer))
+					{
+						if(simple_strtol(tmpbuf, 0, 10) != 0)  //Enable
+							pAd->PortCfg.bWmmCapable = TRUE;
+						else //Disable
+							pAd->PortCfg.bWmmCapable = FALSE;
+							
+						DBGPRINT(RT_DEBUG_TRACE, "%s::(WmmCapable=%d)\n", __FUNCTION__, pAd->PortCfg.bWmmCapable); 
+					}
+					//AckPolicy for AC_BK, AC_BE, AC_VI, AC_VO
+					if(RTMPGetKeyParameter("AckPolicy", tmpbuf, 32, buffer))
+					{
+						INT 	i;
+						PUCHAR	macptr;
+						
+					    for (i = 0, macptr = rstrtok(tmpbuf,";"); macptr; macptr = rstrtok(NULL,";"), i++)
+					    {
+				            pAd->PortCfg.AckPolicy[i] = (UCHAR)simple_strtol(macptr, 0, 10);
+
+				            DBGPRINT(RT_DEBUG_TRACE, "%s::(AckPolicy[%d]=%d)\n", __FUNCTION__, i, pAd->PortCfg.AckPolicy[i]);
+					    }
+					}				
+#else	 
+					pAd->PortCfg.bWmmCapable = FALSE;
+#endif
+
+					//IEEE80211H
+					if(RTMPGetKeyParameter("IEEE80211H", tmpbuf, 10, buffer))
+					{
+						if(simple_strtol(tmpbuf, 0, 10) != 0)  //Enable
+							pAd->PortCfg.bIEEE80211H = TRUE;
+						else //Disable
+							pAd->PortCfg.bIEEE80211H = FALSE;
+
+						DBGPRINT(RT_DEBUG_TRACE, "%s::(IEEE80211H=%d)\n", __FUNCTION__, pAd->PortCfg.bIEEE80211H);
+					}
+					//POWER_MODE
+					if (RTMPGetKeyParameter("PSMode", tmpbuf, 10, buffer))
+					{
+						if (pAd->PortCfg.BssType == BSS_INFRA)
+						{
+							if ((strcmp(tmpbuf, "MAX_PSP") == 0) || (strcmp(tmpbuf, "max_psp") == 0))
+							{
+								// do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
+								// to exclude certain situations.
+								//	   MlmeSetPsmBit(pAd, PWR_SAVE);
+								if (pAd->PortCfg.bWindowsACCAMEnable == FALSE)
+									pAd->PortCfg.WindowsPowerMode = Ndis802_11PowerModeMAX_PSP;
+								pAd->PortCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeMAX_PSP;
+								OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
+								pAd->PortCfg.DefaultListenCount = 5;
+							}
+							else if ((strcmp(tmpbuf, "Fast_PSP") == 0) || (strcmp(tmpbuf, "fast_psp") == 0) 
+								|| (strcmp(tmpbuf, "FAST_PSP") == 0))
+							{
+								// do NOT turn on PSM bit here, wait until MlmeCheckForPsmChange()
+								// to exclude certain situations.
+								//	   MlmeSetPsmBit(pAd, PWR_SAVE);
+								OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
+								if (pAd->PortCfg.bWindowsACCAMEnable == FALSE)
+									pAd->PortCfg.WindowsPowerMode = Ndis802_11PowerModeFast_PSP;
+								pAd->PortCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeFast_PSP;
+								pAd->PortCfg.DefaultListenCount = 3;
+							}
+							else
+							{ //Default Ndis802_11PowerModeCAM
+								// clear PSM bit immediately
+								MlmeSetPsmBit(pAd, PWR_ACTIVE);
+								OPSTATUS_SET_FLAG(pAd, fOP_STATUS_RECEIVE_DTIM);
+								if (pAd->PortCfg.bWindowsACCAMEnable == FALSE)
+									pAd->PortCfg.WindowsPowerMode = Ndis802_11PowerModeCAM;
+								pAd->PortCfg.WindowsBatteryPowerMode = Ndis802_11PowerModeCAM;
+							}
+							DBGPRINT(RT_DEBUG_TRACE, "%s::(PSMode=%d)\n", __FUNCTION__, pAd->PortCfg.WindowsPowerMode);
+						}
+					}
+					//AdhocOfdm
+					if (RTMPGetKeyParameter("AdhocOfdm", tmpbuf, 32, buffer))
+					{
+					    ulInfo = simple_strtol(tmpbuf, 0, 10);
+
+					    if (ulInfo <= ADHOC_11ABG_MIXED)
+					        pAd->PortCfg.AdhocMode = ulInfo;
+                        else
+                            pAd->PortCfg.AdhocMode = 0;
+
+                        DBGPRINT(RT_DEBUG_TRACE, "%s::(AdhocOfdm=%d)\n", __FUNCTION__, pAd->PortCfg.AdhocMode);
+					}
+			        // FastRoaming
+					if (RTMPGetKeyParameter("FastRoaming", tmpbuf, 32, buffer))
+					{
+                   	    ulInfo = simple_strtol(tmpbuf, 0, 10);
+
+					    if (ulInfo == 1)
+					        pAd->PortCfg.bFastRoaming = TRUE;
+                        else
+                            pAd->PortCfg.bFastRoaming = FALSE;
+
+                        DBGPRINT(RT_DEBUG_TRACE, "%s::(FastRoaming=%d)\n", __FUNCTION__, pAd->PortCfg.bFastRoaming);
+					}
+					// RoamThreshold
+					if (RTMPGetKeyParameter("RoamThreshold", tmpbuf, 32, buffer))
+					{
+                        ulInfo = simple_strtol(tmpbuf, 0, 10);
+                            
+                        if (ulInfo > 90 || ulInfo < 60)
+                            pAd->PortCfg.dBmToRoam = 70;
+                        else    
+                            pAd->PortCfg.dBmToRoam = ulInfo;
+
+                        DBGPRINT(RT_DEBUG_TRACE, "%s::(RoamThreshold=%d)\n", __FUNCTION__, (-1)*(pAd->PortCfg.dBmToRoam));
+					}    
+					//AuthMode
+					if (RTMPGetKeyParameter("AuthMode", tmpbuf, 32, buffer))
+					{ 
+						if ((strcmp(tmpbuf, "WEPAUTO") == 0) || (strcmp(tmpbuf, "wepauto") == 0))
+							pAd->PortCfg.AuthMode = Ndis802_11AuthModeAutoSwitch;
+						else if ((strcmp(tmpbuf, "SHARED") == 0) || (strcmp(tmpbuf, "shared") == 0))
+							pAd->PortCfg.AuthMode = Ndis802_11AuthModeShared;
+						else if ((strcmp(tmpbuf, "WPAPSK") == 0) || (strcmp(tmpbuf, "wpapsk") == 0))
+							pAd->PortCfg.AuthMode = Ndis802_11AuthModeWPAPSK;
+						else if ((strcmp(tmpbuf, "WPANONE") == 0) || (strcmp(tmpbuf, "wpanone") == 0))
+							pAd->PortCfg.AuthMode = Ndis802_11AuthModeWPANone;
+						else if ((strcmp(tmpbuf, "WPA2PSK") == 0) || (strcmp(tmpbuf, "wpa2psk") == 0))
+							pAd->PortCfg.AuthMode = Ndis802_11AuthModeWPA2PSK;		
+#if WPA_SUPPLICANT_SUPPORT
+                        else if ((strcmp(tmpbuf, "WPA") == 0) || (strcmp(tmpbuf, "wpa") == 0))
+                            pAd->PortCfg.AuthMode = Ndis802_11AuthModeWPA;  
+                        else if ((strcmp(tmpbuf, "WPA2") == 0) || (strcmp(tmpbuf, "wpa2") == 0))
+                            pAd->PortCfg.AuthMode = Ndis802_11AuthModeWPA2;
+#endif
+						else
+							pAd->PortCfg.AuthMode = Ndis802_11AuthModeOpen;
+
+						pAd->PortCfg.PortSecured = WPA_802_1X_PORT_NOT_SECURED;
+						DBGPRINT(RT_DEBUG_TRACE, "%s::(AuthMode=%d)\n", __FUNCTION__, pAd->PortCfg.AuthMode);
+					}
+					//EncrypType
+					if (RTMPGetKeyParameter("EncrypType", tmpbuf, 32, buffer))
+					{
+						if ((strcmp(tmpbuf, "WEP") == 0) || (strcmp(tmpbuf, "wep") == 0))
+						{
+							pAd->PortCfg.WepStatus	 = Ndis802_11WEPEnabled;
+							pAd->PortCfg.PairCipher  = Ndis802_11WEPEnabled;
+							pAd->PortCfg.GroupCipher = Ndis802_11WEPEnabled;
+						}
+						else if ((strcmp(tmpbuf, "TKIP") == 0) || (strcmp(tmpbuf, "tkip") == 0))
+						{
+							pAd->PortCfg.WepStatus	 = Ndis802_11Encryption2Enabled;
+							pAd->PortCfg.PairCipher  = Ndis802_11Encryption2Enabled;
+							pAd->PortCfg.GroupCipher = Ndis802_11Encryption2Enabled;
+						}
+						else if ((strcmp(tmpbuf, "AES") == 0) || (strcmp(tmpbuf, "aes") == 0))
+						{
+							pAd->PortCfg.WepStatus	 = Ndis802_11Encryption3Enabled;
+							pAd->PortCfg.PairCipher  = Ndis802_11Encryption3Enabled;
+							pAd->PortCfg.GroupCipher = Ndis802_11Encryption3Enabled;   
+						}	 
+						else
+						{
+							pAd->PortCfg.WepStatus	 = Ndis802_11WEPDisabled;
+							pAd->PortCfg.PairCipher  = Ndis802_11WEPDisabled;
+							pAd->PortCfg.GroupCipher = Ndis802_11WEPDisabled;
+						}
+						RTMPMakeRSNIE(pAd, pAd->PortCfg.GroupCipher);
+						DBGPRINT(RT_DEBUG_TRACE, "%s::(EncrypType=%d)\n", __FUNCTION__, pAd->PortCfg.WepStatus);
+					}	  
+					//WPAPSK_KEY
+					if (RTMPGetKeyParameter("WPAPSK", tmpbuf, 255, buffer))
+					{
+						int 	err=0;
+
+                        // the end of this string
+                        tmpbuf[strlen(tmpbuf)]='\0';
+                        
+						if ((pAd->PortCfg.AuthMode != Ndis802_11AuthModeWPAPSK) &&\
+							(pAd->PortCfg.AuthMode != Ndis802_11AuthModeWPA2PSK) &&\
+							(pAd->PortCfg.AuthMode != Ndis802_11AuthModeWPANone) )
+						{
+							err = 1;
+						}
+						else if ((strlen(tmpbuf) >= 8) && (strlen(tmpbuf) < 64))
+						{
+							PasswordHash((char *)tmpbuf, pAd->PortCfg.Ssid, pAd->PortCfg.SsidLen, keyMaterial);
+							NdisMoveMemory(pAd->PortCfg.PskKey.Key, keyMaterial, 32);
+							
+						}
+						else if (strlen(tmpbuf) == 64)
+						{							 
+							AtoH(tmpbuf, keyMaterial, 32);
+							NdisMoveMemory(pAd->PortCfg.PskKey.Key, keyMaterial, 32);
+						}
+						else
+						{	
+							err = 1;
+							DBGPRINT(RT_DEBUG_ERROR, "%s::(WPAPSK key-string required 8 ~ 64 characters!)\n", __FUNCTION__);
+						}
+						
+						if (err == 0)
+						{  
+							RTMPMakeRSNIE(pAd, pAd->PortCfg.GroupCipher);
+							
+							if ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPAPSK) ||\
+								(pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPA2PSK))
+							{
+								// Use RaConfig as PSK agent.
+								// Start STA supplicant state machine
+								pAd->PortCfg.WpaState = SS_START;
+							}
+							else if (pAd->PortCfg.AuthMode == Ndis802_11AuthModeWPANone)
+							{							 
+								// Set wpapsk key later
+								// set the flag 
+								pAd->PortCfg.WpaState = SS_START;
+							}
+							DBGPRINT(RT_DEBUG_TRACE, "%s::(WPAPSK=%s)\n", __FUNCTION__, tmpbuf);
+						}	  
+					}
+                    //DefaultKeyID, KeyType, KeyStr
+                    DBGPRINT(RT_DEBUG_TRACE, "%s::(DefaultKeyID, KeyType, KeyStr !!!!!!!!!)\n", __FUNCTION__);
+					rtmp_read_key_parms_from_file(pAd, tmpbuf, buffer);
+
+                    //
+					// Set wep keys into ASIC
+                    //
+					if ((pAd->PortCfg.WepStatus == Ndis802_11WEPEnabled) &&\
+					    ((pAd->PortCfg.AuthMode == Ndis802_11AuthModeOpen) ||\
+					     (pAd->PortCfg.AuthMode == Ndis802_11AuthModeShared) ||\
+					     (pAd->PortCfg.AuthMode == Ndis802_11AuthModeAutoSwitch)))
+					{	
+                        int idx;
+#if WPA_SUPPLICANT_SUPPORT
+		                int KeyIdx = pAd->PortCfg.DefaultKeyId;
+
+					    // Record the user desired wep setting
+				        pAd->PortCfg.DesireSharedKey[KeyIdx].KeyLen = pAd->SharedKey[KeyIdx].KeyLen;
+					    NdisMoveMemory(pAd->PortCfg.DesireSharedKey[KeyIdx].Key, pAd->SharedKey[KeyIdx].Key, pAd->SharedKey[KeyIdx].KeyLen);						                        
+					    pAd->PortCfg.DesireSharedKey[KeyIdx].CipherAlg = pAd->SharedKey[KeyIdx].CipherAlg;												
+#endif						
+
+                        for (idx=0; idx<4; idx++)
+                        {
+						    if (pAd->SharedKey[idx].KeyLen > 0)
+							    AsicAddSharedKeyEntry(pAd, 
+												    0, 
+												    idx, 
+												    pAd->SharedKey[idx].CipherAlg, 
+												    pAd->SharedKey[idx].Key, 
+												    NULL,
+												    NULL);
+	                    }											    						    
+					}
+					
+				}   /* end of reading parameters */
+			}
+			else
+			{
+				Status = NDIS_STATUS_FAILURE;
+				DBGPRINT(RT_DEBUG_TRACE, "--> %s does not have a write method\n", src);
+			}
+
+			retval=filp_close(srcf,NULL);
+			if (retval)
+			{
+				Status = NDIS_STATUS_FAILURE;
+				DBGPRINT(RT_DEBUG_TRACE, "--> Error %d closing %s\n", -retval, src);
+			}	 
+		} // else (IS_ERR(srcf))	  
+	} //if (src && *src)
+
+  
+done:
+	// Error handling
+	if (mpool != NULL)
+		kfree(mpool);
+	
+	set_fs(orgfs);
+	current->fsuid = orgfsuid;
+	current->fsgid = orgfsgid;
+
+}
+
 #ifndef BIG_ENDIAN
 /*
 	========================================================================
diff -Nur rt73-cvs-2007071510.orig/Module/rtmp_main.c rt73-cvs-2007071510/Module/rtmp_main.c
--- rt73-cvs-2007071510.orig/Module/rtmp_main.c	2007-07-06 21:20:49.000000000 +0200
+++ rt73-cvs-2007071510/Module/rtmp_main.c	2007-07-16 20:10:26.000000000 +0200
@@ -1510,6 +1510,8 @@
 	// Initialize Asics
 	NICInitializeAsic(pAd);
 
+	RTMPReadParametersFromFile(pAd);
+
 	//
 	// Read additional info from NIC such as MAC address
 	// This function must called after register CSR base address
@@ -1843,7 +1845,7 @@
 
 		for (i = 0; i < 8; i++)
 		{
-			sprintf(slot_name, "wlan%d", i);
+			sprintf(slot_name, "rausb%d", i);
 
 			read_lock_bh(&dev_base_lock); // avoid multiple init
 			for (device = first_net_device(); device != NULL;
@@ -1864,7 +1866,7 @@
 			goto out;
 		}
 
-		sprintf(netdev->name, "wlan%d", i);
+		sprintf(netdev->name, "rausb%d", i);
 		DBGPRINT(RT_DEBUG_ERROR, "usb device name %s\n",netdev->name);
 
         /* get Max Packet Size from usb_dev endpoint */
@@ -1888,6 +1890,13 @@
 		goto out;
 	}
 
+	// Load 8051 firmware
+	res = NICLoadFirmware(pAd);
+	if(res != NDIS_STATUS_SUCCESS)
+	{
+		goto out;
+	}
+
 	return pAd;
 
 out:
@@ -2178,7 +2187,7 @@
 
 		for (i = 0; i < 8; i++)
 		{
-			sprintf(slot_name, "wlan%d", i);
+			sprintf(slot_name, "rausb%d", i);
 
 #if 1
 			if(dev_get_by_name(slot_name)==NULL)
@@ -2204,7 +2213,7 @@
 			return res;
 		}
 
-		sprintf(pAd->net_dev->name, "wlan%d", i);
+		sprintf(pAd->net_dev->name, "rausb%d", i);
 		DBGPRINT(RT_DEBUG_ERROR, "usb device name %s\n", pAd->net_dev->name);
 
 
@@ -2235,11 +2244,13 @@
 
 
 	rt73usb_open_debugfs(pAd);
-	res = LoadFirmware(pAd, firmName);
-	if (res) {
-		DBGPRINT(RT_DEBUG_ERROR, "Failed to request Firmware.\n");
+	// Load 8051 firmware
+	res = NICLoadFirmware(pAd);
+	if(res != NDIS_STATUS_SUCCESS)
+	{
 		goto out;
 	}
+
 	return 0;
 
 out:
