Kernel - Slight reworks to timer code
[tpg/acess2.git] / Modules / USB / Core / usb.h
index 397e4d7..5a13363 100644 (file)
@@ -1,85 +1,61 @@
 /*
- * 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 sUSBDevice      tUSBDevice;
+typedef struct sUSBEndpoint    tUSBEndpoint;
 
-// === CONSTANTS ===
-enum eUSB_PIDs
+// === STRUCTURES ===
+/**
+ * \brief USB Hub data
+ */
+struct sUSBHub
 {
-       /**
-        * \name Token
-        * \{
-        */
-       PID_OUT         = 0xE1,
-       PID_IN          = 0x69,
-       PID_SOF         = 0xA5,
-       PID_SETUP       = 0x2D,
-       /**
-        * \}
-        */
+       tUSBInterface   *Interface;
        
-       /**
-        * \name Data
-        * \{
-        */
-       PID_DATA0       = 0xC3,
-       PID_DATA1       = 0x4B,
-       PID_DATA2       = 0x87, // USB2 only
-       PID_MDATA       = 0x0F, // USB2 only
-       /**
-        * \}
-        */
+        int    nPorts;
+       tUSBDevice      *Devices[];
+};
+
+struct sUSBEndpoint
+{
+       tUSBEndpoint    *Next;  // (usb_poll.c) Clock list
+       tUSBInterface   *Interface;
+        int    EndpointIdx;    // Interface endpoint index
+        int    EndpointNum;    // Device endpoint num
        
-       /**
-        * \name Handshake
-        * \{
-        */
-       PID_ACK         = 0xD2,
-       PID_NAK         = 0x5A,
-       PID_STALL       = 0x1E,
-       PID_NYET        = 0x96,
-       /**
-        * \}
-        */
+        int    PollingPeriod;  // In 1ms intervals
+        int    MaxPacketSize;  // In bytes
+       Uint8   Type;   // Same as sUSBDriver.Endpoints.Type
        
-       /**
-        * \name Special
-        * \{
-        */
-       PID_PRE         = 0x3C, PID_ERR         = 0x3C,
-       PID_SPLIT       = 0x78,
-       PID_PING        = 0xB4,
-       PID_RESVD       = 0xF0,
-       /**
-        * \}
-        */
+        int    PollingAtoms;   // (usb_poll.c) Period in clock list
+       void    *InputData;
 };
 
-// === FUNCTIONS ===
-/**
- * \note 00101 - X^5+X^2+1
- */
-Uint8  USB_TokenCRC(void *Data, int len);
 /**
- * \note X^16 + X15 + X^2 + 1
+ * \brief Structure for a device's interface
  */
-Uint16 USB_DataCRC(void *Data, int len);
-
-// === STRUCTURES ===
-/**
- * \brief Defines a USB Host Controller
- */
-struct sUSBHost
+struct sUSBInterface
 {
-       Uint16  IOBase;
+//     tUSBInterface   *Next;
+       tUSBDevice      *Dev;
+
+       tUSBDriver      *Driver;
+       void    *Data;
        
-        int    (*SendPacket)(int ID, int Length, void *Data);
+        int    nEndpoints;
+       tUSBEndpoint    Endpoints[];
 };
 
 /**
@@ -87,10 +63,32 @@ struct sUSBHost
  */
 struct sUSBDevice
 {
+       tUSBHub *ParentHub;
+
+       /**
+        * \brief Host controller used
+        */
        tUSBHost        *Host;
-        int    MaxControl;
-        int    MaxBulk;
-        int    MaxISync;
+        int    Address;
+
+        int    nInterfaces;
+       tUSBInterface   *Interfaces[];
+};
+
+struct sUSBHost
+{
+       struct sUSBHost *Next;
+       
+       tUSBHostDef     *HostDef;
+       void    *Ptr;
+       
+       Uint8   AddressBitmap[128/8];
+       
+       tUSBDevice      RootHubDev;
+       tUSBInterface   RootHubIf;
+       tUSBHub RootHub;
 };
 
+extern tUSBDriver      *USB_int_FindDriverByClass(Uint32 ClassCode);
+
 #endif

UCC git Repository :: git.ucc.asn.au