blob: 7144168d66c147d44ca8f822625edadf2c147f91 [file] [log] [blame]
Kévin Redon9a12d682018-07-08 13:21:16 +02001/* ISO7816-3 state machine for the card side
2 *
3 * (C) 2010-2017 by Harald Welte <hwelte@hmw-consulting.de>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
18 */
Harald Welte9d3e3822015-11-09 00:50:54 +010019#pragma once
20
21#include <stdint.h>
22
23struct card_handle;
24
25enum card_io {
26 CARD_IO_VCC,
27 CARD_IO_RST,
28 CARD_IO_CLK,
29};
30
Harald Welte8e7fca32017-05-07 16:14:33 +020031struct card_handle *card_emu_init(uint8_t slot_num, uint8_t tc_chan, uint8_t uart_chan,
32 uint8_t in_ep, uint8_t irq_ep);
Harald Welte9d3e3822015-11-09 00:50:54 +010033
34/* process a single byte received from the reader */
35void card_emu_process_rx_byte(struct card_handle *ch, uint8_t byte);
36
Harald Welte855ba9e2016-02-24 21:00:46 +010037/* transmit a single byte to the reader */
38int card_emu_tx_byte(struct card_handle *ch);
Harald Welte9d3e3822015-11-09 00:50:54 +010039
40/* hardware driver informs us that a card I/O signal has changed */
41void card_emu_io_statechg(struct card_handle *ch, enum card_io io, int active);
42
43/* User sets a new ATR to be returned during next card reset */
44int card_emu_set_atr(struct card_handle *ch, const uint8_t *atr, uint8_t len);
45
Harald Welte54cb3d02016-02-29 14:12:40 +010046struct llist_head *card_emu_get_uart_tx_queue(struct card_handle *ch);
Harald Welteacae4122016-03-02 10:27:58 +010047void card_emu_have_new_uart_tx(struct card_handle *ch);
Harald Welteff160652016-03-19 21:59:06 +010048void card_emu_report_status(struct card_handle *ch);
Harald Welte9d3e3822015-11-09 00:50:54 +010049
50#define ENABLE_TX 0x01
51#define ENABLE_RX 0x02
52
53int card_emu_uart_update_fidi(uint8_t uart_chan, unsigned int fidi);
54int card_emu_uart_tx(uint8_t uart_chan, uint8_t byte);
55void card_emu_uart_enable(uint8_t uart_chan, uint8_t rxtx);
Harald Weltec58bba02016-03-20 14:57:53 +010056void card_emu_uart_wait_tx_idle(uint8_t uart_chan);