| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2010, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bscd.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/1 $ |
|---|
| 12 | * $brcm_Date: 10/18/10 10:09a $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: This file contains Broadcom smart card (OS/platform |
|---|
| 15 | * independent) porting interface public functions that |
|---|
| 16 | * can support multiple Broadcom smart card interfaces. |
|---|
| 17 | * Since smart card module supports multiple independent |
|---|
| 18 | * and identical interfaces/channels, most of the functions |
|---|
| 19 | * required a channel handle (BSCD_ChannelHandle), |
|---|
| 20 | * instead of module handle (BSCD_Handle). |
|---|
| 21 | * This module can support the board with or without |
|---|
| 22 | * TDA8004 chip. |
|---|
| 23 | * |
|---|
| 24 | * Revision History: |
|---|
| 25 | * |
|---|
| 26 | * $brcm_Log: /magnum/portinginterface/scd/7422/bscd.h $ |
|---|
| 27 | * |
|---|
| 28 | * Hydra_Software_Devel/1 10/18/10 10:09a qxie |
|---|
| 29 | * SW7422-78: initial version |
|---|
| 30 | * |
|---|
| 31 | * Hydra_Software_Devel/18 7/13/09 3:20p qxie |
|---|
| 32 | * PR56770: Smartcard: move BSCD_Channel_P_DumpRegisters to public PI, |
|---|
| 33 | * changed name to BSCD_Channel_DumpRegisters |
|---|
| 34 | * |
|---|
| 35 | * Hydra_Software_Devel/17 3/22/06 10:13a qcheng |
|---|
| 36 | * PR19076: Support BCM7400. |
|---|
| 37 | * |
|---|
| 38 | * Hydra_Software_Devel/16 11/19/04 6:23p btan |
|---|
| 39 | * PR 13298: Refer to the functions BSCD_CLI_T0Test( ) or BSCD_CLI_T1Test( |
|---|
| 40 | * ) in bscd_cli_infra.c for sample codes. |
|---|
| 41 | * |
|---|
| 42 | * Hydra_Software_Devel/15 9/9/04 12:40p btan |
|---|
| 43 | * PR 12504, PR12607:support customized callback functions. Smartcard: T=0 |
|---|
| 44 | * protocol takes too long to time out and time out happens after all |
|---|
| 45 | * bytes are received. |
|---|
| 46 | * |
|---|
| 47 | * Hydra_Software_Devel/14 7/20/04 2:11p btan |
|---|
| 48 | * PR 10898: Pass EMV 2000 tests with either event interrupt or WWT to |
|---|
| 49 | * detect CWT +4 |
|---|
| 50 | * |
|---|
| 51 | * Hydra_Software_Devel/13 12/31/03 11:05a btan |
|---|
| 52 | * PR 8080: Fixed auto_clk set before sc_clk_en |
|---|
| 53 | * |
|---|
| 54 | * Hydra_Software_Devel/12 12/1/03 5:55p btan |
|---|
| 55 | * Added BSCD_Channel_ResetBlockWaitTimer. |
|---|
| 56 | * |
|---|
| 57 | * Hydra_Software_Devel/11 11/26/03 4:59p btan |
|---|
| 58 | * Fixes for EMV T=0 |
|---|
| 59 | * |
|---|
| 60 | * Hydra_Software_Devel/9 11/18/03 5:04p btan |
|---|
| 61 | * Fixed a typo. |
|---|
| 62 | * |
|---|
| 63 | * Hydra_Software_Devel/8 10/13/03 12:05p btan |
|---|
| 64 | * updated to latest version. |
|---|
| 65 | * |
|---|
| 66 | * Hydra_Software_Devel/7 9/17/03 4:49p lseverin |
|---|
| 67 | * fixed a few documentation warnings |
|---|
| 68 | * |
|---|
| 69 | * Hydra_Software_Devel/6 7/23/03 5:40p btan |
|---|
| 70 | * Added some functions headers. |
|---|
| 71 | * |
|---|
| 72 | * Hydra_Software_Devel/5 7/21/03 6:28p btan |
|---|
| 73 | * Updated after 1st review. |
|---|
| 74 | * |
|---|
| 75 | * Hydra_Software_Devel/3 6/10/03 5:56p btan |
|---|
| 76 | * Fixed some comments. |
|---|
| 77 | * |
|---|
| 78 | * Hydra_Software_Devel/2 6/5/03 6:48p btan |
|---|
| 79 | * Correct some comments. |
|---|
| 80 | * |
|---|
| 81 | * Hydra_Software_Devel/1 6/5/03 4:58p btan |
|---|
| 82 | * Initial creation for 7038 |
|---|
| 83 | * |
|---|
| 84 | ***************************************************************************/ |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | /*================== Module Overview ===================================== |
|---|
| 88 | <verbatim> |
|---|
| 89 | |
|---|
| 90 | Module Overview |
|---|
| 91 | The Smart Card (SCD) API is a porting interface(PI) module which |
|---|
| 92 | allows status/control of smart card communication. |
|---|
| 93 | |
|---|
| 94 | |
|---|
| 95 | |
|---|
| 96 | Usage |
|---|
| 97 | Since most of the chips and reference designs can support multiple identical and |
|---|
| 98 | completely indepedent smart card interfaces, SCD shall control multiple |
|---|
| 99 | smartcard channels with different settings concurrently. However, the whole system |
|---|
| 100 | should have only one module handle. |
|---|
| 101 | |
|---|
| 102 | During system initialization, the system may first call BSCD_GetDefaultSettings |
|---|
| 103 | to acquire the default settings for the smart card module. The sytem shall then |
|---|
| 104 | call BSCD_Open to create a module handle. It may call |
|---|
| 105 | BSCD_GetChannelDefaultSettings to retrieve the default settings for the |
|---|
| 106 | specific smart card channel and BSCD_Channel_Open to create a channel handle. |
|---|
| 107 | The sytem shall reset and configure the channel and detect the smart card. |
|---|
| 108 | Upon receiving ATR (Answer To Reset) data after the sytem reset the smart card, |
|---|
| 109 | the system can then communcate with smart card associated with this |
|---|
| 110 | channel. All the I/O data shall be automically processed according to the inverse |
|---|
| 111 | or direct convention. During system shutdown, the system shall call |
|---|
| 112 | BSCD_Channel_Close to close this channel and call BSCD_Close to close the |
|---|
| 113 | smart card module. |
|---|
| 114 | |
|---|
| 115 | Each channel can support ISO 7816 asynchronous T=0 and T=1 modes with |
|---|
| 116 | 264-byte UART receive and transmit buffers. Each channel can have different baud |
|---|
| 117 | rate but all channels have to use either internal clock or external clock. SCD |
|---|
| 118 | could defines various smart card timing and error management registers to conform |
|---|
| 119 | to different standards with minimal CPU overhead and interrupt latency. SCD should |
|---|
| 120 | be able to support NDS, EMV 1996, ARIB and ISO smart card standards. |
|---|
| 121 | |
|---|
| 122 | SCD is expected to be able to support various smart card standards, therefore it |
|---|
| 123 | is designed to be as much standard independent as possible. Application is expected |
|---|
| 124 | to be standard awareness and to handle all the standard comformance requirements. |
|---|
| 125 | |
|---|
| 126 | The caller usually first calls SCD to setup the related registers to receive ATR. |
|---|
| 127 | The caller then interprets ATR and setup the registers again for transmitting |
|---|
| 128 | and receiving data. Since all these scenarioes occur sequentially and |
|---|
| 129 | synchronously, there is no reason for the caller to call more than one |
|---|
| 130 | SCD functions to access one channel concurrently with multiple threads. |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | Sample Code: |
|---|
| 134 | Please refer to the functions BSCD_CLI_T0Test( ) or BSCD_CLI_T1Test( ) in |
|---|
| 135 | bscd_cli_infra.c. |
|---|
| 136 | |
|---|
| 137 | |
|---|
| 138 | </verbatim> |
|---|
| 139 | ***************************************************************************/ |
|---|
| 140 | |
|---|
| 141 | |
|---|
| 142 | #ifndef BSCD_H__ |
|---|
| 143 | #define BSCD_H__ |
|---|
| 144 | |
|---|
| 145 | #include "bchp.h" |
|---|
| 146 | #include "breg_mem.h" |
|---|
| 147 | #include "bint.h" |
|---|
| 148 | #include "bscd_datatypes.h" |
|---|
| 149 | |
|---|
| 150 | #ifdef __cplusplus |
|---|
| 151 | extern "C" { |
|---|
| 152 | #endif |
|---|
| 153 | |
|---|
| 154 | /*************************************************************************** |
|---|
| 155 | Summary: |
|---|
| 156 | Smart Card (SCD) module context handle. |
|---|
| 157 | |
|---|
| 158 | Description: |
|---|
| 159 | Opaque handle that is created in BSCD_Open. |
|---|
| 160 | BSCD_Handle holds the context of the smart card module. The system |
|---|
| 161 | should have only one BSCD_Handle. Caller of BSCD_Open is responsible to store |
|---|
| 162 | this BSCD_Handle and uses it for the future function call after BSCD_Open function |
|---|
| 163 | returns successfully. |
|---|
| 164 | |
|---|
| 165 | See Also: |
|---|
| 166 | BSCD_Open, BSCD_Channel_Open |
|---|
| 167 | |
|---|
| 168 | ****************************************************************************/ |
|---|
| 169 | typedef struct BSCD_P_Handle *BSCD_Handle; |
|---|
| 170 | |
|---|
| 171 | |
|---|
| 172 | /*************************************************************************** |
|---|
| 173 | Summary: |
|---|
| 174 | SCD channel context handle. |
|---|
| 175 | |
|---|
| 176 | Description: |
|---|
| 177 | Opaque handle that is created in BSCD_Channel_Open. |
|---|
| 178 | BSCD_ChannelHandle holds the context of the smart card channel. The system |
|---|
| 179 | could have more than one BSCD_ChannelHandle if the chip can support multiple |
|---|
| 180 | smartcard interfaces/channels. Caller of BSCD_Channel_Open is responsible |
|---|
| 181 | to store this BSCD_ChannelHandle and uses it for the future function call after |
|---|
| 182 | BSCD_Channel_Open function returns successfully. |
|---|
| 183 | |
|---|
| 184 | See Also: |
|---|
| 185 | BSCD_Open, BSCD_Channel_Open |
|---|
| 186 | |
|---|
| 187 | ****************************************************************************/ |
|---|
| 188 | typedef struct BSCD_P_ChannelHandle *BSCD_ChannelHandle; |
|---|
| 189 | |
|---|
| 190 | |
|---|
| 191 | /*************************************************************************** |
|---|
| 192 | Summary: |
|---|
| 193 | Required default settings structure for smart card module. |
|---|
| 194 | |
|---|
| 195 | Description: |
|---|
| 196 | The default setting structure that defines the default configure of |
|---|
| 197 | smart card module when the module is initialized. |
|---|
| 198 | |
|---|
| 199 | See Also: |
|---|
| 200 | BSCD_GetDefaultSettings, BSCD_Open. |
|---|
| 201 | |
|---|
| 202 | ****************************************************************************/ |
|---|
| 203 | typedef struct BSCD_Settings BSCD_Settings; |
|---|
| 204 | |
|---|
| 205 | |
|---|
| 206 | |
|---|
| 207 | /** |
|---|
| 208 | Smart Card Interrupt Callback function. |
|---|
| 209 | **/ |
|---|
| 210 | typedef void (*BSCD_IsrCallbackFunc)( BSCD_ChannelHandle in_channelHandle, void * inp_data ); |
|---|
| 211 | |
|---|
| 212 | /*************************************************************************** |
|---|
| 213 | Summary: |
|---|
| 214 | Required default settings structure for smart card channel. |
|---|
| 215 | |
|---|
| 216 | Description: |
|---|
| 217 | The default setting structure defines the default configure of |
|---|
| 218 | smart card interface/channel when the interface is open. Since SCD |
|---|
| 219 | could support multiple smart card interfaces/channels, system may have |
|---|
| 220 | more than one default channel settings that each channel may have |
|---|
| 221 | different default channel settings. |
|---|
| 222 | |
|---|
| 223 | See Also: |
|---|
| 224 | BSCD_GetChannelDefaultSettings, BSCD_Channel_Open |
|---|
| 225 | |
|---|
| 226 | ****************************************************************************/ |
|---|
| 227 | typedef struct BSCD_ChannelSettings BSCD_ChannelSettings; |
|---|
| 228 | |
|---|
| 229 | |
|---|
| 230 | /*************************************************************************** |
|---|
| 231 | Summary: |
|---|
| 232 | Smart Card Interrupt Callback function. |
|---|
| 233 | |
|---|
| 234 | Description: |
|---|
| 235 | Caller of BSCD shall call BSCD_Channel_EnableIntrCallback_isr |
|---|
| 236 | to register and enable the callback. BSCD shall call |
|---|
| 237 | |
|---|
| 238 | See Also: |
|---|
| 239 | BSCD_Channel_EnableIntrCallback_isr |
|---|
| 240 | ****************************************************************************/ |
|---|
| 241 | typedef void (* BICM_CallbackFunc)( void * inp_parm1, int in_parm2 ); |
|---|
| 242 | |
|---|
| 243 | |
|---|
| 244 | /* Basic Module Functions */ |
|---|
| 245 | |
|---|
| 246 | /***************************************************************************** |
|---|
| 247 | Summary: |
|---|
| 248 | This function shall return a recommended default settings for SCD module. |
|---|
| 249 | |
|---|
| 250 | Description: |
|---|
| 251 | This function shall return a recommended default settings for SCD module. |
|---|
| 252 | This function shall be called before BSCD_Open |
|---|
| 253 | and the caller can then over-ride any of the default settings |
|---|
| 254 | required for the build and configuration by calling BSCD_Open. |
|---|
| 255 | |
|---|
| 256 | These default settings are always the same regardless of how |
|---|
| 257 | many times this function is called or what other functions have |
|---|
| 258 | been called in the porting interface. |
|---|
| 259 | |
|---|
| 260 | Calling Context: |
|---|
| 261 | The function shall be called from application level (for example in |
|---|
| 262 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 263 | recommended ioctl: BSCD_IOCTL_GET_DEFAULT_SETTINGS or during insmod) |
|---|
| 264 | |
|---|
| 265 | Performance and Synchronization: |
|---|
| 266 | This is a synchronous function that will return when it is done. |
|---|
| 267 | |
|---|
| 268 | Input: |
|---|
| 269 | in_chipHandle - BCHP_Handle, chip handle. |
|---|
| 270 | |
|---|
| 271 | Output: |
|---|
| 272 | outp_sSettings - BSCD_Settings, a ref/pointer to the default setting. |
|---|
| 273 | |
|---|
| 274 | Returns: |
|---|
| 275 | BERR_SUCCESS - Always return success. |
|---|
| 276 | |
|---|
| 277 | See Also: |
|---|
| 278 | BSCD_Open |
|---|
| 279 | |
|---|
| 280 | *****************************************************************************/ |
|---|
| 281 | BERR_Code BSCD_GetDefaultSettings( |
|---|
| 282 | BSCD_Settings *outp_sSettings, |
|---|
| 283 | BCHP_Handle in_chipHandle |
|---|
| 284 | ); |
|---|
| 285 | |
|---|
| 286 | |
|---|
| 287 | /***************************************************************************** |
|---|
| 288 | Summary: |
|---|
| 289 | This function creates the smart card module handle. |
|---|
| 290 | |
|---|
| 291 | Description: |
|---|
| 292 | This function shall create the smart card module handle. |
|---|
| 293 | It also initializes the smart card module |
|---|
| 294 | and hardware using settings stored in the p_Settings pointer. |
|---|
| 295 | All the associated channels are not ready to be access until |
|---|
| 296 | BSCD_ChannelOpen is called and returns successfully. |
|---|
| 297 | |
|---|
| 298 | The caller can pass a NULL pointer for inp_sSettings. If the |
|---|
| 299 | p_Settings pointer is NULL, default settings should be used. |
|---|
| 300 | |
|---|
| 301 | It is the caller responsibility to store the outp_handle and uses |
|---|
| 302 | it for the future function call after this function returns |
|---|
| 303 | successfully. If this function returns successfully, outp_handle shall |
|---|
| 304 | not be NULL. |
|---|
| 305 | |
|---|
| 306 | Before calling this function, the only function that the caller |
|---|
| 307 | can call is BSCD_GetDefaultSettings. System shall not call |
|---|
| 308 | any other smart card functions prior to this function. |
|---|
| 309 | |
|---|
| 310 | System shall not call this function more than once without calling BSCD_Close |
|---|
| 311 | previously. |
|---|
| 312 | |
|---|
| 313 | If illegal settings are passed in an error should be |
|---|
| 314 | returned and the hardware state should not be modified. |
|---|
| 315 | |
|---|
| 316 | The BINT_Handle is only required if this module needs to |
|---|
| 317 | associate ISR callback routines with L2 interrupts. |
|---|
| 318 | |
|---|
| 319 | Calling Context: |
|---|
| 320 | The function shall be called from application level (for example in |
|---|
| 321 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 322 | during insmod ) |
|---|
| 323 | |
|---|
| 324 | Performance and Synchronization: |
|---|
| 325 | This is a synchronous function that will return when it is done. |
|---|
| 326 | |
|---|
| 327 | Input: |
|---|
| 328 | in_regHandle - BREG_Handle, use to access smart card register. |
|---|
| 329 | in_chipHandle - BCHP_Handle, Chip handle. |
|---|
| 330 | in_interruptHandle - BINT_Handle, Interrupt handle to handle smart card |
|---|
| 331 | interrupt. |
|---|
| 332 | inp_sSettings - BSCD_Settings, the settings that apply to smart card module |
|---|
| 333 | If NULL, a default setting shall be used. |
|---|
| 334 | |
|---|
| 335 | Output: |
|---|
| 336 | outp_handle - BSCD_Handle, a ref/pointer to the smart card module handle. |
|---|
| 337 | It shall not be NULL if this function returns successfully. |
|---|
| 338 | |
|---|
| 339 | Returns: |
|---|
| 340 | BERR_SUCCESS - success |
|---|
| 341 | BERR_OUT_OF_SYSTEM_MEMORY - out of system memory |
|---|
| 342 | |
|---|
| 343 | See Also: |
|---|
| 344 | BSCD_GetDefaultSettings |
|---|
| 345 | BSCD_Close |
|---|
| 346 | |
|---|
| 347 | *****************************************************************************/ |
|---|
| 348 | BERR_Code BSCD_Open( |
|---|
| 349 | BSCD_Handle *outp_handle, |
|---|
| 350 | BREG_Handle in_regHandle, |
|---|
| 351 | BCHP_Handle in_chipHandle, |
|---|
| 352 | BINT_Handle in_interruptHandle, |
|---|
| 353 | const BSCD_Settings *inp_sSettings |
|---|
| 354 | ); |
|---|
| 355 | |
|---|
| 356 | |
|---|
| 357 | /***************************************************************************** |
|---|
| 358 | Summary: |
|---|
| 359 | This function frees the main handle and any resources contained |
|---|
| 360 | in the main handle. |
|---|
| 361 | |
|---|
| 362 | Description: |
|---|
| 363 | This function shall free the main handle and any resources contained |
|---|
| 364 | in the main handle. This function shall try to free any resources associated |
|---|
| 365 | with sub handles created from the main handle. However, this function does not |
|---|
| 366 | free any resources associated with channel handle. |
|---|
| 367 | |
|---|
| 368 | Regardless of the return value, this function always attempts to free all |
|---|
| 369 | the allocated resources and inout_handle shall be NULL. |
|---|
| 370 | |
|---|
| 371 | Other than BSCD_GetDefaultSettings, system shall not call any other smart |
|---|
| 372 | card functions after this function returns, regardless of the return result. |
|---|
| 373 | |
|---|
| 374 | Calling Context: |
|---|
| 375 | The function shall be called from application level (for example in |
|---|
| 376 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 377 | during rmmod) |
|---|
| 378 | |
|---|
| 379 | Performance and Synchronization: |
|---|
| 380 | This is a synchronous function that will return when it is done. |
|---|
| 381 | |
|---|
| 382 | Input/Output: |
|---|
| 383 | inout_handle - BSCD_Handle, smart card module handle. |
|---|
| 384 | |
|---|
| 385 | Returns: |
|---|
| 386 | BERR_SUCCESS - success |
|---|
| 387 | BSCD_STATUS_FAILED - failed. |
|---|
| 388 | |
|---|
| 389 | See Also: |
|---|
| 390 | BSCD_Open |
|---|
| 391 | BSCD_GetDefaultSettings |
|---|
| 392 | |
|---|
| 393 | ******************************************************************************/ |
|---|
| 394 | BERR_Code BSCD_Close( |
|---|
| 395 | BSCD_Handle inout_handle |
|---|
| 396 | ); |
|---|
| 397 | |
|---|
| 398 | |
|---|
| 399 | /***************************************************************************** |
|---|
| 400 | Summary: |
|---|
| 401 | This function returns the number of smart card interfaces |
|---|
| 402 | that we can support for the build and configuration. |
|---|
| 403 | |
|---|
| 404 | Description: |
|---|
| 405 | This function returns the number of smart card interfaces |
|---|
| 406 | that we can support for the build and configuration. |
|---|
| 407 | |
|---|
| 408 | The caller shall then call BSCD_Channel_Open or BSCD_GetChannelDefaultSettings |
|---|
| 409 | with in_channelNo that smaller than outp_totalChannels. |
|---|
| 410 | |
|---|
| 411 | Calling Context: |
|---|
| 412 | The function shall be called from application level (for example in |
|---|
| 413 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 414 | recommended ioctl: BSCD_IOCTL_GET_TOTAL_CHANNELS or device open ) |
|---|
| 415 | |
|---|
| 416 | Performance and Synchronization: |
|---|
| 417 | This is a synchronous function that will return when it is done. |
|---|
| 418 | |
|---|
| 419 | Input: |
|---|
| 420 | in_handle - BSCD_Handle, smart card module handle. |
|---|
| 421 | |
|---|
| 422 | Output: |
|---|
| 423 | outp_totalChannels - unsigned char, a ref/pointer to the maximum number of |
|---|
| 424 | supported smart card channel handles. |
|---|
| 425 | |
|---|
| 426 | Returns: |
|---|
| 427 | BERR_SUCCESS - success |
|---|
| 428 | BSCD_STATUS_FAILED - failed. |
|---|
| 429 | |
|---|
| 430 | See Also: |
|---|
| 431 | BSCD_GetChannelDefaultSettings |
|---|
| 432 | BSCD_Channel_Open |
|---|
| 433 | |
|---|
| 434 | ******************************************************************************/ |
|---|
| 435 | BERR_Code BSCD_GetTotalChannels( |
|---|
| 436 | BSCD_Handle in_handle, |
|---|
| 437 | unsigned char *outp_ucTotalChannels |
|---|
| 438 | ); |
|---|
| 439 | |
|---|
| 440 | |
|---|
| 441 | /***************************************************************************** |
|---|
| 442 | Summary: |
|---|
| 443 | This function shall return a recommended default settings for SCD channel. |
|---|
| 444 | |
|---|
| 445 | Description: |
|---|
| 446 | This function shall return a recommended default settings for SCD channel. |
|---|
| 447 | This function shall be called before BSCD_Channel_Open |
|---|
| 448 | and the caller can then over-ride any of the default settings |
|---|
| 449 | required for the build and configuration by calling BSCD_Channel_Open |
|---|
| 450 | or BSCD_Channel_ResetIFD. |
|---|
| 451 | |
|---|
| 452 | The caller shall pass in_channelNo that is smaller outp_totalChannels in |
|---|
| 453 | BSCD_GetTotalChannels. The in_channelNo for the first channel shall be zero. |
|---|
| 454 | |
|---|
| 455 | These default settings are always the same regardless of how |
|---|
| 456 | many times this function is called or what other functions have |
|---|
| 457 | been called in the porting interface. |
|---|
| 458 | |
|---|
| 459 | Calling Context: |
|---|
| 460 | The function shall be called from application level (for example in |
|---|
| 461 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 462 | recommended ioctl: BSCD_IOCTL_GET_CHANNEL_DEFAULT_SETTINGS |
|---|
| 463 | or device open ) |
|---|
| 464 | |
|---|
| 465 | Performance and Synchronization: |
|---|
| 466 | This is a synchronous function that will return when it is done. |
|---|
| 467 | |
|---|
| 468 | Input: |
|---|
| 469 | in_handle - BSCD_Handle, smart card module handle. |
|---|
| 470 | in_channelNo - unsigned int, an index that indicates which channel or smart |
|---|
| 471 | card interface that the caller want to access. |
|---|
| 472 | Output: |
|---|
| 473 | outp_sSettings - BSCD_ChannelSettings, a ref/pointer to the default channel |
|---|
| 474 | setting. |
|---|
| 475 | |
|---|
| 476 | Returns: |
|---|
| 477 | BERR_SUCCESS - success |
|---|
| 478 | BSCD_STATUS_FAILED - failed. |
|---|
| 479 | BERR_INVALID_PARAMETER - in_channelNo is invalid. |
|---|
| 480 | |
|---|
| 481 | See Also: |
|---|
| 482 | BSCD_Open |
|---|
| 483 | BSCD_GetTotalChannels |
|---|
| 484 | BSCD_Channel_Open |
|---|
| 485 | |
|---|
| 486 | *****************************************************************************/ |
|---|
| 487 | BERR_Code BSCD_GetChannelDefaultSettings( |
|---|
| 488 | BSCD_Handle in_handle, |
|---|
| 489 | unsigned int in_channelNo, |
|---|
| 490 | BSCD_ChannelSettings *outp_sSettings |
|---|
| 491 | ); |
|---|
| 492 | |
|---|
| 493 | |
|---|
| 494 | /***************************************************************************** |
|---|
| 495 | Summary: |
|---|
| 496 | This function creates the smart card channel handle. |
|---|
| 497 | |
|---|
| 498 | Description: |
|---|
| 499 | This function shall create the smart card channel handle. |
|---|
| 500 | It also initializes the specified smart card interface, all the associated |
|---|
| 501 | channels and hardware using settings stored in the inp_channelDefSettings |
|---|
| 502 | pointer. |
|---|
| 503 | |
|---|
| 504 | The caller shall pass in_channelNo that is smaller outp_totalChannels in |
|---|
| 505 | BSCD_GetTotalChannels. The in_channelNo for the first channel shall be zero. |
|---|
| 506 | |
|---|
| 507 | The caller can pass a NULL pointer for inp_channelDefSettings. If the |
|---|
| 508 | inp_channelDefSettings pointer is NULL, default settings should be used. |
|---|
| 509 | |
|---|
| 510 | It is the caller responsibility to store the outp_channelHandle and uses |
|---|
| 511 | it for the future function call after this function returns |
|---|
| 512 | successfully. If this function returns successfully, outp_handle shall |
|---|
| 513 | not be NULL. |
|---|
| 514 | |
|---|
| 515 | Before calling this function, the only channel related functions that |
|---|
| 516 | the system can call are BSCD_GetTotalChannels and |
|---|
| 517 | BSCD_GetChannelDefaultSettings. System shall not call any other channel |
|---|
| 518 | related functions prior to this function. |
|---|
| 519 | |
|---|
| 520 | System shall not call this function more than once without calling |
|---|
| 521 | BSCD_Channel_Close previously. |
|---|
| 522 | |
|---|
| 523 | If illegal settings are passed in an error should be |
|---|
| 524 | returned and the hardware state should not be modified. |
|---|
| 525 | |
|---|
| 526 | Calling Context: |
|---|
| 527 | The function shall be called from application level (for example in |
|---|
| 528 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 529 | device open) |
|---|
| 530 | |
|---|
| 531 | Performance and Synchronization: |
|---|
| 532 | This is a synchronous function that will return when it is done. |
|---|
| 533 | |
|---|
| 534 | Input: |
|---|
| 535 | in_handle - BSCD_Handle, smart card module handle. |
|---|
| 536 | in_channelNo - unsigned int, an index that indicates which channel or smart |
|---|
| 537 | card interface that the caller want to access. |
|---|
| 538 | inp_channelDefSettings - BSCD_ChannelSettings, the channel settings that |
|---|
| 539 | apply to this specific channel. If NULL, a default |
|---|
| 540 | channel setting shall be used. |
|---|
| 541 | |
|---|
| 542 | Output: |
|---|
| 543 | outp_channelHandle - BSCD_ChannelHandle, a ref/pointer to the smart |
|---|
| 544 | card channel handle. |
|---|
| 545 | |
|---|
| 546 | Returns: |
|---|
| 547 | BERR_SUCCESS - success |
|---|
| 548 | BSCD_STATUS_FAILED - failed. |
|---|
| 549 | BERR_INVALID_PARAMETER - in_channelNo or part of inp_channelDefSettings |
|---|
| 550 | is invalid. |
|---|
| 551 | |
|---|
| 552 | See Also: |
|---|
| 553 | BSCD_Open |
|---|
| 554 | BSCD_GetTotalChannels |
|---|
| 555 | BSCD_Channel_Close |
|---|
| 556 | |
|---|
| 557 | *****************************************************************************/ |
|---|
| 558 | BERR_Code BSCD_Channel_Open( |
|---|
| 559 | BSCD_Handle in_handle, |
|---|
| 560 | BSCD_ChannelHandle *outp_channelHandle, |
|---|
| 561 | unsigned int in_channelNo, |
|---|
| 562 | const BSCD_ChannelSettings *inp_channelDefSettings |
|---|
| 563 | ); |
|---|
| 564 | |
|---|
| 565 | /***************************************************************************** |
|---|
| 566 | Summary: |
|---|
| 567 | This function frees the channel handle and any resources contained |
|---|
| 568 | in the channel handle. |
|---|
| 569 | |
|---|
| 570 | Description: |
|---|
| 571 | This function shall free the channel handle and any resources contained |
|---|
| 572 | in the channel handle. |
|---|
| 573 | |
|---|
| 574 | Regardless of the return value, this function always attempts to free all |
|---|
| 575 | the allocated resources and inout_channelHandle shall be NULL. |
|---|
| 576 | |
|---|
| 577 | Other than BSCD_GetTotalChannels and BSCD_GetChannelDefaultSettings, system |
|---|
| 578 | shall not call any other channel related functions after this function returns, |
|---|
| 579 | regardless of the return result. |
|---|
| 580 | |
|---|
| 581 | Calling Context: |
|---|
| 582 | The function shall be called from application level (for example in |
|---|
| 583 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 584 | device close) |
|---|
| 585 | |
|---|
| 586 | Performance and Synchronization: |
|---|
| 587 | This is a synchronous function that will return when it is done. |
|---|
| 588 | |
|---|
| 589 | Input/output: |
|---|
| 590 | inout_channelHandle - BSCD_ChannelHandle, smart card channel handle. |
|---|
| 591 | |
|---|
| 592 | Returns: |
|---|
| 593 | BERR_SUCCESS - success |
|---|
| 594 | BSCD_STATUS_FAILED - failed. |
|---|
| 595 | |
|---|
| 596 | See Also: |
|---|
| 597 | BSCD_Channel_Open |
|---|
| 598 | |
|---|
| 599 | ******************************************************************************/ |
|---|
| 600 | BERR_Code BSCD_Channel_Close( |
|---|
| 601 | BSCD_ChannelHandle inout_channelHandle |
|---|
| 602 | ); |
|---|
| 603 | |
|---|
| 604 | |
|---|
| 605 | /***************************************************************************** |
|---|
| 606 | Summary: |
|---|
| 607 | This function gets the module handle based on the channel handle. |
|---|
| 608 | |
|---|
| 609 | Description: |
|---|
| 610 | This function shall get the module handle based on the channel handle. |
|---|
| 611 | If this function returns successfully, outp_handle shall not be NULL. |
|---|
| 612 | |
|---|
| 613 | Calling Context: |
|---|
| 614 | The function shall be called from application level (for example in |
|---|
| 615 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 616 | recommended ioctl: BSCD_IOCTL_GET_DEVICE) |
|---|
| 617 | |
|---|
| 618 | Performance and Synchronization: |
|---|
| 619 | This is a synchronous function that will return when it is done. |
|---|
| 620 | |
|---|
| 621 | Input: |
|---|
| 622 | in_channelHandle - BSCD_ChannelHandle, smart card channel handle. |
|---|
| 623 | |
|---|
| 624 | Output: |
|---|
| 625 | outp_handle - BSCD_Handle, a ref/pointer to the smart card module handle. |
|---|
| 626 | |
|---|
| 627 | Returns: |
|---|
| 628 | BERR_SUCCESS - success |
|---|
| 629 | BSCD_STATUS_FAILED - failed. |
|---|
| 630 | |
|---|
| 631 | See Also: |
|---|
| 632 | BSCD_Open |
|---|
| 633 | BSCD_Channel_Open |
|---|
| 634 | |
|---|
| 635 | *****************************************************************************/ |
|---|
| 636 | BERR_Code BSCD_Channel_GetDevice( |
|---|
| 637 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 638 | BSCD_Handle *outp_handle |
|---|
| 639 | ); |
|---|
| 640 | |
|---|
| 641 | /* End of Basic Module Functions */ |
|---|
| 642 | |
|---|
| 643 | |
|---|
| 644 | /* Module Specific Functions */ |
|---|
| 645 | |
|---|
| 646 | |
|---|
| 647 | /***************************************************************************** |
|---|
| 648 | Summary: |
|---|
| 649 | This function returns a specific smart card channel handle. |
|---|
| 650 | |
|---|
| 651 | Description: |
|---|
| 652 | This function returns a specific smart card channel handle. |
|---|
| 653 | The caller shall pass in_channelNo that is smaller outp_totalChannels in |
|---|
| 654 | BSCD_GetTotalChannels. The in_channelNo for the first channel shall be zero. |
|---|
| 655 | If this function returns successfully, outp_channelHandle shall not be NULL. |
|---|
| 656 | |
|---|
| 657 | Calling Context: |
|---|
| 658 | The function shall be called from application level (for example in |
|---|
| 659 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 660 | recommended ioctl: BSCD_IOCTL_GET_CHANNEL ) |
|---|
| 661 | |
|---|
| 662 | Performance and Synchronization: |
|---|
| 663 | This is a synchronous function that will return when it is done. |
|---|
| 664 | |
|---|
| 665 | Input: |
|---|
| 666 | in_handle - BSCD_Handle, smart card module handle. |
|---|
| 667 | in_channelNo - unsigned int, an index that indicate which channel or smart card |
|---|
| 668 | inerface that the caller want to access. |
|---|
| 669 | |
|---|
| 670 | Output: |
|---|
| 671 | outp_channelHandle - BSCD_ChannelHandle, a ref/pointer to the smart card |
|---|
| 672 | channel handle. |
|---|
| 673 | |
|---|
| 674 | Returns: |
|---|
| 675 | BERR_SUCCESS - success |
|---|
| 676 | BSCD_STATUS_FAILED - failed. |
|---|
| 677 | BERR_INVALID_PARAMETER - in_channelNo is invalid. |
|---|
| 678 | |
|---|
| 679 | See Also: |
|---|
| 680 | BSCD_Open |
|---|
| 681 | BSCD_GetTotalChannels |
|---|
| 682 | BSCD_Channel_Open |
|---|
| 683 | |
|---|
| 684 | ******************************************************************************/ |
|---|
| 685 | BERR_Code BSCD_GetChannel( |
|---|
| 686 | BSCD_Handle in_handle, |
|---|
| 687 | unsigned int in_channelNo, |
|---|
| 688 | BSCD_ChannelHandle *outp_channelHandle |
|---|
| 689 | ); |
|---|
| 690 | |
|---|
| 691 | |
|---|
| 692 | /***************************************************************************** |
|---|
| 693 | Summary: |
|---|
| 694 | This function shall wait until the card is inserted or removed. |
|---|
| 695 | |
|---|
| 696 | Description: |
|---|
| 697 | This function shall wait until the card is inserted or removed. |
|---|
| 698 | |
|---|
| 699 | This function shall returns immediately either |
|---|
| 700 | 1) the card is removed and in_eCardPresent is BSCD_CardPresent_eRemoved, or |
|---|
| 701 | 2) the card is inserted and in_eCardPresent is BSCD_CardPresent_eInserted. |
|---|
| 702 | |
|---|
| 703 | This function shall be blocked until the card is inserted if the card is |
|---|
| 704 | currently removed and in_eCardPresent is BSCD_CardPresent_eInserted. |
|---|
| 705 | |
|---|
| 706 | This function shall be blocked until the card is removed if the card is |
|---|
| 707 | currently inserted and in_eCardPresent is BSCD_CardPresent_eRemoved. |
|---|
| 708 | |
|---|
| 709 | If the caller does not want to be blocked, it could use |
|---|
| 710 | BSCD_Channel_GetStatus to check the card presence status. |
|---|
| 711 | |
|---|
| 712 | Note: |
|---|
| 713 | The application may seem to be hang since this function may be blocked until |
|---|
| 714 | user inserting or removing the card. |
|---|
| 715 | |
|---|
| 716 | Calling Context: |
|---|
| 717 | The function shall be called from application level (for example in |
|---|
| 718 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 719 | recommended ioctl: BSCD_IOCTL_DETECT_CARD ) |
|---|
| 720 | |
|---|
| 721 | Performance and Synchronization: |
|---|
| 722 | This is a synchronous function that will return when it is done. |
|---|
| 723 | This function may be |
|---|
| 724 | blocked until user inserts or removes the card. Since TDA8004 does not have |
|---|
| 725 | debounce feature for the presence switches, this function may |
|---|
| 726 | wait for extra 10ms for the presence switches to be stabilized. |
|---|
| 727 | |
|---|
| 728 | Input: |
|---|
| 729 | in_channelHandle - BSCD_ChannelHandle, a specific smart |
|---|
| 730 | card channel handle. |
|---|
| 731 | in_eCardPresent - BSCD_CardPresent, indicate if the caller wants to wait |
|---|
| 732 | until the card is inserted or removed. |
|---|
| 733 | |
|---|
| 734 | Returns: |
|---|
| 735 | BERR_SUCCESS - success |
|---|
| 736 | BSCD_STATUS_FAILED - failed. |
|---|
| 737 | |
|---|
| 738 | See Also: |
|---|
| 739 | BSCD_Channel_GetStatus |
|---|
| 740 | |
|---|
| 741 | ******************************************************************************/ |
|---|
| 742 | BERR_Code BSCD_Channel_DetectCard( |
|---|
| 743 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 744 | BSCD_CardPresent in_eCardPresent |
|---|
| 745 | ); |
|---|
| 746 | |
|---|
| 747 | |
|---|
| 748 | |
|---|
| 749 | /***************************************************************************** |
|---|
| 750 | Summary: |
|---|
| 751 | This function shall modify the current smart card channel setting. |
|---|
| 752 | |
|---|
| 753 | Description: |
|---|
| 754 | This function shall modify the current smart card channel setting. For |
|---|
| 755 | better performance that this function can modify only a small set of changes, |
|---|
| 756 | it is strongly recommended that the caller should call |
|---|
| 757 | BSCD_Channel_GetParameters to retrieve the current channel setting. |
|---|
| 758 | The caller should only update the modified members in BSCD_Settings and call |
|---|
| 759 | BSCD_Channel_SetParameters to set the current setting. |
|---|
| 760 | |
|---|
| 761 | |
|---|
| 762 | Calling Context: |
|---|
| 763 | The function shall be called from application level (for example in |
|---|
| 764 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 765 | recommended ioctl: BSCD_IOCTL_SET_PARAMETERS ) |
|---|
| 766 | |
|---|
| 767 | Performance and Synchronization: |
|---|
| 768 | This is a synchronous function that will return when it is done. |
|---|
| 769 | |
|---|
| 770 | Input: |
|---|
| 771 | in_channelHandle - BSCD_ChannelHandle, a specific smart |
|---|
| 772 | card channel handle. |
|---|
| 773 | inp_sSettings - BSCD_Settings, the settings that apply to a specific |
|---|
| 774 | channel. If NULL, the function shall return an error. |
|---|
| 775 | |
|---|
| 776 | Returns: |
|---|
| 777 | BERR_SUCCESS - success |
|---|
| 778 | bxerr_InvalidArgument - inp_sSettings is NULL. |
|---|
| 779 | BSCD_STATUS_FAILED - failed. |
|---|
| 780 | |
|---|
| 781 | See Also: |
|---|
| 782 | BSCD_Channel_GetParameters |
|---|
| 783 | |
|---|
| 784 | ******************************************************************************/ |
|---|
| 785 | BERR_Code BSCD_Channel_SetParameters( |
|---|
| 786 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 787 | const BSCD_ChannelSettings *inp_sSettings |
|---|
| 788 | ); |
|---|
| 789 | |
|---|
| 790 | /***************************************************************************** |
|---|
| 791 | Summary: |
|---|
| 792 | This function retrieves the current smart card channel setting. |
|---|
| 793 | |
|---|
| 794 | Description: |
|---|
| 795 | This function shall retrieve the current smart card channel setting. If |
|---|
| 796 | necessary, the caller can call BSCD_Channel_SetParameters to modify the |
|---|
| 797 | current channel setting. |
|---|
| 798 | |
|---|
| 799 | |
|---|
| 800 | Calling Context: |
|---|
| 801 | The function shall be called from application level (for example in |
|---|
| 802 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 803 | recommended ioctl: BSCD_IOCTL_GET_PARAMETERS ) |
|---|
| 804 | |
|---|
| 805 | Performance and Synchronization: |
|---|
| 806 | This is a synchronous function that will return when it is done. |
|---|
| 807 | |
|---|
| 808 | Input: |
|---|
| 809 | in_channelHandle - BSCD_ChannelHandle, a ref/pointer to a specific smart |
|---|
| 810 | card channel handle. |
|---|
| 811 | |
|---|
| 812 | Output: |
|---|
| 813 | outp_sSettings - BSCD_Settings, the settings that apply to a specific |
|---|
| 814 | channel. |
|---|
| 815 | |
|---|
| 816 | Returns: |
|---|
| 817 | BERR_SUCCESS - success |
|---|
| 818 | BSCD_STATUS_FAILED - failed. |
|---|
| 819 | |
|---|
| 820 | See Also: |
|---|
| 821 | BSCD_Channel_SetParameters |
|---|
| 822 | |
|---|
| 823 | ******************************************************************************/ |
|---|
| 824 | BERR_Code BSCD_Channel_GetParameters( |
|---|
| 825 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 826 | BSCD_ChannelSettings *outp_sSettings |
|---|
| 827 | ); |
|---|
| 828 | |
|---|
| 829 | /***************************************************************************** |
|---|
| 830 | Summary: |
|---|
| 831 | This function retrieves the current smart card channel number. |
|---|
| 832 | |
|---|
| 833 | Description: |
|---|
| 834 | This function shall retrieve the current smart card channel number. |
|---|
| 835 | |
|---|
| 836 | Calling Context: |
|---|
| 837 | The function shall be called from application level (for example in |
|---|
| 838 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 839 | recommended ioctl: BSCD_IOCTL_GET_CHANNEL_NUMBER ) |
|---|
| 840 | |
|---|
| 841 | Performance and Synchronization: |
|---|
| 842 | This is a synchronous function that will return when it is done. |
|---|
| 843 | |
|---|
| 844 | Input: |
|---|
| 845 | in_channelHandle - BSCD_ChannelHandle, a ref/pointer to a specific smart |
|---|
| 846 | card channel handle. |
|---|
| 847 | |
|---|
| 848 | Output: |
|---|
| 849 | outp_ucChannelNumber - unsigned char, the settings that apply to a specific |
|---|
| 850 | . |
|---|
| 851 | |
|---|
| 852 | Returns: |
|---|
| 853 | Channel number, where 0 is the first channel. If it fails, the return values is -1. |
|---|
| 854 | |
|---|
| 855 | See Also: |
|---|
| 856 | |
|---|
| 857 | ******************************************************************************/ |
|---|
| 858 | char BSCD_Channel_GetChannelNumber( |
|---|
| 859 | BSCD_ChannelHandle in_channelHandle |
|---|
| 860 | ); |
|---|
| 861 | |
|---|
| 862 | /***************************************************************************** |
|---|
| 863 | Summary: |
|---|
| 864 | This function deativates the specific smart card interface. |
|---|
| 865 | |
|---|
| 866 | Description: |
|---|
| 867 | This function shall deativate the specific smart card interface. The |
|---|
| 868 | deactivation sequence shall be: |
|---|
| 869 | |
|---|
| 870 | o Set SC_VCC high |
|---|
| 871 | o Set SC_RST low |
|---|
| 872 | o Disable SC_CLK |
|---|
| 873 | o IO is unconditionally driver low. |
|---|
| 874 | |
|---|
| 875 | The caller shall call BSCD_Channel_ResetIFD to reset a specific smart card |
|---|
| 876 | channel. |
|---|
| 877 | |
|---|
| 878 | Calling Context: |
|---|
| 879 | The function shall be called from application level (for example in |
|---|
| 880 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 881 | recommended ioctl: BSCD_IOCTL_DEACTIVATE ) |
|---|
| 882 | |
|---|
| 883 | Performance and Synchronization: |
|---|
| 884 | This is a synchronous function that will return when it is done. |
|---|
| 885 | |
|---|
| 886 | Input: |
|---|
| 887 | in_channelHandle - BSCD_ChannelHandle, a specific smart |
|---|
| 888 | card channel handle. |
|---|
| 889 | |
|---|
| 890 | Returns: |
|---|
| 891 | BERR_SUCCESS - success |
|---|
| 892 | To Do: Need more error code |
|---|
| 893 | |
|---|
| 894 | See Also: |
|---|
| 895 | BSCD_Channel_PowerICC |
|---|
| 896 | BSCD_Channel_ResetIFD |
|---|
| 897 | |
|---|
| 898 | ******************************************************************************/ |
|---|
| 899 | BERR_Code BSCD_Channel_Deactivate( |
|---|
| 900 | BSCD_ChannelHandle in_channelHandle |
|---|
| 901 | ); |
|---|
| 902 | |
|---|
| 903 | |
|---|
| 904 | /***************************************************************************** |
|---|
| 905 | Summary: |
|---|
| 906 | This function reset a specific smart card interface (IFD). |
|---|
| 907 | |
|---|
| 908 | Description: |
|---|
| 909 | This function shall reset a specific smart card interface (IFD). It shall |
|---|
| 910 | not reset the smart card (ICC). This function shall reset the channel and |
|---|
| 911 | apply the settings stored in the p_Settings pointer to the channel and |
|---|
| 912 | hardware. |
|---|
| 913 | |
|---|
| 914 | This function shall reset the smart card interface in the following sequence: |
|---|
| 915 | Set SC_VCC high (Only Cold Reset) |
|---|
| 916 | Enable SC_CLK |
|---|
| 917 | Set SC_RST high |
|---|
| 918 | Reset UART transmit and receive buffer. |
|---|
| 919 | |
|---|
| 920 | No ATR data shall be received after this call since IO is yet to be |
|---|
| 921 | enabled. BSCD_Channel_PowerICC with ResetICC option shall activate |
|---|
| 922 | the card so that the interface is ready to receive ATR. |
|---|
| 923 | |
|---|
| 924 | For TDA8004 emergency deactivation, we could use this function or |
|---|
| 925 | BSCD_Channel_PowerICC with BSCD_ICCAction_ePowerUp |
|---|
| 926 | to set SC_VCC high after we realize the smart card is no longer present. |
|---|
| 927 | This will set the SC_VCC high and the next BSCD_Channel_GetStatus will show the |
|---|
| 928 | correct presence of the card or next BSCD_Channel_DetectCard will response |
|---|
| 929 | correctly. The presence of card is unknown if this function is not called |
|---|
| 930 | after TDA8004 emergency deactivation. |
|---|
| 931 | |
|---|
| 932 | The caller shall call BSCD_Channel_Deactivate to deactivate a specific smart |
|---|
| 933 | card channel. The caller shall call BSCD_Reset to reset all the channels. |
|---|
| 934 | |
|---|
| 935 | |
|---|
| 936 | Calling Context: |
|---|
| 937 | The function shall be called from application level (for example in |
|---|
| 938 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 939 | recommended ioctl: BSCD_IOCTL_RESET_CHANNEL ) |
|---|
| 940 | |
|---|
| 941 | Performance and Synchronization: |
|---|
| 942 | This is a synchronous function that will return when it is done. |
|---|
| 943 | |
|---|
| 944 | Input: |
|---|
| 945 | in_channelHandle - BSCD_ChannelHandle, a ref/pointer to the smart card |
|---|
| 946 | channel handle. |
|---|
| 947 | |
|---|
| 948 | Returns: |
|---|
| 949 | BERR_SUCCESS - success |
|---|
| 950 | To Do: Need more error code |
|---|
| 951 | |
|---|
| 952 | |
|---|
| 953 | See Also: |
|---|
| 954 | BSCD_Channel_PowerICC |
|---|
| 955 | BSCD_Channel_Deactivate |
|---|
| 956 | |
|---|
| 957 | ******************************************************************************/ |
|---|
| 958 | BERR_Code BSCD_Channel_ResetIFD( |
|---|
| 959 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 960 | BSCD_ResetType in_resetType |
|---|
| 961 | |
|---|
| 962 | ); |
|---|
| 963 | |
|---|
| 964 | |
|---|
| 965 | /***************************************************************************** |
|---|
| 966 | Summary: |
|---|
| 967 | This function shall set SC_VCC high, low or reset the smart card. |
|---|
| 968 | |
|---|
| 969 | Description: |
|---|
| 970 | There are 3 options to be selected in this function. |
|---|
| 971 | |
|---|
| 972 | If in_iccAction is BSCD_ICCAction_ePowerUp, this function shall set SC_VCC |
|---|
| 973 | high. System should call this function so that the next BSCD_Channel_GetStatus |
|---|
| 974 | will show the correct presence of the card or next BSCD_Channel_DetectCard |
|---|
| 975 | will response correctly after TDA8004 emergency deactivation. |
|---|
| 976 | |
|---|
| 977 | If in_iccAction is BSCD_ICCAction_ePowerDown, this function shall set SC_VCC |
|---|
| 978 | low. The next BSCD_Channel_GetStatus may not show the correct presence of the |
|---|
| 979 | card or next BSCD_Channel_DetectCard may not response correctly after |
|---|
| 980 | TDA8004 emergency deactivation. |
|---|
| 981 | |
|---|
| 982 | Calling Context: |
|---|
| 983 | The function shall be called from application level (for example in |
|---|
| 984 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 985 | recommended ioctl: BSCD_IOCTL_Power_ICC ) |
|---|
| 986 | |
|---|
| 987 | Performance and Synchronization: |
|---|
| 988 | This is a synchronous function that will return when it is done. |
|---|
| 989 | |
|---|
| 990 | Input: |
|---|
| 991 | in_channelHandle - BSCD_ChannelHandle, smart card |
|---|
| 992 | channel handle. |
|---|
| 993 | in_iccAction - BSCD_ICCAction, the settings that apply to a specific |
|---|
| 994 | channel. If NULL, the interface shall be reset with the |
|---|
| 995 | current setting. |
|---|
| 996 | |
|---|
| 997 | Returns: |
|---|
| 998 | BERR_SUCCESS - success |
|---|
| 999 | To Do: Need more error code |
|---|
| 1000 | |
|---|
| 1001 | |
|---|
| 1002 | See Also: |
|---|
| 1003 | BSCD_Channel_PowerICC |
|---|
| 1004 | BSCD_Channel_Deactivate |
|---|
| 1005 | BSCD_Channel_Receive |
|---|
| 1006 | |
|---|
| 1007 | ******************************************************************************/ |
|---|
| 1008 | BERR_Code BSCD_Channel_PowerICC( |
|---|
| 1009 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1010 | BSCD_PowerICC in_iccAction |
|---|
| 1011 | ); |
|---|
| 1012 | |
|---|
| 1013 | /***************************************************************************** |
|---|
| 1014 | Summary: |
|---|
| 1015 | This function set voltage level for smart card interface. |
|---|
| 1016 | |
|---|
| 1017 | Description: |
|---|
| 1018 | We have to modify the board to use VPP pin of smartcard and connect it to pin 3 (3V/5V) of TDA chip |
|---|
| 1019 | and run this function. Make sure to disconnect your QAM or QPSK connection before calling this function |
|---|
| 1020 | or your smartcard will be damaged. |
|---|
| 1021 | |
|---|
| 1022 | We also have to use proper voltage card for test when we change smart card interface voltage. |
|---|
| 1023 | ( 3v card for 3v Smart Card interface, 5v card for 5v Smart Card interface ). |
|---|
| 1024 | By default the Smart Card iterface is set 5V. |
|---|
| 1025 | |
|---|
| 1026 | Calling Context: |
|---|
| 1027 | The function shall be called from application level (for example in |
|---|
| 1028 | VxWorks or no-os) or from driver level |
|---|
| 1029 | |
|---|
| 1030 | Performance and Synchronization: |
|---|
| 1031 | This is a synchronous function that will return when it is done. |
|---|
| 1032 | |
|---|
| 1033 | Input: |
|---|
| 1034 | in_channelHandle - BSCD_ChannelHandle, smart card channel handle. |
|---|
| 1035 | in_vccLevel - Smart Card interface voltage level ( 5V and 3V ) |
|---|
| 1036 | |
|---|
| 1037 | Returns: |
|---|
| 1038 | BERR_SUCCESS - success |
|---|
| 1039 | To Do: Need more error code |
|---|
| 1040 | |
|---|
| 1041 | |
|---|
| 1042 | See Also: |
|---|
| 1043 | |
|---|
| 1044 | ******************************************************************************/ |
|---|
| 1045 | BERR_Code BSCD_Channel_SetVccLevel( |
|---|
| 1046 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1047 | BSCD_VccLevel in_vccLevel |
|---|
| 1048 | ); |
|---|
| 1049 | |
|---|
| 1050 | |
|---|
| 1051 | |
|---|
| 1052 | |
|---|
| 1053 | /***************************************************************************** |
|---|
| 1054 | Summary: |
|---|
| 1055 | This function enable or disable "Insert Card Hardware Reset" feature in smart card. |
|---|
| 1056 | |
|---|
| 1057 | Description: |
|---|
| 1058 | When "Insert Card Hardware Reset" is enabled, the hardware will reset when smart card is inserted. |
|---|
| 1059 | This is triggered by SC_STATUS_1 bit card_pres = 0 -> 1 |
|---|
| 1060 | Make sure the SC_IF_CMD_1 bit pres_pol = 1, otherwise this trigger can not happen. |
|---|
| 1061 | After hardware reset, by default this feature is dabled. |
|---|
| 1062 | |
|---|
| 1063 | Calling Context: |
|---|
| 1064 | The function shall be called from application level (for example in |
|---|
| 1065 | VxWorks or no-os) or from driver level |
|---|
| 1066 | |
|---|
| 1067 | Performance and Synchronization: |
|---|
| 1068 | This is a synchronous function that will return when it is done. |
|---|
| 1069 | |
|---|
| 1070 | Input: |
|---|
| 1071 | in_channelHandle - BSCD_ChannelHandle, smart card channel handle. |
|---|
| 1072 | in_enableHwRst - true: Enable this feature |
|---|
| 1073 | false: disable this feature |
|---|
| 1074 | |
|---|
| 1075 | Returns: |
|---|
| 1076 | BERR_SUCCESS - success |
|---|
| 1077 | To Do: Need more error code |
|---|
| 1078 | |
|---|
| 1079 | |
|---|
| 1080 | See Also: |
|---|
| 1081 | |
|---|
| 1082 | ******************************************************************************/ |
|---|
| 1083 | BERR_Code BSCD_Channel_InsCardHwReset( |
|---|
| 1084 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1085 | bool in_enableHwRst |
|---|
| 1086 | ); |
|---|
| 1087 | |
|---|
| 1088 | /***************************************************************************** |
|---|
| 1089 | Summary: |
|---|
| 1090 | This function shall reset the smart card. Depends on the option, this function could |
|---|
| 1091 | further read and interpret the ATR data and program the registers accordingly. |
|---|
| 1092 | |
|---|
| 1093 | Description: |
|---|
| 1094 | There are 2 options to be selected in this function. |
|---|
| 1095 | |
|---|
| 1096 | If in_iccAction is BSCD_ResetCardAction_eNoAction, this function shall only reset the card. It |
|---|
| 1097 | shall not read ATR data. Caller has to call BSCD_Channel_Receive to receive the ATR |
|---|
| 1098 | data, decode it and then call BSCD_Channel_SetParameters to program the registers. |
|---|
| 1099 | |
|---|
| 1100 | If in_iccAction is BSCD_ResetCardAction_eReceiveAndDecode, this function shall reset the card. It |
|---|
| 1101 | then reads and decodes ATR data and programs the registers accordingly. This option is |
|---|
| 1102 | required to support smart card standard, like EMV that has stringent timing requirements |
|---|
| 1103 | on ATR error handling. Caller still has to call BSCD_Channel_Receive to receive the ATR |
|---|
| 1104 | data. The caller has the option if it wants to decode it and then call |
|---|
| 1105 | BSCD_Channel_SetParameters to program the registers. |
|---|
| 1106 | |
|---|
| 1107 | This function shall reset the smart card (ICC) in the following sequence: |
|---|
| 1108 | |
|---|
| 1109 | o SC_VCC low |
|---|
| 1110 | o SC_RST high |
|---|
| 1111 | o Wait for 42000 clock cycles. |
|---|
| 1112 | o IO is ready to receive ATR. |
|---|
| 1113 | o SC_RST low |
|---|
| 1114 | o ICC must send ATR per standard requirements (For example between 400 and |
|---|
| 1115 | 40,000 clock cycles). |
|---|
| 1116 | |
|---|
| 1117 | |
|---|
| 1118 | Unless specify, the rest of this section describes the scenarioes if |
|---|
| 1119 | in_iccAction is BSCD_ResetCardAction_eReceiveAndDecode: |
|---|
| 1120 | This function shall be blocked until either |
|---|
| 1121 | |
|---|
| 1122 | 1) All ATR data is received. |
|---|
| 1123 | 2) one of the timer expired. |
|---|
| 1124 | |
|---|
| 1125 | After ATR data are received correctly, the hardware shall determine if this |
|---|
| 1126 | card support direct (TS, first character is 0x3B) or inverse convention (TS is |
|---|
| 1127 | 0x3F). The caller shall call BSCD_Channel_Receive to receive the ATR data. |
|---|
| 1128 | |
|---|
| 1129 | |
|---|
| 1130 | This function shall parse the ATR data and modify the following settings |
|---|
| 1131 | according to the received ATR data: |
|---|
| 1132 | |
|---|
| 1133 | o ProtocolType (T=0 or T=1) |
|---|
| 1134 | o Clock Rate Conversion Factor |
|---|
| 1135 | o Baud Rate Adjustment Factor |
|---|
| 1136 | o Extra Guard Time |
|---|
| 1137 | o Work Waiting time (For T=0 only. For EMV standard, it applies to T=1 too) |
|---|
| 1138 | o Block Wait time (For T=1 only) |
|---|
| 1139 | o Character Wait time (For T=1 only) |
|---|
| 1140 | |
|---|
| 1141 | This function shall enable certain interrupts for T=0 or T=1 and set the parity |
|---|
| 1142 | retrial number. |
|---|
| 1143 | |
|---|
| 1144 | |
|---|
| 1145 | Calling Context: |
|---|
| 1146 | The function shall be called from application level (for example in |
|---|
| 1147 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 1148 | recommended ioctl: BSCD_IOCTL_RESET_CARD ) |
|---|
| 1149 | |
|---|
| 1150 | Performance and Synchronization: |
|---|
| 1151 | This is a synchronous function that will return when it is done. The maximum |
|---|
| 1152 | number of ATR data is 32 and the default work waiting time is 9600 ETUs, |
|---|
| 1153 | therefore the application can wait for 5 seconds, if each ETU is 165us, |
|---|
| 1154 | before all the ATR bytes are received. |
|---|
| 1155 | |
|---|
| 1156 | Input: |
|---|
| 1157 | in_channelHandle - BSCD_ChannelHandle, smart card |
|---|
| 1158 | channel handle. |
|---|
| 1159 | in_iccAction - BSCD_ResetCardAction, the settings that apply to a specific |
|---|
| 1160 | channel. If NULL, the interface shall be reset with the |
|---|
| 1161 | current setting. |
|---|
| 1162 | |
|---|
| 1163 | Returns: |
|---|
| 1164 | BERR_SUCCESS - success |
|---|
| 1165 | To Do: Need more error code |
|---|
| 1166 | |
|---|
| 1167 | |
|---|
| 1168 | See Also: |
|---|
| 1169 | BSCD_Channel_PowerICC |
|---|
| 1170 | BSCD_Channel_Deactivate |
|---|
| 1171 | BSCD_Channel_Receive |
|---|
| 1172 | |
|---|
| 1173 | ******************************************************************************/ |
|---|
| 1174 | BERR_Code BSCD_Channel_ResetCard( |
|---|
| 1175 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1176 | BSCD_ResetCardAction in_iccAction |
|---|
| 1177 | ); |
|---|
| 1178 | |
|---|
| 1179 | |
|---|
| 1180 | /***************************************************************************** |
|---|
| 1181 | Summary: |
|---|
| 1182 | This function retrieves the smart card channel status and current software |
|---|
| 1183 | state. |
|---|
| 1184 | |
|---|
| 1185 | Description: |
|---|
| 1186 | This function shall retrieve the smart card status and current software |
|---|
| 1187 | state. |
|---|
| 1188 | |
|---|
| 1189 | Calling Context: |
|---|
| 1190 | The function shall be called from application level (for example in |
|---|
| 1191 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 1192 | recommended ioctl: BSCD_IOCTL_GET_STATUS ) |
|---|
| 1193 | |
|---|
| 1194 | Performance and Synchronization: |
|---|
| 1195 | This is a synchronous function that will return when it is done. Since |
|---|
| 1196 | TDA8004 does not have debounce feature for the presence switches, this |
|---|
| 1197 | function may wait for extra 10ms for the presence switches to be stabilized. |
|---|
| 1198 | |
|---|
| 1199 | Input: |
|---|
| 1200 | in_channelHandle - BSCD_ChannelHandle, smart card |
|---|
| 1201 | channel handle. |
|---|
| 1202 | |
|---|
| 1203 | Output: |
|---|
| 1204 | outp_status - BSCD_Status, a ref/pointer that indicates the currect status |
|---|
| 1205 | and software state of the smart card module. |
|---|
| 1206 | |
|---|
| 1207 | Returns: |
|---|
| 1208 | BERR_SUCCESS - success |
|---|
| 1209 | To Do: Need more error code |
|---|
| 1210 | |
|---|
| 1211 | |
|---|
| 1212 | See Also: |
|---|
| 1213 | BSCD_Channel_DetectCard |
|---|
| 1214 | |
|---|
| 1215 | ******************************************************************************/ |
|---|
| 1216 | BERR_Code BSCD_Channel_GetStatus( |
|---|
| 1217 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1218 | BSCD_Status *outp_status |
|---|
| 1219 | ); |
|---|
| 1220 | |
|---|
| 1221 | |
|---|
| 1222 | /***************************************************************************** |
|---|
| 1223 | Summary: |
|---|
| 1224 | This function transmits data to the smart card. |
|---|
| 1225 | |
|---|
| 1226 | Description: |
|---|
| 1227 | This function shall be blocked until it has transmitted in_unNumXmitBytes |
|---|
| 1228 | number of bytes in inp_ucXmitData to the card. |
|---|
| 1229 | |
|---|
| 1230 | This function shall be blocked until either all the bytes has been transmitted. |
|---|
| 1231 | |
|---|
| 1232 | For NDS standard, this function shall set the SC_FLOW_CMD[flow_en] to 1 and |
|---|
| 1233 | the hardware transmitter shall waits until the NDS flow control is deasserted |
|---|
| 1234 | before transmitting the next byte. |
|---|
| 1235 | |
|---|
| 1236 | This function shall not interpret the transmitting data. |
|---|
| 1237 | |
|---|
| 1238 | For any parity error, the hardware shall retry the transmission for the |
|---|
| 1239 | number of times specify in the setting. If ICC still reports transmission parity |
|---|
| 1240 | error after that, SC_INTR_STAT_1[retry_intr] will set to 1 and caller can call |
|---|
| 1241 | BSCD_Channel_GetStatus to check if this is a transmission parity error. |
|---|
| 1242 | |
|---|
| 1243 | Calling Context: |
|---|
| 1244 | The function shall be called from application level (for example in |
|---|
| 1245 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 1246 | driver write) |
|---|
| 1247 | |
|---|
| 1248 | Performance and Synchronization: |
|---|
| 1249 | This is a synchronous function that will return when it is done. This function |
|---|
| 1250 | is blocked until it has transmitted in_unNumXmitBytes number of bytes in |
|---|
| 1251 | inp_ucXmitData. |
|---|
| 1252 | |
|---|
| 1253 | Input: |
|---|
| 1254 | in_channelHandle - BSCD_ChannelHandle, smart card |
|---|
| 1255 | channel handle. |
|---|
| 1256 | inp_ucXmitData - uint8_t, a ref/pointer to the buffer for transmitting data |
|---|
| 1257 | in_unNumXmitBytes - unsigned long, a ref/pointer to the number of transmitting |
|---|
| 1258 | bytes. |
|---|
| 1259 | |
|---|
| 1260 | Returns: |
|---|
| 1261 | BERR_SUCCESS - success |
|---|
| 1262 | To Do: Need more error code |
|---|
| 1263 | |
|---|
| 1264 | |
|---|
| 1265 | See Also: |
|---|
| 1266 | BSCD_Channel_Transmit |
|---|
| 1267 | BSCD_Channel_Receive |
|---|
| 1268 | BSCD_Channel_GetStatus |
|---|
| 1269 | |
|---|
| 1270 | ******************************************************************************/ |
|---|
| 1271 | BERR_Code BSCD_Channel_Transmit( |
|---|
| 1272 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1273 | uint8_t *inp_ucXmitData, |
|---|
| 1274 | unsigned long in_ulNumXmitBytes |
|---|
| 1275 | ); |
|---|
| 1276 | |
|---|
| 1277 | |
|---|
| 1278 | /***************************************************************************** |
|---|
| 1279 | Summary: |
|---|
| 1280 | This function receives data from the smart card after IFD transmits data to the smart card. |
|---|
| 1281 | |
|---|
| 1282 | Description: |
|---|
| 1283 | This function shall receive data in the outp_ucRcvData from the smart card, after IFD |
|---|
| 1284 | transmits data to the smart card. |
|---|
| 1285 | |
|---|
| 1286 | This function is NOT recommended to be used to read ATR data. Use |
|---|
| 1287 | BSCD_Channel_ReceiveATR to read ATR data since it handles the time out more |
|---|
| 1288 | accurately. If the system does not care about the accurate timeout, this function can |
|---|
| 1289 | be used to read the ATR data. |
|---|
| 1290 | |
|---|
| 1291 | For better performance, the caller is recommended to set in_unMaxReadBytes |
|---|
| 1292 | equal to the number of expected receiving bytes. If the caller set |
|---|
| 1293 | in_unMaxReadBytes to a number that is greater than the outp_unNumRcvBytes |
|---|
| 1294 | (for example, MAX_ATR_SIZE), this function shall return outp_unNumRcvBytes |
|---|
| 1295 | number of receiving bytes with an error. It is the responsibility of the |
|---|
| 1296 | application to determine if this operation is succeed or not. |
|---|
| 1297 | |
|---|
| 1298 | This function shall be blocked until either |
|---|
| 1299 | |
|---|
| 1300 | 1) The number of receiving data is equal to in_unMaxReadBytes. |
|---|
| 1301 | 2) An error occurs. |
|---|
| 1302 | |
|---|
| 1303 | This function shall return an error either |
|---|
| 1304 | |
|---|
| 1305 | 1) The number of receiving bytes is greater than in_unMaxReadBytes. |
|---|
| 1306 | 2) One of the timer expired before in_unMaxReadBytes of bytes |
|---|
| 1307 | has received. |
|---|
| 1308 | |
|---|
| 1309 | This function shall not interpret receiving data. |
|---|
| 1310 | |
|---|
| 1311 | For any parity error, the hardware shall retry the receiving for the |
|---|
| 1312 | number of times specify in the setting. If IFD still reports receiving parity |
|---|
| 1313 | error after that, SC_INTR_STAT_1[retry_intr] will set to 1 and caller can call |
|---|
| 1314 | BSCD_Channel_GetStatus to check if this is a receiving parity error. |
|---|
| 1315 | |
|---|
| 1316 | Calling Context: |
|---|
| 1317 | The function shall be called from application level (for example in |
|---|
| 1318 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 1319 | driver read ) |
|---|
| 1320 | |
|---|
| 1321 | Performance and Synchronization: |
|---|
| 1322 | This is a synchronous function that will return when it is done. |
|---|
| 1323 | |
|---|
| 1324 | Input: |
|---|
| 1325 | in_channelHandle - BSCD_ChannelHandle, a ref/pointer to the smart card |
|---|
| 1326 | channel handle. |
|---|
| 1327 | in_unMaxReadBytes - unsigned long, a ref/pointer to the number of maximum receiving |
|---|
| 1328 | bytes |
|---|
| 1329 | |
|---|
| 1330 | Output: |
|---|
| 1331 | outp_ucRcvData - uint8_t, a ref/pointer to the buffer for receive data |
|---|
| 1332 | outp_unNumRcvBytes - unsigned long a ref/pointer to the number of receiving bytes |
|---|
| 1333 | |
|---|
| 1334 | Returns: |
|---|
| 1335 | BERR_SUCCESS - success |
|---|
| 1336 | To Do: Need more error code |
|---|
| 1337 | |
|---|
| 1338 | |
|---|
| 1339 | See Also: |
|---|
| 1340 | BSCD_Channel_Transmit |
|---|
| 1341 | BSCD_Channel_ReceiveATR |
|---|
| 1342 | BSCD_Channel_GetStatus |
|---|
| 1343 | |
|---|
| 1344 | ******************************************************************************/ |
|---|
| 1345 | BERR_Code BSCD_Channel_Receive( |
|---|
| 1346 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1347 | uint8_t *outp_ucRcvData, |
|---|
| 1348 | unsigned long *outp_ulNumRcvBytes, |
|---|
| 1349 | unsigned long in_ulMaxReadBytes |
|---|
| 1350 | ); |
|---|
| 1351 | |
|---|
| 1352 | /***************************************************************************** |
|---|
| 1353 | Summary: |
|---|
| 1354 | This function receives Answer To Reset (ATR) data from the smart card. |
|---|
| 1355 | |
|---|
| 1356 | Description: |
|---|
| 1357 | This function shall receive ATR data in the outp_ucRcvData from the smart card. ATR data |
|---|
| 1358 | shall actually be received after calling BSCD_Channel_PowerICC. This function only |
|---|
| 1359 | retrieve ATR data from the hardware receiving buffer. |
|---|
| 1360 | |
|---|
| 1361 | This function is recommended to be used to return ATR data since the time out period |
|---|
| 1362 | is more accurate. Use BSCD_Channel_Receive |
|---|
| 1363 | to read the data from the smart card after IFD transmits data to the smart card. |
|---|
| 1364 | |
|---|
| 1365 | For better performance, the caller is recommended to set in_unMaxReadBytes |
|---|
| 1366 | equal to the number of expected receiving bytes. If the caller set |
|---|
| 1367 | in_unMaxReadBytes to a number that is greater than the outp_unNumRcvBytes |
|---|
| 1368 | (for example, MAX_ATR_SIZE), this function shall return outp_unNumRcvBytes |
|---|
| 1369 | number of receiving bytes with an error. It is the responsibility of the |
|---|
| 1370 | application to determine if this operation is succeed or not. |
|---|
| 1371 | |
|---|
| 1372 | This function shall be blocked until either |
|---|
| 1373 | |
|---|
| 1374 | 1) The number of receiving data is equal to in_unMaxReadBytes. |
|---|
| 1375 | 2) An error occurs. |
|---|
| 1376 | |
|---|
| 1377 | This function shall return an error either |
|---|
| 1378 | |
|---|
| 1379 | 1) The number of receiving bytes is greater than in_unMaxReadBytes. |
|---|
| 1380 | 2) One of the timer expired before in_unMaxReadBytes of bytes |
|---|
| 1381 | has received. |
|---|
| 1382 | |
|---|
| 1383 | This function shall not interpret receiving data. |
|---|
| 1384 | |
|---|
| 1385 | For any parity error, the hardware shall retry the receiving for the |
|---|
| 1386 | number of times specify in the setting. If IFD still reports receiving parity |
|---|
| 1387 | error after that, SC_INTR_STAT_1[retry_intr] will set to 1 and caller can call |
|---|
| 1388 | BSCD_Channel_GetStatus to check if this is a receiving parity error. |
|---|
| 1389 | |
|---|
| 1390 | Calling Context: |
|---|
| 1391 | The function shall be called from application level (for example in |
|---|
| 1392 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 1393 | driver read ) |
|---|
| 1394 | |
|---|
| 1395 | Performance and Synchronization: |
|---|
| 1396 | This is a synchronous function that will return when it is done. |
|---|
| 1397 | |
|---|
| 1398 | Input: |
|---|
| 1399 | in_channelHandle - BSCD_ChannelHandle, a ref/pointer to the smart card |
|---|
| 1400 | channel handle. |
|---|
| 1401 | in_unMaxReadBytes - unsigned long, a ref/pointer to the number of maximum receiving |
|---|
| 1402 | bytes |
|---|
| 1403 | |
|---|
| 1404 | Output: |
|---|
| 1405 | outp_ucRcvData - uint8_t, a ref/pointer to the buffer for receive data |
|---|
| 1406 | outp_unNumRcvBytes - unsigned long a ref/pointer to the number of receiving bytes |
|---|
| 1407 | |
|---|
| 1408 | Returns: |
|---|
| 1409 | BERR_SUCCESS - success |
|---|
| 1410 | To Do: Need more error code |
|---|
| 1411 | |
|---|
| 1412 | |
|---|
| 1413 | See Also: |
|---|
| 1414 | BSCD_Channel_Transmit |
|---|
| 1415 | BSCD_Channel_Receive |
|---|
| 1416 | BSCD_Channel_GetStatus |
|---|
| 1417 | |
|---|
| 1418 | ******************************************************************************/ |
|---|
| 1419 | BERR_Code BSCD_Channel_ReceiveATR( |
|---|
| 1420 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1421 | uint8_t *outp_ucRcvData, |
|---|
| 1422 | unsigned long *outp_ulNumRcvBytes, |
|---|
| 1423 | unsigned long in_ulMaxReadBytes |
|---|
| 1424 | ); |
|---|
| 1425 | |
|---|
| 1426 | /***************************************************************************** |
|---|
| 1427 | Summary: |
|---|
| 1428 | This function configures the Waiting Timer or General Purpose Timer. |
|---|
| 1429 | |
|---|
| 1430 | Description: |
|---|
| 1431 | This function shall configure the Waiting Timer or General Purpose Timer. |
|---|
| 1432 | |
|---|
| 1433 | Calling Context: |
|---|
| 1434 | The function shall be called from application level (for example in |
|---|
| 1435 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 1436 | recommended ioctl: BSCD_IOCTL_CONFIG_TIMER). |
|---|
| 1437 | |
|---|
| 1438 | Performance and Synchronization: |
|---|
| 1439 | This is a synchronous function that will return when it is done. |
|---|
| 1440 | |
|---|
| 1441 | Input: |
|---|
| 1442 | in_channelHandle - BSCD_ChannelHandle, smart card |
|---|
| 1443 | channel handle. |
|---|
| 1444 | inp_timer - BSCD_Timer, a ref/pointer to the smart card timer structure. |
|---|
| 1445 | inp_unCount - BSCD_TimerValue, a ref/pointer to the smart card timer value |
|---|
| 1446 | and unit. |
|---|
| 1447 | |
|---|
| 1448 | Returns: |
|---|
| 1449 | BERR_SUCCESS - success |
|---|
| 1450 | To Do: Need more error code |
|---|
| 1451 | |
|---|
| 1452 | ******************************************************************************/ |
|---|
| 1453 | BERR_Code BSCD_Channel_ConfigTimer( |
|---|
| 1454 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1455 | BSCD_Timer *inp_timer, |
|---|
| 1456 | BSCD_TimerValue *inp_unCount |
|---|
| 1457 | |
|---|
| 1458 | ); |
|---|
| 1459 | |
|---|
| 1460 | |
|---|
| 1461 | |
|---|
| 1462 | /***************************************************************************** |
|---|
| 1463 | Summary: |
|---|
| 1464 | This function enables or disables the Waiting Timer or General Purpose Timer. |
|---|
| 1465 | |
|---|
| 1466 | Description: |
|---|
| 1467 | This function shall either |
|---|
| 1468 | |
|---|
| 1469 | 1) Disable Waiting Timer or General Purpose Timer. |
|---|
| 1470 | 2) Enable Waiting Timer in Work Waiting Time Mode or Block Waiting Time Mode. |
|---|
| 1471 | 3) Enable General Purppose Timer in Start Timer Immediate mode or Start Timer |
|---|
| 1472 | on Next Start Bit mode. |
|---|
| 1473 | |
|---|
| 1474 | Calling Context: |
|---|
| 1475 | The function shall be called from application level (for example in |
|---|
| 1476 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 1477 | recommended ioctl: BSCD_IOCTL_ENABLE_DISABLE_TIMER). |
|---|
| 1478 | |
|---|
| 1479 | Performance and Synchronization: |
|---|
| 1480 | This is a synchronous function that will return when it is done. |
|---|
| 1481 | |
|---|
| 1482 | Input: |
|---|
| 1483 | in_channelHandle - BSCD_ChannelHandle, a ref/pointer to the smart card |
|---|
| 1484 | channel handle. |
|---|
| 1485 | inp_timer - BSCD_Timer, a ref/pointer to the smart card timer structure. |
|---|
| 1486 | |
|---|
| 1487 | Returns: |
|---|
| 1488 | BERR_SUCCESS - success |
|---|
| 1489 | To Do: Need more error code |
|---|
| 1490 | |
|---|
| 1491 | ******************************************************************************/ |
|---|
| 1492 | BERR_Code BSCD_Channel_EnableDisableTimer_isr( |
|---|
| 1493 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1494 | BSCD_Timer *inp_timer |
|---|
| 1495 | ); |
|---|
| 1496 | |
|---|
| 1497 | |
|---|
| 1498 | /***************************************************************************** |
|---|
| 1499 | Summary: |
|---|
| 1500 | This function enables a specific smart card interrupt. |
|---|
| 1501 | |
|---|
| 1502 | Description: |
|---|
| 1503 | This function enables a specific smart card interrupt. |
|---|
| 1504 | |
|---|
| 1505 | There are 2 callback functions that can be registered with a specific interrupt. |
|---|
| 1506 | One of them must be reserved for default callback function provided by this module. |
|---|
| 1507 | The other callback function is opt to use for customized callback function. |
|---|
| 1508 | Therefore this function can only register 2 different callback functions |
|---|
| 1509 | per specific interrupt. |
|---|
| 1510 | |
|---|
| 1511 | Calling Context: |
|---|
| 1512 | The function shall be called from application level (for example in |
|---|
| 1513 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 1514 | recommended ioctl: BSCD_IOCTL_ENABLE_INTR_CALLBACK). |
|---|
| 1515 | |
|---|
| 1516 | Performance and Synchronization: |
|---|
| 1517 | This is a synchronous function that will return when it is done. |
|---|
| 1518 | |
|---|
| 1519 | Input: |
|---|
| 1520 | in_channelHandle - BSCD_ChannelHandle, a ref/pointer to the smart card |
|---|
| 1521 | channel handle. |
|---|
| 1522 | in_eIntrType - BICM_IntrType, Interrupt type. |
|---|
| 1523 | in_callbackhandle - BICM_CallbackFunc, callback function. |
|---|
| 1524 | |
|---|
| 1525 | Returns: |
|---|
| 1526 | BERR_SUCCESS - success |
|---|
| 1527 | To Do: Need more error code |
|---|
| 1528 | |
|---|
| 1529 | ******************************************************************************/ |
|---|
| 1530 | BERR_Code BSCD_Channel_EnableIntrCallback_isr( |
|---|
| 1531 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1532 | BSCD_IntrType in_eIntrType, |
|---|
| 1533 | BSCD_IsrCallbackFunc in_callbackhandle |
|---|
| 1534 | ); |
|---|
| 1535 | |
|---|
| 1536 | |
|---|
| 1537 | /***************************************************************************** |
|---|
| 1538 | Summary: |
|---|
| 1539 | This function disables a specific smart card interrupt. |
|---|
| 1540 | |
|---|
| 1541 | Description: |
|---|
| 1542 | This function disables a specific smart card interrupt. |
|---|
| 1543 | |
|---|
| 1544 | Calling Context: |
|---|
| 1545 | The function shall be called from application level (for example in |
|---|
| 1546 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 1547 | recommended ioctl: BSCD_IOCTL_DISABLE_INTR_CALLBACK). |
|---|
| 1548 | |
|---|
| 1549 | Performance and Synchronization: |
|---|
| 1550 | This is a synchronous function that will return when it is done. |
|---|
| 1551 | |
|---|
| 1552 | Input: |
|---|
| 1553 | in_channelHandle - BSCD_ChannelHandle, a ref/pointer to the smart card |
|---|
| 1554 | channel handle. |
|---|
| 1555 | in_eIntrType - BICM_IntrType, Interrupt type. |
|---|
| 1556 | |
|---|
| 1557 | Returns: |
|---|
| 1558 | BERR_SUCCESS - success |
|---|
| 1559 | To Do: Need more error code |
|---|
| 1560 | |
|---|
| 1561 | ******************************************************************************/ |
|---|
| 1562 | BERR_Code BSCD_Channel_DisableIntrCallback_isr( |
|---|
| 1563 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1564 | BSCD_IntrType in_eIntrType |
|---|
| 1565 | ); |
|---|
| 1566 | |
|---|
| 1567 | /***************************************************************************** |
|---|
| 1568 | Summary: |
|---|
| 1569 | This function enable set of related smart card interrupts for T=0, T=1 or T=14. |
|---|
| 1570 | |
|---|
| 1571 | Description: |
|---|
| 1572 | This function enable set of related smart card interrupts for T=0, T=1 or T=14. |
|---|
| 1573 | |
|---|
| 1574 | Calling Context: |
|---|
| 1575 | The function shall be called from application level (for example in |
|---|
| 1576 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 1577 | recommended ioctl: BSCD_IOCTL_ENABLE_INTERRUPTS). |
|---|
| 1578 | |
|---|
| 1579 | Performance and Synchronization: |
|---|
| 1580 | This is a synchronous function that will return when it is done. |
|---|
| 1581 | |
|---|
| 1582 | Input: |
|---|
| 1583 | in_channelHandle - BSCD_ChannelHandle, a ref/pointer to the smart card |
|---|
| 1584 | channel handle. |
|---|
| 1585 | |
|---|
| 1586 | Returns: |
|---|
| 1587 | BERR_SUCCESS - success |
|---|
| 1588 | To Do: Need more error code |
|---|
| 1589 | |
|---|
| 1590 | ******************************************************************************/ |
|---|
| 1591 | BERR_Code BSCD_Channel_EnableInterrupts( |
|---|
| 1592 | BSCD_ChannelHandle in_channelHandle |
|---|
| 1593 | ); |
|---|
| 1594 | |
|---|
| 1595 | |
|---|
| 1596 | /***************************************************************************** |
|---|
| 1597 | Summary: |
|---|
| 1598 | This function will reset the Block wait time back to whatever current channel settings which was |
|---|
| 1599 | either set through ATR or BSCD_Channel_SetParameters. |
|---|
| 1600 | |
|---|
| 1601 | Description: |
|---|
| 1602 | This function will reset the Block wait time back to whatever current channel settings which was |
|---|
| 1603 | either set through ATR or BSCD_Channel_SetParameters. |
|---|
| 1604 | |
|---|
| 1605 | Calling Context: |
|---|
| 1606 | The function shall be called from application level (for example in |
|---|
| 1607 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 1608 | recommended ioctl: BSCD_IOCTL_RESET_BLOCK_WAIT_TIMER). |
|---|
| 1609 | |
|---|
| 1610 | Performance and Synchronization: |
|---|
| 1611 | This is a synchronous function that will return when it is done. |
|---|
| 1612 | |
|---|
| 1613 | Input: |
|---|
| 1614 | in_channelHandle - BSCD_ChannelHandle, a ref/pointer to the smart card |
|---|
| 1615 | channel handle. |
|---|
| 1616 | |
|---|
| 1617 | Returns: |
|---|
| 1618 | BERR_SUCCESS - success |
|---|
| 1619 | To Do: Need more error code |
|---|
| 1620 | |
|---|
| 1621 | ******************************************************************************/ |
|---|
| 1622 | BERR_Code BSCD_Channel_ResetBlockWaitTimer( |
|---|
| 1623 | BSCD_ChannelHandle in_channelHandle |
|---|
| 1624 | ); |
|---|
| 1625 | |
|---|
| 1626 | |
|---|
| 1627 | /***************************************************************************** |
|---|
| 1628 | Summary: |
|---|
| 1629 | This function will set the Block wait time extension. |
|---|
| 1630 | |
|---|
| 1631 | Description: |
|---|
| 1632 | This function will set the Block wait time extension. |
|---|
| 1633 | |
|---|
| 1634 | Calling Context: |
|---|
| 1635 | The function shall be called from application level (for example in |
|---|
| 1636 | VxWorks or no-os) or from driver level (for example in Linux, |
|---|
| 1637 | recommended ioctl: BSCD_IOCTL_SET_BLOCK_WAIT_TIME_EXT). |
|---|
| 1638 | |
|---|
| 1639 | Performance and Synchronization: |
|---|
| 1640 | This is a synchronous function that will return when it is done. |
|---|
| 1641 | |
|---|
| 1642 | Input: |
|---|
| 1643 | in_channelHandle - BSCD_ChannelHandle, a ref/pointer to the smart card |
|---|
| 1644 | channel handle. |
|---|
| 1645 | in_ulBlockWaitTimeExtInETU - uint32_t, block wait time extention in ETU. |
|---|
| 1646 | |
|---|
| 1647 | Returns: |
|---|
| 1648 | BERR_SUCCESS - success |
|---|
| 1649 | To Do: Need more error code |
|---|
| 1650 | |
|---|
| 1651 | ******************************************************************************/ |
|---|
| 1652 | BERR_Code BSCD_Channel_SetBlockWaitTimeExt( |
|---|
| 1653 | BSCD_ChannelHandle in_channelHandle, |
|---|
| 1654 | uint32_t in_ulBlockWaitTimeExtInETU |
|---|
| 1655 | ); |
|---|
| 1656 | |
|---|
| 1657 | /***************************************************************************** |
|---|
| 1658 | Summary: |
|---|
| 1659 | This function will dump the smartcard control register values. |
|---|
| 1660 | |
|---|
| 1661 | Description: |
|---|
| 1662 | This function will dump the smartcard control register values. |
|---|
| 1663 | |
|---|
| 1664 | |
|---|
| 1665 | Input: |
|---|
| 1666 | in_channelHandle - BSCD_ChannelHandle, a ref/pointer to the smart card |
|---|
| 1667 | channel handle. |
|---|
| 1668 | ******************************************************************************/ |
|---|
| 1669 | |
|---|
| 1670 | |
|---|
| 1671 | void BSCD_Channel_DumpRegisters( |
|---|
| 1672 | BSCD_ChannelHandle in_channelHandle |
|---|
| 1673 | ); |
|---|
| 1674 | |
|---|
| 1675 | |
|---|
| 1676 | /* End of Module Specific Functions */ |
|---|
| 1677 | |
|---|
| 1678 | #ifdef __cplusplus |
|---|
| 1679 | } |
|---|
| 1680 | #endif |
|---|
| 1681 | |
|---|
| 1682 | #endif /* BSCD_H__ */ |
|---|
| 1683 | |
|---|
| 1684 | |
|---|
| 1685 | |
|---|
| 1686 | |
|---|
| 1687 | |
|---|
| 1688 | |
|---|
| 1689 | |
|---|