vitasdk
Documentation of the vitasdk

Detailed Description

Exports for User.


Using this library in your project

Include the header file in your project:

#include <psp2/usbd.h>


Link the library to the executable:

SceUsbd_stub



Functions

 VITASDK_BUILD_ASSERT_EQ (0xC, SceUsbdDeviceInfo)
 
 VITASDK_BUILD_ASSERT_EQ (0x14, SceUsbdTransferData)
 
 VITASDK_BUILD_ASSERT_EQ (0x1C, SceUsbdReceiveEvent)
 
int sceUsbdInit (SceUID *uid)
 Init usb subsystem. More...
 
int sceUsbdEnd (SceUID uid)
 Stop usb subsystem. More...
 
int sceUsbdGetDeviceList (SceUID uid, SceSize num, SceUsbdDeviceInfo *info)
 Get usb devices list. More...
 
int sceUsbdGetDescriptorSize (SceUID uid, unsigned int device_id)
 Get usb device descriptors data size. More...
 
int sceUsbdGetDescriptor (SceUID uid, SceUID device_id, unsigned char *descriptor, SceSize size)
 Get usb device descriptors (all) More...
 
int sceUsbdGetDeviceSpeed (SceUID uid, SceUID device_id, unsigned int *speed)
 Get usb device speed. More...
 
int sceUsbdRegisterCallback (SceUID cbid, int flag)
 Register callback to usb event. More...
 
int sceUsbdUnregisterCallback (SceUID cbid)
 Remove callback to usb event. More...
 
int sceUsbdResetDevice (SceUID uid, SceUID device_id)
 Reset usb device. More...
 
int sceUsbdAttach (SceUID uid, SceUID driver_id, SceUInt bus, SceUInt device)
 Attach specified driver to device. More...
 
int sceUsbdGetDeviceAddress (SceUID uid, SceUID device_id, SceUsbdDeviceAddress *addr)
 Get device address. More...
 
 VITASDK_BUILD_ASSERT_EQ (0x10, SceUsbdTransferStatus)
 
 VITASDK_BUILD_ASSERT_EQ (0x10, SceUsbdIsochTransferStatus)
 
int sceUsbdGetTransferStatus (SceUID transfer_id, SceUsbdTransferStatus *status)
 Get transfer status. More...
 
int sceUsbdGetIsochTransferStatus (SceUID transfer_id, SceUsbdIsochTransferStatus *status)
 Get isochronous transfer status. More...
 
 VITASDK_BUILD_ASSERT_EQ (0x18, SceUsbdDevicePipe)
 
SceUID sceUsbdOpenPipe (SceUID uid, SceUsbdDevicePipe *pipe)
 Open endpoint communication pipe. More...
 
SceUID sceUsbdOpenDefaultPipe (SceUID uid, SceUID device_id)
 Open endpoint communication pipe for default config endpoint. More...
 
int sceUsbdClosePipe (SceUID uid, SceUID pipe_id)
 Close endpoint communication pipe. More...
 
SceUID sceUsbdTransferData (SceUID uid, SceUsbdTransferData *data)
 Transfer data to/from endpoint. More...
 
 VITASDK_BUILD_ASSERT_EQ (0x28, SceUsbdIsochTransfer)
 
int sceUsbdIsochTransferData (SceUID uid, SceUID pipe_id, SceUsbdIsochTransfer *transfer)
 Transfer data to/from endpoint isochronously. More...
 
int sceUsbdReceiveEvent (SceUID uid, SceUsbdReceiveEvent *event)
 Receive usb event. More...
 
SceUID sceUsbdRegisterLdd (SceUID uid, char *name)
 Register logical device driver. More...
 
SceUID sceUsbdRegisterCompositeLdd (SceUID uid, char *name)
 Register logical device driver for composite devices. More...
 
int sceUsbdUnregisterLdd (SceUID uid, char *name)
 De-register logical device driver. More...
 
 VITASDK_BUILD_ASSERT_EQ (0x14, SceUsbdAttachCompositeParam)
 
int sceUsbdAttachCompositeLdd (SceUID uid, SceUsbdAttachCompositeParam *param)
 Attach composite driver to device. More...
 

Macros

#define USB_DESCRIPTOR_DEVICE   0x01
 
#define USB_DESCRIPTOR_CONFIGURATION   0x02
 
