9 #include "../sf/service.h"
10 #include "../services/usb.h"
11 #include "../kernel/event.h"
12 #include "../kernel/tmem.h"
17 UsbHsInterfaceFilterFlags_idProduct =
BIT(1),
18 UsbHsInterfaceFilterFlags_bcdDevice_Min =
BIT(2),
19 UsbHsInterfaceFilterFlags_bcdDevice_Max =
BIT(3),
20 UsbHsInterfaceFilterFlags_bDeviceClass =
BIT(4),
21 UsbHsInterfaceFilterFlags_bDeviceSubClass =
BIT(5),
25 UsbHsInterfaceFilterFlags_bInterfaceClass =
BIT(7),
26 UsbHsInterfaceFilterFlags_bInterfaceSubClass =
BIT(8),
27 UsbHsInterfaceFilterFlags_bInterfaceProtocol =
BIT(9),
42 u8 bInterfaceSubClass;
43 u8 bInterfaceProtocol;
245 u64 max_reports = s->maxUrbCount * 0x21;
247 size = (size+0xFFF) & ~0xFFF;
static bool serviceIsActive(Service *s)
Returns whether a service has been initialized.
Definition: service.h:92
Kernel-mode event structure.
Definition: event.h:13
Service object structure.
Definition: service.h:14
Event eventXfer
[2.0.0+] Signaled when PostBufferAsync finishes.
Definition: usbhs.h:105
The interface service object. These Events have autoclear=false.
Definition: usbhs.h:94
UsbHsInterface inf
Initialized with the input interface from usbHsAcquireUsbIf, then overwritten with the cmd output....
Definition: usbhs.h:100
Event eventCtrlXfer
[2.0.0+] Signaled when CtrlXferAsync finishes.
Definition: usbhs.h:97
Event event0
Unknown.
Definition: usbhs.h:96
Interface filtering struct.
Definition: usbhs.h:32
u16 Flags
See UsbHsInterfaceFilterFlags. Setting this to 0 is equivalent to disabling filtering.
Definition: usbhs.h:33
u16 bcdDevice_Min
Descriptor value must be >= bcdDevice_Min.
Definition: usbhs.h:36
u16 bcdDevice_Max
Descriptor value must be <= bcdDevice_Max.
Definition: usbhs.h:37
Descriptors which are not available are set to all-zero.
Definition: usbhs.h:48
Interface struct. Note that devices have a seperate UsbHsInterface for each interface.
Definition: usbhs.h:66
u64 timestamp
Unknown u64 timestamp for when the device was inserted?
Definition: usbhs.h:77
u64 id
id from usbHsEpPostBufferAsync.
Definition: usbhs.h:85
Imported from libusb, with some adjustments.
Definition: usb.h:66
Imported from libusb, with some adjustments.
Definition: usb.h:48
Imported from libusb, with some adjustments.
Definition: usb.h:25
Imported from libusb, with some adjustments.
Definition: usb.h:35
Imported from libusb, with some adjustments.
Definition: usb.h:78
#define BIT(n)
Creates a bitmask from a bit number.
Definition: types.h:54
uint64_t u64
64-bit unsigned integer.
Definition: types.h:22
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
#define NX_PACKED
Packs a struct so that it won't include padding bytes.
Definition: types.h:63
volatile u64 vu64
64-bit volatile unsigned integer.
Definition: types.h:34
uint16_t u16
16-bit unsigned integer.
Definition: types.h:20
u32 Result
Function error code result type.
Definition: types.h:44
#define NX_CONSTEXPR
Flags a function as constexpr in C++14 and above; or as (always) inline otherwise.
Definition: types.h:92
int32_t s32
32-bit signed integer.
Definition: types.h:27
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21
Result usbHsDestroyInterfaceAvailableEvent(Event *event, u8 index)
Destroys an event setup by usbHsCreateInterfaceAvailableEvent.
void usbHsExit(void)
Exit usb:hs.
UsbHsInterfaceFilterFlags
Definition: usbhs.h:14
@ UsbHsInterfaceFilterFlags_idVendor
These use usb_device_descriptor. Bit2..6 require [6.0.0+], these are ignored on eariler versions.
Definition: usbhs.h:16
@ UsbHsInterfaceFilterFlags_bDeviceProtocol
These use usb_interface_descriptor.
Definition: usbhs.h:22
Result usbHsEpPostBufferAsync(UsbHsClientEpSession *s, void *buffer, u32 size, u64 id, u32 *xferId)
Starts an async data transfer with the specified endpoint.
Result usbHsInitialize(void)
Initialize usb:hs.
Result usbHsIfResetDevice(UsbHsClientIfSession *s)
Resets the device: has the same affect as unplugging the device and plugging it back in.
Result usbHsQueryAcquiredInterfaces(UsbHsInterface *interfaces, size_t interfaces_maxsize, s32 *total_entries)
Returns an array of UsbHsInterface which were previously acquired.
Result usbHsIfGetAlternateInterface(UsbHsClientIfSession *s, UsbHsInterfaceInfo *inf, u8 id)
Gets an alternate interface.
Result usbHsIfSetInterface(UsbHsClientIfSession *s, UsbHsInterfaceInfo *inf, u8 id)
Selects an interface.
Result usbHsEpCreateSmmuSpace(UsbHsClientEpSession *s, void *buffer, u32 size)
This can be used to map the specified buffer as devicemem, which can then be used with usbHsEpPostBuf...
static u32 usbHsEpGetReportRingSize(UsbHsClientEpSession *s)
Gets the buffer size to use with usbHsEpShareReportRing.
Definition: usbhs.h:244
Result usbHsAcquireUsbIf(UsbHsClientIfSession *s, UsbHsInterface *interface)
Acquires/opens the specified interface.
Result usbHsIfGetCurrentFrame(UsbHsClientIfSession *s, u32 *out)
On [1.0.0] this is stubbed, just returns 0 with out=0.
Result usbHsEpPostBuffer(UsbHsClientEpSession *s, void *buffer, u32 size, u32 *transferredSize)
Uses a data transfer with the specified endpoint, this will block until the transfer finishes.
void usbHsIfClose(UsbHsClientIfSession *s)
UsbHsClientIfSession.
Result usbHsQueryAvailableInterfaces(const UsbHsInterfaceFilter *filter, UsbHsInterface *interfaces, size_t interfaces_maxsize, s32 *total_entries)
Returns an array of UsbHsInterface which are available.
Result usbHsIfOpenUsbEp(UsbHsClientIfSession *s, UsbHsClientEpSession *ep, u16 maxUrbCount, u32 maxXferSize, struct usb_endpoint_descriptor *desc)
Opens an endpoint.
static s32 usbHsIfGetID(UsbHsClientIfSession *s)
Returns the ID which can be used for comparing with the ID in the output interfaces from usbHsQueryAc...
Definition: usbhs.h:187
static bool usbHsIfIsActive(UsbHsClientIfSession *s)
Returns whether the specified interface session was initialized.
Definition: usbhs.h:182
void usbHsEpClose(UsbHsClientEpSession *s)
UsbHsClientEpSession.
Result usbHsCreateInterfaceAvailableEvent(Event *out_event, bool autoclear, u8 index, const UsbHsInterfaceFilter *filter)
Creates an event which is signaled when an interface is available which passes the filtering checks.
Result usbHsEpBatchBufferAsync(UsbHsClientEpSession *s, void *buffer, u32 *urbs, u32 urbCount, u64 id, u32 unk1, u32 unk2, u32 *xferId)
This uses the same functionality internally as usbHsEpPostBufferAsync except the urbs array and unk1/...
static Event * usbHsEpGetXferEvent(UsbHsClientEpSession *s)
Gets the Xfer Event which is signaled when PostBufferAsync finishes. This is only valid for [2....
Definition: usbhs.h:239
Result usbHsEpGetXferReport(UsbHsClientEpSession *s, UsbHsXferReport *reports, u32 max_reports, u32 *count)
Gets an array of UsbHsXferReport for the specified endpoint.
Result usbHsEpShareReportRing(UsbHsClientEpSession *s, void *buffer, size_t size)
This creates TransferMemory which is used to read UsbHsXferReport when usbHsEpGetXferReport is used,...
Result usbHsQueryAllInterfaces(const UsbHsInterfaceFilter *filter, UsbHsInterface *interfaces, size_t interfaces_maxsize, s32 *total_entries)
Returns an array of all UsbHsInterface.
Result usbHsIfCtrlXfer(UsbHsClientIfSession *s, u8 bmRequestType, u8 bRequest, u16 wValue, u16 wIndex, u16 wLength, void *buffer, u32 *transferredSize)
Uses a control transfer, this will block until the transfer finishes. The buffer address and size sho...
Service * usbHsGetServiceSession(void)
Gets the Service object for the actual usb:hs service session.
Result usbHsIfGetInterface(UsbHsClientIfSession *s, UsbHsInterfaceInfo *inf)
Gets an interface.
Event * usbHsGetInterfaceStateChangeEvent(void)
Returns the Event loaded during init with autoclear=false.