1 | /*
|
---|
2 | * Copyright (c) 2011 Jan Vesely
|
---|
3 | * Copyright (c) 2018 Ondrej Hlavaty
|
---|
4 | * All rights reserved.
|
---|
5 | *
|
---|
6 | * Redistribution and use in source and binary forms, with or without
|
---|
7 | * modification, are permitted provided that the following conditions
|
---|
8 | * are met:
|
---|
9 | *
|
---|
10 | * - Redistributions of source code must retain the above copyright
|
---|
11 | * notice, this list of conditions and the following disclaimer.
|
---|
12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
13 | * notice, this list of conditions and the following disclaimer in the
|
---|
14 | * documentation and/or other materials provided with the distribution.
|
---|
15 | * - The name of the author may not be used to endorse or promote products
|
---|
16 | * derived from this software without specific prior written permission.
|
---|
17 | *
|
---|
18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
28 | */
|
---|
29 | /** @addtogroup drvusbohci
|
---|
30 | * @{
|
---|
31 | */
|
---|
32 | /** @file
|
---|
33 | * @brief OHCI driver USB transaction structure
|
---|
34 | */
|
---|
35 | #ifndef DRV_OHCI_BATCH_H
|
---|
36 | #define DRV_OHCI_BATCH_H
|
---|
37 |
|
---|
38 | #include <adt/list.h>
|
---|
39 | #include <assert.h>
|
---|
40 | #include <stdbool.h>
|
---|
41 | #include <usb/dma_buffer.h>
|
---|
42 | #include <usb/host/usb_transfer_batch.h>
|
---|
43 |
|
---|
44 | #include "hw_struct/transfer_descriptor.h"
|
---|
45 | #include "hw_struct/endpoint_descriptor.h"
|
---|
46 |
|
---|
47 | /** OHCI specific data required for USB transfer */
|
---|
48 | typedef struct ohci_transfer_batch {
|
---|
49 | usb_transfer_batch_t base;
|
---|
50 |
|
---|
51 | /** Number of TDs used by the transfer */
|
---|
52 | size_t td_count;
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * List of TDs needed for the transfer - together with setup data
|
---|
56 | * backed by the dma buffer. Note that the TD pointers are pointing to
|
---|
57 | * the DMA buffer initially, but as the scheduling must use the first TD
|
---|
58 | * from EP, it is replaced.
|
---|
59 | */
|
---|
60 | td_t **tds;
|
---|
61 | char *setup_buffer;
|
---|
62 | char *data_buffer;
|
---|
63 |
|
---|
64 | dma_buffer_t ohci_dma_buffer;
|
---|
65 | } ohci_transfer_batch_t;
|
---|
66 |
|
---|
67 | ohci_transfer_batch_t *ohci_transfer_batch_create(endpoint_t *batch);
|
---|
68 | int ohci_transfer_batch_prepare(ohci_transfer_batch_t *ohci_batch);
|
---|
69 | void ohci_transfer_batch_commit(const ohci_transfer_batch_t *batch);
|
---|
70 | bool ohci_transfer_batch_check_completed(ohci_transfer_batch_t *batch);
|
---|
71 | void ohci_transfer_batch_destroy(ohci_transfer_batch_t *ohci_batch);
|
---|
72 |
|
---|
73 | static inline ohci_transfer_batch_t *ohci_transfer_batch_get(
|
---|
74 | usb_transfer_batch_t *usb_batch)
|
---|
75 | {
|
---|
76 | assert(usb_batch);
|
---|
77 |
|
---|
78 | return (ohci_transfer_batch_t *) usb_batch;
|
---|
79 | }
|
---|
80 |
|
---|
81 | #endif
|
---|
82 | /**
|
---|
83 | * @}
|
---|
84 | */
|
---|