Unified __exec_do debug output. Avoid double allocation.
[AROS.git] / rom / usb / pciusb / uhwcmd.h
blobcc26d7eabda15c061e9289ad43a8fd79a3a1cd8d
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 #if defined(USB3)
11 #include "xhcichip.h"
12 #endif
13 #include "pciusb.h"
15 #if (__WORDSIZE == 64)
17 APTR usbGetBuffer(APTR data, ULONG len, UWORD dir);
18 void usbReleaseBuffer(APTR buffer, APTR data, ULONG len, UWORD dir);
20 #else
22 /* On 32-bit systems we don't need mirroring */
24 #define usbGetBuffer(data, len, dir) data
25 #define usbReleaseBuffer(buffer, data, len, dir)
27 #endif
29 struct Unit *Open_Unit(struct IOUsbHWReq *ioreq, LONG unitnr, struct PCIDevice *base);
30 void Close_Unit(struct PCIDevice *base, struct PCIUnit *unit, struct IOUsbHWReq *ioreq);
32 void SureCause(struct PCIDevice *base, struct Interrupt *interrupt);
33 BOOL uhwOpenTimer(struct PCIUnit *unit, struct PCIDevice *base);
34 void uhwDelayMS(ULONG milli, struct PCIUnit *unit);
35 void uhwCheckSpecialCtrlTransfers(struct PCIController *hc, struct IOUsbHWReq *ioreq);
36 void uhwCheckRootHubChanges(struct PCIUnit *unit);
38 WORD cmdReset(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
39 WORD cmdUsbReset(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
40 WORD cmdUsbResume(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
41 WORD cmdUsbSuspend(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
42 WORD cmdUsbOper(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
44 WORD cmdQueryDevice(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
46 WORD cmdControlXFer(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
47 WORD cmdBulkXFer(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
48 WORD cmdIntXFer(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
49 WORD cmdIsoXFer(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
51 WORD cmdFlush(struct IOUsbHWReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
53 WORD cmdNSDeviceQuery(struct IOStdReq *ioreq, struct PCIUnit *unit, struct PCIDevice *base);
55 BOOL cmdAbortIO(struct IOUsbHWReq *ioreq, struct PCIDevice *base);
57 void TermIO(struct IOUsbHWReq *ioreq, struct PCIDevice *base);
59 AROS_UFP1(void, uhwNakTimeoutInt,
60 AROS_UFPA(struct PCIUnit *, unit, A1));
62 BOOL pciInit(struct PCIDevice *hd);
63 void pciExpunge(struct PCIDevice *hd);
64 BOOL pciAllocUnit(struct PCIUnit *hu);
65 void pciFreeUnit(struct PCIUnit *hu);
66 APTR pciGetPhysical(struct PCIController *hc, APTR virtaddr);
68 /* uhcichip.c, in order of appearance */
69 void uhciFreeQContext(struct PCIController *hc, struct UhciQH *uqh);
70 void uhciUpdateIntTree(struct PCIController *hc);
71 void uhciCheckPortStatusChange(struct PCIController *hc);
72 void uhciHandleFinishedTDs(struct PCIController *hc);
73 void uhciScheduleCtrlTDs(struct PCIController *hc);
74 void uhciScheduleIntTDs(struct PCIController *hc);
75 void uhciScheduleBulkTDs(struct PCIController *hc);
76 void uhciUpdateFrameCounter(struct PCIController *hc);
77 void uhciCompleteInt(struct PCIController *hc);
78 void uhciIntCode(HIDDT_IRQ_Handler *irq, HIDDT_IRQ_HwInfo *hw);
79 BOOL uhciInit(struct PCIController *hc, struct PCIUnit *hu);
80 void uhciFree(struct PCIController *hc, struct PCIUnit *hu);
82 static inline struct UhciQH * uhciAllocQH(struct PCIController *hc);
83 static inline void uhciFreeQH(struct PCIController *hc, struct UhciQH *uqh);
84 static inline struct UhciTD * uhciAllocTD(struct PCIController *hc);
85 static inline void uhciFreeTD(struct PCIController *hc, struct UhciTD *utd);
87 /* ehcichip.c, in order of appearance */
88 void ehciFreeAsyncContext(struct PCIController *hc, struct EhciQH *eqh);
89 void ehciFreePeriodicContext(struct PCIController *hc, struct EhciQH *eqh);
90 void ehciFreeQHandTDs(struct PCIController *hc, struct EhciQH *eqh);
91 void ehciUpdateIntTree(struct PCIController *hc);
92 void ehciHandleFinishedTDs(struct PCIController *hc);
93 void ehciScheduleCtrlTDs(struct PCIController *hc);
94 void ehciScheduleIntTDs(struct PCIController *hc);
95 void ehciScheduleBulkTDs(struct PCIController *hc);
96 void ehciUpdateFrameCounter(struct PCIController *hc);
97 void ehciCompleteInt(struct PCIController *hc);
98 void ehciIntCode(HIDDT_IRQ_Handler *irq, HIDDT_IRQ_HwInfo *hw);
99 BOOL ehciInit(struct PCIController *hc, struct PCIUnit *hu);
100 void ehciFree(struct PCIController *hc, struct PCIUnit *hu);
102 static inline struct EhciQH * ehciAllocQH(struct PCIController *hc);
103 static inline void ehciFreeQH(struct PCIController *hc, struct EhciQH *eqh);
104 static inline struct EhciTD * ehciAllocTD(struct PCIController *hc);
105 static inline void ehciFreeTD(struct PCIController *hc, struct EhciTD *etd);
107 #if defined(USB3)
108 /* xhcichip.c, in order of appearance */
109 void xhciCompleteInt(struct PCIController *hc);
110 void xhciIntCode(HIDDT_IRQ_Handler *irq, HIDDT_IRQ_HwInfo *hw);
111 IPTR xhciExtCap(struct PCIController *hc, ULONG id, IPTR extcap);
112 BOOL xhciHaltHC(struct PCIController *hc);
113 BOOL xhciResetHC(struct PCIController *hc);
114 BOOL xhciInit(struct PCIController *hc, struct PCIUnit *hu);
115 void xhciFree(struct PCIController *hc, struct PCIUnit *hu);
116 #endif
118 UBYTE PCIXReadConfigByte(struct PCIController *hc, UBYTE offset);
119 UWORD PCIXReadConfigWord(struct PCIController *hc, UBYTE offset);
120 ULONG PCIXReadConfigLong(struct PCIController *hc, UBYTE offset);
121 void PCIXWriteConfigByte(struct PCIController *hc, ULONG offset, UBYTE value);
122 void PCIXWriteConfigWord(struct PCIController *hc, ULONG offset, UWORD value);
123 void PCIXWriteConfigLong(struct PCIController *hc, ULONG offset, ULONG value);
125 struct my_NSDeviceQueryResult
127 ULONG DevQueryFormat; /* this is type 0 */
128 ULONG SizeAvailable; /* bytes available */
129 UWORD DeviceType; /* what the device does */
130 UWORD DeviceSubType; /* depends on the main type */
131 const UWORD *SupportedCommands; /* 0 terminated list of cmd's */
134 /* /// "uhciAllocQH()" */
135 static inline struct UhciQH * uhciAllocQH(struct PCIController *hc)
137 struct UhciQH *uqh = hc->hc_UhciQHPool;
139 if(!uqh)
141 // out of QHs!
142 KPRINTF(20, ("Out of QHs!\n"));
143 return NULL;
146 hc->hc_UhciQHPool = (struct UhciQH *) uqh->uqh_Succ;
147 return(uqh);
149 /* \\\ */
151 /* /// "uhciFreeQH()" */
152 static inline void uhciFreeQH(struct PCIController *hc, struct UhciQH *uqh)
154 uqh->uqh_Succ = (struct UhciXX *) hc->hc_UhciQHPool;
155 hc->hc_UhciQHPool = uqh;
157 /* \\\ */
159 /* /// "uhciAllocTD()" */
160 static inline struct UhciTD * uhciAllocTD(struct PCIController *hc)
162 struct UhciTD *utd = hc->hc_UhciTDPool;
164 if(!utd)
166 // out of TDs!
167 KPRINTF(20, ("Out of TDs!\n"));
168 return NULL;
171 hc->hc_UhciTDPool = (struct UhciTD *) utd->utd_Succ;
172 return(utd);
174 /* \\\ */
176 /* /// "uhciFreeTD()" */
177 static inline void uhciFreeTD(struct PCIController *hc, struct UhciTD *utd)
179 utd->utd_Succ = (struct UhciXX *) hc->hc_UhciTDPool;
180 hc->hc_UhciTDPool = utd;
182 /* \\\ */
184 /* /// "ehciAllocQH()" */
185 static inline struct EhciQH * ehciAllocQH(struct PCIController *hc)
187 struct EhciQH *eqh = hc->hc_EhciQHPool;
189 if(!eqh)
191 // out of QHs!
192 KPRINTF(20, ("Out of QHs!\n"));
193 return NULL;
196 hc->hc_EhciQHPool = (struct EhciQH *) eqh->eqh_Succ;
197 return(eqh);
199 /* \\\ */
201 /* /// "ehciFreeQH()" */
202 static inline void ehciFreeQH(struct PCIController *hc, struct EhciQH *eqh)
204 eqh->eqh_Succ = hc->hc_EhciQHPool;
205 hc->hc_EhciQHPool = eqh;
207 /* \\\ */
209 /* /// "ehciAllocTD()" */
210 static inline struct EhciTD * ehciAllocTD(struct PCIController *hc)
212 struct EhciTD *etd = hc->hc_EhciTDPool;
214 if(!etd)
216 // out of TDs!
217 KPRINTF(20, ("Out of TDs!\n"));
218 return NULL;
221 hc->hc_EhciTDPool = (struct EhciTD *) etd->etd_Succ;
222 return(etd);
224 /* \\\ */
226 /* /// "ehciFreeTD()" */
227 static inline void ehciFreeTD(struct PCIController *hc, struct EhciTD *etd)
229 etd->etd_Succ = hc->hc_EhciTDPool;
230 hc->hc_EhciTDPool = etd;
232 /* \\\ */
234 #endif /* UHWCMD_H */