Implemented a usb_ioctl to retrive the logical device name (like 0/0, 0/1/0 or 1/hub) that will be used by usb_raw to publish the according devfs entries.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18515 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz
2006-08-16 20:07:24 +00:00
parent 3bb475bdcb
commit 64f3c06503
5 changed files with 66 additions and 1 deletions
@@ -410,6 +410,18 @@ Device::ReportDevice(usb_support_descriptor *supportDescriptors,
}
status_t
Device::BuildDeviceName(char *string, uint32 *index, size_t bufferSize,
Device *device)
{
if (!fParent)
return B_ERROR;
fParent->BuildDeviceName(string, index, bufferSize, this);
return B_OK;
}
status_t
Device::SetFeature(uint16 selector)
{
@@ -3,10 +3,12 @@
* Distributed under the terms of the MIT License.
*
* Authors:
* Michael Lotz <[email protected]>
* Niels S. Reedijk
*/
#include "usb_p.h"
#include <stdio.h>
#define TRACE_HUB
@@ -269,3 +271,31 @@ Hub::ReportDevice(usb_support_descriptor *supportDescriptors,
supportDescriptorCount, hooks, added);
}
}
status_t
Hub::BuildDeviceName(char *string, uint32 *index, size_t bufferSize,
Device *device)
{
status_t result = Device::BuildDeviceName(string, index, bufferSize, device);
if (result < B_OK) {
// recursion to parent failed, we're at the root(hub)
int32 managerIndex = Manager()->GetStack()->IndexOfBusManager(Manager());
*index += snprintf(string + *index, bufferSize - *index, "%d", managerIndex);
}
if (!device) {
// no device was specified - report the hub
*index += snprintf(string + *index, bufferSize - *index, "/hub");
} else {
// find out where the requested device sitts
for (int32 i = 0; i < fHubDescriptor.num_ports; i++) {
if (fChildren[i] == device) {
*index += snprintf(string + *index, bufferSize - *index, "/%d", i);
break;
}
}
}
return B_OK;
}
@@ -192,6 +192,13 @@ Stack::AddBusManager(BusManager *busManager)
}
int32
Stack::IndexOfBusManager(BusManager *busManager)
{
return fBusManagers.IndexOf(busManager);
}
status_t
Stack::AllocateChunk(void **logicalAddress, void **physicalAddress, uint8 size)
{
+10 -1
View File
@@ -274,7 +274,16 @@ status_t
usb_ioctl(uint32 opcode, void *buffer, size_t bufferSize)
{
TRACE(("usb_module: usb_ioctl(0x%08x, 0x%08x, %d)\n", opcode, buffer, bufferSize));
return B_ERROR;
switch (opcode) {
case 'DNAM': {
uint32 index = 0;
Device *device = *(Device **)buffer;
return device->BuildDeviceName((char *)buffer, &index, bufferSize, NULL);
}
}
return B_DEV_INVALID_IOCTL;
}
@@ -51,6 +51,7 @@ public:
void Unlock();
void AddBusManager(BusManager *bus);
int32 IndexOfBusManager(BusManager *bus);
status_t AllocateChunk(void **logicalAddress,
void **physicalAddress, uint8 size);
@@ -326,6 +327,9 @@ virtual void ReportDevice(
uint32 supportDescriptorCount,
const usb_notify_hooks *hooks,
bool added);
virtual status_t BuildDeviceName(char *string,
uint32 *index, size_t bufferSize,
Device *device);
// Convenience functions for standard requests
virtual status_t SetFeature(uint16 selector);
@@ -373,6 +377,9 @@ virtual void ReportDevice(
uint32 supportDescriptorCount,
const usb_notify_hooks *hooks,
bool added);
virtual status_t BuildDeviceName(char *string,
uint32 *index, size_t bufferSize,
Device *device);
private:
InterruptPipe *fInterruptPipe;