typedef void (*tUSBHostCb)(void *DataPtr, void *Data, int Length);
-typedef void *(*tUSBHostOp)(void *Ptr, int Fcn, int Endpt, int DataTgl, tUSBHostCb CB, void *CbData, void *Data, size_t Length);
+typedef void *(*tUSBHostOp)(void *Ptr, int Dest, int DataTgl, tUSBHostCb CB, void *CbData, void *Data, size_t Length);
/**
* \brief Defines a USB Host Controller type
tUSBDriver *gpUSB_InterfaceDrivers = &gUSBHub_Driver;
// === CODE ===
-void USB_RegisterDriver(tUSBDriver *Driver)
-{
- Driver->Next = gpUSB_InterfaceDrivers;
- gpUSB_InterfaceDrivers = Driver;
-}
-
tUSBHub *USB_RegisterHost(tUSBHostDef *HostDef, void *ControllerPtr, int nPorts)
{
tUSBHost *host;
void USB_RegisterDriver(tUSBDriver *Driver)
{
Log_Warning("USB", "TODO: Implement USB_RegisterDriver");
+ Driver->Next = gpUSB_InterfaceDrivers;
+ gpUSB_InterfaceDrivers = Driver;
}
tUSBDriver *USB_int_FindDriverByClass(Uint32 ClassCode)
host = Dev->Dev->Host;
LOG("IN from %p %i:%i", host->Ptr, Dev->Dev->Address, op->Endpt->EndpointNum);
host->HostDef->SendIN(
- host->Ptr, Dev->Dev->Address, op->Endpt->EndpointNum,
+ host->Ptr, Dev->Dev->Address*16 + op->Endpt->EndpointNum,
0, USB_AsyncCallback, op,
DataBuf, Length
);
void *hdl;
// TODO: Sanity check (and check that Type is valid)
struct sDeviceRequest req;
+ int dest = Addr * 16 + EndPt; // TODO: Validate
req.ReqType = Type;
req.Request = Req;
req.Value = LittleEndian16( Val );
req.Index = LittleEndian16( Indx );
req.Length = LittleEndian16( Len );
- hdl = Host->HostDef->SendSETUP(Host->Ptr, Addr, EndPt, 0, NULL, NULL, &req, sizeof(req));
+ hdl = Host->HostDef->SendSETUP(Host->Ptr, dest, 0, NULL, NULL, &req, sizeof(req));
// TODO: Data toggle?
// TODO: Multi-packet transfers
{
void *hdl2;
- hdl = Host->HostDef->SendIN(Host->Ptr, Addr, EndPt, 0, NULL, NULL, Data, Len);
+ hdl = Host->HostDef->SendIN(Host->Ptr, dest, 0, NULL, NULL, Data, Len);
- hdl2 = Host->HostDef->SendOUT(Host->Ptr, Addr, EndPt, 0, NULL, NULL, NULL, 0);
+ hdl2 = Host->HostDef->SendOUT(Host->Ptr, dest, 0, NULL, NULL, NULL, 0);
while( Host->HostDef->IsOpComplete(Host->Ptr, hdl2) == 0 )
Time_Delay(1);
}
void *hdl2;
if( Len > 0 )
- hdl = Host->HostDef->SendOUT(Host->Ptr, Addr, EndPt, 0, NULL, NULL, Data, Len);
+ hdl = Host->HostDef->SendOUT(Host->Ptr, dest, 0, NULL, NULL, Data, Len);
else
hdl = NULL;
// Status phase (DataToggle=1)
- hdl2 = Host->HostDef->SendIN(Host->Ptr, Addr, EndPt, 1, NULL, NULL, NULL, 0);
+ hdl2 = Host->HostDef->SendIN(Host->Ptr, dest, 1, NULL, NULL, NULL, 0);
while( Host->HostDef->IsOpComplete(Host->Ptr, hdl2) == 0 )
Time_Delay(1);
}
struct sDeviceRequest req;
int bToggle = 0;
void *final;
+ int dest = Dev->Address*16 + Endpoint;
req.ReqType = 0x80;
switch( Type & 0xF00 )
req.Length = LittleEndian16( Length );
Dev->Host->HostDef->SendSETUP(
- Dev->Host->Ptr, Dev->Address, Endpoint,
+ Dev->Host->Ptr, dest,
0, NULL, NULL,
&req, sizeof(req)
);
while( Length > ciMaxPacketSize )
{
Dev->Host->HostDef->SendIN(
- Dev->Host->Ptr, Dev->Address, Endpoint,
+ Dev->Host->Ptr, dest,
bToggle, NULL, NULL,
Dest, ciMaxPacketSize
);
}
final = Dev->Host->HostDef->SendIN(
- Dev->Host->Ptr, Dev->Address, Endpoint,
+ Dev->Host->Ptr, dest,
bToggle, INVLPTR, NULL,
Dest, Length
);
tUHCI_TD *UHCI_int_AllocateTD(tUHCI_Controller *Cont);
void UHCI_int_AppendTD(tUHCI_Controller *Cont, tUHCI_TD *TD);
void *UHCI_int_SendTransaction(tUHCI_Controller *Cont, int Addr, Uint8 Type, int bTgl, tUSBHostCb Cb, void *CbData, void *Buf, size_t Length);
-void *UHCI_DataIN(void *Ptr, int Fcn, int Endpt, int DataTgl, tUSBHostCb Cb, void *CbData, void *Buf, size_t Length);
-void *UHCI_DataOUT(void *Ptr, int Fcn, int Endpt, int DataTgl, tUSBHostCb Cb, void *CbData, void *Buf, size_t Length);
-void *UHCI_SendSetup(void *Ptr, int Fcn, int Endpt, int DataTgl, tUSBHostCb Cb, void *CbData, void *Buf, size_t Length);
+void *UHCI_DataIN(void *Ptr, int Dest, int DataTgl, tUSBHostCb Cb, void *CbData, void *Buf, size_t Length);
+void *UHCI_DataOUT(void *Ptr, int Dest, int DataTgl, tUSBHostCb Cb, void *CbData, void *Buf, size_t Length);
+void *UHCI_SendSetup(void *Ptr, int Dest, int DataTgl, tUSBHostCb Cb, void *CbData, void *Buf, size_t Length);
int UHCI_IsTransferComplete(void *Ptr, void *Handle);
int UHCI_Int_InitHost(tUHCI_Controller *Host);
void UHCI_CheckPortUpdate(void *Ptr);
return td;
}
-void *UHCI_DataIN(void *Ptr, int Fcn, int Endpt, int DataTgl, tUSBHostCb Cb, void *CbData, void *Buf, size_t Length)
+void *UHCI_DataIN(void *Ptr, int Dest, int DataTgl, tUSBHostCb Cb, void *CbData, void *Buf, size_t Length)
{
- return UHCI_int_SendTransaction(Ptr, Fcn*16+Endpt, 0x69, DataTgl, Cb, CbData, Buf, Length);
+ return UHCI_int_SendTransaction(Ptr, Dest, 0x69, DataTgl, Cb, CbData, Buf, Length);
}
-void *UHCI_DataOUT(void *Ptr, int Fcn, int Endpt, int DataTgl, tUSBHostCb Cb, void *CbData, void *Buf, size_t Length)
+void *UHCI_DataOUT(void *Ptr, int Dest, int DataTgl, tUSBHostCb Cb, void *CbData, void *Buf, size_t Length)
{
- return UHCI_int_SendTransaction(Ptr, Fcn*16+Endpt, 0xE1, DataTgl, Cb, CbData, Buf, Length);
+ return UHCI_int_SendTransaction(Ptr, Dest, 0xE1, DataTgl, Cb, CbData, Buf, Length);
}
-void *UHCI_SendSetup(void *Ptr, int Fcn, int Endpt, int DataTgl, tUSBHostCb Cb, void *CbData, void *Buf, size_t Length)
+void *UHCI_SendSetup(void *Ptr, int Dest, int DataTgl, tUSBHostCb Cb, void *CbData, void *Buf, size_t Length)
{
- return UHCI_int_SendTransaction(Ptr, Fcn*16+Endpt, 0x2D, DataTgl, Cb, CbData, Buf, Length);
+ return UHCI_int_SendTransaction(Ptr, Dest, 0x2D, DataTgl, Cb, CbData, Buf, Length);
}
int UHCI_IsTransferComplete(void *Ptr, void *Handle)