summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2018-10-26 07:08:24 +0800
committerGitHub <[email protected]>2018-10-26 07:08:24 +0800
commit95fde46d180f079c3ec655d1df9ae3d0a1198b09 (patch)
tree88b6a626bba4ef723b8d5e1f66c679a25b9de70f
parent8483a50d8df8bf652c71d74d678bea48c48cfc92 (diff)
parentc2539db38ed71c56c463b725732db9c0e5a34287 (diff)
Merge pull request #1923 from uestczyh222/usb
[Components][drivers][usb]修复非对齐访问异常
-rw-r--r--components/drivers/usb/usbdevice/class/cdc_vcom.c8
-rw-r--r--components/drivers/usb/usbdevice/class/hid.c6
-rw-r--r--components/drivers/usb/usbdevice/class/mstorage.c6
-rw-r--r--components/drivers/usb/usbdevice/class/rndis.c3
-rw-r--r--components/drivers/usb/usbdevice/class/winusb.c9
5 files changed, 27 insertions, 5 deletions
diff --git a/components/drivers/usb/usbdevice/class/cdc_vcom.c b/components/drivers/usb/usbdevice/class/cdc_vcom.c
index 119e283898..c83043314e 100644
--- a/components/drivers/usb/usbdevice/class/cdc_vcom.c
+++ b/components/drivers/usb/usbdevice/class/cdc_vcom.c
@@ -82,6 +82,7 @@ struct vcom_tx_msg
rt_size_t size;
};
+ALIGN(4)
static struct udevice_descriptor dev_desc =
{
USB_DESC_LENGTH_DEVICE, //bLength;
@@ -101,6 +102,7 @@ static struct udevice_descriptor dev_desc =
};
//FS and HS needed
+ALIGN(4)
static struct usb_qualifier_descriptor dev_qualifier =
{
sizeof(dev_qualifier), //bLength
@@ -115,6 +117,7 @@ static struct usb_qualifier_descriptor dev_qualifier =
};
/* communcation interface descriptor */
+ALIGN(4)
const static struct ucdc_comm_descriptor _comm_desc =
{
#ifdef RT_USB_DEVICE_COMPOSITE
@@ -184,6 +187,7 @@ const static struct ucdc_comm_descriptor _comm_desc =
};
/* data interface descriptor */
+ALIGN(4)
const static struct ucdc_data_descriptor _data_desc =
{
/* interface descriptor */
@@ -217,7 +221,7 @@ const static struct ucdc_data_descriptor _data_desc =
0x00,
},
};
-
+ALIGN(4)
static char serno[_SER_NO_LEN + 1] = {'\0'};
RT_WEAK rt_err_t vcom_get_stored_serno(char *serno, int size);
@@ -225,7 +229,7 @@ rt_err_t vcom_get_stored_serno(char *serno, int size)
{
return RT_ERROR;
}
-
+ALIGN(4)
const static char* _ustring[] =
{
"Language",
diff --git a/components/drivers/usb/usbdevice/class/hid.c b/components/drivers/usb/usbdevice/class/hid.c
index 8f34d4c1af..aea6d802d1 100644
--- a/components/drivers/usb/usbdevice/class/hid.c
+++ b/components/drivers/usb/usbdevice/class/hid.c
@@ -35,6 +35,7 @@ struct hid_s
};
/* CustomHID_ConfigDescriptor */
+ALIGN(4)
const rt_uint8_t _report_desc[]=
{
#ifdef RT_USB_DEVICE_HID_KEYBOARD
@@ -239,6 +240,7 @@ const rt_uint8_t _report_desc[]=
#endif
}; /* CustomHID_ReportDescriptor */
+ALIGN(4)
static struct udevice_descriptor _dev_desc =
{
USB_DESC_LENGTH_DEVICE, //bLength;
@@ -258,6 +260,7 @@ static struct udevice_descriptor _dev_desc =
};
//FS and HS needed
+ALIGN(4)
static struct usb_qualifier_descriptor dev_qualifier =
{
sizeof(dev_qualifier), //bLength
@@ -273,6 +276,7 @@ static struct usb_qualifier_descriptor dev_qualifier =
/* hid interface descriptor */
+ALIGN(4)
const static struct uhid_comm_descriptor _hid_comm_desc =
{
#ifdef RT_USB_DEVICE_COMPOSITE
@@ -357,7 +361,7 @@ const static struct uhid_comm_descriptor _hid_comm_desc =
},
};
-
+ALIGN(4)
const static char* _ustring[] =
{
"Language",
diff --git a/components/drivers/usb/usbdevice/class/mstorage.c b/components/drivers/usb/usbdevice/class/mstorage.c
index 5131f83840..6a6e92415b 100644
--- a/components/drivers/usb/usbdevice/class/mstorage.c
+++ b/components/drivers/usb/usbdevice/class/mstorage.c
@@ -68,6 +68,7 @@ struct mstorage
struct rt_device_blk_geometry geometry;
};
+ALIGN(4)
static struct udevice_descriptor dev_desc =
{
USB_DESC_LENGTH_DEVICE, //bLength;
@@ -87,6 +88,7 @@ static struct udevice_descriptor dev_desc =
};
//FS and HS needed
+ALIGN(4)
static struct usb_qualifier_descriptor dev_qualifier =
{
sizeof(dev_qualifier), //bLength
@@ -101,7 +103,7 @@ static struct usb_qualifier_descriptor dev_qualifier =
};
-
+ALIGN(4)
const static struct umass_descriptor _mass_desc =
{
#ifdef RT_USB_DEVICE_COMPOSITE
@@ -148,6 +150,7 @@ const static struct umass_descriptor _mass_desc =
},
};
+ALIGN(4)
const static char* _ustring[] =
{
"Language",
@@ -170,6 +173,7 @@ static rt_size_t _read_10(ufunction_t func, ustorage_cbw_t cbw);
static rt_size_t _write_10(ufunction_t func, ustorage_cbw_t cbw);
static rt_size_t _verify_10(ufunction_t func, ustorage_cbw_t cbw);
+ALIGN(4)
static struct scsi_cmd cmd_data[] =
{
{SCSI_TEST_UNIT_READY, _test_unit_ready, 6, FIXED, 0, DIR_NONE},
diff --git a/components/drivers/usb/usbdevice/class/rndis.c b/components/drivers/usb/usbdevice/class/rndis.c
index e07c6349d0..8996b728e6 100644
--- a/components/drivers/usb/usbdevice/class/rndis.c
+++ b/components/drivers/usb/usbdevice/class/rndis.c
@@ -214,6 +214,7 @@ const static char* _ustring[] =
USB_STRING_OS
};
+ALIGN(4)
struct usb_os_function_comp_id_descriptor rndis_func_comp_id_desc =
{
.bFirstInterfaceNumber = USB_DYNAMIC,
@@ -222,7 +223,9 @@ struct usb_os_function_comp_id_descriptor rndis_func_comp_id_desc =
.subCompatibleID = {'5', '1', '6', '2', '0', '0', '1', 0x00},
.reserved2 = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
};
+
//FS and HS needed
+ALIGN(4)
static struct usb_qualifier_descriptor dev_qualifier =
{
sizeof(dev_qualifier), //bLength
diff --git a/components/drivers/usb/usbdevice/class/winusb.c b/components/drivers/usb/usbdevice/class/winusb.c
index ff2a81a4da..bf4b353d73 100644
--- a/components/drivers/usb/usbdevice/class/winusb.c
+++ b/components/drivers/usb/usbdevice/class/winusb.c
@@ -24,6 +24,7 @@ struct winusb_device
typedef struct winusb_device * winusb_device_t;
+ALIGN(4)
static struct udevice_descriptor dev_desc =
{
USB_DESC_LENGTH_DEVICE, //bLength;
@@ -41,7 +42,9 @@ static struct udevice_descriptor dev_desc =
USB_STRING_SERIAL_INDEX, //iSerialNumber;
USB_DYNAMIC, //bNumConfigurations;
};
+
//FS and HS needed
+ALIGN(4)
static struct usb_qualifier_descriptor dev_qualifier =
{
sizeof(dev_qualifier), //bLength
@@ -55,6 +58,7 @@ static struct usb_qualifier_descriptor dev_qualifier =
0,
};
+ALIGN(4)
struct winusb_descriptor _winusb_desc =
{
#ifdef RT_USB_DEVICE_COMPOSITE
@@ -102,7 +106,7 @@ struct winusb_descriptor _winusb_desc =
},
};
-
+ALIGN(4)
const static char* _ustring[] =
{
"Language",
@@ -113,11 +117,14 @@ const static char* _ustring[] =
"Interface",
USB_STRING_OS//must be
};
+
+ALIGN(4)
struct usb_os_proerty winusb_proerty[] =
{
USB_OS_PROERTY_DESC(USB_OS_PROERTY_TYPE_REG_SZ,"DeviceInterfaceGUID",RT_WINUSB_GUID),
};
+ALIGN(4)
struct usb_os_function_comp_id_descriptor winusb_func_comp_id_desc =
{
.bFirstInterfaceNumber = USB_DYNAMIC,