mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-16 21:28:33 +03:00
cardem: Add SIMTRACE_MSGT_BD_CEMU_CONFIG
The new SIMTRACE_MSGT_BD_CEMU_CONFIG command can be used to set/change a bitmask of optional features that can be enabled in the simtrace by the host software. This is useful for enabling features in the firmware which are not supported by older host utilities. The firmware will return the actually set/configured features in response. The feature bitmask is not yet used anywhere; it will be by subequent patches. Change-Id: I7cdd3f9171dbed45de0089defe29d2b59044bd84
This commit is contained in:
@@ -37,6 +37,9 @@
|
||||
|
||||
#define NUM_SLOTS 2
|
||||
|
||||
/* bit-mask of supported CEMU_FEAT_F_ flags */
|
||||
#define SUPPORTED_FEATURES 0
|
||||
|
||||
#define ISO7816_3_INIT_WTIME 9600
|
||||
#define ISO7816_3_DEFAULT_WI 10
|
||||
#define ISO7816_3_ATR_LEN_MAX (1+32) /* TS plus 32 chars */
|
||||
@@ -195,6 +198,9 @@ const struct value_string tpdu_state_names[] = {
|
||||
struct card_handle {
|
||||
unsigned int num;
|
||||
|
||||
/* bit-mask of enabled optional features (CEMU_FEAT_F_*) */
|
||||
uint32_t features;
|
||||
|
||||
enum iso7816_3_card_state state;
|
||||
|
||||
/* signal levels */
|
||||
@@ -1081,6 +1087,22 @@ void card_emu_report_status(struct card_handle *ch, bool report_on_irq)
|
||||
usb_buf_upd_len_and_submit(msg);
|
||||
}
|
||||
|
||||
static void card_emu_report_config(struct card_handle *ch)
|
||||
{
|
||||
struct msgb *msg;
|
||||
struct cardemu_usb_msg_config *cfg;
|
||||
uint8_t ep = ch->in_ep;
|
||||
|
||||
msg = usb_buf_alloc_st(ch->in_ep, SIMTRACE_MSGC_CARDEM, SIMTRACE_MSGT_BD_CEMU_CONFIG);
|
||||
if (!msg)
|
||||
return;
|
||||
|
||||
cfg = (struct cardemu_usb_msg_config *) msgb_put(msg, sizeof(*cfg));
|
||||
cfg->features = ch->features;
|
||||
|
||||
usb_buf_upd_len_and_submit(msg);
|
||||
}
|
||||
|
||||
/* hardware driver informs us that a card I/O signal has changed */
|
||||
void card_emu_io_statechg(struct card_handle *ch, enum card_io io, int active)
|
||||
{
|
||||
@@ -1204,6 +1226,18 @@ static const uint8_t default_atr[] = { 0x3B, 0x00 };
|
||||
|
||||
static struct card_handle card_handles[NUM_SLOTS];
|
||||
|
||||
int card_emu_set_config(struct card_handle *ch, const struct cardemu_usb_msg_config *scfg,
|
||||
unsigned int scfg_len)
|
||||
{
|
||||
if (scfg_len >= sizeof(uint32_t))
|
||||
ch->features = (scfg->features & SUPPORTED_FEATURES);
|
||||
|
||||
/* send back a report of our current configuration */
|
||||
card_emu_report_config(ch);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct card_handle *card_emu_init(uint8_t slot_num, uint8_t tc_chan, uint8_t uart_chan, uint8_t in_ep, uint8_t irq_ep, bool vcc_active, bool in_reset, bool clocked)
|
||||
{
|
||||
struct card_handle *ch;
|
||||
|
||||
Reference in New Issue
Block a user