From nobody Sun May 19 11:37:33 2024 Delivered-To: importer@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+importer=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 1673357851851943.1847624681019; Tue, 10 Jan 2023 05:37:31 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pFEWn-0006J4-Gx; Tue, 10 Jan 2023 08:18:57 -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 1pFEWk-0006IQ-5o for qemu-devel@nongnu.org; Tue, 10 Jan 2023 08:18:54 -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 1pFEWi-0001wW-5G for qemu-devel@nongnu.org; Tue, 10 Jan 2023 08:18:53 -0500 Received: from localhost (localhost [127.0.0.1]) by a.mx.secunet.com (Postfix) with ESMTP id 894FD2049B; Tue, 10 Jan 2023 14:18:47 +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 TopqYA8N048Y; Tue, 10 Jan 2023 14:18:47 +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 0654420491; Tue, 10 Jan 2023 14:18:47 +0100 (CET) Received: from cas-essen-02.secunet.de (unknown [10.53.40.202]) by mailout1.secunet.com (Postfix) with ESMTP id EC47E80004A; Tue, 10 Jan 2023 14:18:46 +0100 (CET) Received: from mbx-dresden-01.secunet.de (10.53.40.199) by cas-essen-02.secunet.de (10.53.40.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Tue, 10 Jan 2023 14:18:41 +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; Tue, 10 Jan 2023 14:18:46 +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; Tue, 10 Jan 2023 14:18:45 +0100 X-Virus-Scanned: by secunet From: "Ripke, Klaus" To: "qemu-devel@nongnu.org" CC: "kraxel@redhat.com" Subject: [PATCH] usb-ccid: make ids and descriptor configurable Thread-Topic: [PATCH] usb-ccid: make ids and descriptor configurable Thread-Index: AQHZJPYRutvGp/ehGk+spkxRFFHkoA== Date: Tue, 10 Jan 2023 13:18:45 +0000 Message-ID: <47a155d76238fb1bae401dd77428c9125f37e0d2.camel@secunet.com> 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: <814A71C4742FA14893276D6B2C5B452F@secunet.com> 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+importer=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1673357854873100003 Signed-off-by: Klaus Ripke hw/usb/dev-smartcard-reader.c: Set static values from env vars QEMU_CCID_VENDOR/PRODUCT_ID and _DESCRIPTOR --- =C2=A0hw/usb/dev-smartcard-reader.c | 27 ++++++++++++++++++++++++--- =C2=A01 file changed, 24 insertions(+), 3 deletions(-) diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard- reader.c index 28164d89be..0632ab44c6 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -323,7 +323,7 @@ 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 { +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 +472,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, @@ -1437,12 +1437,33 @@ static Property ccid_properties[] =3D { =C2=A0=C2=A0=C2=A0=C2=A0 DEFINE_PROP_END_OF_LIST(), =C2=A0}; =C2=A0 +static void env_uint16(uint16_t *val, const char *env) +{ +=C2=A0=C2=A0=C2=A0 const char *str =3D getenv(env); +=C2=A0=C2=A0=C2=A0 if (str) { +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *val =3D qemu_strtoul(str, NULL= , 16); +=C2=A0=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); =C2=A0=C2=A0=C2=A0=C2=A0 USBDeviceClass *uc =3D USB_DEVICE_CLASS(klass); =C2=A0=C2=A0=C2=A0=C2=A0 HotplugHandlerClass *hc =3D HOTPLUG_HANDLER_CLASS(= klass); - +=C2=A0=C2=A0=C2=A0 const char *dsc =3D getenv("QEMU_CCID_DESCRIPTOR"); + +=C2=A0=C2=A0=C2=A0 if (dsc) { +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned int idx =3D 0; +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 unsigned int val =3D 0; +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 int off =3D 0; +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for (; 2 =3D=3D sscanf(dsc, "%u= :%x%n", &idx, &val, &off); dsc +=3D off) { +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (idx= < sizeof qemu_ccid_descriptor) { +=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[idx] =3D val; +=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 } +=C2=A0=C2=A0=C2=A0 } +=C2=A0=C2=A0=C2=A0 env_uint16(&desc_ccid.id.idVendor, "QEMU_CCID_VENDOR_ID= "); +=C2=A0=C2=A0=C2=A0 env_uint16(&desc_ccid.id.idProduct, "QEMU_CCID_PRODUCT_= ID"); =C2=A0=C2=A0=C2=A0=C2=A0 uc->realize=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0 =3D ccid_realize; =C2=A0=C2=A0=C2=A0=C2=A0 uc->product_desc=C2=A0=C2=A0 =3D "QEMU USB CCID"; =C2=A0=C2=A0=C2=A0=C2=A0 uc->usb_desc=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = =3D &desc_ccid; --=20 2.34.1 --=20 Klaus Ripke Senior Developer Public Authorities Division secunet Security Networks AG Telefon: +49 201 5454-2982