* Unified and disabled TRACEing for the usb stack and uhci hcd
* Fixed warnings * Some cleanup * Added myself as an author to some files No functional changes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18614 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -10,14 +10,6 @@
|
||||
#include "usb_p.h"
|
||||
|
||||
|
||||
#define TRACE_BUSMANAGER
|
||||
#ifdef TRACE_BUSMANAGER
|
||||
#define TRACE(x) dprintf x
|
||||
#else
|
||||
#define TRACE(x) /* nothing */
|
||||
#endif
|
||||
|
||||
|
||||
BusManager::BusManager(Stack *stack)
|
||||
: fInitOK(false),
|
||||
fDefaultPipe(NULL),
|
||||
@@ -27,7 +19,7 @@ BusManager::BusManager(Stack *stack)
|
||||
fExploreThread(-1)
|
||||
{
|
||||
if (benaphore_init(&fLock, "usb busmanager lock") < B_OK) {
|
||||
TRACE(("usb BusManager: failed to create busmanager lock\n"));
|
||||
TRACE_ERROR(("usb BusManager: failed to create busmanager lock\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -106,7 +98,7 @@ BusManager::AllocateNewDevice(Device *parent, bool lowSpeed)
|
||||
// Check if there is a free entry in the device map (for the device number)
|
||||
int8 deviceAddress = AllocateAddress();
|
||||
if (deviceAddress < 0) {
|
||||
TRACE(("usb BusManager::AllocateNewDevice(): could not get a new address\n"));
|
||||
TRACE_ERROR(("usb BusManager::AllocateNewDevice(): could not get a new address\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -134,7 +126,7 @@ BusManager::AllocateNewDevice(Device *parent, bool lowSpeed)
|
||||
}
|
||||
|
||||
if (result < B_OK) {
|
||||
TRACE(("usb BusManager::AllocateNewDevice(): error while setting device address\n"));
|
||||
TRACE_ERROR(("usb BusManager::AllocateNewDevice(): error while setting device address\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -164,7 +156,7 @@ BusManager::AllocateNewDevice(Device *parent, bool lowSpeed)
|
||||
&actualLength); // actual length
|
||||
|
||||
if (actualLength != 8) {
|
||||
TRACE(("usb BusManager::AllocateNewDevice(): error while getting the device descriptor\n"));
|
||||
TRACE_ERROR(("usb BusManager::AllocateNewDevice(): error while getting the device descriptor\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -183,12 +175,12 @@ BusManager::AllocateNewDevice(Device *parent, bool lowSpeed)
|
||||
Hub *hub = new(std::nothrow) Hub(this, parent, deviceDescriptor,
|
||||
deviceAddress, lowSpeed);
|
||||
if (!hub) {
|
||||
TRACE(("usb BusManager::AllocateNewDevice(): no memory to allocate hub\n"));
|
||||
TRACE_ERROR(("usb BusManager::AllocateNewDevice(): no memory to allocate hub\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (hub->InitCheck() < B_OK) {
|
||||
TRACE(("usb BusManager::AllocateNewDevice(): hub failed init check\n"));
|
||||
TRACE_ERROR(("usb BusManager::AllocateNewDevice(): hub failed init check\n"));
|
||||
delete hub;
|
||||
return NULL;
|
||||
}
|
||||
@@ -205,12 +197,12 @@ BusManager::AllocateNewDevice(Device *parent, bool lowSpeed)
|
||||
Device *device = new(std::nothrow) Device(this, parent, deviceDescriptor,
|
||||
deviceAddress, lowSpeed);
|
||||
if (!device) {
|
||||
TRACE(("usb BusManager::AllocateNewDevice(): no memory to allocate device\n"));
|
||||
TRACE_ERROR(("usb BusManager::AllocateNewDevice(): no memory to allocate device\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (device->InitCheck() < B_OK) {
|
||||
TRACE(("usb BusManager::AllocateNewDevice(): device failed init check\n"));
|
||||
TRACE_ERROR(("usb BusManager::AllocateNewDevice(): device failed init check\n"));
|
||||
delete device;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -3,20 +3,13 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Michael Lotz <mmlr@mlotz.ch>
|
||||
* Niels S. Reedijk
|
||||
*/
|
||||
|
||||
#include "usb_p.h"
|
||||
|
||||
|
||||
#define TRACE_USB_DEVICE
|
||||
#ifdef TRACE_USB_DEVICE
|
||||
#define TRACE(x) dprintf x
|
||||
#else
|
||||
#define TRACE(x) /* nothing */
|
||||
#endif
|
||||
|
||||
|
||||
Device::Device(BusManager *bus, Device *parent, usb_device_descriptor &desc,
|
||||
int8 deviceAddress, bool lowSpeed)
|
||||
: ControlPipe(bus, deviceAddress,
|
||||
@@ -37,7 +30,7 @@ Device::Device(BusManager *bus, Device *parent, usb_device_descriptor &desc,
|
||||
|
||||
fLock = create_sem(1, "USB Device Lock");
|
||||
if (fLock < B_OK) {
|
||||
TRACE(("USB Device: could not create semaphore\n"));
|
||||
TRACE_ERROR(("USB Device: could not create locking semaphore\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -52,7 +45,7 @@ Device::Device(BusManager *bus, Device *parent, usb_device_descriptor &desc,
|
||||
(void *)&fDeviceDescriptor, sizeof(fDeviceDescriptor), &actualLength);
|
||||
|
||||
if (status < B_OK || actualLength != sizeof(fDeviceDescriptor)) {
|
||||
TRACE(("USB Device: error while getting the device descriptor\n"));
|
||||
TRACE_ERROR(("USB Device: error while getting the device descriptor\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -76,7 +69,7 @@ Device::Device(BusManager *bus, Device *parent, usb_device_descriptor &desc,
|
||||
fConfigurations = (usb_configuration_info *)malloc(
|
||||
fDeviceDescriptor.num_configurations * sizeof(usb_configuration_info));
|
||||
if (fConfigurations == NULL) {
|
||||
TRACE(("USB Device: out of memory during config creations!\n"));
|
||||
TRACE_ERROR(("USB Device: out of memory during config creations!\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -87,7 +80,7 @@ Device::Device(BusManager *bus, Device *parent, usb_device_descriptor &desc,
|
||||
&actualLength);
|
||||
|
||||
if (status < B_OK || actualLength != sizeof(usb_configuration_descriptor)) {
|
||||
TRACE(("USB Device %d: error fetching configuration %d\n", fDeviceAddress, i));
|
||||
TRACE_ERROR(("USB Device %d: error fetching configuration %ld\n", fDeviceAddress, i));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -106,7 +99,7 @@ Device::Device(BusManager *bus, Device *parent, usb_device_descriptor &desc,
|
||||
(void *)configData, configDescriptor.total_length, &actualLength);
|
||||
|
||||
if (status < B_OK || actualLength != configDescriptor.total_length) {
|
||||
TRACE(("USB Device %d: error fetching full configuration descriptor %d\n", fDeviceAddress, i));
|
||||
TRACE_ERROR(("USB Device %d: error fetching full configuration descriptor %ld\n", fDeviceAddress, i));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -253,7 +246,7 @@ Device::Device(BusManager *bus, Device *parent, usb_device_descriptor &desc,
|
||||
// Set default configuration
|
||||
TRACE(("USB Device %d: setting default configuration\n", fDeviceAddress));
|
||||
if (SetConfigurationAt(0) < B_OK) {
|
||||
TRACE(("USB Device %d: failed to set default configuration\n", fDeviceAddress));
|
||||
TRACE_ERROR(("USB Device %d: failed to set default configuration\n", fDeviceAddress));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,14 +11,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#define TRACE_HUB
|
||||
#ifdef TRACE_HUB
|
||||
#define TRACE(x) dprintf x
|
||||
#else
|
||||
#define TRACE(x) /* nothing */
|
||||
#endif
|
||||
|
||||
|
||||
Hub::Hub(BusManager *bus, Device *parent, usb_device_descriptor &desc,
|
||||
int8 deviceAddress, bool lowSpeed)
|
||||
: Device(bus, parent, desc, deviceAddress, lowSpeed)
|
||||
@@ -26,7 +18,7 @@ Hub::Hub(BusManager *bus, Device *parent, usb_device_descriptor &desc,
|
||||
TRACE(("USB Hub is being initialised\n"));
|
||||
|
||||
if (!fInitOK) {
|
||||
TRACE(("USB Hub: Device failed to initialize\n"));
|
||||
TRACE_ERROR(("USB Hub: Device failed to initialize\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -37,7 +29,7 @@ Hub::Hub(BusManager *bus, Device *parent, usb_device_descriptor &desc,
|
||||
fChildren[i] = NULL;
|
||||
|
||||
if (fDeviceDescriptor.device_class != 9) {
|
||||
TRACE(("USB Hub: wrong class! Bailing out\n"));
|
||||
TRACE_ERROR(("USB Hub: wrong class! Bailing out\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -48,7 +40,7 @@ Hub::Hub(BusManager *bus, Device *parent, usb_device_descriptor &desc,
|
||||
|
||||
// we need at least 8 bytes
|
||||
if (status < B_OK || actualLength < 8) {
|
||||
TRACE(("USB Hub: Error getting hub descriptor\n"));
|
||||
TRACE_ERROR(("USB Hub: Error getting hub descriptor\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,7 +55,7 @@ Hub::Hub(BusManager *bus, Device *parent, usb_device_descriptor &desc,
|
||||
|
||||
Object *object = GetStack()->GetObject(Configuration()->interface->active->endpoint[0].handle);
|
||||
if (!object || (object->Type() & USB_OBJECT_INTERRUPT_PIPE) == 0) {
|
||||
TRACE(("USB Hub: no interrupt pipe found\n"));
|
||||
TRACE_ERROR(("USB Hub: no interrupt pipe found\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -80,7 +72,7 @@ Hub::Hub(BusManager *bus, Device *parent, usb_device_descriptor &desc,
|
||||
USB_REQUEST_SET_FEATURE, PORT_POWER, i + 1, 0, NULL, 0, NULL);
|
||||
|
||||
if (status < B_OK)
|
||||
TRACE(("USB Hub: power up failed on port %d\n", i));
|
||||
TRACE_ERROR(("USB Hub: power up failed on port %ld\n", i));
|
||||
}
|
||||
|
||||
// Wait for power to stabilize
|
||||
@@ -101,7 +93,7 @@ Hub::UpdatePortStatus(uint8 index)
|
||||
4, &actualLength);
|
||||
|
||||
if (result < B_OK || actualLength < 4) {
|
||||
TRACE(("USB Hub: error updating port status\n"));
|
||||
TRACE_ERROR(("USB Hub: error updating port status\n"));
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -138,7 +130,7 @@ Hub::ResetPort(uint8 index)
|
||||
}
|
||||
|
||||
if ((fPortStatus[index].change & C_PORT_RESET) == 0) {
|
||||
TRACE(("USB Hub: port %d won't reset\n", index));
|
||||
TRACE_ERROR(("USB Hub: port %d won't reset\n", index));
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -282,7 +274,7 @@ Hub::BuildDeviceName(char *string, uint32 *index, size_t bufferSize,
|
||||
if (result < B_OK) {
|
||||
// recursion to parent failed, we're at the root(hub)
|
||||
int32 managerIndex = GetStack()->IndexOfBusManager(Manager());
|
||||
*index += snprintf(string + *index, bufferSize - *index, "%d", managerIndex);
|
||||
*index += snprintf(string + *index, bufferSize - *index, "%ld", managerIndex);
|
||||
}
|
||||
|
||||
if (!device) {
|
||||
@@ -292,7 +284,7 @@ Hub::BuildDeviceName(char *string, uint32 *index, size_t bufferSize,
|
||||
// find out where the requested device sitts
|
||||
for (int32 i = 0; i < fHubDescriptor.num_ports; i++) {
|
||||
if (fChildren[i] == device) {
|
||||
*index += snprintf(string + *index, bufferSize - *index, "/%d", i);
|
||||
*index += snprintf(string + *index, bufferSize - *index, "/%ld", i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2004-2006, Haiku Inc. All rights reserved.
|
||||
* Copyright 2006, Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/*
|
||||
* Copyright 2006, Haiku Inc. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Michael Lotz <mmlr@mlotz.ch>
|
||||
*/
|
||||
|
||||
#include "usb_p.h"
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
|
||||
Pipe::Pipe(Device *device, pipeDirection direction, pipeSpeed speed,
|
||||
uint8 endpointAddress, uint32 maxPacketSize)
|
||||
uint8 endpointAddress, size_t maxPacketSize)
|
||||
: Object(device->Manager()),
|
||||
fDevice(device),
|
||||
fDeviceAddress(device->Address()),
|
||||
@@ -26,7 +26,7 @@ Pipe::Pipe(Device *device, pipeDirection direction, pipeSpeed speed,
|
||||
|
||||
|
||||
Pipe::Pipe(BusManager *bus, int8 deviceAddress, pipeSpeed speed,
|
||||
uint32 maxPacketSize)
|
||||
size_t maxPacketSize)
|
||||
: Object(bus),
|
||||
fDevice(NULL),
|
||||
fDeviceAddress(deviceAddress),
|
||||
@@ -130,7 +130,7 @@ Pipe::GetStatus(uint16 *status)
|
||||
|
||||
|
||||
InterruptPipe::InterruptPipe(Device *device, pipeDirection direction,
|
||||
pipeSpeed speed, uint8 endpointAddress, uint32 maxPacketSize)
|
||||
pipeSpeed speed, uint8 endpointAddress, size_t maxPacketSize)
|
||||
: Pipe(device, direction, speed, endpointAddress, maxPacketSize)
|
||||
{
|
||||
}
|
||||
@@ -160,7 +160,7 @@ InterruptPipe::QueueInterrupt(void *data, size_t dataLength,
|
||||
|
||||
|
||||
BulkPipe::BulkPipe(Device *device, pipeDirection direction,
|
||||
pipeSpeed speed, uint8 endpointAddress, uint32 maxPacketSize)
|
||||
pipeSpeed speed, uint8 endpointAddress, size_t maxPacketSize)
|
||||
: Pipe(device, direction, speed, endpointAddress, maxPacketSize)
|
||||
{
|
||||
}
|
||||
@@ -208,7 +208,7 @@ BulkPipe::QueueBulkV(iovec *vector, size_t vectorCount,
|
||||
|
||||
|
||||
IsochronousPipe::IsochronousPipe(Device *device, pipeDirection direction,
|
||||
pipeSpeed speed, uint8 endpointAddress, uint32 maxPacketSize)
|
||||
pipeSpeed speed, uint8 endpointAddress, size_t maxPacketSize)
|
||||
: Pipe(device, direction, speed, endpointAddress, maxPacketSize)
|
||||
{
|
||||
}
|
||||
@@ -236,14 +236,14 @@ struct transfer_result_data {
|
||||
|
||||
|
||||
ControlPipe::ControlPipe(Device *device, pipeSpeed speed,
|
||||
uint8 endpointAddress, uint32 maxPacketSize)
|
||||
uint8 endpointAddress, size_t maxPacketSize)
|
||||
: Pipe(device, Pipe::Default, speed, endpointAddress, maxPacketSize)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ControlPipe::ControlPipe(BusManager *bus, int8 deviceAddress, pipeSpeed speed,
|
||||
uint32 maxPacketSize)
|
||||
size_t maxPacketSize)
|
||||
: Pipe(bus, deviceAddress, speed, maxPacketSize)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Michael Lotz <mmlr@mlotz.ch>
|
||||
* Niels S. Reedijk
|
||||
*/
|
||||
|
||||
@@ -11,14 +12,6 @@
|
||||
#include "usb_p.h"
|
||||
|
||||
|
||||
#define TRACE_STACK
|
||||
#ifdef TRACE_STACK
|
||||
#define TRACE(x) dprintf x
|
||||
#else
|
||||
#define TRACE(x) /* nothing */
|
||||
#endif
|
||||
|
||||
|
||||
Stack::Stack()
|
||||
: fObjectIndex(1),
|
||||
fObjectMaxCount(1024),
|
||||
@@ -28,7 +21,7 @@ Stack::Stack()
|
||||
TRACE(("usb stack: stack init\n"));
|
||||
|
||||
if (benaphore_init(&fLock, "USB Stack Master Lock") < B_OK) {
|
||||
TRACE(("usb stack: failed to create benaphore lock\n"));
|
||||
TRACE_ERROR(("usb stack: failed to create benaphore lock\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -48,7 +41,7 @@ Stack::Stack()
|
||||
"8-byte chunk area");
|
||||
|
||||
if (fAreas[0] < B_OK) {
|
||||
TRACE(("usb stack: 8-byte chunk area failed to initialise\n"));
|
||||
TRACE_ERROR(("usb stack: 8-byte chunk area failed to initialise\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -60,7 +53,7 @@ Stack::Stack()
|
||||
if (i < B_PAGE_SIZE / 8 - 1)
|
||||
chunk->next_item = (addr_t)fLogical[0] + 8 * (i + 1);
|
||||
else
|
||||
chunk->next_item = NULL;
|
||||
chunk->next_item = 0;
|
||||
}
|
||||
|
||||
// 16-byte heap
|
||||
@@ -69,7 +62,7 @@ Stack::Stack()
|
||||
"16-byte chunk area");
|
||||
|
||||
if (fAreas[1] < B_OK) {
|
||||
TRACE(("usb stack: 16-byte chunk area failed to initialise\n"));
|
||||
TRACE_ERROR(("usb stack: 16-byte chunk area failed to initialise\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,7 +74,7 @@ Stack::Stack()
|
||||
if (i < B_PAGE_SIZE / 16 - 1)
|
||||
chunk->next_item = (addr_t)fLogical[1] + 16 * (i + 1);
|
||||
else
|
||||
chunk->next_item = NULL;
|
||||
chunk->next_item = 0;
|
||||
}
|
||||
|
||||
// 32-byte heap
|
||||
@@ -90,7 +83,7 @@ Stack::Stack()
|
||||
"32-byte chunk area");
|
||||
|
||||
if (fAreas[2] < B_OK) {
|
||||
TRACE(("usb stack: 32-byte chunk area failed to initialise\n"));
|
||||
TRACE_ERROR(("usb stack: 32-byte chunk area failed to initialise\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -102,7 +95,7 @@ Stack::Stack()
|
||||
if (i < B_PAGE_SIZE / 32 - 1)
|
||||
chunk->next_item = (addr_t)fLogical[2] + 32 * (i + 1);
|
||||
else
|
||||
chunk->next_item = NULL;
|
||||
chunk->next_item = 0;
|
||||
}
|
||||
|
||||
// 64-byte heap
|
||||
@@ -111,7 +104,7 @@ Stack::Stack()
|
||||
"64-byte chunk area");
|
||||
|
||||
if (fAreas[3] < B_OK) {
|
||||
TRACE(("usb stack: 64-byte chunk area failed to initialise\n"));
|
||||
TRACE_ERROR(("usb stack: 64-byte chunk area failed to initialise\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -123,7 +116,7 @@ Stack::Stack()
|
||||
if (i < B_PAGE_SIZE / 64 - 1)
|
||||
chunk->next_item = (addr_t)fLogical[3] + 64 * (i + 1);
|
||||
else
|
||||
chunk->next_item = NULL;
|
||||
chunk->next_item = 0;
|
||||
}
|
||||
|
||||
// Check for host controller modules
|
||||
@@ -218,7 +211,7 @@ Stack::PutUSBID(usb_id id)
|
||||
return;
|
||||
|
||||
if (id >= fObjectMaxCount) {
|
||||
TRACE(("usb stack: tried to put invalid usb_id!\n"));
|
||||
TRACE_ERROR(("usb stack: tried to put invalid usb_id!\n"));
|
||||
Unlock();
|
||||
return;
|
||||
}
|
||||
@@ -235,7 +228,7 @@ Stack::GetObject(usb_id id)
|
||||
return NULL;
|
||||
|
||||
if (id >= fObjectMaxCount) {
|
||||
TRACE(("usb stack: tried to get object with invalid id\n"));
|
||||
TRACE_ERROR(("usb stack: tried to get object with invalid id\n"));
|
||||
Unlock();
|
||||
return NULL;
|
||||
}
|
||||
@@ -276,24 +269,24 @@ Stack::AllocateChunk(void **logicalAddress, void **physicalAddress, uint8 size)
|
||||
else if (size <= 64)
|
||||
listhead = fListhead64;
|
||||
else {
|
||||
TRACE(("usb stack: Chunk size %d to big\n", size));
|
||||
TRACE_ERROR(("usb stack: Chunk size %d to big\n", size));
|
||||
Unlock();
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
if (listhead == NULL) {
|
||||
TRACE(("usb stack: Out of memory on this list\n"));
|
||||
if (listhead == 0) {
|
||||
TRACE_ERROR(("usb stack: Out of memory on this list\n"));
|
||||
Unlock();
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
//TRACE(("usb stack: Stack::Allocate() listhead: 0x%08x\n", listhead));
|
||||
TRACE(("usb stack: Stack::Allocate() listhead: 0x%08x\n", listhead));
|
||||
memory_chunk *chunk = (memory_chunk *)listhead;
|
||||
*logicalAddress = (void *)listhead;
|
||||
*physicalAddress = (void *)chunk->physical;
|
||||
if (chunk->next_item == NULL) {
|
||||
if (chunk->next_item == 0) {
|
||||
//TODO: allocate more memory
|
||||
listhead = NULL;
|
||||
listhead = 0;
|
||||
} else {
|
||||
listhead = chunk->next_item;
|
||||
}
|
||||
@@ -309,7 +302,7 @@ Stack::AllocateChunk(void **logicalAddress, void **physicalAddress, uint8 size)
|
||||
fListhead64 = listhead;
|
||||
|
||||
Unlock();
|
||||
//TRACE(("usb stack: allocated a new chunk with size %u\n", size));
|
||||
TRACE(("usb stack: allocated a new chunk with size %u\n", size));
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -329,7 +322,7 @@ Stack::FreeChunk(void *logicalAddress, void *physicalAddress, uint8 size)
|
||||
else if (size <= 64)
|
||||
listhead = fListhead64;
|
||||
else {
|
||||
TRACE(("usb stack: Chunk size %d invalid\n", size));
|
||||
TRACE_ERROR(("usb stack: Chunk size %d invalid\n", size));
|
||||
Unlock();
|
||||
return B_ERROR;
|
||||
}
|
||||
@@ -364,7 +357,7 @@ Stack::AllocateArea(void **logicalAddress, void **physicalAddress, size_t size,
|
||||
B_FULL_LOCK | B_CONTIGUOUS, 0);
|
||||
|
||||
if (area < B_OK) {
|
||||
TRACE(("usb stack: couldn't allocate area %s\n", name));
|
||||
TRACE_ERROR(("usb stack: couldn't allocate area %s\n", name));
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -372,7 +365,7 @@ Stack::AllocateArea(void **logicalAddress, void **physicalAddress, size_t size,
|
||||
status_t result = get_memory_map(logAddress, size, &physicalEntry, 1);
|
||||
if (result < B_OK) {
|
||||
delete_area(area);
|
||||
TRACE(("usb stack: couldn't map area %s\n", name));
|
||||
TRACE_ERROR(("usb stack: couldn't map area %s\n", name));
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Michael Lotz <mmlr@mlotz.ch>
|
||||
* Niels S. Reedijk
|
||||
*/
|
||||
|
||||
@@ -58,7 +59,7 @@ size_t
|
||||
Transfer::VectorLength()
|
||||
{
|
||||
size_t length = 0;
|
||||
for (int32 i = 0; i < fVectorCount; i++)
|
||||
for (size_t i = 0; i < fVectorCount; i++)
|
||||
length += fVector[i].iov_len;
|
||||
return length;
|
||||
}
|
||||
|
||||
@@ -11,14 +11,6 @@
|
||||
#include "usb_p.h"
|
||||
|
||||
|
||||
#define TRACE_USB
|
||||
#ifdef TRACE_USB
|
||||
#define TRACE(x) dprintf x
|
||||
#else
|
||||
#define TRACE(x) /* nothing */
|
||||
#endif
|
||||
|
||||
|
||||
Stack *gUSBStack = NULL;
|
||||
|
||||
|
||||
@@ -33,8 +25,8 @@ bus_std_ops(int32 op, ...)
|
||||
#ifdef TRACE_USB
|
||||
set_dprintf_enabled(true);
|
||||
load_driver_symbols("usb");
|
||||
#endif
|
||||
TRACE(("usb_module: init\n"));
|
||||
#endif
|
||||
|
||||
Stack *stack = new(std::nothrow) Stack();
|
||||
if (!stack)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
** usb.rdef
|
||||
**
|
||||
*/
|
||||
* usb.rdef
|
||||
*/
|
||||
|
||||
resource app_signature "application/x-vnd.haiku-usb";
|
||||
|
||||
@@ -12,5 +11,5 @@ resource app_version {
|
||||
variety = 0,
|
||||
internal = 1,
|
||||
short_info = "USB bus manager",
|
||||
long_info = "Haiku - This driver is (c) 2003-2004 Niels Sascha Reedijk"
|
||||
long_info = "Haiku USB bus manager - Copyright 2003-2006, Haiku Inc."
|
||||
};
|
||||
|
||||
@@ -15,6 +15,16 @@
|
||||
#include "BeOSCompatibility.h"
|
||||
|
||||
|
||||
//#define TRACE_USB
|
||||
#ifdef TRACE_USB
|
||||
#define TRACE(x) dprintf x
|
||||
#define TRACE_ERROR(x) dprintf x
|
||||
#else
|
||||
#define TRACE(x) /* nothing */
|
||||
#define TRACE_ERROR(x) dprintf x
|
||||
#endif
|
||||
|
||||
|
||||
class Hub;
|
||||
class Stack;
|
||||
class Device;
|
||||
@@ -189,11 +199,11 @@ enum pipeSpeed { LowSpeed, NormalSpeed };
|
||||
pipeDirection direction,
|
||||
pipeSpeed speed,
|
||||
uint8 endpointAddress,
|
||||
uint32 maxPacketSize);
|
||||
size_t maxPacketSize);
|
||||
Pipe(BusManager *bus,
|
||||
int8 deviceAddress,
|
||||
pipeSpeed speed,
|
||||
uint32 maxPacketSize);
|
||||
size_t maxPacketSize);
|
||||
virtual ~Pipe();
|
||||
|
||||
virtual uint32 Type() { return USB_OBJECT_PIPE; };
|
||||
@@ -202,7 +212,7 @@ virtual uint32 Type() { return USB_OBJECT_PIPE; };
|
||||
pipeSpeed Speed() { return fSpeed; };
|
||||
pipeDirection Direction() { return fDirection; };
|
||||
int8 EndpointAddress() { return fEndpoint; };
|
||||
uint32 MaxPacketSize() { return fMaxPacketSize; };
|
||||
size_t MaxPacketSize() { return fMaxPacketSize; };
|
||||
|
||||
virtual bool DataToggle() { return fDataToggle; };
|
||||
virtual void SetDataToggle(bool toggle) { fDataToggle = toggle; };
|
||||
@@ -223,7 +233,7 @@ protected:
|
||||
pipeDirection fDirection;
|
||||
pipeSpeed fSpeed;
|
||||
uint8 fEndpoint;
|
||||
uint32 fMaxPacketSize;
|
||||
size_t fMaxPacketSize;
|
||||
bool fDataToggle;
|
||||
};
|
||||
|
||||
@@ -233,13 +243,13 @@ public:
|
||||
ControlPipe(Device *device,
|
||||
pipeSpeed speed,
|
||||
uint8 endpointAddress,
|
||||
uint32 maxPacketSize);
|
||||
size_t maxPacketSize);
|
||||
|
||||
// Constructor for default control pipe
|
||||
ControlPipe(BusManager *bus,
|
||||
int8 deviceAddress,
|
||||
pipeSpeed speed,
|
||||
uint32 maxPacketSize);
|
||||
size_t maxPacketSize);
|
||||
|
||||
virtual uint32 Type() { return USB_OBJECT_PIPE | USB_OBJECT_CONTROL_PIPE; };
|
||||
|
||||
@@ -275,7 +285,7 @@ public:
|
||||
pipeDirection direction,
|
||||
pipeSpeed speed,
|
||||
uint8 endpointAddress,
|
||||
uint32 maxPacketSize);
|
||||
size_t maxPacketSize);
|
||||
|
||||
virtual uint32 Type() { return USB_OBJECT_PIPE | USB_OBJECT_INTERRUPT_PIPE; };
|
||||
|
||||
@@ -292,7 +302,7 @@ public:
|
||||
pipeDirection direction,
|
||||
pipeSpeed speed,
|
||||
uint8 endpointAddress,
|
||||
uint32 maxPacketSize);
|
||||
size_t maxPacketSize);
|
||||
|
||||
virtual uint32 Type() { return USB_OBJECT_PIPE | USB_OBJECT_BULK_PIPE; };
|
||||
|
||||
@@ -313,7 +323,7 @@ public:
|
||||
pipeDirection direction,
|
||||
pipeSpeed speed,
|
||||
uint8 endpointAddress,
|
||||
uint32 maxPacketSize);
|
||||
size_t maxPacketSize);
|
||||
|
||||
virtual uint32 Type() { return USB_OBJECT_PIPE | USB_OBJECT_ISO_PIPE; };
|
||||
|
||||
@@ -387,8 +397,8 @@ protected:
|
||||
BusManager *fBus;
|
||||
Device *fParent;
|
||||
int8 fDeviceAddress;
|
||||
uint32 fMaxPacketIn[16];
|
||||
uint32 fMaxPacketOut[16];
|
||||
size_t fMaxPacketIn[16];
|
||||
size_t fMaxPacketOut[16];
|
||||
sem_id fLock;
|
||||
void *fNotifyCookie;
|
||||
};
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* Distributed under the terms of the MIT License.
|
||||
*
|
||||
* Authors:
|
||||
* Michael Lotz <mmlr@mlotz.ch>
|
||||
* Niels S. Reedijk
|
||||
*/
|
||||
|
||||
@@ -55,8 +56,8 @@ struct usb_hub_descriptor
|
||||
uint16 characteristics;
|
||||
uint8 power_on_to_power_good;
|
||||
uint8 max_power;
|
||||
uint8 device_removeable; //Should be variable!!!
|
||||
uint8 power_control_mask; //Deprecated
|
||||
uint8 device_removeable; //Should be variable!!!
|
||||
uint8 power_control_mask; //Deprecated
|
||||
} _PACKED;
|
||||
|
||||
#define USB_DESCRIPTOR_HUB 0x29
|
||||
|
||||
@@ -18,16 +18,6 @@
|
||||
#include "usb_p.h"
|
||||
|
||||
|
||||
#define TRACE_UHCI
|
||||
#ifdef TRACE_UHCI
|
||||
#define TRACE(x) dprintf x
|
||||
#define TRACE_ERROR(x) dprintf x
|
||||
#else
|
||||
#define TRACE(x) /* nothing */
|
||||
#define TRACE_ERROR(x) dprintf x
|
||||
#endif
|
||||
|
||||
|
||||
pci_module_info *UHCI::sPCIModule = NULL;
|
||||
|
||||
|
||||
@@ -71,7 +61,7 @@ module_info *modules[] = {
|
||||
//
|
||||
|
||||
|
||||
#ifdef TRACE_UHCI
|
||||
#ifdef TRACE_USB
|
||||
|
||||
void
|
||||
print_descriptor_chain(uhci_td *descriptor)
|
||||
@@ -91,7 +81,7 @@ print_descriptor_chain(uhci_td *descriptor)
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TRACE_UHCI
|
||||
#endif // TRACE_USB
|
||||
|
||||
|
||||
//
|
||||
@@ -217,7 +207,7 @@ Queue::AppendDescriptorChain(uhci_td *descriptor)
|
||||
if (!Lock())
|
||||
return B_ERROR;
|
||||
|
||||
#ifdef TRACE_UHCI
|
||||
#ifdef TRACE_USB
|
||||
print_descriptor_chain(descriptor);
|
||||
#endif
|
||||
|
||||
@@ -288,7 +278,7 @@ Queue::RemoveDescriptorChain(uhci_td *firstDescriptor, uhci_td *lastDescriptor)
|
||||
lastDescriptor->link_log = NULL;
|
||||
lastDescriptor->link_phy = TD_TERMINATE;
|
||||
|
||||
#ifdef TRACE_UHCI
|
||||
#ifdef TRACE_USB
|
||||
print_descriptor_chain(firstDescriptor);
|
||||
#endif
|
||||
|
||||
@@ -307,7 +297,7 @@ Queue::PhysicalAddress()
|
||||
void
|
||||
Queue::PrintToStream()
|
||||
{
|
||||
#ifdef TRACE_UHCI
|
||||
#ifdef TRACE_USB
|
||||
dprintf("USB UHCI Queue:\n");
|
||||
dprintf("link phy: 0x%08x; link type: %s; terminate: %s\n", fQueueHead->link_phy & 0xfff0, fQueueHead->link_phy & 0x0002 ? "QH" : "TD", fQueueHead->link_phy & 0x0001 ? "yes" : "no");
|
||||
dprintf("elem phy: 0x%08x; elem type: %s; terminate: %s\n", fQueueHead->element_phy & 0xfff0, fQueueHead->element_phy & 0x0002 ? "QH" : "TD", fQueueHead->element_phy & 0x0001 ? "yes" : "no");
|
||||
@@ -339,7 +329,7 @@ UHCI::UHCI(pci_info *info, Stack *stack)
|
||||
fRootHubAddress(0)
|
||||
{
|
||||
if (!fInitOK) {
|
||||
TRACE(("usb_uhci: bus manager failed to init\n"));
|
||||
TRACE_ERROR(("usb_uhci: bus manager failed to init\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -514,7 +504,7 @@ UHCI::Start()
|
||||
status_t
|
||||
UHCI::SubmitTransfer(Transfer *transfer)
|
||||
{
|
||||
//TRACE(("usb_uhci: submit transfer called for device %d\n", transfer->TransferPipe()->DeviceAddress()));
|
||||
TRACE(("usb_uhci: submit transfer called for device %d\n", transfer->TransferPipe()->DeviceAddress()));
|
||||
|
||||
// Short circuit the root hub
|
||||
if (transfer->TransferPipe()->DeviceAddress() == fRootHubAddress)
|
||||
@@ -721,7 +711,7 @@ UHCI::FinishTransfers()
|
||||
}
|
||||
|
||||
if (status & TD_ERROR_MASK) {
|
||||
TRACE_ERROR(("usb_uhci: td (0x%08x) error: 0x%08x\n", descriptor->this_phy, status));
|
||||
TRACE_ERROR(("usb_uhci: td (0x%08lx) error: 0x%08lx\n", descriptor->this_phy, status));
|
||||
// an error occured. we have to remove the
|
||||
// transfer from the queue and clean up
|
||||
|
||||
@@ -986,6 +976,7 @@ UHCI::Interrupt()
|
||||
|
||||
if (status & UHCI_USBSTS_HCHALT) {
|
||||
TRACE(("usb_uhci: host controller halted\n"));
|
||||
// ToDo: cancel all transfers and reset the host controller
|
||||
// acknowledge not needed
|
||||
}
|
||||
|
||||
@@ -1000,7 +991,7 @@ UHCI::Interrupt()
|
||||
bool
|
||||
UHCI::AddTo(Stack &stack)
|
||||
{
|
||||
#ifdef TRACE_UHCI
|
||||
#ifdef TRACE_USB
|
||||
set_dprintf_enabled(true);
|
||||
load_driver_symbols("uhci");
|
||||
#endif
|
||||
@@ -1008,7 +999,7 @@ UHCI::AddTo(Stack &stack)
|
||||
if (!sPCIModule) {
|
||||
status_t status = get_module(B_PCI_MODULE_NAME, (module_info **)&sPCIModule);
|
||||
if (status < B_OK) {
|
||||
TRACE_ERROR(("usb_uhci: AddTo(): getting pci module failed! 0x%08x\n",
|
||||
TRACE_ERROR(("usb_uhci: AddTo(): getting pci module failed! 0x%08lx\n",
|
||||
status));
|
||||
return status;
|
||||
}
|
||||
@@ -1044,7 +1035,7 @@ UHCI::AddTo(Stack &stack)
|
||||
}
|
||||
|
||||
if (bus->InitCheck() < B_OK) {
|
||||
TRACE_ERROR(("usb_uhci: AddTo(): InitCheck() failed 0x%08x\n", bus->InitCheck()));
|
||||
TRACE_ERROR(("usb_uhci: AddTo(): InitCheck() failed 0x%08lx\n", bus->InitCheck()));
|
||||
delete bus;
|
||||
continue;
|
||||
}
|
||||
@@ -1056,7 +1047,7 @@ UHCI::AddTo(Stack &stack)
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
TRACE(("usb_uhci: AddTo(): no devices found\n"));
|
||||
TRACE_ERROR(("usb_uhci: no devices found\n"));
|
||||
delete item;
|
||||
sPCIModule = NULL;
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
@@ -1068,7 +1059,7 @@ UHCI::AddTo(Stack &stack)
|
||||
|
||||
|
||||
uhci_td *
|
||||
UHCI::CreateDescriptor(Pipe *pipe, uint8 direction, int32 bufferSize)
|
||||
UHCI::CreateDescriptor(Pipe *pipe, uint8 direction, size_t bufferSize)
|
||||
{
|
||||
uhci_td *result;
|
||||
void *physicalAddress;
|
||||
@@ -1113,9 +1104,9 @@ UHCI::CreateDescriptor(Pipe *pipe, uint8 direction, int32 bufferSize)
|
||||
|
||||
status_t
|
||||
UHCI::CreateDescriptorChain(Pipe *pipe, uhci_td **_firstDescriptor,
|
||||
uhci_td **_lastDescriptor, uint8 direction, int32 bufferSize)
|
||||
uhci_td **_lastDescriptor, uint8 direction, size_t bufferSize)
|
||||
{
|
||||
int32 packetSize = pipe->MaxPacketSize();
|
||||
size_t packetSize = pipe->MaxPacketSize();
|
||||
int32 descriptorCount = (bufferSize + packetSize - 1) / packetSize;
|
||||
|
||||
bool dataToggle = pipe->DataToggle();
|
||||
|
||||
@@ -102,12 +102,12 @@ static int32 FinishThread(void *data);
|
||||
// Descriptor functions
|
||||
uhci_td *CreateDescriptor(Pipe *pipe,
|
||||
uint8 direction,
|
||||
int32 bufferSizeToAllocate);
|
||||
size_t bufferSizeToAllocate);
|
||||
status_t CreateDescriptorChain(Pipe *pipe,
|
||||
uhci_td **firstDescriptor,
|
||||
uhci_td **lastDescriptor,
|
||||
uint8 direction,
|
||||
int32 bufferSizeToAllocate);
|
||||
size_t bufferSizeToAllocate);
|
||||
|
||||
void FreeDescriptor(uhci_td *descriptor);
|
||||
void FreeDescriptorChain(uhci_td *topDescriptor);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/*
|
||||
** uhci.rdef
|
||||
**
|
||||
*/
|
||||
* uhci.rdef
|
||||
*/
|
||||
|
||||
resource app_signature "application/x-vnd.haiku-uhci";
|
||||
|
||||
@@ -12,5 +11,5 @@ resource app_version {
|
||||
variety = 0,
|
||||
internal = 0,
|
||||
short_info = "UHCI host controller driver",
|
||||
long_info = "OpenBeOS - This driver is (c) 2003-2005 Niels Sascha Reedijk"
|
||||
long_info = "Haiku UHCI HCD - Copyright 2003-2006, Haiku Inc."
|
||||
};
|
||||
|
||||
@@ -91,7 +91,7 @@ typedef struct
|
||||
addr_t this_phy; // A physical pointer to this address
|
||||
void *link_log; // Pointer to the next logical TD/QT
|
||||
void *buffer_log; // Pointer to the logical buffer
|
||||
int32 buffer_size; // Size of the buffer
|
||||
size_t buffer_size; // Size of the buffer
|
||||
} uhci_td;
|
||||
|
||||
// Control and Status
|
||||
|
||||
@@ -11,14 +11,6 @@
|
||||
#include <PCI.h>
|
||||
|
||||
|
||||
//#define TRACE_UHCI_ROOT_HUB
|
||||
#ifdef TRACE_UHCI_ROOT_HUB
|
||||
#define TRACE(x) dprintf x
|
||||
#else
|
||||
#define TRACE(x) /* nothing */
|
||||
#endif
|
||||
|
||||
|
||||
static usb_device_descriptor sUHCIRootHubDevice =
|
||||
{
|
||||
18, // Descriptor length
|
||||
@@ -231,11 +223,11 @@ UHCIRootHub::SubmitTransfer(Transfer *transfer)
|
||||
case RH_CLEAR_FEATURE: {
|
||||
if (request->Index == 0) {
|
||||
// We don't support any hub changes
|
||||
TRACE(("usb_uhci_roothub: RH_CLEAR_FEATURE no hub changes!\n"));
|
||||
TRACE_ERROR(("usb_uhci_roothub: RH_CLEAR_FEATURE no hub changes!\n"));
|
||||
break;
|
||||
} else if (request->Index > sUHCIRootHubConfig.hub.num_ports) {
|
||||
// Invalid port number
|
||||
TRACE(("usb_uhci_roothub: RH_CLEAR_FEATURE invalid port!\n"));
|
||||
TRACE_ERROR(("usb_uhci_roothub: RH_CLEAR_FEATURE invalid port!\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -261,11 +253,11 @@ UHCIRootHub::SubmitTransfer(Transfer *transfer)
|
||||
case RH_SET_FEATURE: {
|
||||
if (request->Index == 0) {
|
||||
// We don't support any hub changes
|
||||
TRACE(("usb_uhci_roothub: RH_SET_FEATURE no hub changes!\n"));
|
||||
TRACE_ERROR(("usb_uhci_roothub: RH_SET_FEATURE no hub changes!\n"));
|
||||
break;
|
||||
} else if (request->Index > sUHCIRootHubConfig.hub.num_ports) {
|
||||
// Invalid port number
|
||||
TRACE(("usb_uhci_roothub: RH_SET_FEATURE invalid port!\n"));
|
||||
TRACE_ERROR(("usb_uhci_roothub: RH_SET_FEATURE invalid port!\n"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user