blob: 9a6b24e8eb7296a62ce295cac5978a3cc05ffbf0 [file] [log] [blame]
Harald Weltefa2d9272019-05-19 00:45:17 +02001#pragma once
2
3#include <osmocom/core/fsm.h>
4struct card_uart;
5
6enum iso7816_3_event {
7 ISO7816_E_RX_SINGLE, /*!< single-byte data received on UART */
8 ISO7816_E_RX_COMPL, /*!< data receive complete on UART */
9 ISO7816_E_TX_COMPL, /*!< data transmit complete on UART */
10 ISO7816_E_POWER_UP_IND, /*!< Card powered up */
11 ISO7816_E_RESET_REL_IND, /*!< Reset released */
12 ISO7816_E_RX_ERR_IND, /*!< Uncorrectable Rx [parity] error */
13 ISO7816_E_TX_ERR_IND, /*!< Uncorrectable Rx [parity] error */
14 ISO7816_E_XCEIVE_TPDU_CMD, /*!< Ask for start of TPDU transmission */
15 /* allstate events */
16 ISO7816_E_WTIME_EXP, /*!< WTIME expired */
17 ISO7816_E_HW_ERR_IND, /*!< Hardware error (overcurrent, ...) */
18 ISO7816_E_SW_ERR_IND, /*!< Software error */
19 ISO7816_E_CARD_REMOVAL, /*!< card has been removed from slot */
20 ISO7816_E_POWER_DN_IND, /*!< Card powered down */
21 ISO7816_E_RESET_ACT_IND, /*!< Reset activated */
22 ISO7816_E_ABORT_REQ, /*!< Abort request (e.g. from CCID) */
23 /* TODO: PPS request */
24 /* TODO: Clock stop request */
25 /* TODO: Rx FIFO overrun */
26 /* TODO: Rx buffer overrun */
27
28 /* internal events between FSMs in this file */
29 ISO7816_E_ATR_DONE_IND, /*!< ATR Done indication from ATR child FSM */
30 ISO7816_E_TPDU_DONE_IND, /*!< TPDU Done indication from TPDU child FSM */
31 ISO7816_E_TPDU_CLEAR_REQ, /*!< Return TPDU FSM to TPDU_S_INIT */
32};
33
34typedef void (*iso7816_user_cb)(struct osmo_fsm_inst *fi, int event, int cause, void *data);
35
36struct osmo_fsm_inst *iso7816_fsm_alloc(void *ctx, int log_level, const char *id,
37 struct card_uart *cuart, iso7816_user_cb user_cb,
38 void *ussr_priv);
39
40void *iso7816_fsm_get_user_priv(struct osmo_fsm_inst *fi);