From nobody Sat Apr 27 13:03:58 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1673884045996402.28896908150784; Mon, 16 Jan 2023 07:47:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHRh9-0005FK-5D; Mon, 16 Jan 2023 10:46:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHRh5-0005F8-3r for qemu-devel@nongnu.org; Mon, 16 Jan 2023 10:46:43 -0500 Received: from a.mx.secunet.com ([62.96.220.36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHRh2-0002w6-IW for qemu-devel@nongnu.org; Mon, 16 Jan 2023 10:46:42 -0500 Received: from localhost (localhost [127.0.0.1]) by a.mx.secunet.com (Postfix) with ESMTP id C0A27200A7; Mon, 16 Jan 2023 16:46:33 +0100 (CET) Received: from a.mx.secunet.com ([127.0.0.1]) by localhost (a.mx.secunet.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id kr_dhlGBOMaI; Mon, 16 Jan 2023 16:46:33 +0100 (CET) Received: from mailout1.secunet.com (mailout1.secunet.com [62.96.220.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by a.mx.secunet.com (Postfix) with ESMTPS id 26FE42007F; Mon, 16 Jan 2023 16:46:33 +0100 (CET) Received: from cas-essen-01.secunet.de (unknown [10.53.40.201]) by mailout1.secunet.com (Postfix) with ESMTP id 1817580004A; Mon, 16 Jan 2023 16:46:33 +0100 (CET) Received: from mbx-dresden-01.secunet.de (10.53.40.199) by cas-essen-01.secunet.de (10.53.40.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 16 Jan 2023 16:46:32 +0100 Received: from mbx-essen-01.secunet.de (10.53.40.197) by mbx-dresden-01.secunet.de (10.53.40.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Mon, 16 Jan 2023 16:46:32 +0100 Received: from mbx-essen-01.secunet.de ([fe80::1522:bd4f:78cd:ce75]) by mbx-essen-01.secunet.de ([fe80::1522:bd4f:78cd:ce75%6]) with mapi id 15.01.2375.034; Mon, 16 Jan 2023 16:46:31 +0100 X-Virus-Scanned: by secunet From: "Ripke, Klaus" To: "qemu-devel@nongnu.org" CC: "kraxel@redhat.com" , "marcandre.lureau@gmail.com" Subject: [PATCH] usb-ccid: make ids and descriptor configurable Thread-Topic: [PATCH] usb-ccid: make ids and descriptor configurable Thread-Index: AQHZKcG0q3Fh+fkSEUuGnSe3Q7/htw== Date: Mon, 16 Jan 2023 15:46:31 +0000 Message-ID: Accept-Language: de-DE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="utf-8" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: 2c86f778-e09b-4440-8b15-867914633a10 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=62.96.220.36; envelope-from=klaus.ripke@secunet.com; helo=a.mx.secunet.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZM-MESSAGEID: 1673884047744100001 Signed-off-by: Klaus Ripke hw/usb/dev-smartcard-reader.c: Set some static values from ccid_properties. --- =C2=A0hw/usb/dev-smartcard-reader.c | 35 ++++++++++++++++++++++++++++++----- =C2=A01 file changed, 30 insertions(+), 5 deletions(-) diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard- reader.c index 28164d89be..4002157773 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -311,6 +311,11 @@ struct USBCCIDState { =C2=A0=C2=A0=C2=A0=C2=A0 uint8_t=C2=A0 powered; =C2=A0=C2=A0=C2=A0=C2=A0 uint8_t=C2=A0 notify_slot_change; =C2=A0=C2=A0=C2=A0=C2=A0 uint8_t=C2=A0 debug; +=C2=A0=C2=A0=C2=A0 /* the following are copied to static on initial realiz= e */ +=C2=A0=C2=A0=C2=A0 uint16_t vendor; +=C2=A0=C2=A0=C2=A0 uint16_t product; +=C2=A0=C2=A0=C2=A0 uint8_t=C2=A0 maxslot; +=C2=A0=C2=A0=C2=A0 uint8_t=C2=A0 feat2; =C2=A0}; =C2=A0 =C2=A0/* @@ -323,7 +328,11 @@ struct USBCCIDState { =C2=A0 *=C2=A0=C2=A0 0dc3:1004 Athena Smartcard Solutions, Inc. =C2=A0 */ =C2=A0 -static const uint8_t qemu_ccid_descriptor[] =3D { +enum { +=C2=A0=C2=A0=C2=A0 DESC_MAXSLOT =3D 4, +=C2=A0=C2=A0=C2=A0 DESC_FEAT2 =3D 42 /* dwFeatures byte 2 */ +}; +static uint8_t qemu_ccid_descriptor[] =3D { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Smart Card Device Class= Descriptor */ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0x36,=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 /* u8=C2=A0 bLength; */ =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0x21,=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 /* u8=C2=A0 bDescriptorType; Functional */ @@ -472,7 +481,7 @@ static const USBDescDevice desc_device =3D { =C2=A0=C2=A0=C2=A0=C2=A0 }, =C2=A0}; =C2=A0 -static const USBDesc desc_ccid =3D { +static USBDesc desc_ccid =3D { =C2=A0=C2=A0=C2=A0=C2=A0 .id =3D { =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .idVendor=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D CCID_VENDOR_ID, =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 .idProduct=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D CCID_PRODUCT_ID, @@ -1295,9 +1304,10 @@ static void ccid_card_realize(DeviceState *qdev, Error **errp) =C2=A0=C2=A0=C2=A0=C2=A0 USBCCIDState *s =3D USB_CCID_DEV(dev); =C2=A0=C2=A0=C2=A0=C2=A0 Error *local_err =3D NULL; =C2=A0 -=C2=A0=C2=A0=C2=A0 if (card->slot !=3D 0) { -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 error_setg(errp, "usb-ccid supp= orts one slot, can't add %d", -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 card->slot); +=C2=A0=C2=A0=C2=A0 DPRINTF(s, D_VERBOSE, "%s: slot %d\n", __func__, card->= slot); +=C2=A0=C2=A0=C2=A0 if (card->slot > qemu_ccid_descriptor[DESC_MAXSLOT]) { +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 error_setg(errp, "usb-ccid supp= orts %d slot, can't add %d", +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 qemu_ccid_descriptor[DESC_MAXSLOT] + 1= , card- >slot); =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return; =C2=A0=C2=A0=C2=A0=C2=A0 } =C2=A0=C2=A0=C2=A0=C2=A0 if (s->card !=3D NULL) { @@ -1317,6 +1327,14 @@ static void ccid_card_realize(DeviceState *qdev, Error **errp) =C2=A0static void ccid_realize(USBDevice *dev, Error **errp) =C2=A0{ =C2=A0=C2=A0=C2=A0=C2=A0 USBCCIDState *s =3D USB_CCID_DEV(dev); +=C2=A0=C2=A0=C2=A0 static int initialized; +=C2=A0=C2=A0=C2=A0 if (!initialized) { +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 desc_ccid.id.idVendor =3D s->ve= ndor; +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 desc_ccid.id.idProduct =3D s->p= roduct; +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 qemu_ccid_descriptor[DESC_MAXSL= OT] =3D s->maxslot; +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 qemu_ccid_descriptor[DESC_FEAT2= ] =3D s->feat2; +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 initialized =3D !0; +=C2=A0=C2=A0=C2=A0 } =C2=A0 =C2=A0=C2=A0=C2=A0=C2=A0 usb_desc_create_serial(dev); =C2=A0=C2=A0=C2=A0=C2=A0 usb_desc_init(dev); @@ -1339,6 +1357,8 @@ static void ccid_realize(USBDevice *dev, Error **errp) =C2=A0=C2=A0=C2=A0=C2=A0 ccid_reset_parameters(s); =C2=A0=C2=A0=C2=A0=C2=A0 ccid_reset(s); =C2=A0=C2=A0=C2=A0=C2=A0 s->debug =3D parse_debug_env("QEMU_CCID_DEBUG", D_= VERBOSE, s- >debug); +=C2=A0=C2=A0=C2=A0 DPRINTF(s, D_VERBOSE, "ccid_realize %d %x %x %x %x\n", +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 initialized, s->vendor, s->prod= uct, s->maxslot, s->feat2); =C2=A0} =C2=A0 =C2=A0static int ccid_post_load(void *opaque, int version_id) @@ -1434,9 +1454,14 @@ static const VMStateDescription ccid_vmstate =3D { =C2=A0 =C2=A0static Property ccid_properties[] =3D { =C2=A0=C2=A0=C2=A0=C2=A0 DEFINE_PROP_UINT8("debug", USBCCIDState, debug, 0), +=C2=A0=C2=A0=C2=A0 DEFINE_PROP_UINT16("vendor", USBCCIDState, vendor, CCID_VENDOR_ID), +=C2=A0=C2=A0=C2=A0 DEFINE_PROP_UINT16("product", USBCCIDState, product, CCID_PRODUCT_ID), +=C2=A0=C2=A0=C2=A0 DEFINE_PROP_UINT8("maxslot", USBCCIDState, maxslot, 0), +=C2=A0=C2=A0=C2=A0 DEFINE_PROP_UINT8("feat2", USBCCIDState, feat2, 0), =C2=A0=C2=A0=C2=A0=C2=A0 DEFINE_PROP_END_OF_LIST(), =C2=A0}; =C2=A0 + =C2=A0static void ccid_class_initfn(ObjectClass *klass, void *data) =C2=A0{ =C2=A0=C2=A0=C2=A0=C2=A0 DeviceClass *dc =3D DEVICE_CLASS(klass); --=20 2.34.1 --=20 Klaus Ripke Senior Developer Public Authorities Division secunet Security Networks AG Telefon: +49 201 5454-2982