Change in osmo-ccid-firmware[master]: split usb descriptor code

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Thu Nov 28 15:17:06 UTC 2019


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16266 )

Change subject: split usb descriptor code
......................................................................

split usb descriptor code

Change-Id: I9eb3606cfbaecf81f7ae80a9ea3d061a39088760
---
M sysmoOCTSIM/main.c
M sysmoOCTSIM/usb/class/ccid/device/ccid_df.c
M sysmoOCTSIM/usb_descriptors.c
A sysmoOCTSIM/usb_descriptors.h
4 files changed, 105 insertions(+), 47 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c
index 15e2004..fed562b 100644
--- a/sysmoOCTSIM/main.c
+++ b/sysmoOCTSIM/main.c
@@ -43,6 +43,8 @@
 // TODO put declaration in more global file
 // TODO for now SIM7 is not present because used for debug
 static struct usart_async_descriptor* SIM_peripheral_descriptors[] = {&SIM0, &SIM1, &SIM2, &SIM3, &SIM4, &SIM5, &SIM6, NULL};
+#include "ccid_device.h"
+#include "usb_descriptors.h"
 
 /** number of bytes transmitted on the SIM peripheral */
 static volatile bool SIM_tx_count[8];
diff --git a/sysmoOCTSIM/usb/class/ccid/device/ccid_df.c b/sysmoOCTSIM/usb/class/ccid/device/ccid_df.c
index 65d3499..665f0fc 100644
--- a/sysmoOCTSIM/usb/class/ccid/device/ccid_df.c
+++ b/sysmoOCTSIM/usb/class/ccid/device/ccid_df.c
@@ -24,6 +24,9 @@
 #include "ccid_proto.h"
 #include "usb_includes.h"
 
+#include "cdcdf_acm_desc.h"
+#include "usb_descriptors.h"
+
 #ifndef USB_CLASS_CCID
 #define	USB_CLASS_CCID	11
 #endif
@@ -40,9 +43,11 @@
 static struct usbdf_driver _ccid_df;
 static struct ccid_df_func_data _ccid_df_funcd;
 
+extern const struct usb_desc_collection usb_fs_descs;
+
 /* FIXME: make those configurable, ensure they're sized according to
  * bNumClockSupported / bNumDataRatesSupported */
-static uint32_t ccid_clock_frequencies[] = { LE32(20000) };
+static uint32_t ccid_clock_frequencies[CCID_NUM_CLK_SUPPORTED] = { LE32(2500),LE32(5000),LE32(10000),LE32(20000) };
 static uint32_t ccid_baud_rates[] = { LE32(9600) };
 
 static int32_t ccid_df_enable(struct usbdf_driver *drv, struct usbd_descriptors *desc)
diff --git a/sysmoOCTSIM/usb_descriptors.c b/sysmoOCTSIM/usb_descriptors.c
index 944e43b..63ace0c 100644
--- a/sysmoOCTSIM/usb_descriptors.c
+++ b/sysmoOCTSIM/usb_descriptors.c
@@ -1,54 +1,32 @@
+/*
+ * Copyright (C) 2019 sysmocom -s.f.m.c. GmbH, Author: Eric Wild <ewild at sysmocom.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
 #include "usbd_config.h"
 #include "usbdc.h"
 #include "usb_protocol.h"
 #include "usb_protocol_cdc.h"
 #include "ccid_proto.h"
 #include "cdcdf_acm_desc.h"
+#include "usb_descriptors.h"
 
-/* aggregate descriptors for the combined CDC-ACM + CCID device that we expose
- * from sysmoQMOD */
 
-enum str_desc_num {
-	STR_DESC_MANUF = 1,
-	STR_DESC_PRODUCT,
-	STR_DESC_CONFIG,
-	STR_DESC_INTF_ACM_COMM,
-	STR_DESC_INTF_ACM_DATA,
-	STR_DESC_INTF_CCID,
-	STR_DESC_SERIAL,
-};
 
