Changeset 7160
- Timestamp:
- 07/10/12 12:29:22 (12 years ago)
- Location:
- trunk/csctapi
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/csctapi/icc_async.c
r7145 r7160 133 133 return ERROR; 134 134 } 135 if ((reader->fdmc = open(DEV_MULTICAM, O_RDWR)) < 0) { 135 if ((reader->fdmc = open(DEV_MULTICAM, O_RDWR)) < 0) { 136 136 rdr_log(reader, "ERROR: Opening device %s (errno=%d %s)", DEV_MULTICAM, errno, strerror(errno)); 137 137 close(reader->handle); … … 337 337 rdr_log(reader, "Doing fast reset"); 338 338 call (Cool_FastReset_With_ATR(reader, atr)); 339 } 339 } 340 340 #elif defined(WITH_AZBOX) 341 341 call (Azbox_Reset(reader, atr)); … … 463 463 if (reader->crdr.active==1) { 464 464 if (reader->convention == ATR_CONVENTION_INVERSE && reader->crdr.need_inverse==1) { 465 buffer = (BYTE *) calloc(sizeof (BYTE), size);465 if(!cs_malloc(&buffer,size, -1)) return -1; 466 466 memcpy (buffer, data, size); 467 467 ICC_Async_InvertBuffer (size, buffer); … … 762 762 } 763 763 else { //negotiable mode 764 764 765 765 if (reader->mhz > 2000) // Initial timeout for pll readers to 10000000 us 766 766 reader->read_timeout = 1000000; … … 845 845 return ret; 846 846 } 847 847 848 848 /* Send PPS request */ 849 849 call (ICC_Async_Transmit (reader, len_request, params)); … … 890 890 return (uint32_t) (WWT * work_etu); // in us 891 891 } 892 892 893 893 if (WWT > CHAR_LEN) 894 894 WWT -= CHAR_LEN; … … 965 965 if (ATR_GetParameter(atr, ATR_PARAMETER_I, &I) != ATR_OK) 966 966 I = 0; 967 968 //set clock speed to max if internal reader 967 968 //set clock speed to max if internal reader 969 969 if((reader->typ > R_MOUSE && reader->crdr.active == 0) || (reader->crdr.active == 1 && reader->crdr.max_clock_speed==1)) 970 970 if (reader->mhz == 357 || reader->mhz == 358) //no overclocking 971 971 reader->mhz = atr_fs_table[FI] / 10000; //we are going to clock the card to this nominal frequency 972 972 973 973 if (reader->mhz > 2000 && reader->cardmhz == -1) // -1 is magic number pll internal reader set cardmhz according to optimal atr speed 974 974 reader->cardmhz = atr_fs_table[FI] / 10000 ; 975 975 976 976 if (reader->mhz > 2000) { 977 reader->divider = 0; //reset pll divider so divider will be set calculated again. 977 reader->divider = 0; //reset pll divider so divider will be set calculated again. 978 978 ICC_Async_GetPLL_Divider(reader); // calculate pll divider for target cardmhz. 979 979 } 980 980 981 981 //set clock speed/baudrate must be done before timings 982 982 //because reader->current_baudrate is used in calculation of timings 983 983 F = (double) atr_f_table[FI]; //Get FI (this is != clockspeed) 984 984 985 985 reader->current_baudrate = DEFAULT_BAUDRATE; 986 986 … … 990 990 if (reader->mhz >2000 && reader->mhz != 8300) 991 991 baud_temp = (uint32_t) (d * (double) reader->mhz / reader->divider *10000L / F); 992 else 992 else 993 993 baud_temp = d * ICC_Async_GetClockRate (reader->cardmhz) / F; 994 994 if (reader->crdr.active == 1) { … … 1031 1031 1032 1032 // WWT = 960 * d * WI work etu 1033 1033 1034 1034 if (reader->mhz > 2000) WWT = (uint32_t) 960 * d * wi; //in work ETU 1035 1035 else WWT = (uint32_t) 960 * wi; //in ETU 1036 1036 1037 1037 if (reader->protocol_type == ATR_PROTOCOL_TYPE_T14) 1038 WWT >>= 1; //is this correct? 1039 1038 WWT >>= 1; //is this correct? 1039 1040 1040 if( reader->mhz > 2000){ 1041 1041 EGT = 2; 1042 1042 if (n != 255) //Extra Guard Time 1043 1043 EGT =+ n; // T0 protocol, if TC1 = 255 then dont add extra guardtime 1044 GT = 0; 1045 gt_ms = ETU_to_ms(reader, GT); 1044 GT = 0; 1045 gt_ms = ETU_to_ms(reader, GT); 1046 1046 reader->CWT = 0; // T0 protocol doesnt have char_delay, block_delay. 1047 1047 reader->BWT = 0; … … 1059 1059 reader->protocol_type, WWT, 1060 1060 ICC_Async_GetClockRate(reader->cardmhz)); 1061 1061 1062 1062 reader->read_timeout = ETU_to_ms(reader, WWT); 1063 1063 reader->block_delay = gt_ms; … … 1086 1086 //FIXME not sure whether this limitation still exists 1087 1087 reader->ifsc = MIN (reader->ifsc, MAX_IFSC); 1088 1088 1089 1089 #ifndef PROTOCOL_T1_USE_DEFAULT_TIMINGS 1090 1090 // Calculate CWI and BWI … … 1106 1106 reader->CWT = (uint16_t) (((1<<cwi) + 11L)); // in ETU 1107 1107 1108 // Set BWT = (2^BWI * 960 * 372 / clockspeed) seconds + 11 work etu (in seconds) 1108 // Set BWT = (2^BWI * 960 * 372 / clockspeed) seconds + 11 work etu (in seconds) 1109 1109 // 1 worketu = 1 / baudrate *1000*1000 us 1110 1110 if (reader->mhz > 2000 && reader->mhz != 8300) … … 1112 1112 else 1113 1113 reader->BWT = (uint32_t)((1<<bwi) * 960L * 372L * 9600L / (double) ICC_Async_GetClockRate(reader->cardmhz)) + 11L ; 1114 1114 1115 1115 // Set BGT = 22 * work etu 1116 1116 BGT = 22L; //in ETU … … 1134 1134 reader->CWT, reader->BWT, 1135 1135 BGT, (edc == EDC_LRC) ? "LRC" : "CRC"); 1136 1136 1137 1137 if( reader->mhz > 2000){ 1138 1138 GT = 12L; … … 1145 1145 } 1146 1146 reader->read_timeout = ETU_to_ms(reader, reader->BWT); 1147 reader->block_delay = ETU_to_ms(reader, BGT); 1147 reader->block_delay = ETU_to_ms(reader, BGT); 1148 1148 reader->char_delay = ETU_to_ms(reader, CGT); 1149 1149 rdr_debug_mask(reader, D_ATR, "Setting timings: timeout=%u ms, block_delay=%u ms, char_delay=%u ms", … … 1155 1155 break; 1156 1156 }//switch 1157 1157 1158 1158 rdr_debug_mask(reader, D_ATR, "Setting right parity"); 1159 1159 call (SetRightParity (reader)); -
trunk/csctapi/ifd_pcsc.c
r7159 r7160 51 51 return 2; 52 52 } 53 54 readers = calloc(nbReaders, sizeof(char *)); 55 if (readers == NULL) { 56 rdr_log(pcsc_reader, "PCSC failed calloc"); 57 return 2; 58 } 53 if(!cs_malloc(&readers,sizeof(char *), -1)) return 2; 59 54 60 55 /* fill the readers table */ -
trunk/csctapi/t1_block.c
r6309 r7160 31 31 * Not exported constants definition 32 32 */ 33 33 34 34 #define T1_BLOCK_NAD 0x00 35 35 … … 38 38 */ 39 39 static unsigned char T1_Block_LRC (unsigned char * data, uint32_t length); 40 40 41 41 /* 42 42 * Exported functions definition … … 46 46 { 47 47 T1_Block * block; 48 48 49 49 if (length < 4) 50 50 return NULL; 51 52 block = (T1_Block *) malloc (sizeof (T1_Block)); 53 54 if (block != NULL) { 51 52 if(cs_malloc(&block,sizeof(T1_Block), 1)) 53 { 55 54 if (length > T1_BLOCK_MAX_SIZE) 56 55 block->length = T1_BLOCK_MAX_SIZE; 57 56 else 58 57 block->length = length; 59 block->data = (unsigned char *) calloc (block->length, sizeof (unsigned char)); 60 61 if (block->data != NULL) 58 if(cs_malloc(&block->data,sizeof(unsigned char *), 1)) 62 59 memcpy (block->data, buffer, block->length); 63 60 else { … … 72 69 { 73 70 T1_Block * block; 74 block = (T1_Block *) malloc (sizeof (T1_Block));75 if (block != NULL){71 if(cs_malloc(&block,sizeof(T1_Block), 1)) 72 { 76 73 block->length = len + 4; 77 block->data = (unsigned char *) calloc (block->length, sizeof (unsigned char)); 78 if (block->data != NULL) { 74 if(cs_malloc(&block->data,sizeof(unsigned char *), 1)) { 79 75 block->data[0] = T1_BLOCK_NAD; 80 76 block->data[1] = T1_BLOCK_I | ((ns << 6) & 0x40); … … 97 93 { 98 94 T1_Block * block; 99 block = (T1_Block *) malloc (sizeof (T1_Block));100 if (block != NULL){95 if(cs_malloc(&block,sizeof(T1_Block), 1)) 96 { 101 97 block->length = 4; 102 block->data = (unsigned char *) calloc (block->length, sizeof (unsigned char)); 103 if (block->data != NULL) { 98 if(cs_malloc(&block->data,sizeof(unsigned char *), 1)) { 104 99 block->data[0] = T1_BLOCK_NAD; 105 100 block->data[1] = type | ((nr << 4) & 0x10); … … 118 113 { 119 114 T1_Block * block; 120 block = (T1_Block *) malloc (sizeof (T1_Block));121 if (block != NULL){115 if(cs_malloc(&block,sizeof(T1_Block), 1)) 116 { 122 117 block->length = 4 + len; 123 block->data = (unsigned char *) calloc (block->length, sizeof (unsigned char)); 124 if (block->data != NULL) { 118 if(cs_malloc(&block->data,sizeof(unsigned char *), 1)) { 125 119 block->data[0] = T1_BLOCK_NAD; 126 120 block->data[1] = type; … … 189 183 for (i = 0; i < length; i++) 190 184 lrc ^= data[i]; 191 return lrc; 185 return lrc; 192 186 } 193 187 #endif
Note:
See TracChangeset
for help on using the changeset viewer.