* Rework the USB tracing mechanism. Cleaned it up and make it more convenient to
use. It will now print out the usb_ids of the objects that generate the trace messages. These IDs are unique compared to the device address used previously, because device addresses are per bus while usb_ids are global. This makes trace output from devices across multiple controllers distinguishable. * Some cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29002 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
|
||||
BusManager::BusManager(Stack *stack)
|
||||
: fInitOK(false),
|
||||
fStack(stack),
|
||||
fRootHub(NULL)
|
||||
{
|
||||
mutex_init(&fLock, "usb busmanager lock");
|
||||
@@ -86,7 +87,7 @@ BusManager::AllocateAddress()
|
||||
address = (address + 1) % 127;
|
||||
}
|
||||
|
||||
TRACE_ERROR(("USB BusManager: the busmanager has run out of device addresses\n"));
|
||||
TRACE_ERROR("the busmanager has run out of device addresses\n");
|
||||
Unlock();
|
||||
return -1;
|
||||
}
|
||||
@@ -103,7 +104,7 @@ BusManager::FreeAddress(int8 address)
|
||||
return;
|
||||
|
||||
if (!fDeviceMap[address]) {
|
||||
TRACE_ERROR(("USB BusManager: freeing address %d which was not allocated\n", address));
|
||||
TRACE_ERROR("freeing address %d which was not allocated\n", address);
|
||||
}
|
||||
|
||||
fDeviceMap[address] = false;
|
||||
@@ -118,15 +119,15 @@ BusManager::AllocateDevice(Hub *parent, int8 hubAddress, uint8 hubPort,
|
||||
// Check if there is a free entry in the device map (for the device number)
|
||||
int8 deviceAddress = AllocateAddress();
|
||||
if (deviceAddress < 0) {
|
||||
TRACE_ERROR(("USB BusManager: could not allocate an address\n"));
|
||||
TRACE_ERROR("could not allocate an address\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TRACE(("USB BusManager: setting device address to %d\n", deviceAddress));
|
||||
TRACE("setting device address to %d\n", deviceAddress);
|
||||
ControlPipe *defaultPipe = _GetDefaultPipe(speed);
|
||||
|
||||
if (!defaultPipe) {
|
||||
TRACE_ERROR(("USB BusManager: error getting the default pipe for speed %d\n", (int)speed));
|
||||
TRACE_ERROR("error getting the default pipe for speed %d\n", speed);
|
||||
FreeAddress(deviceAddress);
|
||||
return NULL;
|
||||
}
|
||||
@@ -153,7 +154,7 @@ BusManager::AllocateDevice(Hub *parent, int8 hubAddress, uint8 hubPort,
|
||||
}
|
||||
|
||||
if (result < B_OK) {
|
||||
TRACE_ERROR(("USB BusManager: error while setting device address\n"));
|
||||
TRACE_ERROR("error while setting device address\n");
|
||||
FreeAddress(deviceAddress);
|
||||
return NULL;
|
||||
}
|
||||
@@ -173,7 +174,7 @@ BusManager::AllocateDevice(Hub *parent, int8 hubAddress, uint8 hubPort,
|
||||
size_t actualLength = 0;
|
||||
usb_device_descriptor deviceDescriptor;
|
||||
|
||||
TRACE(("USB BusManager: getting the device descriptor\n"));
|
||||
TRACE("getting the device descriptor\n");
|
||||
pipe.SendRequest(
|
||||
USB_REQTYPE_DEVICE_IN | USB_REQTYPE_STANDARD, // type
|
||||
USB_REQUEST_GET_DESCRIPTOR, // request
|
||||
@@ -185,33 +186,33 @@ BusManager::AllocateDevice(Hub *parent, int8 hubAddress, uint8 hubPort,
|
||||
&actualLength); // actual length
|
||||
|
||||
if (actualLength != 8) {
|
||||
TRACE_ERROR(("USB BusManager: error while getting the device descriptor\n"));
|
||||
TRACE_ERROR("error while getting the device descriptor\n");
|
||||
FreeAddress(deviceAddress);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TRACE(("short device descriptor for device %d:\n", deviceAddress));
|
||||
TRACE(("\tlength:..............%d\n", deviceDescriptor.length));
|
||||
TRACE(("\tdescriptor_type:.....0x%04x\n", deviceDescriptor.descriptor_type));
|
||||
TRACE(("\tusb_version:.........0x%04x\n", deviceDescriptor.usb_version));
|
||||
TRACE(("\tdevice_class:........0x%02x\n", deviceDescriptor.device_class));
|
||||
TRACE(("\tdevice_subclass:.....0x%02x\n", deviceDescriptor.device_subclass));
|
||||
TRACE(("\tdevice_protocol:.....0x%02x\n", deviceDescriptor.device_protocol));
|
||||
TRACE(("\tmax_packet_size_0:...%d\n", deviceDescriptor.max_packet_size_0));
|
||||
TRACE("short device descriptor for device %d:\n", deviceAddress);
|
||||
TRACE("\tlength:..............%d\n", deviceDescriptor.length);
|
||||
TRACE("\tdescriptor_type:.....0x%04x\n", deviceDescriptor.descriptor_type);
|
||||
TRACE("\tusb_version:.........0x%04x\n", deviceDescriptor.usb_version);
|
||||
TRACE("\tdevice_class:........0x%02x\n", deviceDescriptor.device_class);
|
||||
TRACE("\tdevice_subclass:.....0x%02x\n", deviceDescriptor.device_subclass);
|
||||
TRACE("\tdevice_protocol:.....0x%02x\n", deviceDescriptor.device_protocol);
|
||||
TRACE("\tmax_packet_size_0:...%d\n", deviceDescriptor.max_packet_size_0);
|
||||
|
||||
// Create a new instance based on the type (Hub or Device)
|
||||
if (deviceDescriptor.device_class == 0x09) {
|
||||
TRACE(("USB BusManager: creating new hub\n"));
|
||||
TRACE("creating new hub\n");
|
||||
Hub *hub = new(std::nothrow) Hub(parent, hubAddress, hubPort,
|
||||
deviceDescriptor, deviceAddress, speed, false);
|
||||
if (!hub) {
|
||||
TRACE_ERROR(("USB BusManager: no memory to allocate hub\n"));
|
||||
TRACE_ERROR("no memory to allocate hub\n");
|
||||
FreeAddress(deviceAddress);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (hub->InitCheck() < B_OK) {
|
||||
TRACE_ERROR(("USB BusManager: hub failed init check\n"));
|
||||
TRACE_ERROR("hub failed init check\n");
|
||||
FreeAddress(deviceAddress);
|
||||
delete hub;
|
||||
return NULL;
|
||||
@@ -220,17 +221,17 @@ BusManager::AllocateDevice(Hub *parent, int8 hubAddress, uint8 hubPort,
|
||||
return (Device *)hub;
|
||||
}
|
||||
|
||||
TRACE(("USB BusManager: creating new device\n"));
|
||||
TRACE("creating new device\n");
|
||||
Device *device = new(std::nothrow) Device(parent, hubAddress, hubPort,
|
||||
deviceDescriptor, deviceAddress, speed, false);
|
||||
if (!device) {
|
||||
TRACE_ERROR(("USB BusManager: no memory to allocate device\n"));
|
||||
TRACE_ERROR("no memory to allocate device\n");
|
||||
FreeAddress(deviceAddress);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (device->InitCheck() < B_OK) {
|
||||
TRACE_ERROR(("USB BusManager: device failed init check\n"));
|
||||
TRACE_ERROR("device failed init check\n");
|
||||
FreeAddress(deviceAddress);
|
||||
delete device;
|
||||
return NULL;
|
||||
@@ -298,7 +299,7 @@ BusManager::_GetDefaultPipe(usb_speed speed)
|
||||
}
|
||||
|
||||
if (!fDefaultPipes[speed]) {
|
||||
TRACE_ERROR(("USB BusManager: failed to allocate default pipe for speed %d\n", speed));
|
||||
TRACE_ERROR("failed to allocate default pipe for speed %d\n", speed);
|
||||
}
|
||||
|
||||
Unlock();
|
||||
|
||||
@@ -25,11 +25,11 @@ Device::Device(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
fHubAddress(hubAddress),
|
||||
fHubPort(hubPort)
|
||||
{
|
||||
TRACE(("USB Device %d: creating device\n", fDeviceAddress));
|
||||
TRACE("creating device\n");
|
||||
|
||||
fDefaultPipe = new(std::nothrow) ControlPipe(this);
|
||||
if (!fDefaultPipe) {
|
||||
TRACE_ERROR(("USB Device %d: could not allocate default pipe\n", fDeviceAddress));
|
||||
TRACE_ERROR("could not allocate default pipe\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,32 +43,31 @@ Device::Device(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
(void *)&fDeviceDescriptor, sizeof(fDeviceDescriptor), &actualLength);
|
||||
|
||||
if (status < B_OK || actualLength != sizeof(fDeviceDescriptor)) {
|
||||
TRACE_ERROR(("USB Device %d: error while getting the device descriptor\n", fDeviceAddress));
|
||||
TRACE_ERROR("error while getting the device descriptor\n");
|
||||
return;
|
||||
}
|
||||
|
||||
TRACE(("full device descriptor for device %d:\n", fDeviceAddress));
|
||||
TRACE(("\tlength:..............%d\n", fDeviceDescriptor.length));
|
||||
TRACE(("\tdescriptor_type:.....0x%04x\n", fDeviceDescriptor.descriptor_type));
|
||||
TRACE(("\tusb_version:.........0x%04x\n", fDeviceDescriptor.usb_version));
|
||||
TRACE(("\tdevice_class:........0x%02x\n", fDeviceDescriptor.device_class));
|
||||
TRACE(("\tdevice_subclass:.....0x%02x\n", fDeviceDescriptor.device_subclass));
|
||||
TRACE(("\tdevice_protocol:.....0x%02x\n", fDeviceDescriptor.device_protocol));
|
||||
TRACE(("\tmax_packet_size_0:...%d\n", fDeviceDescriptor.max_packet_size_0));
|
||||
TRACE(("\tvendor_id:...........0x%04x\n", fDeviceDescriptor.vendor_id));
|
||||
TRACE(("\tproduct_id:..........0x%04x\n", fDeviceDescriptor.product_id));
|
||||
TRACE(("\tdevice_version:......0x%04x\n", fDeviceDescriptor.device_version));
|
||||
TRACE(("\tmanufacturer:........0x%02x\n", fDeviceDescriptor.manufacturer));
|
||||
TRACE(("\tproduct:.............0x%02x\n", fDeviceDescriptor.product));
|
||||
TRACE(("\tserial_number:.......0x%02x\n", fDeviceDescriptor.serial_number));
|
||||
TRACE(("\tnum_configurations:..%d\n", fDeviceDescriptor.num_configurations));
|
||||
TRACE("full device descriptor for device %d:\n", fDeviceAddress);
|
||||
TRACE("\tlength:..............%d\n", fDeviceDescriptor.length);
|
||||
TRACE("\tdescriptor_type:.....0x%04x\n", fDeviceDescriptor.descriptor_type);
|
||||
TRACE("\tusb_version:.........0x%04x\n", fDeviceDescriptor.usb_version);
|
||||
TRACE("\tdevice_class:........0x%02x\n", fDeviceDescriptor.device_class);
|
||||
TRACE("\tdevice_subclass:.....0x%02x\n", fDeviceDescriptor.device_subclass);
|
||||
TRACE("\tdevice_protocol:.....0x%02x\n", fDeviceDescriptor.device_protocol);
|
||||
TRACE("\tmax_packet_size_0:...%d\n", fDeviceDescriptor.max_packet_size_0);
|
||||
TRACE("\tvendor_id:...........0x%04x\n", fDeviceDescriptor.vendor_id);
|
||||
TRACE("\tproduct_id:..........0x%04x\n", fDeviceDescriptor.product_id);
|
||||
TRACE("\tdevice_version:......0x%04x\n", fDeviceDescriptor.device_version);
|
||||
TRACE("\tmanufacturer:........0x%02x\n", fDeviceDescriptor.manufacturer);
|
||||
TRACE("\tproduct:.............0x%02x\n", fDeviceDescriptor.product);
|
||||
TRACE("\tserial_number:.......0x%02x\n", fDeviceDescriptor.serial_number);
|
||||
TRACE("\tnum_configurations:..%d\n", fDeviceDescriptor.num_configurations);
|
||||
|
||||
// Get the configurations
|
||||
fConfigurations = (usb_configuration_info *)malloc(
|
||||
fDeviceDescriptor.num_configurations * sizeof(usb_configuration_info));
|
||||
if (fConfigurations == NULL) {
|
||||
TRACE_ERROR(("USB Device %d: out of memory during config creations!\n",
|
||||
fDeviceAddress));
|
||||
TRACE_ERROR("out of memory during config creations!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -81,25 +80,23 @@ Device::Device(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
&actualLength);
|
||||
|
||||
if (status < B_OK || actualLength != sizeof(usb_configuration_descriptor)) {
|
||||
TRACE_ERROR(("USB Device %d: error fetching configuration %ld\n",
|
||||
fDeviceAddress, i));
|
||||
TRACE_ERROR("error fetching configuration %ld\n", i);
|
||||
return;
|
||||
}
|
||||
|
||||
TRACE(("USB Device %d: configuration %ld\n", fDeviceAddress, i));
|
||||
TRACE(("\tlength:..............%d\n", configDescriptor.length));
|
||||
TRACE(("\tdescriptor_type:.....0x%02x\n", configDescriptor.descriptor_type));
|
||||
TRACE(("\ttotal_length:........%d\n", configDescriptor.total_length));
|
||||
TRACE(("\tnumber_interfaces:...%d\n", configDescriptor.number_interfaces));
|
||||
TRACE(("\tconfiguration_value:.0x%02x\n", configDescriptor.configuration_value));
|
||||
TRACE(("\tconfiguration:.......0x%02x\n", configDescriptor.configuration));
|
||||
TRACE(("\tattributes:..........0x%02x\n", configDescriptor.attributes));
|
||||
TRACE(("\tmax_power:...........%d\n", configDescriptor.max_power));
|
||||
TRACE("configuration %ld\n", i);
|
||||
TRACE("\tlength:..............%d\n", configDescriptor.length);
|
||||
TRACE("\tdescriptor_type:.....0x%02x\n", configDescriptor.descriptor_type);
|
||||
TRACE("\ttotal_length:........%d\n", configDescriptor.total_length);
|
||||
TRACE("\tnumber_interfaces:...%d\n", configDescriptor.number_interfaces);
|
||||
TRACE("\tconfiguration_value:.0x%02x\n", configDescriptor.configuration_value);
|
||||
TRACE("\tconfiguration:.......0x%02x\n", configDescriptor.configuration);
|
||||
TRACE("\tattributes:..........0x%02x\n", configDescriptor.attributes);
|
||||
TRACE("\tmax_power:...........%d\n", configDescriptor.max_power);
|
||||
|
||||
uint8 *configData = (uint8 *)malloc(configDescriptor.total_length);
|
||||
if (configData == NULL) {
|
||||
TRACE_ERROR(("USB Device %d: out of memory when reading config\n",
|
||||
fDeviceAddress));
|
||||
TRACE_ERROR("out of memory when reading config\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -107,9 +104,9 @@ Device::Device(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
(void *)configData, configDescriptor.total_length, &actualLength);
|
||||
|
||||
if (status < B_OK || actualLength != configDescriptor.total_length) {
|
||||
TRACE_ERROR(("USB Device %d: error fetching full configuration"
|
||||
" descriptor %ld got %lu expected %u\n", fDeviceAddress, i,
|
||||
actualLength, configDescriptor.total_length));
|
||||
TRACE_ERROR("error fetching full configuration"
|
||||
" descriptor %ld got %lu expected %u\n", i,
|
||||
actualLength, configDescriptor.total_length);
|
||||
free(configData);
|
||||
return;
|
||||
}
|
||||
@@ -121,8 +118,7 @@ Device::Device(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
fConfigurations[i].interface = (usb_interface_list *)malloc(
|
||||
configuration->number_interfaces * sizeof(usb_interface_list));
|
||||
if (fConfigurations[i].interface == NULL) {
|
||||
TRACE_ERROR(("USB Device %d: out of memory when creating interfaces\n",
|
||||
fDeviceAddress));
|
||||
TRACE_ERROR("out of memory when creating interfaces\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -134,18 +130,18 @@ Device::Device(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
while (descriptorStart < actualLength) {
|
||||
switch (configData[descriptorStart + 1]) {
|
||||
case USB_DESCRIPTOR_INTERFACE: {
|
||||
TRACE(("USB Device %d: got interface descriptor\n", fDeviceAddress));
|
||||
TRACE("got interface descriptor\n");
|
||||
usb_interface_descriptor *interfaceDescriptor
|
||||
= (usb_interface_descriptor *)&configData[descriptorStart];
|
||||
TRACE(("\tlength:.............%d\n", interfaceDescriptor->length));
|
||||
TRACE(("\tdescriptor_type:....0x%02x\n", interfaceDescriptor->descriptor_type));
|
||||
TRACE(("\tinterface_number:...%d\n", interfaceDescriptor->interface_number));
|
||||
TRACE(("\talternate_setting:..%d\n", interfaceDescriptor->alternate_setting));
|
||||
TRACE(("\tnum_endpoints:......%d\n", interfaceDescriptor->num_endpoints));
|
||||
TRACE(("\tinterface_class:....0x%02x\n", interfaceDescriptor->interface_class));
|
||||
TRACE(("\tinterface_subclass:.0x%02x\n", interfaceDescriptor->interface_subclass));
|
||||
TRACE(("\tinterface_protocol:.0x%02x\n", interfaceDescriptor->interface_protocol));
|
||||
TRACE(("\tinterface:..........%d\n", interfaceDescriptor->interface));
|
||||
TRACE("\tlength:.............%d\n", interfaceDescriptor->length);
|
||||
TRACE("\tdescriptor_type:....0x%02x\n", interfaceDescriptor->descriptor_type);
|
||||
TRACE("\tinterface_number:...%d\n", interfaceDescriptor->interface_number);
|
||||
TRACE("\talternate_setting:..%d\n", interfaceDescriptor->alternate_setting);
|
||||
TRACE("\tnum_endpoints:......%d\n", interfaceDescriptor->num_endpoints);
|
||||
TRACE("\tinterface_class:....0x%02x\n", interfaceDescriptor->interface_class);
|
||||
TRACE("\tinterface_subclass:.0x%02x\n", interfaceDescriptor->interface_subclass);
|
||||
TRACE("\tinterface_protocol:.0x%02x\n", interfaceDescriptor->interface_protocol);
|
||||
TRACE("\tinterface:..........%d\n", interfaceDescriptor->interface);
|
||||
|
||||
usb_interface_list *interfaceList
|
||||
= &fConfigurations[i].interface[interfaceDescriptor->interface_number];
|
||||
@@ -156,8 +152,8 @@ Device::Device(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
= (usb_interface_info *)realloc(interfaceList->alt,
|
||||
interfaceList->alt_count * sizeof(usb_interface_info));
|
||||
if (newAlternates == NULL) {
|
||||
TRACE_ERROR(("USB Device %d: out of memory allocating"
|
||||
" alternate interface\n", fDeviceAddress));
|
||||
TRACE_ERROR("out of memory allocating"
|
||||
" alternate interface\n");
|
||||
interfaceList->alt_count--;
|
||||
return;
|
||||
}
|
||||
@@ -179,8 +175,8 @@ Device::Device(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
Interface *interface = new(std::nothrow) Interface(this,
|
||||
interfaceDescriptor->interface_number);
|
||||
if (interface == NULL) {
|
||||
TRACE_ERROR(("USB Device %d: failed to allocate"
|
||||
" interface object\n", fDeviceAddress));
|
||||
TRACE_ERROR("failed to allocate"
|
||||
" interface object\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -190,15 +186,15 @@ Device::Device(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
}
|
||||
|
||||
case USB_DESCRIPTOR_ENDPOINT: {
|
||||
TRACE(("USB Device %d: got endpoint descriptor\n", fDeviceAddress));
|
||||
TRACE("got endpoint descriptor\n");
|
||||
usb_endpoint_descriptor *endpointDescriptor
|
||||
= (usb_endpoint_descriptor *)&configData[descriptorStart];
|
||||
TRACE(("\tlength:.............%d\n", endpointDescriptor->length));
|
||||
TRACE(("\tdescriptor_type:....0x%02x\n", endpointDescriptor->descriptor_type));
|
||||
TRACE(("\tendpoint_address:...0x%02x\n", endpointDescriptor->endpoint_address));
|
||||
TRACE(("\tattributes:.........0x%02x\n", endpointDescriptor->attributes));
|
||||
TRACE(("\tmax_packet_size:....%d\n", endpointDescriptor->max_packet_size));
|
||||
TRACE(("\tinterval:...........%d\n", endpointDescriptor->interval));
|
||||
TRACE("\tlength:.............%d\n", endpointDescriptor->length);
|
||||
TRACE("\tdescriptor_type:....0x%02x\n", endpointDescriptor->descriptor_type);
|
||||
TRACE("\tendpoint_address:...0x%02x\n", endpointDescriptor->endpoint_address);
|
||||
TRACE("\tattributes:.........0x%02x\n", endpointDescriptor->attributes);
|
||||
TRACE("\tmax_packet_size:....%d\n", endpointDescriptor->max_packet_size);
|
||||
TRACE("\tinterval:...........%d\n", endpointDescriptor->interval);
|
||||
|
||||
if (!currentInterface)
|
||||
break;
|
||||
@@ -211,8 +207,8 @@ Device::Device(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
currentInterface->endpoint_count
|
||||
* sizeof(usb_endpoint_info));
|
||||
if (newEndpoints == NULL) {
|
||||
TRACE_ERROR(("USB Device %d: out of memory allocating"
|
||||
" new endpoint\n", fDeviceAddress));
|
||||
TRACE_ERROR("out of memory allocating"
|
||||
" new endpoint\n");
|
||||
currentInterface->endpoint_count--;
|
||||
return;
|
||||
}
|
||||
@@ -228,11 +224,11 @@ Device::Device(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
}
|
||||
|
||||
default:
|
||||
TRACE(("USB Device %d: got generic descriptor\n", fDeviceAddress));
|
||||
TRACE("got generic descriptor\n");
|
||||
usb_generic_descriptor *genericDescriptor
|
||||
= (usb_generic_descriptor *)&configData[descriptorStart];
|
||||
TRACE(("\tlength:.............%d\n", genericDescriptor->length));
|
||||
TRACE(("\tdescriptor_type:....0x%02x\n", genericDescriptor->descriptor_type));
|
||||
TRACE("\tlength:.............%d\n", genericDescriptor->length);
|
||||
TRACE("\tdescriptor_type:....0x%02x\n", genericDescriptor->descriptor_type);
|
||||
|
||||
if (!currentInterface)
|
||||
break;
|
||||
@@ -244,8 +240,8 @@ Device::Device(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
currentInterface->generic_count
|
||||
* sizeof(usb_descriptor *));
|
||||
if (newGenerics == NULL) {
|
||||
TRACE_ERROR(("USB Device %d: out of memory allocating"
|
||||
" generic descriptor\n", fDeviceAddress));
|
||||
TRACE_ERROR("out of memory allocating"
|
||||
" generic descriptor\n");
|
||||
currentInterface->generic_count--;
|
||||
return;
|
||||
}
|
||||
@@ -263,10 +259,9 @@ Device::Device(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
}
|
||||
|
||||
// Set default configuration
|
||||
TRACE(("USB Device %d: setting default configuration\n", fDeviceAddress));
|
||||
TRACE("setting default configuration\n");
|
||||
if (SetConfigurationAt(0) < B_OK) {
|
||||
TRACE_ERROR(("USB Device %d: failed to set default configuration\n",
|
||||
fDeviceAddress));
|
||||
TRACE_ERROR("failed to set default configuration\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -468,8 +463,7 @@ Device::InitEndpoints(int32 interfaceIndex)
|
||||
}
|
||||
|
||||
if (pipe == NULL) {
|
||||
TRACE_ERROR(("USB Device %d: failed to allocate pipe\n",
|
||||
fDeviceAddress));
|
||||
TRACE_ERROR("failed to allocate pipe\n");
|
||||
endpoint->handle = 0;
|
||||
continue;
|
||||
}
|
||||
@@ -584,7 +578,7 @@ Device::ReportDevice(usb_support_descriptor *supportDescriptors,
|
||||
uint32 supportDescriptorCount, const usb_notify_hooks *hooks,
|
||||
usb_driver_cookie **cookies, bool added, bool recursive)
|
||||
{
|
||||
TRACE(("USB Device %d: reporting device\n", fDeviceAddress));
|
||||
TRACE("reporting device\n");
|
||||
bool supported = false;
|
||||
if (supportDescriptorCount == 0 || supportDescriptors == NULL)
|
||||
supported = true;
|
||||
@@ -685,6 +679,7 @@ Device::SetFeature(uint16 selector)
|
||||
if (!fAvailable)
|
||||
return B_ERROR;
|
||||
|
||||
TRACE("set feature %u\n", selector);
|
||||
return fDefaultPipe->SendRequest(
|
||||
USB_REQTYPE_STANDARD | USB_REQTYPE_DEVICE_OUT,
|
||||
USB_REQUEST_SET_FEATURE,
|
||||
@@ -703,6 +698,7 @@ Device::ClearFeature(uint16 selector)
|
||||
if (!fAvailable)
|
||||
return B_ERROR;
|
||||
|
||||
TRACE("clear feature %u\n", selector);
|
||||
return fDefaultPipe->SendRequest(
|
||||
USB_REQTYPE_STANDARD | USB_REQTYPE_DEVICE_OUT,
|
||||
USB_REQUEST_CLEAR_FEATURE,
|
||||
@@ -721,6 +717,7 @@ Device::GetStatus(uint16 *status)
|
||||
if (!fAvailable)
|
||||
return B_ERROR;
|
||||
|
||||
TRACE("get status\n");
|
||||
return fDefaultPipe->SendRequest(
|
||||
USB_REQTYPE_STANDARD | USB_REQTYPE_DEVICE_IN,
|
||||
USB_REQUEST_GET_STATUS,
|
||||
|
||||
@@ -18,14 +18,14 @@ Hub::Hub(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
isRootHub),
|
||||
fInterruptPipe(NULL)
|
||||
{
|
||||
TRACE(("USB Hub %d: creating hub\n", DeviceAddress()));
|
||||
TRACE("creating hub\n");
|
||||
|
||||
memset(&fHubDescriptor, 0, sizeof(fHubDescriptor));
|
||||
for (int32 i = 0; i < USB_MAX_PORT_COUNT; i++)
|
||||
fChildren[i] = NULL;
|
||||
|
||||
if (!fInitOK) {
|
||||
TRACE_ERROR(("USB Hub %d: device failed to initialize\n", DeviceAddress()));
|
||||
TRACE_ERROR("device failed to initialize\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -33,33 +33,33 @@ Hub::Hub(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
fInitOK = false;
|
||||
|
||||
if (fDeviceDescriptor.device_class != 9) {
|
||||
TRACE_ERROR(("USB Hub %d: wrong class! bailing out\n", DeviceAddress()));
|
||||
TRACE_ERROR("wrong class! bailing out\n");
|
||||
return;
|
||||
}
|
||||
|
||||
TRACE(("USB Hub %d: Getting hub descriptor...\n", DeviceAddress()));
|
||||
TRACE("getting hub descriptor...\n");
|
||||
size_t actualLength;
|
||||
status_t status = GetDescriptor(USB_DESCRIPTOR_HUB, 0, 0,
|
||||
(void *)&fHubDescriptor, sizeof(usb_hub_descriptor), &actualLength);
|
||||
|
||||
// we need at least 8 bytes
|
||||
if (status < B_OK || actualLength < 8) {
|
||||
TRACE_ERROR(("USB Hub %d: Error getting hub descriptor\n", DeviceAddress()));
|
||||
TRACE_ERROR("error getting hub descriptor\n");
|
||||
return;
|
||||
}
|
||||
|
||||
TRACE(("USB Hub %d: hub descriptor (%ld bytes):\n", DeviceAddress(), actualLength));
|
||||
TRACE(("\tlength:..............%d\n", fHubDescriptor.length));
|
||||
TRACE(("\tdescriptor_type:.....0x%02x\n", fHubDescriptor.descriptor_type));
|
||||
TRACE(("\tnum_ports:...........%d\n", fHubDescriptor.num_ports));
|
||||
TRACE(("\tcharacteristics:.....0x%04x\n", fHubDescriptor.characteristics));
|
||||
TRACE(("\tpower_on_to_power_g:.%d\n", fHubDescriptor.power_on_to_power_good));
|
||||
TRACE(("\tdevice_removeable:...0x%02x\n", fHubDescriptor.device_removeable));
|
||||
TRACE(("\tpower_control_mask:..0x%02x\n", fHubDescriptor.power_control_mask));
|
||||
TRACE("hub descriptor (%ld bytes):\n", actualLength);
|
||||
TRACE("\tlength:..............%d\n", fHubDescriptor.length);
|
||||
TRACE("\tdescriptor_type:.....0x%02x\n", fHubDescriptor.descriptor_type);
|
||||
TRACE("\tnum_ports:...........%d\n", fHubDescriptor.num_ports);
|
||||
TRACE("\tcharacteristics:.....0x%04x\n", fHubDescriptor.characteristics);
|
||||
TRACE("\tpower_on_to_power_g:.%d\n", fHubDescriptor.power_on_to_power_good);
|
||||
TRACE("\tdevice_removeable:...0x%02x\n", fHubDescriptor.device_removeable);
|
||||
TRACE("\tpower_control_mask:..0x%02x\n", fHubDescriptor.power_control_mask);
|
||||
|
||||
if (fHubDescriptor.num_ports > USB_MAX_PORT_COUNT) {
|
||||
TRACE_ERROR(("USB Hub %d: hub supports more ports than we do (%d vs. %d)\n",
|
||||
DeviceAddress(), fHubDescriptor.num_ports, USB_MAX_PORT_COUNT));
|
||||
TRACE_ALWAYS("hub supports more ports than we do (%d vs. %d)\n",
|
||||
fHubDescriptor.num_ports, USB_MAX_PORT_COUNT);
|
||||
fHubDescriptor.num_ports = USB_MAX_PORT_COUNT;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ Hub::Hub(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
fInterruptPipe->QueueInterrupt(fInterruptStatus,
|
||||
sizeof(fInterruptStatus), InterruptCallback, this);
|
||||
} else {
|
||||
TRACE_ERROR(("USB Hub %d: no interrupt pipe found\n", DeviceAddress()));
|
||||
TRACE_ALWAYS("no interrupt pipe found\n");
|
||||
}
|
||||
|
||||
// Wait some time before powering up the ports
|
||||
@@ -83,14 +83,14 @@ Hub::Hub(Object *parent, int8 hubAddress, uint8 hubPort,
|
||||
USB_REQUEST_SET_FEATURE, PORT_POWER, i + 1, 0, NULL, 0, NULL);
|
||||
|
||||
if (status < B_OK)
|
||||
TRACE_ERROR(("USB Hub %d: power up failed on port %ld\n", DeviceAddress(), i));
|
||||
TRACE_ERROR("power up failed on port %ld\n", i);
|
||||
}
|
||||
|
||||
// Wait for power to stabilize
|
||||
snooze(fHubDescriptor.power_on_to_power_good * 2000);
|
||||
|
||||
fInitOK = true;
|
||||
TRACE(("USB Hub %d: initialised ok\n", DeviceAddress()));
|
||||
TRACE("initialised ok\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ Hub::UpdatePortStatus(uint8 index)
|
||||
4, &actualLength);
|
||||
|
||||
if (result < B_OK || actualLength < 4) {
|
||||
TRACE_ERROR(("USB Hub %d: error updating port status\n", DeviceAddress()));
|
||||
TRACE_ERROR("error updating port status\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ Hub::ResetPort(uint8 index)
|
||||
}
|
||||
|
||||
if ((fPortStatus[index].change & C_PORT_RESET) == 0) {
|
||||
TRACE_ERROR(("USB Hub %d: port %d won't reset\n", DeviceAddress(), index));
|
||||
TRACE_ERROR("port %d won't reset\n", index);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ Hub::ResetPort(uint8 index)
|
||||
|
||||
// wait for reset recovery
|
||||
snooze(USB_DELAY_PORT_RESET_RECOVERY);
|
||||
TRACE(("USB Hub %d: port %d was reset successfully\n", DeviceAddress(), index));
|
||||
TRACE("port %d was reset successfully\n", index);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -197,8 +197,10 @@ Hub::Explore(change_item **changeList)
|
||||
|
||||
#ifdef TRACE_USB
|
||||
if (fPortStatus[i].change) {
|
||||
TRACE(("USB Hub %d: port %ld: status: 0x%04x; change: 0x%04x\n", DeviceAddress(), i, fPortStatus[i].status, fPortStatus[i].change));
|
||||
TRACE(("USB Hub %d: device at port %ld: 0x%08lx\n", DeviceAddress(), i, fChildren[i]));
|
||||
TRACE("port %ld: status: 0x%04x; change: 0x%04x\n", i,
|
||||
fPortStatus[i].status, fPortStatus[i].change);
|
||||
TRACE("device at port %ld: %p (%ld)\n", i, fChildren[i],
|
||||
fChildren[i] != NULL ? fChildren[i]->USBID() : 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -210,7 +212,7 @@ Hub::Explore(change_item **changeList)
|
||||
|
||||
if (fPortStatus[i].status & PORT_STATUS_CONNECTION) {
|
||||
// new device attached!
|
||||
TRACE(("USB Hub %d: new device connected\n", DeviceAddress()));
|
||||
TRACE_ALWAYS("port %ld: new device connected\n", i);
|
||||
|
||||
// wait some time for the device to power up
|
||||
snooze(USB_DELAY_DEVICE_POWER_UP);
|
||||
@@ -218,7 +220,7 @@ Hub::Explore(change_item **changeList)
|
||||
// reset the port, this will also enable it
|
||||
result = ResetPort(i);
|
||||
if (result < B_OK) {
|
||||
TRACE_ERROR(("USB Hub %d: resetting port %ld failed\n", DeviceAddress(), i));
|
||||
TRACE_ERROR("resetting port %ld failed\n", i);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -228,12 +230,12 @@ Hub::Explore(change_item **changeList)
|
||||
|
||||
if ((fPortStatus[i].status & PORT_STATUS_CONNECTION) == 0) {
|
||||
// device has vanished after reset, ignore
|
||||
TRACE(("USB Hub %d: device disappeared on reset\n", DeviceAddress()));
|
||||
TRACE("device disappeared on reset\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if (fChildren[i]) {
|
||||
TRACE_ERROR(("USB Hub %d: new device on a port that is already in use\n", DeviceAddress()));
|
||||
if (fChildren[i] != NULL) {
|
||||
TRACE_ERROR("new device on a port that is already in use\n");
|
||||
fChildren[i]->Changed(changeList, false);
|
||||
fChildren[i] = NULL;
|
||||
}
|
||||
@@ -251,7 +253,7 @@ Hub::Explore(change_item **changeList)
|
||||
int8 hubAddress = HubAddress();
|
||||
uint8 hubPort = HubPort();
|
||||
if (Speed() == USB_SPEED_HIGHSPEED) {
|
||||
hubAddress = DeviceAddress();
|
||||
hubAddress = USBID();
|
||||
hubPort = i + 1;
|
||||
}
|
||||
|
||||
@@ -269,9 +271,9 @@ Hub::Explore(change_item **changeList)
|
||||
}
|
||||
} else {
|
||||
// Device removed...
|
||||
TRACE(("USB Hub %d: device removed\n", DeviceAddress()));
|
||||
if (fChildren[i]) {
|
||||
TRACE(("USB Hub %d: removing device 0x%08lx\n", DeviceAddress(), fChildren[i]));
|
||||
TRACE_ALWAYS("port %ld: device removed\n", i);
|
||||
if (fChildren[i] != NULL) {
|
||||
TRACE("removing device %p\n", fChildren[i]);
|
||||
fChildren[i]->Changed(changeList, false);
|
||||
fChildren[i] = NULL;
|
||||
}
|
||||
@@ -280,28 +282,28 @@ Hub::Explore(change_item **changeList)
|
||||
|
||||
// other port changes we do not really handle, report and clear them
|
||||
if (fPortStatus[i].change & PORT_STATUS_ENABLE) {
|
||||
TRACE_ERROR(("USB Hub %d: port %ld %sabled\n", DeviceAddress(), i, (fPortStatus[i].status & PORT_STATUS_ENABLE) ? "en" : "dis"));
|
||||
TRACE_ALWAYS("port %ld %sabled\n", i, (fPortStatus[i].status & PORT_STATUS_ENABLE) ? "en" : "dis");
|
||||
DefaultPipe()->SendRequest(USB_REQTYPE_CLASS | USB_REQTYPE_OTHER_OUT,
|
||||
USB_REQUEST_CLEAR_FEATURE, C_PORT_ENABLE, i + 1,
|
||||
0, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
if (fPortStatus[i].change & PORT_STATUS_SUSPEND) {
|
||||
TRACE_ERROR(("USB Hub %d: port %ld is %ssuspended\n", DeviceAddress(), i, (fPortStatus[i].status & PORT_STATUS_SUSPEND) ? "" : "not "));
|
||||
TRACE_ALWAYS("port %ld is %ssuspended\n", i, (fPortStatus[i].status & PORT_STATUS_SUSPEND) ? "" : "not ");
|
||||
DefaultPipe()->SendRequest(USB_REQTYPE_CLASS | USB_REQTYPE_OTHER_OUT,
|
||||
USB_REQUEST_CLEAR_FEATURE, C_PORT_SUSPEND, i + 1,
|
||||
0, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
if (fPortStatus[i].change & PORT_STATUS_OVER_CURRENT) {
|
||||
TRACE_ERROR(("USB Hub %d: port %ld is %sin an over current state\n", DeviceAddress(), i, (fPortStatus[i].status & PORT_STATUS_OVER_CURRENT) ? "" : "not "));
|
||||
TRACE_ALWAYS("port %ld is %sin an over current state\n", i, (fPortStatus[i].status & PORT_STATUS_OVER_CURRENT) ? "" : "not ");
|
||||
DefaultPipe()->SendRequest(USB_REQTYPE_CLASS | USB_REQTYPE_OTHER_OUT,
|
||||
USB_REQUEST_CLEAR_FEATURE, C_PORT_OVER_CURRENT, i + 1,
|
||||
0, NULL, 0, NULL);
|
||||
}
|
||||
|
||||
if (fPortStatus[i].change & PORT_RESET) {
|
||||
TRACE_ERROR(("USB Hub %d: port %ld was reset\n", DeviceAddress(), i));
|
||||
TRACE_ALWAYS("port %ld was reset\n", i);
|
||||
DefaultPipe()->SendRequest(USB_REQTYPE_CLASS | USB_REQTYPE_OTHER_OUT,
|
||||
USB_REQUEST_CLEAR_FEATURE, C_PORT_RESET, i + 1,
|
||||
0, NULL, 0, NULL);
|
||||
@@ -322,7 +324,7 @@ void
|
||||
Hub::InterruptCallback(void *cookie, status_t status, void *data,
|
||||
size_t actualLength)
|
||||
{
|
||||
TRACE(("USB Hub %d: interrupt callback!\n", ((Hub *)data)->DeviceAddress()));
|
||||
TRACE_STATIC((Hub *)cookie, "interrupt callback!\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -347,7 +349,7 @@ Hub::ReportDevice(usb_support_descriptor *supportDescriptors,
|
||||
uint32 supportDescriptorCount, const usb_notify_hooks *hooks,
|
||||
usb_driver_cookie **cookies, bool added, bool recursive)
|
||||
{
|
||||
TRACE(("USB Hub %d: reporting hub\n", DeviceAddress()));
|
||||
TRACE("reporting hub\n");
|
||||
|
||||
// Report ourselfs first
|
||||
status_t result = Device::ReportDevice(supportDescriptors,
|
||||
|
||||
@@ -13,12 +13,14 @@ Interface::Interface(Object *parent, uint8 interfaceIndex)
|
||||
: Object(parent),
|
||||
fInterfaceIndex(interfaceIndex)
|
||||
{
|
||||
TRACE("creating interface\n");
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
Interface::SetFeature(uint16 selector)
|
||||
{
|
||||
TRACE("set feature %u\n", selector);
|
||||
return ((Device *)Parent())->DefaultPipe()->SendRequest(
|
||||
USB_REQTYPE_STANDARD | USB_REQTYPE_INTERFACE_OUT,
|
||||
USB_REQUEST_SET_FEATURE,
|
||||
@@ -34,6 +36,7 @@ Interface::SetFeature(uint16 selector)
|
||||
status_t
|
||||
Interface::ClearFeature(uint16 selector)
|
||||
{
|
||||
TRACE("clear feature %u\n", selector);
|
||||
return ((Device *)Parent())->DefaultPipe()->SendRequest(
|
||||
USB_REQTYPE_STANDARD | USB_REQTYPE_INTERFACE_OUT,
|
||||
USB_REQUEST_CLEAR_FEATURE,
|
||||
@@ -49,6 +52,7 @@ Interface::ClearFeature(uint16 selector)
|
||||
status_t
|
||||
Interface::GetStatus(uint16 *status)
|
||||
{
|
||||
TRACE("get status\n");
|
||||
return ((Device *)Parent())->DefaultPipe()->SendRequest(
|
||||
USB_REQTYPE_STANDARD | USB_REQTYPE_INTERFACE_IN,
|
||||
USB_REQUEST_GET_STATUS,
|
||||
|
||||
@@ -37,7 +37,7 @@ status_t
|
||||
Object::SetFeature(uint16 selector)
|
||||
{
|
||||
// to be implemented in subclasses
|
||||
TRACE_ERROR(("USB Object: set feature called\n"));
|
||||
TRACE_ERROR("set feature called\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ status_t
|
||||
Object::ClearFeature(uint16 selector)
|
||||
{
|
||||
// to be implemented in subclasses
|
||||
TRACE_ERROR(("USB Object: clear feature called\n"));
|
||||
TRACE_ERROR("clear feature called\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,6 @@ status_t
|
||||
Object::GetStatus(uint16 *status)
|
||||
{
|
||||
// to be implemented in subclasses
|
||||
TRACE_ERROR(("USB Object: get status called\n"));
|
||||
TRACE_ERROR("get status called\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ Pipe::CancelQueuedTransfers(bool force)
|
||||
status_t
|
||||
Pipe::SetFeature(uint16 selector)
|
||||
{
|
||||
TRACE("set feature %u\n", selector);
|
||||
return ((Device *)Parent())->DefaultPipe()->SendRequest(
|
||||
USB_REQTYPE_STANDARD | USB_REQTYPE_ENDPOINT_OUT,
|
||||
USB_REQUEST_SET_FEATURE,
|
||||
@@ -89,6 +90,7 @@ Pipe::ClearFeature(uint16 selector)
|
||||
if (selector == USB_FEATURE_ENDPOINT_HALT)
|
||||
SetDataToggle(false);
|
||||
|
||||
TRACE("clear feature %u\n", selector);
|
||||
return ((Device *)Parent())->DefaultPipe()->SendRequest(
|
||||
USB_REQTYPE_STANDARD | USB_REQTYPE_ENDPOINT_OUT,
|
||||
USB_REQUEST_CLEAR_FEATURE,
|
||||
@@ -105,6 +107,7 @@ Pipe::ClearFeature(uint16 selector)
|
||||
status_t
|
||||
Pipe::GetStatus(uint16 *status)
|
||||
{
|
||||
TRACE("get status\n");
|
||||
return ((Device *)Parent())->DefaultPipe()->SendRequest(
|
||||
USB_REQTYPE_STANDARD | USB_REQTYPE_ENDPOINT_IN,
|
||||
USB_REQUEST_GET_STATUS,
|
||||
@@ -336,7 +339,7 @@ ControlPipe::SendRequest(uint8 requestType, uint8 request, uint16 value,
|
||||
// The sem will be released unconditionally in the callback after the
|
||||
// result data was filled in. Use a 1 second timeout for control transfers.
|
||||
if (acquire_sem_etc(fNotifySem, 1, B_RELATIVE_TIMEOUT, 1000000) < B_OK) {
|
||||
TRACE_ERROR(("USB ControlPipe: timeout waiting for queued request to complete\n"));
|
||||
TRACE_ERROR("timeout waiting for queued request to complete\n");
|
||||
|
||||
CancelQueuedTransfers(false);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ Stack::Stack()
|
||||
fObjectArray(NULL),
|
||||
fDriverList(NULL)
|
||||
{
|
||||
TRACE(("USB Stack: stack init\n"));
|
||||
TRACE("stack init\n");
|
||||
|
||||
mutex_init(&fStackLock, "usb stack lock");
|
||||
mutex_init(&fExploreLock, "usb explore lock");
|
||||
@@ -34,7 +34,7 @@ Stack::Stack()
|
||||
size_t objectArraySize = fObjectMaxCount * sizeof(Object *);
|
||||
fObjectArray = (Object **)malloc(objectArraySize);
|
||||
if (fObjectArray == NULL) {
|
||||
TRACE_ERROR(("USB Stack: failed to allocate object array\n"));
|
||||
TRACE_ERROR("failed to allocate object array\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ Stack::Stack()
|
||||
fAllocator = new(std::nothrow) PhysicalMemoryAllocator("USB Stack Allocator",
|
||||
8, B_PAGE_SIZE * 4, 64);
|
||||
if (!fAllocator || fAllocator->InitCheck() < B_OK) {
|
||||
TRACE_ERROR(("USB Stack: failed to allocate the allocator\n"));
|
||||
TRACE_ERROR("failed to allocate the allocator\n");
|
||||
delete fAllocator;
|
||||
fAllocator = NULL;
|
||||
return;
|
||||
@@ -66,25 +66,25 @@ Stack::Stack()
|
||||
NULL
|
||||
};
|
||||
|
||||
TRACE(("USB Stack: looking for host controller modules\n"));
|
||||
TRACE("looking for host controller modules\n");
|
||||
for (uint32 i = 0; moduleNames[i]; i++) {
|
||||
TRACE(("USB Stack: looking for module %s\n", moduleNames[i]));
|
||||
TRACE("looking for module %s\n", moduleNames[i]);
|
||||
|
||||
usb_host_controller_info *module = NULL;
|
||||
if (get_module(moduleNames[i], (module_info **)&module) != B_OK)
|
||||
continue;
|
||||
|
||||
TRACE(("USB Stack: adding module %s\n", moduleNames[i]));
|
||||
TRACE("adding module %s\n", moduleNames[i]);
|
||||
if (module->add_to(this) < B_OK) {
|
||||
put_module(moduleNames[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
TRACE(("USB Stack: module %s successfully loaded\n", moduleNames[i]));
|
||||
TRACE("module %s successfully loaded\n", moduleNames[i]);
|
||||
}
|
||||
|
||||
if (fBusManagers.Count() == 0) {
|
||||
TRACE_ERROR(("USB Stack: no bus managers available\n"));
|
||||
TRACE_ERROR("no bus managers available\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ Stack::GetUSBID(Object *object)
|
||||
id = (id + 1) % fObjectMaxCount;
|
||||
}
|
||||
|
||||
TRACE_ERROR(("USB Stack: the stack did run out of usb_ids\n"));
|
||||
TRACE_ERROR("the stack did run out of usb_ids\n");
|
||||
Unlock();
|
||||
return 0;
|
||||
}
|
||||
@@ -177,7 +177,7 @@ Stack::PutUSBID(usb_id id)
|
||||
return;
|
||||
|
||||
if (id >= fObjectMaxCount) {
|
||||
TRACE_ERROR(("USB Stack: tried to put an invalid usb_id\n"));
|
||||
TRACE_ERROR("tried to put an invalid usb_id\n");
|
||||
Unlock();
|
||||
return;
|
||||
}
|
||||
@@ -194,7 +194,7 @@ Stack::GetObject(usb_id id)
|
||||
return NULL;
|
||||
|
||||
if (id >= fObjectMaxCount) {
|
||||
TRACE_ERROR(("USB Stack: tried to get object with invalid usb_id\n"));
|
||||
TRACE_ERROR("tried to get object with invalid usb_id\n");
|
||||
Unlock();
|
||||
return NULL;
|
||||
}
|
||||
@@ -285,7 +285,7 @@ area_id
|
||||
Stack::AllocateArea(void **logicalAddress, void **physicalAddress, size_t size,
|
||||
const char *name)
|
||||
{
|
||||
TRACE(("USB Stack: allocating %ld bytes for %s\n", size, name));
|
||||
TRACE("allocating %ld bytes for %s\n", size, name);
|
||||
|
||||
void *logAddress;
|
||||
size = (size + B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);
|
||||
@@ -293,7 +293,7 @@ Stack::AllocateArea(void **logicalAddress, void **physicalAddress, size_t size,
|
||||
B_CONTIGUOUS, 0);
|
||||
|
||||
if (area < B_OK) {
|
||||
TRACE_ERROR(("USB Stack: couldn't allocate area %s\n", name));
|
||||
TRACE_ERROR("couldn't allocate area %s\n", name);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -301,7 +301,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_ERROR(("USB Stack: couldn't map area %s\n", name));
|
||||
TRACE_ERROR("couldn't map area %s\n", name);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -312,8 +312,8 @@ Stack::AllocateArea(void **logicalAddress, void **physicalAddress, size_t size,
|
||||
if (physicalAddress)
|
||||
*physicalAddress = physicalEntry.address;
|
||||
|
||||
TRACE(("USB Stack: area = 0x%08lx, size = %ld, log = 0x%08lx, phy = 0x%08lx\n",
|
||||
area, size, logAddress, physicalEntry.address));
|
||||
TRACE("area = %ld, size = %ld, log = %p, phy = %p\n",
|
||||
area, size, logAddress, physicalEntry.address);
|
||||
return area;
|
||||
}
|
||||
|
||||
@@ -321,7 +321,7 @@ Stack::AllocateArea(void **logicalAddress, void **physicalAddress, size_t size,
|
||||
void
|
||||
Stack::NotifyDeviceChange(Device *device, rescan_item **rescanList, bool added)
|
||||
{
|
||||
TRACE(("USB Stack: device %s\n", added ? "added" : "removed"));
|
||||
TRACE("device %s\n", added ? "added" : "removed");
|
||||
|
||||
usb_driver_info *element = fDriverList;
|
||||
while (element) {
|
||||
@@ -393,7 +393,7 @@ Stack::RegisterDriver(const char *driverName,
|
||||
const usb_support_descriptor *descriptors,
|
||||
size_t descriptorCount, const char *republishDriverName)
|
||||
{
|
||||
TRACE(("USB Stack: register driver \"%s\"\n", driverName));
|
||||
TRACE("register driver \"%s\"\n", driverName);
|
||||
if (!driverName)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
@@ -457,7 +457,7 @@ Stack::RegisterDriver(const char *driverName,
|
||||
status_t
|
||||
Stack::InstallNotify(const char *driverName, const usb_notify_hooks *hooks)
|
||||
{
|
||||
TRACE(("USB Stack: installing notify hooks for driver \"%s\"\n", driverName));
|
||||
TRACE("installing notify hooks for driver \"%s\"\n", driverName);
|
||||
|
||||
usb_driver_info *element = fDriverList;
|
||||
while (element) {
|
||||
@@ -492,7 +492,7 @@ Stack::InstallNotify(const char *driverName, const usb_notify_hooks *hooks)
|
||||
status_t
|
||||
Stack::UninstallNotify(const char *driverName)
|
||||
{
|
||||
TRACE(("USB Stack: uninstalling notify hooks for driver \"%s\"\n", driverName));
|
||||
TRACE("uninstalling notify hooks for driver \"%s\"\n", driverName);
|
||||
|
||||
usb_driver_info *element = fDriverList;
|
||||
while (element) {
|
||||
|
||||
@@ -71,7 +71,7 @@ Transfer::SetData(uint8 *data, size_t dataLength)
|
||||
// Calculate the bandwidth (only if it is not a bulk transfer)
|
||||
if (!(fPipe->Type() & USB_OBJECT_BULK_PIPE)) {
|
||||
if (_CalculateBandwidth() < B_OK)
|
||||
TRACE_ERROR(("USB Transfer: can't calculate bandwidth\n"));
|
||||
TRACE_ERROR("can't calculate bandwidth\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +135,7 @@ Transfer::InitKernelAccess()
|
||||
if (IS_USER_ADDRESS(vector[i].iov_base)) {
|
||||
fUserArea = area_for(vector[i].iov_base);
|
||||
if (fUserArea < B_OK) {
|
||||
TRACE_ERROR(("USB Transfer: failed to find area for user"
|
||||
" space buffer!\n"));
|
||||
TRACE_ERROR("failed to find area for user space buffer!\n");
|
||||
return B_BAD_ADDRESS;
|
||||
}
|
||||
break;
|
||||
@@ -149,7 +148,7 @@ Transfer::InitKernelAccess()
|
||||
|
||||
area_info areaInfo;
|
||||
if (fUserArea < B_OK || get_area_info(fUserArea, &areaInfo) < B_OK) {
|
||||
TRACE_ERROR(("USB Transfer: couldn't get user area info\n"));
|
||||
TRACE_ERROR("couldn't get user area info\n");
|
||||
return B_BAD_ADDRESS;
|
||||
}
|
||||
|
||||
@@ -158,7 +157,7 @@ Transfer::InitKernelAccess()
|
||||
|
||||
if ((size_t)vector[i].iov_base > areaInfo.size
|
||||
|| (size_t)vector[i].iov_base + vector[i].iov_len > areaInfo.size) {
|
||||
TRACE_ERROR(("USB Transfer: data buffer spans across multiple areas!\n"));
|
||||
TRACE_ERROR("data buffer spans across multiple areas!\n");
|
||||
return B_BAD_ADDRESS;
|
||||
}
|
||||
}
|
||||
@@ -264,7 +263,7 @@ Transfer::_CalculateBandwidth()
|
||||
|
||||
default:
|
||||
// We should never get here
|
||||
TRACE(("USB Transfer: speed unknown"));
|
||||
TRACE("speed unknown");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "usb_p.h"
|
||||
#include <USB_rle.h>
|
||||
|
||||
#define USB_MODULE_NAME "module"
|
||||
|
||||
Stack *gUSBStack = NULL;
|
||||
|
||||
@@ -20,7 +21,7 @@ bus_std_ops(int32 op, ...)
|
||||
{
|
||||
switch (op) {
|
||||
case B_MODULE_INIT: {
|
||||
TRACE(("usb_module: init\n"));
|
||||
TRACE_MODULE("init\n");
|
||||
if (gUSBStack)
|
||||
return B_OK;
|
||||
|
||||
@@ -35,7 +36,7 @@ bus_std_ops(int32 op, ...)
|
||||
if (shared >= B_OK && clone_area("usb stack clone", &address,
|
||||
B_ANY_KERNEL_ADDRESS, B_KERNEL_READ_AREA, shared) >= B_OK) {
|
||||
gUSBStack = *((Stack **)address);
|
||||
TRACE(("usb_module: found shared stack at %p\n", gUSBStack));
|
||||
TRACE_MODULE("found shared stack at %p\n", gUSBStack);
|
||||
return B_OK;
|
||||
}
|
||||
#endif
|
||||
@@ -47,7 +48,7 @@ bus_std_ops(int32 op, ...)
|
||||
#endif
|
||||
#endif
|
||||
Stack *stack = new(std::nothrow) Stack();
|
||||
TRACE(("usb_module: stack created %p\n", stack));
|
||||
TRACE_MODULE("usb_module: stack created %p\n", stack);
|
||||
if (!stack)
|
||||
return B_NO_MEMORY;
|
||||
|
||||
@@ -69,7 +70,7 @@ bus_std_ops(int32 op, ...)
|
||||
}
|
||||
|
||||
case B_MODULE_UNINIT:
|
||||
TRACE(("usb_module: uninit\n"));
|
||||
TRACE_MODULE("uninit\n");
|
||||
delete gUSBStack;
|
||||
gUSBStack = NULL;
|
||||
break;
|
||||
@@ -109,7 +110,7 @@ uninstall_notify(const char *driverName)
|
||||
const usb_device_descriptor *
|
||||
get_device_descriptor(usb_device device)
|
||||
{
|
||||
TRACE(("usb_module: get_device_descriptor(%ld)\n", device));
|
||||
TRACE_MODULE("get_device_descriptor(%ld)\n", device);
|
||||
Object *object = gUSBStack->GetObject(device);
|
||||
if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0)
|
||||
return NULL;
|
||||
@@ -121,7 +122,7 @@ get_device_descriptor(usb_device device)
|
||||
const usb_configuration_info *
|
||||
get_nth_configuration(usb_device device, uint32 index)
|
||||
{
|
||||
TRACE(("usb_module: get_nth_configuration(%ld, %d)\n", device, index));
|
||||
TRACE_MODULE("get_nth_configuration(%ld, %lu)\n", device, index);
|
||||
Object *object = gUSBStack->GetObject(device);
|
||||
if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0)
|
||||
return NULL;
|
||||
@@ -133,7 +134,7 @@ get_nth_configuration(usb_device device, uint32 index)
|
||||
const usb_configuration_info *
|
||||
get_configuration(usb_device device)
|
||||
{
|
||||
TRACE(("usb_module: get_configuration(%ld)\n", device));
|
||||
TRACE_MODULE("get_configuration(%ld)\n", device);
|
||||
Object *object = gUSBStack->GetObject(device);
|
||||
if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0)
|
||||
return NULL;
|
||||
@@ -146,7 +147,7 @@ status_t
|
||||
set_configuration(usb_device device,
|
||||
const usb_configuration_info *configuration)
|
||||
{
|
||||
TRACE(("usb_module: set_configuration(%ld, 0x%08lx)\n", device, configuration));
|
||||
TRACE_MODULE("set_configuration(%ld, %p)\n", device, configuration);
|
||||
Object *object = gUSBStack->GetObject(device);
|
||||
if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0)
|
||||
return B_DEV_INVALID_PIPE;
|
||||
@@ -158,7 +159,7 @@ set_configuration(usb_device device,
|
||||
status_t
|
||||
set_alt_interface(usb_device device, const usb_interface_info *interface)
|
||||
{
|
||||
TRACE(("usb_module: set_alt_interface(%ld, 0x%08lx)\n", device, interface));
|
||||
TRACE_MODULE("set_alt_interface(%ld, %p)\n", device, interface);
|
||||
Object *object = gUSBStack->GetObject(device);
|
||||
if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0)
|
||||
return B_DEV_INVALID_PIPE;
|
||||
@@ -170,7 +171,7 @@ set_alt_interface(usb_device device, const usb_interface_info *interface)
|
||||
status_t
|
||||
set_feature(usb_id handle, uint16 selector)
|
||||
{
|
||||
TRACE(("usb_module: set_feature(%ld, %d)\n", handle, selector));
|
||||
TRACE_MODULE("set_feature(%ld, %d)\n", handle, selector);
|
||||
Object *object = gUSBStack->GetObject(handle);
|
||||
if (!object)
|
||||
return B_DEV_INVALID_PIPE;
|
||||
@@ -182,7 +183,7 @@ set_feature(usb_id handle, uint16 selector)
|
||||
status_t
|
||||
clear_feature(usb_id handle, uint16 selector)
|
||||
{
|
||||
TRACE(("usb_module: clear_feature(%ld, %d)\n", handle, selector));
|
||||
TRACE_MODULE("clear_feature(%ld, %d)\n", handle, selector);
|
||||
Object *object = gUSBStack->GetObject(handle);
|
||||
if (!object)
|
||||
return B_DEV_INVALID_PIPE;
|
||||
@@ -194,7 +195,7 @@ clear_feature(usb_id handle, uint16 selector)
|
||||
status_t
|
||||
get_status(usb_id handle, uint16 *status)
|
||||
{
|
||||
TRACE(("usb_module: get_status(%ld, 0x%08lx)\n", handle, status));
|
||||
TRACE_MODULE("get_status(%ld, %p)\n", handle, status);
|
||||
if (!status)
|
||||
return B_BAD_VALUE;
|
||||
|
||||
@@ -210,7 +211,8 @@ status_t
|
||||
get_descriptor(usb_device device, uint8 type, uint8 index, uint16 languageID,
|
||||
void *data, size_t dataLength, size_t *actualLength)
|
||||
{
|
||||
TRACE(("usb_module: get_descriptor(%ld, 0x%02x, 0x%02x, 0x%04x, 0x%08lx, %ld, 0x%08lx)\n", device, type, index, languageID, data, dataLength, actualLength));
|
||||
TRACE_MODULE("get_descriptor(%ld, 0x%02x, 0x%02x, 0x%04x, %p, %ld, %p)\n",
|
||||
device, type, index, languageID, data, dataLength, actualLength);
|
||||
Object *object = gUSBStack->GetObject(device);
|
||||
if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0)
|
||||
return B_DEV_INVALID_PIPE;
|
||||
@@ -224,7 +226,8 @@ status_t
|
||||
send_request(usb_device device, uint8 requestType, uint8 request,
|
||||
uint16 value, uint16 index, uint16 length, void *data, size_t *actualLength)
|
||||
{
|
||||
TRACE(("usb_module: send_request(%ld, 0x%02x, 0x%02x, 0x%04x, 0x%04x, %d, 0x%08lx, 0x%08lx)\n", device, requestType, request, value, index, length, data, actualLength));
|
||||
TRACE_MODULE("send_request(%ld, 0x%02x, 0x%02x, 0x%04x, 0x%04x, %d, %p, %p)\n",
|
||||
device, requestType, request, value, index, length, data, actualLength);
|
||||
Object *object = gUSBStack->GetObject(device);
|
||||
if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0)
|
||||
return B_DEV_INVALID_PIPE;
|
||||
@@ -239,7 +242,9 @@ queue_request(usb_device device, uint8 requestType, uint8 request,
|
||||
uint16 value, uint16 index, uint16 length, void *data,
|
||||
usb_callback_func callback, void *callbackCookie)
|
||||
{
|
||||
TRACE(("usb_module: queue_request(%ld, 0x%02x, 0x%02x, 0x%04x, 0x%04x, %ld, 0x%08lx, 0x%08lx, 0x%08lx)\n", device, requestType, request, value, index, length, data, callback, callbackCookie));
|
||||
TRACE_MODULE("queue_request(%ld, 0x%02x, 0x%02x, 0x%04x, 0x%04x, %u, %p, %p, %p)\n",
|
||||
device, requestType, request, value, index, length, data, callback,
|
||||
callbackCookie);
|
||||
Object *object = gUSBStack->GetObject(device);
|
||||
if (!object || (object->Type() & USB_OBJECT_DEVICE) == 0)
|
||||
return B_DEV_INVALID_PIPE;
|
||||
@@ -253,7 +258,8 @@ status_t
|
||||
queue_interrupt(usb_pipe pipe, void *data, size_t dataLength,
|
||||
usb_callback_func callback, void *callbackCookie)
|
||||
{
|
||||
TRACE(("usb_module: queue_interrupt(%ld, 0x%08lx, %ld, 0x%08lx, 0x%08lx)\n", pipe, data, dataLength, callback, callbackCookie));
|
||||
TRACE_MODULE("queue_interrupt(%ld, %p, %ld, %p, %p)\n",
|
||||
pipe, data, dataLength, callback, callbackCookie);
|
||||
Object *object = gUSBStack->GetObject(pipe);
|
||||
if (!object || (object->Type() & USB_OBJECT_INTERRUPT_PIPE) == 0)
|
||||
return B_DEV_INVALID_PIPE;
|
||||
@@ -267,7 +273,8 @@ status_t
|
||||
queue_bulk(usb_pipe pipe, void *data, size_t dataLength,
|
||||
usb_callback_func callback, void *callbackCookie)
|
||||
{
|
||||
TRACE(("usb_module: queue_bulk(%ld, 0x%08lx, %ld, 0x%08lx, 0x%08lx)\n", pipe, data, dataLength, callback, callbackCookie));
|
||||
TRACE_MODULE("queue_bulk(%ld, %p, %ld, %p, %p)\n",
|
||||
pipe, data, dataLength, callback, callbackCookie);
|
||||
Object *object = gUSBStack->GetObject(pipe);
|
||||
if (!object || (object->Type() & USB_OBJECT_BULK_PIPE) == 0)
|
||||
return B_DEV_INVALID_PIPE;
|
||||
@@ -281,7 +288,8 @@ status_t
|
||||
queue_bulk_v(usb_pipe pipe, iovec *vector, size_t vectorCount,
|
||||
usb_callback_func callback, void *callbackCookie)
|
||||
{
|
||||
TRACE(("usb_module: queue_bulk(%ld, 0x%08lx, %ld, 0x%08lx, 0x%08lx)\n", pipe, vector, vectorCount, callback, callbackCookie));
|
||||
TRACE_MODULE("queue_bulk(%ld, %p, %ld, %p, %p)\n",
|
||||
pipe, vector, vectorCount, callback, callbackCookie);
|
||||
Object *object = gUSBStack->GetObject(pipe);
|
||||
if (!object || (object->Type() & USB_OBJECT_BULK_PIPE) == 0)
|
||||
return B_DEV_INVALID_PIPE;
|
||||
@@ -297,7 +305,9 @@ queue_isochronous(usb_pipe pipe, void *data, size_t dataLength,
|
||||
uint32 *startingFrameNumber, uint32 flags, usb_callback_func callback,
|
||||
void *callbackCookie)
|
||||
{
|
||||
TRACE(("usb_module: queue_isochronous(%ld, 0x%08lx, %ld, 0x%08lx, %ld, 0x%08lx, 0x%08lx, 0x%08lx, 0x%08lx)\n", pipe, data, dataLength, packetDesc, packetCount, startingFrameNumber, flags, callback, callbackCookie));
|
||||
TRACE_MODULE("queue_isochronous(%ld, %p, %ld, %p, %ld, %p, 0x%08lx, %p, %p)\n",
|
||||
pipe, data, dataLength, packetDesc, packetCount, startingFrameNumber,
|
||||
flags, callback, callbackCookie);
|
||||
Object *object = gUSBStack->GetObject(pipe);
|
||||
if (!object || (object->Type() & USB_OBJECT_ISO_PIPE) == 0)
|
||||
return B_DEV_INVALID_PIPE;
|
||||
@@ -312,7 +322,8 @@ status_t
|
||||
set_pipe_policy(usb_pipe pipe, uint8 maxQueuedPackets,
|
||||
uint16 maxBufferDurationMS, uint16 sampleSize)
|
||||
{
|
||||
TRACE(("usb_module: set_pipe_policy(%ld, %d, %d, %d)\n", pipe, maxQueuedPackets, maxBufferDurationMS, sampleSize));
|
||||
TRACE_MODULE("set_pipe_policy(%ld, %d, %d, %d)\n", pipe, maxQueuedPackets,
|
||||
maxBufferDurationMS, sampleSize);
|
||||
Object *object = gUSBStack->GetObject(pipe);
|
||||
if (!object || (object->Type() & USB_OBJECT_ISO_PIPE) == 0)
|
||||
return B_DEV_INVALID_PIPE;
|
||||
@@ -325,7 +336,7 @@ set_pipe_policy(usb_pipe pipe, uint8 maxQueuedPackets,
|
||||
status_t
|
||||
cancel_queued_transfers(usb_pipe pipe)
|
||||
{
|
||||
TRACE(("usb_module: cancel_queued_transfers(%ld)\n", pipe));
|
||||
TRACE_MODULE("cancel_queued_transfers(%ld)\n", pipe);
|
||||
Object *object = gUSBStack->GetObject(pipe);
|
||||
if (!object || (object->Type() & USB_OBJECT_PIPE) == 0)
|
||||
return B_DEV_INVALID_PIPE;
|
||||
@@ -337,7 +348,7 @@ cancel_queued_transfers(usb_pipe pipe)
|
||||
status_t
|
||||
usb_ioctl(uint32 opcode, void *buffer, size_t bufferSize)
|
||||
{
|
||||
TRACE(("usb_module: usb_ioctl(0x%08lx, 0x%08lx, %ld)\n", opcode, buffer, bufferSize));
|
||||
TRACE_MODULE("usb_ioctl(%lu, %p, %ld)\n", opcode, buffer, bufferSize);
|
||||
|
||||
switch (opcode) {
|
||||
case 'DNAM': {
|
||||
|
||||
@@ -14,15 +14,28 @@
|
||||
#include "usbspec_p.h"
|
||||
#include <lock.h>
|
||||
|
||||
|
||||
#define TRACE_OUTPUT(x, y, z...) \
|
||||
{ \
|
||||
dprintf("usb %s%s %ld: ", y, (x)->TypeName(), (x)->USBID()); \
|
||||
dprintf(z); \
|
||||
}
|
||||
|
||||
//#define TRACE_USB
|
||||
#ifdef TRACE_USB
|
||||
#define TRACE(x) dprintf x
|
||||
#define TRACE_ERROR(x) dprintf x
|
||||
#define TRACE(x...) TRACE_OUTPUT(this, "", x)
|
||||
#define TRACE_STATIC(x, y...) TRACE_OUTPUT(x, "", y)
|
||||
#define TRACE_MODULE(x...) dprintf("usb "USB_MODULE_NAME": "x)
|
||||
#else
|
||||
#define TRACE(x) /* nothing */
|
||||
#define TRACE_ERROR(x) dprintf x
|
||||
#define TRACE(x...) /* nothing */
|
||||
#define TRACE_STATIC(x, y...) /* nothing */
|
||||
#define TRACE_MODULE(x...) /* nothing */
|
||||
#endif
|
||||
|
||||
#define TRACE_ALWAYS(x...) TRACE_OUTPUT(this, "", x)
|
||||
#define TRACE_ERROR(x...) TRACE_OUTPUT(this, "error ", x)
|
||||
#define TRACE_MODULE_ALWAYS(x...) dprintf("usb "USB_MODULE_NAME": "x)
|
||||
#define TRACE_MODULE_ERROR(x...) dprintf("usb "USB_MODULE_NAME": "x)
|
||||
|
||||
class Hub;
|
||||
class Stack;
|
||||
@@ -36,40 +49,40 @@ class PhysicalMemoryAllocator;
|
||||
|
||||
|
||||
struct usb_host_controller_info {
|
||||
module_info info;
|
||||
status_t (*control)(uint32 op, void *data, size_t length);
|
||||
status_t (*add_to)(Stack *stack);
|
||||
module_info info;
|
||||
status_t (*control)(uint32 op, void *data, size_t length);
|
||||
status_t (*add_to)(Stack *stack);
|
||||
};
|
||||
|
||||
|
||||
struct usb_driver_cookie {
|
||||
usb_id device;
|
||||
void *cookie;
|
||||
usb_driver_cookie *link;
|
||||
usb_id device;
|
||||
void *cookie;
|
||||
usb_driver_cookie *link;
|
||||
};
|
||||
|
||||
|
||||
struct usb_driver_info {
|
||||
const char *driver_name;
|
||||
usb_support_descriptor *support_descriptors;
|
||||
uint32 support_descriptor_count;
|
||||
const char *republish_driver_name;
|
||||
usb_notify_hooks notify_hooks;
|
||||
usb_driver_cookie *cookies;
|
||||
usb_driver_info *link;
|
||||
const char *driver_name;
|
||||
usb_support_descriptor *support_descriptors;
|
||||
uint32 support_descriptor_count;
|
||||
const char *republish_driver_name;
|
||||
usb_notify_hooks notify_hooks;
|
||||
usb_driver_cookie *cookies;
|
||||
usb_driver_info *link;
|
||||
};
|
||||
|
||||
|
||||
struct change_item {
|
||||
bool added;
|
||||
Device *device;
|
||||
change_item *link;
|
||||
bool added;
|
||||
Device *device;
|
||||
change_item *link;
|
||||
};
|
||||
|
||||
|
||||
struct rescan_item {
|
||||
const char *name;
|
||||
rescan_item *link;
|
||||
const char *name;
|
||||
rescan_item *link;
|
||||
};
|
||||
|
||||
|
||||
@@ -111,11 +124,11 @@ public:
|
||||
|
||||
usb_id GetUSBID(Object *object);
|
||||
void PutUSBID(usb_id id);
|
||||
Object *GetObject(usb_id id);
|
||||
Object * GetObject(usb_id id);
|
||||
|
||||
void AddBusManager(BusManager *bus);
|
||||
int32 IndexOfBusManager(BusManager *bus);
|
||||
BusManager *BusManagerAt(int32 index);
|
||||
BusManager * BusManagerAt(int32 index);
|
||||
|
||||
status_t AllocateChunk(void **logicalAddress,
|
||||
void **physicalAddress, size_t size);
|
||||
@@ -141,6 +154,9 @@ public:
|
||||
const usb_notify_hooks *hooks);
|
||||
status_t UninstallNotify(const char *driverName);
|
||||
|
||||
usb_id USBID() { return 0; };
|
||||
const char * TypeName() { return "stack"; };
|
||||
|
||||
private:
|
||||
static int32 ExploreThread(void *data);
|
||||
|
||||
@@ -151,13 +167,13 @@ static int32 ExploreThread(void *data);
|
||||
|
||||
mutex fStackLock;
|
||||
mutex fExploreLock;
|
||||
PhysicalMemoryAllocator *fAllocator;
|
||||
PhysicalMemoryAllocator * fAllocator;
|
||||
|
||||
uint32 fObjectIndex;
|
||||
uint32 fObjectMaxCount;
|
||||
Object **fObjectArray;
|
||||
Object ** fObjectArray;
|
||||
|
||||
usb_driver_info *fDriverList;
|
||||
usb_driver_info * fDriverList;
|
||||
};
|
||||
|
||||
|
||||
@@ -179,7 +195,7 @@ virtual status_t InitCheck();
|
||||
int8 AllocateAddress();
|
||||
void FreeAddress(int8 address);
|
||||
|
||||
Device *AllocateDevice(Hub *parent,
|
||||
Device * AllocateDevice(Hub *parent,
|
||||
int8 hubAddress, uint8 hubPort,
|
||||
usb_speed speed);
|
||||
void FreeDevice(Device *device);
|
||||
@@ -194,25 +210,29 @@ virtual status_t CancelQueuedTransfers(Pipe *pipe,
|
||||
virtual status_t NotifyPipeChange(Pipe *pipe,
|
||||
usb_change change);
|
||||
|
||||
Object *RootObject() { return fRootObject; };
|
||||
Object * RootObject() { return fRootObject; };
|
||||
|
||||
Hub *GetRootHub() { return fRootHub; };
|
||||
Hub * GetRootHub() { return fRootHub; };
|
||||
void SetRootHub(Hub *hub) { fRootHub = hub; };
|
||||
|
||||
usb_id USBID() { return fStack->IndexOfBusManager(this); };
|
||||
virtual const char * TypeName() = 0;
|
||||
|
||||
protected:
|
||||
bool fInitOK;
|
||||
|
||||
private:
|
||||
ControlPipe *_GetDefaultPipe(usb_speed);
|
||||
ControlPipe * _GetDefaultPipe(usb_speed);
|
||||
|
||||
mutex fLock;
|
||||
|
||||
bool fDeviceMap[128];
|
||||
int8 fDeviceIndex;
|
||||
|
||||
ControlPipe *fDefaultPipes[USB_SPEED_MAX + 1];
|
||||
Hub *fRootHub;
|
||||
Object *fRootObject;
|
||||
Stack * fStack;
|
||||
ControlPipe * fDefaultPipes[USB_SPEED_MAX + 1];
|
||||
Hub * fRootHub;
|
||||
Object * fRootObject;
|
||||
};
|
||||
|
||||
|
||||
@@ -222,13 +242,14 @@ public:
|
||||
Object(Object *parent);
|
||||
virtual ~Object();
|
||||
|
||||
Object *Parent() { return fParent; };
|
||||
Object * Parent() { return fParent; };
|
||||
|
||||
BusManager *GetBusManager() { return fBusManager; };
|
||||
Stack *GetStack() { return fStack; };
|
||||
BusManager * GetBusManager() { return fBusManager; };
|
||||
Stack * GetStack() { return fStack; };
|
||||
|
||||
usb_id USBID() { return fUSBID; };
|
||||
virtual uint32 Type() { return USB_OBJECT_NONE; };
|
||||
virtual const char * TypeName() { return "object"; };
|
||||
|
||||
// Convenience functions for standard requests
|
||||
virtual status_t SetFeature(uint16 selector);
|
||||
@@ -236,9 +257,9 @@ virtual status_t ClearFeature(uint16 selector);
|
||||
virtual status_t GetStatus(uint16 *status);
|
||||
|
||||
private:
|
||||
Object *fParent;
|
||||
BusManager *fBusManager;
|
||||
Stack *fStack;
|
||||
Object * fParent;
|
||||
BusManager * fBusManager;
|
||||
Stack * fStack;
|
||||
usb_id fUSBID;
|
||||
};
|
||||
|
||||
@@ -263,6 +284,7 @@ virtual ~Pipe();
|
||||
int8 hubAddress, uint8 hubPort);
|
||||
|
||||
virtual uint32 Type() { return USB_OBJECT_PIPE; };
|
||||
virtual const char * TypeName() { return "pipe"; };
|
||||
|
||||
int8 DeviceAddress() { return fDeviceAddress; };
|
||||
usb_speed Speed() { return fSpeed; };
|
||||
@@ -283,7 +305,7 @@ virtual void SetDataToggle(bool toggle) { fDataToggle = toggle; };
|
||||
status_t CancelQueuedTransfers(bool force);
|
||||
|
||||
void SetControllerCookie(void *cookie) { fControllerCookie = cookie; };
|
||||
void *ControllerCookie() { return fControllerCookie; };
|
||||
void * ControllerCookie() { return fControllerCookie; };
|
||||
|
||||
// Convenience functions for standard requests
|
||||
virtual status_t SetFeature(uint16 selector);
|
||||
@@ -300,7 +322,7 @@ private:
|
||||
int8 fHubAddress;
|
||||
uint8 fHubPort;
|
||||
bool fDataToggle;
|
||||
void *fControllerCookie;
|
||||
void * fControllerCookie;
|
||||
};
|
||||
|
||||
|
||||
@@ -310,6 +332,7 @@ public:
|
||||
virtual ~ControlPipe();
|
||||
|
||||
virtual uint32 Type() { return USB_OBJECT_PIPE | USB_OBJECT_CONTROL_PIPE; };
|
||||
virtual const char * TypeName() { return "control pipe"; };
|
||||
|
||||
// The data toggle is not relevant
|
||||
// for control transfers, as they are
|
||||
@@ -348,6 +371,7 @@ public:
|
||||
InterruptPipe(Object *parent);
|
||||
|
||||
virtual uint32 Type() { return USB_OBJECT_PIPE | USB_OBJECT_INTERRUPT_PIPE; };
|
||||
virtual const char * TypeName() { return "interrupt pipe"; };
|
||||
|
||||
status_t QueueInterrupt(void *data,
|
||||
size_t dataLength,
|
||||
@@ -361,6 +385,7 @@ public:
|
||||
BulkPipe(Object *parent);
|
||||
|
||||
virtual uint32 Type() { return USB_OBJECT_PIPE | USB_OBJECT_BULK_PIPE; };
|
||||
virtual const char * TypeName() { return "bulk pipe"; };
|
||||
|
||||
status_t QueueBulk(void *data,
|
||||
size_t dataLength,
|
||||
@@ -378,6 +403,7 @@ public:
|
||||
IsochronousPipe(Object *parent);
|
||||
|
||||
virtual uint32 Type() { return USB_OBJECT_PIPE | USB_OBJECT_ISO_PIPE; };
|
||||
virtual const char * TypeName() { return "iso pipe"; };
|
||||
|
||||
status_t QueueIsochronous(void *data,
|
||||
size_t dataLength,
|
||||
@@ -408,6 +434,7 @@ public:
|
||||
uint8 interfaceIndex);
|
||||
|
||||
virtual uint32 Type() { return USB_OBJECT_INTERFACE; };
|
||||
virtual const char * TypeName() { return "interface"; };
|
||||
|
||||
// Convenience functions for standard requests
|
||||
virtual status_t SetFeature(uint16 selector);
|
||||
@@ -434,8 +461,9 @@ virtual status_t Changed(change_item **changeList,
|
||||
bool added);
|
||||
|
||||
virtual uint32 Type() { return USB_OBJECT_DEVICE; };
|
||||
virtual const char * TypeName() { return "device"; };
|
||||
|
||||
ControlPipe *DefaultPipe() { return fDefaultPipe; };
|
||||
ControlPipe * DefaultPipe() { return fDefaultPipe; };
|
||||
|
||||
virtual status_t GetDescriptor(uint8 descriptorType,
|
||||
uint8 index, uint16 languageID,
|
||||
@@ -443,11 +471,11 @@ virtual status_t GetDescriptor(uint8 descriptorType,
|
||||
size_t *actualLength);
|
||||
|
||||
int8 DeviceAddress() const { return fDeviceAddress; };
|
||||
const usb_device_descriptor *DeviceDescriptor() const;
|
||||
const usb_device_descriptor * DeviceDescriptor() const;
|
||||
usb_speed Speed() const { return fSpeed; };
|
||||
|
||||
const usb_configuration_info *Configuration() const;
|
||||
const usb_configuration_info *ConfigurationAt(uint8 index) const;
|
||||
const usb_configuration_info * Configuration() const;
|
||||
const usb_configuration_info * ConfigurationAt(uint8 index) const;
|
||||
status_t SetConfiguration(const usb_configuration_info *configuration);
|
||||
status_t SetConfigurationAt(uint8 index);
|
||||
status_t Unconfigure(bool atDeviceLevel);
|
||||
@@ -482,13 +510,13 @@ protected:
|
||||
private:
|
||||
bool fAvailable;
|
||||
bool fIsRootHub;
|
||||
usb_configuration_info *fConfigurations;
|
||||
usb_configuration_info *fCurrentConfiguration;
|
||||
usb_configuration_info * fConfigurations;
|
||||
usb_configuration_info * fCurrentConfiguration;
|
||||
usb_speed fSpeed;
|
||||
int8 fDeviceAddress;
|
||||
int8 fHubAddress;
|
||||
uint8 fHubPort;
|
||||
ControlPipe *fDefaultPipe;
|
||||
ControlPipe * fDefaultPipe;
|
||||
};
|
||||
|
||||
|
||||
@@ -505,13 +533,14 @@ virtual status_t Changed(change_item **changeList,
|
||||
bool added);
|
||||
|
||||
virtual uint32 Type() { return USB_OBJECT_DEVICE | USB_OBJECT_HUB; };
|
||||
virtual const char * TypeName() { return "hub"; };
|
||||
|
||||
virtual status_t GetDescriptor(uint8 descriptorType,
|
||||
uint8 index, uint16 languageID,
|
||||
void *data, size_t dataLength,
|
||||
size_t *actualLength);
|
||||
|
||||
Device *ChildAt(uint8 index)
|
||||
Device * ChildAt(uint8 index)
|
||||
{ return fChildren[index]; };
|
||||
|
||||
status_t UpdatePortStatus(uint8 index);
|
||||
@@ -534,12 +563,12 @@ virtual status_t BuildDeviceName(char *string,
|
||||
Device *device);
|
||||
|
||||
private:
|
||||
InterruptPipe *fInterruptPipe;
|
||||
InterruptPipe * fInterruptPipe;
|
||||
usb_hub_descriptor fHubDescriptor;
|
||||
|
||||
usb_port_status fInterruptStatus[USB_MAX_PORT_COUNT];
|
||||
usb_port_status fPortStatus[USB_MAX_PORT_COUNT];
|
||||
Device *fChildren[USB_MAX_PORT_COUNT];
|
||||
Device * fChildren[USB_MAX_PORT_COUNT];
|
||||
};
|
||||
|
||||
|
||||
@@ -559,20 +588,20 @@ public:
|
||||
Transfer(Pipe *pipe);
|
||||
~Transfer();
|
||||
|
||||
Pipe *TransferPipe() { return fPipe; };
|
||||
Pipe * TransferPipe() { return fPipe; };
|
||||
|
||||
void SetRequestData(usb_request_data *data);
|
||||
usb_request_data *RequestData() { return fRequestData; };
|
||||
usb_request_data * RequestData() { return fRequestData; };
|
||||
|
||||
void SetIsochronousData(usb_isochronous_data *data);
|
||||
usb_isochronous_data *IsochronousData() { return fIsochronousData; };
|
||||
usb_isochronous_data * IsochronousData() { return fIsochronousData; };
|
||||
|
||||
void SetData(uint8 *buffer, size_t length);
|
||||
uint8 *Data() { return (uint8 *)fData.iov_base; };
|
||||
uint8 * Data() { return (uint8 *)fData.iov_base; };
|
||||
size_t DataLength() { return fData.iov_len; };
|
||||
|
||||
void SetVector(iovec *vector, size_t vectorCount);
|
||||
iovec *Vector() { return fVector; };
|
||||
iovec * Vector() { return fVector; };
|
||||
size_t VectorCount() { return fVectorCount; };
|
||||
size_t VectorLength();
|
||||
|
||||
@@ -589,28 +618,31 @@ public:
|
||||
|
||||
void Finished(uint32 status, size_t actualLength);
|
||||
|
||||
usb_id USBID() { return 0; };
|
||||
const char * TypeName() { return "transfer"; };
|
||||
|
||||
private:
|
||||
status_t _CalculateBandwidth();
|
||||
|
||||
// Data that is related to the transfer
|
||||
Pipe *fPipe;
|
||||
Pipe * fPipe;
|
||||
iovec fData;
|
||||
iovec *fVector;
|
||||
iovec * fVector;
|
||||
size_t fVectorCount;
|
||||
void *fBaseAddress;
|
||||
void * fBaseAddress;
|
||||
bool fFragmented;
|
||||
size_t fActualLength;
|
||||
area_id fUserArea;
|
||||
area_id fClonedArea;
|
||||
|
||||
usb_callback_func fCallback;
|
||||
void *fCallbackCookie;
|
||||
void * fCallbackCookie;
|
||||
|
||||
// For control transfers
|
||||
usb_request_data *fRequestData;
|
||||
usb_request_data * fRequestData;
|
||||
|
||||
// For isochronous transfers
|
||||
usb_isochronous_data *fIsochronousData;
|
||||
usb_isochronous_data * fIsochronousData;
|
||||
|
||||
// For bandwidth management.
|
||||
// It contains the bandwidth necessary in microseconds
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
#include "ehci.h"
|
||||
|
||||
#define USB_MODULE_NAME "ehci"
|
||||
|
||||
pci_module_info *EHCI::sPCIModule = NULL;
|
||||
|
||||
|
||||
@@ -21,10 +23,10 @@ ehci_std_ops(int32 op, ...)
|
||||
{
|
||||
switch (op) {
|
||||
case B_MODULE_INIT:
|
||||
TRACE(("usb_ehci_module: init module\n"));
|
||||
TRACE_MODULE("ehci init module\n");
|
||||
return B_OK;
|
||||
case B_MODULE_UNINIT:
|
||||
TRACE(("usb_ehci_module: uninit module\n"));
|
||||
TRACE_MODULE("ehci uninit module\n");
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -124,11 +126,11 @@ EHCI::EHCI(pci_info *info, Stack *stack)
|
||||
fPortSuspendChange(0)
|
||||
{
|
||||
if (BusManager::InitCheck() < B_OK) {
|
||||
TRACE_ERROR(("usb_ehci: bus manager failed to init\n"));
|
||||
TRACE_ERROR("bus manager failed to init\n");
|
||||
return;
|
||||
}
|
||||
|
||||
TRACE(("usb_ehci: constructing new EHCI Host Controller Driver\n"));
|
||||
TRACE("constructing new EHCI host controller driver\n");
|
||||
fInitOK = false;
|
||||
|
||||
// enable busmaster and memory mapped access
|
||||
@@ -146,23 +148,26 @@ EHCI::EHCI(pci_info *info, Stack *stack)
|
||||
size_t mapSize = (fPCIInfo->u.h0.base_register_sizes[0] + offset
|
||||
+ B_PAGE_SIZE - 1) & ~(B_PAGE_SIZE - 1);
|
||||
|
||||
TRACE(("usb_ehci: map physical memory 0x%08lx (base: 0x%08lx; offset: %lx); size: %ld\n", fPCIInfo->u.h0.base_registers[0], physicalAddress, offset, fPCIInfo->u.h0.base_register_sizes[0]));
|
||||
TRACE("map physical memory 0x%08lx (base: 0x%08lx; offset: %lx); size: %ld\n",
|
||||
fPCIInfo->u.h0.base_registers[0], physicalAddress, offset,
|
||||
fPCIInfo->u.h0.base_register_sizes[0]);
|
||||
|
||||
fRegisterArea = map_physical_memory("EHCI memory mapped registers",
|
||||
(void *)physicalAddress, mapSize, B_ANY_KERNEL_BLOCK_ADDRESS,
|
||||
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_READ_AREA | B_WRITE_AREA,
|
||||
(void **)&fCapabilityRegisters);
|
||||
if (fRegisterArea < B_OK) {
|
||||
TRACE(("usb_ehci: failed to map register memory\n"));
|
||||
TRACE("failed to map register memory\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fCapabilityRegisters += offset;
|
||||
fOperationalRegisters = fCapabilityRegisters + ReadCapReg8(EHCI_CAPLENGTH);
|
||||
TRACE(("usb_ehci: mapped capability registers: 0x%08lx\n", (uint32)fCapabilityRegisters));
|
||||
TRACE(("usb_ehci: mapped operational registers: 0x%08lx\n", (uint32)fOperationalRegisters));
|
||||
TRACE("mapped capability registers: 0x%08lx\n", (uint32)fCapabilityRegisters);
|
||||
TRACE("mapped operational registers: 0x%08lx\n", (uint32)fOperationalRegisters);
|
||||
|
||||
TRACE(("usb_ehci: structural parameters: 0x%08lx\n", ReadCapReg32(EHCI_HCSPARAMS)));
|
||||
TRACE(("usb_ehci: capability parameters: 0x%08lx\n", ReadCapReg32(EHCI_HCCPARAMS)));
|
||||
TRACE("structural parameters: 0x%08lx\n", ReadCapReg32(EHCI_HCSPARAMS));
|
||||
TRACE("capability parameters: 0x%08lx\n", ReadCapReg32(EHCI_HCCPARAMS));
|
||||
|
||||
// read port count from capability register
|
||||
fPortCount = ReadCapReg32(EHCI_HCSPARAMS) & 0x0f;
|
||||
@@ -170,15 +175,15 @@ EHCI::EHCI(pci_info *info, Stack *stack)
|
||||
uint32 extendedCapPointer = ReadCapReg32(EHCI_HCCPARAMS) >> EHCI_ECP_SHIFT;
|
||||
extendedCapPointer &= EHCI_ECP_MASK;
|
||||
if (extendedCapPointer > 0) {
|
||||
TRACE(("usb_ehci: extended capabilities register at %ld\n", extendedCapPointer));
|
||||
TRACE("extended capabilities register at %ld\n", extendedCapPointer);
|
||||
|
||||
uint32 legacySupport = sPCIModule->read_pci_config(fPCIInfo->bus,
|
||||
fPCIInfo->device, fPCIInfo->function, extendedCapPointer, 4);
|
||||
if ((legacySupport & EHCI_LEGSUP_CAPID_MASK) == EHCI_LEGSUP_CAPID) {
|
||||
if (legacySupport & EHCI_LEGSUP_BIOSOWNED)
|
||||
dprintf("usb_ehci: the host controller is bios owned\n");
|
||||
TRACE_ALWAYS("the host controller is bios owned\n");
|
||||
|
||||
dprintf("usb_ehci: claiming ownership of the host controller\n");
|
||||
TRACE_ALWAYS("claiming ownership of the host controller\n");
|
||||
sPCIModule->write_pci_config(fPCIInfo->bus, fPCIInfo->device,
|
||||
fPCIInfo->function, extendedCapPointer + 3, 1, 1);
|
||||
|
||||
@@ -187,14 +192,14 @@ EHCI::EHCI(pci_info *info, Stack *stack)
|
||||
fPCIInfo->device, fPCIInfo->function, extendedCapPointer, 4);
|
||||
|
||||
if (legacySupport & EHCI_LEGSUP_BIOSOWNED) {
|
||||
dprintf("usb_ehci: controller is still bios owned, waiting\n");
|
||||
TRACE_ALWAYS("controller is still bios owned, waiting\n");
|
||||
snooze(50000);
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
||||
if (legacySupport & EHCI_LEGSUP_BIOSOWNED) {
|
||||
TRACE_ERROR(("usb_ehci: bios won't give up control over the host controller (ignoring)\n"));
|
||||
TRACE_ERROR("bios won't give up control over the host controller (ignoring)\n");
|
||||
|
||||
// turn off the BIOS owned flag, clear all SMIs and continue
|
||||
sPCIModule->write_pci_config(fPCIInfo->bus, fPCIInfo->device,
|
||||
@@ -202,13 +207,13 @@ EHCI::EHCI(pci_info *info, Stack *stack)
|
||||
sPCIModule->write_pci_config(fPCIInfo->bus, fPCIInfo->device,
|
||||
fPCIInfo->function, extendedCapPointer + 4, 4, 0);
|
||||
} else if (legacySupport & EHCI_LEGSUP_OSOWNED) {
|
||||
dprintf("usb_ehci: successfully took ownership of the host controller\n");
|
||||
TRACE_ALWAYS("successfully took ownership of the host controller\n");
|
||||
}
|
||||
} else {
|
||||
TRACE(("usb_ehci: extended capability is not a legacy support register\n"));
|
||||
TRACE("extended capability is not a legacy support register\n");
|
||||
}
|
||||
} else {
|
||||
TRACE(("usb_ehci: no extended capabilities register\n"));
|
||||
TRACE("no extended capabilities register\n");
|
||||
}
|
||||
|
||||
// disable interrupts
|
||||
@@ -216,7 +221,7 @@ EHCI::EHCI(pci_info *info, Stack *stack)
|
||||
|
||||
// reset the host controller
|
||||
if (ControllerReset() < B_OK) {
|
||||
TRACE_ERROR(("usb_ehci: host controller failed to reset\n"));
|
||||
TRACE_ERROR("host controller failed to reset\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -229,7 +234,7 @@ EHCI::EHCI(pci_info *info, Stack *stack)
|
||||
fCleanupSem = create_sem(0, "EHCI Cleanup");
|
||||
if (fFinishTransfersSem < B_OK || fAsyncAdvanceSem < B_OK
|
||||
|| fCleanupSem < B_OK) {
|
||||
TRACE_ERROR(("usb_ehci: failed to create semaphores\n"));
|
||||
TRACE_ERROR("failed to create semaphores\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -254,7 +259,7 @@ EHCI::EHCI(pci_info *info, Stack *stack)
|
||||
fPeriodicFrameListArea = fStack->AllocateArea((void **)&fPeriodicFrameList,
|
||||
(void **)&physicalAddress, B_PAGE_SIZE * 2, "USB EHCI Periodic Framelist");
|
||||
if (fPeriodicFrameListArea < B_OK) {
|
||||
TRACE_ERROR(("usb_ehci: unable to allocate periodic framelist\n"));
|
||||
TRACE_ERROR("unable to allocate periodic framelist\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -262,7 +267,7 @@ EHCI::EHCI(pci_info *info, Stack *stack)
|
||||
WriteOpReg(EHCI_PERIODICLISTBASE, (uint32)physicalAddress);
|
||||
|
||||
// create the interrupt entries to support different polling intervals
|
||||
TRACE(("usb_ehci: creating interrupt entries\n"));
|
||||
TRACE("creating interrupt entries\n");
|
||||
addr_t physicalBase = physicalAddress + B_PAGE_SIZE;
|
||||
uint8 *logicalBase = (uint8 *)fPeriodicFrameList + B_PAGE_SIZE;
|
||||
memset(logicalBase, 0, B_PAGE_SIZE);
|
||||
@@ -287,7 +292,7 @@ EHCI::EHCI(pci_info *info, Stack *stack)
|
||||
}
|
||||
|
||||
// build flat interrupt tree
|
||||
TRACE(("usb_ehci: build up interrupt links\n"));
|
||||
TRACE("build up interrupt links\n");
|
||||
uint32 interval = 1024;
|
||||
uint32 intervalIndex = 10;
|
||||
while (interval > 1) {
|
||||
@@ -320,7 +325,7 @@ EHCI::EHCI(pci_info *info, Stack *stack)
|
||||
// allocate a queue head that will always stay in the async frame list
|
||||
fAsyncQueueHead = CreateQueueHead();
|
||||
if (!fAsyncQueueHead) {
|
||||
TRACE_ERROR(("usb_ehci: unable to allocate stray async queue head\n"));
|
||||
TRACE_ERROR("unable to allocate stray async queue head\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -334,16 +339,16 @@ EHCI::EHCI(pci_info *info, Stack *stack)
|
||||
|
||||
WriteOpReg(EHCI_ASYNCLISTADDR, (uint32)fAsyncQueueHead->this_phy
|
||||
| EHCI_QH_TYPE_QH);
|
||||
TRACE(("usb_ehci: set the async list addr to 0x%08lx\n", ReadOpReg(EHCI_ASYNCLISTADDR)));
|
||||
TRACE("set the async list addr to 0x%08lx\n", ReadOpReg(EHCI_ASYNCLISTADDR));
|
||||
|
||||
fInitOK = true;
|
||||
TRACE(("usb_ehci: EHCI Host Controller Driver constructed\n"));
|
||||
TRACE("EHCI host controller driver constructed\n");
|
||||
}
|
||||
|
||||
|
||||
EHCI::~EHCI()
|
||||
{
|
||||
TRACE(("usb_ehci: tear down EHCI Host Controller Driver\n"));
|
||||
TRACE("tear down EHCI host controller driver\n");
|
||||
|
||||
WriteOpReg(EHCI_USBCMD, 0);
|
||||
WriteOpReg(EHCI_CONFIGFLAG, 0);
|
||||
@@ -366,8 +371,8 @@ EHCI::~EHCI()
|
||||
status_t
|
||||
EHCI::Start()
|
||||
{
|
||||
TRACE(("usb_ehci: starting EHCI Host Controller\n"));
|
||||
TRACE(("usb_ehci: usbcmd: 0x%08lx; usbsts: 0x%08lx\n", ReadOpReg(EHCI_USBCMD), ReadOpReg(EHCI_USBSTS)));
|
||||
TRACE("starting EHCI host controller\n");
|
||||
TRACE("usbcmd: 0x%08lx; usbsts: 0x%08lx\n", ReadOpReg(EHCI_USBCMD), ReadOpReg(EHCI_USBSTS));
|
||||
|
||||
uint32 frameListSize = (ReadOpReg(EHCI_USBCMD) >> EHCI_USBCMD_FLS_SHIFT)
|
||||
& EHCI_USBCMD_FLS_MASK;
|
||||
@@ -379,7 +384,7 @@ EHCI::Start()
|
||||
bool running = false;
|
||||
for (int32 i = 0; i < 10; i++) {
|
||||
uint32 status = ReadOpReg(EHCI_USBSTS);
|
||||
TRACE(("usb_ehci: try %ld: status 0x%08lx\n", i, status));
|
||||
TRACE("try %ld: status 0x%08lx\n", i, status);
|
||||
|
||||
if (status & EHCI_USBSTS_HCHALTED) {
|
||||
snooze(10000);
|
||||
@@ -390,7 +395,7 @@ EHCI::Start()
|
||||
}
|
||||
|
||||
if (!running) {
|
||||
TRACE(("usb_ehci: Host Controller didn't start\n"));
|
||||
TRACE("host controller didn't start\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -401,17 +406,17 @@ EHCI::Start()
|
||||
fRootHubAddress = AllocateAddress();
|
||||
fRootHub = new(std::nothrow) EHCIRootHub(RootObject(), fRootHubAddress);
|
||||
if (!fRootHub) {
|
||||
TRACE_ERROR(("usb_ehci: no memory to allocate root hub\n"));
|
||||
TRACE_ERROR("no memory to allocate root hub\n");
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
if (fRootHub->InitCheck() < B_OK) {
|
||||
TRACE_ERROR(("usb_ehci: root hub failed init check\n"));
|
||||
TRACE_ERROR("root hub failed init check\n");
|
||||
return fRootHub->InitCheck();
|
||||
}
|
||||
|
||||
SetRootHub(fRootHub);
|
||||
dprintf("usb_ehci: successfully started the controller\n");
|
||||
TRACE_ALWAYS("successfully started the controller\n");
|
||||
return BusManager::Start();
|
||||
}
|
||||
|
||||
@@ -431,13 +436,13 @@ EHCI::SubmitTransfer(Transfer *transfer)
|
||||
|
||||
ehci_qh *queueHead = CreateQueueHead();
|
||||
if (!queueHead) {
|
||||
TRACE_ERROR(("usb_ehci: failed to allocate queue head\n"));
|
||||
TRACE_ERROR("failed to allocate queue head\n");
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
status_t result = InitQueueHead(queueHead, pipe);
|
||||
if (result < B_OK) {
|
||||
TRACE_ERROR(("usb_ehci: failed to init queue head\n"));
|
||||
TRACE_ERROR("failed to init queue head\n");
|
||||
FreeQueueHead(queueHead);
|
||||
return result;
|
||||
}
|
||||
@@ -453,20 +458,20 @@ EHCI::SubmitTransfer(Transfer *transfer)
|
||||
}
|
||||
|
||||
if (result < B_OK) {
|
||||
TRACE_ERROR(("usb_ehci: failed to fill transfer queue with data\n"));
|
||||
TRACE_ERROR("failed to fill transfer queue with data\n");
|
||||
FreeQueueHead(queueHead);
|
||||
return result;
|
||||
}
|
||||
|
||||
result = AddPendingTransfer(transfer, queueHead, dataDescriptor, directionIn);
|
||||
if (result < B_OK) {
|
||||
TRACE_ERROR(("usb_ehci: failed to add pending transfer\n"));
|
||||
TRACE_ERROR("failed to add pending transfer\n");
|
||||
FreeQueueHead(queueHead);
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef TRACE_USB
|
||||
TRACE(("usb_ehci: linking queue\n"));
|
||||
TRACE("linking queue\n");
|
||||
print_queue(queueHead);
|
||||
#endif
|
||||
|
||||
@@ -476,7 +481,7 @@ EHCI::SubmitTransfer(Transfer *transfer)
|
||||
result = LinkQueueHead(queueHead);
|
||||
|
||||
if (result < B_OK) {
|
||||
TRACE_ERROR(("usb_ehci: failed to link queue head\n"));
|
||||
TRACE_ERROR("failed to link queue head\n");
|
||||
FreeQueueHead(queueHead);
|
||||
return result;
|
||||
}
|
||||
@@ -488,7 +493,7 @@ EHCI::SubmitTransfer(Transfer *transfer)
|
||||
status_t
|
||||
EHCI::NotifyPipeChange(Pipe *pipe, usb_change change)
|
||||
{
|
||||
TRACE(("usb_ehci: pipe change %d for pipe 0x%08lx\n", change, (uint32)pipe));
|
||||
TRACE("pipe change %d for pipe %p\n", change, pipe);
|
||||
switch (change) {
|
||||
case USB_CHANGE_CREATED:
|
||||
case USB_CHANGE_DESTROYED: {
|
||||
@@ -521,12 +526,12 @@ EHCI::AddTo(Stack *stack)
|
||||
if (!sPCIModule) {
|
||||
status_t status = get_module(B_PCI_MODULE_NAME, (module_info **)&sPCIModule);
|
||||
if (status < B_OK) {
|
||||
TRACE_ERROR(("usb_ehci: getting pci module failed! 0x%08lx\n", status));
|
||||
TRACE_MODULE_ERROR("getting pci module failed! 0x%08lx\n", status);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
TRACE(("usb_ehci: searching devices\n"));
|
||||
TRACE_MODULE("searching devices\n");
|
||||
bool found = false;
|
||||
pci_info *item = new(std::nothrow) pci_info;
|
||||
if (!item) {
|
||||
@@ -540,11 +545,11 @@ EHCI::AddTo(Stack *stack)
|
||||
&& item->class_api == PCI_usb_ehci) {
|
||||
if (item->u.h0.interrupt_line == 0
|
||||
|| item->u.h0.interrupt_line == 0xFF) {
|
||||
TRACE_ERROR(("usb_ehci: found device with invalid IRQ - check IRQ assignement\n"));
|
||||
TRACE_MODULE_ERROR("found device with invalid IRQ - check IRQ assignement\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
TRACE(("usb_ehci: found device at IRQ %u\n", item->u.h0.interrupt_line));
|
||||
TRACE_MODULE("found device at IRQ %u\n", item->u.h0.interrupt_line);
|
||||
EHCI *bus = new(std::nothrow) EHCI(item, stack);
|
||||
if (!bus) {
|
||||
delete item;
|
||||
@@ -554,7 +559,7 @@ EHCI::AddTo(Stack *stack)
|
||||
}
|
||||
|
||||
if (bus->InitCheck() < B_OK) {
|
||||
TRACE_ERROR(("usb_ehci: bus failed init check\n"));
|
||||
TRACE_MODULE_ERROR("bus failed init check\n");
|
||||
delete bus;
|
||||
continue;
|
||||
}
|
||||
@@ -569,7 +574,7 @@ EHCI::AddTo(Stack *stack)
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
TRACE_ERROR(("usb_ehci: no devices found\n"));
|
||||
TRACE_MODULE_ERROR("no devices found\n");
|
||||
delete item;
|
||||
sPCIModule = NULL;
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
@@ -697,12 +702,12 @@ EHCI::ClearPortFeature(uint8 index, uint16 feature)
|
||||
status_t
|
||||
EHCI::ResetPort(uint8 index)
|
||||
{
|
||||
TRACE(("usb_ehci: reset port %d\n", index));
|
||||
TRACE("reset port %d\n", index);
|
||||
uint32 portRegister = EHCI_PORTSC + index * sizeof(uint32);
|
||||
uint32 portStatus = ReadOpReg(portRegister) & EHCI_PORTSC_DATAMASK;
|
||||
|
||||
if (portStatus & EHCI_PORTSC_DMINUS) {
|
||||
dprintf("usb_ehci: lowspeed device connected, giving up port ownership\n");
|
||||
TRACE_ALWAYS("lowspeed device connected, giving up port ownership\n");
|
||||
// there is a lowspeed device connected.
|
||||
// we give the ownership to a companion controller.
|
||||
WriteOpReg(portRegister, portStatus | EHCI_PORTSC_PORTOWNER);
|
||||
@@ -721,12 +726,12 @@ EHCI::ResetPort(uint8 index)
|
||||
|
||||
portStatus = ReadOpReg(portRegister) & EHCI_PORTSC_DATAMASK;
|
||||
if (portStatus & EHCI_PORTSC_PORTRESET) {
|
||||
TRACE_ERROR(("usb_ehci: port reset won't complete\n"));
|
||||
TRACE_ERROR("port reset won't complete\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
if ((portStatus & EHCI_PORTSC_ENABLE) == 0) {
|
||||
dprintf("usb_ehci: fullspeed device connected, giving up port ownership\n");
|
||||
TRACE_ALWAYS("fullspeed device connected, giving up port ownership\n");
|
||||
// the port was not enabled, this means that no high speed device is
|
||||
// attached to this port. we give up ownership to a companion controler
|
||||
WriteOpReg(portRegister, portStatus | EHCI_PORTSC_PORTOWNER);
|
||||
@@ -802,33 +807,33 @@ EHCI::Interrupt()
|
||||
int32 result = B_HANDLED_INTERRUPT;
|
||||
|
||||
if (status & EHCI_USBSTS_USBINT) {
|
||||
TRACE(("usb_ehci: transfer finished\n"));
|
||||
TRACE("transfer finished\n");
|
||||
acknowledge |= EHCI_USBSTS_USBINT;
|
||||
result = B_INVOKE_SCHEDULER;
|
||||
finishTransfers = true;
|
||||
}
|
||||
|
||||
if (status & EHCI_USBSTS_USBERRINT) {
|
||||
TRACE(("usb_ehci: transfer error\n"));
|
||||
TRACE("transfer error\n");
|
||||
acknowledge |= EHCI_USBSTS_USBERRINT;
|
||||
result = B_INVOKE_SCHEDULER;
|
||||
finishTransfers = true;
|
||||
}
|
||||
|
||||
if (status & EHCI_USBSTS_PORTCHANGE) {
|
||||
TRACE(("usb_ehci: port change detected\n"));
|
||||
TRACE("port change detected\n");
|
||||
acknowledge |= EHCI_USBSTS_PORTCHANGE;
|
||||
}
|
||||
|
||||
if (status & EHCI_USBSTS_INTONAA) {
|
||||
TRACE(("usb_ehci: interrupt on async advance\n"));
|
||||
TRACE("interrupt on async advance\n");
|
||||
acknowledge |= EHCI_USBSTS_INTONAA;
|
||||
asyncAdvance = true;
|
||||
result = B_INVOKE_SCHEDULER;
|
||||
}
|
||||
|
||||
if (status & EHCI_USBSTS_HOSTSYSERR) {
|
||||
TRACE_ERROR(("usb_ehci: host system error!\n"));
|
||||
TRACE_ERROR("host system error!\n");
|
||||
acknowledge |= EHCI_USBSTS_HOSTSYSERR;
|
||||
}
|
||||
|
||||
@@ -989,7 +994,7 @@ EHCI::FinishTransfers()
|
||||
if (!Lock())
|
||||
continue;
|
||||
|
||||
TRACE(("usb_ehci: finishing transfers\n"));
|
||||
TRACE("finishing transfers\n");
|
||||
transfer_data *lastTransfer = NULL;
|
||||
transfer_data *transfer = fFirstTransfer;
|
||||
Unlock();
|
||||
@@ -1003,13 +1008,13 @@ EHCI::FinishTransfers()
|
||||
uint32 status = descriptor->token;
|
||||
if (status & EHCI_QTD_STATUS_ACTIVE) {
|
||||
// still in progress
|
||||
TRACE(("usb_ehci: qtd (0x%08lx) still active\n", descriptor->this_phy));
|
||||
TRACE("qtd (0x%08lx) still active\n", descriptor->this_phy);
|
||||
break;
|
||||
}
|
||||
|
||||
if (status & EHCI_QTD_STATUS_ERRMASK) {
|
||||
// a transfer error occured
|
||||
TRACE_ERROR(("usb_ehci: qtd (0x%08lx) error: 0x%08lx\n", descriptor->this_phy, status));
|
||||
TRACE_ERROR("qtd (0x%08lx) error: 0x%08lx\n", descriptor->this_phy, status);
|
||||
|
||||
uint8 errorCount = status >> EHCI_QTD_ERRCOUNT_SHIFT;
|
||||
errorCount &= EHCI_QTD_ERRCOUNT_MASK;
|
||||
@@ -1043,7 +1048,7 @@ EHCI::FinishTransfers()
|
||||
|
||||
if (descriptor->next_phy & EHCI_QTD_TERMINATE) {
|
||||
// we arrived at the last (stray) descriptor, we're done
|
||||
TRACE(("usb_ehci: qtd (0x%08lx) done\n", descriptor->this_phy));
|
||||
TRACE("qtd (0x%08lx) done\n", descriptor->this_phy);
|
||||
callbackStatus = B_OK;
|
||||
transferDone = true;
|
||||
break;
|
||||
@@ -1188,7 +1193,7 @@ EHCI::CreateQueueHead()
|
||||
void *physicalAddress;
|
||||
if (fStack->AllocateChunk((void **)&result, &physicalAddress,
|
||||
sizeof(ehci_qh)) < B_OK) {
|
||||
TRACE_ERROR(("usb_ehci: failed to allocate queue head\n"));
|
||||
TRACE_ERROR("failed to allocate queue head\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1199,7 +1204,7 @@ EHCI::CreateQueueHead()
|
||||
|
||||
ehci_qtd *descriptor = CreateDescriptor(0, 0);
|
||||
if (!descriptor) {
|
||||
TRACE_ERROR(("usb_ehci: failed to allocate initial qtd for queue head\n"));
|
||||
TRACE_ERROR("failed to allocate initial qtd for queue head\n");
|
||||
fStack->FreeChunk(result, (void *)result->this_phy, sizeof(ehci_qh));
|
||||
return NULL;
|
||||
}
|
||||
@@ -1234,7 +1239,7 @@ EHCI::InitQueueHead(ehci_qh *queueHead, Pipe *pipe)
|
||||
queueHead->endpoint_chars = EHCI_QH_CHARS_EPS_HIGH;
|
||||
break;
|
||||
default:
|
||||
TRACE_ERROR(("usb_ehci: unknown pipe speed\n"));
|
||||
TRACE_ERROR("unknown pipe speed\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -1377,7 +1382,7 @@ EHCI::FillQueueWithRequest(Transfer *transfer, ehci_qh *queueHead,
|
||||
directionIn ? EHCI_QTD_PID_OUT : EHCI_QTD_PID_IN);
|
||||
|
||||
if (!setupDescriptor || !statusDescriptor) {
|
||||
TRACE_ERROR(("usb_ehci: failed to allocate descriptors\n"));
|
||||
TRACE_ERROR("failed to allocate descriptors\n");
|
||||
FreeDescriptor(setupDescriptor);
|
||||
FreeDescriptor(statusDescriptor);
|
||||
return B_NO_MEMORY;
|
||||
@@ -1467,7 +1472,7 @@ EHCI::CreateDescriptor(size_t bufferSize, uint8 pid)
|
||||
void *physicalAddress;
|
||||
if (fStack->AllocateChunk((void **)&result, &physicalAddress,
|
||||
sizeof(ehci_qtd)) < B_OK) {
|
||||
TRACE_ERROR(("usb_ehci: failed to allocate a qtd\n"));
|
||||
TRACE_ERROR("failed to allocate a qtd\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1493,7 +1498,7 @@ EHCI::CreateDescriptor(size_t bufferSize, uint8 pid)
|
||||
|
||||
if (fStack->AllocateChunk(&result->buffer_log, &physicalAddress,
|
||||
bufferSize) < B_OK) {
|
||||
TRACE_ERROR(("usb_ehci: unable to allocate qtd buffer\n"));
|
||||
TRACE_ERROR("unable to allocate qtd buffer\n");
|
||||
fStack->FreeChunk(result, (void *)result->this_phy, sizeof(ehci_qtd));
|
||||
return NULL;
|
||||
}
|
||||
@@ -1621,7 +1626,7 @@ EHCI::WriteDescriptorChain(ehci_qtd *topDescriptor, iovec *vector,
|
||||
|
||||
if (vectorOffset >= vector[vectorIndex].iov_len) {
|
||||
if (++vectorIndex >= vectorCount) {
|
||||
TRACE(("usb_ehci: wrote descriptor chain (%ld bytes, no more vectors)\n", actualLength));
|
||||
TRACE("wrote descriptor chain (%ld bytes, no more vectors)\n", actualLength);
|
||||
return actualLength;
|
||||
}
|
||||
|
||||
@@ -1640,7 +1645,7 @@ EHCI::WriteDescriptorChain(ehci_qtd *topDescriptor, iovec *vector,
|
||||
current = (ehci_qtd *)current->next_log;
|
||||
}
|
||||
|
||||
TRACE(("usb_ehci: wrote descriptor chain (%ld bytes)\n", actualLength));
|
||||
TRACE("wrote descriptor chain (%ld bytes)\n", actualLength);
|
||||
return actualLength;
|
||||
}
|
||||
|
||||
@@ -1677,7 +1682,7 @@ EHCI::ReadDescriptorChain(ehci_qtd *topDescriptor, iovec *vector,
|
||||
|
||||
if (vectorOffset >= vector[vectorIndex].iov_len) {
|
||||
if (++vectorIndex >= vectorCount) {
|
||||
TRACE(("usb_ehci: read descriptor chain (%ld bytes, no more vectors)\n", actualLength));
|
||||
TRACE("read descriptor chain (%ld bytes, no more vectors)\n", actualLength);
|
||||
*nextDataToggle = dataToggle > 0 ? true : false;
|
||||
return actualLength;
|
||||
}
|
||||
@@ -1697,7 +1702,7 @@ EHCI::ReadDescriptorChain(ehci_qtd *topDescriptor, iovec *vector,
|
||||
current = (ehci_qtd *)current->next_log;
|
||||
}
|
||||
|
||||
TRACE(("usb_ehci: read descriptor chain (%ld bytes)\n", actualLength));
|
||||
TRACE("read descriptor chain (%ld bytes)\n", actualLength);
|
||||
*nextDataToggle = dataToggle > 0 ? true : false;
|
||||
return actualLength;
|
||||
}
|
||||
@@ -1722,7 +1727,7 @@ EHCI::ReadActualLength(ehci_qtd *topDescriptor, bool *nextDataToggle)
|
||||
current = (ehci_qtd *)current->next_log;
|
||||
}
|
||||
|
||||
TRACE(("usb_ehci: read actual length (%ld bytes)\n", actualLength));
|
||||
TRACE("read actual length (%ld bytes)\n", actualLength);
|
||||
*nextDataToggle = dataToggle > 0 ? true : false;
|
||||
return actualLength;
|
||||
}
|
||||
|
||||
@@ -51,6 +51,8 @@ static status_t AddTo(Stack *stack);
|
||||
status_t ResetPort(uint8 index);
|
||||
status_t SuspendPort(uint8 index);
|
||||
|
||||
virtual const char * TypeName() { return "ehci"; };
|
||||
|
||||
private:
|
||||
// Controller resets
|
||||
status_t ControllerReset();
|
||||
|
||||
@@ -11,5 +11,5 @@ resource app_version {
|
||||
variety = 0,
|
||||
internal = 0,
|
||||
short_info = "EHCI host controller driver",
|
||||
long_info = "Haiku EHCI HCD - Copyright 2006-2008, Haiku Inc."
|
||||
long_info = "Haiku EHCI HCD - Copyright 2006-2009, Haiku Inc."
|
||||
};
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "ehci.h"
|
||||
|
||||
#define USB_MODULE_NAME "ehci roothub"
|
||||
|
||||
static usb_device_descriptor sEHCIRootHubDevice =
|
||||
{
|
||||
18, // Descriptor length
|
||||
@@ -135,7 +137,7 @@ EHCIRootHub::ProcessTransfer(EHCI *ehci, Transfer *transfer)
|
||||
return B_ERROR;
|
||||
|
||||
usb_request_data *request = transfer->RequestData();
|
||||
TRACE(("usb_ehci_roothub: request: %d\n", request->Request));
|
||||
TRACE_MODULE("request: %d\n", request->Request);
|
||||
|
||||
status_t status = B_TIMED_OUT;
|
||||
size_t actualLength = 0;
|
||||
@@ -169,12 +171,12 @@ EHCIRootHub::ProcessTransfer(EHCI *ehci, Transfer *transfer)
|
||||
break;
|
||||
}
|
||||
|
||||
TRACE(("usb_ehci_roothub: set address: %d\n", request->Value));
|
||||
TRACE_MODULE("set address: %d\n", request->Value);
|
||||
status = B_OK;
|
||||
break;
|
||||
|
||||
case USB_REQUEST_GET_DESCRIPTOR:
|
||||
TRACE(("usb_ehci_roothub: get descriptor: %d\n", request->Value >> 8));
|
||||
TRACE_MODULE("get descriptor: %d\n", request->Value >> 8);
|
||||
|
||||
switch (request->Value >> 8) {
|
||||
case USB_DESCRIPTOR_DEVICE: {
|
||||
@@ -228,11 +230,11 @@ EHCIRootHub::ProcessTransfer(EHCI *ehci, Transfer *transfer)
|
||||
case USB_REQUEST_CLEAR_FEATURE: {
|
||||
if (request->Index == 0) {
|
||||
// we don't support any hub changes
|
||||
TRACE_ERROR(("usb_ehci_roothub: clear feature: no hub changes\n"));
|
||||
TRACE_MODULE_ERROR("clear feature: no hub changes\n");
|
||||
break;
|
||||
}
|
||||
|
||||
TRACE(("usb_ehci_roothub: clear feature: %d\n", request->Value));
|
||||
TRACE_MODULE("clear feature: %d\n", request->Value);
|
||||
if (ehci->ClearPortFeature(request->Index - 1, request->Value) >= B_OK)
|
||||
status = B_OK;
|
||||
break;
|
||||
@@ -241,11 +243,11 @@ EHCIRootHub::ProcessTransfer(EHCI *ehci, Transfer *transfer)
|
||||
case USB_REQUEST_SET_FEATURE: {
|
||||
if (request->Index == 0) {
|
||||
// we don't support any hub changes
|
||||
TRACE_ERROR(("usb_ehci_roothub: set feature: no hub changes\n"));
|
||||
TRACE_MODULE_ERROR("set feature: no hub changes\n");
|
||||
break;
|
||||
}
|
||||
|
||||
TRACE(("usb_ehci_roothub: set feature: %d\n", request->Value));
|
||||
TRACE_MODULE("set feature: %d\n", request->Value);
|
||||
if (ehci->SetPortFeature(request->Index - 1, request->Value) >= B_OK)
|
||||
status = B_OK;
|
||||
break;
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
#include "ohci.h"
|
||||
|
||||
#define USB_MODULE_NAME "ohci"
|
||||
|
||||
pci_module_info *OHCI::sPCIModule = NULL;
|
||||
|
||||
|
||||
@@ -23,10 +25,10 @@ ohci_std_ops(int32 op, ...)
|
||||
{
|
||||
switch (op) {
|
||||
case B_MODULE_INIT:
|
||||
TRACE(("usb_ohci_module: init module\n"));
|
||||
TRACE_MODULE("init module\n");
|
||||
return B_OK;
|
||||
case B_MODULE_UNINIT:
|
||||
TRACE(("usb_ohci_module: uninit module\n"));
|
||||
TRACE_MODULE("uninit module\n");
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -73,11 +75,11 @@ OHCI::OHCI(pci_info *info, Stack *stack)
|
||||
fPortCount(0)
|
||||
{
|
||||
if (!fInitOK) {
|
||||
TRACE_ERROR(("usb_ohci: bus manager failed to init\n"));
|
||||
TRACE_ERROR("bus manager failed to init\n");
|
||||
return;
|
||||
}
|
||||
|
||||
TRACE(("usb_ohci: constructing new OHCI Host Controller Driver\n"));
|
||||
TRACE("constructing new OHCI host controller driver\n");
|
||||
fInitOK = false;
|
||||
|
||||
mutex_init(&fEndpointLock, "ohci endpoint lock");
|
||||
@@ -95,26 +97,25 @@ OHCI::OHCI(pci_info *info, Stack *stack)
|
||||
uint32 offset = sPCIModule->read_pci_config(fPCIInfo->bus,
|
||||
fPCIInfo->device, fPCIInfo->function, PCI_base_registers, 4);
|
||||
offset &= PCI_address_memory_32_mask;
|
||||
TRACE(("usb_ohci: iospace offset: 0x%lx\n", offset));
|
||||
TRACE_ALWAYS("iospace offset: 0x%lx\n", offset);
|
||||
fRegisterArea = map_physical_memory("OHCI memory mapped registers",
|
||||
(void *)offset, B_PAGE_SIZE, B_ANY_KERNEL_BLOCK_ADDRESS,
|
||||
B_KERNEL_READ_AREA | B_KERNEL_WRITE_AREA | B_READ_AREA | B_WRITE_AREA,
|
||||
(void **)&fOperationalRegisters);
|
||||
if (fRegisterArea < B_OK) {
|
||||
TRACE_ERROR(("usb_ohci: failed to map register memory\n"));
|
||||
TRACE_ERROR("failed to map register memory\n");
|
||||
return;
|
||||
}
|
||||
|
||||
TRACE(("usb_ohci: mapped operational registers: %p\n",
|
||||
fOperationalRegisters));
|
||||
TRACE("mapped operational registers: %p\n", fOperationalRegisters);
|
||||
|
||||
// Check the revision of the controller, which should be 10h
|
||||
uint32 revision = _ReadReg(OHCI_REVISION) & 0xff;
|
||||
TRACE(("usb_ohci: version %ld.%ld%s\n", OHCI_REVISION_HIGH(revision),
|
||||
TRACE("version %ld.%ld%s\n", OHCI_REVISION_HIGH(revision),
|
||||
OHCI_REVISION_LOW(revision), OHCI_REVISION_LEGACY(revision)
|
||||
? ", legacy support" : ""));
|
||||
? ", legacy support" : "");
|
||||
if (OHCI_REVISION_HIGH(revision) != 1 || OHCI_REVISION_LOW(revision) != 0) {
|
||||
TRACE_ERROR(("usb_ohci: unsupported OHCI revision\n"));
|
||||
TRACE_ERROR("unsupported OHCI revision\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -123,7 +124,7 @@ OHCI::OHCI(pci_info *info, Stack *stack)
|
||||
sizeof(ohci_hcca), "USB OHCI Host Controller Communication Area");
|
||||
|
||||
if (fHccaArea < B_OK) {
|
||||
TRACE_ERROR(("usb_ohci: unable to create the HCCA block area\n"));
|
||||
TRACE_ERROR("unable to create the HCCA block area\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -152,7 +153,7 @@ OHCI::OHCI(pci_info *info, Stack *stack)
|
||||
fInterruptEndpoints = new(std::nothrow)
|
||||
ohci_endpoint_descriptor *[OHCI_STATIC_ENDPOINT_COUNT];
|
||||
if (!fInterruptEndpoints) {
|
||||
TRACE_ERROR(("ohci_usb: failed to allocate memory for interrupt endpoints\n"));
|
||||
TRACE_ERROR("failed to allocate memory for interrupt endpoints\n");
|
||||
_FreeEndpoint(fDummyControl);
|
||||
_FreeEndpoint(fDummyBulk);
|
||||
_FreeEndpoint(fDummyIsochronous);
|
||||
@@ -162,7 +163,7 @@ OHCI::OHCI(pci_info *info, Stack *stack)
|
||||
for (int32 i = 0; i < OHCI_STATIC_ENDPOINT_COUNT; i++) {
|
||||
fInterruptEndpoints[i] = _AllocateEndpoint();
|
||||
if (!fInterruptEndpoints[i]) {
|
||||
TRACE_ERROR(("ohci_usb: failed to allocate interrupt endpoint %ld", i));
|
||||
TRACE_ERROR("failed to allocate interrupt endpoint %ld", i);
|
||||
while (--i >= 0)
|
||||
_FreeEndpoint(fInterruptEndpoints[i]);
|
||||
_FreeEndpoint(fDummyBulk);
|
||||
@@ -204,7 +205,7 @@ OHCI::OHCI(pci_info *info, Stack *stack)
|
||||
// Determine in what context we are running (Kindly copied from FreeBSD)
|
||||
uint32 control = _ReadReg(OHCI_CONTROL);
|
||||
if (control & OHCI_INTERRUPT_ROUTING) {
|
||||
TRACE(("usb_ohci: smm is in control of the host controller\n"));
|
||||
TRACE_ALWAYS("smm is in control of the host controller\n");
|
||||
uint32 status = _ReadReg(OHCI_COMMAND_STATUS);
|
||||
_WriteReg(OHCI_COMMAND_STATUS, status | OHCI_OWNERSHIP_CHANGE_REQUEST);
|
||||
for (uint32 i = 0; i < 100 && (control & OHCI_INTERRUPT_ROUTING); i++) {
|
||||
@@ -213,13 +214,13 @@ OHCI::OHCI(pci_info *info, Stack *stack)
|
||||
}
|
||||
|
||||
if ((control & OHCI_INTERRUPT_ROUTING) != 0) {
|
||||
TRACE_ERROR(("usb_ohci: smm does not respond. resetting...\n"));
|
||||
TRACE_ERROR("smm does not respond. resetting...\n");
|
||||
_WriteReg(OHCI_CONTROL, OHCI_HC_FUNCTIONAL_STATE_RESET);
|
||||
snooze(USB_DELAY_BUS_RESET);
|
||||
} else
|
||||
TRACE(("usb_ohci: ownership change successful\n"));
|
||||
TRACE_ALWAYS("ownership change successful\n");
|
||||
} else {
|
||||
TRACE(("usb_ohci: cold started\n"));
|
||||
TRACE("cold started\n");
|
||||
snooze(USB_DELAY_BUS_RESET);
|
||||
}
|
||||
|
||||
@@ -244,7 +245,7 @@ OHCI::OHCI(pci_info *info, Stack *stack)
|
||||
}
|
||||
|
||||
if (reset) {
|
||||
TRACE_ERROR(("usb_ohci: Error resetting the host controller (timeout)\n"));
|
||||
TRACE_ERROR("error resetting the host controller (timeout)\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -293,12 +294,12 @@ OHCI::OHCI(pci_info *info, Stack *stack)
|
||||
if (numberOfPorts > OHCI_MAX_PORT_COUNT)
|
||||
numberOfPorts = OHCI_MAX_PORT_COUNT;
|
||||
fPortCount = numberOfPorts;
|
||||
TRACE(("usb_ohci: port count is %d\n", fPortCount));
|
||||
TRACE("port count is %d\n", fPortCount);
|
||||
|
||||
// Create semaphore the finisher thread will wait for
|
||||
fFinishTransfersSem = create_sem(0, "OHCI Finish Transfers");
|
||||
if (fFinishTransfersSem < B_OK) {
|
||||
TRACE_ERROR(("usb_ohci: failed to create semaphore\n"));
|
||||
TRACE_ERROR("failed to create semaphore\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -308,7 +309,7 @@ OHCI::OHCI(pci_info *info, Stack *stack)
|
||||
resume_thread(fFinishThread);
|
||||
|
||||
// Install the interrupt handler
|
||||
TRACE(("usb_ohci: installing interrupt handler\n"));
|
||||
TRACE("installing interrupt handler\n");
|
||||
install_io_interrupt_handler(fPCIInfo->u.h0.interrupt_line,
|
||||
_InterruptHandler, (void *)this, 0);
|
||||
|
||||
@@ -316,7 +317,7 @@ OHCI::OHCI(pci_info *info, Stack *stack)
|
||||
_WriteReg(OHCI_INTERRUPT_ENABLE, OHCI_NORMAL_INTERRUPTS
|
||||
| OHCI_MASTER_INTERRUPT_ENABLE);
|
||||
|
||||
TRACE(("usb_ohci: OHCI Host Controller Driver constructed\n"));
|
||||
TRACE("OHCI host controller driver constructed\n");
|
||||
fInitOK = true;
|
||||
}
|
||||
|
||||
@@ -355,31 +356,30 @@ OHCI::~OHCI()
|
||||
status_t
|
||||
OHCI::Start()
|
||||
{
|
||||
TRACE(("usb_ohci: starting OHCI Host Controller\n"));
|
||||
TRACE("starting OHCI host controller\n");
|
||||
|
||||
uint32 control = _ReadReg(OHCI_CONTROL);
|
||||
if ((control & OHCI_HC_FUNCTIONAL_STATE_MASK)
|
||||
!= OHCI_HC_FUNCTIONAL_STATE_OPERATIONAL) {
|
||||
TRACE_ERROR(("usb_ohci: Controller not started (0x%08lx)!\n",
|
||||
control));
|
||||
TRACE_ERROR("controller not started (0x%08lx)!\n", control);
|
||||
return B_ERROR;
|
||||
} else
|
||||
TRACE(("usb_ohci: Controller is operational!\n"));
|
||||
TRACE("controller is operational!\n");
|
||||
|
||||
fRootHubAddress = AllocateAddress();
|
||||
fRootHub = new(std::nothrow) OHCIRootHub(RootObject(), fRootHubAddress);
|
||||
if (!fRootHub) {
|
||||
TRACE_ERROR(("usb_ohci: no memory to allocate root hub\n"));
|
||||
TRACE_ERROR("no memory to allocate root hub\n");
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
if (fRootHub->InitCheck() < B_OK) {
|
||||
TRACE_ERROR(("usb_ohci: root hub failed init check\n"));
|
||||
TRACE_ERROR("root hub failed init check\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
SetRootHub(fRootHub);
|
||||
dprintf("usb_ohci: successfully started the controller\n");
|
||||
TRACE_ALWAYS("successfully started the controller\n");
|
||||
return BusManager::Start();
|
||||
}
|
||||
|
||||
@@ -393,23 +393,22 @@ OHCI::SubmitTransfer(Transfer *transfer)
|
||||
|
||||
uint32 type = transfer->TransferPipe()->Type();
|
||||
if (type & USB_OBJECT_CONTROL_PIPE) {
|
||||
TRACE(("usb_ohci: submitting request\n"));
|
||||
TRACE("submitting request\n");
|
||||
return _SubmitRequest(transfer);
|
||||
}
|
||||
|
||||
if ((type & USB_OBJECT_BULK_PIPE) || (type & USB_OBJECT_INTERRUPT_PIPE)) {
|
||||
TRACE(("usb_ohci: submitting %s transfer\n",
|
||||
(type & USB_OBJECT_BULK_PIPE) ? "bulk" : "interrupt"));
|
||||
TRACE("submitting %s transfer\n",
|
||||
(type & USB_OBJECT_BULK_PIPE) ? "bulk" : "interrupt");
|
||||
return _SubmitTransfer(transfer);
|
||||
}
|
||||
|
||||
if (type & USB_OBJECT_ISO_PIPE) {
|
||||
TRACE(("usb_ohci: submitting isochronous transfer\n"));
|
||||
TRACE("submitting isochronous transfer\n");
|
||||
return _SubmitIsochronousTransfer(transfer);
|
||||
}
|
||||
|
||||
TRACE_ERROR(("usb_ohci: tried to submit transfer for unknown pipe"
|
||||
" type %lu\n", type));
|
||||
TRACE_ERROR("tried to submit transfer for unknown pipe type %lu\n", type);
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -481,7 +480,7 @@ OHCI::CancelQueuedTransfers(Pipe *pipe, bool force)
|
||||
status_t
|
||||
OHCI::NotifyPipeChange(Pipe *pipe, usb_change change)
|
||||
{
|
||||
TRACE(("usb_ohci: pipe change %d for pipe 0x%08lx\n", change, (uint32)pipe));
|
||||
TRACE("pipe change %d for pipe 0x%08lx\n", change, (uint32)pipe);
|
||||
if (pipe->DeviceAddress() == fRootHubAddress) {
|
||||
// no need to insert/remove endpoint descriptors for the root hub
|
||||
return B_OK;
|
||||
@@ -495,11 +494,11 @@ OHCI::NotifyPipeChange(Pipe *pipe, usb_change change)
|
||||
return _RemoveEndpointForPipe(pipe);
|
||||
|
||||
case USB_CHANGE_PIPE_POLICY_CHANGED:
|
||||
TRACE(("usb_ohci: pipe policy changing unhandled!\n"));
|
||||
TRACE("pipe policy changing unhandled!\n");
|
||||
break;
|
||||
|
||||
default:
|
||||
TRACE_ERROR(("usb_ohci: unknown pipe change!\n"));
|
||||
TRACE_ERROR("unknown pipe change!\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -520,13 +519,12 @@ OHCI::AddTo(Stack *stack)
|
||||
if (!sPCIModule) {
|
||||
status_t status = get_module(B_PCI_MODULE_NAME, (module_info **)&sPCIModule);
|
||||
if (status < B_OK) {
|
||||
TRACE_ERROR(("usb_ohci: getting pci module failed! 0x%08lx\n",
|
||||
status));
|
||||
TRACE_MODULE_ERROR("getting pci module failed! 0x%08lx\n", status);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
TRACE(("usb_ohci: searching devices\n"));
|
||||
TRACE_MODULE("searching devices\n");
|
||||
bool found = false;
|
||||
pci_info *item = new(std::nothrow) pci_info;
|
||||
if (!item) {
|
||||
@@ -540,13 +538,13 @@ OHCI::AddTo(Stack *stack)
|
||||
&& item->class_api == PCI_usb_ohci) {
|
||||
if (item->u.h0.interrupt_line == 0
|
||||
|| item->u.h0.interrupt_line == 0xFF) {
|
||||
TRACE_ERROR(("usb_ohci: found device with invalid IRQ -"
|
||||
" check IRQ assignement\n"));
|
||||
TRACE_MODULE_ERROR("found device with invalid IRQ -"
|
||||
" check IRQ assignement\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
TRACE(("usb_ohci: found device at IRQ %u\n",
|
||||
item->u.h0.interrupt_line));
|
||||
TRACE_MODULE("found device at IRQ %u\n",
|
||||
item->u.h0.interrupt_line);
|
||||
OHCI *bus = new(std::nothrow) OHCI(item, stack);
|
||||
if (!bus) {
|
||||
delete item;
|
||||
@@ -556,7 +554,7 @@ OHCI::AddTo(Stack *stack)
|
||||
}
|
||||
|
||||
if (bus->InitCheck() < B_OK) {
|
||||
TRACE_ERROR(("usb_ohci: bus failed init check\n"));
|
||||
TRACE_MODULE_ERROR("bus failed init check\n");
|
||||
delete bus;
|
||||
continue;
|
||||
}
|
||||
@@ -571,7 +569,7 @@ OHCI::AddTo(Stack *stack)
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
TRACE_ERROR(("usb_ohci: no devices found\n"));
|
||||
TRACE_MODULE_ERROR("no devices found\n");
|
||||
delete item;
|
||||
sPCIModule = NULL;
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
@@ -587,7 +585,7 @@ status_t
|
||||
OHCI::GetPortStatus(uint8 index, usb_port_status *status)
|
||||
{
|
||||
if (index >= fPortCount) {
|
||||
TRACE_ERROR(("usb_ohci: get port status for invalid port %u\n", index));
|
||||
TRACE_ERROR("get port status for invalid port %u\n", index);
|
||||
return B_BAD_INDEX;
|
||||
}
|
||||
|
||||
@@ -622,8 +620,8 @@ OHCI::GetPortStatus(uint8 index, usb_port_status *status)
|
||||
if (portStatus & OHCI_RH_PORTSTATUS_PRSC)
|
||||
status->change |= PORT_STATUS_RESET;
|
||||
|
||||
TRACE(("usb_ohci: port %u status 0x%04x change 0x%04x\n", index,
|
||||
status->status, status->change));
|
||||
TRACE("port %u status 0x%04x change 0x%04x\n", index,
|
||||
status->status, status->change);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -631,7 +629,7 @@ OHCI::GetPortStatus(uint8 index, usb_port_status *status)
|
||||
status_t
|
||||
OHCI::SetPortFeature(uint8 index, uint16 feature)
|
||||
{
|
||||
TRACE(("usb_ohci: set port feature index %u feature %u\n", index, feature));
|
||||
TRACE("set port feature index %u feature %u\n", index, feature);
|
||||
if (index > fPortCount)
|
||||
return B_BAD_INDEX;
|
||||
|
||||
@@ -660,7 +658,7 @@ OHCI::SetPortFeature(uint8 index, uint16 feature)
|
||||
status_t
|
||||
OHCI::ClearPortFeature(uint8 index, uint16 feature)
|
||||
{
|
||||
TRACE(("usb_ohci: clear port feature index %u feature %u\n", index, feature));
|
||||
TRACE("clear port feature index %u feature %u\n", index, feature);
|
||||
if (index > fPortCount)
|
||||
return B_BAD_INDEX;
|
||||
|
||||
@@ -746,12 +744,12 @@ OHCI::_Interrupt()
|
||||
}
|
||||
|
||||
if (status & OHCI_SCHEDULING_OVERRUN) {
|
||||
TRACE(("usb_ohci: scheduling overrun occured\n"));
|
||||
TRACE_MODULE("scheduling overrun occured\n");
|
||||
acknowledge |= OHCI_SCHEDULING_OVERRUN;
|
||||
}
|
||||
|
||||
if (status & OHCI_WRITEBACK_DONE_HEAD) {
|
||||
TRACE(("usb_ohci: transfer descriptors processed\n"));
|
||||
TRACE_MODULE("transfer descriptors processed\n");
|
||||
fHcca->done_head = 0;
|
||||
acknowledge |= OHCI_WRITEBACK_DONE_HEAD;
|
||||
result = B_INVOKE_SCHEDULER;
|
||||
@@ -759,18 +757,18 @@ OHCI::_Interrupt()
|
||||
}
|
||||
|
||||
if (status & OHCI_RESUME_DETECTED) {
|
||||
TRACE(("usb_ohci: resume detected\n"));
|
||||
TRACE_MODULE("resume detected\n");
|
||||
acknowledge |= OHCI_RESUME_DETECTED;
|
||||
}
|
||||
|
||||
if (status & OHCI_UNRECOVERABLE_ERROR) {
|
||||
TRACE_ERROR(("usb_ohci: unrecoverable error - controller halted\n"));
|
||||
TRACE_MODULE_ERROR("unrecoverable error - controller halted\n");
|
||||
_WriteReg(OHCI_CONTROL, OHCI_HC_FUNCTIONAL_STATE_RESET);
|
||||
// TODO: clear all pending transfers, reset and resetup the controller
|
||||
}
|
||||
|
||||
if (status & OHCI_ROOT_HUB_STATUS_CHANGE) {
|
||||
TRACE(("usb_ohci: root hub status change\n"));
|
||||
TRACE_MODULE("root hub status change\n");
|
||||
// Disable the interrupt as it will otherwise be retriggered until the
|
||||
// port has been reset and the change is cleared explicitly.
|
||||
// TODO: renable it once we use status changes instead of polling
|
||||
@@ -879,8 +877,8 @@ OHCI::_FinishTransfers()
|
||||
if (!Lock())
|
||||
continue;
|
||||
|
||||
TRACE(("usb_ohci: finishing transfers (first transfer: %p; last"
|
||||
" transfer: %p)\n", fFirstTransfer, fLastTransfer));
|
||||
TRACE("finishing transfers (first transfer: %p; last"
|
||||
" transfer: %p)\n", fFirstTransfer, fLastTransfer);
|
||||
transfer_data *lastTransfer = NULL;
|
||||
transfer_data *transfer = fFirstTransfer;
|
||||
Unlock();
|
||||
@@ -894,7 +892,7 @@ OHCI::_FinishTransfers()
|
||||
uint32 status = OHCI_TD_GET_CONDITION_CODE(descriptor->flags);
|
||||
if (status == OHCI_TD_CONDITION_NOT_ACCESSED) {
|
||||
// td is still active
|
||||
TRACE(("usb_ohci: td %p still active\n", descriptor));
|
||||
TRACE("td %p still active\n", descriptor);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -908,7 +906,7 @@ OHCI::_FinishTransfers()
|
||||
// was halted because of this td, but we do not need
|
||||
// to know, as when it was halted by another td this
|
||||
// still ensures that this td was handled before).
|
||||
TRACE_ERROR(("usb_ohci: td error: 0x%08lx\n", status));
|
||||
TRACE_ERROR("td error: 0x%08lx\n", status);
|
||||
|
||||
switch (status) {
|
||||
case OHCI_TD_CONDITION_CRC_ERROR:
|
||||
@@ -959,13 +957,13 @@ OHCI::_FinishTransfers()
|
||||
} else {
|
||||
// an error occured but the endpoint is not halted so
|
||||
// the td is in fact still active
|
||||
TRACE(("usb_ohci: td %p active with error\n", descriptor));
|
||||
TRACE("td %p active with error\n", descriptor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// the td has complete without an error
|
||||
TRACE(("usb_ohci: td %p done\n", descriptor));
|
||||
TRACE("td %p done\n", descriptor);
|
||||
|
||||
if (descriptor == transfer->last_descriptor
|
||||
|| descriptor->buffer_physical != 0) {
|
||||
@@ -1013,8 +1011,8 @@ OHCI::_FinishTransfers()
|
||||
|
||||
// break the descriptor chain on the last descriptor
|
||||
transfer->last_descriptor->next_logical_descriptor = NULL;
|
||||
TRACE(("usb_ohci: transfer %p done with status 0x%08lx\n",
|
||||
transfer, callbackStatus));
|
||||
TRACE("transfer %p done with status 0x%08lx\n",
|
||||
transfer, callbackStatus);
|
||||
|
||||
// if canceled the callback has already been called
|
||||
if (!transfer->canceled) {
|
||||
@@ -1037,11 +1035,11 @@ OHCI::_FinishTransfers()
|
||||
|
||||
if (transfer->transfer->IsFragmented()) {
|
||||
// this transfer may still have data left
|
||||
TRACE(("usb_ohci: advancing fragmented transfer\n"));
|
||||
TRACE("advancing fragmented transfer\n");
|
||||
transfer->transfer->AdvanceByFragment(actualLength);
|
||||
if (transfer->transfer->VectorLength() > 0) {
|
||||
TRACE(("usb_ohci: still %ld bytes left on transfer\n",
|
||||
transfer->transfer->VectorLength()));
|
||||
TRACE("still %ld bytes left on transfer\n",
|
||||
transfer->transfer->VectorLength());
|
||||
// TODO actually resubmit the transfer
|
||||
}
|
||||
|
||||
@@ -1080,7 +1078,7 @@ OHCI::_SubmitRequest(Transfer *transfer)
|
||||
ohci_general_td *setupDescriptor
|
||||
= _CreateGeneralDescriptor(sizeof(usb_request_data));
|
||||
if (!setupDescriptor) {
|
||||
TRACE_ERROR(("usb_ohci: failed to allocate setup descriptor\n"));
|
||||
TRACE_ERROR("failed to allocate setup descriptor\n");
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
@@ -1091,7 +1089,7 @@ OHCI::_SubmitRequest(Transfer *transfer)
|
||||
|
||||
ohci_general_td *statusDescriptor = _CreateGeneralDescriptor(0);
|
||||
if (!statusDescriptor) {
|
||||
TRACE_ERROR(("usb_ohci: failed to allocate status descriptor\n"));
|
||||
TRACE_ERROR("failed to allocate status descriptor\n");
|
||||
_FreeGeneralDescriptor(setupDescriptor);
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
@@ -1137,7 +1135,7 @@ OHCI::_SubmitRequest(Transfer *transfer)
|
||||
result = _AddPendingTransfer(transfer, endpoint, setupDescriptor,
|
||||
dataDescriptor, statusDescriptor, directionIn);
|
||||
if (result < B_OK) {
|
||||
TRACE_ERROR(("usb_ohci: failed to add pending transfer\n"));
|
||||
TRACE_ERROR("failed to add pending transfer\n");
|
||||
_FreeDescriptorChain(setupDescriptor);
|
||||
return result;
|
||||
}
|
||||
@@ -1183,7 +1181,7 @@ OHCI::_SubmitTransfer(Transfer *transfer)
|
||||
result = _AddPendingTransfer(transfer, endpoint, firstDescriptor,
|
||||
firstDescriptor, lastDescriptor, directionIn);
|
||||
if (result < B_OK) {
|
||||
TRACE_ERROR(("usb_ohci: failed to add pending transfer\n"));
|
||||
TRACE_ERROR("failed to add pending transfer\n");
|
||||
_FreeDescriptorChain(firstDescriptor);
|
||||
return result;
|
||||
}
|
||||
@@ -1289,7 +1287,7 @@ OHCI::_AllocateEndpoint()
|
||||
// Allocate memory chunk
|
||||
if (fStack->AllocateChunk((void **)&endpoint, &physicalAddress,
|
||||
sizeof(ohci_endpoint_descriptor)) < B_OK) {
|
||||
TRACE_ERROR(("usb_ohci: failed to allocate endpoint descriptor\n"));
|
||||
TRACE_ERROR("failed to allocate endpoint descriptor\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1318,12 +1316,12 @@ OHCI::_FreeEndpoint(ohci_endpoint_descriptor *endpoint)
|
||||
status_t
|
||||
OHCI::_InsertEndpointForPipe(Pipe *pipe)
|
||||
{
|
||||
TRACE(("usb_ohci: inserting endpoint for device %u endpoint %u\n",
|
||||
pipe->DeviceAddress(), pipe->EndpointAddress()));
|
||||
TRACE("inserting endpoint for device %u endpoint %u\n",
|
||||
pipe->DeviceAddress(), pipe->EndpointAddress());
|
||||
|
||||
ohci_endpoint_descriptor *endpoint = _AllocateEndpoint();
|
||||
if (!endpoint) {
|
||||
TRACE_ERROR(("usb_ohci: cannot allocate memory for endpoint\n"));
|
||||
TRACE_ERROR("cannot allocate memory for endpoint\n");
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
@@ -1348,7 +1346,7 @@ OHCI::_InsertEndpointForPipe(Pipe *pipe)
|
||||
break;
|
||||
|
||||
default:
|
||||
TRACE_ERROR(("usb_ohci: direction unknown\n"));
|
||||
TRACE_ERROR("direction unknown\n");
|
||||
_FreeEndpoint(endpoint);
|
||||
return B_ERROR;
|
||||
}
|
||||
@@ -1364,7 +1362,7 @@ OHCI::_InsertEndpointForPipe(Pipe *pipe)
|
||||
break;
|
||||
|
||||
default:
|
||||
TRACE_ERROR(("usb_ohci: unaccetable speed\n"));
|
||||
TRACE_ERROR("unaccetable speed\n");
|
||||
_FreeEndpoint(endpoint);
|
||||
return B_ERROR;
|
||||
}
|
||||
@@ -1385,10 +1383,10 @@ OHCI::_InsertEndpointForPipe(Pipe *pipe)
|
||||
else if (type & USB_OBJECT_ISO_PIPE)
|
||||
head = fDummyIsochronous;
|
||||
else
|
||||
TRACE_ERROR(("usb_ohci: unknown pipe type\n"));
|
||||
TRACE_ERROR("unknown pipe type\n");
|
||||
|
||||
if (head == NULL) {
|
||||
TRACE_ERROR(("usb_ohci: no list found for endpoint\n"));
|
||||
TRACE_ERROR("no list found for endpoint\n");
|
||||
_FreeEndpoint(endpoint);
|
||||
return B_ERROR;
|
||||
}
|
||||
@@ -1431,8 +1429,8 @@ OHCI::_InsertEndpointForPipe(Pipe *pipe)
|
||||
status_t
|
||||
OHCI::_RemoveEndpointForPipe(Pipe *pipe)
|
||||
{
|
||||
TRACE(("usb_ohci: removing endpoint for device %u endpoint %u\n",
|
||||
pipe->DeviceAddress(), pipe->EndpointAddress()));
|
||||
TRACE("removing endpoint for device %u endpoint %u\n",
|
||||
pipe->DeviceAddress(), pipe->EndpointAddress());
|
||||
|
||||
ohci_endpoint_descriptor *endpoint
|
||||
= (ohci_endpoint_descriptor *)pipe->ControllerCookie();
|
||||
@@ -1470,7 +1468,7 @@ OHCI::_CreateGeneralDescriptor(size_t bufferSize)
|
||||
|
||||
if (fStack->AllocateChunk((void **)&descriptor, &physicalAddress,
|
||||
sizeof(ohci_general_td)) != B_OK) {
|
||||
TRACE_ERROR(("usb_ohci: failed to allocate general descriptor\n"));
|
||||
TRACE_ERROR("failed to allocate general descriptor\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1487,7 +1485,7 @@ OHCI::_CreateGeneralDescriptor(size_t bufferSize)
|
||||
|
||||
if (fStack->AllocateChunk(&descriptor->buffer_logical,
|
||||
(void **)&descriptor->buffer_physical, bufferSize) != B_OK) {
|
||||
TRACE_ERROR(("usb_ohci: failed to allocate space for buffer\n"));
|
||||
TRACE_ERROR("failed to allocate space for buffer\n");
|
||||
fStack->FreeChunk(descriptor, (void *)descriptor->physical_address,
|
||||
sizeof(ohci_general_td));
|
||||
return NULL;
|
||||
@@ -1589,9 +1587,9 @@ OHCI::_WriteDescriptorChain(ohci_general_td *topDescriptor, iovec *vector,
|
||||
size_t length = min_c(current->buffer_size - bufferOffset,
|
||||
vector[vectorIndex].iov_len - vectorOffset);
|
||||
|
||||
TRACE(("usb_ohci: copying %ld bytes to bufferOffset %ld from"
|
||||
TRACE("copying %ld bytes to bufferOffset %ld from"
|
||||
" vectorOffset %ld at index %ld of %ld\n", length, bufferOffset,
|
||||
vectorOffset, vectorIndex, vectorCount));
|
||||
vectorOffset, vectorIndex, vectorCount);
|
||||
memcpy((uint8 *)current->buffer_logical + bufferOffset,
|
||||
(uint8 *)vector[vectorIndex].iov_base + vectorOffset, length);
|
||||
|
||||
@@ -1601,8 +1599,8 @@ OHCI::_WriteDescriptorChain(ohci_general_td *topDescriptor, iovec *vector,
|
||||
|
||||
if (vectorOffset >= vector[vectorIndex].iov_len) {
|
||||
if (++vectorIndex >= vectorCount) {
|
||||
TRACE(("usb_ohci: wrote descriptor chain (%ld bytes, no"
|
||||
" more vectors)\n", actualLength));
|
||||
TRACE("wrote descriptor chain (%ld bytes, no"
|
||||
" more vectors)\n", actualLength);
|
||||
return actualLength;
|
||||
}
|
||||
|
||||
@@ -1621,7 +1619,7 @@ OHCI::_WriteDescriptorChain(ohci_general_td *topDescriptor, iovec *vector,
|
||||
current = (ohci_general_td *)current->next_logical_descriptor;
|
||||
}
|
||||
|
||||
TRACE(("usb_ohci: wrote descriptor chain (%ld bytes)\n", actualLength));
|
||||
TRACE("wrote descriptor chain (%ld bytes)\n", actualLength);
|
||||
return actualLength;
|
||||
}
|
||||
|
||||
@@ -1651,9 +1649,9 @@ OHCI::_ReadDescriptorChain(ohci_general_td *topDescriptor, iovec *vector,
|
||||
size_t length = min_c(bufferSize - bufferOffset,
|
||||
vector[vectorIndex].iov_len - vectorOffset);
|
||||
|
||||
TRACE(("usb_ohci: copying %ld bytes to vectorOffset %ld from"
|
||||
TRACE("copying %ld bytes to vectorOffset %ld from"
|
||||
" bufferOffset %ld at index %ld of %ld\n", length, vectorOffset,
|
||||
bufferOffset, vectorIndex, vectorCount));
|
||||
bufferOffset, vectorIndex, vectorCount);
|
||||
memcpy((uint8 *)vector[vectorIndex].iov_base + vectorOffset,
|
||||
(uint8 *)current->buffer_logical + bufferOffset, length);
|
||||
|
||||
@@ -1663,7 +1661,8 @@ OHCI::_ReadDescriptorChain(ohci_general_td *topDescriptor, iovec *vector,
|
||||
|
||||
if (vectorOffset >= vector[vectorIndex].iov_len) {
|
||||
if (++vectorIndex >= vectorCount) {
|
||||
TRACE(("usb_ohci: read descriptor chain (%ld bytes, no more vectors)\n", actualLength));
|
||||
TRACE("read descriptor chain (%ld bytes, no more vectors)\n",
|
||||
actualLength);
|
||||
return actualLength;
|
||||
}
|
||||
|
||||
@@ -1679,7 +1678,7 @@ OHCI::_ReadDescriptorChain(ohci_general_td *topDescriptor, iovec *vector,
|
||||
current = (ohci_general_td *)current->next_logical_descriptor;
|
||||
}
|
||||
|
||||
TRACE(("usb_ohci: read descriptor chain (%ld bytes)\n", actualLength));
|
||||
TRACE("read descriptor chain (%ld bytes)\n", actualLength);
|
||||
return actualLength;
|
||||
}
|
||||
|
||||
@@ -1702,7 +1701,7 @@ OHCI::_ReadActualLength(ohci_general_td *topDescriptor)
|
||||
current = (ohci_general_td *)current->next_logical_descriptor;
|
||||
}
|
||||
|
||||
TRACE(("usb_ohci: read actual length (%ld bytes)\n", actualLength));
|
||||
TRACE("read actual length (%ld bytes)\n", actualLength);
|
||||
return actualLength;
|
||||
}
|
||||
|
||||
@@ -1761,7 +1760,7 @@ OHCI::_ReadReg(uint32 reg)
|
||||
void
|
||||
OHCI::_PrintEndpoint(ohci_endpoint_descriptor *endpoint)
|
||||
{
|
||||
dprintf("usb_ohci: endpoint %p\n", endpoint);
|
||||
TRACE_ALWAYS("endpoint %p\n", endpoint);
|
||||
dprintf("\tflags........... 0x%08lx\n", endpoint->flags);
|
||||
dprintf("\ttail_physical... 0x%08lx\n", endpoint->tail_physical_descriptor);
|
||||
dprintf("\thead_physical... 0x%08lx\n", endpoint->head_physical_descriptor);
|
||||
@@ -1776,7 +1775,7 @@ void
|
||||
OHCI::_PrintDescriptorChain(ohci_general_td *topDescriptor)
|
||||
{
|
||||
while (topDescriptor) {
|
||||
dprintf("usb_ohci: descriptor %p\n", topDescriptor);
|
||||
TRACE_ALWAYS("descriptor %p\n", topDescriptor);
|
||||
dprintf("\tflags........... 0x%08lx\n", topDescriptor->flags);
|
||||
dprintf("\tbuffer_physical. 0x%08lx\n", topDescriptor->buffer_physical);
|
||||
dprintf("\tnext_physical... 0x%08lx\n", topDescriptor->next_physical_descriptor);
|
||||
|
||||
@@ -55,6 +55,7 @@ static status_t AddTo(Stack *stack);
|
||||
|
||||
status_t ResetPort(uint8 index);
|
||||
|
||||
virtual const char * TypeName() { return "ohci"; };
|
||||
|
||||
private:
|
||||
// Interrupt functions
|
||||
|
||||
@@ -12,6 +12,6 @@ resource app_version {
|
||||
variety = 0,
|
||||
internal = 0,
|
||||
short_info = "OHCI host controller driver",
|
||||
long_info = "Haiku OHCI HCD - Copyright 2005-2008, Haiku Inc."
|
||||
long_info = "Haiku OHCI HCD - Copyright 2005-2009, Haiku Inc."
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
#include "ohci.h"
|
||||
|
||||
#define USB_MODULE_NAME "ohci roothub"
|
||||
|
||||
static usb_device_descriptor sOHCIRootHubDevice =
|
||||
{
|
||||
18, // Descriptor length
|
||||
@@ -137,7 +139,7 @@ OHCIRootHub::ProcessTransfer(OHCI *ohci, Transfer *transfer)
|
||||
return B_ERROR;
|
||||
|
||||
usb_request_data *request = transfer->RequestData();
|
||||
TRACE(("usb_ohci_roothub: request: %d\n", request->Request));
|
||||
TRACE_MODULE("request: %d\n", request->Request);
|
||||
|
||||
status_t status = B_TIMED_OUT;
|
||||
size_t actualLength = 0;
|
||||
@@ -171,12 +173,12 @@ OHCIRootHub::ProcessTransfer(OHCI *ohci, Transfer *transfer)
|
||||
break;
|
||||
}
|
||||
|
||||
TRACE(("usb_ohci_roothub: set address: %d\n", request->Value));
|
||||
TRACE_MODULE("set address: %d\n", request->Value);
|
||||
status = B_OK;
|
||||
break;
|
||||
|
||||
case USB_REQUEST_GET_DESCRIPTOR:
|
||||
TRACE(("usb_ohci_roothub: get descriptor: %d\n", request->Value >> 8));
|
||||
TRACE_MODULE("get descriptor: %d\n", request->Value >> 8);
|
||||
|
||||
switch (request->Value >> 8) {
|
||||
case USB_DESCRIPTOR_DEVICE: {
|
||||
@@ -230,11 +232,11 @@ OHCIRootHub::ProcessTransfer(OHCI *ohci, Transfer *transfer)
|
||||
case USB_REQUEST_CLEAR_FEATURE: {
|
||||
if (request->Index == 0) {
|
||||
// we don't support any hub changes
|
||||
TRACE_ERROR(("usb_ohci_roothub: clear feature: no hub changes\n"));
|
||||
TRACE_MODULE_ERROR("clear feature: no hub changes\n");
|
||||
break;
|
||||
}
|
||||
|
||||
TRACE(("usb_ohci_roothub: clear feature: %d\n", request->Value));
|
||||
TRACE_MODULE("clear feature: %d\n", request->Value);
|
||||
if (ohci->ClearPortFeature(request->Index - 1, request->Value) >= B_OK)
|
||||
status = B_OK;
|
||||
break;
|
||||
@@ -243,11 +245,11 @@ OHCIRootHub::ProcessTransfer(OHCI *ohci, Transfer *transfer)
|
||||
case USB_REQUEST_SET_FEATURE: {
|
||||
if (request->Index == 0) {
|
||||
// we don't support any hub changes
|
||||
TRACE_ERROR(("usb_ohci_roothub: set feature: no hub changes\n"));
|
||||
TRACE_MODULE_ERROR("set feature: no hub changes\n");
|
||||
break;
|
||||
}
|
||||
|
||||
TRACE(("usb_ohci_roothub: set feature: %d\n", request->Value));
|
||||
TRACE_MODULE("set feature: %d\n", request->Value);
|
||||
if (ohci->SetPortFeature(request->Index - 1, request->Value) >= B_OK)
|
||||
status = B_OK;
|
||||
break;
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
#include "uhci.h"
|
||||
|
||||
#define USB_MODULE_NAME "uhci"
|
||||
|
||||
pci_module_info *UHCI::sPCIModule = NULL;
|
||||
|
||||
|
||||
@@ -23,10 +25,10 @@ uhci_std_ops(int32 op, ...)
|
||||
{
|
||||
switch (op) {
|
||||
case B_MODULE_INIT:
|
||||
TRACE(("usb_uhci_module: init module\n"));
|
||||
TRACE_MODULE("init module\n");
|
||||
return B_OK;
|
||||
case B_MODULE_UNINIT:
|
||||
TRACE(("usb_uhci_module: uninit module\n"));
|
||||
TRACE_MODULE("uninit module\n");
|
||||
break;
|
||||
default:
|
||||
return EINVAL;
|
||||
@@ -166,7 +168,7 @@ Queue::TerminateByStrayDescriptor()
|
||||
status_t result = fStack->AllocateChunk((void **)&fStrayDescriptor,
|
||||
&physicalAddress, sizeof(uhci_td));
|
||||
if (result < B_OK) {
|
||||
TRACE_ERROR(("usb_uhci: failed to allocate a stray transfer descriptor\n"));
|
||||
TRACE_ERROR("failed to allocate a stray transfer descriptor\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -271,7 +273,7 @@ void
|
||||
Queue::PrintToStream()
|
||||
{
|
||||
#ifdef TRACE_USB
|
||||
dprintf("USB UHCI Queue:\n");
|
||||
TRACE("queue:\n");
|
||||
dprintf("link phy: 0x%08lx; 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%08lx; elem type: %s; terminate: %s\n", fQueueHead->element_phy & 0xfff0, fQueueHead->element_phy & 0x0002 ? "QH" : "TD", fQueueHead->element_phy & 0x0001 ? "yes" : "no");
|
||||
#endif
|
||||
@@ -310,21 +312,21 @@ UHCI::UHCI(pci_info *info, Stack *stack)
|
||||
fPortResetChange(0)
|
||||
{
|
||||
if (!fInitOK) {
|
||||
TRACE_ERROR(("usb_uhci: bus manager failed to init\n"));
|
||||
TRACE_ERROR("bus manager failed to init\n");
|
||||
return;
|
||||
}
|
||||
|
||||
TRACE(("usb_uhci: constructing new UHCI Host Controller Driver\n"));
|
||||
TRACE("constructing new UHCI host controller driver\n");
|
||||
fInitOK = false;
|
||||
|
||||
fRegisterBase = sPCIModule->read_pci_config(fPCIInfo->bus,
|
||||
fPCIInfo->device, fPCIInfo->function, PCI_memory_base, 4);
|
||||
fRegisterBase &= PCI_address_io_mask;
|
||||
TRACE(("usb_uhci: iospace offset: 0x%08lx\n", fRegisterBase));
|
||||
TRACE("iospace offset: 0x%08lx\n", fRegisterBase);
|
||||
|
||||
if (fRegisterBase == 0) {
|
||||
fRegisterBase = fPCIInfo->u.h0.base_registers[0];
|
||||
TRACE_ERROR(("usb_uhci: register base: 0x%08lx\n", fRegisterBase));
|
||||
TRACE_ALWAYS("register base: 0x%08lx\n", fRegisterBase);
|
||||
}
|
||||
|
||||
// enable pci address access
|
||||
@@ -346,7 +348,7 @@ UHCI::UHCI(pci_info *info, Stack *stack)
|
||||
// do a global and host reset
|
||||
GlobalReset();
|
||||
if (ControllerReset() < B_OK) {
|
||||
TRACE_ERROR(("usb_uhci: host failed to reset\n"));
|
||||
TRACE_ERROR("host failed to reset\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -356,7 +358,7 @@ UHCI::UHCI(pci_info *info, Stack *stack)
|
||||
(void **)&physicalAddress, 4096, "USB UHCI framelist");
|
||||
|
||||
if (fFrameArea < B_OK) {
|
||||
TRACE_ERROR(("usb_uhci: unable to create an area for the frame pointer list\n"));
|
||||
TRACE_ERROR("unable to create an area for the frame pointer list\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -383,7 +385,7 @@ UHCI::UHCI(pci_info *info, Stack *stack)
|
||||
for (int32 i = 0; i < fQueueCount; i++) {
|
||||
fQueues[i] = new(std::nothrow) Queue(fStack);
|
||||
if (!fQueues[i] || fQueues[i]->InitCheck() < B_OK) {
|
||||
TRACE_ERROR(("usb_uhci: cannot create queues\n"));
|
||||
TRACE_ERROR("cannot create queues\n");
|
||||
delete_area(fFrameArea);
|
||||
return;
|
||||
}
|
||||
@@ -401,12 +403,13 @@ UHCI::UHCI(pci_info *info, Stack *stack)
|
||||
// Create lists for managing isochronous transfer descriptors
|
||||
fFirstIsochronousDescriptor = new(std::nothrow) uhci_td *[NUMBER_OF_FRAMES];
|
||||
if (!fFirstIsochronousDescriptor) {
|
||||
TRACE_ERROR(("usb_uhci: cannot allocate memory\n"));
|
||||
TRACE_ERROR("faild to allocate memory for first isochronous descriptor\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fLastIsochronousDescriptor = new(std::nothrow) uhci_td *[NUMBER_OF_FRAMES];
|
||||
if (!fLastIsochronousDescriptor) {
|
||||
TRACE_ERROR(("usb_uhci: cannot allocate memory\n"));
|
||||
TRACE_ERROR("failed to allocate memory for last isochronous descriptor\n");
|
||||
delete [] fFirstIsochronousDescriptor;
|
||||
return;
|
||||
}
|
||||
@@ -422,7 +425,7 @@ UHCI::UHCI(pci_info *info, Stack *stack)
|
||||
// Create semaphore the finisher thread will wait for
|
||||
fFinishTransfersSem = create_sem(0, "UHCI Finish Transfers");
|
||||
if (fFinishTransfersSem < B_OK) {
|
||||
TRACE_ERROR(("usb_uhci: failed to create semaphore\n"));
|
||||
TRACE_ERROR("failed to create finisher semaphore\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -438,7 +441,7 @@ UHCI::UHCI(pci_info *info, Stack *stack)
|
||||
fFinishIsochronousTransfersSem = create_sem(0,
|
||||
"UHCI Isochronous Finish Transfers");
|
||||
if (fFinishIsochronousTransfersSem < B_OK) {
|
||||
TRACE_ERROR(("usb_uhci: failed to create semaphore\n"));
|
||||
TRACE_ERROR("failed to create isochronous finisher semaphore\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -449,7 +452,7 @@ UHCI::UHCI(pci_info *info, Stack *stack)
|
||||
resume_thread(fFinishIsochronousThread);
|
||||
|
||||
// Install the interrupt handler
|
||||
TRACE(("usb_uhci: installing interrupt handler\n"));
|
||||
TRACE("installing interrupt handler\n");
|
||||
install_io_interrupt_handler(fPCIInfo->u.h0.interrupt_line,
|
||||
InterruptHandler, (void *)this, 0);
|
||||
|
||||
@@ -459,7 +462,7 @@ UHCI::UHCI(pci_info *info, Stack *stack)
|
||||
WriteReg16(UHCI_USBINTR, UHCI_USBINTR_CRC | UHCI_USBINTR_IOC
|
||||
| UHCI_USBINTR_SHORT);
|
||||
|
||||
TRACE(("usb_uhci: UHCI Host Controller Driver constructed\n"));
|
||||
TRACE("UHCI host controller driver constructed\n");
|
||||
fInitOK = true;
|
||||
}
|
||||
|
||||
@@ -513,9 +516,9 @@ status_t
|
||||
UHCI::Start()
|
||||
{
|
||||
// Start the host controller, then start the Busmanager
|
||||
TRACE(("usb_uhci: starting UHCI BusManager\n"));
|
||||
TRACE(("usb_uhci: usbcmd reg 0x%04x, usbsts reg 0x%04x\n",
|
||||
ReadReg16(UHCI_USBCMD), ReadReg16(UHCI_USBSTS)));
|
||||
TRACE("starting UHCI BusManager\n");
|
||||
TRACE("usbcmd reg 0x%04x, usbsts reg 0x%04x\n",
|
||||
ReadReg16(UHCI_USBCMD), ReadReg16(UHCI_USBSTS));
|
||||
|
||||
// Set the run bit in the command register
|
||||
WriteReg16(UHCI_USBCMD, ReadReg16(UHCI_USBCMD) | UHCI_USBCMD_RS);
|
||||
@@ -523,7 +526,7 @@ UHCI::Start()
|
||||
bool running = false;
|
||||
for (int32 i = 0; i < 10; i++) {
|
||||
uint16 status = ReadReg16(UHCI_USBSTS);
|
||||
TRACE(("usb_uhci: current loop %ld, status 0x%04x\n", i, status));
|
||||
TRACE("current loop %ld, status 0x%04x\n", i, status);
|
||||
|
||||
if (status & UHCI_USBSTS_HCHALT)
|
||||
snooze(10000);
|
||||
@@ -534,28 +537,28 @@ UHCI::Start()
|
||||
}
|
||||
|
||||
if (!running) {
|
||||
TRACE_ERROR(("usb_uhci: controller won't start running\n"));
|
||||
TRACE_ERROR("controller won't start running\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
fRootHubAddress = AllocateAddress();
|
||||
fRootHub = new(std::nothrow) UHCIRootHub(RootObject(), fRootHubAddress);
|
||||
if (!fRootHub) {
|
||||
TRACE_ERROR(("usb_uhci: no memory to allocate root hub\n"));
|
||||
TRACE_ERROR("no memory to allocate root hub\n");
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
if (fRootHub->InitCheck() < B_OK) {
|
||||
TRACE_ERROR(("usb_uhci: root hub failed init check\n"));
|
||||
TRACE_ERROR("root hub failed init check\n");
|
||||
delete fRootHub;
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
SetRootHub(fRootHub);
|
||||
|
||||
TRACE(("usb_uhci: controller is started. status: %u curframe: %u\n",
|
||||
ReadReg16(UHCI_USBSTS), ReadReg16(UHCI_FRNUM)));
|
||||
dprintf("usb_uhci: successfully started the controller\n");
|
||||
TRACE("controller is started. status: %u curframe: %u\n",
|
||||
ReadReg16(UHCI_USBSTS), ReadReg16(UHCI_FRNUM));
|
||||
TRACE_ALWAYS("successfully started the controller\n");
|
||||
return BusManager::Start();
|
||||
}
|
||||
|
||||
@@ -568,8 +571,7 @@ UHCI::SubmitTransfer(Transfer *transfer)
|
||||
if (pipe->DeviceAddress() == fRootHubAddress)
|
||||
return fRootHub->ProcessTransfer(this, transfer);
|
||||
|
||||
TRACE(("usb_uhci: submit transfer called for device %d\n",
|
||||
pipe->DeviceAddress()));
|
||||
TRACE("submit transfer called for device %d\n", pipe->DeviceAddress());
|
||||
if (pipe->Type() & USB_OBJECT_CONTROL_PIPE)
|
||||
return SubmitRequest(transfer);
|
||||
|
||||
@@ -594,7 +596,7 @@ UHCI::SubmitTransfer(Transfer *transfer)
|
||||
result = AddPendingTransfer(transfer, queue, transferQueue,
|
||||
firstDescriptor, firstDescriptor, directionIn);
|
||||
if (result < B_OK) {
|
||||
TRACE_ERROR(("usb_uhci: failed to add pending transfer\n"));
|
||||
TRACE_ERROR("failed to add pending transfer\n");
|
||||
FreeDescriptorChain(firstDescriptor);
|
||||
FreeTransferQueue(transferQueue);
|
||||
return result;
|
||||
@@ -689,7 +691,7 @@ UHCI::CancelQueuedIsochronousTransfers(Pipe *pipe, bool force)
|
||||
current = current->link;
|
||||
}
|
||||
|
||||
TRACE_ERROR(("usb_uhci: no isochronous transfer found!\n"));
|
||||
TRACE_ERROR("no isochronous transfer found!\n");
|
||||
return B_ERROR;
|
||||
}
|
||||
|
||||
@@ -708,7 +710,7 @@ UHCI::SubmitRequest(Transfer *transfer)
|
||||
directionIn ? TD_TOKEN_OUT : TD_TOKEN_IN, 0);
|
||||
|
||||
if (!setupDescriptor || !statusDescriptor) {
|
||||
TRACE_ERROR(("usb_uhci: failed to allocate descriptors\n"));
|
||||
TRACE_ERROR("failed to allocate descriptors\n");
|
||||
FreeDescriptor(setupDescriptor);
|
||||
FreeDescriptor(statusDescriptor);
|
||||
return B_NO_MEMORY;
|
||||
@@ -759,7 +761,7 @@ UHCI::SubmitRequest(Transfer *transfer)
|
||||
status_t result = AddPendingTransfer(transfer, queue, transferQueue,
|
||||
setupDescriptor, dataDescriptor, directionIn);
|
||||
if (result < B_OK) {
|
||||
TRACE_ERROR(("usb_uhci: failed to add pending transfer\n"));
|
||||
TRACE_ERROR("failed to add pending transfer\n");
|
||||
FreeDescriptorChain(setupDescriptor);
|
||||
FreeTransferQueue(transferQueue);
|
||||
return result;
|
||||
@@ -867,8 +869,7 @@ UHCI::SubmitIsochronous(Transfer *transfer)
|
||||
uint16 currentFrame;
|
||||
|
||||
if (packetSize > pipe->MaxPacketSize()) {
|
||||
TRACE_ERROR(("usb_uhci: isochronous packetSize is bigger"
|
||||
" than pipe MaxPacketSize\n"));
|
||||
TRACE_ERROR("isochronous packetSize is bigger than pipe MaxPacketSize\n");
|
||||
return B_BAD_VALUE;
|
||||
}
|
||||
|
||||
@@ -876,8 +877,7 @@ UHCI::SubmitIsochronous(Transfer *transfer)
|
||||
// The overhead is not worthy.
|
||||
uint16 bandwidth = transfer->Bandwidth() / isochronousData->packet_count;
|
||||
|
||||
TRACE(("usb_uhci: isochronous transfer descriptor bandwdith = %d\n",
|
||||
bandwidth));
|
||||
TRACE("isochronous transfer descriptor bandwdith %d\n", bandwidth);
|
||||
|
||||
// The following holds the list of transfer descriptor of the
|
||||
// isochronous request. It is used to quickly remove all the isochronous
|
||||
@@ -886,7 +886,7 @@ UHCI::SubmitIsochronous(Transfer *transfer)
|
||||
uhci_td **isoRequest
|
||||
= new(std::nothrow) uhci_td *[isochronousData->packet_count];
|
||||
if (isoRequest == NULL) {
|
||||
TRACE(("usb_uhci: failed to create isoRequest array!\n"));
|
||||
TRACE("failed to create isoRequest array!\n");
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
@@ -932,9 +932,9 @@ UHCI::SubmitIsochronous(Transfer *transfer)
|
||||
}
|
||||
}
|
||||
|
||||
TRACE(("usb_uhci: isochronous submitted size=%ld bytes, TDs=%ld, "
|
||||
TRACE("isochronous submitted size=%ld bytes, TDs=%ld, "
|
||||
"packetSize=%ld, restSize=%ld\n", transfer->DataLength(),
|
||||
isochronousData->packet_count, packetSize, restSize));
|
||||
isochronousData->packet_count, packetSize, restSize);
|
||||
|
||||
// Find the entry where to start inserting the first Isochronous descriptor
|
||||
if (isochronousData->flags & USB_ISO_ASAP ||
|
||||
@@ -963,8 +963,7 @@ UHCI::SubmitIsochronous(Transfer *transfer)
|
||||
while (fFrameBandwidth[currentFrame] < bandwidth) {
|
||||
currentFrame = (currentFrame + 1) % NUMBER_OF_FRAMES;
|
||||
if (currentFrame == startSeekingFromFrame) {
|
||||
TRACE_ERROR(("usb_uhci: Not enough bandwidth to queue the"
|
||||
" isochronous request. Try again later!\n"));
|
||||
TRACE_ERROR("not enough bandwidth to queue the isochronous request");
|
||||
for (uint32 i = 0; i < isochronousData->packet_count; i++)
|
||||
FreeDescriptor(isoRequest[i]);
|
||||
delete [] isoRequest;
|
||||
@@ -979,15 +978,15 @@ UHCI::SubmitIsochronous(Transfer *transfer)
|
||||
status_t result = AddPendingIsochronousTransfer(transfer, isoRequest,
|
||||
directionIn);
|
||||
if (result < B_OK) {
|
||||
TRACE_ERROR(("usb_uhci: failed to add pending isochronous transfer\n"));
|
||||
TRACE_ERROR("failed to add pending isochronous transfer\n");
|
||||
for (uint32 i = 0; i < isochronousData->packet_count; i++)
|
||||
FreeDescriptor(isoRequest[i]);
|
||||
delete [] isoRequest;
|
||||
return result;
|
||||
}
|
||||
|
||||
TRACE(("usb_uhci: appended isochronous transfer by starting at frame"
|
||||
" number %d\n", currentFrame));
|
||||
TRACE("appended isochronous transfer by starting at frame number %d\n",
|
||||
currentFrame);
|
||||
|
||||
// Insert the Transfer Descriptor by starting at
|
||||
// the starting_frame_number entry
|
||||
@@ -995,7 +994,7 @@ UHCI::SubmitIsochronous(Transfer *transfer)
|
||||
for (uint32 i = 0; i < isochronousData->packet_count; i++) {
|
||||
result = LinkIsochronousDescriptor(isoRequest[i], currentFrame);
|
||||
if (result < B_OK) {
|
||||
TRACE_ERROR(("usb_uhci: failed to add pending isochronous transfer\n"));
|
||||
TRACE_ERROR("failed to add pending isochronous transfer\n");
|
||||
for (uint32 i = 0; i < isochronousData->packet_count; i++)
|
||||
FreeDescriptor(isoRequest[i]);
|
||||
delete [] isoRequest;
|
||||
@@ -1111,9 +1110,9 @@ UHCI::FinishTransfers()
|
||||
if (!Lock())
|
||||
continue;
|
||||
|
||||
TRACE(("usb_uhci: finishing transfers (first transfer: 0x%08lx; last"
|
||||
TRACE("finishing transfers (first transfer: 0x%08lx; last"
|
||||
" transfer: 0x%08lx)\n", (uint32)fFirstTransfer,
|
||||
(uint32)fLastTransfer));
|
||||
(uint32)fLastTransfer);
|
||||
transfer_data *lastTransfer = NULL;
|
||||
transfer_data *transfer = fFirstTransfer;
|
||||
Unlock();
|
||||
@@ -1127,15 +1126,15 @@ UHCI::FinishTransfers()
|
||||
uint32 status = descriptor->status;
|
||||
if (status & TD_STATUS_ACTIVE) {
|
||||
// still in progress
|
||||
TRACE(("usb_uhci: td (0x%08lx) still active\n", descriptor->this_phy));
|
||||
TRACE("td (0x%08lx) still active\n", descriptor->this_phy);
|
||||
break;
|
||||
}
|
||||
|
||||
if (status & TD_ERROR_MASK) {
|
||||
// an error occured
|
||||
TRACE_ERROR(("usb_uhci: td (0x%08lx) error: status: 0x%08lx;"
|
||||
TRACE_ERROR("td (0x%08lx) error: status: 0x%08lx;"
|
||||
" token: 0x%08lx;\n", descriptor->this_phy, status,
|
||||
descriptor->token));
|
||||
descriptor->token);
|
||||
|
||||
uint8 errorCount = status >> TD_ERROR_COUNT_SHIFT;
|
||||
errorCount &= TD_ERROR_COUNT_MASK;
|
||||
@@ -1179,7 +1178,7 @@ UHCI::FinishTransfers()
|
||||
|| (descriptor->status & TD_STATUS_ACTLEN_MASK)
|
||||
< (descriptor->token >> TD_TOKEN_MAXLEN_SHIFT)) {
|
||||
// all descriptors are done, or we have a short packet
|
||||
TRACE(("usb_uhci: td (0x%08lx) ok\n", descriptor->this_phy));
|
||||
TRACE("td (0x%08lx) ok\n", descriptor->this_phy);
|
||||
callbackStatus = B_OK;
|
||||
transferDone = true;
|
||||
break;
|
||||
@@ -1235,11 +1234,11 @@ UHCI::FinishTransfers()
|
||||
|
||||
if (transfer->transfer->IsFragmented()) {
|
||||
// this transfer may still have data left
|
||||
TRACE(("usb_uhci: advancing fragmented transfer\n"));
|
||||
TRACE("advancing fragmented transfer\n");
|
||||
transfer->transfer->AdvanceByFragment(actualLength);
|
||||
if (transfer->transfer->VectorLength() > 0) {
|
||||
TRACE(("usb_uhci: still %ld bytes left on transfer\n",
|
||||
transfer->transfer->VectorLength()));
|
||||
TRACE("still %ld bytes left on transfer\n",
|
||||
transfer->transfer->VectorLength());
|
||||
|
||||
// free the used descriptors
|
||||
transfer->queue->RemoveTransfer(transfer->transfer_queue);
|
||||
@@ -1497,7 +1496,7 @@ UHCI::ResetPort(uint8 index)
|
||||
if (index > 1)
|
||||
return B_BAD_INDEX;
|
||||
|
||||
TRACE(("usb_uhci: reset port %d\n", index));
|
||||
TRACE("reset port %d\n", index);
|
||||
|
||||
uint32 port = UHCI_PORTSC1 + index * 2;
|
||||
uint16 status = ReadReg16(port);
|
||||
@@ -1540,7 +1539,7 @@ UHCI::ResetPort(uint8 index)
|
||||
}
|
||||
|
||||
fPortResetChange |= (1 << index);
|
||||
TRACE(("usb_uhci: port was reset: 0x%04x\n", ReadReg16(port)));
|
||||
TRACE("port was reset: 0x%04x\n", ReadReg16(port));
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -1570,36 +1569,36 @@ UHCI::Interrupt()
|
||||
int32 result = B_HANDLED_INTERRUPT;
|
||||
|
||||
if (status & UHCI_USBSTS_USBINT) {
|
||||
TRACE(("usb_uhci: transfer finished\n"));
|
||||
TRACE_MODULE("transfer finished\n");
|
||||
acknowledge |= UHCI_USBSTS_USBINT;
|
||||
result = B_INVOKE_SCHEDULER;
|
||||
finishTransfers = true;
|
||||
}
|
||||
|
||||
if (status & UHCI_USBSTS_ERRINT) {
|
||||
TRACE(("usb_uhci: transfer error\n"));
|
||||
TRACE_MODULE("transfer error\n");
|
||||
acknowledge |= UHCI_USBSTS_ERRINT;
|
||||
result = B_INVOKE_SCHEDULER;
|
||||
finishTransfers = true;
|
||||
}
|
||||
|
||||
if (status & UHCI_USBSTS_RESDET) {
|
||||
TRACE(("usb_uhci: resume detected\n"));
|
||||
TRACE_MODULE("resume detected\n");
|
||||
acknowledge |= UHCI_USBSTS_RESDET;
|
||||
}
|
||||
|
||||
if (status & UHCI_USBSTS_HOSTERR) {
|
||||
TRACE(("usb_uhci: host system error\n"));
|
||||
TRACE_MODULE("host system error\n");
|
||||
acknowledge |= UHCI_USBSTS_HOSTERR;
|
||||
}
|
||||
|
||||
if (status & UHCI_USBSTS_HCPRERR) {
|
||||
TRACE(("usb_uhci: process error\n"));
|
||||
TRACE_MODULE("process error\n");
|
||||
acknowledge |= UHCI_USBSTS_HCPRERR;
|
||||
}
|
||||
|
||||
if (status & UHCI_USBSTS_HCHALT) {
|
||||
TRACE_ERROR(("usb_uhci: host controller halted\n"));
|
||||
TRACE_MODULE_ERROR("host controller halted\n");
|
||||
// at least disable interrupts so we do not flood the system
|
||||
WriteReg16(UHCI_USBINTR, 0);
|
||||
fEnabledInterrupts = 0;
|
||||
@@ -1632,13 +1631,13 @@ 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%08lx\n",
|
||||
status));
|
||||
TRACE_MODULE_ERROR("AddTo(): getting pci module failed! 0x%08lx\n",
|
||||
status);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
TRACE(("usb_uhci: AddTo(): setting up hardware\n"));
|
||||
TRACE_MODULE("AddTo(): setting up hardware\n");
|
||||
|
||||
bool found = false;
|
||||
pci_info *item = new(std::nothrow) pci_info;
|
||||
@@ -1654,12 +1653,12 @@ UHCI::AddTo(Stack *stack)
|
||||
&& item->class_api == PCI_usb_uhci) {
|
||||
if (item->u.h0.interrupt_line == 0
|
||||
|| item->u.h0.interrupt_line == 0xFF) {
|
||||
TRACE_ERROR(("usb_uhci: AddTo(): found with invalid IRQ - check IRQ assignement\n"));
|
||||
TRACE_MODULE_ERROR("AddTo(): found with invalid IRQ - check IRQ assignement\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
TRACE(("usb_uhci: AddTo(): found at IRQ %u\n",
|
||||
item->u.h0.interrupt_line));
|
||||
TRACE_MODULE("AddTo(): found at IRQ %u\n",
|
||||
item->u.h0.interrupt_line);
|
||||
UHCI *bus = new(std::nothrow) UHCI(item, stack);
|
||||
if (!bus) {
|
||||
delete item;
|
||||
@@ -1669,8 +1668,8 @@ UHCI::AddTo(Stack *stack)
|
||||
}
|
||||
|
||||
if (bus->InitCheck() < B_OK) {
|
||||
TRACE_ERROR(("usb_uhci: AddTo(): InitCheck() failed 0x%08lx\n",
|
||||
bus->InitCheck()));
|
||||
TRACE_MODULE_ERROR("AddTo(): InitCheck() failed 0x%08lx\n",
|
||||
bus->InitCheck());
|
||||
delete bus;
|
||||
continue;
|
||||
}
|
||||
@@ -1685,7 +1684,7 @@ UHCI::AddTo(Stack *stack)
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
TRACE_ERROR(("usb_uhci: no devices found\n"));
|
||||
TRACE_MODULE_ERROR("no devices found\n");
|
||||
delete item;
|
||||
sPCIModule = NULL;
|
||||
put_module(B_PCI_MODULE_NAME);
|
||||
@@ -1769,7 +1768,7 @@ UHCI::CreateDescriptor(Pipe *pipe, uint8 direction, size_t bufferSize)
|
||||
|
||||
if (fStack->AllocateChunk((void **)&result, &physicalAddress,
|
||||
sizeof(uhci_td)) < B_OK) {
|
||||
TRACE_ERROR(("usb_uhci: failed to allocate a transfer descriptor\n"));
|
||||
TRACE_ERROR("failed to allocate a transfer descriptor\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1804,7 +1803,7 @@ UHCI::CreateDescriptor(Pipe *pipe, uint8 direction, size_t bufferSize)
|
||||
|
||||
if (fStack->AllocateChunk(&result->buffer_log, (void **)&result->buffer_phy,
|
||||
bufferSize) < B_OK) {
|
||||
TRACE_ERROR(("usb_uhci: unable to allocate space for the buffer\n"));
|
||||
TRACE_ERROR("unable to allocate space for the buffer\n");
|
||||
fStack->FreeChunk(result, (void *)result->this_phy, sizeof(uhci_td));
|
||||
return NULL;
|
||||
}
|
||||
@@ -1909,9 +1908,9 @@ UHCI::WriteDescriptorChain(uhci_td *topDescriptor, iovec *vector,
|
||||
size_t length = min_c(current->buffer_size - bufferOffset,
|
||||
vector[vectorIndex].iov_len - vectorOffset);
|
||||
|
||||
TRACE(("usb_uhci: copying %ld bytes to bufferOffset %ld from"
|
||||
TRACE("copying %ld bytes to bufferOffset %ld from"
|
||||
" vectorOffset %ld at index %ld of %ld\n", length, bufferOffset,
|
||||
vectorOffset, vectorIndex, vectorCount));
|
||||
vectorOffset, vectorIndex, vectorCount);
|
||||
memcpy((uint8 *)current->buffer_log + bufferOffset,
|
||||
(uint8 *)vector[vectorIndex].iov_base + vectorOffset, length);
|
||||
|
||||
@@ -1921,8 +1920,8 @@ UHCI::WriteDescriptorChain(uhci_td *topDescriptor, iovec *vector,
|
||||
|
||||
if (vectorOffset >= vector[vectorIndex].iov_len) {
|
||||
if (++vectorIndex >= vectorCount) {
|
||||
TRACE(("usb_uhci: wrote descriptor chain (%ld bytes, no"
|
||||
" more vectors)\n", actualLength));
|
||||
TRACE("wrote descriptor chain (%ld bytes, no more vectors)\n",
|
||||
actualLength);
|
||||
return actualLength;
|
||||
}
|
||||
|
||||
@@ -1941,7 +1940,7 @@ UHCI::WriteDescriptorChain(uhci_td *topDescriptor, iovec *vector,
|
||||
current = (uhci_td *)current->link_log;
|
||||
}
|
||||
|
||||
TRACE(("usb_uhci: wrote descriptor chain (%ld bytes)\n", actualLength));
|
||||
TRACE("wrote descriptor chain (%ld bytes)\n", actualLength);
|
||||
return actualLength;
|
||||
}
|
||||
|
||||
@@ -1970,9 +1969,9 @@ UHCI::ReadDescriptorChain(uhci_td *topDescriptor, iovec *vector,
|
||||
size_t length = min_c(bufferSize - bufferOffset,
|
||||
vector[vectorIndex].iov_len - vectorOffset);
|
||||
|
||||
TRACE(("usb_uhci: copying %ld bytes to vectorOffset %ld from"
|
||||
TRACE("copying %ld bytes to vectorOffset %ld from"
|
||||
" bufferOffset %ld at index %ld of %ld\n", length, vectorOffset,
|
||||
bufferOffset, vectorIndex, vectorCount));
|
||||
bufferOffset, vectorIndex, vectorCount);
|
||||
memcpy((uint8 *)vector[vectorIndex].iov_base + vectorOffset,
|
||||
(uint8 *)current->buffer_log + bufferOffset, length);
|
||||
|
||||
@@ -1982,7 +1981,8 @@ UHCI::ReadDescriptorChain(uhci_td *topDescriptor, iovec *vector,
|
||||
|
||||
if (vectorOffset >= vector[vectorIndex].iov_len) {
|
||||
if (++vectorIndex >= vectorCount) {
|
||||
TRACE(("usb_uhci: read descriptor chain (%ld bytes, no more vectors)\n", actualLength));
|
||||
TRACE("read descriptor chain (%ld bytes, no more vectors)\n",
|
||||
actualLength);
|
||||
if (lastDataToggle)
|
||||
*lastDataToggle = dataToggle;
|
||||
return actualLength;
|
||||
@@ -2006,7 +2006,7 @@ UHCI::ReadDescriptorChain(uhci_td *topDescriptor, iovec *vector,
|
||||
if (lastDataToggle)
|
||||
*lastDataToggle = dataToggle;
|
||||
|
||||
TRACE(("usb_uhci: read descriptor chain (%ld bytes)\n", actualLength));
|
||||
TRACE("read descriptor chain (%ld bytes)\n", actualLength);
|
||||
return actualLength;
|
||||
}
|
||||
|
||||
@@ -2035,7 +2035,7 @@ UHCI::ReadActualLength(uhci_td *topDescriptor, uint8 *lastDataToggle)
|
||||
if (lastDataToggle)
|
||||
*lastDataToggle = dataToggle;
|
||||
|
||||
TRACE(("usb_uhci: read actual length (%ld bytes)\n", actualLength));
|
||||
TRACE("read actual length (%ld bytes)\n", actualLength);
|
||||
return actualLength;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,6 +46,9 @@ public:
|
||||
|
||||
void PrintToStream();
|
||||
|
||||
usb_id USBID() { return 0; };
|
||||
const char * TypeName() { return "uhci"; };
|
||||
|
||||
private:
|
||||
status_t fStatus;
|
||||
Stack *fStack;
|
||||
@@ -105,6 +108,8 @@ static status_t AddTo(Stack *stack);
|
||||
|
||||
status_t ResetPort(uint8 index);
|
||||
|
||||
virtual const char * TypeName() { return "uhci"; };
|
||||
|
||||
private:
|
||||
// Controller resets
|
||||
void GlobalReset();
|
||||
|
||||
@@ -11,5 +11,5 @@ resource app_version {
|
||||
variety = 0,
|
||||
internal = 0,
|
||||
short_info = "UHCI host controller driver",
|
||||
long_info = "Haiku UHCI HCD - Copyright 2003-2008, Haiku Inc."
|
||||
long_info = "Haiku UHCI HCD - Copyright 2003-2009, Haiku Inc."
|
||||
};
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "uhci.h"
|
||||
|
||||
#define USB_MODULE_NAME "uhci roothub"
|
||||
|
||||
static usb_device_descriptor sUHCIRootHubDevice =
|
||||
{
|
||||
18, // Descriptor length
|
||||
@@ -136,7 +138,7 @@ UHCIRootHub::ProcessTransfer(UHCI *uhci, Transfer *transfer)
|
||||
return B_ERROR;
|
||||
|
||||
usb_request_data *request = transfer->RequestData();
|
||||
TRACE(("usb_uhci_roothub: request: %d\n", request->Request));
|
||||
TRACE_MODULE("request: %d\n", request->Request);
|
||||
|
||||
status_t status = B_TIMED_OUT;
|
||||
size_t actualLength = 0;
|
||||
@@ -170,12 +172,12 @@ UHCIRootHub::ProcessTransfer(UHCI *uhci, Transfer *transfer)
|
||||
break;
|
||||
}
|
||||
|
||||
TRACE(("usb_uhci_roothub: set address: %d\n", request->Value));
|
||||
TRACE_MODULE("set address: %d\n", request->Value);
|
||||
status = B_OK;
|
||||
break;
|
||||
|
||||
case USB_REQUEST_GET_DESCRIPTOR:
|
||||
TRACE(("usb_uhci_roothub: get descriptor: %d\n", request->Value >> 8));
|
||||
TRACE_MODULE("get descriptor: %d\n", request->Value >> 8);
|
||||
|
||||
switch (request->Value >> 8) {
|
||||
case USB_DESCRIPTOR_DEVICE: {
|
||||
@@ -227,11 +229,11 @@ UHCIRootHub::ProcessTransfer(UHCI *uhci, Transfer *transfer)
|
||||
case USB_REQUEST_CLEAR_FEATURE: {
|
||||
if (request->Index == 0) {
|
||||
// we don't support any hub changes
|
||||
TRACE_ERROR(("usb_uhci_roothub: clear feature: no hub changes\n"));
|
||||
TRACE_MODULE_ERROR("clear feature: no hub changes\n");
|
||||
break;
|
||||
}
|
||||
|
||||
TRACE(("usb_uhci_roothub: clear feature: %d\n", request->Value));
|
||||
TRACE_MODULE("clear feature: %d\n", request->Value);
|
||||
if (uhci->ClearPortFeature(request->Index - 1, request->Value) >= B_OK)
|
||||
status = B_OK;
|
||||
break;
|
||||
@@ -240,11 +242,11 @@ UHCIRootHub::ProcessTransfer(UHCI *uhci, Transfer *transfer)
|
||||
case USB_REQUEST_SET_FEATURE: {
|
||||
if (request->Index == 0) {
|
||||
// we don't support any hub changes
|
||||
TRACE_ERROR(("usb_uhci_roothub: set feature: no hub changes\n"));
|
||||
TRACE_MODULE_ERROR("set feature: no hub changes\n");
|
||||
break;
|
||||
}
|
||||
|
||||
TRACE(("usb_uhci_roothub: set feature: %d!\n", request->Value));
|
||||
TRACE_MODULE("set feature: %d\n", request->Value);
|
||||
if (uhci->SetPortFeature(request->Index - 1, request->Value) >= B_OK)
|
||||
status = B_OK;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user