PopFile image fits better.
[AROS.git] / rom / usb / pciusb / uhwcmd.h
blob5484992692da3463c7dfbeda9b3fce3bce484e85
1 #ifndef UHWCMD_H
2 #define UHWCMD_H
4 #include "debug.h"
5 #include "pci_aros.h"
7 #include "uhcichip.h"
8 #include "ohcichip.h"
9 #include "ehcichip.h"
10 #include "pciusb.h"
12 #if (__WORDSIZE == 64)
14 APTR usbGetBuffer(APTR data, ULONG len, UWORD dir);
15 void usbReleaseBuffer(APTR buffer, APTR data, ULONG len, UWORD dir);
17 #else
19 /* On 32-bit systems we don't need mirroring */
21 #define usbGetBuffer(data, len, dir) ({ (void)(len); (void)(dir); (data);})
22 #define usbReleaseBuffer(buffer, data, len, dir) do { (void)(buffer); (void)(data); (void)(len); (void)(dir); } while (0)
24 #endif
26 struct Unit *Open_Unit(struct IOUsbHWReq *ioreq, LONG unitnr, struct PCIDevice *base);
27 void Close_Unit(struct PCIDevice *base, struct PCIUnit *unit, struct IOUsbHWReq *ioreq);
29 void SureCause(struct PCIDevice *base, struct Interrupt *interrupt);
30 BOOL uhwOpenTimer(struct PCIUnit *unit, struct PCIDevice *base);
31 void uhwDelayMS(ULONG milli, struct PCIUnit *unit);
32 void uhwCheckSpecialCtrlTransfers(struct PCIController *hc, struct IOUsbHWReq *ioreq);
33 void uhwCheckRootHubChanges(struct PCIUnit *unit);
35 WORD cmdReset(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
36 WORD cmdUsbReset(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
37 WORD cmdUsbResume(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
38 WORD cmdUsbSuspend(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
39 WORD cmdUsbOper(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
41 WORD cmdQueryDevice(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
43 WORD cmdControlXFer(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
44 WORD cmdBulkXFer(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
45 WORD cmdIntXFer(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
46 WORD cmdIsoXFer(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
48 WORD cmdFlush(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
50 WORD cmdNSDeviceQuery(struct IOStdReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
52 BOOL cmdAbortIO(struct IOUsbHWReq *ioreq, struct PCIDevice *base);
54 void TermIO(struct IOUsbHWReq *ioreq, struct PCIDevice *base);
56 AROS_UFP1(void, uhwNakTimeoutInt,
57 AROS_UFPA(struct PCIUnit *, unit, A1));
59 BOOL pciInit(struct PCIDevice *hd);
60 void pciExpunge(struct PCIDevice *hd);
61 BOOL pciAllocUnit(struct PCIUnit *hu);
62 void pciFreeUnit(struct PCIUnit *hu);
63 APTR pciGetPhysical(struct PCIController *hc, APTR virtaddr);
65 /* uhcichip.c, in order of appearance */
66 void uhciFreeQContext(struct PCIController *hc, struct UhciQH *uqh);
67 void uhciUpdateIntTree(struct PCIController *hc);
68 void uhciCheckPortStatusChange(struct PCIController *hc);
69 void uhciHandleFinishedTDs(struct PCIController *hc);
70 void uhciScheduleCtrlTDs(struct PCIController *hc);
71 void uhciScheduleIntTDs(struct PCIController *hc);
72 void uhciScheduleBulkTDs(struct PCIController *hc);
73 void uhciUpdateFrameCounter(struct PCIController *hc);
74 void uhciCompleteInt(struct PCIController *hc);
75 void uhciIntCode(HIDDT_IRQ_Handler *irq, HIDDT_IRQ_HwInfo *hw);
76 BOOL uhciInit(struct PCIController *hc, struct PCIUnit *hu);
77 void uhciFree(struct PCIController *hc, struct PCIUnit *hu);
79 static inline struct UhciQH * uhciAllocQH(struct PCIController *hc);
80 static inline void uhciFreeQH(struct PCIController *hc, struct UhciQH *uqh);
81 static inline struct UhciTD * uhciAllocTD(struct PCIController *hc);
82 static inline void uhciFreeTD(struct PCIController *hc, struct UhciTD *utd);
84 /* ehcichip.c, in order of appearance */
85 void ehciFreeAsyncContext(struct PCIController *hc, struct IOUsbHWReq *ioreq);
86 void ehciFreePeriodicContext(struct PCIController *hc, struct IOUsbHWReq *ioreq);
87 void ehciFreeQHandTDs(struct PCIController *hc, struct EhciQH *eqh);
88 void ehciUpdateIntTree(struct PCIController *hc);
89 void ehciHandleFinishedTDs(struct PCIController *hc);
90 void ehciScheduleCtrlTDs(struct PCIController *hc);
91 void ehciScheduleIntTDs(struct PCIController *hc);
92 void ehciScheduleBulkTDs(struct PCIController *hc);
93 void ehciUpdateFrameCounter(struct PCIController *hc);
94 void ehciCompleteInt(struct PCIController *hc);
95 void ehciIntCode(HIDDT_IRQ_Handler *irq, HIDDT_IRQ_HwInfo *hw);
96 BOOL ehciInit(struct PCIController *hc, struct PCIUnit *hu);
97 void ehciFree(struct PCIController *hc, struct PCIUnit *hu);
99 static inline struct EhciQH * ehciAllocQH(struct PCIController *hc);
100 static inline void ehciFreeQH(struct PCIController *hc, struct EhciQH *eqh);
101 static inline struct EhciTD * ehciAllocTD(struct PCIController *hc);
102 static inline void ehciFreeTD(struct PCIController *hc, struct EhciTD *etd);
104 UBYTE PCIXReadConfigByte(struct PCIController *hc, UBYTE offset);
105 UWORD PCIXReadConfigWord(struct PCIController *hc, UBYTE offset);
106 ULONG PCIXReadConfigLong(struct PCIController *hc, UBYTE offset);
107 void PCIXWriteConfigByte(struct PCIController *hc, ULONG offset, UBYTE value);
108 void PCIXWriteConfigWord(struct PCIController *hc, ULONG offset, UWORD value);
109 void PCIXWriteConfigLong(struct PCIController *hc, ULONG offset, ULONG value);
111 struct my_NSDeviceQueryResult
113 ULONG DevQueryFormat; /* this is type 0 */
114 ULONG SizeAvailable; /* bytes available */
115 UWORD DeviceType; /* what the device does */
116 UWORD DeviceSubType; /* depends on the main type */
117 const UWORD *SupportedCommands; /* 0 terminated list of cmd's */
120 /* /// "uhciAllocQH()" */
121 static inline struct UhciQH * uhciAllocQH(struct PCIController *hc)
123 struct UhciQH *uqh = hc->hc_UhciQHPool;
125 if(!uqh)
127 // out of QHs!
128 KPRINTF(20, ("Out of QHs!\n"));
129 return NULL;
132 hc->hc_UhciQHPool = (struct UhciQH *) uqh->uqh_Succ;
134 uqh->uqh_SetupBuffer = NULL;
135 uqh->uqh_DataBuffer = NULL;
136 return(uqh);
138 /* \\\ */
140 /* /// "uhciFreeQH()" */
141 static inline void uhciFreeQH(struct PCIController *hc, struct UhciQH *uqh)
143 uqh->uqh_Succ = (struct UhciXX *) hc->hc_UhciQHPool;
144 hc->hc_UhciQHPool = uqh;
146 /* \\\ */
148 /* /// "uhciAllocTD()" */
149 static inline struct UhciTD * uhciAllocTD(struct PCIController *hc)
151 struct UhciTD *utd = hc->hc_UhciTDPool;
153 if(!utd)
155 // out of TDs!
156 KPRINTF(20, ("Out of TDs!\n"));
157 return NULL;
160 hc->hc_UhciTDPool = (struct UhciTD *) utd->utd_Succ;
161 return(utd);
163 /* \\\ */
165 /* /// "uhciFreeTD()" */
166 static inline void uhciFreeTD(struct PCIController *hc, struct UhciTD *utd)
168 utd->utd_Succ = (struct UhciXX *) hc->hc_UhciTDPool;
169 hc->hc_UhciTDPool = utd;
171 /* \\\ */
173 /* /// "ehciAllocQH()" */
174 static inline struct EhciQH * ehciAllocQH(struct PCIController *hc)
176 struct EhciQH *eqh = hc->hc_EhciQHPool;
178 if(!eqh)
180 // out of QHs!
181 KPRINTF(20, ("Out of QHs!\n"));
182 return NULL;
185 hc->hc_EhciQHPool = (struct EhciQH *) eqh->eqh_Succ;
186 return(eqh);
188 /* \\\ */
190 /* /// "ehciFreeQH()" */
191 static inline void ehciFreeQH(struct PCIController *hc, struct EhciQH *eqh)
193 eqh->eqh_Succ = hc->hc_EhciQHPool;
194 hc->hc_EhciQHPool = eqh;
196 /* \\\ */
198 /* /// "ehciAllocTD()" */
199 static inline struct EhciTD * ehciAllocTD(struct PCIController *hc)
201 struct EhciTD *etd = hc->hc_EhciTDPool;
203 if(!etd)
205 // out of TDs!
206 KPRINTF(20, ("Out of TDs!\n"));
207 return NULL;
210 hc->hc_EhciTDPool = (struct EhciTD *) etd->etd_Succ;
211 return(etd);
213 /* \\\ */
215 /* /// "ehciFreeTD()" */
216 static inline void ehciFreeTD(struct PCIController *hc, struct EhciTD *etd)
218 etd->etd_Succ = hc->hc_EhciTDPool;
219 hc->hc_EhciTDPool = etd;
221 /* \\\ */
223 #endif /* UHWCMD_H */