Difference between revisions of "/dev/uhs"
Marionumber1 (talk | contribs) (→0x11 - UhsQueryInterfaces(): Specifying nothing for match_params selects all interfaces) |
Marionumber1 (talk | contribs) (→0x11 - UhsQueryInterfaces(): Found vendor and product IDs in the struct) |
||
Line 18: | Line 18: | ||
typedef struct | typedef struct | ||
{ | { | ||
− | uint16_t match_params; | + | uint16_t match_params; /* Bitmask of above flags */ |
− | char | + | uint16_t vid, pid; /* Vendor ID and product ID */ |
− | uint8_t dev_class; | + | char unknown6[0xa - 0x6]; |
− | uint8_t dev_subclass; | + | uint8_t dev_class; /* Device class */ |
− | uint8_t dev_protocol; | + | uint8_t dev_subclass; /* Device subclass */ |
− | uint8_t if_class; | + | uint8_t dev_protocol; /* Device protocol */ |
− | uint8_t if_subclass; | + | uint8_t if_class; /* Interface class */ |
− | uint8_t if_protocol; | + | uint8_t if_subclass; /* Interface subclass */ |
+ | uint8_t if_protocol; /* Interface protocol */ | ||
} UhsInterfaceFilter; | } UhsInterfaceFilter; | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 01:33, 12 April 2015
/dev/uhs is the IOSU device node for USB. It provides an interface for low-level USB device access, which nsysuhs.rpl exposes to the Cafe OS userspace. The interface is opened through /dev/uhs/%d, where %d is an integer representing something (controller number?). Only 0 can be opened, as 1 returns access denied and further values do not exist as device nodes. Once opened, ioctl() requests can be issued to the interface, which are documented below.
ioctl() interface
0x11 - UhsQueryInterfaces()
This function is used to determine which USB device interfaces are plugged in and available. Its input is a 0x10-byte buffer containing a series of parameters to filter the interfaces by, such as class, subclass, vendor ID, and product ID. The output is an array of 0x16c-byte interface descriptors, one for each interface being read. IOS_Ioctl() with this function returns the number of attached USB interfaces permitted by the filter.
/* Determines which parameters to check */
#define MATCH_DEV_ANY 0x000
#define MATCH_DEV_CLASS 0x010
#define MATCH_DEV_SUBCLASS 0x020
#define MATCH_DEV_PROTOCOL 0x040
#define MATCH_IF_CLASS 0x080
#define MATCH_IF_SUBCLASS 0x100
#define MATCH_IF_PROTOCOL 0x200
/* Input buffer */
typedef struct
{
uint16_t match_params; /* Bitmask of above flags */
uint16_t vid, pid; /* Vendor ID and product ID */
char unknown6[0xa - 0x6];
uint8_t dev_class; /* Device class */
uint8_t dev_subclass; /* Device subclass */
uint8_t dev_protocol; /* Device protocol */
uint8_t if_class; /* Interface class */
uint8_t if_subclass; /* Interface subclass */
uint8_t if_protocol; /* Interface protocol */
} UhsInterfaceFilter;