-/* a struct of structs representing the concatenated collection of USB descriptors */
-struct usb_desc_collection {
-	struct usb_dev_desc dev;
-	struct usb_config_desc cfg;
-
-	/* CDC-ACM: Two interfaces, one with IRQ EP and one with BULK IN + OUT */
-	struct {
-		struct {
-			struct usb_iface_desc iface;
-			struct usb_cdc_hdr_desc cdc_hdr;
-			struct usb_cdc_call_mgmt_desc cdc_call_mgmt;
-			struct usb_cdc_acm_desc cdc_acm;
-			struct usb_cdc_union_desc cdc_union;
-			struct usb_ep_desc ep[1];
-		} comm;
-		struct {
-			struct usb_iface_desc iface;
-			struct usb_ep_desc ep[2];
-		} data;
-	} cdc;
-
-	/* CCID: One interface with CCID class descriptor and three endpoints */
-	struct {
-		struct usb_iface_desc iface;
-		struct usb_ccid_class_descriptor class;
-		struct usb_ep_desc ep[3];
-	} ccid;
-	uint8_t str[116];
-} __attribute__((packed));
-
-static const struct usb_desc_collection usb_fs_descs = {
+const struct usb_desc_collection usb_fs_descs = {
 	.dev = {
 		.bLength = sizeof(struct usb_dev_desc),
 		.bDescriptorType = USB_DT_DEVICE,
@@ -176,17 +154,23 @@
 			.bcdCCID = LE16(0x0110),
 			.bMaxSlotIndex = 7,
 			.bVoltageSupport = 0x07, /* 5/3/1.8V */
-			.dwProtocols = 0x03,
+			.dwProtocols = 0x01, /* only t0 */
 			.dwDefaultClock = LE32(2500),
 			.dwMaximumClock = LE32(20000),
-			.bNumClockSupported = 4,
-			.dwDataRate = LE32(9600),
+			.bNumClockSupported = CCID_NUM_CLK_SUPPORTED,
+			.dwDataRate = LE32(6720), /* default clock 2.5M/372 */
 			.dwMaxDataRate = LE32(921600),
 			.bNumDataRatesSupported = 0,
 			.dwMaxIFSD = LE32(0),
 			.dwSynchProtocols = LE32(0),
 			.dwMechanical = LE32(0),
-			.dwFeatures = LE32(0x10 | 0x00010000),
+			/* 0x10000 TPDU level exchanges with CCID
+			 * 0x80 Automatic PPS made by the CCID according to the active parameters
+			 * 0x20 Automatic baud rate change according to active parameters 
+			 * provided by the Host or self determined
+			 * 0x10 Automatic ICC clock frequency change according to active parameters
+			 *  provided by the Host or self determined */
+			.dwFeatures = LE32(0x10 | 0x20 | 0x80 | 0x00010000),
 			.dwMaxCCIDMessageLength = 272,
 			.bClassGetResponse = 0xff,
 			.bClassEnvelope = 0xff,
diff --git a/sysmoOCTSIM/usb_descriptors.h b/sysmoOCTSIM/usb_descriptors.h
new file mode 100644
index 0000000..94a4212
--- /dev/null
+++ b/sysmoOCTSIM/usb_descriptors.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2019 sysmocom -s.f.m.c. GmbH, Author: Eric Wild <ewild at sysmocom.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+*/
+
+#ifndef USB_DESCRIPTORS_H_
+#define USB_DESCRIPTORS_H_
+
+#define CCID_NUM_CLK_SUPPORTED 4
+
+/* aggregate descriptors for the combined CDC-ACM + CCID device that we expose
+ * from sysmoQMOD */
+
+enum str_desc_num {
+	STR_DESC_MANUF = 1,
+	STR_DESC_PRODUCT,
+	STR_DESC_CONFIG,
+	STR_DESC_INTF_ACM_COMM,
+	STR_DESC_INTF_ACM_DATA,
+	STR_DESC_INTF_CCID,
+	STR_DESC_SERIAL,
+};
+
+/* a struct of structs representing the concatenated collection of USB descriptors */
+struct usb_desc_collection {
+	struct usb_dev_desc dev;
+	struct usb_config_desc cfg;
+
+	/* CDC-ACM: Two interfaces, one with IRQ EP and one with BULK IN + OUT */
+	struct {
+		struct {
+			struct usb_iface_desc iface;
+			struct usb_cdc_hdr_desc cdc_hdr;
+			struct usb_cdc_call_mgmt_desc cdc_call_mgmt;
+			struct usb_cdc_acm_desc cdc_acm;
+			struct usb_cdc_union_desc cdc_union;
+			struct usb_ep_desc ep[1];
+		} comm;
+		struct {
+			struct usb_iface_desc iface;
+			struct usb_ep_desc ep[2];
+		} data;
+	} cdc;
+
+	/* CCID: One interface with CCID class descriptor and three endpoints */
+	struct {
+		struct usb_iface_desc iface;
+		struct usb_ccid_class_descriptor class;
+		struct usb_ep_desc ep[3];
+	} ccid;
+	uint8_t str[116];
+} __attribute__((packed));
+
+#endif /* USB_DESCRIPTORS_H_ */

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16266
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I9eb3606cfbaecf81f7ae80a9ea3d061a39088760
Gerrit-Change-Number: 16266
Gerrit-PatchSet: 3
Gerrit-Owner: Hoernchen <ewild at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191128/2da7726a/attachment.htm>


More information about the gerrit-log mailing list