2 * Copyright (c) 2004-2010 Atheros Communications Inc.
5 * This file implements the Atheros PS and patch parser.
6 * It implements APIs to parse data buffer with patch and PS information and convert it to HCI commands.
14 * The software source and binaries included in this development package are
15 * licensed, not sold. You, or your company, received the package under one
16 * or more license agreements. The rights granted to you are specifically
17 * listed in these license agreement(s). All other rights remain with Atheros
18 * Communications, Inc., its subsidiaries, or the respective owner including
19 * those listed on the included copyright notices.. Distribution of any
20 * portion of this package must be in strict compliance with the license
28 #include "ar3kpsparser.h"
30 #include <linux/ctype.h>
31 #include <linux/kernel.h>
33 #define BD_ADDR_SIZE 6
35 #define ENABLE_PATCH 11
38 #define PS_VERIFY_CRC 9
39 #define CHANGE_BDADDR 15
41 #define HCI_COMMAND_HEADER 7
43 #define HCI_EVENT_SIZE 7
45 #define WRITE_PATCH_COMMAND_STATUS_OFFSET 5
47 #define PS_RAM_SIZE 2048
49 #define RAM_PS_REGION (1<<0)
50 #define RAM_PATCH_REGION (1<<1)
51 #define RAMPS_MAX_PS_DATA_PER_TAG 20000
52 #define MAX_RADIO_CFG_TABLE_SIZE 244
53 #define RAMPS_MAX_PS_TAGS_PER_FILE 50
55 #define PS_MAX_LEN 500
56 #define LINE_SIZE_MAX (PS_MAX_LEN *2)
58 /* Constant values used by parser */
59 #define BYTES_OF_PS_DATA_PER_LINE 16
60 #define RAMPS_MAX_PS_DATA_PER_TAG 20000
63 /* Number pf PS/Patch entries in an HCI packet */
64 #define MAX_BYTE_LENGTH 244
66 #define SKIP_BLANKS(str) while (*str == ' ') str++
68 enum MinBootFileFormatE
70 MB_FILEFORMAT_RADIOTBL
,
72 MB_FILEFORMAT_COEXCONFIG
88 typedef struct tPsTagEntry
93 } tPsTagEntry
, *tpPsTagEntry
;
95 typedef struct tRamPatch
99 } tRamPatch
, *ptRamPatch
;
103 typedef struct ST_PS_DATA_FORMAT
{
104 enum eType eDataType
;
108 typedef struct ST_READ_STATUS
{
117 /* Stores the number of PS Tags */
118 static u32 Tag_Count
= 0;
120 /* Stores the number of patch commands */
121 static u32 Patch_Count
= 0;
122 static u32 Total_tag_lenght
= 0;
126 tPsTagEntry PsTagEntry
[RAMPS_MAX_PS_TAGS_PER_FILE
];
127 tRamPatch RamPatch
[MAX_NUM_PATCH_ENTRY
];
130 int AthParseFilesUnified(A_UCHAR
*srcbuffer
,u32 srclen
, int FileFormat
);
131 char AthReadChar(A_UCHAR
*buffer
, u32 len
,u32
*pos
);
132 char *AthGetLine(char *buffer
, int maxlen
, A_UCHAR
*srcbuffer
,u32 len
,u32
*pos
);
133 static int AthPSCreateHCICommand(A_UCHAR Opcode
, u32 Param1
,PSCmdPacket
*PSPatchPacket
,u32
*index
);
135 /* Function to reads the next character from the input buffer */
136 char AthReadChar(A_UCHAR
*buffer
, u32 len
,u32
*pos
)
139 if(buffer
== NULL
|| *pos
>=len
)
148 /* PS parser helper function */
149 unsigned int uGetInputDataFormat(char *pCharLine
, ST_PS_DATA_FORMAT
*pstFormat
)
151 if(pCharLine
[0] != '[') {
152 pstFormat
->eDataType
= eHex
;
153 pstFormat
->bIsArray
= true;
156 switch(pCharLine
[1]) {
159 if(pCharLine
[2]==':') {
160 if((pCharLine
[3]== 'a') || (pCharLine
[3]== 'A')) {
161 if(pCharLine
[4] == ']') {
162 pstFormat
->eDataType
= eHex
;
163 pstFormat
->bIsArray
= true;
168 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Illegal Data format\n")); //[H:A
172 if((pCharLine
[3]== 'S') || (pCharLine
[3]== 's')) {
173 if(pCharLine
[4] == ']') {
174 pstFormat
->eDataType
= eHex
;
175 pstFormat
->bIsArray
= false;
180 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Illegal Data format\n")); //[H:A
184 else if(pCharLine
[3] == ']') { //[H:]
185 pstFormat
->eDataType
= eHex
;
186 pstFormat
->bIsArray
= true;
191 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Illegal Data format\n"));
195 else if(pCharLine
[2]==']') { //[H]
196 pstFormat
->eDataType
= eHex
;
197 pstFormat
->bIsArray
= true;
202 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Illegal Data format\n"));
209 if(pCharLine
[2]==':') {
210 if((pCharLine
[3]== 'h') || (pCharLine
[3]== 'H')) {
211 if(pCharLine
[4] == ']') {
212 pstFormat
->eDataType
= eHex
;
213 pstFormat
->bIsArray
= true;
218 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Illegal Data format 1\n")); //[A:H
222 else if(pCharLine
[3]== ']') { //[A:]
223 pstFormat
->eDataType
= eHex
;
224 pstFormat
->bIsArray
= true;
229 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Illegal Data format 2\n"));
233 else if(pCharLine
[2]==']') { //[H]
234 pstFormat
->eDataType
= eHex
;
235 pstFormat
->bIsArray
= true;
240 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Illegal Data format 3\n"));
247 if(pCharLine
[2]==':') {
248 if((pCharLine
[3]== 'h') || (pCharLine
[3]== 'H')) {
249 if(pCharLine
[4] == ']') {
250 pstFormat
->eDataType
= eHex
;
251 pstFormat
->bIsArray
= true;
256 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Illegal Data format 5\n")); //[A:H
260 else if(pCharLine
[3]== ']') { //[A:]
261 pstFormat
->eDataType
= eHex
;
262 pstFormat
->bIsArray
= true;
267 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Illegal Data format 6\n"));
271 else if(pCharLine
[2]==']') { //[H]
272 pstFormat
->eDataType
= eHex
;
273 pstFormat
->bIsArray
= true;
278 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Illegal Data format 7\n"));
284 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Illegal Data format 8\n"));
289 unsigned int uReadDataInSection(char *pCharLine
, ST_PS_DATA_FORMAT stPS_DataFormat
)
291 char *pTokenPtr
= pCharLine
;
293 if(pTokenPtr
[0] == '[') {
294 while(pTokenPtr
[0] != ']' && pTokenPtr
[0] != '\0') {
297 if(pTokenPtr
[0] == '\0') {
304 if(stPS_DataFormat
.eDataType
== eHex
) {
305 if(stPS_DataFormat
.bIsArray
== true) {
310 return (A_STRTOL(pTokenPtr
, NULL
, 16));
318 int AthParseFilesUnified(A_UCHAR
*srcbuffer
,u32 srclen
, int FileFormat
)
324 u8 ParseSection
=RAM_PS_SECTION
;
330 ST_PS_DATA_FORMAT stPS_DataFormat
;
331 ST_READ_STATUS stReadStatus
= {0, 0, 0,0};
335 if (srcbuffer
== NULL
|| srclen
== 0)
337 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
, ("Could not open .\n"));
342 Buffer
= A_MALLOC(LINE_SIZE_MAX
+ 1);
346 if (FileFormat
== MB_FILEFORMAT_PATCH
)
349 while((pCharLine
= AthGetLine(Buffer
, LINE_SIZE_MAX
, srcbuffer
,srclen
,&pos
)) != NULL
)
352 SKIP_BLANKS(pCharLine
);
354 // Comment line or empty line
355 if ((pCharLine
[0] == '/') && (pCharLine
[1] == '/'))
360 if ((pCharLine
[0] == '#')) {
361 if (stReadStatus
.uSection
!= 0)
363 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("error\n"));
370 stReadStatus
.uSection
= 1;
374 if ((pCharLine
[0] == '/') && (pCharLine
[1] == '*'))
377 SKIP_BLANKS(pCharLine
);
379 if(!strncmp(pCharLine
,"PA",2)||!strncmp(pCharLine
,"Pa",2)||!strncmp(pCharLine
,"pa",2))
380 ParseSection
=RAM_PATCH_SECTION
;
382 if(!strncmp(pCharLine
,"DY",2)||!strncmp(pCharLine
,"Dy",2)||!strncmp(pCharLine
,"dy",2))
383 ParseSection
=RAM_DYN_MEM_SECTION
;
385 if(!strncmp(pCharLine
,"PS",2)||!strncmp(pCharLine
,"Ps",2)||!strncmp(pCharLine
,"ps",2))
386 ParseSection
=RAM_PS_SECTION
;
389 stReadStatus
.uSection
= 0;
398 if (stReadStatus
.uSection
== 1) //TagID
400 SKIP_BLANKS(pCharLine
);
401 if(uGetInputDataFormat(pCharLine
, &stPS_DataFormat
)) {
402 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("uGetInputDataFormat fail\n"));
409 PsTagEntry
[TagCount
].TagId
= uReadDataInSection(pCharLine
, stPS_DataFormat
);
410 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,(" TAG ID %d \n",PsTagEntry
[TagCount
].TagId
));
412 //AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("tag # %x\n", PsTagEntry[TagCount].TagId);
415 StartTagId
= PsTagEntry
[TagCount
].TagId
;
417 stReadStatus
.uSection
= 2;
419 else if (stReadStatus
.uSection
== 2) //TagLength
422 if(uGetInputDataFormat(pCharLine
, &stPS_DataFormat
)) {
423 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("uGetInputDataFormat fail \n"));
430 ByteCount
= uReadDataInSection(pCharLine
, stPS_DataFormat
);
432 //AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("tag length %x\n", ByteCount));
433 if (ByteCount
> LINE_SIZE_MAX
/2)
440 PsTagEntry
[TagCount
].TagLen
= ByteCount
;
441 PsTagEntry
[TagCount
].TagData
= (u8
*)A_MALLOC(ByteCount
);
442 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,(" TAG Length %d Tag Index %d \n",PsTagEntry
[TagCount
].TagLen
,TagCount
));
443 stReadStatus
.uSection
= 3;
444 stReadStatus
.uLineCount
= 0;
446 else if( stReadStatus
.uSection
== 3) { //Data
448 if(stReadStatus
.uLineCount
== 0) {
449 if(uGetInputDataFormat(pCharLine
,&stPS_DataFormat
)) {
450 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("uGetInputDataFormat Fail\n"));
458 SKIP_BLANKS(pCharLine
);
459 stReadStatus
.uCharCount
= 0;
460 if(pCharLine
[stReadStatus
.uCharCount
] == '[') {
461 while(pCharLine
[stReadStatus
.uCharCount
] != ']' && pCharLine
[stReadStatus
.uCharCount
] != '\0' ) {
462 stReadStatus
.uCharCount
++;
464 if(pCharLine
[stReadStatus
.uCharCount
] == ']' ) {
465 stReadStatus
.uCharCount
++;
467 stReadStatus
.uCharCount
= 0;
470 uReadCount
= (ByteCount
> BYTES_OF_PS_DATA_PER_LINE
)? BYTES_OF_PS_DATA_PER_LINE
: ByteCount
;
471 //AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" "));
472 if((stPS_DataFormat
.eDataType
== eHex
) && stPS_DataFormat
.bIsArray
== true) {
473 while(uReadCount
> 0) {
474 PsTagEntry
[TagCount
].TagData
[stReadStatus
.uByteCount
] =
475 (u8
)(hex_to_bin(pCharLine
[stReadStatus
.uCharCount
]) << 4)
476 | (u8
)(hex_to_bin(pCharLine
[stReadStatus
.uCharCount
+ 1]));
478 PsTagEntry
[TagCount
].TagData
[stReadStatus
.uByteCount
+1] =
479 (u8
)(hex_to_bin(pCharLine
[stReadStatus
.uCharCount
+ 3]) << 4)
480 | (u8
)(hex_to_bin(pCharLine
[stReadStatus
.uCharCount
+ 4]));
482 stReadStatus
.uCharCount
+= 6; // read two bytes, plus a space;
483 stReadStatus
.uByteCount
+= 2;
486 if(ByteCount
> BYTES_OF_PS_DATA_PER_LINE
) {
487 ByteCount
-= BYTES_OF_PS_DATA_PER_LINE
;
497 stReadStatus
.uLineCount
++;
500 stReadStatus
.uSection
= 0;
501 stReadStatus
.uCharCount
= 0;
502 stReadStatus
.uLineCount
= 0;
503 stReadStatus
.uByteCount
= 0;
506 stReadStatus
.uCharCount
= 0;
509 if((stReadStatus
.uSection
== 0)&&(++TagCount
== RAMPS_MAX_PS_TAGS_PER_FILE
))
511 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("\n Buffer over flow PS File too big!!!"));
535 Tag_Count
= TagCount
;
536 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Number of Tags %d\n", Tag_Count
));
540 if (TagCount
> RAMPS_MAX_PS_TAGS_PER_FILE
)
558 /********************/
561 int GetNextTwoChar(A_UCHAR
*srcbuffer
,u32 len
, u32
*pos
, char *buffer
)
565 ch
= AthReadChar(srcbuffer
,len
,pos
);
566 if(ch
!= '\0' && isxdigit(ch
)) {
572 ch
= AthReadChar(srcbuffer
,len
,pos
);
573 if(ch
!= '\0' && isxdigit(ch
)) {
582 int AthDoParsePatch(A_UCHAR
*patchbuffer
, u32 patchlen
)
586 char Line
[MAX_BYTE_LENGTH
+ 1];
587 int ByteCount
,ByteCount_Org
;
597 while(NULL
!= AthGetLine(Line
,MAX_BYTE_LENGTH
,patchbuffer
,patchlen
,&filepos
)) {
598 if(strlen(Line
) <= 1 || !isxdigit(Line
[0])) {
604 ByteCount
= A_STRTOL(Line
, NULL
, 16);
605 ByteCount_Org
= ByteCount
;
607 while(ByteCount
> MAX_BYTE_LENGTH
){
609 /* Handle case when the number of patch buffer is more than the 20K */
610 if(MAX_NUM_PATCH_ENTRY
== Patch_Count
) {
611 for(i
= 0; i
< Patch_Count
; i
++) {
612 A_FREE(RamPatch
[i
].Data
);
616 RamPatch
[Patch_Count
].Len
= MAX_BYTE_LENGTH
;
617 RamPatch
[Patch_Count
].Data
= (u8
*)A_MALLOC(MAX_BYTE_LENGTH
);
621 ByteCount
= ByteCount
- MAX_BYTE_LENGTH
;
624 RamPatch
[Patch_Count
].Len
= (ByteCount
& 0xFF);
626 RamPatch
[Patch_Count
].Data
= (u8
*)A_MALLOC(ByteCount
);
630 while(ByteCount_Org
> MAX_BYTE_LENGTH
){
631 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,(" Index [%d]\n",j
));
632 for (i
= 0,k
=0; i
< MAX_BYTE_LENGTH
*2; i
+= 2,k
++,count
+=2) {
633 if(GetNextTwoChar(patchbuffer
,patchlen
,&filepos
,Byte
) == A_ERROR
) {
636 data
= A_STRTOUL(&Byte
[0], NULL
, 16);
637 RamPatch
[j
].Data
[k
] = (data
& 0xFF);
642 ByteCount_Org
= ByteCount_Org
- MAX_BYTE_LENGTH
;
647 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,(" Index [%d]\n",j
));
648 for (k
=0; k
< ByteCount_Org
; i
+= 2,k
++,count
+=2) {
649 if(GetNextTwoChar(patchbuffer
,patchlen
,&filepos
,Byte
) == A_ERROR
) {
652 data
= A_STRTOUL(Byte
, NULL
, 16);
653 RamPatch
[j
].Data
[k
] = (data
& 0xFF);
661 /********************/
662 int AthDoParsePS(A_UCHAR
*srcbuffer
, u32 srclen
)
666 bool BDADDR_Present
= false;
670 Total_tag_lenght
= 0;
676 if(NULL
!= srcbuffer
&& srclen
!= 0)
678 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("File Open Operation Successful\n"));
680 status
= AthParseFilesUnified(srcbuffer
,srclen
,MB_FILEFORMAT_PATCH
);
686 Total_tag_lenght
= 10;
690 for(i
=0; i
<Tag_Count
; i
++){
691 if(PsTagEntry
[i
].TagId
== 1){
692 BDADDR_Present
= true;
693 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BD ADDR is present in Patch File \r\n"));
696 if(PsTagEntry
[i
].TagLen
% 2 == 1){
697 Total_tag_lenght
= Total_tag_lenght
+ PsTagEntry
[i
].TagLen
+ 1;
700 Total_tag_lenght
= Total_tag_lenght
+ PsTagEntry
[i
].TagLen
;
706 if(Tag_Count
> 0 && !BDADDR_Present
){
707 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BD ADDR is not present adding 10 extra bytes \r\n"));
708 Total_tag_lenght
=Total_tag_lenght
+ 10;
710 Total_tag_lenght
= Total_tag_lenght
+ 10 + (Tag_Count
*4);
711 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("** Total Length %d\n",Total_tag_lenght
));
716 char *AthGetLine(char *buffer
, int maxlen
, A_UCHAR
*srcbuffer
,u32 len
,u32
*pos
)
727 CharRead
= AthReadChar(srcbuffer
,len
,pos
);
728 if( CharRead
== '\0' ) {
729 buffer
[count
+1] = '\0';
739 } else if(CharRead
== 10) {
744 buffer
[count
++] = CharRead
;
748 while(count
< maxlen
-1 && CharRead
!= '\0');
749 buffer
[count
] = '\0';
754 static void LoadHeader(A_UCHAR
*HCI_PS_Command
,A_UCHAR opcode
,int length
,int index
){
756 HCI_PS_Command
[0]= 0x0B;
757 HCI_PS_Command
[1]= 0xFC;
758 HCI_PS_Command
[2]= length
+ 4;
759 HCI_PS_Command
[3]= opcode
;
760 HCI_PS_Command
[4]= (index
& 0xFF);
761 HCI_PS_Command
[5]= ((index
>>8) & 0xFF);
762 HCI_PS_Command
[6]= length
;
765 /////////////////////////
767 int AthCreateCommandList(PSCmdPacket
**HciPacketList
, u32
*numPackets
)
778 Crc
|= RAM_PATCH_REGION
;
780 Crc
|= RAM_PS_REGION
;
781 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("PS Thread Started CRC %x Patch Count %d Tag Count %d \n",Crc
,Patch_Count
,Tag_Count
));
783 if(Patch_Count
|| Tag_Count
){
784 NumcmdEntry
+=(2 + Patch_Count
+ Tag_Count
); /* CRC Packet + PS Reset Packet + Patch List + PS List*/
785 if(Patch_Count
> 0) {
786 NumcmdEntry
++; /* Patch Enable Command */
788 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Num Cmd Entries %d Size %d \r\n",NumcmdEntry
,(u32
)sizeof(PSCmdPacket
) * NumcmdEntry
));
789 (*HciPacketList
) = A_MALLOC(sizeof(PSCmdPacket
) * NumcmdEntry
);
790 if(NULL
== *HciPacketList
) {
791 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("memory allocation failed \r\n"));
793 AthPSCreateHCICommand(PS_VERIFY_CRC
,Crc
,*HciPacketList
,numPackets
);
795 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("*** Write Patch**** \r\n"));
796 AthPSCreateHCICommand(WRITE_PATCH
,Patch_Count
,*HciPacketList
,numPackets
);
797 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("*** Enable Patch**** \r\n"));
798 AthPSCreateHCICommand(ENABLE_PATCH
,0,*HciPacketList
,numPackets
);
801 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("*** PS Reset**** %d[0x%x] \r\n",PS_RAM_SIZE
,PS_RAM_SIZE
));
802 AthPSCreateHCICommand(PS_RESET
,PS_RAM_SIZE
,*HciPacketList
,numPackets
);
804 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("*** PS Write**** \r\n"));
805 AthPSCreateHCICommand(PS_WRITE
,Tag_Count
,*HciPacketList
,numPackets
);
809 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("BD ADDR not present \r\n"));
812 for(count
= 0; count
< Patch_Count
; count
++) {
814 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Freeing Patch Buffer %d \r\n",count
));
815 A_FREE(RamPatch
[Patch_Count
].Data
);
818 for(count
= 0; count
< Tag_Count
; count
++) {
820 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Freeing PS Buffer %d \r\n",count
));
821 A_FREE(PsTagEntry
[count
].TagData
);
825 * SDIO Transport uses synchronous mode of data transfer
826 * So, AthPSOperations() call returns only after receiving the
827 * command complete event.
833 ////////////////////////
836 static int AthPSCreateHCICommand(A_UCHAR Opcode
, u32 Param1
,PSCmdPacket
*PSPatchPacket
,u32
*index
)
838 A_UCHAR
*HCI_PS_Command
;
847 for(i
=0;i
< Param1
;i
++){
849 HCI_PS_Command
= (A_UCHAR
*) A_MALLOC(RamPatch
[i
].Len
+HCI_COMMAND_HEADER
);
850 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("Allocated Buffer Size %d\n",RamPatch
[i
].Len
+HCI_COMMAND_HEADER
));
851 if(HCI_PS_Command
== NULL
){
852 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("MALLOC Failed\r\n"));
855 memset (HCI_PS_Command
, 0, RamPatch
[i
].Len
+HCI_COMMAND_HEADER
);
856 LoadHeader(HCI_PS_Command
,Opcode
,RamPatch
[i
].Len
,i
);
857 for(j
=0;j
<RamPatch
[i
].Len
;j
++){
858 HCI_PS_Command
[HCI_COMMAND_HEADER
+j
]=RamPatch
[i
].Data
[j
];
860 PSPatchPacket
[*index
].Hcipacket
= HCI_PS_Command
;
861 PSPatchPacket
[*index
].packetLen
= RamPatch
[i
].Len
+HCI_COMMAND_HEADER
;
874 HCI_PS_Command
= (A_UCHAR
*) A_MALLOC(Length
+HCI_COMMAND_HEADER
);
875 if(HCI_PS_Command
== NULL
){
876 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("MALLOC Failed\r\n"));
880 memset (HCI_PS_Command
, 0, Length
+HCI_COMMAND_HEADER
);
881 LoadHeader(HCI_PS_Command
,Opcode
,Length
,i
);
882 PSPatchPacket
[*index
].Hcipacket
= HCI_PS_Command
;
883 PSPatchPacket
[*index
].packetLen
= Length
+HCI_COMMAND_HEADER
;
891 HCI_PS_Command
= (A_UCHAR
*) A_MALLOC(Length
+HCI_COMMAND_HEADER
);
892 if(HCI_PS_Command
== NULL
){
893 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("MALLOC Failed\r\n"));
896 memset (HCI_PS_Command
, 0, Length
+HCI_COMMAND_HEADER
);
897 LoadHeader(HCI_PS_Command
,Opcode
,Length
,i
);
898 HCI_PS_Command
[7]= 0x00;
899 HCI_PS_Command
[Length
+HCI_COMMAND_HEADER
-2]= (Param1
& 0xFF);
900 HCI_PS_Command
[Length
+HCI_COMMAND_HEADER
-1]= ((Param1
>> 8) & 0xFF);
901 PSPatchPacket
[*index
].Hcipacket
= HCI_PS_Command
;
902 PSPatchPacket
[*index
].packetLen
= Length
+HCI_COMMAND_HEADER
;
908 for(i
=0;i
< Param1
;i
++){
909 if(PsTagEntry
[i
].TagId
==1)
912 HCI_PS_Command
= (A_UCHAR
*) A_MALLOC(PsTagEntry
[i
].TagLen
+HCI_COMMAND_HEADER
);
913 if(HCI_PS_Command
== NULL
){
914 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("MALLOC Failed\r\n"));
918 memset (HCI_PS_Command
, 0, PsTagEntry
[i
].TagLen
+HCI_COMMAND_HEADER
);
919 LoadHeader(HCI_PS_Command
,Opcode
,PsTagEntry
[i
].TagLen
,PsTagEntry
[i
].TagId
);
921 for(j
=0;j
<PsTagEntry
[i
].TagLen
;j
++){
922 HCI_PS_Command
[HCI_COMMAND_HEADER
+j
]=PsTagEntry
[i
].TagData
[j
];
925 PSPatchPacket
[*index
].Hcipacket
= HCI_PS_Command
;
926 PSPatchPacket
[*index
].packetLen
= PsTagEntry
[i
].TagLen
+HCI_COMMAND_HEADER
;
937 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("VALUE of CRC:%d At index %d\r\n",Param1
,*index
));
939 HCI_PS_Command
= (A_UCHAR
*) A_MALLOC(Length
+HCI_COMMAND_HEADER
);
940 if(HCI_PS_Command
== NULL
){
941 AR_DEBUG_PRINTF(ATH_DEBUG_ERR
,("MALLOC Failed\r\n"));
944 memset (HCI_PS_Command
, 0, Length
+HCI_COMMAND_HEADER
);
945 LoadHeader(HCI_PS_Command
,Opcode
,Length
,Param1
);
947 PSPatchPacket
[*index
].Hcipacket
= HCI_PS_Command
;
948 PSPatchPacket
[*index
].packetLen
= Length
+HCI_COMMAND_HEADER
;
958 int AthFreeCommandList(PSCmdPacket
**HciPacketList
, u32 numPackets
)
961 if(*HciPacketList
== NULL
) {
964 for(i
= 0; i
< numPackets
;i
++) {
965 A_FREE((*HciPacketList
)[i
].Hcipacket
);
967 A_FREE(*HciPacketList
);