BusProberSharedFunctions.h [plain text]
#include <AvailabilityMacros.h>
#define SUPPORTS_SS_USB 1
#import <Foundation/Foundation.h>
#import <IOKit/usb/IOUSBLib.h>
#import <IOKit/usb/USB.h>
#import <IOKit/usb/USBSpec.h>
#import <IOKit/IOCFPlugIn.h>
#import "BusProbeClass.h"
typedef struct IOUSBDeviceStruct320** IOUSBDeviceRef ;
typedef struct IOUSBInterfaceStruct220** IOUSBInterfaceRef ;
#define ROOT_LEVEL 0
#define DEVICE_DESCRIPTOR_LEVEL ROOT_LEVEL + 1
#define CONFIGURATION_DESCRIPTOR_LEVEL ROOT_LEVEL + 1
#define INTERFACE_LEVEL CONFIGURATION_DESCRIPTOR_LEVEL + 1
#define ENDPOINT_LEVEL INTERFACE_LEVEL + 1
#define HID_DESCRIPTOR_LEVEL INTERFACE_LEVEL + 1
#define DFU_DESCRIPTOR_LEVEL INTERFACE_LEVEL + 1
#define CCID_DESCRIPTOR_LEVEL INTERFACE_LEVEL + 1
#define HUB_DESCRIPTOR_LEVEL ROOT_LEVEL + 1
#define DEVICE_QUAL_DESCRIPTOR_LEVEL ROOT_LEVEL + 1
#ifdef SUPPORTS_SS_USB
#define BOS_DESCRIPTOR_LEVEL ROOT_LEVEL + 1
#endif
enum {
kIntegerOutputStyle = 0,
kHexOutputStyle = 1
};
IOReturn GetNumberOfConfigurations( IOUSBDeviceRef deviceIntf, uint8_t * numberOfConfigs );
IOReturn GetConfigurationDescriptor( IOUSBDeviceRef deviceIntf, uint8_t config, IOUSBConfigurationDescriptorPtr * description );
IOReturn GetConfiguration( IOUSBDeviceRef deviceIntf, uint8_t * currentConfig );
IOReturn GetPortInformation( IOUSBDeviceRef deviceIntf, uint32_t * portInfo );
int GetDeviceLocationID( IOUSBDeviceRef deviceIntf, UInt32 * locationID );
int GetDeviceSpeed( IOUSBDeviceRef deviceIntf, UInt8 * speed );
int GetDeviceAddress( IOUSBDeviceRef deviceIntf, USBDeviceAddress * address );
int SuspendDevice( IOUSBDeviceRef deviceIntf, BOOL suspend );
IOReturn GetDescriptor(IOUSBDeviceRef deviceIntf, UInt8 descType, UInt8 descIndex, void *buf, UInt16 len, IOReturn *actError);
int GetStringDescriptor(IOUSBDeviceRef deviceIntf, UInt8 descIndex, void *buf, UInt16 len, UInt16 lang);
int GetClassDescriptor(IOUSBDeviceRef deviceIntf, UInt8 descType, UInt8 descIndex, void *buf, UInt16 len);
int GetDescriptorFromInterface(IOUSBDeviceRef deviceIntf, UInt8 descType, UInt8 descIndex, UInt16 wIndex, void *buf, UInt16 len, Boolean inCurrentConfig);
int GetCurrentConfiguration(IOUSBDeviceRef deviceIntf);
BusProbeClass * GetDeviceClassAndSubClass(UInt8 * pcls);
BusProbeClass * GetInterfaceClassAndSubClass(UInt8 * pcls);
char * GetStringFromNumber(UInt32 value, int sizeInBytes, int style);
char * GetStringFromIndex(UInt8 strIndex, IOUSBDeviceRef deviceIntf);
NSString * VendorNameFromVendorID(NSString * intValueAsString);
NSString * GetUSBProductNameFromRegistry(io_registry_entry_t entry);
void FreeString(char * cstr);
UInt16 Swap16(void *p);
uint32_t Swap32(void *p);
uint64_t Swap64(void *p);
uint32_t Swap24(void *p);
const char * USBErrorToString(IOReturn status);
IOUSBDescriptorHeader * NextDescriptor(const void *desc);
IOUSBDescriptorHeader* FindNextDescriptor(IOUSBConfigurationDescriptor *curConfDesc, const void *cur, UInt8 descType);
IOReturn FindNextInterfaceDescriptor(const IOUSBConfigurationDescriptor *configDescIn, const IOUSBInterfaceDescriptor *intfDesc,IOUSBInterfaceDescriptor **descOut);