* Implemented _InsertEndpointForPipe
* usual clean up git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22938 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -172,7 +172,7 @@ OHCI::OHCI(pci_info *info, Stack *stack)
|
|||||||
fInterruptEndpoints[i] = _AllocateEndpoint();
|
fInterruptEndpoints[i] = _AllocateEndpoint();
|
||||||
if (!fInterruptEndpoints[i]) {
|
if (!fInterruptEndpoints[i]) {
|
||||||
TRACE_ERROR(("ohci_usb: cannot allocate memory for"
|
TRACE_ERROR(("ohci_usb: cannot allocate memory for"
|
||||||
" fInterruptEndpoints[%d] endpoint\n", i));
|
" fInterruptEndpoints[%ld] endpoint\n", i));
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
_FreeEndpoint(fInterruptEndpoints[i]);
|
_FreeEndpoint(fInterruptEndpoints[i]);
|
||||||
_FreeEndpoint(fDummyBulk);
|
_FreeEndpoint(fDummyBulk);
|
||||||
@@ -640,6 +640,7 @@ OHCI::_AllocateEndpoint()
|
|||||||
TRACE_ERROR(("usb_ohci: failed to allocate endpoint descriptor\n"));
|
TRACE_ERROR(("usb_ohci: failed to allocate endpoint descriptor\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
memset((void *)endpoint, 0, sizeof(ohci_endpoint_descriptor));
|
||||||
|
|
||||||
endpoint->physical_address = (addr_t)physicalAddress;
|
endpoint->physical_address = (addr_t)physicalAddress;
|
||||||
|
|
||||||
@@ -698,89 +699,100 @@ OHCI::_FreeGeneralDescriptor(ohci_general_descriptor *descriptor)
|
|||||||
status_t
|
status_t
|
||||||
OHCI::_InsertEndpointForPipe(Pipe *pipe)
|
OHCI::_InsertEndpointForPipe(Pipe *pipe)
|
||||||
{
|
{
|
||||||
#if 0
|
TRACE(("OHCI: Inserting Endpoint for device %u function %u\n",
|
||||||
TRACE(("OHCI: Inserting Endpoint for device %u function %u\n", p->DeviceAddress(), p->EndpointAddress()));
|
pipe->DeviceAddress(), pipe->EndpointAddress()));
|
||||||
|
|
||||||
ohci_endpoint_descriptor *endpoint = _AllocateEndpoint();
|
ohci_endpoint_descriptor *endpoint = _AllocateEndpoint();
|
||||||
if (!endpoint) {
|
if (!endpoint) {
|
||||||
TRACE_ERROR(("usb_ohci: cannot allocate memory for endpoint\n"));
|
TRACE_ERROR(("usb_ohci: cannot allocate memory for endpoint\n"));
|
||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
}
|
}
|
||||||
endpoint->flags |= OHCI_ENDPOINT_SKIP;
|
|
||||||
|
|
||||||
// Set up properties of the endpoint
|
uint32 flags = 0;
|
||||||
endpoints->flags |= OHCI_ENDPOINT_SET_DEVICE_ADDRESS(pipe->DeviceAddress())
|
flags |= OHCI_ENDPOINT_SKIP;
|
||||||
|
|
||||||
|
// Set up flag field for the endpoint
|
||||||
|
flags |= OHCI_ENDPOINT_SET_DEVICE_ADDRESS(pipe->DeviceAddress())
|
||||||
| OHCI_ENDPOINT_SET_ENDPOINT_NUMBER(pipe->EndpointAddress());
|
| OHCI_ENDPOINT_SET_ENDPOINT_NUMBER(pipe->EndpointAddress());
|
||||||
|
|
||||||
// Set the direction
|
// Set the direction
|
||||||
switch (pipe->Direction()) {
|
switch (pipe->Direction()) {
|
||||||
case Pipe::In:
|
case Pipe::In:
|
||||||
properties |= OHCI_ENDPOINT_DIRECTION_IN;
|
flags |= OHCI_ENDPOINT_DIRECTION_IN;
|
||||||
break;
|
break;
|
||||||
case Pipe::Out:
|
case Pipe::Out:
|
||||||
properties |= OHCI_ENDPOINT_DIRECTION_OUT;
|
flags |= OHCI_ENDPOINT_DIRECTION_OUT;
|
||||||
break;
|
break;
|
||||||
case Pipe::Default:
|
case Pipe::Default:
|
||||||
properties |= OHCI_ENDPOINT_DIRECTION_DESCRIPTOR;
|
flags |= OHCI_ENDPOINT_DIRECTION_DESCRIPTOR;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//TODO: error
|
TRACE_ERROR(("usb_ohci: direction unknown. Wrong value!\n"));
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Set the speed
|
|
||||||
switch (p->Speed()) {
|
|
||||||
case USB_SPEED_LOWSPEED:
|
|
||||||
//the bit is 0
|
|
||||||
break;
|
|
||||||
case USB_SPEED_FULLSPEED:
|
|
||||||
properties |= OHCI_ENDPOINT_SPEED;
|
|
||||||
break;
|
|
||||||
case USB_SPEED_HIGHSPEED:
|
|
||||||
default:
|
|
||||||
//TODO: error
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Assign the format. Isochronous endpoints require this switch
|
|
||||||
if (p->Type() & USB_OBJECT_ISO_PIPE)
|
|
||||||
properties |= OHCI_ENDPOINT_ISOCHRONOUS_FORMAT;
|
|
||||||
|
|
||||||
//Set the maximum packet size
|
|
||||||
properties |= OHCI_ENDPOINT_SET_MAX_PACKET_SIZE(p->MaxPacketSize());
|
|
||||||
|
|
||||||
endpoint->ed->flags = properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Check which list we need to add the endpoint in
|
|
||||||
Endpoint *listhead;
|
|
||||||
if (p->Type() & USB_OBJECT_CONTROL_PIPE)
|
|
||||||
listhead = fDummyControl;
|
|
||||||
else if (p->Type() & USB_OBJECT_BULK_PIPE)
|
|
||||||
listhead = fDummyBulk;
|
|
||||||
else if (p->Type() & USB_OBJECT_ISO_PIPE)
|
|
||||||
listhead = fDummyIsochronous;
|
|
||||||
else {
|
|
||||||
_FreeEndpoint(endpoint);
|
_FreeEndpoint(endpoint);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add the endpoint to the queues
|
// Set up the speed
|
||||||
if ((p->Type() & USB_OBJECT_ISO_PIPE) == 0) {
|
switch (pipe->Speed()) {
|
||||||
//Link the endpoint into the head of the list
|
case USB_SPEED_LOWSPEED:
|
||||||
endpoint->SetNext(listhead->next);
|
flags |= OHCI_ENDPOINT_LOW_SPEED;
|
||||||
listhead->SetNext(endpoint);
|
break;
|
||||||
} else {
|
case USB_SPEED_FULLSPEED:
|
||||||
//Link the endpoint into the tail of the list
|
flags |= OHCI_ENDPOINT_FULL_SPEED;
|
||||||
Endpoint *tail = listhead;
|
break;
|
||||||
while (tail->next != 0)
|
case USB_SPEED_HIGHSPEED:
|
||||||
tail = tail->next;
|
default:
|
||||||
tail->SetNext(endpoint);
|
TRACE_ERROR(("usb_ohci: unaccetable speed. Wrong value!\n"));
|
||||||
|
_FreeEndpoint(endpoint);
|
||||||
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
// Set the maximum packet size
|
||||||
|
flags |= OHCI_ENDPOINT_SET_MAX_PACKET_SIZE(pipe->MaxPacketSize());
|
||||||
|
|
||||||
|
endpoint->flags = flags;
|
||||||
|
|
||||||
|
// Add the endpoint to the appropriate list
|
||||||
|
ohci_endpoint_descriptor *head = NULL;
|
||||||
|
switch (pipe->Type()) {
|
||||||
|
case USB_OBJECT_CONTROL_PIPE:
|
||||||
|
head = fDummyControl;
|
||||||
|
break;
|
||||||
|
case USB_OBJECT_BULK_PIPE:
|
||||||
|
head = fDummyBulk;
|
||||||
|
break;
|
||||||
|
case USB_OBJECT_ISO_PIPE:
|
||||||
|
// Set the isochronous bit format
|
||||||
|
endpoint->flags = OHCI_ENDPOINT_ISOCHRONOUS_FORMAT;
|
||||||
|
head = fDummyIsochronous;
|
||||||
|
break;
|
||||||
|
case USB_OBJECT_INTERRUPT_PIPE:
|
||||||
|
head = _FindInterruptEndpoint((static_cast<InterruptPipe*>(pipe))->Interval());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
TRACE_ERROR(("usb_ohci: unknown type of pipe. Wrong value!\n"));
|
||||||
|
_FreeEndpoint(endpoint);
|
||||||
|
return B_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
Lock();
|
||||||
|
endpoint->next_logical_endpoint = head->next_logical_endpoint;
|
||||||
|
endpoint->next_physical_endpoint = head->next_physical_endpoint;
|
||||||
|
head->next_logical_endpoint = (void *)endpoint;
|
||||||
|
head->next_physical_endpoint = (uint32)endpoint->physical_address;
|
||||||
|
Unlock();
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ohci_endpoint_descriptor*
|
||||||
|
OHCI::_FindInterruptEndpoint(uint8 interval)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
OHCI::_RemoveEndpointForPipe(Pipe *pipe)
|
OHCI::_RemoveEndpointForPipe(Pipe *pipe)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ static int32 _FinishThread(void *data);
|
|||||||
status_t _RemoveEndpointForPipe(Pipe *pipe);
|
status_t _RemoveEndpointForPipe(Pipe *pipe);
|
||||||
status_t _CreateEndpoint(Pipe *pipe,
|
status_t _CreateEndpoint(Pipe *pipe,
|
||||||
bool isIsochronous);
|
bool isIsochronous);
|
||||||
|
ohci_endpoint_descriptor *_FindInterruptEndpoint(uint8 interval);
|
||||||
ohci_endpoint_descriptor *_AllocateEndpoint();
|
ohci_endpoint_descriptor *_AllocateEndpoint();
|
||||||
void _FreeEndpoint(
|
void _FreeEndpoint(
|
||||||
ohci_endpoint_descriptor *endpoint);
|
ohci_endpoint_descriptor *endpoint);
|
||||||
|
|||||||
@@ -316,7 +316,8 @@ typedef struct ohci_endpoint_descriptor
|
|||||||
#define OHCI_ENDPOINT_DIRECTION_DESCRIPTOR 0x00000000
|
#define OHCI_ENDPOINT_DIRECTION_DESCRIPTOR 0x00000000
|
||||||
#define OHCI_ENDPOINT_DIRECTION_OUT 0x00000800
|
#define OHCI_ENDPOINT_DIRECTION_OUT 0x00000800
|
||||||
#define OHCI_ENDPOINT_DIRECTION_IN 0x00001000
|
#define OHCI_ENDPOINT_DIRECTION_IN 0x00001000
|
||||||
#define OHCI_ENDPOINT_SPEED 0x00002000
|
#define OHCI_ENDPOINT_LOW_SPEED 0x00002000
|
||||||
|
#define OHCI_ENDPOINT_FULL_SPEED 0x00000000
|
||||||
#define OHCI_ENDPOINT_SKIP 0x00004000
|
#define OHCI_ENDPOINT_SKIP 0x00004000
|
||||||
#define OHCI_ENDPOINT_GENERAL_FORMAT 0x00000000
|
#define OHCI_ENDPOINT_GENERAL_FORMAT 0x00000000
|
||||||
#define OHCI_ENDPOINT_ISOCHRONOUS_FORMAT 0x00008000
|
#define OHCI_ENDPOINT_ISOCHRONOUS_FORMAT 0x00008000
|
||||||
|
|||||||
Reference in New Issue
Block a user