mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-16 21:28:33 +03:00
simtrace2-cardem-pcsc: Reset the real card if reader resets cardem
When the cardem detects a reset from the phone/modem, pass this on to the actual card via the PC/SC reader. This is important to reset the card state whenever requested by the stack/driver on the phone/modem. Change-Id: I7056476c5f81e8aa8f550afb86bf2380d1497ebb Depends: libosmocore 20199da02d37a6d284915a27ec12641e79b8781c
This commit is contained in:
@@ -74,6 +74,27 @@ static void cemu_flags2str(char *out, unsigned int out_len, uint32_t flags)
|
|||||||
flags & CEMU_STATUS_F_RCEMU_ACTIVE ? "RCEMU " : "");
|
flags & CEMU_STATUS_F_RCEMU_ACTIVE ? "RCEMU " : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t last_flags = 0;
|
||||||
|
|
||||||
|
static void update_flags(struct osmo_st2_cardem_inst *ci, uint32_t flags)
|
||||||
|
{
|
||||||
|
struct osim_card_hdl *card = ci->chan->card;
|
||||||
|
|
||||||
|
if ((flags & CEMU_STATUS_F_VCC_PRESENT) && (flags & CEMU_STATUS_F_CLK_ACTIVE) &&
|
||||||
|
!(flags & CEMU_STATUS_F_RESET_ACTIVE)) {
|
||||||
|
if (last_flags & CEMU_STATUS_F_RESET_ACTIVE) {
|
||||||
|
/* a reset has just ended, forward it to the real card */
|
||||||
|
bool cold_reset = true;
|
||||||
|
if (last_flags & CEMU_STATUS_F_VCC_PRESENT)
|
||||||
|
cold_reset = false;
|
||||||
|
LOGCI(ci, LOGL_NOTICE, "%s Resetting card in reader...\n",
|
||||||
|
cold_reset ? "Cold" : "Warm");
|
||||||
|
osim_card_reset(card, cold_reset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
last_flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Incoming Messages
|
* Incoming Messages
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
@@ -89,6 +110,8 @@ static int process_do_status(struct osmo_st2_cardem_inst *ci, uint8_t *buf, int
|
|||||||
status->flags, status->fi, status->di, status->wi,
|
status->flags, status->fi, status->di, status->wi,
|
||||||
status->waiting_time, fbuf);
|
status->waiting_time, fbuf);
|
||||||
|
|
||||||
|
update_flags(ci, status->flags);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,6 +218,8 @@ static int process_irq_status(struct osmo_st2_cardem_inst *ci, const uint8_t *bu
|
|||||||
status->flags, status->fi, status->di, status->wi,
|
status->flags, status->fi, status->di, status->wi,
|
||||||
status->waiting_time, fbuf);
|
status->waiting_time, fbuf);
|
||||||
|
|
||||||
|
update_flags(ci, status->flags);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user