#define USB_DESCRIPTOR_STRING   0x03
 
#define USB_DESCRIPTOR_INTERFACE   0x04
 
#define USB_DESCRIPTOR_ENDPOINT   0x05
 
#define USB_DESCRIPTOR_DEVICE_QUALIFIER   0x06
 
#define USB_DESCRIPTOR_OTHER_SPEED   0x07
 
#define USB_DESCRIPTOR_INTERFACE_POWER   0x08
 
#define USB_DESCRIPTOR_OTG   0x09
 
#define SCE_USBD_DEVICE_SPEED_LS   (0)
 
#define SCE_USBD_DEVICE_SPEED_FS   (1)
 
#define SCE_USBD_DEVICE_SPEED_HS   (2)
 

Data Structure Documentation

◆ SceUsbdDeviceInfo

struct SceUsbdDeviceInfo
Data Fields
unsigned int port
unsigned int device_num
unsigned int unk3

◆ SceUsbdTransferData

struct SceUsbdTransferData
Data Fields
unsigned int pipe
const void * data
unsigned int data_size
void * transferred
unsigned int timeout

◆ SceUsbdReceiveEvent

struct SceUsbdReceiveEvent
Data Fields
unsigned int unk0
unsigned int unk1
unsigned int unk2
unsigned int unk3
unsigned int unk4
unsigned int unk5
unsigned int transfer_id

◆ SceUsbdTransferStatus

struct SceUsbdTransferStatus
Data Fields
uint32_t unk0
uint32_t unk1
uint32_t unk2
uint32_t unk3

◆ SceUsbdIsochTransferStatus

struct SceUsbdIsochTransferStatus
Data Fields
uint32_t unk0
uint32_t unk1
uintptr_t * unk2
uint32_t unk3

◆ SceUsbdDevicePipe

struct SceUsbdDevicePipe
Data Fields
unsigned int device_id
unsigned int unk1
unsigned int unk2
unsigned int unk3
unsigned int unk4
unsigned int unk5

◆ SceUsbdIsochTransfer

struct SceUsbdIsochTransfer
Data Fields
unsigned int unk0
unsigned int unk1
unsigned int unk2
unsigned int unk3
unsigned int unk4
unsigned int unk5
unsigned int unk6
unsigned int unk7
unsigned int unk8
unsigned int unk9

◆ SceUsbdAttachCompositeParam

struct SceUsbdAttachCompositeParam
Data Fields
uint32_t driver_id
uint32_t bus
uint32_t device
uint32_t unk3
uint32_t unk4

Macro Definition Documentation

◆ USB_DESCRIPTOR_DEVICE

#define USB_DESCRIPTOR_DEVICE   0x01

◆ USB_DESCRIPTOR_CONFIGURATION

#define USB_DESCRIPTOR_CONFIGURATION   0x02

◆ USB_DESCRIPTOR_STRING

#define USB_DESCRIPTOR_STRING   0x03

◆ USB_DESCRIPTOR_INTERFACE

#define USB_DESCRIPTOR_INTERFACE   0x04

◆ USB_DESCRIPTOR_ENDPOINT

#define USB_DESCRIPTOR_ENDPOINT   0x05

◆ USB_DESCRIPTOR_DEVICE_QUALIFIER

#define USB_DESCRIPTOR_DEVICE_QUALIFIER   0x06

◆ USB_DESCRIPTOR_OTHER_SPEED

#define USB_DESCRIPTOR_OTHER_SPEED   0x07

◆ USB_DESCRIPTOR_INTERFACE_POWER

#define USB_DESCRIPTOR_INTERFACE_POWER   0x08

◆ USB_DESCRIPTOR_OTG

#define USB_DESCRIPTOR_OTG   0x09

◆ SCE_USBD_DEVICE_SPEED_LS

#define SCE_USBD_DEVICE_SPEED_LS   (0)

◆ SCE_USBD_DEVICE_SPEED_FS

#define SCE_USBD_DEVICE_SPEED_FS   (1)

◆ SCE_USBD_DEVICE_SPEED_HS

#define SCE_USBD_DEVICE_SPEED_HS   (2)

Function Documentation

◆ VITASDK_BUILD_ASSERT_EQ() [1/8]

