X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FUSB%2FCore%2Fusb_io.c;h=de6f6f1169279a0764106725d3882eceaccd5b59;hb=85362e8a4c919b58cd261345d29f26bae4ad75e2;hp=9a3c4173db7d996e6c86a3aff30baf508e40495d;hpb=5db5602b547aa66aa115a9dbb4360fa3633e620e;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/USB/Core/usb_io.c b/KernelLand/Modules/USB/Core/usb_io.c index 9a3c4173..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,11 +53,18 @@ void USB_SendData(tUSBInterface *Dev, int Endpoint, size_t Length, const void *D { tUSBHost *host; tUSBEndpoint *ep; - void *dest_hdl = (void*)(Dev->Dev->Address*16 + Dev->Endpoints[Endpoint-1].EndpointNum + 1); + void *dest_hdl; ENTER("pDev iEndpoint iLength pData", Dev, Endpoint, Length, Data); - ep = &Dev->Endpoints[Endpoint-1]; host = Dev->Dev->Host; + 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->SendBulk(host->Ptr, dest_hdl, USB_WakeCallback, Proc_GetCurThread(), 1, (void*)Data, Length); @@ -70,11 +77,18 @@ void USB_RecvData(tUSBInterface *Dev, int Endpoint, size_t Length, void *Data) { tUSBHost *host; tUSBEndpoint *ep; - void *dest_hdl = (void*)(Dev->Dev->Address*16 + Dev->Endpoints[Endpoint-1].EndpointNum + 1); + void *dest_hdl; ENTER("pDev iEndpoint iLength pData", Dev, Endpoint, Length, Data); - ep = &Dev->Endpoints[Endpoint-1]; host = Dev->Dev->Host; + 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->SendBulk(host->Ptr, dest_hdl, USB_WakeCallback, Proc_GetCurThread(), 0, Data, Length); @@ -83,11 +97,11 @@ void USB_RecvData(tUSBInterface *Dev, int Endpoint, size_t Length, void *Data) LEAVE('-'); } -void USB_RecvDataA(tUSBInterface *Dev, int Endpoint, size_t 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 = (void*)(Dev->Dev->Address*16 + Dev->Endpoints[Endpoint-1].EndpointNum + 1); + void *dest_hdl; ENTER("pDev iEndpoint iLength pDataBuf", Dev, Endpoint, Length, DataBuf); @@ -97,10 +111,13 @@ void USB_RecvDataA(tUSBInterface *Dev, int Endpoint, size_t Length, void *DataBu 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->SendBulk(host->Ptr, dest_hdl, USB_AsyncCallback, op, 0, DataBuf, Length);