mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-16 21:28:33 +03:00
I couldn't help but to spend my sunday on working towards card emulation, including * various state machines in the target about ISO7816 states * tc_etu timer import from simtrace1 * req_ctx import from simtrace1 (needs renaming and simplifiation) * USB protocol description as cardemu_prot.h * some host-based testing code to test the state machines The code seems to work fine throughout card reset, sending ATR and receiving the TPDU header of the first APDU, up to the point where it marks the TPDU header as to-be-transmitted over th bulk-in endpoint. Sending the ATR must be done inside the firmware for timing requirements. From that point onwards, the host needs to respond at the very least with a procedure byte, and some indication whether or not the card emulator should continue to transmit data (card->reader), or receive data (reader->card). The code is intentionally not hooked up yet with the USB logic nor with the UART. I want host-based testing completed before doing that.
19 lines
358 B
C
19 lines
358 B
C
#pragma once
|
|
|
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
|
|
|
#ifdef __ARM
|
|
#define local_irq_save(x) \
|
|
({ \
|
|
x = __get_PRIMASK(); \
|
|
__disable_irq(); \
|
|
})
|
|
|
|
#define local_irq_restore(x) \
|
|
__set_PRIMASK(x)
|
|
#else
|
|
#warning "local_irq_{save,restore}() not implemented"
|
|
#define local_irq_save(x)
|
|
#define local_irq_restore(x)
|
|
#endif
|