Merge branch 'master' of git://localhost/acess2
[tpg/acess2.git] / KernelLand / Modules / USB / EHCI / ehci.h
1 /*
2  * Acess2 EHCI Driver
3  * - By John Hodge (thePowersGang)
4  *
5  * ehci.h
6  * - ECHI Header
7  */
8 #ifndef _EHCI_H_
9 #define _EHCI_H_
10
11 #include <threads.h>
12
13 typedef struct sEHCI_Controller tEHCI_Controller;
14 typedef struct sEHCI_Endpoint   tEHCI_Endpoint;
15
16 #define PERIODIC_SIZE   1024
17
18 #include "ehci_hw.h"
19
20 #define PID_OUT         0
21 #define PID_IN          1
22 #define PID_SETUP       2
23
24 #define TD_POOL_SIZE    (PAGE_SIZE/sizeof(tEHCI_qTD))
25 // - 256 addresses * 16 endpoints
26 #define QH_POOL_SIZE    (256*16)
27 #define QH_POOL_PAGES   (QH_POOL_SIZE*sizeof(tEHCI_QH)/PAGE_SIZE)
28 #define QH_POOL_NPERPAGE        (PAGE_SIZE/sizeof(tEHCI_QH))
29
30 struct sEHCI_Controller
31 {
32         tUSBHub *RootHub;
33         tThread *InterruptThread;
34          int    nPorts;
35
36         tPAddr  PhysBase;
37         tEHCI_CapRegs   *CapRegs;
38         tEHCI_OpRegs    *OpRegs;
39
40         tEHCI_qTD       *DeadTD;
41         tEHCI_QH        *DeadQH;
42
43          int    InterruptLoad[PERIODIC_SIZE];
44         
45         tMutex  lReclaimList;
46         tEHCI_QH        *ReclaimList;
47
48         tMutex  lAsyncSchedule; 
49
50         tMutex          PeriodicListLock;
51         Uint32          *PeriodicQueue;
52         tEHCI_QH        *PeriodicQueueV[PERIODIC_SIZE];
53         
54         tMutex  QHPoolMutex;
55         tEHCI_QH        *QHPools[QH_POOL_PAGES];        // [PAGE_SIZE/64]
56         tMutex  TDPoolMutex;
57         tEHCI_qTD       *TDPool;        // [TD_POOL_SIZE]
58         
59         tEHCI_Endpoint  *FirstInterruptEndpt;   // List of interrupt endpoints
60 };
61
62 struct sEHCI_Endpoint
63 {
64         tEHCI_Endpoint  *Next;
65         bool    NextToggle;
66         Uint16  EndpointID;
67         Sint8   PeriodPow2;
68         Uint8   InterruptOfs;
69         size_t  MaxPacketSize;
70         tEHCI_QH        *ActiveQHs;
71 };
72
73 #endif
74

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