ccid.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * CCID Passthru Card Device emulation
  3. *
  4. * Copyright (c) 2011 Red Hat.
  5. * Written by Alon Levy.
  6. *
  7. * This code is licensed under the GNU LGPL, version 2 or later.
  8. */
  9. #ifndef CCID_H
  10. #define CCID_H
  11. #include "hw/qdev-core.h"
  12. #include "qom/object.h"
  13. typedef struct CCIDCardInfo CCIDCardInfo;
  14. #define TYPE_CCID_CARD "ccid-card"
  15. OBJECT_DECLARE_TYPE(CCIDCardState, CCIDCardClass, CCID_CARD)
  16. /*
  17. * callbacks to be used by the CCID device (hw/usb-ccid.c) to call
  18. * into the smartcard device (hw/ccid-card-*.c)
  19. */
  20. struct CCIDCardClass {
  21. /*< private >*/
  22. DeviceClass parent_class;
  23. /*< public >*/
  24. const uint8_t *(*get_atr)(CCIDCardState *card, uint32_t *len);
  25. void (*apdu_from_guest)(CCIDCardState *card,
  26. const uint8_t *apdu,
  27. uint32_t len);
  28. void (*realize)(CCIDCardState *card, Error **errp);
  29. void (*unrealize)(CCIDCardState *card);
  30. };
  31. /*
  32. * state of the CCID Card device (i.e. hw/ccid-card-*.c)
  33. */
  34. struct CCIDCardState {
  35. DeviceState qdev;
  36. uint32_t slot; /* For future use with multiple slot reader. */
  37. };
  38. /*
  39. * API for smartcard calling the CCID device (used by hw/ccid-card-*.c)
  40. */
  41. void ccid_card_send_apdu_to_guest(CCIDCardState *card,
  42. uint8_t *apdu,
  43. uint32_t len);
  44. void ccid_card_card_removed(CCIDCardState *card);
  45. void ccid_card_card_inserted(CCIDCardState *card);
  46. void ccid_card_card_error(CCIDCardState *card, uint64_t error);
  47. /*
  48. * support guest visible insertion/removal of ccid devices based on actual
  49. * devices connected/removed. Called by card implementation (passthru, local)
  50. */
  51. int ccid_card_ccid_attach(CCIDCardState *card);
  52. void ccid_card_ccid_detach(CCIDCardState *card);
  53. #endif /* CCID_H */