[41b96b4] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Jan Vesely
|
---|
[e0a5d4c] | 3 | * Copyright (c) 2018 Ondrej Hlavaty
|
---|
[41b96b4] | 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 | */
|
---|
[23f40280] | 29 | /** @addtogroup drvusbohci
|
---|
[41b96b4] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
[23f40280] | 33 | * @brief OHCI driver USB transaction structure
|
---|
[41b96b4] | 34 | */
|
---|
[23f40280] | 35 | #ifndef DRV_OHCI_BATCH_H
|
---|
| 36 | #define DRV_OHCI_BATCH_H
|
---|
[41b96b4] | 37 |
|
---|
[9c10e51] | 38 | #include <adt/list.h>
|
---|
[0d4b110] | 39 | #include <assert.h>
|
---|
| 40 | #include <stdbool.h>
|
---|
[e67c50a] | 41 | #include <usb/dma_buffer.h>
|
---|
[f58ef61] | 42 | #include <usb/host/usb_transfer_batch.h>
|
---|
[41b96b4] | 43 |
|
---|
[9c10e51] | 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 {
|
---|
[5fd9c30] | 49 | usb_transfer_batch_t base;
|
---|
| 50 |
|
---|
[9c10e51] | 51 | /** Number of TDs used by the transfer */
|
---|
| 52 | size_t td_count;
|
---|
[e67c50a] | 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;
|
---|
[9c10e51] | 65 | } ohci_transfer_batch_t;
|
---|
| 66 |
|
---|
[ae3a941] | 67 | ohci_transfer_batch_t *ohci_transfer_batch_create(endpoint_t *batch);
|
---|
[5fd9c30] | 68 | int ohci_transfer_batch_prepare(ohci_transfer_batch_t *ohci_batch);
|
---|
[11cb0565] | 69 | void ohci_transfer_batch_commit(const ohci_transfer_batch_t *batch);
|
---|
[5fd9c30] | 70 | bool ohci_transfer_batch_check_completed(ohci_transfer_batch_t *batch);
|
---|
| 71 | void ohci_transfer_batch_destroy(ohci_transfer_batch_t *ohci_batch);
|
---|
[76fbd9a] | 72 |
|
---|
[ae3a941] | 73 | static inline ohci_transfer_batch_t *ohci_transfer_batch_get(
|
---|
| 74 | usb_transfer_batch_t *usb_batch)
|
---|
[5fd9c30] | 75 | {
|
---|
| 76 | assert(usb_batch);
|
---|
| 77 |
|
---|
| 78 | return (ohci_transfer_batch_t *) usb_batch;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
[41b96b4] | 81 | #endif
|
---|
| 82 | /**
|
---|
| 83 | * @}
|
---|
| 84 | */
|
---|