[haiku-commits] r41157 - in haiku/trunk/src: add-ons/kernel/bus_managers/usb bin

  • From: korli@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 31 Mar 2011 23:58:06 +0200 (CEST)

Author: korli
Date: 2011-03-31 23:58:06 +0200 (Thu, 31 Mar 2011)
New Revision: 41157
Changeset: https://dev.haiku-os.org/changeset/41157

Modified:
   haiku/trunk/src/add-ons/kernel/bus_managers/usb/Hub.cpp
   haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_private.h
   haiku/trunk/src/add-ons/kernel/bus_managers/usb/usbspec_private.h
   haiku/trunk/src/bin/Jamfile
   haiku/trunk/src/bin/listusb.cpp
Log:
added some hub ports information to listusb


Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/Hub.cpp
===================================================================
--- haiku/trunk/src/add-ons/kernel/bus_managers/usb/Hub.cpp     2011-03-31 
21:53:36 UTC (rev 41156)
+++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/Hub.cpp     2011-03-31 
21:58:06 UTC (rev 41157)
@@ -128,10 +128,10 @@
        // get the current port status
        size_t actualLength = 0;
        status_t result = DefaultPipe()->SendRequest(USB_REQTYPE_CLASS | 
USB_REQTYPE_OTHER_IN,
-               USB_REQUEST_GET_STATUS, 0, index + 1, 4, (void 
*)&fPortStatus[index],
-               4, &actualLength);
+               USB_REQUEST_GET_STATUS, 0, index + 1, sizeof(usb_port_status), 
+               (void *)&fPortStatus[index], sizeof(usb_port_status), 
&actualLength);
 
-       if (result < B_OK || actualLength < 4) {
+       if (result < B_OK || actualLength < sizeof(usb_port_status)) {
                TRACE_ERROR("error updating port status\n");
                return B_ERROR;
        }

Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_private.h
===================================================================
--- haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_private.h       
2011-03-31 21:53:36 UTC (rev 41156)
+++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/usb_private.h       
2011-03-31 21:58:06 UTC (rev 41157)
@@ -12,6 +12,7 @@
 #include "BeOSCompatibility.h"
 #include "usbspec_private.h"
 #include <lock.h>
+#include <util/Vector.h>
 
 
 #define TRACE_OUTPUT(x, y, z...) \

Modified: haiku/trunk/src/add-ons/kernel/bus_managers/usb/usbspec_private.h
===================================================================
--- haiku/trunk/src/add-ons/kernel/bus_managers/usb/usbspec_private.h   
2011-03-31 21:53:36 UTC (rev 41156)
+++ haiku/trunk/src/add-ons/kernel/bus_managers/usb/usbspec_private.h   
2011-03-31 21:58:06 UTC (rev 41157)
@@ -6,15 +6,14 @@
  *             Michael Lotz <mmlr@xxxxxxxx>
  *             Niels S. Reedijk
  */
-
 #ifndef _USBSPEC_PRIVATE_H
 #define _USBSPEC_PRIVATE_H
 
+
 #include <KernelExport.h>
-#include <util/Vector.h>
 #include <USB3.h>
-#include <util/kernel_cpp.h>
 
+
 #define USB_MAX_AREAS                                  8
 #define USB_MAX_FRAGMENT_SIZE                  B_PAGE_SIZE * 96
 #define USB_MAX_PORT_COUNT                             16
@@ -96,6 +95,8 @@
 #define PORT_STATUS_POWER                      0x0100
 #define PORT_STATUS_LOW_SPEED          0x0200
 #define PORT_STATUS_HIGH_SPEED         0x0400
+#define PORT_STATUS_TEST                       0x0800
+#define PORT_STATUS_INDICATOR          0x1000
 
 
 //The feature requests with ports

Modified: haiku/trunk/src/bin/Jamfile
===================================================================
--- haiku/trunk/src/bin/Jamfile 2011-03-31 21:53:36 UTC (rev 41156)
+++ haiku/trunk/src/bin/Jamfile 2011-03-31 21:58:06 UTC (rev 41157)
@@ -195,6 +195,9 @@
        setusbconfig.cpp
        : be libdevice.so : $(haiku-utils_rsrc) ;
 
+ObjectHdrs [ FGristFiles listusb$(SUFOBJ) ]
+       : [ FDirName $(SUBDIR) $(DOTDOT) add-ons kernel bus_managers usb ] ;
+
 # standard commands that need libbluetooth.so, due the Bluetooth Kit
 StdBinCommands
        bt_dev_info.cpp

Modified: haiku/trunk/src/bin/listusb.cpp
===================================================================
--- haiku/trunk/src/bin/listusb.cpp     2011-03-31 21:53:36 UTC (rev 41156)
+++ haiku/trunk/src/bin/listusb.cpp     2011-03-31 21:58:06 UTC (rev 41157)
@@ -13,7 +13,9 @@
 #include <USBKit.h>
 #include <stdio.h>
 
+#include "usbspec_private.h"
 
+
 const char*
 ClassName(int classNumber) {
        switch (classNumber) {
@@ -168,6 +170,40 @@
                printf("    [Configuration %lu]\n", i);
                DumpConfiguration(device.ConfigurationAt(i));
        }
+
+       if (device.Class() != 0x09)
+               return;
+
+       usb_hub_descriptor hubDescriptor;
+       size_t size = device.GetDescriptor(USB_DESCRIPTOR_HUB, 0, 0,
+               (void *)&hubDescriptor, sizeof(usb_hub_descriptor));
+       if (size == sizeof(usb_hub_descriptor)) {
+               printf("    Hub ports count......... %d\n", 
hubDescriptor.num_ports);
+               printf("    Hub Controller Current.. %dmA\n", 
hubDescriptor.max_power);
+
+               for (int index = 1; index <= hubDescriptor.num_ports; index++) {
+                       usb_port_status portStatus;
+                       size_t actualLength = 
device.ControlTransfer(USB_REQTYPE_CLASS
+                               | USB_REQTYPE_OTHER_IN, USB_REQUEST_GET_STATUS, 
0,
+                               index, sizeof(portStatus), (void *)&portStatus);
+                       if (actualLength != sizeof(portStatus))
+                               continue;
+                       printf("      Port %d status....... 
%04x.%04x%s%s%s%s%s%s%s%s%s\n",
+                               index, portStatus.status, portStatus.change,
+                               portStatus.status & PORT_STATUS_CONNECTION ? " 
Connect": "",
+                               portStatus.status & PORT_STATUS_ENABLE ? " 
Enable": "",
+                               portStatus.status & PORT_STATUS_SUSPEND ? " 
Suspend": "",
+                               portStatus.status & PORT_STATUS_OVER_CURRENT ? 
" Overcurrent": "",
+                               portStatus.status & PORT_STATUS_RESET ? " 
Reset": "",
+                               portStatus.status & PORT_STATUS_POWER ? " 
Power": "",
+                               portStatus.status & PORT_STATUS_CONNECTION ? 
+                                       (portStatus.status & 
PORT_STATUS_LOW_SPEED ? " Lowspeed" 
+                                       : (portStatus.status & 
PORT_STATUS_HIGH_SPEED ? " Highspeed"
+                                               : " Fullspeed")) : "",
+                               portStatus.status & PORT_STATUS_TEST ? " Test": 
"",
+                               portStatus.status & PORT_STATUS_INDICATOR ? " 
Indicator": "");
+               }
+       }
 }
 
 


Other related posts:

  • » [haiku-commits] r41157 - in haiku/trunk/src: add-ons/kernel/bus_managers/usb bin - korli