hcd-uhci.c (3c87c76d1a0e9ce1dde6f919e3b1b9bcabb69985) hcd-uhci.c (40507377261250fe19e441300788c77b748688cb)
1/*
2 * USB UHCI controller emulation
3 *
4 * Copyright (c) 2005 Fabrice Bellard
5 *
6 * Copyright (c) 2008 Max Krasnyansky
7 * Magor rewrite of the UHCI data structures parser and frame processor
8 * Support for fully async operation and multiple outstanding transactions

--- 146 unchanged lines hidden (view full) ---

155 uint32_t buffer;
156} UHCI_TD;
157
158typedef struct UHCI_QH {
159 uint32_t link;
160 uint32_t el_link;
161} UHCI_QH;
162
1/*
2 * USB UHCI controller emulation
3 *
4 * Copyright (c) 2005 Fabrice Bellard
5 *
6 * Copyright (c) 2008 Max Krasnyansky
7 * Magor rewrite of the UHCI data structures parser and frame processor
8 * Support for fully async operation and multiple outstanding transactions

--- 146 unchanged lines hidden (view full) ---

155 uint32_t buffer;
156} UHCI_TD;
157
158typedef struct UHCI_QH {
159 uint32_t link;
160 uint32_t el_link;
161} UHCI_QH;
162
163static void uhci_async_cancel(UHCIAsync *async);
164
163static inline int32_t uhci_queue_token(UHCI_TD *td)
164{
165 /* covers ep, dev, pid -> identifies the endpoint */
166 return td->token & 0x7ffff;
167}
168
169static UHCIQueue *uhci_queue_get(UHCIState *s, UHCI_TD *td)
170{

--- 13 unchanged lines hidden (view full) ---

184 QTAILQ_INSERT_HEAD(&s->queues, queue, next);
185 trace_usb_uhci_queue_add(queue->token);
186 return queue;
187}
188
189static void uhci_queue_free(UHCIQueue *queue)
190{
191 UHCIState *s = queue->uhci;
165static inline int32_t uhci_queue_token(UHCI_TD *td)
166{
167 /* covers ep, dev, pid -> identifies the endpoint */
168 return td->token & 0x7ffff;
169}
170
171static UHCIQueue *uhci_queue_get(UHCIState *s, UHCI_TD *td)
172{

--- 13 unchanged lines hidden (view full) ---

186 QTAILQ_INSERT_HEAD(&s->queues, queue, next);
187 trace_usb_uhci_queue_add(queue->token);
188 return queue;
189}
190
191static void uhci_queue_free(UHCIQueue *queue)
192{
193 UHCIState *s = queue->uhci;
194 UHCIAsync *async;
192
195
196 while (!QTAILQ_EMPTY(&queue->asyncs)) {
197 async = QTAILQ_FIRST(&queue->asyncs);
198 uhci_async_cancel(async);
199 }
200
193 trace_usb_uhci_queue_del(queue->token);
194 QTAILQ_REMOVE(&s->queues, queue, next);
195 g_free(queue);
196}
197
198static UHCIAsync *uhci_async_alloc(UHCIQueue *queue, uint32_t addr)
199{
200 UHCIAsync *async = g_new0(UHCIAsync, 1);

--- 53 unchanged lines hidden (view full) ---

254}
255
256/*
257 * Cancel async packets that are no longer valid
258 */
259static void uhci_async_validate_end(UHCIState *s)
260{
261 UHCIQueue *queue, *n;
201 trace_usb_uhci_queue_del(queue->token);
202 QTAILQ_REMOVE(&s->queues, queue, next);
203 g_free(queue);
204}
205
206static UHCIAsync *uhci_async_alloc(UHCIQueue *queue, uint32_t addr)
207{
208 UHCIAsync *async = g_new0(UHCIAsync, 1);

--- 53 unchanged lines hidden (view full) ---

262}
263
264/*
265 * Cancel async packets that are no longer valid
266 */
267static void uhci_async_validate_end(UHCIState *s)
268{
269 UHCIQueue *queue, *n;
262 UHCIAsync *async;
263
264 QTAILQ_FOREACH_SAFE(queue, &s->queues, next, n) {
270
271 QTAILQ_FOREACH_SAFE(queue, &s->queues, next, n) {
265 if (queue->valid > 0) {
266 continue;
272 if (!queue->valid) {
273 uhci_queue_free(queue);
267 }
274 }
268 while (!QTAILQ_EMPTY(&queue->asyncs)) {
269 async = QTAILQ_FIRST(&queue->asyncs);
270 uhci_async_cancel(async);
271 }
272 uhci_queue_free(queue);
273 }
274}
275
276static void uhci_async_cancel_device(UHCIState *s, USBDevice *dev)
277{
278 UHCIQueue *queue;
279 UHCIAsync *curr, *n;
280

--- 6 unchanged lines hidden (view full) ---

287 uhci_async_cancel(curr);
288 }
289 }
290}
291
292static void uhci_async_cancel_all(UHCIState *s)
293{
294 UHCIQueue *queue, *nq;
275 }
276}
277
278static void uhci_async_cancel_device(UHCIState *s, USBDevice *dev)
279{
280 UHCIQueue *queue;
281 UHCIAsync *curr, *n;
282

--- 6 unchanged lines hidden (view full) ---

289 uhci_async_cancel(curr);
290 }
291 }
292}
293
294static void uhci_async_cancel_all(UHCIState *s)
295{
296 UHCIQueue *queue, *nq;
295 UHCIAsync *curr, *n;
296
297 QTAILQ_FOREACH_SAFE(queue, &s->queues, next, nq) {
297
298 QTAILQ_FOREACH_SAFE(queue, &s->queues, next, nq) {
298 QTAILQ_FOREACH_SAFE(curr, &queue->asyncs, next, n) {
299 uhci_async_cancel(curr);
300 }
301 uhci_queue_free(queue);
302 }
303}
304
305static UHCIAsync *uhci_async_find_td(UHCIState *s, uint32_t addr, UHCI_TD *td)
306{
307 uint32_t token = uhci_queue_token(td);
308 UHCIQueue *queue;

--- 1083 unchanged lines hidden ---
299 uhci_queue_free(queue);
300 }
301}
302
303static UHCIAsync *uhci_async_find_td(UHCIState *s, uint32_t addr, UHCI_TD *td)
304{
305 uint32_t token = uhci_queue_token(td);
306 UHCIQueue *queue;

--- 1083 unchanged lines hidden ---