/*
- * AcessOS Version 1
- * USB Stack
+ * Acess2 USB Stack
+ * - By John Hodge (thePowersGang)
+ *
+ * usb.h
+ * - USB Internal definitions
*/
#ifndef _USB_H_
#define _USB_H_
-// === TYPES ===
+#include <usb_core.h>
+#include <usb_hub.h>
+#include <usb_host.h>
+
typedef struct sUSBHost tUSBHost;
-typedef struct sUSBHub tUSBHub;
typedef struct sUSBDevice tUSBDevice;
+typedef struct sUSBEndpoint tUSBEndpoint;
// === STRUCTURES ===
/**
- * \brief Defines a USB Host Controller type
+ * \brief USB Hub data
*/
-struct sUSBHost
+struct sUSBHub
{
- tUSBHost *Next;
-
- void (*CheckPorts)(void *Ptr);
+ tUSBInterface *Interface;
+
+ int nPorts;
+ tUSBDevice *Devices[];
+};
- void *(*SendIN)(void *Ptr, int Fcn, int Endpt, int DataTgl, int bIOC, void *Data, size_t Length);
- void *(*SendOUT)(void *Ptr, int Fcn, int Endpt, int DataTgl, int bIOC, void *Data, size_t Length);
- void *(*SendSETUP)(void *Ptr, int Fcn, int Endpt, int DataTgl, int bIOC, void *Data, size_t Length);
+struct sUSBEndpoint
+{
+ tUSBEndpoint *Next; // (usb_poll.c) Clock list
+ tUSBInterface *Interface;
+ int EndpointIdx; // Interface endpoint index
+ int EndpointNum; // Device endpoint num
+
+ int PollingPeriod; // In 1ms intervals
+ int MaxPacketSize; // In bytes
+ Uint8 Type; // Same as sUSBDriver.Endpoints.Type
+
+ int PollingAtoms; // (usb_poll.c) Period in clock list
+ void *InputData;
};
/**
- * \brief USB Hub data
+ * \brief Structure for a device's interface
*/
-struct sUSBHub
+struct sUSBInterface
{
- /**
- * \brief Host controller used
- */
- tUSBHost *HostDef;
- void *Controller;
+// tUSBInterface *Next;
+ tUSBDevice *Dev;
- int nPorts;
- tUSBDevice *Devices[];
+ tUSBDriver *Driver;
+ void *Data;
+
+ int nEndpoints;
+ tUSBEndpoint Endpoints[];
};
/**
*/
struct sUSBDevice
{
- tUSBDevice *Next;
- tUSBDevice *Hub;
+ tUSBHub *ParentHub;
+ /**
+ * \brief Host controller used
+ */
+ tUSBHost *Host;
int Address;
+
+ int nInterfaces;
+ tUSBInterface *Interfaces[];
+};
+
+struct sUSBHost
+{
+ struct sUSBHost *Next;
+
+ tUSBHostDef *HostDef;
+ void *Ptr;
- int Type;
+ Uint8 AddressBitmap[128/8];
- union {
- tUSBHub Hub;
- char Impl[0];
- } Data;
+ tUSBDevice RootHubDev;
+ tUSBInterface RootHubIf;
+ tUSBHub RootHub;
};
-extern void USB_RegisterHost(tUSBHost *HostDef, void *ControllerPtr);
-extern void USB_NewDevice(tUSBHub *Hub);
+extern tUSBDriver *USB_int_FindDriverByClass(Uint32 ClassCode);
#endif