VITASDK_BUILD_ASSERT_EQ ( 0xC  ,
SceUsbdDeviceInfo   
)

◆ VITASDK_BUILD_ASSERT_EQ() [2/8]

VITASDK_BUILD_ASSERT_EQ ( 0x14  ,
SceUsbdTransferData   
)

◆ VITASDK_BUILD_ASSERT_EQ() [3/8]

VITASDK_BUILD_ASSERT_EQ ( 0x1C  ,
SceUsbdReceiveEvent   
)

◆ sceUsbdInit()

int sceUsbdInit ( SceUID uid)

Init usb subsystem.

Returns
0 on success, < 0 on error
Parameters
[out]uidPointer to uid

◆ sceUsbdEnd()

int sceUsbdEnd ( SceUID  uid)

Stop usb subsystem.

Returns
0 on success, < 0 on error
Parameters
uiduid

◆ sceUsbdGetDeviceList()

int sceUsbdGetDeviceList ( SceUID  uid,
SceSize  num,
SceUsbdDeviceInfo info 
)

Get usb devices list.

Returns
0 on success, < 0 on error
Parameters
[in]uiduid
[in]nummax number of devices to return (8 max)
[out]infopointer to receive device info

◆ sceUsbdGetDescriptorSize()

int sceUsbdGetDescriptorSize ( SceUID  uid,
unsigned int  device_id 
)

Get usb device descriptors data size.

Returns
size on success, < 0 on error
Parameters
uiduid
device_iddevice id

◆ sceUsbdGetDescriptor()

int sceUsbdGetDescriptor ( SceUID  uid,
SceUID  device_id,
unsigned char *  descriptor,
SceSize  size 
)

Get usb device descriptors (all)

Returns
0 on success, < 0 on error
Parameters
[in]uiduid
[in]device_iddevice id
[out]descriptorbuffer for descriptor data
[in]sizebuffer size

◆ sceUsbdGetDeviceSpeed()

int sceUsbdGetDeviceSpeed ( SceUID  uid,
SceUID  device_id,
unsigned int *  speed 
)

Get usb device speed.

Returns
0 on success, < 0 on error
Parameters
[in]uiduid
[in]device_iddevice id
[out]speeddevice speed

◆ sceUsbdRegisterCallback()

int sceUsbdRegisterCallback ( SceUID  cbid,
int  flag 
)

Register callback to usb event.

Returns
0 on success, < 0 on error
Parameters
[in]cbidcallback uid
[in]flagif 1 - trigger events immediately
Note
there may be only one callback registered through whole system. And it's currently taken up by shell.

◆ sceUsbdUnregisterCallback()

int sceUsbdUnregisterCallback ( SceUID  cbid)

Remove callback to usb event.

Returns
0 on success, < 0 on error
Parameters
[in]cbidcallback uid
Note
this checks process id

◆ sceUsbdResetDevice()

int sceUsbdResetDevice ( SceUID  uid,
SceUID  device_id 
)

Reset usb device.

Returns
0 on success, < 0 on error
Parameters
[in]uiduid
[in]device_iddevice id

◆ sceUsbdAttach()

int sceUsbdAttach ( SceUID  uid,
SceUID  driver_id,
SceUInt  bus,
SceUInt  device 
)

Attach specified driver to device.

Returns
0 on success, < 0 on error
Parameters
[in]uiduid
[in]driver_iddriver id (result of Register(Composite)Ldd)
[in]bususb port number
[in]deviceusb device number
Note
device_id = (bus << 16) + device

◆ sceUsbdGetDeviceAddress()

int sceUsbdGetDeviceAddress ( SceUID  uid,
SceUID  device_id,
SceUsbdDeviceAddress addr 
)

Get device address.

Returns
0 on success, < 0 on error
Parameters
[in]uiduid
[in]device_iddevice id
[out]addrbuffer for return value
Note
it is unknown what that function actually returns in addr, observed only 0

◆ VITASDK_BUILD_ASSERT_EQ() [4/8]

VITASDK_BUILD_ASSERT_EQ ( 0x10  ,
SceUsbdTransferStatus   
)

◆ VITASDK_BUILD_ASSERT_EQ() [5/8]

VITASDK_BUILD_ASSERT_EQ ( 0x10  ,
SceUsbdIsochTransferStatus   
)

◆ sceUsbdGetTransferStatus()

