19 OldGP = SetModuleGP();
31 res = doRegisterDriver(driver, OldGP);
45 OldGP = SetModuleGP();
57 res = doRegisterAutoLoader(drv, OldGP);
71 OldGP = SetModuleGP();
83 res = doUnregisterDriver(driver);
91int sceUsbdUnregisterAutoloader(
void)
97 OldGP = SetModuleGP();
109 res = doUnregisterAutoLoader();
117void *sceUsbdScanStaticDescriptor(
int devId,
void *data, u8 type)
124 OldGP = SetModuleGP();
136 dev = fetchDeviceById(devId);
137 if ( dev && dev->m_deviceStatus == DEVICE_READY )
138 res = doGetDeviceStaticDescriptor(devId, data, type);
146int sceUsbdGetDeviceLocation(
int devId, u8 *path)
153 OldGP = SetModuleGP();
166 dev = fetchDeviceById(devId);
167 if ( dev && dev->m_deviceStatus == DEVICE_READY )
168 res = doGetDeviceLocation(dev, path);
176int sceUsbdSetPrivateData(
int devId,
void *data)
183 OldGP = SetModuleGP();
196 dev = fetchDeviceById(devId);
199 dev->m_privDataField = data;
209void *sceUsbdGetPrivateData(
int devId)
216 OldGP = SetModuleGP();
228 dev = fetchDeviceById(devId);
230 res = dev->m_privDataField;
246 OldGP = SetModuleGP();
259 dev = fetchDeviceById(devId);
261 ep = doOpenEndpoint(dev, desc, 0);
279 OldGP = SetModuleGP();
292 dev = fetchDeviceById(devId);
294 ep = doOpenEndpoint(dev, desc, 1u);
304int sceUsbdClosePipe(
int id)
311 OldGP = SetModuleGP();
324 ep = fetchEndpointById(
id);
326 res = doCloseEndpoint(ep);
339 req->m_prev = cbListEnd;
343 cbListEnd->m_next = req;
347 SetEventFlag(usbKernelResources.m_callbackEvent, 1u);
350static int usbdTransferPipeImpl(
371 ep = fetchEndpointById(
id);
374 dbg_printf(
"sceUsbdTransferPipe: UsbdEndpoint_t %d not found\n",
id);
380 bNumPackets =
request->bNumPackets;
385 if ( (
unsigned int)(bNumPackets - 1) >= 8 || !data )
392 if ( ep->m_alignFlag && ((uiptr)data & 3) != 0 )
394 res = USB_RC_BADALIGN;
399 if ( ep->m_endpointType != TYPE_ISOCHRON )
409 for ( i_pkt = 0; i_pkt < bNumPackets; i_pkt += 1 )
411 if ( (ep->m_hcEd->m_hcArea.stru.m_maxPacketSize & 0x7FFu) <
request->Packets[i_pkt].bLength )
416 length +=
request->Packets[i_pkt].bLength;
417 if ( ep->m_alignFlag && (((((uiptr)data) & 0xFF) + (length & 0xFF)) & 3) != 0 )
419 res = USB_RC_BADALIGN;
426 if ( (((uiptr)data + length - 1) >> 12) - ((uiptr)data >> 12) >= 2 )
433 switch ( ep->m_endpointType )
437 if ( ((uiptr)data & 3) != 0 && (option->requesttype & 0x80) == 0 )
439 if ( (ep->m_hcEd->m_hcArea.stru.m_maxPacketSize & 0x7FF) == 64 && (
int)length >= 63 )
441 res = USB_RC_BADALIGN;
448 if ( (ep->m_hcEd->m_hcArea.stru.m_maxPacketSize & 0x7FFu) < length )
462 req = allocIoRequest();
465 dbg_printf(
"Ran out of IoReqs\n");
471 req->m_userCallbackArg = cbArg;
472 req->m_gpSeg = gp_val;
473 req->m_req.bNumPackets = 0;
474 req->m_userCallbackProc = callback;
475 switch ( ep->m_endpointType )
481 req->m_waitFrames =
request->bRelStartFrame;
486 req->m_waitFrames = (u32)option;
488 res = attachIoReqToEndpoint(ep, req, data, length, signalCallbackThreadFunc);
500 if ( option->length != length )
508 res = doControlTransfer(
517 signalCallbackThreadFunc);
523 res = attachIoReqToEndpoint(ep, req, data, length, signalCallbackThreadFunc);
532int sceUsbdTransferPipe(
int id,
void *data, u32 len,
void *option, sceUsbdDoneCallback callback,
void *cbArg)
538 OldGP = SetModuleGP();
542 res = usbdTransferPipeImpl(OldGP,
id, data, len, (
UsbDeviceRequest *)option, callback, cbArg, NULL);
549int sceUsbdMultiIsochronousTransfer(
556 OldGP = SetModuleGP();
560 res = usbdTransferPipeImpl(OldGP, pipeId, NULL, 0, NULL, callback, cbArg,
request);
567int sceUsbdChangeThreadPriority(
int prio1,
int prio2)
573 OldGP = SetModuleGP();
578 if ( usbConfig.m_hcdThreadPrio != prio1 )
580 usbConfig.m_hcdThreadPrio = prio1;
581 res = ChangeThreadPriority(usbKernelResources.m_hcdTid, prio1);
583 if ( res == 0 && usbConfig.m_cbThreadPrio != prio2 )
585 usbConfig.m_cbThreadPrio = prio2;
586 res = ChangeThreadPriority(usbKernelResources.m_callbackTid, prio2);
594int sceUsbdGetReportDescriptor(
int devId,
int cfgNum,
int ifNum,
void **desc, u32 *len)
602 OldGP = SetModuleGP();
615 hidDescriptorStart = NULL;
616 dev = fetchDeviceById(devId);
620 for ( hidDescriptorStart = dev->m_reportDescriptorStart;
622 && ((int)hidDescriptorStart->m_cfgNum != cfgNum || (
int)hidDescriptorStart->m_ifNum != ifNum);
623 hidDescriptorStart = hidDescriptorStart->m_next )
627 if ( hidDescriptorStart )
631 *desc = hidDescriptorStart->m_data;
633 *len = hidDescriptorStart->m_length;
int CpuResumeIntr(int state)
int CpuSuspendIntr(int *state)
#define USB_RC_BADCONTEXT