AM243x MCU+ SDK  11.02.00
udma_ring.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018-2021 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
48 #ifndef UDMA_RING_H_
49 #define UDMA_RING_H_
50 
51 /* ========================================================================== */
52 /* Include Files */
53 /* ========================================================================== */
54 
55 /* None */
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 /* ========================================================================== */
62 /* Macros & Typedefs */
63 /* ========================================================================== */
64 
69 #define UDMA_RING_INVALID ((uint16_t) TISCI_MSG_VALUE_RM_NULL_RING_TYPE)
70 
74 #define UDMA_RING_ANY ((uint16_t) 0xFFFEU)
75 
79 #define UDMA_RING_VIRTID_INVALID ((uint16_t) 0xFFFFU)
80 
82 #define UDMA_RING_SIZE_CHECK_SKIP (0xABDCABCDU)
83 
87 #define UDMA_RING_ORDERID_MAX (0x0FU)
88 
101 #define UDMA_RING_ES_4BYTES ((uint8_t) 0x00U)
102 
103 #define UDMA_RING_ES_8BYTES ((uint8_t) 0x01U)
104 
105 #define UDMA_RING_ES_16BYTES ((uint8_t) 0x02U)
106 
107 #define UDMA_RING_ES_32BYTES ((uint8_t) 0x03U)
108 
109 #define UDMA_RING_ES_64BYTES ((uint8_t) 0x04U)
110 
111 #define UDMA_RING_ES_128BYTES ((uint8_t) 0x05U)
112 
113 #define UDMA_RING_ES_256BYTES ((uint8_t) 0x06U)
114 
116 /* ========================================================================== */
117 /* Structure Declarations */
118 /* ========================================================================== */
119 
120 
121 
122 /* ========================================================================== */
123 /* Function Declarations */
124 /* ========================================================================== */
125 
144 int32_t Udma_ringAlloc(Udma_DrvHandle drvHandle,
145  Udma_RingHandle ringHandle,
146  uint16_t ringNum,
147  const Udma_RingPrms *ringPrms);
148 
159 int32_t Udma_ringFree(Udma_RingHandle ringHandle);
160 
191 int32_t Udma_ringAttach(Udma_DrvHandle drvHandle,
192  Udma_RingHandle ringHandle,
193  uint16_t ringNum);
194 
208 int32_t Udma_ringDetach(Udma_RingHandle ringHandle);
209 
238 int32_t Udma_ringQueueRaw(Udma_RingHandle ringHandle, uint64_t phyDescMem);
239 
276 int32_t Udma_ringDequeueRaw(Udma_RingHandle ringHandle, uint64_t *phyDescMem);
277 
301 int32_t Udma_ringFlushRaw(Udma_RingHandle ringHandle, uint64_t *phyDescMem);
302 
329 void Udma_ringPrime(Udma_RingHandle ringHandle, uint64_t phyDescMem);
330 
359 void Udma_ringPrimeRead(Udma_RingHandle ringHandle, uint64_t *phyDescMem);
360 
388 void Udma_ringSetDoorBell(Udma_RingHandle ringHandle, int32_t count);
389 
398 uint16_t Udma_ringGetNum(Udma_RingHandle ringHandle);
399 
410 uint8_t *Udma_ringGetMemPtr(Udma_RingHandle ringHandle);
411 
422 uint32_t Udma_ringGetMode(Udma_RingHandle ringHandle);
423 
435 
453 
471 
488 uint32_t Udma_ringGetWrIdx(Udma_RingHandle ringHandle);
489 
506 uint32_t Udma_ringGetRdIdx(Udma_RingHandle ringHandle);
507 
508 /*
509  * Structure Init functions
510  */
518 
519 /* ========================================================================== */
520 /* Static Function Definitions */
521 /* ========================================================================== */
522 
523 /* None */
524 
525 /* ========================================================================== */
526 /* Internal/Private Structure Declarations */
527 /* ========================================================================== */
528 
529 /* None */
530 
531 #ifdef __cplusplus
532 }
533 #endif
534 
535 #endif /* #ifndef UDMA_RING_H_ */
536 
Udma_ringDequeueRaw
int32_t Udma_ringDequeueRaw(Udma_RingHandle ringHandle, uint64_t *phyDescMem)
UDMA dequeue descriptor from a ring - raw version (Takes all physical pointers).
Udma_ringPrime
void Udma_ringPrime(Udma_RingHandle ringHandle, uint64_t phyDescMem)
UDMA prime descriptor to a exposed/"RING" mode ring - raw version (Takes all physical pointers)....
Udma_RingPrms
UDMA ring parameters.
Definition: udma_types.h:98
Udma_ringAttach
int32_t Udma_ringAttach(Udma_DrvHandle drvHandle, Udma_RingHandle ringHandle, uint16_t ringNum)
UDMA ring attach API. This API is used to attach to an already allocated and configured ring....
Udma_DrvHandle
struct Udma_DrvObjectInt * Udma_DrvHandle
UDMA driver handle.
Definition: udma_types.h:84
count
uint32_t count
Definition: tisci_rm_ra.h:6
Udma_ringGetElementCnt
uint32_t Udma_ringGetElementCnt(Udma_RingHandle ringHandle)
Returns the ring element count which is passed during ring alloc.
Udma_ringGetMode
uint32_t Udma_ringGetMode(Udma_RingHandle ringHandle)
Returns the ring mode which is configured during ring alloc.
Udma_ringGetReverseRingOcc
uint32_t Udma_ringGetReverseRingOcc(Udma_RingHandle ringHandle)
Returns the reverse ring occupancy.
UdmaRingPrms_init
void UdmaRingPrms_init(Udma_RingPrms *ringPrms)
Udma_RingPrms structure init function.
Udma_ringQueueRaw
int32_t Udma_ringQueueRaw(Udma_RingHandle ringHandle, uint64_t phyDescMem)
UDMA queue descriptor to a ring - raw version (Takes all physical pointers)
Udma_ringGetMemPtr
uint8_t * Udma_ringGetMemPtr(Udma_RingHandle ringHandle)
Returns the ring memory pointer which is passed during ring alloc.
Udma_ringFlushRaw
int32_t Udma_ringFlushRaw(Udma_RingHandle ringHandle, uint64_t *phyDescMem)
UDMA dequeue descriptor from a ring when UDMA channel is disabled - raw version (Takes all physical p...
Udma_ringGetWrIdx
uint32_t Udma_ringGetWrIdx(Udma_RingHandle ringHandle)
Returns the ring write index value.
Udma_ringGetNum
uint16_t Udma_ringGetNum(Udma_RingHandle ringHandle)
Returns the ring number allocated for this ring.
Udma_ringSetDoorBell
void Udma_ringSetDoorBell(Udma_RingHandle ringHandle, int32_t count)
UDMA ring API to set the doorbell in exposed/"RING" mode ring. This will commit the previously primed...
Udma_ringPrimeRead
void Udma_ringPrimeRead(Udma_RingHandle ringHandle, uint64_t *phyDescMem)
UDMA read descriptor from a exposed/"RING" mode ring - raw version (Reads physical pointers)....
Udma_ringDetach
int32_t Udma_ringDetach(Udma_RingHandle ringHandle)
UDMA detach ring API.
Udma_ringGetRdIdx
uint32_t Udma_ringGetRdIdx(Udma_RingHandle ringHandle)
Returns the ring read index value.
Udma_RingHandle
struct Udma_RingObjectInt * Udma_RingHandle
UDMA ring handle.
Definition: udma_types.h:90
Udma_ringAlloc
int32_t Udma_ringAlloc(Udma_DrvHandle drvHandle, Udma_RingHandle ringHandle, uint16_t ringNum, const Udma_RingPrms *ringPrms)
UDMA ring allocation and configuration API.
Udma_ringFree
int32_t Udma_ringFree(Udma_RingHandle ringHandle)
UDMA free ring.
Udma_ringGetForwardRingOcc
uint32_t Udma_ringGetForwardRingOcc(Udma_RingHandle ringHandle)
Returns the forward ring occupancy.