From: Alon Levy <alevy@redhat.com>
To: qemu-devel@nongnu.org
Cc: mlureau@redhat.com
Subject: [Qemu-devel] [PATCH 15/26] hw/usb/dev-smartcard-reader.c: nicer debug messages
Date: Mon, 18 Mar 2013 15:11:01 +0200 [thread overview]
Message-ID: <1363612272-13713-16-git-send-email-alevy@redhat.com> (raw)
In-Reply-To: <1363612272-13713-1-git-send-email-alevy@redhat.com>
From: Alon Levy <alon@pobox.com>
Signed-off-by: Alon Levy <alevy@redhat.com>
---
hw/usb/dev-smartcard-reader.c | 69 +++++++++++++++++++++++++++++++++++++++----
1 file changed, 63 insertions(+), 6 deletions(-)
diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c
index 7205613..4ff0641 100644
--- a/hw/usb/dev-smartcard-reader.c
+++ b/hw/usb/dev-smartcard-reader.c
@@ -639,13 +639,47 @@ static void ccid_handle_reset(USBDevice *dev)
ccid_reset(s);
}
+static const char *ccid_control_to_str(USBCCIDState *s, int request)
+{
+ switch (request) {
+ /* generic - should be factored out if there are other debugees */
+ case DeviceOutRequest | USB_REQ_SET_ADDRESS:
+ return "(generic) set address";
+ case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
+ return "(generic) get descriptor";
+ case DeviceRequest | USB_REQ_GET_CONFIGURATION:
+ return "(generic) get configuration";
+ case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
+ return "(generic) set configuration";
+ case DeviceRequest | USB_REQ_GET_STATUS:
+ return "(generic) get status";
+ case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
+ return "(generic) clear feature";
+ case DeviceOutRequest | USB_REQ_SET_FEATURE:
+ return "(generic) set_feature";
+ case InterfaceRequest | USB_REQ_GET_INTERFACE:
+ return "(generic) get interface";
+ case InterfaceOutRequest | USB_REQ_SET_INTERFACE:
+ return "(generic) set interface";
+ /* class requests */
+ case ClassInterfaceOutRequest | CCID_CONTROL_ABORT:
+ return "ABORT";
+ case ClassInterfaceRequest | CCID_CONTROL_GET_CLOCK_FREQUENCIES:
+ return "GET_CLOCK_FREQUENCIES";
+ case ClassInterfaceRequest | CCID_CONTROL_GET_DATA_RATES:
+ return "GET_DATA_RATES";
+ }
+ return "unknown";
+}
+
static void ccid_handle_control(USBDevice *dev, USBPacket *p, int request,
int value, int index, int length, uint8_t *data)
{
USBCCIDState *s = DO_UPCAST(USBCCIDState, dev, dev);
int ret;
- DPRINTF(s, 1, "got control %x, value %x\n", request, value);
+ DPRINTF(s, 1, "%s: got control %s (%x), value %x\n", __func__,
+ ccid_control_to_str(s, request), request, value);
ret = usb_desc_handle_control(dev, p, request, value, index, length, data);
if (ret >= 0) {
return;
@@ -695,7 +729,7 @@ static uint8_t ccid_calc_status(USBCCIDState *s)
* bmCommandStatus
*/
uint8_t ret = ccid_card_status(s) | (s->bmCommandStatus << 6);
- DPRINTF(s, D_VERBOSE, "status = %d\n", ret);
+ DPRINTF(s, D_VERBOSE, "%s: status = %d\n", __func__, ret);
return ret;
}
@@ -756,7 +790,7 @@ static void ccid_write_data_block(USBCCIDState *s, uint8_t slot, uint8_t seq,
p->b.bStatus = ccid_calc_status(s);
p->b.bError = s->bError;
if (p->b.bError) {
- DPRINTF(s, D_VERBOSE, "error %d", p->b.bError);
+ DPRINTF(s, D_VERBOSE, "error %d\n", p->b.bError);
}
memcpy(p->abData, data, len);
ccid_reset_error_status(s);
@@ -873,6 +907,28 @@ static void ccid_on_apdu_from_guest(USBCCIDState *s, CCID_XferBlock *recv)
}
}
+static const char *ccid_message_type_to_str(uint8_t type)
+{
+ switch (type) {
+ case CCID_MESSAGE_TYPE_PC_to_RDR_IccPowerOn: return "IccPowerOn";
+ case CCID_MESSAGE_TYPE_PC_to_RDR_IccPowerOff: return "IccPowerOff";
+ case CCID_MESSAGE_TYPE_PC_to_RDR_GetSlotStatus: return "GetSlotStatus";
+ case CCID_MESSAGE_TYPE_PC_to_RDR_XfrBlock: return "XfrBlock";
+ case CCID_MESSAGE_TYPE_PC_to_RDR_GetParameters: return "GetParameters";
+ case CCID_MESSAGE_TYPE_PC_to_RDR_ResetParameters: return "ResetParameters";
+ case CCID_MESSAGE_TYPE_PC_to_RDR_SetParameters: return "SetParameters";
+ case CCID_MESSAGE_TYPE_PC_to_RDR_Escape: return "Escape";
+ case CCID_MESSAGE_TYPE_PC_to_RDR_IccClock: return "IccClock";
+ case CCID_MESSAGE_TYPE_PC_to_RDR_T0APDU: return "T0APDU";
+ case CCID_MESSAGE_TYPE_PC_to_RDR_Secure: return "Secure";
+ case CCID_MESSAGE_TYPE_PC_to_RDR_Mechanical: return "Mechanical";
+ case CCID_MESSAGE_TYPE_PC_to_RDR_Abort: return "Abort";
+ case CCID_MESSAGE_TYPE_PC_to_RDR_SetDataRateAndClockFrequency:
+ return "SetDataRateAndClockFrequency";
+ }
+ return "unknown";
+}
+
static void ccid_handle_bulk_out(USBCCIDState *s, USBPacket *p)
{
CCID_Header *ccid_header;
@@ -895,13 +951,15 @@ static void ccid_handle_bulk_out(USBCCIDState *s, USBPacket *p)
"%s: bad USB_TOKEN_OUT length, should be at least 10 bytes\n",
__func__);
} else {
- DPRINTF(s, D_MORE_INFO, "%s %x\n", __func__, ccid_header->bMessageType);
+ DPRINTF(s, D_MORE_INFO, "%s %x %s\n", __func__,
+ ccid_header->bMessageType,
+ ccid_message_type_to_str(ccid_header->bMessageType));
switch (ccid_header->bMessageType) {
case CCID_MESSAGE_TYPE_PC_to_RDR_GetSlotStatus:
ccid_write_slot_status(s, ccid_header);
break;
case CCID_MESSAGE_TYPE_PC_to_RDR_IccPowerOn:
- DPRINTF(s, 1, "PowerOn: %d\n",
+ DPRINTF(s, 1, "%s: PowerOn: %d\n", __func__,
((CCID_IccPowerOn *)(ccid_header))->bPowerSelect);
s->powered = true;
if (!ccid_card_inserted(s)) {
@@ -911,7 +969,6 @@ static void ccid_handle_bulk_out(USBCCIDState *s, USBPacket *p)
ccid_write_data_block_atr(s, ccid_header);
break;
case CCID_MESSAGE_TYPE_PC_to_RDR_IccPowerOff:
- DPRINTF(s, 1, "PowerOff\n");
ccid_reset_error_status(s);
s->powered = false;
ccid_write_slot_status(s, ccid_header);
--
1.8.1.4
next prev parent reply other threads:[~2013-03-18 13:12 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-18 13:10 [Qemu-devel] [PATCH 00/26] ccid and libcacard fixes for windows/mingw Alon Levy
2013-03-18 13:10 ` [Qemu-devel] [PATCH 01/26] libcacard: correct T0 historical bytes size Alon Levy
2013-03-18 13:10 ` [Qemu-devel] [PATCH 02/26] ccid-card-emul: do not crash if backend is not provided Alon Levy
2013-03-18 13:10 ` [Qemu-devel] [PATCH 03/26] ccid: make backend_enum_table "static const" and adjust users Alon Levy
2013-03-18 13:10 ` [Qemu-devel] [PATCH 04/26] ccid: declare DEFAULT_ATR table to be "static const" Alon Levy
2013-03-18 13:10 ` [Qemu-devel] [PATCH 05/26] libcacard: use system config directory for nss db on win32 Alon Levy
2013-03-18 13:10 ` [Qemu-devel] [PATCH 06/26] util: move socket_init() to osdep.c Alon Levy
2013-03-18 13:10 ` [Qemu-devel] [PATCH 07/26] build-sys: must link with -fstack-protector Alon Levy
2013-03-22 17:18 ` Paolo Bonzini
2013-03-18 13:10 ` [Qemu-devel] [PATCH 08/26] libcacard: fix mingw64 cross-compilation Alon Levy
2013-03-18 14:54 ` Paolo Bonzini
2013-03-18 13:10 ` [Qemu-devel] [PATCH 09/26] libcacard: split vscclient main() from socket reading Alon Levy
2013-03-18 13:10 ` [Qemu-devel] [PATCH 10/26] libcacard: vscclient to use QemuThread for portability Alon Levy
2013-03-18 13:10 ` [Qemu-devel] [PATCH 11/26] libcacard: teach vscclient to use GMainLoop " Alon Levy
2013-03-18 13:10 ` [Qemu-devel] [PATCH 12/26] hw/ccid-card-passthru.c: add atr check Alon Levy
2013-03-22 14:23 ` Marc-André Lureau
2013-03-22 19:31 ` Alon Levy
2013-03-18 13:10 ` [Qemu-devel] [PATCH 13/26] ccid-card-passthru, dev-smartcard-reader: add debug environment variables Alon Levy
2013-03-22 14:23 ` Marc-André Lureau
2013-03-18 13:11 ` [Qemu-devel] [PATCH 14/26] hw/usb/dev-smartcard-reader.c: white space fixes Alon Levy
2013-03-22 14:23 ` Marc-André Lureau
2013-03-18 13:11 ` Alon Levy [this message]
2013-03-22 14:23 ` [Qemu-devel] [PATCH 15/26] hw/usb/dev-smartcard-reader.c: nicer debug messages Marc-André Lureau
2013-03-18 13:11 ` [Qemu-devel] [PATCH 16/26] hw/usb/dev-smartcard-reader.c: remove aborts (never triggered, but just in case) Alon Levy
2013-03-22 14:23 ` Marc-André Lureau
2013-03-18 13:11 ` [Qemu-devel] [PATCH 17/26] hw/usb/dev-smartcard-reader.c: define structs for CCID_Parameter internals Alon Levy
2013-03-22 14:23 ` Marc-André Lureau
2013-03-18 13:11 ` [Qemu-devel] [PATCH 18/26] hw/usb/dev-smartcard-reader.c: copy atr's protocol to ccid's parameters (adds todo's) Alon Levy
2013-03-22 14:23 ` Marc-André Lureau
2013-03-27 15:06 ` Alon Levy
2013-03-18 13:11 ` [Qemu-devel] [PATCH 19/26] hw/usb/dev-smartcard-reader.c: dwFeadvertise support for T=0 only Alon Levy
2013-03-22 14:23 ` Marc-André Lureau
2013-03-18 13:11 ` [Qemu-devel] [PATCH 20/26] hw/usb/dev-smartcard-reader: support windows guest Alon Levy
2013-03-22 14:23 ` Marc-André Lureau
2013-03-18 13:11 ` [Qemu-devel] [PATCH 21/26] dev-smartcard-reader: reuse usb.h definitions Alon Levy
2013-03-22 14:22 ` Marc-André Lureau
2013-03-18 13:11 ` [Qemu-devel] [PATCH 22/26] libcacard/vreader: add debugging messages for apdu Alon Levy
2013-03-22 14:22 ` Marc-André Lureau
2013-03-18 13:11 ` [Qemu-devel] [PATCH 23/26] libcacard: change default ATR Alon Levy
2013-03-22 14:22 ` Marc-André Lureau
2013-03-18 13:11 ` [Qemu-devel] [PATCH 24/26] libcacard: move atr setting from macro to function Alon Levy
2013-03-22 14:22 ` Marc-André Lureau
2013-03-22 19:33 ` Alon Levy
2013-03-18 13:11 ` [Qemu-devel] [PATCH 25/26] dev-smartcard-reader: empty implementation for Mechanical (fail correctly) Alon Levy
2013-03-22 14:22 ` Marc-André Lureau
2013-03-18 13:11 ` [Qemu-devel] [PATCH 26/26] libcacard/cac.c: questionable change to single return of big switch functions Alon Levy
2013-03-22 14:22 ` Marc-André Lureau
2013-03-18 13:15 ` [Qemu-devel] [PATCH 00/26] ccid and libcacard fixes for windows/mingw Alon Levy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1363612272-13713-16-git-send-email-alevy@redhat.com \
--to=alevy@redhat.com \
--cc=mlureau@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).