88
88
typedef struct tPsTagEntry
93
93
} tPsTagEntry, *tpPsTagEntry;
95
95
typedef struct tRamPatch
99
99
} tRamPatch, *ptRamPatch;
103
typedef struct ST_PS_DATA_FORMAT {
103
struct st_ps_data_format {
104
104
enum eType eDataType;
108
typedef struct ST_READ_STATUS {
108
struct st_read_status {
110
110
unsigned uSection;
111
111
unsigned uLineCount;
112
112
unsigned uCharCount;
113
113
unsigned uByteCount;
117
117
/* Stores the number of PS Tags */
118
static A_UINT32 Tag_Count = 0;
118
static u32 Tag_Count = 0;
120
120
/* Stores the number of patch commands */
121
static A_UINT32 Patch_Count = 0;
122
static A_UINT32 Total_tag_lenght = 0;
123
A_BOOL BDADDR = FALSE;
121
static u32 Patch_Count = 0;
122
static u32 Total_tag_lenght = 0;
126
126
tPsTagEntry PsTagEntry[RAMPS_MAX_PS_TAGS_PER_FILE];
127
127
tRamPatch RamPatch[MAX_NUM_PATCH_ENTRY];
130
A_STATUS AthParseFilesUnified(A_UCHAR *srcbuffer,A_UINT32 srclen, int FileFormat);
131
char AthReadChar(A_UCHAR *buffer, A_UINT32 len,A_UINT32 *pos);
132
char * AthGetLine(char * buffer, int maxlen, A_UCHAR *srcbuffer,A_UINT32 len,A_UINT32 *pos);
133
static A_STATUS AthPSCreateHCICommand(A_UCHAR Opcode, A_UINT32 Param1,PSCmdPacket *PSPatchPacket,A_UINT32 *index);
130
int AthParseFilesUnified(u8 *srcbuffer,u32 srclen, int FileFormat);
131
char AthReadChar(u8 *buffer, u32 len,u32 *pos);
132
char *AthGetLine(char *buffer, int maxlen, u8 *srcbuffer,u32 len,u32 *pos);
133
static int AthPSCreateHCICommand(u8 Opcode, u32 Param1,struct ps_cmd_packet *PSPatchPacket,u32 *index);
135
135
/* Function to reads the next character from the input buffer */
136
char AthReadChar(A_UCHAR *buffer, A_UINT32 len,A_UINT32 *pos)
136
char AthReadChar(u8 *buffer, u32 len,u32 *pos)
139
139
if(buffer == NULL || *pos >=len )
148
148
/* PS parser helper function */
149
unsigned int uGetInputDataFormat(char* pCharLine, ST_PS_DATA_FORMAT *pstFormat)
149
unsigned int uGetInputDataFormat(char *pCharLine, struct st_ps_data_format *pstFormat)
151
151
if(pCharLine[0] != '[') {
152
152
pstFormat->eDataType = eHex;
318
A_STATUS AthParseFilesUnified(A_UCHAR *srcbuffer,A_UINT32 srclen, int FileFormat)
318
int AthParseFilesUnified(u8 *srcbuffer,u32 srclen, int FileFormat)
324
A_UINT8 ParseSection=RAM_PS_SECTION;
324
u8 ParseSection=RAM_PS_SECTION;
330
ST_PS_DATA_FORMAT stPS_DataFormat;
331
ST_READ_STATUS stReadStatus = {0, 0, 0,0};
330
struct st_ps_data_format stPS_DataFormat;
331
struct st_read_status stReadStatus = {0, 0, 0,0};
433
433
if (ByteCount > LINE_SIZE_MAX/2)
435
435
if(Buffer != NULL) {
440
440
PsTagEntry[TagCount].TagLen = ByteCount;
441
PsTagEntry[TagCount].TagData = (A_UINT8*)A_MALLOC(ByteCount);
441
PsTagEntry[TagCount].TagData = (u8 *)A_MALLOC(ByteCount);
442
442
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" TAG Length %d Tag Index %d \n",PsTagEntry[TagCount].TagLen,TagCount));
443
443
stReadStatus.uSection = 3;
444
444
stReadStatus.uLineCount = 0;
472
472
if((stPS_DataFormat.eDataType == eHex) && stPS_DataFormat.bIsArray == true) {
473
473
while(uReadCount > 0) {
474
474
PsTagEntry[TagCount].TagData[stReadStatus.uByteCount] =
475
(A_UINT8)(hex_to_bin(pCharLine[stReadStatus.uCharCount]) << 4)
476
| (A_UINT8)(hex_to_bin(pCharLine[stReadStatus.uCharCount + 1]));
475
(u8)(hex_to_bin(pCharLine[stReadStatus.uCharCount]) << 4)
476
| (u8)(hex_to_bin(pCharLine[stReadStatus.uCharCount + 1]));
478
478
PsTagEntry[TagCount].TagData[stReadStatus.uByteCount+1] =
479
(A_UINT8)(hex_to_bin(pCharLine[stReadStatus.uCharCount + 3]) << 4)
480
| (A_UINT8)(hex_to_bin(pCharLine[stReadStatus.uCharCount + 4]));
479
(u8)(hex_to_bin(pCharLine[stReadStatus.uCharCount + 3]) << 4)
480
| (u8)(hex_to_bin(pCharLine[stReadStatus.uCharCount + 4]));
482
482
stReadStatus.uCharCount += 6; // read two bytes, plus a space;
483
483
stReadStatus.uByteCount += 2;
582
A_STATUS AthDoParsePatch(A_UCHAR *patchbuffer, A_UINT32 patchlen)
582
int AthDoParsePatch(u8 *patchbuffer, u32 patchlen)
586
char Line[MAX_BYTE_LENGTH + 1];
586
char Line[MAX_BYTE_LENGTH + 1];
587
587
int ByteCount,ByteCount_Org;
609
609
/* Handle case when the number of patch buffer is more than the 20K */
610
610
if(MAX_NUM_PATCH_ENTRY == Patch_Count) {
611
611
for(i = 0; i < Patch_Count; i++) {
612
A_FREE(RamPatch[i].Data);
612
kfree(RamPatch[i].Data);
616
616
RamPatch[Patch_Count].Len= MAX_BYTE_LENGTH;
617
RamPatch[Patch_Count].Data = (A_UINT8*)A_MALLOC(MAX_BYTE_LENGTH);
617
RamPatch[Patch_Count].Data = (u8 *)A_MALLOC(MAX_BYTE_LENGTH);
661
661
/********************/
662
A_STATUS AthDoParsePS(A_UCHAR *srcbuffer, A_UINT32 srclen)
662
int AthDoParsePS(u8 *srcbuffer, u32 srclen)
666
A_BOOL BDADDR_Present = A_ERROR;
666
bool BDADDR_Present = false;
670
670
Total_tag_lenght = 0;
674
674
status = A_ERROR;
716
char * AthGetLine(char * buffer, int maxlen, A_UCHAR *srcbuffer,A_UINT32 len,A_UINT32 *pos)
716
char *AthGetLine(char *buffer, int maxlen, u8 *srcbuffer,u32 len,u32 *pos)
754
static void LoadHeader(A_UCHAR *HCI_PS_Command,A_UCHAR opcode,int length,int index){
754
static void LoadHeader(u8 *HCI_PS_Command,u8 opcode,int length,int index){
756
756
HCI_PS_Command[0]= 0x0B;
757
757
HCI_PS_Command[1]= 0xFC;
765
765
/////////////////////////
767
int AthCreateCommandList(PSCmdPacket **HciPacketList, A_UINT32 *numPackets)
767
int AthCreateCommandList(struct ps_cmd_packet **HciPacketList, u32 *numPackets)
771
A_UINT32 NumcmdEntry = 0;
785
785
if(Patch_Count > 0) {
786
786
NumcmdEntry++; /* Patch Enable Command */
788
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Num Cmd Entries %d Size %d \r\n",NumcmdEntry,(A_UINT32)sizeof(PSCmdPacket) * NumcmdEntry));
789
(*HciPacketList) = A_MALLOC(sizeof(PSCmdPacket) * NumcmdEntry);
788
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Num Cmd Entries %d Size %d \r\n",NumcmdEntry,(u32)sizeof(struct ps_cmd_packet) * NumcmdEntry));
789
(*HciPacketList) = A_MALLOC(sizeof(struct ps_cmd_packet) * NumcmdEntry);
790
790
if(NULL == *HciPacketList) {
791
791
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("memory allocation failed \r\n"));
812
812
for(count = 0; count < Patch_Count; count++) {
814
814
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Freeing Patch Buffer %d \r\n",count));
815
A_FREE(RamPatch[Patch_Count].Data);
815
kfree(RamPatch[Patch_Count].Data);
818
818
for(count = 0; count < Tag_Count; count++) {
820
820
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Freeing PS Buffer %d \r\n",count));
821
A_FREE(PsTagEntry[count].TagData);
821
kfree(PsTagEntry[count].TagData);
833
833
////////////////////////
836
static A_STATUS AthPSCreateHCICommand(A_UCHAR Opcode, A_UINT32 Param1,PSCmdPacket *PSPatchPacket,A_UINT32 *index)
836
static int AthPSCreateHCICommand(u8 Opcode, u32 Param1,struct ps_cmd_packet *PSPatchPacket,u32 *index)
838
A_UCHAR *HCI_PS_Command;
847
847
for(i=0;i< Param1;i++){
849
HCI_PS_Command = (A_UCHAR *) A_MALLOC(RamPatch[i].Len+HCI_COMMAND_HEADER);
849
HCI_PS_Command = (u8 *) A_MALLOC(RamPatch[i].Len+HCI_COMMAND_HEADER);
850
850
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Allocated Buffer Size %d\n",RamPatch[i].Len+HCI_COMMAND_HEADER));
851
851
if(HCI_PS_Command == NULL){
852
852
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("MALLOC Failed\r\n"));
908
908
for(i=0;i< Param1;i++){
909
909
if(PsTagEntry[i].TagId ==1)
912
HCI_PS_Command = (A_UCHAR *) A_MALLOC(PsTagEntry[i].TagLen+HCI_COMMAND_HEADER);
912
HCI_PS_Command = (u8 *) A_MALLOC(PsTagEntry[i].TagLen+HCI_COMMAND_HEADER);
913
913
if(HCI_PS_Command == NULL){
914
914
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("MALLOC Failed\r\n"));
937
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);
939
HCI_PS_Command = (u8 *) A_MALLOC(Length+HCI_COMMAND_HEADER);
940
940
if(HCI_PS_Command == NULL){
941
941
AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("MALLOC Failed\r\n"));
953
953
case CHANGE_BDADDR:
958
A_STATUS AthFreeCommandList(PSCmdPacket **HciPacketList, A_UINT32 numPackets)
958
int AthFreeCommandList(struct ps_cmd_packet **HciPacketList, u32 numPackets)
961
961
if(*HciPacketList == NULL) {
964
964
for(i = 0; i < numPackets;i++) {
965
A_FREE((*HciPacketList)[i].Hcipacket);
965
kfree((*HciPacketList)[i].Hcipacket);
967
A_FREE(*HciPacketList);
967
kfree(*HciPacketList);