Harald Welte | 0634836 | 2019-05-19 00:45:17 +0200 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <osmocom/core/fsm.h> |
| 4 | struct card_uart; |
| 5 | |
| 6 | enum 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 */ |
Harald Welte | 1ac9ef9 | 2019-10-09 22:20:16 +0200 | [diff] [blame] | 30 | ISO7816_E_ATR_ERR_IND, /*!< ATR Error indication from ATR child FSM */ |
Harald Welte | 0634836 | 2019-05-19 00:45:17 +0200 | [diff] [blame] | 31 | ISO7816_E_TPDU_DONE_IND, /*!< TPDU Done indication from TPDU child FSM */ |
| 32 | ISO7816_E_TPDU_CLEAR_REQ, /*!< Return TPDU FSM to TPDU_S_INIT */ |
| 33 | }; |
| 34 | |
| 35 | typedef void (*iso7816_user_cb)(struct osmo_fsm_inst *fi, int event, int cause, void *data); |
| 36 | |
| 37 | struct osmo_fsm_inst *iso7816_fsm_alloc(void *ctx, int log_level, const char *id, |
| 38 | struct card_uart *cuart, iso7816_user_cb user_cb, |
| 39 | void *ussr_priv); |
| 40 | |
| 41 | void *iso7816_fsm_get_user_priv(struct osmo_fsm_inst *fi); |