2018-07-08 11:21:16 +00:00
|
|
|
/* SIMtrace 2 mode definitions
|
|
|
|
*
|
2019-08-06 13:41:31 +00:00
|
|
|
* Copyright (c) 2015-2017 by Harald Welte <hwelte@hmw-consulting.de>
|
|
|
|
* Copyright (c) 2018-2019, sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de>
|
2018-07-08 11:21:16 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
*/
|
2015-02-25 13:02:01 +00:00
|
|
|
#ifndef SIMTRACE_H
|
|
|
|
#define SIMTRACE_H
|
2015-02-24 10:35:19 +00:00
|
|
|
|
2015-04-11 16:14:41 +00:00
|
|
|
#include "ringbuffer.h"
|
2016-03-03 10:02:45 +00:00
|
|
|
#include "board.h"
|
2017-11-28 19:58:06 +00:00
|
|
|
#include <usb/device/dfu/dfu.h>
|
2015-04-11 16:14:41 +00:00
|
|
|
|
2015-06-24 14:05:09 +00:00
|
|
|
#define BUFLEN 512
|
2015-04-03 09:35:59 +00:00
|
|
|
|
2015-04-16 08:45:39 +00:00
|
|
|
#define CLK_MASTER true
|
|
|
|
#define CLK_SLAVE false
|
|
|
|
|
|
|
|
/* ===================================================*/
|
|
|
|
/* Taken from iso7816_4.c */
|
|
|
|
/* ===================================================*/
|
|
|
|
/** Flip flop for send and receive char */
|
|
|
|
#define USART_SEND 0
|
|
|
|
#define USART_RCV 1
|
|
|
|
|
2015-04-10 13:38:49 +00:00
|
|
|
|
2015-04-11 16:14:41 +00:00
|
|
|
extern volatile ringbuf sim_rcv_buf;
|
2015-04-09 20:38:47 +00:00
|
|
|
|
|
|
|
extern volatile bool rcvdChar;
|
|
|
|
extern volatile uint32_t char_stat;
|
2015-03-02 15:14:09 +00:00
|
|
|
|
2015-04-20 11:07:28 +00:00
|
|
|
extern const Pin pinPhoneRST;
|
|
|
|
|
2015-02-25 17:40:15 +00:00
|
|
|
enum confNum {
|
2016-03-03 10:02:45 +00:00
|
|
|
CFG_NUM_NONE = 0,
|
|
|
|
#ifdef HAVE_SNIFFER
|
|
|
|
CFG_NUM_SNIFF,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_CCID
|
|
|
|
CFG_NUM_CCID,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_CARDEM
|
|
|
|
CFG_NUM_PHONE,
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_MITM
|
|
|
|
CFG_NUM_MITM,
|
|
|
|
#endif
|
2019-08-06 13:41:31 +00:00
|
|
|
CFG_NUM_VERSION,
|
2016-03-03 10:02:45 +00:00
|
|
|
NUM_CONF
|
2015-02-25 17:40:15 +00:00
|
|
|
};
|
|
|
|
|
2015-03-03 11:34:36 +00:00
|
|
|
/// CCIDDriverConfiguration Descriptors
|
|
|
|
/// List of descriptors that make up the configuration descriptors of a
|
|
|
|
/// device using the CCID driver.
|
|
|
|
typedef struct {
|
|
|
|
|
2018-07-08 11:58:12 +00:00
|
|
|
/// Configuration descriptor
|
|
|
|
USBConfigurationDescriptor configuration;
|
|
|
|
/// Interface descriptor
|
|
|
|
USBInterfaceDescriptor interface;
|
|
|
|
/// CCID descriptor
|
|
|
|
CCIDDescriptor ccid;
|
|
|
|
/// Bulk OUT endpoint descriptor
|
|
|
|
USBEndpointDescriptor bulkOut;
|
|
|
|
/// Bulk IN endpoint descriptor
|
|
|
|
USBEndpointDescriptor bulkIn;
|
|
|
|
/// Interrupt OUT endpoint descriptor
|
|
|
|
USBEndpointDescriptor interruptIn;
|
|
|
|
DFURT_IF_DESCRIPTOR_STRUCT
|
2015-03-03 11:34:36 +00:00
|
|
|
} __attribute__ ((packed)) CCIDDriverConfigurationDescriptors;
|
|
|
|
|
2015-04-06 21:28:02 +00:00
|
|
|
extern const USBConfigurationDescriptor *configurationDescriptorsArr[];
|
|
|
|
|
2018-06-25 13:53:19 +00:00
|
|
|
/*! Update USART baud rate to Fi/Di ratio
|
|
|
|
* @param[io] usart USART peripheral base address
|
|
|
|
* @param[in] fidi FiDi value as provided in TA interface byte
|
|
|
|
*/
|
|
|
|
void update_fidi(Usart_info *usart, uint8_t fidi);
|
2015-05-02 15:56:32 +00:00
|
|
|
|
2015-04-20 11:07:28 +00:00
|
|
|
void ISR_PhoneRST( const Pin *pPin);
|
2015-03-03 11:34:36 +00:00
|
|
|
|
2015-04-09 20:38:47 +00:00
|
|
|
/* Configure functions */
|
|
|
|
extern void Sniffer_configure( void );
|
|
|
|
extern void CCID_configure( void );
|
2016-02-28 18:29:14 +00:00
|
|
|
extern void mode_cardemu_configure(void);
|
2015-04-09 20:38:47 +00:00
|
|
|
extern void MITM_configure( void );
|
|
|
|
|
2015-02-27 12:33:52 +00:00
|
|
|
/* Init functions */
|
2015-04-09 20:38:47 +00:00
|
|
|
extern void Sniffer_init( void );
|
2015-03-03 11:34:36 +00:00
|
|
|
extern void CCID_init( void );
|
2016-02-28 18:29:14 +00:00
|
|
|
extern void mode_cardemu_init(void);
|
2015-02-27 12:33:52 +00:00
|
|
|
extern void MITM_init( void );
|
2015-02-24 18:09:08 +00:00
|
|
|
|
2015-02-25 13:02:01 +00:00
|
|
|
extern void SIMtrace_USB_Initialize( void );
|
|
|
|
|
2015-04-09 20:38:47 +00:00
|
|
|
/* Exit functions */
|
|
|
|
extern void Sniffer_exit( void );
|
|
|
|
extern void CCID_exit( void );
|
2016-02-28 18:29:14 +00:00
|
|
|
extern void mode_cardemu_exit(void);
|
2015-04-09 20:38:47 +00:00
|
|
|
extern void MITM_exit( void );
|
|
|
|
|
2015-02-27 12:33:52 +00:00
|
|
|
/* Run functions */
|
|
|
|
extern void Sniffer_run( void );
|
2015-03-03 11:34:36 +00:00
|
|
|
extern void CCID_run( void );
|
2016-02-28 18:29:14 +00:00
|
|
|
extern void mode_cardemu_run(void);
|
2015-02-27 12:33:52 +00:00
|
|
|
extern void MITM_run( void );
|
|
|
|
|
2018-06-06 14:13:48 +00:00
|
|
|
/* IRQ functions */
|
2018-06-07 16:56:41 +00:00
|
|
|
extern void Sniffer_usart0_irq(void);
|
2018-06-11 11:45:16 +00:00
|
|
|
extern void Sniffer_usart1_irq(void);
|
2016-03-20 15:43:12 +00:00
|
|
|
extern void mode_cardemu_usart0_irq(void);
|
|
|
|
extern void mode_cardemu_usart1_irq(void);
|
|
|
|
|
2015-03-19 18:27:04 +00:00
|
|
|
/* Timer helper function */
|
|
|
|
void Timer_Init( void );
|
|
|
|
void TC0_Counter_Reset( void );
|
|
|
|
|
2015-02-27 12:33:52 +00:00
|
|
|
#endif /* SIMTRACE_H */
|