USB: add central file to define USB IDs, classes, and endpoints

Change-Id: Iba81f32a92c68a973e8e7adbc4c2a1064ba5290f
This commit is contained in:
Kévin Redon
2018-07-01 18:11:01 +02:00
committed by King Kévin
parent 42bd026416
commit a1012b170a
11 changed files with 121 additions and 105 deletions

View File

@@ -28,7 +28,7 @@ static const USBDeviceDescriptor fsDevice = {
.bDeviceClass = 0, .bDeviceClass = 0,
.bDeviceSubClass = 0, .bDeviceSubClass = 0,
.bDeviceProtocol = 0, .bDeviceProtocol = 0,
.bMaxPacketSize0 = BOARD_USB_ENDPOINTS_MAXPACKETSIZE(0), .bMaxPacketSize0 = USBEndpointDescriptor_MAXCTRLSIZE_FS,
.idVendor = BOARD_USB_VENDOR_ID, .idVendor = BOARD_USB_VENDOR_ID,
.idProduct = BOARD_DFU_USB_PRODUCT_ID, .idProduct = BOARD_DFU_USB_PRODUCT_ID,
.bcdDevice = BOARD_USB_RELEASE, .bcdDevice = BOARD_USB_RELEASE,

View File

@@ -108,21 +108,6 @@
// D+ has external pull-up // D+ has external pull-up
#define BOARD_USB_PULLUP_EXTERNAL #define BOARD_USB_PULLUP_EXTERNAL
#define BOARD_USB_NUMENDPOINTS 8
// FIXME: in all other cases return 0?
#define BOARD_USB_ENDPOINTS_MAXPACKETSIZE(i) (((i == 4) || (i == 5))? 512 : 64)
#define BOARD_USB_ENDPOINTS_BANKS(i) (((i == 0) || (i == 3)) ? 1 : 2)
#define USB_VENDOR_OPENMOKO 0x1d50
#define USB_PRODUCT_OWHW_SAM3_DFU 0x4001 /* was 0x4000 */
#define USB_PRODUCT_OWHW_SAM3 0x4001
#define USB_PRODUCT_QMOD_HUB 0x4002
#define USB_PRODUCT_QMOD_SAM3_DFU 0x4004 /* was 0x4003 */
#define USB_PRODUCT_QMOD_SAM3 0x4004
#define USB_PRODUCT_SIMTRACE2_DFU 0x60e3 /* was 0x60e2 */
#define USB_PRODUCT_SIMTRACE2 0x60e3
#define BOARD_USB_DFU #define BOARD_USB_DFU
#define BOARD_DFU_BOOT_SIZE (16 * 1024) #define BOARD_DFU_BOOT_SIZE (16 * 1024)
#define BOARD_DFU_RAM_SIZE (2 * 1024) #define BOARD_DFU_RAM_SIZE (2 * 1024)

View File

@@ -1,5 +1,6 @@
#pragma once #pragma once
#include "board_common.h" #include "board_common.h"
#include "simtrace_usb.h"
/** Name of the board */ /** Name of the board */
#define BOARD_NAME "OWHW" #define BOARD_NAME "OWHW"

View File

@@ -1,5 +1,6 @@
#pragma once #pragma once
#include "board_common.h" #include "board_common.h"
#include "simtrace_usb.h"
#define LED_USIM1 LED_GREEN #define LED_USIM1 LED_GREEN
#define LED_USIM2 LED_RED #define LED_USIM2 LED_RED

View File

@@ -1,5 +1,6 @@
#pragma once #pragma once
#include "board_common.h" #include "board_common.h"
#include "simtrace_usb.h"
/* Name of the board */ /* Name of the board */
#define BOARD_NAME "SAM3S-SIMTRACE" #define BOARD_NAME "SAM3S-SIMTRACE"

View File

@@ -5,21 +5,8 @@
#include "board.h" #include "board.h"
#include <usb/device/dfu/dfu.h> #include <usb/device/dfu/dfu.h>
/* Endpoint numbers */
#define DATAOUT 1
#define DATAIN 2
#define INT 3
#define BUFLEN 512 #define BUFLEN 512
#define PHONE_DATAOUT 4
#define PHONE_DATAIN 5
#define PHONE_INT 6
#define CARDEM_USIM2_DATAOUT DATAOUT
#define CARDEM_USIM2_DATAIN DATAIN
#define CARDEM_USIM2_INT INT
#define CLK_MASTER true #define CLK_MASTER true
#define CLK_SLAVE false #define CLK_SLAVE false

View File

@@ -0,0 +1,67 @@
/* 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.
*
* (C) 2018 by sysmocom -s.f.m.c. GmbH, Author: Kevin Redon <kredon@sysmocom.de>
* All Rights Reserved
*/
/* SIMtrace USB IDs */
#define USB_VENDOR_OPENMOKO 0x1d50
#define USB_PRODUCT_OWHW_SAM3_DFU 0x4001 /* was 0x4000 */
#define USB_PRODUCT_OWHW_SAM3 0x4001
#define USB_PRODUCT_QMOD_HUB 0x4002
#define USB_PRODUCT_QMOD_SAM3_DFU 0x4004 /* was 0x4003 */
#define USB_PRODUCT_QMOD_SAM3 0x4004
#define USB_PRODUCT_SIMTRACE2_DFU 0x60e3 /* was 0x60e2 */
#define USB_PRODUCT_SIMTRACE2 0x60e3
/* USB proprietary class */
#define USB_CLASS_PROPRIETARY 0xff
/* SIMtrace USB sub-classes */
/*! Sniffer USB sub-class */
#define SIMTRACE_SNIFFER_USB_SUBCLASS 1
/*! Card-emulation USB sub-class */
#define SIMTRACE_CARDEM_USB_SUBCLASS 2
/* Generic USB endpoint numbers */
/*! Card-side USB data out (host to device) endpoint number */
#define SIMTRACE_USB_EP_CARD_DATAOUT 1
/*! Card-side USB data in (device to host) endpoint number */
#define SIMTRACE_USB_EP_CARD_DATAIN 2
/*! Card-side USB interrupt endpoint number */
#define SIMTRACE_USB_EP_CARD_INT 3
/*! Phone-side USB data out (host to device) endpoint number */
#define SIMTRACE_USB_EP_PHONE_DATAOUT 4
/*! Phone-side USB data in (device to host) endpoint number */
#define SIMTRACE_USB_EP_PHONE_DATAIN 5
/*! Phone-side USB interrupt endpoint number */
#define SIMTRACE_USB_EP_PHONE_INT 6
/* Card-emulation USB endpoint numbers */
/*! USIM1 USB data out (host to device) endpoint number */
#define SIMTRACE_CARDEM_USB_EP_USIM1_DATAOUT 4
/*! USIM1 USB data in (device to host) endpoint number */
#define SIMTRACE_CARDEM_USB_EP_USIM1_DATAIN 5
/*! USIM1 USB interrupt endpoint number */
#define SIMTRACE_CARDEM_USB_EP_USIM1_INT 6
/*! USIM2 USB data out (host to device) endpoint number */
#define SIMTRACE_CARDEM_USB_EP_USIM2_DATAOUT 1
/*! USIM2 USB data in (device to host) endpoint number */
#define SIMTRACE_CARDEM_USB_EP_USIM2_DATAIN 2
/*! USIM2 USB interrupt endpoint number */
#define SIMTRACE_CARDEM_USB_EP_USIM2_INT 3
/*! Maximum number of endpoints */
#define BOARD_USB_NUMENDPOINTS 6

View File

@@ -10,6 +10,7 @@
#include <osmocom/core/msgb.h> #include <osmocom/core/msgb.h>
#include "llist_irqsafe.h" #include "llist_irqsafe.h"
#include "usb_buf.h" #include "usb_buf.h"
#include "simtrace_usb.h"
#include "simtrace_prot.h" #include "simtrace_prot.h"
#include "sim_switch.h" #include "sim_switch.h"
@@ -53,9 +54,9 @@ struct cardem_inst cardem_inst[] = {
.id = ID_USART1, .id = ID_USART1,
.state = USART_RCV .state = USART_RCV
}, },
.ep_out = PHONE_DATAOUT, .ep_out = SIMTRACE_CARDEM_USB_EP_USIM1_DATAOUT,
.ep_in = PHONE_DATAIN, .ep_in = SIMTRACE_CARDEM_USB_EP_USIM1_DATAIN,
.ep_int = PHONE_INT, .ep_int = SIMTRACE_CARDEM_USB_EP_USIM1_INT,
#ifdef PIN_SET_USIM1_PRES #ifdef PIN_SET_USIM1_PRES
.pin_insert = PIN_SET_USIM1_PRES, .pin_insert = PIN_SET_USIM1_PRES,
#endif #endif
@@ -68,9 +69,9 @@ struct cardem_inst cardem_inst[] = {
.id = ID_USART0, .id = ID_USART0,
.state = USART_RCV .state = USART_RCV
}, },
.ep_out = CARDEM_USIM2_DATAOUT, .ep_out = SIMTRACE_CARDEM_USB_EP_USIM2_DATAOUT,
.ep_in = CARDEM_USIM2_DATAIN, .ep_in = SIMTRACE_CARDEM_USB_EP_USIM2_DATAIN,
.ep_int = CARDEM_USIM2_INT, .ep_int = SIMTRACE_CARDEM_USB_EP_USIM2_INT,
#ifdef PIN_SET_USIM2_PRES #ifdef PIN_SET_USIM2_PRES
.pin_insert = PIN_SET_USIM2_PRES, .pin_insert = PIN_SET_USIM2_PRES,
#endif #endif
@@ -398,7 +399,7 @@ void mode_cardemu_init(void)
PIO_ConfigureIt(&pin_usim1_vcc, usim1_vcc_irqhandler); PIO_ConfigureIt(&pin_usim1_vcc, usim1_vcc_irqhandler);
PIO_EnableIt(&pin_usim1_vcc); PIO_EnableIt(&pin_usim1_vcc);
#endif /* DETECT_VCC_BY_ADC */ #endif /* DETECT_VCC_BY_ADC */
cardem_inst[0].ch = card_emu_init(0, 2, 0, PHONE_DATAIN, PHONE_INT); cardem_inst[0].ch = card_emu_init(0, 2, 0, SIMTRACE_CARDEM_USB_EP_USIM1_DATAIN, SIMTRACE_CARDEM_USB_EP_USIM1_INT);
sim_switch_use_physical(0, 1); sim_switch_use_physical(0, 1);
#ifdef CARDEMU_SECOND_UART #ifdef CARDEMU_SECOND_UART
@@ -413,7 +414,7 @@ void mode_cardemu_init(void)
PIO_ConfigureIt(&pin_usim2_vcc, usim2_vcc_irqhandler); PIO_ConfigureIt(&pin_usim2_vcc, usim2_vcc_irqhandler);
PIO_EnableIt(&pin_usim2_vcc); PIO_EnableIt(&pin_usim2_vcc);
#endif /* DETECT_VCC_BY_ADC */ #endif /* DETECT_VCC_BY_ADC */
cardem_inst[1].ch = card_emu_init(1, 0, 1, CARDEM_USIM2_DATAIN, CARDEM_USIM2_INT); cardem_inst[1].ch = card_emu_init(1, 0, 1, SIMTRACE_CARDEM_USB_EP_USIM2_DATAIN, SIMTRACE_CARDEM_USB_EP_USIM2_INT);
sim_switch_use_physical(1, 1); sim_switch_use_physical(1, 1);
#endif /* CARDEMU_SECOND_UART */ #endif /* CARDEMU_SECOND_UART */

