X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FUSB%2FCore%2Fusb_io.c;h=de6f6f1169279a0764106725d3882eceaccd5b59;hb=5cab4c07bc13888dc7956194ef9595508072a4eb;hp=992269aca4bc9c32dfc6cf7d838d3b8a3b9ac889;hpb=adaa3a0feeecdda90df3e010898a37f1ffa83197;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/USB/Core/usb_io.c b/KernelLand/Modules/USB/Core/usb_io.c index 992269ac..de6f6f11 100644 --- a/KernelLand/Modules/USB/Core/usb_io.c +++ b/KernelLand/Modules/USB/Core/usb_io.c @@ -45,7 +45,7 @@ void USB_Request(tUSBInterface *Iface, int Endpoint, int Type, int Req, int Valu else endpt = 0; - USB_int_Request(Iface->Dev->Host, Iface->Dev->Address, endpt, Type, Req, Value, Index, Len, Data); + USB_int_Request(Iface->Dev, endpt, Type, Req, Value, Index, Len, Data); } @@ -53,22 +53,21 @@ void USB_SendData(tUSBInterface *Dev, int Endpoint, size_t Length, const void *D { tUSBHost *host; tUSBEndpoint *ep; + void *dest_hdl; ENTER("pDev iEndpoint iLength pData", Dev, Endpoint, Length, Data); - ep = &Dev->Endpoints[Endpoint-1]; host = Dev->Dev->Host; - - if( Length > ep->MaxPacketSize ) { - Log_Warning("USB", "Max packet size exceeded (%i > %i)", ep->MaxPacketSize); + ep = &Dev->Endpoints[Endpoint-1]; + dest_hdl = Dev->Dev->EndpointHandles[ep->EndpointNum]; + LOG("dest_hdl = %p", dest_hdl); + if( !dest_hdl ) { + Log_Notice("USB", "_SendData on uninitialised enpoint (%p#%i)", Dev->Dev, ep->EndpointNum); LEAVE('-'); + return; } Threads_ClearEvent(THREAD_EVENT_SHORTWAIT); - host->HostDef->BulkOUT( - host->Ptr, Dev->Dev->Address*16 + Dev->Endpoints[Endpoint-1].EndpointNum, - 0, USB_WakeCallback, Proc_GetCurThread(), - (void*)Data, Length - ); + host->HostDef->SendBulk(host->Ptr, dest_hdl, USB_WakeCallback, Proc_GetCurThread(), 1, (void*)Data, Length); Threads_WaitEvents(THREAD_EVENT_SHORTWAIT); LEAVE('-'); @@ -78,31 +77,31 @@ void USB_RecvData(tUSBInterface *Dev, int Endpoint, size_t Length, void *Data) { tUSBHost *host; tUSBEndpoint *ep; + void *dest_hdl; ENTER("pDev iEndpoint iLength pData", Dev, Endpoint, Length, Data); - ep = &Dev->Endpoints[Endpoint-1]; host = Dev->Dev->Host; - - if( Length > ep->MaxPacketSize ) { - Log_Warning("USB", "Max packet size exceeded (%i > %i)", ep->MaxPacketSize); + ep = &Dev->Endpoints[Endpoint-1]; + dest_hdl = Dev->Dev->EndpointHandles[ep->EndpointNum]; + LOG("dest_hdl = %p", dest_hdl); + if( !dest_hdl ) { + Log_Notice("USB", "_RecvData on uninitialised enpoint (%p#%i)", Dev->Dev, ep->EndpointNum); LEAVE('-'); + return; } Threads_ClearEvent(THREAD_EVENT_SHORTWAIT); - host->HostDef->BulkIN( - host->Ptr, Dev->Dev->Address*16 + Dev->Endpoints[Endpoint-1].EndpointNum, - 0, USB_WakeCallback, Proc_GetCurThread(), - Data, Length - ); + host->HostDef->SendBulk(host->Ptr, dest_hdl, USB_WakeCallback, Proc_GetCurThread(), 0, Data, Length); Threads_WaitEvents(THREAD_EVENT_SHORTWAIT); LEAVE('-'); } -void USB_RecvDataA(tUSBInterface *Dev, int Endpoint, int Length, void *DataBuf, tUSB_DataCallback Callback) +void USB_RecvDataA(tUSBInterface *Dev, int Endpoint, size_t Length, void *DataBuf) { tAsyncOp *op; tUSBHost *host; + void *dest_hdl; ENTER("pDev iEndpoint iLength pDataBuf", Dev, Endpoint, Length, DataBuf); @@ -112,16 +111,16 @@ void USB_RecvDataA(tUSBInterface *Dev, int Endpoint, int Length, void *DataBuf, op->Length = Length; op->Data = DataBuf; - // TODO: Handle transfers that are larger than one packet - // TODO: Data toggle - host = Dev->Dev->Host; + dest_hdl = Dev->Dev->EndpointHandles[op->Endpt->EndpointNum]; + if( !dest_hdl ) { + Log_Notice("USB", "_SendData on uninitialised enpoint (%p#%i)", Dev->Dev, op->Endpt->EndpointNum); + LEAVE('-'); + return; + } + LOG("IN from %p %i:%i", host->Ptr, Dev->Dev->Address, op->Endpt->EndpointNum); - host->HostDef->BulkIN( - host->Ptr, Dev->Dev->Address*16 + op->Endpt->EndpointNum, - 0, USB_AsyncCallback, op, - DataBuf, Length - ); + host->HostDef->SendBulk(host->Ptr, dest_hdl, USB_AsyncCallback, op, 0, DataBuf, Length); LEAVE('-');