More endianness porting of the LUFA host mode class drivers.

pull/1469/head
Dean Camera 14 years ago
parent 85e85befc4
commit c029d72b94

@ -103,7 +103,7 @@ uint8_t Audio_Host_ConfigurePipes(USB_ClassInfo_Audio_Host_t* const AudioInterfa
if (PipeNum == AudioInterfaceInfo->Config.DataINPipeNumber) if (PipeNum == AudioInterfaceInfo->Config.DataINPipeNumber)
{ {
Size = DataINEndpoint->EndpointSize; Size = le16_to_cpu(DataINEndpoint->EndpointSize);
EndpointAddress = DataINEndpoint->EndpointAddress; EndpointAddress = DataINEndpoint->EndpointAddress;
Token = PIPE_TOKEN_IN; Token = PIPE_TOKEN_IN;
Type = EP_TYPE_ISOCHRONOUS; Type = EP_TYPE_ISOCHRONOUS;
@ -113,7 +113,7 @@ uint8_t Audio_Host_ConfigurePipes(USB_ClassInfo_Audio_Host_t* const AudioInterfa
} }
else if (PipeNum == AudioInterfaceInfo->Config.DataOUTPipeNumber) else if (PipeNum == AudioInterfaceInfo->Config.DataOUTPipeNumber)
{ {
Size = DataOUTEndpoint->EndpointSize; Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);
EndpointAddress = DataOUTEndpoint->EndpointAddress; EndpointAddress = DataOUTEndpoint->EndpointAddress;
Token = PIPE_TOKEN_OUT; Token = PIPE_TOKEN_OUT;
Type = EP_TYPE_ISOCHRONOUS; Type = EP_TYPE_ISOCHRONOUS;

@ -110,7 +110,7 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
if (PipeNum == CDCInterfaceInfo->Config.DataINPipeNumber) if (PipeNum == CDCInterfaceInfo->Config.DataINPipeNumber)
{ {
Size = DataINEndpoint->EndpointSize; Size = le16_to_cpu(DataINEndpoint->EndpointSize);
EndpointAddress = DataINEndpoint->EndpointAddress; EndpointAddress = DataINEndpoint->EndpointAddress;
Token = PIPE_TOKEN_IN; Token = PIPE_TOKEN_IN;
Type = EP_TYPE_BULK; Type = EP_TYPE_BULK;
@ -121,7 +121,7 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
} }
else if (PipeNum == CDCInterfaceInfo->Config.DataOUTPipeNumber) else if (PipeNum == CDCInterfaceInfo->Config.DataOUTPipeNumber)
{ {
Size = DataOUTEndpoint->EndpointSize; Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);
EndpointAddress = DataOUTEndpoint->EndpointAddress; EndpointAddress = DataOUTEndpoint->EndpointAddress;
Token = PIPE_TOKEN_OUT; Token = PIPE_TOKEN_OUT;
Type = EP_TYPE_BULK; Type = EP_TYPE_BULK;
@ -132,7 +132,7 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
} }
else if (PipeNum == CDCInterfaceInfo->Config.NotificationPipeNumber) else if (PipeNum == CDCInterfaceInfo->Config.NotificationPipeNumber)
{ {
Size = NotificationEndpoint->EndpointSize; Size = le16_to_cpu(NotificationEndpoint->EndpointSize);
EndpointAddress = NotificationEndpoint->EndpointAddress; EndpointAddress = NotificationEndpoint->EndpointAddress;
Token = PIPE_TOKEN_IN; Token = PIPE_TOKEN_IN;
Type = EP_TYPE_INTERRUPT; Type = EP_TYPE_INTERRUPT;

@ -105,7 +105,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
if (PipeNum == HIDInterfaceInfo->Config.DataINPipeNumber) if (PipeNum == HIDInterfaceInfo->Config.DataINPipeNumber)
{ {
Size = DataINEndpoint->EndpointSize; Size = le16_to_cpu(DataINEndpoint->EndpointSize);
EndpointAddress = DataINEndpoint->EndpointAddress; EndpointAddress = DataINEndpoint->EndpointAddress;
Token = PIPE_TOKEN_IN; Token = PIPE_TOKEN_IN;
Type = EP_TYPE_INTERRUPT; Type = EP_TYPE_INTERRUPT;
@ -119,7 +119,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
if (DataOUTEndpoint == NULL) if (DataOUTEndpoint == NULL)
continue; continue;
Size = DataOUTEndpoint->EndpointSize; Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);
EndpointAddress = DataOUTEndpoint->EndpointAddress; EndpointAddress = DataOUTEndpoint->EndpointAddress;
Token = PIPE_TOKEN_OUT; Token = PIPE_TOKEN_OUT;
Type = EP_TYPE_INTERRUPT; Type = EP_TYPE_INTERRUPT;
@ -145,7 +145,7 @@ uint8_t HID_Host_ConfigurePipes(USB_ClassInfo_HID_Host_t* const HIDInterfaceInfo
} }
HIDInterfaceInfo->State.InterfaceNumber = HIDInterface->InterfaceNumber; HIDInterfaceInfo->State.InterfaceNumber = HIDInterface->InterfaceNumber;
HIDInterfaceInfo->State.HIDReportSize = HIDDescriptor->HIDReportLength; HIDInterfaceInfo->State.HIDReportSize = LE16_TO_CPU(HIDDescriptor->HIDReportLength);
HIDInterfaceInfo->State.SupportsBootProtocol = (HIDInterface->SubClass != HID_CSCP_NonBootProtocol); HIDInterfaceInfo->State.SupportsBootProtocol = (HIDInterface->SubClass != HID_CSCP_NonBootProtocol);
HIDInterfaceInfo->State.LargestReportSize = 8; HIDInterfaceInfo->State.LargestReportSize = 8;
HIDInterfaceInfo->State.IsActive = true; HIDInterfaceInfo->State.IsActive = true;
@ -334,6 +334,9 @@ uint8_t HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInf
{ {
uint8_t ErrorCode; uint8_t ErrorCode;
if (!(HIDInterfaceInfo->State.SupportsBootProtocol))
return HID_ERROR_LOGICAL;
USB_ControlRequest = (USB_Request_Header_t) USB_ControlRequest = (USB_Request_Header_t)
{ {
.bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE), .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
@ -345,9 +348,6 @@ uint8_t HID_Host_SetBootProtocol(USB_ClassInfo_HID_Host_t* const HIDInterfaceInf
Pipe_SelectPipe(PIPE_CONTROLPIPE); Pipe_SelectPipe(PIPE_CONTROLPIPE);
if (!(HIDInterfaceInfo->State.SupportsBootProtocol))
return HID_ERROR_LOGICAL;
if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful) if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)
return ErrorCode; return ErrorCode;

@ -88,7 +88,7 @@ uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceI
if (PipeNum == MIDIInterfaceInfo->Config.DataINPipeNumber) if (PipeNum == MIDIInterfaceInfo->Config.DataINPipeNumber)
{ {
Size = DataINEndpoint->EndpointSize; Size = le16_to_cpu(DataINEndpoint->EndpointSize);
EndpointAddress = DataINEndpoint->EndpointAddress; EndpointAddress = DataINEndpoint->EndpointAddress;
Token = PIPE_TOKEN_IN; Token = PIPE_TOKEN_IN;
Type = EP_TYPE_BULK; Type = EP_TYPE_BULK;
@ -98,7 +98,7 @@ uint8_t MIDI_Host_ConfigurePipes(USB_ClassInfo_MIDI_Host_t* const MIDIInterfaceI
} }
else if (PipeNum == MIDIInterfaceInfo->Config.DataOUTPipeNumber) else if (PipeNum == MIDIInterfaceInfo->Config.DataOUTPipeNumber)
{ {
Size = DataOUTEndpoint->EndpointSize; Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);
EndpointAddress = DataOUTEndpoint->EndpointAddress; EndpointAddress = DataOUTEndpoint->EndpointAddress;
Token = PIPE_TOKEN_OUT; Token = PIPE_TOKEN_OUT;
Type = EP_TYPE_BULK; Type = EP_TYPE_BULK;

@ -88,7 +88,7 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
if (PipeNum == MSInterfaceInfo->Config.DataINPipeNumber) if (PipeNum == MSInterfaceInfo->Config.DataINPipeNumber)
{ {
Size = DataINEndpoint->EndpointSize; Size = le16_to_cpu(DataINEndpoint->EndpointSize);
EndpointAddress = DataINEndpoint->EndpointAddress; EndpointAddress = DataINEndpoint->EndpointAddress;
Token = PIPE_TOKEN_IN; Token = PIPE_TOKEN_IN;
Type = EP_TYPE_BULK; Type = EP_TYPE_BULK;
@ -98,7 +98,7 @@ uint8_t MS_Host_ConfigurePipes(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
} }
else if (PipeNum == MSInterfaceInfo->Config.DataOUTPipeNumber) else if (PipeNum == MSInterfaceInfo->Config.DataOUTPipeNumber)
{ {
Size = DataOUTEndpoint->EndpointSize; Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);
EndpointAddress = DataOUTEndpoint->EndpointAddress; EndpointAddress = DataOUTEndpoint->EndpointAddress;
Token = PIPE_TOKEN_OUT; Token = PIPE_TOKEN_OUT;
Type = EP_TYPE_BULK; Type = EP_TYPE_BULK;
@ -175,8 +175,8 @@ static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInf
if (++MSInterfaceInfo->State.TransactionTag == 0xFFFFFFFF) if (++MSInterfaceInfo->State.TransactionTag == 0xFFFFFFFF)
MSInterfaceInfo->State.TransactionTag = 1; MSInterfaceInfo->State.TransactionTag = 1;
SCSICommandBlock->Signature = MS_CBW_SIGNATURE; SCSICommandBlock->Signature = CPU_TO_LE32(MS_CBW_SIGNATURE);
SCSICommandBlock->Tag = MSInterfaceInfo->State.TransactionTag; SCSICommandBlock->Tag = cpu_to_le32(MSInterfaceInfo->State.TransactionTag);
Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipeNumber); Pipe_SelectPipe(MSInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze(); Pipe_Unfreeze();
@ -260,7 +260,7 @@ static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* const MSInterfac
void* BufferPtr) void* BufferPtr)
{ {
uint8_t ErrorCode = PIPE_RWSTREAM_NoError; uint8_t ErrorCode = PIPE_RWSTREAM_NoError;
uint16_t BytesRem = SCSICommandBlock->DataTransferLength; uint16_t BytesRem = le32_to_cpu(SCSICommandBlock->DataTransferLength);
if (SCSICommandBlock->Flags & MS_COMMAND_DIR_DATA_IN) if (SCSICommandBlock->Flags & MS_COMMAND_DIR_DATA_IN)
{ {
@ -358,7 +358,7 @@ uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
Pipe_SelectPipe(PIPE_CONTROLPIPE); Pipe_SelectPipe(PIPE_CONTROLPIPE);
if ((ErrorCode = USB_Host_SendControlRequest(MaxLUNIndex)) != HOST_SENDCONTROL_Successful) if ((ErrorCode = USB_Host_SendControlRequest(MaxLUNIndex)) == HOST_SENDCONTROL_SetupStalled)
{ {
*MaxLUNIndex = 0; *MaxLUNIndex = 0;
ErrorCode = HOST_SENDCONTROL_Successful; ErrorCode = HOST_SENDCONTROL_Successful;
@ -378,7 +378,7 @@ uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{ {
.DataTransferLength = sizeof(SCSI_Inquiry_Response_t), .DataTransferLength = CPU_TO_LE32(sizeof(SCSI_Inquiry_Response_t)),
.Flags = MS_COMMAND_DIR_DATA_IN, .Flags = MS_COMMAND_DIR_DATA_IN,
.LUN = LUNIndex, .LUN = LUNIndex,
.SCSICommandLength = 6, .SCSICommandLength = 6,
@ -414,7 +414,7 @@ uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{ {
.DataTransferLength = 0, .DataTransferLength = CPU_TO_LE32(0),
.Flags = MS_COMMAND_DIR_DATA_IN, .Flags = MS_COMMAND_DIR_DATA_IN,
.LUN = LUNIndex, .LUN = LUNIndex,
.SCSICommandLength = 6, .SCSICommandLength = 6,
@ -451,7 +451,7 @@ uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* const MSInterfaceInf
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{ {
.DataTransferLength = sizeof(SCSI_Capacity_t), .DataTransferLength = CPU_TO_LE32(sizeof(SCSI_Capacity_t)),
.Flags = MS_COMMAND_DIR_DATA_IN, .Flags = MS_COMMAND_DIR_DATA_IN,
.LUN = LUNIndex, .LUN = LUNIndex,
.SCSICommandLength = 10, .SCSICommandLength = 10,
@ -475,8 +475,8 @@ uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* const MSInterfaceInf
if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, DeviceCapacity)) != PIPE_RWSTREAM_NoError) if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, DeviceCapacity)) != PIPE_RWSTREAM_NoError)
return ErrorCode; return ErrorCode;
SwapEndian_n(&DeviceCapacity->Blocks, sizeof(DeviceCapacity->Blocks)); DeviceCapacity->Blocks = BE32_TO_CPU(DeviceCapacity->Blocks);
SwapEndian_n(&DeviceCapacity->BlockSize, sizeof(DeviceCapacity->BlockSize)); DeviceCapacity->BlockSize = BE32_TO_CPU(DeviceCapacity->BlockSize);
if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError) if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError)
return ErrorCode; return ErrorCode;
@ -495,7 +495,7 @@ uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{ {
.DataTransferLength = sizeof(SCSI_Request_Sense_Response_t), .DataTransferLength = CPU_TO_LE32(sizeof(SCSI_Request_Sense_Response_t)),
.Flags = MS_COMMAND_DIR_DATA_IN, .Flags = MS_COMMAND_DIR_DATA_IN,
.LUN = LUNIndex, .LUN = LUNIndex,
.SCSICommandLength = 6, .SCSICommandLength = 6,
@ -532,7 +532,7 @@ uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* const MSInter
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{ {
.DataTransferLength = 0, .DataTransferLength = CPU_TO_LE32(0),
.Flags = MS_COMMAND_DIR_DATA_OUT, .Flags = MS_COMMAND_DIR_DATA_OUT,
.LUN = LUNIndex, .LUN = LUNIndex,
.SCSICommandLength = 6, .SCSICommandLength = 6,
@ -572,7 +572,7 @@ uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{ {
.DataTransferLength = ((uint32_t)Blocks * BlockSize), .DataTransferLength = cpu_to_le32((uint32_t)Blocks * BlockSize),
.Flags = MS_COMMAND_DIR_DATA_IN, .Flags = MS_COMMAND_DIR_DATA_IN,
.LUN = LUNIndex, .LUN = LUNIndex,
.SCSICommandLength = 10, .SCSICommandLength = 10,
@ -616,7 +616,7 @@ uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo
MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t)
{ {
.DataTransferLength = ((uint32_t)Blocks * BlockSize), .DataTransferLength = cpu_to_le32((uint32_t)Blocks * BlockSize),
.Flags = MS_COMMAND_DIR_DATA_OUT, .Flags = MS_COMMAND_DIR_DATA_OUT,
.LUN = LUNIndex, .LUN = LUNIndex,
.SCSICommandLength = 10, .SCSICommandLength = 10,

@ -88,7 +88,7 @@ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI
if (PipeNum == PRNTInterfaceInfo->Config.DataINPipeNumber) if (PipeNum == PRNTInterfaceInfo->Config.DataINPipeNumber)
{ {
Size = DataINEndpoint->EndpointSize; Size = le16_to_cpu(DataINEndpoint->EndpointSize);
EndpointAddress = DataINEndpoint->EndpointAddress; EndpointAddress = DataINEndpoint->EndpointAddress;
Token = PIPE_TOKEN_IN; Token = PIPE_TOKEN_IN;
Type = EP_TYPE_BULK; Type = EP_TYPE_BULK;
@ -98,7 +98,7 @@ uint8_t PRNT_Host_ConfigurePipes(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceI
} }
else if (PipeNum == PRNTInterfaceInfo->Config.DataOUTPipeNumber) else if (PipeNum == PRNTInterfaceInfo->Config.DataOUTPipeNumber)
{ {
Size = DataOUTEndpoint->EndpointSize; Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);
EndpointAddress = DataOUTEndpoint->EndpointAddress; EndpointAddress = DataOUTEndpoint->EndpointAddress;
Token = PIPE_TOKEN_OUT; Token = PIPE_TOKEN_OUT;
Type = EP_TYPE_BULK; Type = EP_TYPE_BULK;
@ -204,7 +204,6 @@ uint8_t PRNT_Host_GetPortStatus(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceIn
}; };
Pipe_SelectPipe(PIPE_CONTROLPIPE); Pipe_SelectPipe(PIPE_CONTROLPIPE);
return USB_Host_SendControlRequest(PortStatus); return USB_Host_SendControlRequest(PortStatus);
} }
@ -220,7 +219,6 @@ uint8_t PRNT_Host_SoftReset(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo)
}; };
Pipe_SelectPipe(PIPE_CONTROLPIPE); Pipe_SelectPipe(PIPE_CONTROLPIPE);
return USB_Host_SendControlRequest(NULL); return USB_Host_SendControlRequest(NULL);
} }
@ -407,7 +405,7 @@ uint8_t PRNT_Host_GetDeviceID(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo
return HOST_SENDCONTROL_Successful; return HOST_SENDCONTROL_Successful;
} }
DeviceIDStringLength = SwapEndian_16(DeviceIDStringLength); DeviceIDStringLength = be16_to_cpu(DeviceIDStringLength);
if (DeviceIDStringLength > BufferSize) if (DeviceIDStringLength > BufferSize)
DeviceIDStringLength = BufferSize; DeviceIDStringLength = BufferSize;

@ -112,7 +112,7 @@ uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfa
if (PipeNum == RNDISInterfaceInfo->Config.DataINPipeNumber) if (PipeNum == RNDISInterfaceInfo->Config.DataINPipeNumber)
{ {
Size = DataINEndpoint->EndpointSize; Size = le16_to_cpu(DataINEndpoint->EndpointSize);
EndpointAddress = DataINEndpoint->EndpointAddress; EndpointAddress = DataINEndpoint->EndpointAddress;
Token = PIPE_TOKEN_IN; Token = PIPE_TOKEN_IN;
Type = EP_TYPE_BULK; Type = EP_TYPE_BULK;
@ -123,7 +123,7 @@ uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfa
} }
else if (PipeNum == RNDISInterfaceInfo->Config.DataOUTPipeNumber) else if (PipeNum == RNDISInterfaceInfo->Config.DataOUTPipeNumber)
{ {
Size = DataOUTEndpoint->EndpointSize; Size = le16_to_cpu(DataOUTEndpoint->EndpointSize);
EndpointAddress = DataOUTEndpoint->EndpointAddress; EndpointAddress = DataOUTEndpoint->EndpointAddress;
Token = PIPE_TOKEN_OUT; Token = PIPE_TOKEN_OUT;
Type = EP_TYPE_BULK; Type = EP_TYPE_BULK;
@ -134,7 +134,7 @@ uint8_t RNDIS_Host_ConfigurePipes(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfa
} }
else if (PipeNum == RNDISInterfaceInfo->Config.NotificationPipeNumber) else if (PipeNum == RNDISInterfaceInfo->Config.NotificationPipeNumber)
{ {
Size = NotificationEndpoint->EndpointSize; Size = le16_to_cpu(NotificationEndpoint->EndpointSize);
EndpointAddress = NotificationEndpoint->EndpointAddress; EndpointAddress = NotificationEndpoint->EndpointAddress;
Token = PIPE_TOKEN_IN; Token = PIPE_TOKEN_IN;
Type = EP_TYPE_INTERRUPT; Type = EP_TYPE_INTERRUPT;
@ -241,6 +241,7 @@ static uint8_t RNDIS_SendEncapsulatedCommand(USB_ClassInfo_RNDIS_Host_t* const R
}; };
Pipe_SelectPipe(PIPE_CONTROLPIPE); Pipe_SelectPipe(PIPE_CONTROLPIPE);
return USB_Host_SendControlRequest(Buffer); return USB_Host_SendControlRequest(Buffer);
} }
@ -258,6 +259,7 @@ static uint8_t RNDIS_GetEncapsulatedResponse(USB_ClassInfo_RNDIS_Host_t* const R
}; };
Pipe_SelectPipe(PIPE_CONTROLPIPE); Pipe_SelectPipe(PIPE_CONTROLPIPE);
return USB_Host_SendControlRequest(Buffer); return USB_Host_SendControlRequest(Buffer);
} }
@ -268,9 +270,9 @@ uint8_t RNDIS_Host_SendKeepAlive(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfac
RNDIS_KeepAlive_Message_t KeepAliveMessage; RNDIS_KeepAlive_Message_t KeepAliveMessage;
RNDIS_KeepAlive_Complete_t KeepAliveMessageResponse; RNDIS_KeepAlive_Complete_t KeepAliveMessageResponse;
KeepAliveMessage.MessageType = REMOTE_NDIS_KEEPALIVE_MSG; KeepAliveMessage.MessageType = CPU_TO_LE32(REMOTE_NDIS_KEEPALIVE_MSG);
KeepAliveMessage.MessageLength = sizeof(RNDIS_KeepAlive_Message_t); KeepAliveMessage.MessageLength = CPU_TO_LE32(sizeof(RNDIS_KeepAlive_Message_t));
KeepAliveMessage.RequestId = RNDISInterfaceInfo->State.RequestID++; KeepAliveMessage.RequestId = cpu_to_le32(RNDISInterfaceInfo->State.RequestID++);
if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &KeepAliveMessage, if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &KeepAliveMessage,
sizeof(RNDIS_KeepAlive_Message_t))) != HOST_SENDCONTROL_Successful) sizeof(RNDIS_KeepAlive_Message_t))) != HOST_SENDCONTROL_Successful)
@ -294,13 +296,13 @@ uint8_t RNDIS_Host_InitializeDevice(USB_ClassInfo_RNDIS_Host_t* const RNDISInter
RNDIS_Initialize_Message_t InitMessage; RNDIS_Initialize_Message_t InitMessage;
RNDIS_Initialize_Complete_t InitMessageResponse; RNDIS_Initialize_Complete_t InitMessageResponse;
InitMessage.MessageType = REMOTE_NDIS_INITIALIZE_MSG; InitMessage.MessageType = CPU_TO_LE32(REMOTE_NDIS_INITIALIZE_MSG);
InitMessage.MessageLength = sizeof(RNDIS_Initialize_Message_t); InitMessage.MessageLength = CPU_TO_LE32(sizeof(RNDIS_Initialize_Message_t));
InitMessage.RequestId = RNDISInterfaceInfo->State.RequestID++; InitMessage.RequestId = cpu_to_le32(RNDISInterfaceInfo->State.RequestID++);
InitMessage.MajorVersion = REMOTE_NDIS_VERSION_MAJOR; InitMessage.MajorVersion = CPU_TO_LE32(REMOTE_NDIS_VERSION_MAJOR);
InitMessage.MinorVersion = REMOTE_NDIS_VERSION_MINOR; InitMessage.MinorVersion = CPU_TO_LE32(REMOTE_NDIS_VERSION_MINOR);
InitMessage.MaxTransferSize = RNDISInterfaceInfo->Config.HostMaxPacketSize; InitMessage.MaxTransferSize = cpu_to_le32(RNDISInterfaceInfo->Config.HostMaxPacketSize);
if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &InitMessage, if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &InitMessage,
sizeof(RNDIS_Initialize_Message_t))) != HOST_SENDCONTROL_Successful) sizeof(RNDIS_Initialize_Message_t))) != HOST_SENDCONTROL_Successful)
@ -314,10 +316,10 @@ uint8_t RNDIS_Host_InitializeDevice(USB_ClassInfo_RNDIS_Host_t* const RNDISInter
return ErrorCode; return ErrorCode;
} }
if (InitMessageResponse.Status != REMOTE_NDIS_STATUS_SUCCESS) if (InitMessageResponse.Status != CPU_TO_LE32(REMOTE_NDIS_STATUS_SUCCESS))
return RNDIS_ERROR_LOGICAL_CMD_FAILED; return RNDIS_ERROR_LOGICAL_CMD_FAILED;
RNDISInterfaceInfo->State.DeviceMaxPacketSize = InitMessageResponse.MaxTransferSize; RNDISInterfaceInfo->State.DeviceMaxPacketSize = le32_to_cpu(InitMessageResponse.MaxTransferSize);
return HOST_SENDCONTROL_Successful; return HOST_SENDCONTROL_Successful;
} }
@ -337,14 +339,14 @@ uint8_t RNDIS_Host_SetRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInter
RNDIS_Set_Complete_t SetMessageResponse; RNDIS_Set_Complete_t SetMessageResponse;
SetMessageData.SetMessage.MessageType = REMOTE_NDIS_SET_MSG; SetMessageData.SetMessage.MessageType = CPU_TO_LE32(REMOTE_NDIS_SET_MSG);
SetMessageData.SetMessage.MessageLength = sizeof(RNDIS_Set_Message_t) + Length; SetMessageData.SetMessage.MessageLength = cpu_to_le32(sizeof(RNDIS_Set_Message_t) + Length);
SetMessageData.SetMessage.RequestId = RNDISInterfaceInfo->State.RequestID++; SetMessageData.SetMessage.RequestId = cpu_to_le32(RNDISInterfaceInfo->State.RequestID++);
SetMessageData.SetMessage.Oid = Oid; SetMessageData.SetMessage.Oid = cpu_to_le32(Oid);
SetMessageData.SetMessage.InformationBufferLength = Length; SetMessageData.SetMessage.InformationBufferLength = cpu_to_le32(Length);
SetMessageData.SetMessage.InformationBufferOffset = (sizeof(RNDIS_Set_Message_t) - sizeof(RNDIS_Message_Header_t)); SetMessageData.SetMessage.InformationBufferOffset = CPU_TO_LE32(sizeof(RNDIS_Set_Message_t) - sizeof(RNDIS_Message_Header_t));
SetMessageData.SetMessage.DeviceVcHandle = 0; SetMessageData.SetMessage.DeviceVcHandle = CPU_TO_LE32(0);
memcpy(&SetMessageData.ContiguousBuffer, Buffer, Length); memcpy(&SetMessageData.ContiguousBuffer, Buffer, Length);
@ -360,7 +362,7 @@ uint8_t RNDIS_Host_SetRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInter
return ErrorCode; return ErrorCode;
} }
if (SetMessageResponse.Status != REMOTE_NDIS_STATUS_SUCCESS) if (SetMessageResponse.Status != CPU_TO_LE32(REMOTE_NDIS_STATUS_SUCCESS))
return RNDIS_ERROR_LOGICAL_CMD_FAILED; return RNDIS_ERROR_LOGICAL_CMD_FAILED;
return HOST_SENDCONTROL_Successful; return HOST_SENDCONTROL_Successful;
@ -381,14 +383,14 @@ uint8_t RNDIS_Host_QueryRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInt
uint8_t ContiguousBuffer[MaxLength]; uint8_t ContiguousBuffer[MaxLength];
} QueryMessageResponseData; } QueryMessageResponseData;
QueryMessage.MessageType = REMOTE_NDIS_QUERY_MSG; QueryMessage.MessageType = CPU_TO_LE32(REMOTE_NDIS_QUERY_MSG);
QueryMessage.MessageLength = sizeof(RNDIS_Query_Message_t); QueryMessage.MessageLength = CPU_TO_LE32(sizeof(RNDIS_Query_Message_t));
QueryMessage.RequestId = RNDISInterfaceInfo->State.RequestID++; QueryMessage.RequestId = cpu_to_le32(RNDISInterfaceInfo->State.RequestID++);
QueryMessage.Oid = Oid; QueryMessage.Oid = cpu_to_le32(Oid);
QueryMessage.InformationBufferLength = 0; QueryMessage.InformationBufferLength = CPU_TO_LE32(0);
QueryMessage.InformationBufferOffset = 0; QueryMessage.InformationBufferOffset = CPU_TO_LE32(0);
QueryMessage.DeviceVcHandle = 0; QueryMessage.DeviceVcHandle = CPU_TO_LE32(0);
if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &QueryMessage, if ((ErrorCode = RNDIS_SendEncapsulatedCommand(RNDISInterfaceInfo, &QueryMessage,
sizeof(RNDIS_Query_Message_t))) != HOST_SENDCONTROL_Successful) sizeof(RNDIS_Query_Message_t))) != HOST_SENDCONTROL_Successful)
@ -402,7 +404,7 @@ uint8_t RNDIS_Host_QueryRNDISProperty(USB_ClassInfo_RNDIS_Host_t* const RNDISInt
return ErrorCode; return ErrorCode;
} }
if (QueryMessageResponseData.QueryMessageResponse.Status != REMOTE_NDIS_STATUS_SUCCESS) if (QueryMessageResponseData.QueryMessageResponse.Status != CPU_TO_LE32(REMOTE_NDIS_STATUS_SUCCESS))
return RNDIS_ERROR_LOGICAL_CMD_FAILED; return RNDIS_ERROR_LOGICAL_CMD_FAILED;
memcpy(Buffer, &QueryMessageResponseData.ContiguousBuffer, MaxLength); memcpy(Buffer, &QueryMessageResponseData.ContiguousBuffer, MaxLength);
@ -456,7 +458,7 @@ uint8_t RNDIS_Host_ReadPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn
return ErrorCode; return ErrorCode;
} }
*PacketLength = (uint16_t)DeviceMessage.DataLength; *PacketLength = (uint16_t)le32_to_cpu(DeviceMessage.DataLength);
Pipe_Discard_Stream(DeviceMessage.DataOffset - Pipe_Discard_Stream(DeviceMessage.DataOffset -
(sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t)), (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t)),
@ -484,10 +486,10 @@ uint8_t RNDIS_Host_SendPacket(USB_ClassInfo_RNDIS_Host_t* const RNDISInterfaceIn
RNDIS_Packet_Message_t DeviceMessage; RNDIS_Packet_Message_t DeviceMessage;
memset(&DeviceMessage, 0, sizeof(RNDIS_Packet_Message_t)); memset(&DeviceMessage, 0, sizeof(RNDIS_Packet_Message_t));
DeviceMessage.MessageType = REMOTE_NDIS_PACKET_MSG; DeviceMessage.MessageType = CPU_TO_LE32(REMOTE_NDIS_PACKET_MSG);
DeviceMessage.MessageLength = (sizeof(RNDIS_Packet_Message_t) + PacketLength); DeviceMessage.MessageLength = CPU_TO_LE32(sizeof(RNDIS_Packet_Message_t) + PacketLength);
DeviceMessage.DataOffset = (sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t)); DeviceMessage.DataOffset = CPU_TO_LE32(sizeof(RNDIS_Packet_Message_t) - sizeof(RNDIS_Message_Header_t));
DeviceMessage.DataLength = PacketLength; DeviceMessage.DataLength = cpu_to_le32(PacketLength);
Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataOUTPipeNumber); Pipe_SelectPipe(RNDISInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze(); Pipe_Unfreeze();

@ -202,7 +202,7 @@ uint8_t SI_Host_SendBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
return PIPE_RWSTREAM_DeviceDisconnected; return PIPE_RWSTREAM_DeviceDisconnected;
if (SIInterfaceInfo->State.IsSessionOpen) if (SIInterfaceInfo->State.IsSessionOpen)
PIMAHeader->TransactionID = SIInterfaceInfo->State.TransactionID++; PIMAHeader->TransactionID = cpu_to_le32(SIInterfaceInfo->State.TransactionID++);
Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipeNumber); Pipe_SelectPipe(SIInterfaceInfo->Config.DataOUTPipeNumber);
Pipe_Unfreeze(); Pipe_Unfreeze();
@ -274,7 +274,7 @@ uint8_t SI_Host_ReceiveBlockHeader(USB_ClassInfo_SI_Host_t* const SIInterfaceInf
Pipe_Read_Stream_LE(PIMAHeader, PIMA_COMMAND_SIZE(0), NULL); Pipe_Read_Stream_LE(PIMAHeader, PIMA_COMMAND_SIZE(0), NULL);
if (PIMAHeader->Type == PIMA_CONTAINER_ResponseBlock) if (PIMAHeader->Type == CPU_TO_LE16(PIMA_CONTAINER_ResponseBlock))
{ {
uint8_t ParamBytes = (PIMAHeader->DataLength - PIMA_COMMAND_SIZE(0)); uint8_t ParamBytes = (PIMAHeader->DataLength - PIMA_COMMAND_SIZE(0));
@ -377,10 +377,10 @@ uint8_t SI_Host_OpenSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
PIMA_Container_t PIMABlock = (PIMA_Container_t) PIMA_Container_t PIMABlock = (PIMA_Container_t)
{ {
.DataLength = PIMA_COMMAND_SIZE(1), .DataLength = CPU_TO_LE32(PIMA_COMMAND_SIZE(1)),
.Type = PIMA_CONTAINER_CommandBlock, .Type = CPU_TO_LE16(PIMA_CONTAINER_CommandBlock),
.Code = 0x1002, .Code = CPU_TO_LE16(0x1002),
.Params = {1}, .Params = {CPU_TO_LE32(1)},
}; };
if ((ErrorCode = SI_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError) if ((ErrorCode = SI_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
@ -389,7 +389,7 @@ uint8_t SI_Host_OpenSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
if ((ErrorCode = SI_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError) if ((ErrorCode = SI_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
return ErrorCode; return ErrorCode;
if ((PIMABlock.Type != PIMA_CONTAINER_ResponseBlock) || (PIMABlock.Code != 0x2001)) if ((PIMABlock.Type != CPU_TO_LE16(PIMA_CONTAINER_ResponseBlock)) || (PIMABlock.Code != CPU_TO_LE16(0x2001)))
return SI_ERROR_LOGICAL_CMD_FAILED; return SI_ERROR_LOGICAL_CMD_FAILED;
SIInterfaceInfo->State.IsSessionOpen = true; SIInterfaceInfo->State.IsSessionOpen = true;
@ -406,10 +406,10 @@ uint8_t SI_Host_CloseSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
PIMA_Container_t PIMABlock = (PIMA_Container_t) PIMA_Container_t PIMABlock = (PIMA_Container_t)
{ {
.DataLength = PIMA_COMMAND_SIZE(1), .DataLength = CPU_TO_LE32(PIMA_COMMAND_SIZE(1)),
.Type = PIMA_CONTAINER_CommandBlock, .Type = CPU_TO_LE16(PIMA_CONTAINER_CommandBlock),
.Code = 0x1003, .Code = CPU_TO_LE16(0x1003),
.Params = {1}, .Params = {CPU_TO_LE32(1)},
}; };
if ((ErrorCode = SI_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError) if ((ErrorCode = SI_Host_SendBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
@ -420,7 +420,7 @@ uint8_t SI_Host_CloseSession(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
SIInterfaceInfo->State.IsSessionOpen = false; SIInterfaceInfo->State.IsSessionOpen = false;
if ((PIMABlock.Type != PIMA_CONTAINER_ResponseBlock) || (PIMABlock.Code != 0x2001)) if ((PIMABlock.Type != CPU_TO_LE16(PIMA_CONTAINER_ResponseBlock)) || (PIMABlock.Code != CPU_TO_LE16(0x2001)))
return SI_ERROR_LOGICAL_CMD_FAILED; return SI_ERROR_LOGICAL_CMD_FAILED;
return PIPE_RWSTREAM_NoError; return PIPE_RWSTREAM_NoError;
@ -438,9 +438,9 @@ uint8_t SI_Host_SendCommand(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo,
PIMA_Container_t PIMABlock = (PIMA_Container_t) PIMA_Container_t PIMABlock = (PIMA_Container_t)
{ {
.DataLength = PIMA_COMMAND_SIZE(TotalParams), .DataLength = cpu_to_le32(PIMA_COMMAND_SIZE(TotalParams)),
.Type = PIMA_CONTAINER_CommandBlock, .Type = CPU_TO_LE16(PIMA_CONTAINER_CommandBlock),
.Code = Operation, .Code = cpu_to_le16(Operation),
}; };
memcpy(&PIMABlock.Params, Params, sizeof(uint32_t) * TotalParams); memcpy(&PIMABlock.Params, Params, sizeof(uint32_t) * TotalParams);
@ -462,7 +462,7 @@ uint8_t SI_Host_ReceiveResponse(USB_ClassInfo_SI_Host_t* const SIInterfaceInfo)
if ((ErrorCode = SI_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError) if ((ErrorCode = SI_Host_ReceiveBlockHeader(SIInterfaceInfo, &PIMABlock)) != PIPE_RWSTREAM_NoError)
return ErrorCode; return ErrorCode;
if ((PIMABlock.Type != PIMA_CONTAINER_ResponseBlock) || (PIMABlock.Code != 0x2001)) if ((PIMABlock.Type != CPU_TO_LE16(PIMA_CONTAINER_ResponseBlock)) || (PIMABlock.Code != CPU_TO_LE16(0x2001)))
return SI_ERROR_LOGICAL_CMD_FAILED; return SI_ERROR_LOGICAL_CMD_FAILED;
return PIPE_RWSTREAM_NoError; return PIPE_RWSTREAM_NoError;

Loading…
Cancel
Save