View File

@@ -33,6 +33,7 @@
#include "board.h" #include "board.h"
#include "simtrace.h" #include "simtrace.h"
#include "simtrace_usb.h"
#include "ringbuffer.h" #include "ringbuffer.h"
#include "iso7816_fidi.h" #include "iso7816_fidi.h"
@@ -67,7 +68,7 @@ void ISR_PhoneRST(const Pin * pPin)
} }
if ((ret = if ((ret =
USBD_Write(PHONE_INT, "R", 1, USBD_Write(SIMTRACE_USB_EP_PHONE_INT, "R", 1,
(TransferCallback) & Callback_PhoneRST_ISR, (TransferCallback) & Callback_PhoneRST_ISR,
0)) != USBD_STATUS_SUCCESS) { 0)) != USBD_STATUS_SUCCESS) {
TRACE_ERROR("USB err status: %d (%s)\n", ret, __FUNCTION__); TRACE_ERROR("USB err status: %d (%s)\n", ret, __FUNCTION__);

View File

@@ -33,15 +33,13 @@
#include "board.h" #include "board.h"
#include "simtrace.h" #include "simtrace.h"
#include "simtrace_usb.h"
#include "utils.h" #include "utils.h"
#include <cciddriverdescriptors.h> #include <cciddriverdescriptors.h>
#include <usb/common/dfu/usb_dfu.h> #include <usb/common/dfu/usb_dfu.h>
#include <usb/device/dfu/dfu.h> #include <usb/device/dfu/dfu.h>
#define SIMTRACE_SUBCLASS_SNIFFER 1
#define SIMTRACE_SUBCLASS_CARDEM 2
/*------------------------------------------------------------------------------ /*------------------------------------------------------------------------------
* USB String descriptors * USB String descriptors
*------------------------------------------------------------------------------*/ *------------------------------------------------------------------------------*/
@@ -94,8 +92,8 @@ static const SIMTraceDriverConfigurationDescriptorSniffer
.bInterfaceNumber = 0, .bInterfaceNumber = 0,
.bAlternateSetting = 0, .bAlternateSetting = 0,
.bNumEndpoints = 3, .bNumEndpoints = 3,
.bInterfaceClass = 0xff, .bInterfaceClass = USB_CLASS_PROPRIETARY,
.bInterfaceSubClass = SIMTRACE_SUBCLASS_SNIFFER, .bInterfaceSubClass = SIMTRACE_SNIFFER_USB_SUBCLASS,
.bInterfaceProtocol = 0, .bInterfaceProtocol = 0,
.iInterface = SNIFFER_CONF_STR, .iInterface = SNIFFER_CONF_STR,
}, },
@@ -105,11 +103,9 @@ static const SIMTraceDriverConfigurationDescriptorSniffer
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS( .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_OUT, USBEndpointDescriptor_OUT,
PHONE_DATAOUT), SIMTRACE_USB_EP_CARD_DATAOUT),
.bmAttributes = USBEndpointDescriptor_BULK, .bmAttributes = USBEndpointDescriptor_BULK,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE( .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
PHONE_DATAOUT),
USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0, .bInterval = 0,
}, },
/* Bulk-IN endpoint descriptor */ /* Bulk-IN endpoint descriptor */
@@ -118,11 +114,9 @@ static const SIMTraceDriverConfigurationDescriptorSniffer
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS( .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN, USBEndpointDescriptor_IN,
PHONE_DATAIN), SIMTRACE_USB_EP_CARD_DATAIN),
.bmAttributes = USBEndpointDescriptor_BULK, .bmAttributes = USBEndpointDescriptor_BULK,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE( .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
PHONE_DATAIN),
USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0, .bInterval = 0,
}, },
// Notification endpoint descriptor // Notification endpoint descriptor
@@ -131,11 +125,9 @@ static const SIMTraceDriverConfigurationDescriptorSniffer
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS( .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN, USBEndpointDescriptor_IN,
PHONE_INT), SIMTRACE_USB_EP_CARD_INT),
.bmAttributes = USBEndpointDescriptor_INTERRUPT, .bmAttributes = USBEndpointDescriptor_INTERRUPT,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE( .wMaxPacketSize = USBEndpointDescriptor_MAXINTERRUPTSIZE_FS,
PHONE_INT),
USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
.bInterval = 0x10, .bInterval = 0x10,
}, },
DFURT_IF_DESCRIPTOR(1, 0), DFURT_IF_DESCRIPTOR(1, 0),
@@ -205,9 +197,7 @@ static const CCIDDriverConfigurationDescriptors configurationDescriptorCCID = {
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
CCID_EPT_DATA_OUT), CCID_EPT_DATA_OUT),
.bmAttributes = USBEndpointDescriptor_BULK, .bmAttributes = USBEndpointDescriptor_BULK,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE( .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
CCID_EPT_DATA_OUT),
USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0x00, .bInterval = 0x00,
}, },
// Bulk-IN endpoint descriptor // Bulk-IN endpoint descriptor
@@ -218,9 +208,7 @@ static const CCIDDriverConfigurationDescriptors configurationDescriptorCCID = {
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
CCID_EPT_DATA_IN), CCID_EPT_DATA_IN),
.bmAttributes = USBEndpointDescriptor_BULK, .bmAttributes = USBEndpointDescriptor_BULK,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE( .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS),
CCID_EPT_DATA_IN),
USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0x00, .bInterval = 0x00,
}, },
// Notification endpoint descriptor // Notification endpoint descriptor
@@ -231,9 +219,7 @@ static const CCIDDriverConfigurationDescriptors configurationDescriptorCCID = {
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
CCID_EPT_NOTIFICATION), CCID_EPT_NOTIFICATION),
.bmAttributes = USBEndpointDescriptor_INTERRUPT, .bmAttributes = USBEndpointDescriptor_INTERRUPT,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE( .wMaxPacketSize = USBEndpointDescriptor_MAXINTERRUPTSIZE_FS,
CCID_EPT_NOTIFICATION),
USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
.bInterval = 0x10, .bInterval = 0x10,
}, },
DFURT_IF_DESCRIPTOR(1, 0), DFURT_IF_DESCRIPTOR(1, 0),
@@ -282,8 +268,8 @@ static const SIMTraceDriverConfigurationDescriptorPhone
.bInterfaceNumber = 0, .bInterfaceNumber = 0,
.bAlternateSetting = 0, .bAlternateSetting = 0,
.bNumEndpoints = 3, .bNumEndpoints = 3,
.bInterfaceClass = 0xff, .bInterfaceClass = USB_CLASS_PROPRIETARY,
.bInterfaceSubClass = SIMTRACE_SUBCLASS_CARDEM, .bInterfaceSubClass = SIMTRACE_CARDEM_USB_SUBCLASS,
.bInterfaceProtocol = 0, .bInterfaceProtocol = 0,
.iInterface = CARDEM_USIM1_INTF_STR, .iInterface = CARDEM_USIM1_INTF_STR,
}, },
@@ -293,10 +279,9 @@ static const SIMTraceDriverConfigurationDescriptorPhone
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS( .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_OUT, USBEndpointDescriptor_OUT,
PHONE_DATAOUT), SIMTRACE_CARDEM_USB_EP_USIM1_DATAOUT),
.bmAttributes = USBEndpointDescriptor_BULK, .bmAttributes = USBEndpointDescriptor_BULK,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_DATAOUT), .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0 /* Must be 0 for full-speed bulk endpoints */ .bInterval = 0 /* Must be 0 for full-speed bulk endpoints */
}, },
/* Bulk-IN endpoint descriptor */ /* Bulk-IN endpoint descriptor */
@@ -305,10 +290,9 @@ static const SIMTraceDriverConfigurationDescriptorPhone
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS( .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN, USBEndpointDescriptor_IN,
PHONE_DATAIN), SIMTRACE_CARDEM_USB_EP_USIM1_DATAIN),
.bmAttributes = USBEndpointDescriptor_BULK, .bmAttributes = USBEndpointDescriptor_BULK,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_DATAIN), .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0 /* Must be 0 for full-speed bulk endpoints */ .bInterval = 0 /* Must be 0 for full-speed bulk endpoints */
}, },
/* Notification endpoint descriptor */ /* Notification endpoint descriptor */
@@ -317,10 +301,9 @@ static const SIMTraceDriverConfigurationDescriptorPhone
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS( .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN, USBEndpointDescriptor_IN,
PHONE_INT), SIMTRACE_CARDEM_USB_EP_USIM1_INT),
.bmAttributes = USBEndpointDescriptor_INTERRUPT, .bmAttributes = USBEndpointDescriptor_INTERRUPT,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_INT), .wMaxPacketSize = USBEndpointDescriptor_MAXINTERRUPTSIZE_FS,
USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
.bInterval = 0x10 .bInterval = 0x10
}, },
#ifdef CARDEMU_SECOND_UART #ifdef CARDEMU_SECOND_UART
@@ -331,8 +314,8 @@ static const SIMTraceDriverConfigurationDescriptorPhone
.bInterfaceNumber = 1, .bInterfaceNumber = 1,
.bAlternateSetting = 0, .bAlternateSetting = 0,
.bNumEndpoints = 3, .bNumEndpoints = 3,
.bInterfaceClass = 0xff, .bInterfaceClass = USB_CLASS_PROPRIETARY,
.bInterfaceSubClass = SIMTRACE_SUBCLASS_CARDEM, .bInterfaceSubClass = SIMTRACE_CARDEM_USB_SUBCLASS,
.bInterfaceProtocol = 0, .bInterfaceProtocol = 0,
.iInterface = CARDEM_USIM2_INTF_STR, .iInterface = CARDEM_USIM2_INTF_STR,
}, },
@@ -342,10 +325,9 @@ static const SIMTraceDriverConfigurationDescriptorPhone
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS( .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_OUT, USBEndpointDescriptor_OUT,
CARDEM_USIM2_DATAOUT), SIMTRACE_CARDEM_USB_EP_USIM2_DATAOUT),
.bmAttributes = USBEndpointDescriptor_BULK, .bmAttributes = USBEndpointDescriptor_BULK,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(CARDEM_USIM2_DATAOUT), .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0 /* Must be 0 for full-speed bulk endpoints */ .bInterval = 0 /* Must be 0 for full-speed bulk endpoints */
} }
, ,
@@ -355,10 +337,9 @@ static const SIMTraceDriverConfigurationDescriptorPhone
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS( .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN, USBEndpointDescriptor_IN,
CARDEM_USIM2_DATAIN), SIMTRACE_CARDEM_USB_EP_USIM2_DATAIN),
.bmAttributes = USBEndpointDescriptor_BULK, .bmAttributes = USBEndpointDescriptor_BULK,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(CARDEM_USIM2_DATAIN), .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0 /* Must be 0 for full-speed bulk endpoints */ .bInterval = 0 /* Must be 0 for full-speed bulk endpoints */
}, },
/* Notification endpoint descriptor */ /* Notification endpoint descriptor */
@@ -367,10 +348,9 @@ static const SIMTraceDriverConfigurationDescriptorPhone
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS( .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN, USBEndpointDescriptor_IN,
CARDEM_USIM2_INT), SIMTRACE_CARDEM_USB_EP_USIM2_INT),
.bmAttributes = USBEndpointDescriptor_INTERRUPT, .bmAttributes = USBEndpointDescriptor_INTERRUPT,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(CARDEM_USIM2_INT), .wMaxPacketSize = USBEndpointDescriptor_MAXINTERRUPTSIZE_FS,
USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
.bInterval = 0x10, .bInterval = 0x10,
}, },
DFURT_IF_DESCRIPTOR(2, 0), DFURT_IF_DESCRIPTOR(2, 0),
@@ -466,9 +446,7 @@ static const SIMTraceDriverConfigurationDescriptorMITM
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT, USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_OUT,
CCID_EPT_DATA_OUT), CCID_EPT_DATA_OUT),
.bmAttributes = USBEndpointDescriptor_BULK, .bmAttributes = USBEndpointDescriptor_BULK,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE( .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
CCID_EPT_DATA_OUT),
USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0x00, .bInterval = 0x00,
}, },
// Bulk-IN endpoint descriptor // Bulk-IN endpoint descriptor
@@ -479,9 +457,7 @@ static const SIMTraceDriverConfigurationDescriptorMITM
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
CCID_EPT_DATA_IN), CCID_EPT_DATA_IN),
.bmAttributes = USBEndpointDescriptor_BULK, .bmAttributes = USBEndpointDescriptor_BULK,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE( .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
CCID_EPT_DATA_IN),
USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0x00, .bInterval = 0x00,
}, },
// Notification endpoint descriptor // Notification endpoint descriptor
@@ -492,9 +468,7 @@ static const SIMTraceDriverConfigurationDescriptorMITM
USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN, USBEndpointDescriptor_ADDRESS(USBEndpointDescriptor_IN,
CCID_EPT_NOTIFICATION), CCID_EPT_NOTIFICATION),
.bmAttributes = USBEndpointDescriptor_INTERRUPT, .bmAttributes = USBEndpointDescriptor_INTERRUPT,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE( .wMaxPacketSize = USBEndpointDescriptor_MAXINTERRUPTSIZE_FS,
CCID_EPT_NOTIFICATION),
USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
.bInterval = 0x10, .bInterval = 0x10,
}, },
@@ -516,10 +490,9 @@ static const SIMTraceDriverConfigurationDescriptorMITM
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS( .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_OUT, USBEndpointDescriptor_OUT,
PHONE_DATAOUT), SIMTRACE_USB_EP_PHONE_DATAOUT),
.bmAttributes = USBEndpointDescriptor_BULK, .bmAttributes = USBEndpointDescriptor_BULK,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_DATAOUT), .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0, /* Must be 0 for full-speed bulk endpoints */ .bInterval = 0, /* Must be 0 for full-speed bulk endpoints */
}, },
/* Bulk-IN endpoint descriptor */ /* Bulk-IN endpoint descriptor */
@@ -528,10 +501,9 @@ static const SIMTraceDriverConfigurationDescriptorMITM
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS( .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN, USBEndpointDescriptor_IN,
PHONE_DATAIN), SIMTRACE_USB_EP_PHONE_DATAIN),
.bmAttributes = USBEndpointDescriptor_BULK, .bmAttributes = USBEndpointDescriptor_BULK,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_DATAIN), .wMaxPacketSize = USBEndpointDescriptor_MAXBULKSIZE_FS,
USBEndpointDescriptor_MAXBULKSIZE_FS),
.bInterval = 0, /* Must be 0 for full-speed bulk endpoints */ .bInterval = 0, /* Must be 0 for full-speed bulk endpoints */
}, },
/* Notification endpoint descriptor */ /* Notification endpoint descriptor */
@@ -540,10 +512,9 @@ static const SIMTraceDriverConfigurationDescriptorMITM
.bDescriptorType = USBGenericDescriptor_ENDPOINT, .bDescriptorType = USBGenericDescriptor_ENDPOINT,
.bEndpointAddress = USBEndpointDescriptor_ADDRESS( .bEndpointAddress = USBEndpointDescriptor_ADDRESS(
USBEndpointDescriptor_IN, USBEndpointDescriptor_IN,
PHONE_INT), SIMTRACE_USB_EP_PHONE_INT),
.bmAttributes = USBEndpointDescriptor_INTERRUPT, .bmAttributes = USBEndpointDescriptor_INTERRUPT,
.wMaxPacketSize = MIN(BOARD_USB_ENDPOINTS_MAXPACKETSIZE(PHONE_INT), .wMaxPacketSize = USBEndpointDescriptor_MAXINTERRUPTSIZE_FS,
USBEndpointDescriptor_MAXINTERRUPTSIZE_FS),
.bInterval = 0x10 .bInterval = 0x10
}, },
DFURT_IF_DESCRIPTOR(2, 0), DFURT_IF_DESCRIPTOR(2, 0),
@@ -573,7 +544,7 @@ const USBDeviceDescriptor deviceDescriptor = {
.bDeviceClass = 0, .bDeviceClass = 0,
.bDeviceSubClass = 0, .bDeviceSubClass = 0,
.bDeviceProtocol = 0, .bDeviceProtocol = 0,
.bMaxPacketSize0 = BOARD_USB_ENDPOINTS_MAXPACKETSIZE(0), .bMaxPacketSize0 = 64,
.idVendor = BOARD_USB_VENDOR_ID, .idVendor = BOARD_USB_VENDOR_ID,
.idProduct = BOARD_USB_PRODUCT_ID, .idProduct = BOARD_USB_PRODUCT_ID,
.bcdDevice = 2, /* Release number */ .bcdDevice = 2, /* Release number */

View File

@@ -1,6 +1,7 @@
#include "board.h" #include "board.h"
#include "trace.h" #include "trace.h"
#include "usb_buf.h" #include "usb_buf.h"
#include "simtrace_usb.h"
#include <osmocom/core/linuxlist.h> #include <osmocom/core/linuxlist.h>
#include <osmocom/core/msgb.h> #include <osmocom/core/msgb.h>