int sceUsbdGetTransferStatus ( SceUID  transfer_id,
SceUsbdTransferStatus status 
)

Get transfer status.

Returns
0 on success, < 0 on error
Parameters
[in]transfer_idtransfer uid
[out]statusbuffer for return value
Note
it is unknown what that function actually returns in addr, observed only 0

◆ sceUsbdGetIsochTransferStatus()

int sceUsbdGetIsochTransferStatus ( SceUID  transfer_id,
SceUsbdIsochTransferStatus status 
)

Get isochronous transfer status.

Returns
0 on success, < 0 on error
Parameters
[in]transfer_idtransfer uid
[out]statusbuffer for return value
Note
it is unknown what that function actually returns in addr, observed only 0

◆ VITASDK_BUILD_ASSERT_EQ() [6/8]

VITASDK_BUILD_ASSERT_EQ ( 0x18  ,
SceUsbdDevicePipe   
)

◆ sceUsbdOpenPipe()

SceUID sceUsbdOpenPipe ( SceUID  uid,
SceUsbdDevicePipe pipe 
)

Open endpoint communication pipe.

Returns
pipe_id on success, < 0 on error
Parameters
[in]uiduid
[in]pipeendpoint to open

◆ sceUsbdOpenDefaultPipe()

SceUID sceUsbdOpenDefaultPipe ( SceUID  uid,
SceUID  device_id 
)

Open endpoint communication pipe for default config endpoint.

Returns
pipe_id on success, < 0 on error
Parameters
[in]uiduid
[in]device_iddevice id

◆ sceUsbdClosePipe()

int sceUsbdClosePipe ( SceUID  uid,
SceUID  pipe_id 
)

Close endpoint communication pipe.

Returns
0 on success, < 0 on error
Parameters
[in]uiduid
[in]pipe_idpipe uid

◆ sceUsbdTransferData()

SceUID sceUsbdTransferData ( SceUID  uid,
SceUsbdTransferData data 
)

Transfer data to/from endpoint.

Returns
transfer_id on success, < 0 on error
Parameters
[in]uiduid
[in]datadata to transfer

◆ VITASDK_BUILD_ASSERT_EQ() [7/8]

VITASDK_BUILD_ASSERT_EQ ( 0x28  ,
SceUsbdIsochTransfer   
)

◆ sceUsbdIsochTransferData()

int sceUsbdIsochTransferData ( SceUID  uid,
SceUID  pipe_id,
SceUsbdIsochTransfer transfer 
)

Transfer data to/from endpoint isochronously.

Returns
transfer_id on success, < 0 on error
Parameters
[in]uiduid
[in]pipe_idpipe uid
[in]transferdata to transfer

◆ sceUsbdReceiveEvent()

int sceUsbdReceiveEvent ( SceUID  uid,
SceUsbdReceiveEvent event 
)

Receive usb event.

Returns
transfer_id on success, < 0 on error
Parameters
[in]uiduid
[out]event

◆ sceUsbdRegisterLdd()

SceUID sceUsbdRegisterLdd ( SceUID  uid,
char *  name 
)

Register logical device driver.

Returns
driver_id on success, < 0 on error
Parameters
[in]uiduid
[in]namedriver name, 255 max

◆ sceUsbdRegisterCompositeLdd()

SceUID sceUsbdRegisterCompositeLdd ( SceUID  uid,
char *  name 
)

Register logical device driver for composite devices.

Returns
driver_id on success, < 0 on error
Parameters
[in]uiduid
[in]namedriver name, 255 max

◆ sceUsbdUnregisterLdd()

int sceUsbdUnregisterLdd ( SceUID  uid,
char *  name 
)

De-register logical device driver.

Returns
0 on success, < 0 on error
Parameters
[in]uiduid
[in]namedriver name, 255 max

◆ VITASDK_BUILD_ASSERT_EQ() [8/8]

VITASDK_BUILD_ASSERT_EQ ( 0x14  ,
SceUsbdAttachCompositeParam   
)

◆ sceUsbdAttachCompositeLdd()

int sceUsbdAttachCompositeLdd ( SceUID  uid,
SceUsbdAttachCompositeParam param 
)

Attach composite driver to device.

Returns
0 on success, < 0 on error
Parameters
[in]uiduid
[in]paramparameters