forked from len0rd/rockbox
fix alignment and packed-ness of USB structs
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16455 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
d6adda1356
commit
f712c7ff36
2 changed files with 26 additions and 26 deletions
|
@ -227,7 +227,7 @@ struct usb_config_descriptor {
|
||||||
uint8_t iConfiguration;
|
uint8_t iConfiguration;
|
||||||
uint8_t bmAttributes;
|
uint8_t bmAttributes;
|
||||||
uint8_t bMaxPower;
|
uint8_t bMaxPower;
|
||||||
} __attribute__ ((packed,aligned(2)));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#define USB_DT_CONFIG_SIZE 9
|
#define USB_DT_CONFIG_SIZE 9
|
||||||
|
|
||||||
|
@ -245,7 +245,7 @@ struct usb_string_descriptor {
|
||||||
uint8_t bDescriptorType;
|
uint8_t bDescriptorType;
|
||||||
|
|
||||||
uint16_t wString[]; /* UTF-16LE encoded */
|
uint16_t wString[]; /* UTF-16LE encoded */
|
||||||
} __attribute__ ((packed,aligned(2)));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/* note that "string" zero is special, it holds language codes that
|
/* note that "string" zero is special, it holds language codes that
|
||||||
* the device supports, not Unicode characters.
|
* the device supports, not Unicode characters.
|
||||||
|
@ -285,7 +285,7 @@ struct usb_endpoint_descriptor {
|
||||||
/* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */
|
/* use USB_DT_ENDPOINT*_SIZE in bLength, not sizeof. */
|
||||||
//uint8_t bRefresh;
|
//uint8_t bRefresh;
|
||||||
//uint8_t bSynchAddress;
|
//uint8_t bSynchAddress;
|
||||||
} __attribute__ ((packed,aligned(2)));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
#define USB_DT_ENDPOINT_SIZE 7
|
#define USB_DT_ENDPOINT_SIZE 7
|
||||||
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
|
#define USB_DT_ENDPOINT_AUDIO_SIZE 9 /* Audio extension */
|
||||||
|
@ -304,7 +304,7 @@ struct usb_qualifier_descriptor {
|
||||||
uint8_t bMaxPacketSize0;
|
uint8_t bMaxPacketSize0;
|
||||||
uint8_t bNumConfigurations;
|
uint8_t bNumConfigurations;
|
||||||
uint8_t bRESERVED;
|
uint8_t bRESERVED;
|
||||||
} __attribute__ ((packed,aligned(2)));
|
} __attribute__ ((packed));
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
#define USB_SC_SCSI 0x06 /* Transparent */
|
#define USB_SC_SCSI 0x06 /* Transparent */
|
||||||
#define USB_PROT_BULK 0x50 /* bulk only */
|
#define USB_PROT_BULK 0x50 /* bulk only */
|
||||||
|
|
||||||
static const struct usb_device_descriptor device_descriptor= {
|
static const struct usb_device_descriptor __attribute__((aligned(2))) device_descriptor= {
|
||||||
.bLength = sizeof(struct usb_device_descriptor),
|
.bLength = sizeof(struct usb_device_descriptor),
|
||||||
.bDescriptorType = USB_DT_DEVICE,
|
.bDescriptorType = USB_DT_DEVICE,
|
||||||
#ifdef USE_HIGH_SPEED
|
#ifdef USE_HIGH_SPEED
|
||||||
|
@ -77,9 +77,9 @@ static const struct usb_device_descriptor device_descriptor= {
|
||||||
.iProduct = 2,
|
.iProduct = 2,
|
||||||
.iSerialNumber = 3,
|
.iSerialNumber = 3,
|
||||||
.bNumConfigurations = 1
|
.bNumConfigurations = 1
|
||||||
};
|
} ;
|
||||||
|
|
||||||
struct usb_config_descriptor config_descriptor =
|
struct usb_config_descriptor __attribute__((aligned(2))) config_descriptor =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(struct usb_config_descriptor),
|
.bLength = sizeof(struct usb_config_descriptor),
|
||||||
.bDescriptorType = USB_DT_CONFIG,
|
.bDescriptorType = USB_DT_CONFIG,
|
||||||
|
@ -93,7 +93,7 @@ struct usb_config_descriptor config_descriptor =
|
||||||
|
|
||||||
#ifdef USB_CHARGING_ONLY
|
#ifdef USB_CHARGING_ONLY
|
||||||
/* dummy interface for charging-only */
|
/* dummy interface for charging-only */
|
||||||
struct usb_interface_descriptor charging_interface_descriptor =
|
struct usb_interface_descriptor __attribute__((aligned(2))) charging_interface_descriptor =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(struct usb_interface_descriptor),
|
.bLength = sizeof(struct usb_interface_descriptor),
|
||||||
.bDescriptorType = USB_DT_INTERFACE,
|
.bDescriptorType = USB_DT_INTERFACE,
|
||||||
|
@ -109,7 +109,7 @@ struct usb_interface_descriptor charging_interface_descriptor =
|
||||||
|
|
||||||
#ifdef USB_STORAGE
|
#ifdef USB_STORAGE
|
||||||
/* storage interface */
|
/* storage interface */
|
||||||
struct usb_interface_descriptor mass_storage_interface_descriptor =
|
struct usb_interface_descriptor __attribute__((aligned(2))) mass_storage_interface_descriptor =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(struct usb_interface_descriptor),
|
.bLength = sizeof(struct usb_interface_descriptor),
|
||||||
.bDescriptorType = USB_DT_INTERFACE,
|
.bDescriptorType = USB_DT_INTERFACE,
|
||||||
|
@ -122,7 +122,7 @@ struct usb_interface_descriptor mass_storage_interface_descriptor =
|
||||||
.iInterface = 0
|
.iInterface = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
struct usb_endpoint_descriptor mass_storage_ep_in_descriptor =
|
struct usb_endpoint_descriptor __attribute__((aligned(2))) mass_storage_ep_in_descriptor =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(struct usb_endpoint_descriptor),
|
.bLength = sizeof(struct usb_endpoint_descriptor),
|
||||||
.bDescriptorType = USB_DT_ENDPOINT,
|
.bDescriptorType = USB_DT_ENDPOINT,
|
||||||
|
@ -131,7 +131,7 @@ struct usb_endpoint_descriptor mass_storage_ep_in_descriptor =
|
||||||
.wMaxPacketSize = 16,
|
.wMaxPacketSize = 16,
|
||||||
.bInterval = 0
|
.bInterval = 0
|
||||||
};
|
};
|
||||||
struct usb_endpoint_descriptor mass_storage_ep_out_descriptor =
|
struct usb_endpoint_descriptor __attribute__((aligned(2))) mass_storage_ep_out_descriptor =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(struct usb_endpoint_descriptor),
|
.bLength = sizeof(struct usb_endpoint_descriptor),
|
||||||
.bDescriptorType = USB_DT_ENDPOINT,
|
.bDescriptorType = USB_DT_ENDPOINT,
|
||||||
|
@ -144,7 +144,7 @@ struct usb_endpoint_descriptor mass_storage_ep_out_descriptor =
|
||||||
|
|
||||||
#ifdef USB_SERIAL
|
#ifdef USB_SERIAL
|
||||||
/* serial interface */
|
/* serial interface */
|
||||||
struct usb_interface_descriptor serial_interface_descriptor =
|
struct usb_interface_descriptor __attribute__((aligned(2))) serial_interface_descriptor =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(struct usb_interface_descriptor),
|
.bLength = sizeof(struct usb_interface_descriptor),
|
||||||
.bDescriptorType = USB_DT_INTERFACE,
|
.bDescriptorType = USB_DT_INTERFACE,
|
||||||
|
@ -157,7 +157,7 @@ struct usb_interface_descriptor serial_interface_descriptor =
|
||||||
.iInterface = 0
|
.iInterface = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
struct usb_endpoint_descriptor serial_ep_in_descriptor =
|
struct usb_endpoint_descriptor __attribute__((aligned(2))) serial_ep_in_descriptor =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(struct usb_endpoint_descriptor),
|
.bLength = sizeof(struct usb_endpoint_descriptor),
|
||||||
.bDescriptorType = USB_DT_ENDPOINT,
|
.bDescriptorType = USB_DT_ENDPOINT,
|
||||||
|
@ -166,7 +166,7 @@ struct usb_endpoint_descriptor serial_ep_in_descriptor =
|
||||||
.wMaxPacketSize = 16,
|
.wMaxPacketSize = 16,
|
||||||
.bInterval = 0
|
.bInterval = 0
|
||||||
};
|
};
|
||||||
struct usb_endpoint_descriptor serial_ep_out_descriptor =
|
struct usb_endpoint_descriptor __attribute__((aligned(2))) serial_ep_out_descriptor =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(struct usb_endpoint_descriptor),
|
.bLength = sizeof(struct usb_endpoint_descriptor),
|
||||||
.bDescriptorType = USB_DT_ENDPOINT,
|
.bDescriptorType = USB_DT_ENDPOINT,
|
||||||
|
@ -179,7 +179,7 @@ struct usb_endpoint_descriptor serial_ep_out_descriptor =
|
||||||
|
|
||||||
#ifdef USB_BENCHMARK
|
#ifdef USB_BENCHMARK
|
||||||
/* bulk test interface */
|
/* bulk test interface */
|
||||||
struct usb_interface_descriptor benchmark_interface_descriptor =
|
struct usb_interface_descriptor __attribute__((aligned(2))) benchmark_interface_descriptor =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(struct usb_interface_descriptor),
|
.bLength = sizeof(struct usb_interface_descriptor),
|
||||||
.bDescriptorType = USB_DT_INTERFACE,
|
.bDescriptorType = USB_DT_INTERFACE,
|
||||||
|
@ -192,7 +192,7 @@ struct usb_interface_descriptor benchmark_interface_descriptor =
|
||||||
.iInterface = 4
|
.iInterface = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
struct usb_endpoint_descriptor benchmark_ep_in_descriptor =
|
struct usb_endpoint_descriptor __attribute__((aligned(2))) benchmark_ep_in_descriptor =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(struct usb_endpoint_descriptor),
|
.bLength = sizeof(struct usb_endpoint_descriptor),
|
||||||
.bDescriptorType = USB_DT_ENDPOINT,
|
.bDescriptorType = USB_DT_ENDPOINT,
|
||||||
|
@ -212,7 +212,7 @@ struct usb_endpoint_descriptor benchmark_ep_out_descriptor =
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const struct usb_qualifier_descriptor qualifier_descriptor =
|
static const struct usb_qualifier_descriptor __attribute__((aligned(2))) qualifier_descriptor =
|
||||||
{
|
{
|
||||||
.bLength = sizeof(struct usb_qualifier_descriptor),
|
.bLength = sizeof(struct usb_qualifier_descriptor),
|
||||||
.bDescriptorType = USB_DT_DEVICE_QUALIFIER,
|
.bDescriptorType = USB_DT_DEVICE_QUALIFIER,
|
||||||
|
@ -224,21 +224,21 @@ static const struct usb_qualifier_descriptor qualifier_descriptor =
|
||||||
.bNumConfigurations = 1
|
.bNumConfigurations = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct usb_string_descriptor usb_string_iManufacturer =
|
static struct usb_string_descriptor __attribute__((aligned(2))) usb_string_iManufacturer =
|
||||||
{
|
{
|
||||||
24,
|
24,
|
||||||
USB_DT_STRING,
|
USB_DT_STRING,
|
||||||
{'R','o','c','k','b','o','x','.','o','r','g'}
|
{'R','o','c','k','b','o','x','.','o','r','g'}
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct usb_string_descriptor usb_string_iProduct =
|
static struct usb_string_descriptor __attribute__((aligned(2))) usb_string_iProduct =
|
||||||
{
|
{
|
||||||
42,
|
42,
|
||||||
USB_DT_STRING,
|
USB_DT_STRING,
|
||||||
{'R','o','c','k','b','o','x',' ','m','e','d','i','a',' ','p','l','a','y','e','r'}
|
{'R','o','c','k','b','o','x',' ','m','e','d','i','a',' ','p','l','a','y','e','r'}
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct usb_string_descriptor usb_string_iSerial =
|
static struct usb_string_descriptor __attribute__((aligned(2))) usb_string_iSerial =
|
||||||
{
|
{
|
||||||
82,
|
82,
|
||||||
USB_DT_STRING,
|
USB_DT_STRING,
|
||||||
|
@ -250,21 +250,21 @@ static struct usb_string_descriptor usb_string_iSerial =
|
||||||
/* Generic for all targets */
|
/* Generic for all targets */
|
||||||
|
|
||||||
/* this is stringid #0: languages supported */
|
/* this is stringid #0: languages supported */
|
||||||
static struct usb_string_descriptor lang_descriptor =
|
static struct usb_string_descriptor __attribute__((aligned(2))) lang_descriptor =
|
||||||
{
|
{
|
||||||
4,
|
4,
|
||||||
USB_DT_STRING,
|
USB_DT_STRING,
|
||||||
{0x0409} /* LANGID US English */
|
{0x0409} /* LANGID US English */
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct usb_string_descriptor usb_string_usb_benchmark =
|
static struct usb_string_descriptor __attribute__((aligned(2))) usb_string_usb_benchmark =
|
||||||
{
|
{
|
||||||
40,
|
40,
|
||||||
USB_DT_STRING,
|
USB_DT_STRING,
|
||||||
{'B','u','l','k',' ','t','e','s','t',' ','i','n','t','e','r','f','a','c','e'}
|
{'B','u','l','k',' ','t','e','s','t',' ','i','n','t','e','r','f','a','c','e'}
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct usb_string_descriptor usb_string_charging_only =
|
static struct usb_string_descriptor __attribute__((aligned(2))) usb_string_charging_only =
|
||||||
{
|
{
|
||||||
28,
|
28,
|
||||||
USB_DT_STRING,
|
USB_DT_STRING,
|
||||||
|
@ -580,7 +580,7 @@ static void usb_core_control_request_handler(struct usb_ctrlrequest* req)
|
||||||
switch (req->wValue >> 8) { /* type */
|
switch (req->wValue >> 8) { /* type */
|
||||||
case USB_DT_DEVICE:
|
case USB_DT_DEVICE:
|
||||||
ptr = &device_descriptor;
|
ptr = &device_descriptor;
|
||||||
size = sizeof device_descriptor;
|
size = sizeof(struct usb_device_descriptor);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case USB_DT_OTHER_SPEED_CONFIG:
|
case USB_DT_OTHER_SPEED_CONFIG:
|
||||||
|
@ -606,7 +606,7 @@ static void usb_core_control_request_handler(struct usb_ctrlrequest* req)
|
||||||
}
|
}
|
||||||
config_descriptor.bDescriptorType=USB_DT_OTHER_SPEED_CONFIG;
|
config_descriptor.bDescriptorType=USB_DT_OTHER_SPEED_CONFIG;
|
||||||
}
|
}
|
||||||
size = sizeof(config_descriptor);
|
size = sizeof(struct usb_config_descriptor);
|
||||||
|
|
||||||
#ifdef USB_CHARGING_ONLY
|
#ifdef USB_CHARGING_ONLY
|
||||||
if(usb_core_charging_enabled){
|
if(usb_core_charging_enabled){
|
||||||
|
@ -682,7 +682,7 @@ static void usb_core_control_request_handler(struct usb_ctrlrequest* req)
|
||||||
|
|
||||||
case USB_DT_DEVICE_QUALIFIER:
|
case USB_DT_DEVICE_QUALIFIER:
|
||||||
ptr = &qualifier_descriptor;
|
ptr = &qualifier_descriptor;
|
||||||
size = sizeof qualifier_descriptor;
|
size = sizeof (struct usb_qualifier_descriptor);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue