source: svn/newcon3bcm2_21bu/BSEAV/api/include/bsettop_smartcard.h @ 46

Last change on this file since 46 was 46, checked in by megakiss, 11 years ago

459Mhz로 OTC 주파수 변경

  • Property svn:executable set to *
File size: 13.0 KB
Line 
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: bsettop_smartcard.h $
11 * $brcm_Revision: 7 $
12 * $brcm_Date: 8/4/10 12:17p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /BSEAV/api/include/bsettop_smartcard.h $
19 *
20 * 7   8/4/10 12:17p vsilyaev
21 * SW7125-478: Removed function bsmartcard_set_params_from_atr
22 *
23 * 6   8/19/08 1:40p vsilyaev
24 * PR 45615: Added ISO smartcard channel settings
25 *
26 * 5   9/13/06 1:03p mphillip
27 * PR23885: Added a card insertion/removal callback
28 *
29 * 4   8/21/06 5:09p mphillip
30 * PR23568: Copy/paste error, fixed bsmartcard_protocol to be
31 * bsmartcard_standard for the enum values for bsmartcard_standard's
32 * enums
33 *
34 * 3   8/18/06 3:49p mphillip
35 * PR23568: Add warm/cold parameter for bsmartcard_reset, and fix error
36 * enum to be bsmartcard_err_
37 *
38 * 2   8/17/06 11:38a mphillip
39 * PR23568: Renaming/adjusting of the smartcard API.  Functionality is
40 * still forthcoming.
41 *
42 * 1   2/7/05 7:06p dlwin
43 * Merge down for release 2005_REFSW_MERGETOMAIN:
44 *
45 * Irvine_BSEAVSW_Devel/11   7/6/04 3:54p erickson
46 * PR11771: settop api dataflow redesign
47 *
48 * Irvine_BSEAVSW_Devel/10   6/29/04 11:28a erickson
49 * PR11135: updated deprecation notices for settop api
50 *
51 * Irvine_BSEAVSW_Devel/9   2/12/04 11:08a btan
52 * PR 9741: Added settop API for 7038
53 *
54 * Irvine_BSEAVSW_Devel/8   11/7/03 4:28p erickson
55 * PR8583: removing, fixing or implementing TODO's
56 *
57 * Irvine_BSEAVSW_Devel/7   10/31/03 11:58a erickson
58 * settop api changes after internal review
59 *
60 * Irvine_BSEAVSW_Devel/6   10/28/03 11:28a erickson
61 * settop api reworks after internal design view
62 *
63 * Irvine_BSEAVSW_Devel/5   10/10/03 5:33p erickson
64 * converted all streaming api's to use size_t instead of unsigned
65 *
66 * Irvine_BSEAVSW_Devel/4   10/8/03 2:19p erickson
67 * got smartcard working
68 *
69 * Irvine_BSEAVSW_Devel/3   10/8/03 11:46a erickson
70 * added initial implementation for smartcard
71 *
72 * Irvine_BSEAVSW_Devel/2   10/7/03 5:28p erickson
73 * changed comments
74 *
75 * Irvine_BSEAVSW_Devel/1   10/7/03 5:17p erickson
76 * initial smartcard api
77 *
78 ***************************************************************************/
79#ifndef BSETTOP_SMARTCARD_H__
80#define BSETTOP_SMARTCARD_H__
81
82#ifdef __cplusplus
83extern "C"
84{
85#endif
86
87/*=*************************
88Smartcard (bsmartcard_t) supports a read/write interface to the smartcard along with
89reset functions.
90
91Asynchronous I/O is not supported yet.
92****************************/
93
94/*
95Summary:
96        Smartcard handle returned by bsmartcard_open.
97*/
98typedef struct bsmartcard *bsmartcard_t;
99
100/*
101Summary:
102        Smartcard protocol enum definition.
103*/
104typedef enum bsmartcard_protocol {
105        bsmartcard_protocol_unknown,
106        bsmartcard_protocol_t0,
107        bsmartcard_protocol_t1,
108        bsmartcard_protocol_t14
109} bsmartcard_protocol;
110
111/*
112Summary:
113        Smartcard standard enum definition.
114*/
115typedef enum bsmartcard_standard {
116        bsmartcard_standard_nds,
117        bsmartcard_standard_iso,
118        bsmartcard_standard_emv2000,
119        bsmartcard_standard_irdeto
120} bsmartcard_standard;
121
122/*
123Summary:
124    This enum is to identify the unit of timer value.
125
126Description:
127See Also:
128
129*/
130typedef enum bsmartcard_timer_unit{
131    bsmartcard_timer_unit_etu = 0,  /* in Elementary Time Units */
132    bsmartcard_timer_unit_clock,      /* in raw clock cycles that smart card receives */
133    bsmartcard_timer_unit_msec  /* in milli seconds */
134} bsmartcard_timer_unit;
135
136/*
137Summary:
138    The timer value that application set to or get from the smartcard.
139
140Description:
141
142See Also:
143
144*/
145typedef struct bsmartcard_timer_value
146{
147    unsigned    value;  /* timer value */
148    bsmartcard_timer_unit unit; /* units */
149} bsmartcard_timer_value;
150
151/*
152Summary:
153    This enum is to identify error detect code (EDC) encoding.
154
155Description:
156    This enumeration defines the supported error detect code (EDC) encoding .
157
158See Also:
159*/
160typedef enum bsmartcard_edc_encode {
161    bsmartcard_edc_encode_lrc= 0,
162        bsmartcard_edc_encode_crc
163} bsmartcard_edc_encode;
164
165/*
166Summary:
167    The configuration of EDC setting for T=1 protocol only.
168
169Description:
170
171See Also:
172 */
173typedef struct bsmartcard_edc_setting
174{
175    bsmartcard_edc_encode edc_encode;   /* EDC encoding */
176    bool    is_enabled;
177} bsmartcard_edc_setting;
178
179/*
180Summary:
181    This enum is to identify read or write a specific register.
182
183Description:
184    This enumeration defines read or write of a smart card register.
185
186See Also:
187 */
188typedef enum bsmartcard_sc_presmode {
189    bsmartcard_sc_presmode_debounce = 0,   
190    bsmartcard_sc_presmode_mask       
191}  bsmartcard_sc_presmode;
192
193/*
194Summary:
195    The configuration of Smartcard Pres Debounce.
196
197Description:
198
199See Also:
200
201 */
202typedef struct bsmartcard_sc_pres_dbinfo
203{
204    bsmartcard_sc_presmode      sc_pres_mode;   /* EDC encoding */
205    bool                is_enabled; /* True if enabled. Otherwise it should be false*/
206    uint8_t             db_width; 
207                       
208} bsmartcard_sc_pres_dbinfo;
209
210/*
211Summary:
212    This enum is to identify action for BSCD_Channel_ResetCard function.
213
214Description:
215This enumeration defines the supported action for  BSCD_Channel_ResetCard function.
216
217See Also:
218BSCD_Channel_ResetCard
219 */
220typedef enum bsmartcard_reset_card_action{
221        bsmartcard_reset_card_no_action = 0,
222        bsmartcard_reset_card_receive_decode
223} bsmartcard_reset_card_action;
224
225/*
226Summary:
227        Smartcard settings structure.
228Description:
229        Smartcard settings structure, used by bsmartcard_open. 
230        This allows protocol (T=0, T=1, T=14) and standard (NDS, ISO, EMV2000, IRDETO) to be selected.
231*/
232typedef struct bsmartcard_settings {
233    bsmartcard_protocol protocol;
234    bsmartcard_standard standard;
235    uint8_t ffactor;
236    uint8_t dfactor;
237    uint8_t ext_clock_divisor;
238    uint8_t tx_retries;
239    uint8_t rx_retries;
240    bsmartcard_timer_value  work_wait_time;
241    bsmartcard_timer_value  block_wait_time;
242    bsmartcard_timer_value  extra_guard_time;
243    bsmartcard_timer_value  block_guard_time;
244    unsigned                character_wait_time;   
245    bsmartcard_edc_setting  edc_setting;
246    bsmartcard_timer_value  time_out;
247    bool                    auto_deactive_req;
248    bool                    null_filter;
249    bsmartcard_sc_pres_dbinfo       sc_pres_dbinfo;
250    bsmartcard_reset_card_action    reset_card_action;
251    bsmartcard_timer_value  block_wait_time_ext;
252    bool                    is_pres_high;
253    void *callback_context;             /* Context pointer, returned in the callback functions */
254    bsettop_callback    card_insertion; /* Called when a card is inserted */
255    bsettop_callback    card_removal; /* Called when a card is removed */
256} bsmartcard_settings_t;
257
258/*
259Summary:
260        Smartcard setting structure initialization.
261Description:
262        This function initializes the smartcard settings structure to defaults.
263*/
264void bsmartcard_settings_init(
265        bsmartcard_settings_t *settings
266);
267
268/*
269Summary:
270        Open a smart object which corresponds to one smartcard reader.
271Description:
272*/
273bsmartcard_t bsmartcard_open(
274        bobject_t smartcard_id, /* smartcard object id */
275        const bsmartcard_settings_t *settings /* smartcard settings */
276);
277
278/*
279Summary:
280        Close a smartcard object.
281Description:
282        After closing, the bsmartcard_t handle is invalid.
283*/
284void bsmartcard_close(
285        bsmartcard_t smartcard /* handle returned by bsmartcard_open */
286);
287
288/*
289Summary:
290        Get the smartcard channel settings structure a smart object which corresponds to one smartcard reader.
291
292Description:
293*/
294void bsmartcard_get_settings(
295    bsmartcard_t smartcard,
296    bsmartcard_settings_t *settings
297);
298
299/*
300Summary:
301        Set the smartcard channel settings structure a smart object which corresponds to one smartcard reader.
302
303Description:
304*/
305bresult bsmartcard_set_settings(
306    bsmartcard_t smartcard,
307    const bsmartcard_settings_t *settings
308);
309
310/*
311Summary:
312        Read data from the smartcard.
313
314Description:
315        If you don't call bsmartcard_set_async, this function will block until it can return
316        some data or returns an error.
317
318        If you call bsmartcard_set_async, this function will never block and will return
319        either some data, no data or an error.
320
321        If read fails, you should call bsmartcard_get_status in order to determine
322        the state of the smartcard interface.
323*/
324bresult bsmartcard_read(
325        bsmartcard_t smartcard, /* handle returned by bsmartcard_open */
326        void *data,                             /* [out,size_is(length)] memory to read into */
327        size_t length,                  /* maximum number of bytes to read */
328        size_t *length_read             /* [out] amount of data read into memory */
329);
330
331/*
332Summary:
333        Write data to the smartcard.
334
335Description:
336        If you don't call bsmartcard_set_async, this function will block until it can write
337        some data or returns an error.
338
339        If you call bsmartcard_set_async, this function will never block and will write
340        some data or return an error.
341
342        If write fails, you should call bsmartcard_get_status in order to determine
343        the state of the smartcard interface.
344*/
345bresult bsmartcard_write(
346        bsmartcard_t smartcard, /* handle returned by bsmartcard_open */
347        const void *data,               /* [size_is(length)] memory to write from */
348        size_t length,                  /* maximum number of bytes to write */
349        size_t *length_written  /* [out] amount of data written */
350);
351
352/* TODO: need async notification of status change using bsettop_event */
353
354/*
355Summary:
356        Smartcard error status enum.
357*/
358typedef enum bsmartcard_error {
359        bsmartcard_no_error,
360        bsmartcard_err_rx_parity,
361        bsmartcard_err_tx_parity,
362        bsmartcard_err_rx_timeout,
363        bsmartcard_err_tx_timeout,
364        bsmartcard_err_hardware_failure,
365        bsmartcard_err_reset_terminal /* requires a call to bsmartcard_reset() */
366} bsmartcard_error;
367
368/*
369Summary:
370        Smartcard state enum.
371Description:
372        This represents the current state of the given slot and card.
373*/
374typedef enum bsmartcard_state {
375        bsmartcard_state_unknown = 0, /* Unknown state (perhaps not yet initialized).  Persistent. */
376        bsmartcard_state_cold_resetting, /* A cold reset has been requested but is not yet complete.  Transient. */
377        bsmartcard_state_warm_resetting, /* A warm reset has been requested but is not yet complete.  Transient. */
378        bsmartcard_state_reset_done, /* The slot/card reset has completed.  Persistent. */
379        bsmartcard_state_activating, /* The slot/card is currently being activated, but activation is not yet complete.  Transient. */
380        bsmartcard_state_receive_decode_atr, /* The ATR is being received or decoded.  Transient. */
381        bsmartcard_state_ready, /* The slot/card is initialized and is awaiting sends/receives.  Persistent. */
382        bsmartcard_state_transmitting, /* The slot/card is currently transmitting.  Transient. */
383        bsmartcard_state_transmitted, /* The slot/card has completed its transmission.  Persistent. */
384        bsmartcard_state_receiving, /* The slot/card is currently receiving.  Transient. */
385        bsmartcard_state_ignore, /* The slot/card is ignoring events/commands.  Persistent. */
386        bsmartcard_state_initialized, /* The slot/card has been initialized, but the ATR has not yet been received.  Persistent. */
387        bsmartcard_state_max_state /* A value indicating the total number of possible states.  The state returned from bsmartcard_get_status should never exceed this value. */
388} bsmartcard_state;
389/*
390Summary:
391        Status information returned by bsmartcard_get_status.
392*/
393typedef struct bsmartcard_status {
394        bool card_present;
395        bsmartcard_error err;
396        bsmartcard_state state;
397} bsmartcard_status;
398
399/*
400Summary:
401Get the status of the smartcard interface.
402Description:
403This function must be called after read or write fails in order to determine the
404state of the smartcard interface.
405*/
406bresult bsmartcard_get_status(
407        bsmartcard_t smartcard,
408        bsmartcard_status *status               /* [out] Fills in the status information. */
409);
410
411/*
412Summary:
413        Reset a smartcard.
414Description:
415        Reset the smartcard itself.
416*/
417bresult bsmartcard_reset_card(
418        bsmartcard_t smartcard, /* handle returned by bsmartcard_open */
419        void *data,                             /* [out,size_is(length)] pointer to memory that can be read into */
420        size_t length,                  /* maximum number of bytes pointed to by data */
421        size_t *length_read             /* [out] length of data read into the data field. */
422);
423
424/*
425Summary:
426        Reset the smartcard interface.
427Description:
428        Reprogram all the Broadcom smartcard interface, not the card.
429        If you want to reset the card, use bsmartcard_reset_card.
430
431        The interface must be reset whenever a card is inserted.
432*/
433bresult bsmartcard_reset(
434        bsmartcard_t smartcard, /* handle returned by bsmartcard_open */
435        bool warm_reset /* true for a warm reset, false for a cold reset */
436);
437
438
439/*
440Summary:
441        Detect the card insertion.
442Description:
443        The function will be blocked until the card is inserted.
444*/
445bresult bsmartcard_detect_card( /* name changed: was bsmartcard_detectCardPres */
446                bsmartcard_t smartcard
447);
448
449/*
450Summary:
451        Smartcard initialization.
452Description:
453        The function initializes the smartcard module.
454*/
455bresult bsmartcard_init(void);
456
457/*
458Summary:
459        Smartcard shutdown.
460Description:
461        The function shutdowns the smartcard module.
462*/
463
464void bsmartcard_shutdown(void);
465
466#ifdef __cplusplus
467}
468#endif
469
470
471#endif /* BSETTOP_SMARTCARD_H__ */
Note: See TracBrowser for help on using the repository browser.