Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: chromeos/drivers/ath6kl/miscdrv/ar3kps/ar3kpsparser.c

Issue 3579004: ath6kl: Bringing in the upstream version (Closed) Base URL: http://git.chromium.org/git/kernel.git
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2004-2008 Atheros Communications Inc. 2 * Copyright (c) 2004-2010 Atheros Communications Inc.
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
5 * This file implements the Atheros PS and patch parser. 5 * This file implements the Atheros PS and patch parser.
6 * It implements APIs to parse data buffer with patch and PS information and con vert it to HCI commands. 6 * It implements APIs to parse data buffer with patch and PS information and con vert it to HCI commands.
7 * 7 *
8 * 8 *
9 * 9 *
10 * ar3kpsparser.c 10 * ar3kpsparser.c
11 * 11 *
12 * 12 *
13 * 13 *
14 * The software source and binaries included in this development package are 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 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 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 17 * listed in these license agreement(s). All other rights remain with Atheros
18 * Communications, Inc., its subsidiaries, or the respective owner including 18 * Communications, Inc., its subsidiaries, or the respective owner including
19 * those listed on the included copyright notices.. Distribution of any 19 * those listed on the included copyright notices.. Distribution of any
20 * portion of this package must be in strict compliance with the license 20 * portion of this package must be in strict compliance with the license
21 * agreement(s) terms. 21 * agreement(s) terms.
22 * 22 *
23 * 23 *
24 * 24 *
25 */ 25 */
26 26
27 27
28 #include "ar3kpsparser.h" 28 #include "ar3kpsparser.h"
29 29
30 #include <linux/ctype.h>
31 #include <linux/kernel.h>
32
30 #define BD_ADDR_SIZE 6 33 #define BD_ADDR_SIZE 6
31 #define WRITE_PATCH 8 34 #define WRITE_PATCH 8
32 #define ENABLE_PATCH 11 35 #define ENABLE_PATCH 11
33 #define PS_RESET 2 36 #define PS_RESET 2
34 #define PS_WRITE 1 37 #define PS_WRITE 1
35 #define PS_VERIFY_CRC 9 38 #define PS_VERIFY_CRC 9
36 #define CHANGE_BDADDR 15 39 #define CHANGE_BDADDR 15
37 40
38 #define HCI_COMMAND_HEADER 7 41 #define HCI_COMMAND_HEADER 7
39 42
(...skipping 14 matching lines...) Expand all
54 57
55 /* Constant values used by parser */ 58 /* Constant values used by parser */
56 #define BYTES_OF_PS_DATA_PER_LINE 16 59 #define BYTES_OF_PS_DATA_PER_LINE 16
57 #define RAMPS_MAX_PS_DATA_PER_TAG 20000 60 #define RAMPS_MAX_PS_DATA_PER_TAG 20000
58 61
59 62
60 /* Number pf PS/Patch entries in an HCI packet */ 63 /* Number pf PS/Patch entries in an HCI packet */
61 #define MAX_BYTE_LENGTH 244 64 #define MAX_BYTE_LENGTH 244
62 65
63 #define SKIP_BLANKS(str) while (*str == ' ') str++ 66 #define SKIP_BLANKS(str) while (*str == ' ') str++
64 #define MIN(x, y) (((x) <= (y))? (x):(y))
65 #define MAX(x, y) (((x) >= (y))? (x):(y))
66
67 #define UNUSED(x) (x=x)
68
69 #define IS_BETWEEN(x, lower, upper) (((lower) <= (x)) && ((x) <= (upper)))
70 #define IS_DIGIT(c) (IS_BETWEEN((c), '0', '9'))
71 #define IS_HEX(c) (IS_BETWEEN((c), '0', '9') || IS_BETWEEN((c), 'a', 'f') || I S_BETWEEN((c), 'A', 'F'))
72 #define TO_LOWER(c) (IS_BETWEEN((c), 'A', 'Z') ? ((c) - 'A' + 'a') : (c))
73 #define IS_BLANK(c) ((c) == ' ')
74 #define CONV_DEC_DIGIT_TO_VALUE(c) ((c) - '0')
75 #define CONV_HEX_DIGIT_TO_VALUE(c) (IS_DIGIT(c) ? ((c) - '0') : (IS_BETWEEN((c), 'A', 'Z') ? ((c) - 'A' + 10) : ((c) - 'a' + 10)))
76 #define CONV_VALUE_TO_HEX(v) ((A_UINT8)( ((v & 0x0F) <= 9) ? ((v & 0x0F) + '0') : ((v & 0x0F) - 10 + 'A') ) )
77
78 67
79 enum MinBootFileFormatE 68 enum MinBootFileFormatE
80 { 69 {
81 MB_FILEFORMAT_RADIOTBL, 70 MB_FILEFORMAT_RADIOTBL,
82 MB_FILEFORMAT_PATCH, 71 MB_FILEFORMAT_PATCH,
83 MB_FILEFORMAT_COEXCONFIG 72 MB_FILEFORMAT_COEXCONFIG
84 }; 73 };
85 74
86 enum RamPsSection 75 enum RamPsSection
87 { 76 {
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 stReadStatus.uCharCount++; 465 stReadStatus.uCharCount++;
477 } else { 466 } else {
478 stReadStatus.uCharCount = 0; 467 stReadStatus.uCharCount = 0;
479 } 468 }
480 } 469 }
481 uReadCount = (ByteCount > BYTES_OF_PS_DATA_PER_LINE)? BYTES_ OF_PS_DATA_PER_LINE: ByteCount; 470 uReadCount = (ByteCount > BYTES_OF_PS_DATA_PER_LINE)? BYTES_ OF_PS_DATA_PER_LINE: ByteCount;
482 //AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" ")); 471 //AR_DEBUG_PRINTF(ATH_DEBUG_ERR,(" "));
483 if((stPS_DataFormat.eDataType == eHex) && stPS_DataFormat.bI sArray == true) { 472 if((stPS_DataFormat.eDataType == eHex) && stPS_DataFormat.bI sArray == true) {
484 while(uReadCount > 0) { 473 while(uReadCount > 0) {
485 PsTagEntry[TagCount].TagData[stReadStatus.uByteCount] = 474 PsTagEntry[TagCount].TagData[stReadStatus.uByteCount] =
486 (A_UINT8)(CONV_HEX_DIGIT_TO _VALUE(pCharLine[stReadStatus.uCharCount]) << 4) 475 (A_UINT8)(hex_to_bin(pCharL ine[stReadStatus.uCharCount]) << 4)
487 | (A_UINT8)(CONV_HEX_DIGIT_ TO_VALUE(pCharLine[stReadStatus.uCharCount + 1])); 476 | (A_UINT8)(hex_to_bin(pCha rLine[stReadStatus.uCharCount + 1]));
488 477
489 PsTagEntry[TagCount].TagData[stReadStatus.uByteCount+ 1] = 478 PsTagEntry[TagCount].TagData[stReadStatus.uByteCount+ 1] =
490 (A_UINT8)(CONV_HEX_DIGIT_TO _VALUE(pCharLine[stReadStatus.uCharCount + 3]) << 4) 479 (A_UINT8)(hex_to_bin(pCharL ine[stReadStatus.uCharCount + 3]) << 4)
491 | (A_UINT8)(CONV_HEX_DIGIT_ TO_VALUE(pCharLine[stReadStatus.uCharCount + 4])); 480 | (A_UINT8)(hex_to_bin(pCha rLine[stReadStatus.uCharCount + 4]));
492 481
493 stReadStatus.uCharCount += 6; // read two bytes, plus a space; 482 stReadStatus.uCharCount += 6; // read two bytes, plus a space;
494 stReadStatus.uByteCount += 2; 483 stReadStatus.uByteCount += 2;
495 uReadCount -= 2; 484 uReadCount -= 2;
496 } 485 }
497 if(ByteCount > BYTES_OF_PS_DATA_PER_LINE) { 486 if(ByteCount > BYTES_OF_PS_DATA_PER_LINE) {
498 ByteCount -= BYTES_OF_PS_DATA_PER_LINE; 487 ByteCount -= BYTES_OF_PS_DATA_PER_LINE;
499 } 488 }
500 else { 489 else {
501 ByteCount = 0; 490 ByteCount = 0;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 556
568 557
569 /********************/ 558 /********************/
570 559
571 560
572 A_STATUS GetNextTwoChar(A_UCHAR *srcbuffer,A_UINT32 len, A_UINT32 *pos, char * b uffer) 561 A_STATUS GetNextTwoChar(A_UCHAR *srcbuffer,A_UINT32 len, A_UINT32 *pos, char * b uffer)
573 { 562 {
574 unsigned char ch; 563 unsigned char ch;
575 564
576 ch = AthReadChar(srcbuffer,len,pos); 565 ch = AthReadChar(srcbuffer,len,pos);
577 if(ch != '\0' && IS_HEX(ch)) { 566 if(ch != '\0' && isxdigit(ch)) {
578 buffer[0] = ch; 567 buffer[0] = ch;
579 } else 568 } else
580 { 569 {
581 return A_ERROR; 570 return A_ERROR;
582 } 571 }
583 ch = AthReadChar(srcbuffer,len,pos); 572 ch = AthReadChar(srcbuffer,len,pos);
584 if(ch != '\0' && IS_HEX(ch)) { 573 if(ch != '\0' && isxdigit(ch)) {
585 buffer[1] = ch; 574 buffer[1] = ch;
586 } else 575 } else
587 { 576 {
588 return A_ERROR; 577 return A_ERROR;
589 } 578 }
590 return A_OK; 579 return A_OK;
591 } 580 }
592 581
593 A_STATUS AthDoParsePatch(A_UCHAR *patchbuffer, A_UINT32 patchlen) 582 A_STATUS AthDoParsePatch(A_UCHAR *patchbuffer, A_UINT32 patchlen)
594 { 583 {
595 584
596 char Byte[3]; 585 char Byte[3];
597 char Line[MAX_BYTE_LENGTH + 1]; 586 char Line[MAX_BYTE_LENGTH + 1];
598 int ByteCount,ByteCount_Org; 587 int ByteCount,ByteCount_Org;
599 int count; 588 int count;
600 int i,j,k; 589 int i,j,k;
601 int data; 590 int data;
602 A_UINT32 filepos; 591 A_UINT32 filepos;
603 Byte[2] = '\0'; 592 Byte[2] = '\0';
604 j = 0; 593 j = 0;
605 filepos = 0; 594 filepos = 0;
606 Patch_Count = 0; 595 Patch_Count = 0;
607 596
608 while(NULL != AthGetLine(Line,MAX_BYTE_LENGTH,patchbuffer,patchlen,&filepos) ) { 597 while(NULL != AthGetLine(Line,MAX_BYTE_LENGTH,patchbuffer,patchlen,&filepos) ) {
609 if(strlen(Line) <= 1 || !IS_HEX(Line[0])) { 598 if(strlen(Line) <= 1 || !isxdigit(Line[0])) {
610 continue; 599 continue;
611 } else { 600 } else {
612 break; 601 break;
613 } 602 }
614 } 603 }
615 ByteCount = A_STRTOL(Line, NULL, 16); 604 ByteCount = A_STRTOL(Line, NULL, 16);
616 ByteCount_Org = ByteCount; 605 ByteCount_Org = ByteCount;
617 606
618 while(ByteCount > MAX_BYTE_LENGTH){ 607 while(ByteCount > MAX_BYTE_LENGTH){
619 608
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 Crc |= RAM_PATCH_REGION; 778 Crc |= RAM_PATCH_REGION;
790 if(Tag_Count > 0) 779 if(Tag_Count > 0)
791 Crc |= RAM_PS_REGION; 780 Crc |= RAM_PS_REGION;
792 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("PS Thread Started CRC %x Patch Count %d Tag Count %d \n",Crc,Patch_Count,Tag_Count)); 781 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("PS Thread Started CRC %x Patch Count %d Tag Count %d \n",Crc,Patch_Count,Tag_Count));
793 782
794 if(Patch_Count || Tag_Count ){ 783 if(Patch_Count || Tag_Count ){
795 NumcmdEntry+=(2 + Patch_Count + Tag_Count); /* CRC Packet + PS Reset Packet + Patch List + PS List*/ 784 NumcmdEntry+=(2 + Patch_Count + Tag_Count); /* CRC Packet + PS Reset Packet + Patch List + PS List*/
796 if(Patch_Count > 0) { 785 if(Patch_Count > 0) {
797 NumcmdEntry++; /* Patch Enable Command */ 786 NumcmdEntry++; /* Patch Enable Command */
798 } 787 }
799 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Num Cmd Entries %d Size %d \r\n",Nu mcmdEntry,sizeof(PSCmdPacket) * NumcmdEntry)); 788 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("Num Cmd Entries %d Size %d \r\n",Nu mcmdEntry,(A_UINT32)sizeof(PSCmdPacket) * NumcmdEntry));
800 (*HciPacketList) = A_MALLOC(sizeof(PSCmdPacket) * NumcmdEntry); 789 (*HciPacketList) = A_MALLOC(sizeof(PSCmdPacket) * NumcmdEntry);
801 if(NULL == *HciPacketList) { 790 if(NULL == *HciPacketList) {
802 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("memory allocation failed \r\n")) ; 791 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("memory allocation failed \r\n")) ;
803 } 792 }
804 AthPSCreateHCICommand(PS_VERIFY_CRC,Crc,*HciPacketList,numPackets); 793 AthPSCreateHCICommand(PS_VERIFY_CRC,Crc,*HciPacketList,numPackets);
805 if(Patch_Count > 0){ 794 if(Patch_Count > 0){
806 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("*** Write Patch**** \r\n")); 795 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("*** Write Patch**** \r\n"));
807 AthPSCreateHCICommand(WRITE_PATCH,Patch_Count,*HciPacketList,num Packets); 796 AthPSCreateHCICommand(WRITE_PATCH,Patch_Count,*HciPacketList,num Packets);
808 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("*** Enable Patch**** \r\n")); 797 AR_DEBUG_PRINTF(ATH_DEBUG_ERR,("*** Enable Patch**** \r\n"));
809 AthPSCreateHCICommand(ENABLE_PATCH,0,*HciPacketList,numPackets); 798 AthPSCreateHCICommand(ENABLE_PATCH,0,*HciPacketList,numPackets);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 int i; 960 int i;
972 if(*HciPacketList == NULL) { 961 if(*HciPacketList == NULL) {
973 return A_ERROR; 962 return A_ERROR;
974 } 963 }
975 for(i = 0; i < numPackets;i++) { 964 for(i = 0; i < numPackets;i++) {
976 A_FREE((*HciPacketList)[i].Hcipacket); 965 A_FREE((*HciPacketList)[i].Hcipacket);
977 } 966 }
978 A_FREE(*HciPacketList); 967 A_FREE(*HciPacketList);
979 return A_OK; 968 return A_OK;
980 } 969 }
OLDNEW
« no previous file with comments | « chromeos/drivers/ath6kl/miscdrv/ar3kps/ar3kpsparser.h ('k') | chromeos/drivers/ath6kl/miscdrv/common_drv.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698