Make Control Endpoint stream transfers more reliable by adding in early aborts for unexpected new SETUP tokens, or unexpected status stage during control stream writes.

Fix corruption in Device RNDIS demos TCP stack when too many connections attempted simultaneously, freezing the device when a page was re-fetched before the first connection was closed.

Fix incorrect model compatibility information in the Host LowLevel demo overview text files.
This commit is contained in:
Dean Camera 2009-08-05 11:39:28 +00:00
parent a9d5e129b7
commit 4421782b7f
18 changed files with 71 additions and 65 deletions

View File

@ -381,19 +381,24 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, void* TCPHeaderInStart, void
case TCP_Connection_Listen:
if (TCPHeaderIN->Flags == TCP_FLAG_SYN)
{
/* SYN connection when closed starts a connection with a peer */
/* SYN connection starts a connection with a peer */
if (TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress,
TCPHeaderIN->SourcePort, TCP_Connection_SYNReceived))
{
TCPHeaderOUT->Flags = (TCP_FLAG_SYN | TCP_FLAG_ACK);
TCPHeaderOUT->Flags = (TCP_FLAG_SYN | TCP_FLAG_ACK);
PacketResponse = true;
TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort,
TCP_Connection_SYNReceived);
ConnectionInfo = TCP_GetConnectionInfo(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort);
ConnectionInfo->SequenceNumberIn = (SwapEndian_32(TCPHeaderIN->SequenceNumber) + 1);
ConnectionInfo->SequenceNumberOut = 0;
ConnectionInfo->Buffer.InUse = false;
}
else
{
TCPHeaderOUT->Flags = TCP_FLAG_RST;
}
ConnectionInfo = TCP_GetConnectionInfo(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort);
ConnectionInfo->SequenceNumberIn = (SwapEndian_32(TCPHeaderIN->SequenceNumber) + 1);
ConnectionInfo->SequenceNumberOut = 0;
ConnectionInfo->Buffer.InUse = false;
PacketResponse = true;
}
break;

View File

@ -49,7 +49,7 @@
#define MAX_OPEN_TCP_PORTS 1
/** Maximum number of TCP connections which can be sustained at the one time */
#define MAX_TCP_CONNECTIONS 1
#define MAX_TCP_CONNECTIONS 3
/** TCP window size, giving the maximum number of bytes which can be buffered at the one time */
#define TCP_WINDOW_SIZE 512

View File

@ -381,19 +381,24 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, void* TCPHeaderInStart, void
case TCP_Connection_Listen:
if (TCPHeaderIN->Flags == TCP_FLAG_SYN)
{
/* SYN connection when closed starts a connection with a peer */
/* SYN connection starts a connection with a peer */
if (TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress,
TCPHeaderIN->SourcePort, TCP_Connection_SYNReceived))
{
TCPHeaderOUT->Flags = (TCP_FLAG_SYN | TCP_FLAG_ACK);
TCPHeaderOUT->Flags = (TCP_FLAG_SYN | TCP_FLAG_ACK);
PacketResponse = true;
TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort,
TCP_Connection_SYNReceived);
ConnectionInfo = TCP_GetConnectionInfo(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort);
ConnectionInfo->SequenceNumberIn = (SwapEndian_32(TCPHeaderIN->SequenceNumber) + 1);
ConnectionInfo->SequenceNumberOut = 0;
ConnectionInfo->Buffer.InUse = false;
}
else
{
TCPHeaderOUT->Flags = TCP_FLAG_RST;
}
ConnectionInfo = TCP_GetConnectionInfo(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress, TCPHeaderIN->SourcePort);
ConnectionInfo->SequenceNumberIn = (SwapEndian_32(TCPHeaderIN->SequenceNumber) + 1);
ConnectionInfo->SequenceNumberOut = 0;
ConnectionInfo->Buffer.InUse = false;
PacketResponse = true;
}
break;

View File

@ -49,7 +49,7 @@
#define MAX_OPEN_TCP_PORTS 1
/** Maximum number of TCP connections which can be sustained at the one time */
#define MAX_TCP_CONNECTIONS 1
#define MAX_TCP_CONNECTIONS 3
/** TCP window size, giving the maximum number of bytes which can be buffered at the one time */
#define TCP_WINDOW_SIZE 512

View File

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

View File

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

View File

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

View File

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

View File

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

View File

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

View File

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

View File

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

View File

@ -11,7 +11,7 @@
* The following table indicates what microcontrollers are compatible with this demo.
*
* - AT90USB1287
* - AT90USB1286
* - AT90USB647
*
* \section SSec_Info USB Information:
*

File diff suppressed because one or more lines are too long

View File

@ -76,7 +76,7 @@ void Endpoint_ClearStatusStage(void)
if (USB_ControlRequest.bmRequestType & REQDIR_DEVICETOHOST)
{
while (!(Endpoint_IsOUTReceived()))
{
{
if (USB_DeviceState == DEVICE_STATE_Unattached)
return;
}

View File

@ -4,6 +4,12 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
while (Length)
{
if (Endpoint_IsSETUPReceived())
return ENDPOINT_RWCSTREAM_HostAborted;
if (USB_DeviceState == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
if (Endpoint_IsOUTReceived())
{
while (Length && Endpoint_BytesInEndpoint())
@ -13,10 +19,7 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
}
Endpoint_ClearOUT();
}
if (USB_DeviceState == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
}
}
while (!(Endpoint_IsINReady()))

View File

@ -6,36 +6,28 @@ uint8_t TEMPLATE_FUNC_NAME (void* Buffer, uint16_t Length)
if (Length > USB_ControlRequest.wLength)
Length = USB_ControlRequest.wLength;
while (Length && !(Endpoint_IsOUTReceived()))
while (Length || LastPacketFull)
{
while (!(Endpoint_IsINReady()))
{
if (USB_DeviceState == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
}
if (Endpoint_IsSETUPReceived())
return ENDPOINT_RWCSTREAM_HostAborted;
if (Endpoint_IsOUTReceived())
break;
while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
if (USB_DeviceState == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
if (Endpoint_IsINReady())
{
TEMPLATE_TRANSFER_BYTE(DataStream);
Length--;
while (Length && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
{
TEMPLATE_TRANSFER_BYTE(DataStream);
Length--;
}
LastPacketFull = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
Endpoint_ClearIN();
}
LastPacketFull = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
Endpoint_ClearIN();
}
if (Endpoint_IsOUTReceived())
return ENDPOINT_RWCSTREAM_HostAborted;
if (LastPacketFull)
{
while (!(Endpoint_IsINReady()))
{
if (USB_DeviceState == DEVICE_STATE_Unattached)
return ENDPOINT_RWCSTREAM_DeviceDisconnected;
}
Endpoint_ClearIN();
}
while (!(Endpoint_IsOUTReceived()))

View File

@ -85,6 +85,7 @@
* - Fixed report data alignment issues in the MouseHostWithParser demo when X and Y movement data size is not a multiple of 8 bits
* - Fixed HID Report Descriptor Parser not correctly resetting internal states when a REPORT ID element is encountered
* - Fixed incorrect BUTTONS_BUTTON1 for the STK526 target
* - Fixed RNDIS demos freezing when more than one connection was attempted simultaneously, causing memory corruption
*
*
* \section Sec_ChangeLog090605 Version 090605