提交 c2539db3 编写于 作者: lymzzyh's avatar lymzzyh

[Components][drivers][usb]修复非对齐访问异常

上级 1ddde279
...@@ -82,6 +82,7 @@ struct vcom_tx_msg ...@@ -82,6 +82,7 @@ struct vcom_tx_msg
rt_size_t size; rt_size_t size;
}; };
ALIGN(4)
static struct udevice_descriptor dev_desc = static struct udevice_descriptor dev_desc =
{ {
USB_DESC_LENGTH_DEVICE, //bLength; USB_DESC_LENGTH_DEVICE, //bLength;
...@@ -101,6 +102,7 @@ static struct udevice_descriptor dev_desc = ...@@ -101,6 +102,7 @@ static struct udevice_descriptor dev_desc =
}; };
//FS and HS needed //FS and HS needed
ALIGN(4)
static struct usb_qualifier_descriptor dev_qualifier = static struct usb_qualifier_descriptor dev_qualifier =
{ {
sizeof(dev_qualifier), //bLength sizeof(dev_qualifier), //bLength
...@@ -115,6 +117,7 @@ static struct usb_qualifier_descriptor dev_qualifier = ...@@ -115,6 +117,7 @@ static struct usb_qualifier_descriptor dev_qualifier =
}; };
/* communcation interface descriptor */ /* communcation interface descriptor */
ALIGN(4)
const static struct ucdc_comm_descriptor _comm_desc = const static struct ucdc_comm_descriptor _comm_desc =
{ {
#ifdef RT_USB_DEVICE_COMPOSITE #ifdef RT_USB_DEVICE_COMPOSITE
...@@ -184,6 +187,7 @@ const static struct ucdc_comm_descriptor _comm_desc = ...@@ -184,6 +187,7 @@ const static struct ucdc_comm_descriptor _comm_desc =
}; };
/* data interface descriptor */ /* data interface descriptor */
ALIGN(4)
const static struct ucdc_data_descriptor _data_desc = const static struct ucdc_data_descriptor _data_desc =
{ {
/* interface descriptor */ /* interface descriptor */
...@@ -217,7 +221,7 @@ const static struct ucdc_data_descriptor _data_desc = ...@@ -217,7 +221,7 @@ const static struct ucdc_data_descriptor _data_desc =
0x00, 0x00,
}, },
}; };
ALIGN(4)
static char serno[_SER_NO_LEN + 1] = {'\0'}; static char serno[_SER_NO_LEN + 1] = {'\0'};
RT_WEAK rt_err_t vcom_get_stored_serno(char *serno, int size); 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) ...@@ -225,7 +229,7 @@ rt_err_t vcom_get_stored_serno(char *serno, int size)
{ {
return RT_ERROR; return RT_ERROR;
} }
ALIGN(4)
const static char* _ustring[] = const static char* _ustring[] =
{ {
"Language", "Language",
......
...@@ -35,6 +35,7 @@ struct hid_s ...@@ -35,6 +35,7 @@ struct hid_s
}; };
/* CustomHID_ConfigDescriptor */ /* CustomHID_ConfigDescriptor */
ALIGN(4)
const rt_uint8_t _report_desc[]= const rt_uint8_t _report_desc[]=
{ {
#ifdef RT_USB_DEVICE_HID_KEYBOARD #ifdef RT_USB_DEVICE_HID_KEYBOARD
...@@ -239,6 +240,7 @@ const rt_uint8_t _report_desc[]= ...@@ -239,6 +240,7 @@ const rt_uint8_t _report_desc[]=
#endif #endif
}; /* CustomHID_ReportDescriptor */ }; /* CustomHID_ReportDescriptor */
ALIGN(4)
static struct udevice_descriptor _dev_desc = static struct udevice_descriptor _dev_desc =
{ {
USB_DESC_LENGTH_DEVICE, //bLength; USB_DESC_LENGTH_DEVICE, //bLength;
...@@ -258,6 +260,7 @@ static struct udevice_descriptor _dev_desc = ...@@ -258,6 +260,7 @@ static struct udevice_descriptor _dev_desc =
}; };
//FS and HS needed //FS and HS needed
ALIGN(4)
static struct usb_qualifier_descriptor dev_qualifier = static struct usb_qualifier_descriptor dev_qualifier =
{ {
sizeof(dev_qualifier), //bLength sizeof(dev_qualifier), //bLength
...@@ -273,6 +276,7 @@ static struct usb_qualifier_descriptor dev_qualifier = ...@@ -273,6 +276,7 @@ static struct usb_qualifier_descriptor dev_qualifier =
/* hid interface descriptor */ /* hid interface descriptor */
ALIGN(4)
const static struct uhid_comm_descriptor _hid_comm_desc = const static struct uhid_comm_descriptor _hid_comm_desc =
{ {
#ifdef RT_USB_DEVICE_COMPOSITE #ifdef RT_USB_DEVICE_COMPOSITE
...@@ -357,7 +361,7 @@ const static struct uhid_comm_descriptor _hid_comm_desc = ...@@ -357,7 +361,7 @@ const static struct uhid_comm_descriptor _hid_comm_desc =
}, },
}; };
ALIGN(4)
const static char* _ustring[] = const static char* _ustring[] =
{ {
"Language", "Language",
......
...@@ -68,6 +68,7 @@ struct mstorage ...@@ -68,6 +68,7 @@ struct mstorage
struct rt_device_blk_geometry geometry; struct rt_device_blk_geometry geometry;
}; };
ALIGN(4)
static struct udevice_descriptor dev_desc = static struct udevice_descriptor dev_desc =
{ {
USB_DESC_LENGTH_DEVICE, //bLength; USB_DESC_LENGTH_DEVICE, //bLength;
...@@ -87,6 +88,7 @@ static struct udevice_descriptor dev_desc = ...@@ -87,6 +88,7 @@ static struct udevice_descriptor dev_desc =
}; };
//FS and HS needed //FS and HS needed
ALIGN(4)
static struct usb_qualifier_descriptor dev_qualifier = static struct usb_qualifier_descriptor dev_qualifier =
{ {
sizeof(dev_qualifier), //bLength sizeof(dev_qualifier), //bLength
...@@ -101,7 +103,7 @@ static struct usb_qualifier_descriptor dev_qualifier = ...@@ -101,7 +103,7 @@ static struct usb_qualifier_descriptor dev_qualifier =
}; };
ALIGN(4)
const static struct umass_descriptor _mass_desc = const static struct umass_descriptor _mass_desc =
{ {
#ifdef RT_USB_DEVICE_COMPOSITE #ifdef RT_USB_DEVICE_COMPOSITE
...@@ -148,6 +150,7 @@ const static struct umass_descriptor _mass_desc = ...@@ -148,6 +150,7 @@ const static struct umass_descriptor _mass_desc =
}, },
}; };
ALIGN(4)
const static char* _ustring[] = const static char* _ustring[] =
{ {
"Language", "Language",
...@@ -170,6 +173,7 @@ static rt_size_t _read_10(ufunction_t func, ustorage_cbw_t cbw); ...@@ -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 _write_10(ufunction_t func, ustorage_cbw_t cbw);
static rt_size_t _verify_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[] = static struct scsi_cmd cmd_data[] =
{ {
{SCSI_TEST_UNIT_READY, _test_unit_ready, 6, FIXED, 0, DIR_NONE}, {SCSI_TEST_UNIT_READY, _test_unit_ready, 6, FIXED, 0, DIR_NONE},
......
...@@ -214,6 +214,7 @@ const static char* _ustring[] = ...@@ -214,6 +214,7 @@ const static char* _ustring[] =
USB_STRING_OS USB_STRING_OS
}; };
ALIGN(4)
struct usb_os_function_comp_id_descriptor rndis_func_comp_id_desc = struct usb_os_function_comp_id_descriptor rndis_func_comp_id_desc =
{ {
.bFirstInterfaceNumber = USB_DYNAMIC, .bFirstInterfaceNumber = USB_DYNAMIC,
...@@ -222,7 +223,9 @@ struct usb_os_function_comp_id_descriptor rndis_func_comp_id_desc = ...@@ -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}, .subCompatibleID = {'5', '1', '6', '2', '0', '0', '1', 0x00},
.reserved2 = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00} .reserved2 = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
}; };
//FS and HS needed //FS and HS needed
ALIGN(4)
static struct usb_qualifier_descriptor dev_qualifier = static struct usb_qualifier_descriptor dev_qualifier =
{ {
sizeof(dev_qualifier), //bLength sizeof(dev_qualifier), //bLength
......
...@@ -24,6 +24,7 @@ struct winusb_device ...@@ -24,6 +24,7 @@ struct winusb_device
typedef struct winusb_device * winusb_device_t; typedef struct winusb_device * winusb_device_t;
ALIGN(4)
static struct udevice_descriptor dev_desc = static struct udevice_descriptor dev_desc =
{ {
USB_DESC_LENGTH_DEVICE, //bLength; USB_DESC_LENGTH_DEVICE, //bLength;
...@@ -41,7 +42,9 @@ static struct udevice_descriptor dev_desc = ...@@ -41,7 +42,9 @@ static struct udevice_descriptor dev_desc =
USB_STRING_SERIAL_INDEX, //iSerialNumber; USB_STRING_SERIAL_INDEX, //iSerialNumber;
USB_DYNAMIC, //bNumConfigurations; USB_DYNAMIC, //bNumConfigurations;
}; };
//FS and HS needed //FS and HS needed
ALIGN(4)
static struct usb_qualifier_descriptor dev_qualifier = static struct usb_qualifier_descriptor dev_qualifier =
{ {
sizeof(dev_qualifier), //bLength sizeof(dev_qualifier), //bLength
...@@ -55,6 +58,7 @@ static struct usb_qualifier_descriptor dev_qualifier = ...@@ -55,6 +58,7 @@ static struct usb_qualifier_descriptor dev_qualifier =
0, 0,
}; };
ALIGN(4)
struct winusb_descriptor _winusb_desc = struct winusb_descriptor _winusb_desc =
{ {
#ifdef RT_USB_DEVICE_COMPOSITE #ifdef RT_USB_DEVICE_COMPOSITE
...@@ -102,7 +106,7 @@ struct winusb_descriptor _winusb_desc = ...@@ -102,7 +106,7 @@ struct winusb_descriptor _winusb_desc =
}, },
}; };
ALIGN(4)
const static char* _ustring[] = const static char* _ustring[] =
{ {
"Language", "Language",
...@@ -113,11 +117,14 @@ const static char* _ustring[] = ...@@ -113,11 +117,14 @@ const static char* _ustring[] =
"Interface", "Interface",
USB_STRING_OS//must be USB_STRING_OS//must be
}; };
ALIGN(4)
struct usb_os_proerty winusb_proerty[] = struct usb_os_proerty winusb_proerty[] =
{ {
USB_OS_PROERTY_DESC(USB_OS_PROERTY_TYPE_REG_SZ,"DeviceInterfaceGUID",RT_WINUSB_GUID), 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 = struct usb_os_function_comp_id_descriptor winusb_func_comp_id_desc =
{ {
.bFirstInterfaceNumber = USB_DYNAMIC, .bFirstInterfaceNumber = USB_DYNAMIC,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册