Просмотр исходного кода

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

zyh 6 лет назад
Родитель
Сommit
c2539db38e

+ 6 - 2
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",

+ 5 - 1
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",

+ 5 - 1
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},

+ 3 - 0
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

+ 8 - 1
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,