blob: f5127090b8bf5dc506b0b2f68512515a350f6019 [file] [log] [blame]
Harald Welte06348362019-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 */
Eric Wildad1edce2019-11-27 16:51:08 +010024 ISO7816_E_XCEIVE_PPS_CMD,
25 ISO7816_E_PPS_DONE_IND,
26 ISO7816_E_PPS_FAILED_IND,
Harald Welte06348362019-05-19 00:45:17 +020027 /* TODO: Clock stop request */
28 /* TODO: Rx FIFO overrun */
29 /* TODO: Rx buffer overrun */
30
31 /* internal events between FSMs in this file */
32 ISO7816_E_ATR_DONE_IND, /*!< ATR Done indication from ATR child FSM */
Harald Welte1ac9ef92019-10-09 22:20:16 +020033 ISO7816_E_ATR_ERR_IND, /*!< ATR Error indication from ATR child FSM */
Harald Welte06348362019-05-19 00:45:17 +020034 ISO7816_E_TPDU_DONE_IND, /*!< TPDU Done indication from TPDU child FSM */
35 ISO7816_E_TPDU_CLEAR_REQ, /*!< Return TPDU FSM to TPDU_S_INIT */
36};
37
38typedef void (*iso7816_user_cb)(struct osmo_fsm_inst *fi, int event, int cause, void *data);
39
40struct osmo_fsm_inst *iso7816_fsm_alloc(void *ctx, int log_level, const char *id,
41 struct card_uart *cuart, iso7816_user_cb user_cb,
42 void *ussr_priv);
43
44void *iso7816_fsm_get_user_priv(struct osmo_fsm_inst *fi);