forked from mfulz_github/qmk_firmware
Remove potentially unaligned uint32_t access in HIDParser.c, replace with standard C bit shifts.
This commit is contained in:
parent
6c738343ae
commit
4068efbd18
|
@ -7,7 +7,23 @@
|
||||||
/** \page Page_ChangeLog Project Changelog
|
/** \page Page_ChangeLog Project Changelog
|
||||||
*
|
*
|
||||||
* \section Sec_ChangeLogXXXXXX Version XXXXXX
|
* \section Sec_ChangeLogXXXXXX Version XXXXXX
|
||||||
* None.
|
* <b>New:</b>
|
||||||
|
* - Core:
|
||||||
|
* - None
|
||||||
|
* - Library Applications:
|
||||||
|
* - None
|
||||||
|
*
|
||||||
|
* <b>Changed:</b>
|
||||||
|
* - Core:
|
||||||
|
* - Android Accessory Host property strings changed from a struct of pointer to an array to prevent unaligned access on greater than 8-bit architectures
|
||||||
|
* - Library Applications:
|
||||||
|
* - None
|
||||||
|
*
|
||||||
|
* <b>Fixed:</b>
|
||||||
|
* - Core:
|
||||||
|
* - None
|
||||||
|
* - Library Applications:
|
||||||
|
* - None
|
||||||
*
|
*
|
||||||
* \section Sec_ChangeLog120219 Version 120219
|
* \section Sec_ChangeLog120219 Version 120219
|
||||||
* <b>New:</b>
|
* <b>New:</b>
|
||||||
|
|
|
@ -11,7 +11,9 @@
|
||||||
* areas relevant to making older projects compatible with the API changes of each new release.
|
* areas relevant to making older projects compatible with the API changes of each new release.
|
||||||
*
|
*
|
||||||
* \section Sec_MigrationXXXXXX Migrating from 120219 to XXXXXX
|
* \section Sec_MigrationXXXXXX Migrating from 120219 to XXXXXX
|
||||||
* None.
|
* <b>Host Mode</b>
|
||||||
|
* - The Android Accessory Host class driver property strings are now a array of \c char* rather than a struct of named pointers. Existing applications
|
||||||
|
* should use C99 Designated Initializers with the property string indexes located in \ref AOA_Strings_t instead.
|
||||||
*
|
*
|
||||||
* \section Sec_Migration120219 Migrating from 111009 to 120219
|
* \section Sec_Migration120219 Migrating from 111009 to 120219
|
||||||
* <b>USB Core</b>
|
* <b>USB Core</b>
|
||||||
|
|
|
@ -61,17 +61,18 @@ uint8_t USB_ProcessHIDReport(const uint8_t* ReportData,
|
||||||
switch (HIDReportItem & HID_RI_DATA_SIZE_MASK)
|
switch (HIDReportItem & HID_RI_DATA_SIZE_MASK)
|
||||||
{
|
{
|
||||||
case HID_RI_DATA_BITS_32:
|
case HID_RI_DATA_BITS_32:
|
||||||
ReportItemData = le32_to_cpu(*((uint32_t*)ReportData));
|
ReportItemData = (((uint32_t)ReportData[3] << 24) | ((uint32_t)ReportData[2] << 16) |
|
||||||
|
((uint16_t)ReportData[1] << 8) | ReportData[0]);
|
||||||
ReportSize -= 4;
|
ReportSize -= 4;
|
||||||
ReportData += 4;
|
ReportData += 4;
|
||||||
break;
|
break;
|
||||||
case HID_RI_DATA_BITS_16:
|
case HID_RI_DATA_BITS_16:
|
||||||
ReportItemData = le16_to_cpu(*((uint16_t*)ReportData));
|
ReportItemData = (((uint16_t)ReportData[1] << 8) | (ReportData[0]));
|
||||||
ReportSize -= 2;
|
ReportSize -= 2;
|
||||||
ReportData += 2;
|
ReportData += 2;
|
||||||
break;
|
break;
|
||||||
case HID_RI_DATA_BITS_8:
|
case HID_RI_DATA_BITS_8:
|
||||||
ReportItemData = *((uint8_t*)ReportData);
|
ReportItemData = ReportData[0];
|
||||||
ReportSize -= 1;
|
ReportSize -= 1;
|
||||||
ReportData += 1;
|
ReportData += 1;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -233,7 +233,7 @@ static uint8_t AOA_Host_GetAccessoryProtocol(uint16_t* const Protocol)
|
||||||
static uint8_t AOA_Host_SendPropertyString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
static uint8_t AOA_Host_SendPropertyString(USB_ClassInfo_AOA_Host_t* const AOAInterfaceInfo,
|
||||||
const uint8_t StringIndex)
|
const uint8_t StringIndex)
|
||||||
{
|
{
|
||||||
const char* String = ((char**)&AOAInterfaceInfo->Config.PropertyStrings)[StringIndex];
|
const char* String = AOAInterfaceInfo->Config.PropertyStrings[StringIndex];
|
||||||
|
|
||||||
if (String == NULL)
|
if (String == NULL)
|
||||||
String = "";
|
String = "";
|
||||||
|
|
|
@ -91,16 +91,8 @@
|
||||||
uint8_t DataOUTPipeNumber; /**< Pipe number of the AOA interface's OUT data pipe. */
|
uint8_t DataOUTPipeNumber; /**< Pipe number of the AOA interface's OUT data pipe. */
|
||||||
bool DataOUTPipeDoubleBank; /**< Indicates if the AOA interface's OUT data pipe should use double banking. */
|
bool DataOUTPipeDoubleBank; /**< Indicates if the AOA interface's OUT data pipe should use double banking. */
|
||||||
|
|
||||||
struct
|
char* PropertyStrings[AOA_STRING_TOTAL_STRINGS]; /**< Android Accessory property strings, sent to identify the accessory when the
|
||||||
{
|
* Android device is switched into Open Accessory mode. */
|
||||||
char* Manufacturer; /**< Device manufacturer string. */
|
|
||||||
char* Model; /**< Device model name string. */
|
|
||||||
char* Description; /**< Device description string. */
|
|
||||||
char* Version; /**< Device version string. */
|
|
||||||
char* URI; /**< Device URI information string. */
|
|
||||||
char* Serial; /**< Device serial number string. */
|
|
||||||
} ATTR_PACKED PropertyStrings; /**< Android Accessory property strings, sent to identify the accessory when the
|
|
||||||
* Android device is switched into Open Accessory mode. */
|
|
||||||
} Config; /**< Config data for the USB class interface within the device. All elements in this section
|
} Config; /**< Config data for the USB class interface within the device. All elements in this section
|
||||||
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.
|
* <b>must</b> be set or the interface will fail to enumerate and operate correctly.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -278,7 +278,7 @@ uint8_t PRNT_Host_SendByte(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t PRNT_Host_SendString(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,
|
uint8_t PRNT_Host_SendString(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,
|
||||||
void* String)
|
const char* const String)
|
||||||
{
|
{
|
||||||
uint8_t ErrorCode;
|
uint8_t ErrorCode;
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,7 @@
|
||||||
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
* \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum.
|
||||||
*/
|
*/
|
||||||
uint8_t PRNT_Host_SendString(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,
|
uint8_t PRNT_Host_SendString(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo,
|
||||||
void* String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
|
const char* const String) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(2);
|
||||||
|
|
||||||
/** Sends the given raw data stream to the attached printer's input endpoint. This should contain commands that the
|
/** Sends the given raw data stream to the attached printer's input endpoint. This should contain commands that the
|
||||||
* printer is able to understand - for example, PCL data. Not all printers accept all printer languages; see
|
* printer is able to understand - for example, PCL data. Not all printers accept all printer languages; see
|
||||||
|
|
|
@ -38,17 +38,16 @@
|
||||||
|
|
||||||
uint8_t USB_Host_ConfigurationNumber;
|
uint8_t USB_Host_ConfigurationNumber;
|
||||||
|
|
||||||
uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
|
static uint8_t USB_Host_SendControlRequest_PRV(void* const BufferPtr)
|
||||||
{
|
{
|
||||||
uint8_t* DataStream = (uint8_t*)BufferPtr;
|
uint8_t* DataStream = (uint8_t*)BufferPtr;
|
||||||
bool BusSuspended = USB_Host_IsBusSuspended();
|
|
||||||
uint8_t ReturnStatus = HOST_SENDCONTROL_Successful;
|
uint8_t ReturnStatus = HOST_SENDCONTROL_Successful;
|
||||||
uint16_t DataLen = USB_ControlRequest.wLength;
|
uint16_t DataLen = USB_ControlRequest.wLength;
|
||||||
|
|
||||||
USB_Host_ResumeBus();
|
USB_Host_ResumeBus();
|
||||||
|
|
||||||
if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)
|
if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)
|
||||||
goto End_Of_Control_Send;
|
return ReturnStatus;
|
||||||
|
|
||||||
Pipe_SetPipeToken(PIPE_TOKEN_SETUP);
|
Pipe_SetPipeToken(PIPE_TOKEN_SETUP);
|
||||||
Pipe_ClearError();
|
Pipe_ClearError();
|
||||||
|
@ -71,12 +70,12 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
|
||||||
Pipe_ClearSETUP();
|
Pipe_ClearSETUP();
|
||||||
|
|
||||||
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_SetupSent)) != HOST_SENDCONTROL_Successful)
|
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_SetupSent)) != HOST_SENDCONTROL_Successful)
|
||||||
goto End_Of_Control_Send;
|
return ReturnStatus;
|
||||||
|
|
||||||
Pipe_Freeze();
|
Pipe_Freeze();
|
||||||
|
|
||||||
if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)
|
if ((ReturnStatus = USB_Host_WaitMS(1)) != HOST_WAITERROR_Successful)
|
||||||
goto End_Of_Control_Send;
|
return ReturnStatus;
|
||||||
|
|
||||||
if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_DIRECTION) == REQDIR_DEVICETOHOST)
|
if ((USB_ControlRequest.bmRequestType & CONTROL_REQTYPE_DIRECTION) == REQDIR_DEVICETOHOST)
|
||||||
{
|
{
|
||||||
|
@ -89,7 +88,7 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
|
||||||
Pipe_Unfreeze();
|
Pipe_Unfreeze();
|
||||||
|
|
||||||
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_InReceived)) != HOST_SENDCONTROL_Successful)
|
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_InReceived)) != HOST_SENDCONTROL_Successful)
|
||||||
goto End_Of_Control_Send;
|
return ReturnStatus;
|
||||||
|
|
||||||
if (!(Pipe_BytesInPipe()))
|
if (!(Pipe_BytesInPipe()))
|
||||||
DataLen = 0;
|
DataLen = 0;
|
||||||
|
@ -109,12 +108,12 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
|
||||||
Pipe_Unfreeze();
|
Pipe_Unfreeze();
|
||||||
|
|
||||||
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful)
|
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful)
|
||||||
goto End_Of_Control_Send;
|
return ReturnStatus;
|
||||||
|
|
||||||
Pipe_ClearOUT();
|
Pipe_ClearOUT();
|
||||||
|
|
||||||
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful)
|
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful)
|
||||||
goto End_Of_Control_Send;
|
return ReturnStatus;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -126,7 +125,7 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
|
||||||
while (DataLen)
|
while (DataLen)
|
||||||
{
|
{
|
||||||
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful)
|
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful)
|
||||||
goto End_Of_Control_Send;
|
return ReturnStatus;
|
||||||
|
|
||||||
while (DataLen && (Pipe_BytesInPipe() < USB_Host_ControlPipeSize))
|
while (DataLen && (Pipe_BytesInPipe() < USB_Host_ControlPipeSize))
|
||||||
{
|
{
|
||||||
|
@ -138,7 +137,7 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful)
|
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_OutReady)) != HOST_SENDCONTROL_Successful)
|
||||||
goto End_Of_Control_Send;
|
return ReturnStatus;
|
||||||
|
|
||||||
Pipe_Freeze();
|
Pipe_Freeze();
|
||||||
}
|
}
|
||||||
|
@ -147,19 +146,11 @@ uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
|
||||||
Pipe_Unfreeze();
|
Pipe_Unfreeze();
|
||||||
|
|
||||||
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_InReceived)) != HOST_SENDCONTROL_Successful)
|
if ((ReturnStatus = USB_Host_WaitForIOS(USB_HOST_WAITFOR_InReceived)) != HOST_SENDCONTROL_Successful)
|
||||||
goto End_Of_Control_Send;
|
return ReturnStatus;
|
||||||
|
|
||||||
Pipe_ClearIN();
|
Pipe_ClearIN();
|
||||||
}
|
}
|
||||||
|
|
||||||
End_Of_Control_Send:
|
|
||||||
Pipe_Freeze();
|
|
||||||
|
|
||||||
if (BusSuspended)
|
|
||||||
USB_Host_SuspendBus();
|
|
||||||
|
|
||||||
Pipe_ResetPipe(PIPE_CONTROLPIPE);
|
|
||||||
|
|
||||||
return ReturnStatus;
|
return ReturnStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,6 +178,21 @@ static uint8_t USB_Host_WaitForIOS(const uint8_t WaitType)
|
||||||
return HOST_SENDCONTROL_Successful;
|
return HOST_SENDCONTROL_Successful;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t USB_Host_SendControlRequest(void* const BufferPtr)
|
||||||
|
{
|
||||||
|
bool BusSuspended = USB_Host_IsBusSuspended();
|
||||||
|
uint8_t ReturnStatus = USB_Host_SendControlRequest_PRV(BufferPtr);
|
||||||
|
|
||||||
|
Pipe_Freeze();
|
||||||
|
|
||||||
|
if (BusSuspended)
|
||||||
|
USB_Host_SuspendBus();
|
||||||
|
|
||||||
|
Pipe_ResetPipe(PIPE_CONTROLPIPE);
|
||||||
|
|
||||||
|
return ReturnStatus;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber)
|
uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber)
|
||||||
{
|
{
|
||||||
uint8_t ErrorCode;
|
uint8_t ErrorCode;
|
||||||
|
|
|
@ -278,6 +278,7 @@
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
#if defined(__INCLUDE_FROM_HOSTSTDREQ_C)
|
#if defined(__INCLUDE_FROM_HOSTSTDREQ_C)
|
||||||
|
static uint8_t USB_Host_SendControlRequest_PRV(void* const BufferPtr);
|
||||||
static uint8_t USB_Host_WaitForIOS(const uint8_t WaitType);
|
static uint8_t USB_Host_WaitForIOS(const uint8_t WaitType);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue