root / hw / ccid.h @ 0cdd3d14
History | View | Annotate | Download (1.9 kB)
1 | 36707144 | Alon Levy | /*
|
---|---|---|---|
2 | 36707144 | Alon Levy | * CCID Passthru Card Device emulation
|
3 | 36707144 | Alon Levy | *
|
4 | 36707144 | Alon Levy | * Copyright (c) 2011 Red Hat.
|
5 | 36707144 | Alon Levy | * Written by Alon Levy.
|
6 | 36707144 | Alon Levy | *
|
7 | 8e31bf38 | Matthew Fernandez | * This code is licensed under the GNU LGPL, version 2 or later.
|
8 | 36707144 | Alon Levy | */
|
9 | 36707144 | Alon Levy | |
10 | 36707144 | Alon Levy | #ifndef CCID_H
|
11 | 36707144 | Alon Levy | #define CCID_H
|
12 | 36707144 | Alon Levy | |
13 | 36707144 | Alon Levy | #include "qdev.h" |
14 | 36707144 | Alon Levy | |
15 | 36707144 | Alon Levy | typedef struct CCIDCardState CCIDCardState; |
16 | 36707144 | Alon Levy | typedef struct CCIDCardInfo CCIDCardInfo; |
17 | 36707144 | Alon Levy | |
18 | ba7c0520 | Anthony Liguori | #define TYPE_CCID_CARD "ccid-card" |
19 | ba7c0520 | Anthony Liguori | #define CCID_CARD(obj) \
|
20 | ba7c0520 | Anthony Liguori | OBJECT_CHECK(CCIDCardState, (obj), TYPE_CCID_CARD) |
21 | ba7c0520 | Anthony Liguori | #define CCID_CARD_CLASS(klass) \
|
22 | ba7c0520 | Anthony Liguori | OBJECT_CLASS_CHECK(CCIDCardClass, (klass), TYPE_CCID_CARD) |
23 | ba7c0520 | Anthony Liguori | #define CCID_CARD_GET_CLASS(obj) \
|
24 | ba7c0520 | Anthony Liguori | OBJECT_GET_CLASS(CCIDCardClass, (obj), TYPE_CCID_CARD) |
25 | 36707144 | Alon Levy | |
26 | 36707144 | Alon Levy | /*
|
27 | 36707144 | Alon Levy | * callbacks to be used by the CCID device (hw/usb-ccid.c) to call
|
28 | 36707144 | Alon Levy | * into the smartcard device (hw/ccid-card-*.c)
|
29 | 36707144 | Alon Levy | */
|
30 | ba7c0520 | Anthony Liguori | typedef struct CCIDCardClass { |
31 | ba7c0520 | Anthony Liguori | DeviceClass parent_class; |
32 | 36707144 | Alon Levy | const uint8_t *(*get_atr)(CCIDCardState *card, uint32_t *len);
|
33 | 36707144 | Alon Levy | void (*apdu_from_guest)(CCIDCardState *card,
|
34 | 36707144 | Alon Levy | const uint8_t *apdu,
|
35 | 36707144 | Alon Levy | uint32_t len); |
36 | 36707144 | Alon Levy | int (*exitfn)(CCIDCardState *card);
|
37 | 36707144 | Alon Levy | int (*initfn)(CCIDCardState *card);
|
38 | ba7c0520 | Anthony Liguori | } CCIDCardClass; |
39 | ba7c0520 | Anthony Liguori | |
40 | ba7c0520 | Anthony Liguori | /*
|
41 | ba7c0520 | Anthony Liguori | * state of the CCID Card device (i.e. hw/ccid-card-*.c)
|
42 | ba7c0520 | Anthony Liguori | */
|
43 | ba7c0520 | Anthony Liguori | struct CCIDCardState {
|
44 | ba7c0520 | Anthony Liguori | DeviceState qdev; |
45 | ba7c0520 | Anthony Liguori | uint32_t slot; /* For future use with multiple slot reader. */
|
46 | 36707144 | Alon Levy | }; |
47 | 36707144 | Alon Levy | |
48 | 36707144 | Alon Levy | /*
|
49 | 36707144 | Alon Levy | * API for smartcard calling the CCID device (used by hw/ccid-card-*.c)
|
50 | 36707144 | Alon Levy | */
|
51 | 36707144 | Alon Levy | void ccid_card_send_apdu_to_guest(CCIDCardState *card,
|
52 | 36707144 | Alon Levy | uint8_t *apdu, |
53 | 36707144 | Alon Levy | uint32_t len); |
54 | 36707144 | Alon Levy | void ccid_card_card_removed(CCIDCardState *card);
|
55 | 36707144 | Alon Levy | void ccid_card_card_inserted(CCIDCardState *card);
|
56 | 36707144 | Alon Levy | void ccid_card_card_error(CCIDCardState *card, uint64_t error);
|
57 | 36707144 | Alon Levy | |
58 | 36707144 | Alon Levy | /*
|
59 | 36707144 | Alon Levy | * support guest visible insertion/removal of ccid devices based on actual
|
60 | 36707144 | Alon Levy | * devices connected/removed. Called by card implementation (passthru, local)
|
61 | 36707144 | Alon Levy | */
|
62 | 36707144 | Alon Levy | int ccid_card_ccid_attach(CCIDCardState *card);
|
63 | 36707144 | Alon Levy | void ccid_card_ccid_detach(CCIDCardState *card);
|
64 | 36707144 | Alon Levy | |
65 | 36707144 | Alon Levy | #endif /* CCID_H */ |