OpenCores
URL https://opencores.org/ocsvn/1g_ethernet_dpi/1g_ethernet_dpi/trunk

Subversion Repositories 1g_ethernet_dpi

[/] [1g_ethernet_dpi/] [trunk/] [sw/] [dev/] [test_main/] [src/] [_hdl/] [bsp/] [libsrc/] [axidma_v9_0/] [src/] [xaxidma_bd.h] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 kuzmi4
/******************************************************************************
2
*
3
* Copyright (C) 2010 - 2015 Xilinx, Inc.  All rights reserved.
4
*
5
* Permission is hereby granted, free of charge, to any person obtaining a copy
6
* of this software and associated documentation files (the "Software"), to deal
7
* in the Software without restriction, including without limitation the rights
8
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
* copies of the Software, and to permit persons to whom the Software is
10
* furnished to do so, subject to the following conditions:
11
*
12
* The above copyright notice and this permission notice shall be included in
13
* all copies or substantial portions of the Software.
14
*
15
* Use of the Software is limited solely to applications:
16
* (a) running on a Xilinx device, or
17
* (b) that interact with a Xilinx device through a bus or interconnect.
18
*
19
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22
* XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24
* OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
* SOFTWARE.
26
*
27
* Except as contained in this notice, the name of the Xilinx shall not be used
28
* in advertising or otherwise to promote the sale, use or other dealings in
29
* this Software without prior written authorization from Xilinx.
30
*
31
******************************************************************************/
32
/*****************************************************************************/
33
/**
34
 *
35
 * @file xaxidma_bd.h
36
* @addtogroup axidma_v9_0
37
* @{
38
 *
39
 * Buffer descriptor (BD) management API.
40
 *
41
 * <b> Buffer Descriptors </b>
42
 *
43
 * A BD defines a DMA transaction (see "Transaction" section in xaxidma.h).
44
 * All accesses to a BD go through this set of API.
45
 *
46
 * The XAxiDma_Bd structure defines a BD. The first XAXIDMA_BD_HW_NUM_BYTES
47
 * are shared between hardware and software.
48
 *
49
 * <b> Actual Transfer Length </b>
50
 *
51
 * The actual transfer length for receive could be smaller than the requested
52
 * transfer length. The hardware sets the actual transfer length in the
53
 * completed BD. The API to retrieve the actual transfer length is
54
 * XAxiDma_GetActualLength().
55
 *
56
 * <b> User IP words </b>
57
 *
58
 * There are 5 user IP words in each BD.
59
 *
60
 * If hardware does not have the StsCntrl stream built in, then these words
61
 * are not usable. Retrieving these words get a NULL pointer and setting
62
 * these words results an error.
63
 *
64
 * <b> Performance </b>
65
 *
66
 * BDs are typically in a non-cached memory space. Reducing the number of
67
 * I/O operations to BDs can improve overall performance of the DMA channel.
68
 *
69
 * <pre>
70
 * MODIFICATION HISTORY:
71
 *
72
 * Ver   Who  Date     Changes
73
 * ----- ---- -------- ------------------------------------------------------
74
 * 1.00a jz   05/18/10 First release
75
 * 2.00a jz   08/10/10 Second release, added in xaxidma_g.c, xaxidma_sinit.c,
76
 *                     updated tcl file, added xaxidma_porting_guide.h
77
 * 3.00a jz   11/22/10 Support IP core parameters change
78
 * 5.00a srt  08/25/11 Changed Cache Macros to have a common API for Zynq
79
 *                         and Microblaze.
80
 * 6.00a srt  01/24/12 Added APIs to support Multi-Channel DMA:
81
 *                      XAxiDma_BdSetTId()
82
 *                      XAxiDma_BdGetTId()
83
 *                      XAxiDma_BdSetTDest()
84
 *                      XAxiDma_BdGetTDest()
85
 *                      XAxiDma_BdSetTUser()
86
 *                      XAxiDma_BdGetTUser()
87
 *                      XAxiDma_BdSetARCache()
88
 *                      XAxiDma_BdGetARCache()
89
 *                      XAxiDma_BdSetARUser()
90
 *                      XAxiDma_BdGetARUser()
91
 *                      XAxiDma_BdSetStride()
92
 *                      XAxiDma_BdGetStride()
93
 *                      XAxiDma_BdSetVSize()
94
 *                      XAxiDma_BdGetVSize()
95
 *                      - Changed APIs
96
 *                      XAxiDma_BdGetActualLength(BdPtr, LengthMask)
97
 *                      XAxiDma_BdGetLength(BdPtr, LengthMask)
98
 *                      XAxiDma_BdSetLength(XAxiDma_Bd* BdPtr,
99
 *                                      u32 LenBytes, u32 LengthMask)
100
 * 7.01a srt  10/26/12  Changed the logic of MCDMA BD fields Set APIs, to
101
 *                      clear the field first and set it.
102
 * 8.0   srt  01/29/14 Added support for Micro DMA Mode.
103
 *
104
 * </pre>
105
 *****************************************************************************/
106
 
107
#ifndef XAXIDMA_BD_H_    /* To prevent circular inclusions */
108
#define XAXIDMA_BD_H_
109
 
110
#ifdef __cplusplus
111
extern "C" {
112
#endif
113
 
114
/***************************** Include Files *********************************/
115
 
116
#include "xaxidma_hw.h"
117
#include "xstatus.h"
118
#include "xdebug.h"
119
#include "xil_cache.h"
120
 
121
#ifdef __MICROBLAZE__
122
#include "xenv.h"
123
#else
124
#include <string.h>
125
#endif
126
 
127
/************************** Constant Definitions *****************************/
128
 
129
/**************************** Type Definitions *******************************/
130
 
131
/**
132
 * The XAxiDma_Bd is the type for a buffer descriptor (BD).
133
 */
134
 
135
typedef UINTPTR XAxiDma_Bd[XAXIDMA_BD_NUM_WORDS];
136
 
137
 
138
/***************** Macros (Inline Functions) Definitions *********************/
139
 
140
/******************************************************************************
141
 * Define methods to flush and invalidate cache for BDs should they be
142
 * located in cached memory.
143
 *****************************************************************************/
144
#ifdef __aarch64__
145
#define XAXIDMA_CACHE_FLUSH(BdPtr)
146
#define XAXIDMA_CACHE_INVALIDATE(BdPtr)
147
#else
148
#define XAXIDMA_CACHE_FLUSH(BdPtr) \
149
        Xil_DCacheFlushRange((UINTPTR)(BdPtr), XAXIDMA_BD_HW_NUM_BYTES)
150
 
151
#define XAXIDMA_CACHE_INVALIDATE(BdPtr) \
152
        Xil_DCacheInvalidateRange((UINTPTR)(BdPtr), XAXIDMA_BD_HW_NUM_BYTES)
153
#endif
154
 
155
/*****************************************************************************/
156
/**
157
*
158
* Read the given Buffer Descriptor word.
159
*
160
* @param        BaseAddress is the base address of the BD to read
161
* @param        Offset is the word offset to be read
162
*
163
* @return       The 32-bit value of the field
164
*
165
* @note
166
*               C-style signature:
167
*               u32 XAxiDma_BdRead(u32 BaseAddress, u32 Offset)
168
*
169
******************************************************************************/
170
#define XAxiDma_BdRead(BaseAddress, Offset)                             \
171
        (*(u32 *)((UINTPTR)((void *)(BaseAddress)) + (u32)(Offset)))
172
 
173
 
174
/*****************************************************************************/
175
/**
176
*
177
* Write the given Buffer Descriptor word.
178
*
179
* @param        BaseAddress is the base address of the BD to write
180
* @param        Offset is the word offset to be written
181
* @param        Data is the 32-bit value to write to the field
182
*
183
* @return       None.
184
*
185
* @note
186
*               C-style signature:
187
*               void XAxiDma_BdWrite(u32 BaseAddress, u32 RegOffset, u32 Data)
188
*
189
******************************************************************************/
190
#define XAxiDma_BdWrite(BaseAddress, Offset, Data)                      \
191
        (*(u32 *)((UINTPTR)(void *)(BaseAddress) + (u32)(Offset))) = (u32)(Data)
192
 
193
 
194
/*****************************************************************************/
195
/**
196
 * Zero out BD specific fields. BD fields that are for the BD ring or for the
197
 * system hardware build information are not touched.
198
 *
199
 * @param       BdPtr is the BD to operate on
200
 *
201
 * @return      None
202
 *
203
 * @note
204
 *              C-style signature:
205
 *              void XAxiDma_BdClear(XAxiDma_Bd* BdPtr)
206
 *
207
 *****************************************************************************/
208
#define XAxiDma_BdClear(BdPtr)                    \
209
  memset((void *)(((UINTPTR)(BdPtr)) + XAXIDMA_BD_START_CLEAR), 0, \
210
    XAXIDMA_BD_BYTES_TO_CLEAR)
211
 
212
/*****************************************************************************/
213
/**
214
 * Get the control bits for the BD
215
 *
216
 * @param       BdPtr is the BD to operate on
217
 *
218
 * @return      The bit mask for the control of the BD
219
 *
220
 * @note
221
 *              C-style signature:
222
 *              u32 XAxiDma_BdGetCtrl(XAxiDma_Bd* BdPtr)
223
 *
224
 *****************************************************************************/
225
#define XAxiDma_BdGetCtrl(BdPtr)                                \
226
                (XAxiDma_BdRead((BdPtr), XAXIDMA_BD_CTRL_LEN_OFFSET)    \
227
                & XAXIDMA_BD_CTRL_ALL_MASK)
228
/*****************************************************************************/
229
/**
230
 * Retrieve the status of a BD
231
 *
232
 * @param       BdPtr is the BD to operate on
233
 *
234
 * @return      Word at offset XAXIDMA_BD_DMASR_OFFSET. Use XAXIDMA_BD_STS_***
235
 *              values defined in xaxidma_hw.h to interpret the returned value
236
 *
237
 * @note
238
 *              C-style signature:
239
 *              u32 XAxiDma_BdGetSts(XAxiDma_Bd* BdPtr)
240
 *
241
 *****************************************************************************/
242
#define XAxiDma_BdGetSts(BdPtr)              \
243
        (XAxiDma_BdRead((BdPtr), XAXIDMA_BD_STS_OFFSET) & \
244
                XAXIDMA_BD_STS_ALL_MASK)
245
/*****************************************************************************/
246
/**
247
 * Retrieve the length field value from the given BD.  The returned value is
248
 * the same as what was written with XAxiDma_BdSetLength(). Note that in the
249
 * this value does not reflect the real length of received data.
250
 * See the comments of XAxiDma_BdSetLength() for more details. To obtain the
251
 * actual transfer length, use XAxiDma_BdGetActualLength().
252
 *
253
 * @param       BdPtr is the BD to operate on.
254
 * @param       LengthMask is the Maximum Transfer Length.
255
 *
256
 * @return      The length value set in the BD.
257
 *
258
 * @note
259
 *              C-style signature:
260
 *              u32 XAxiDma_BdGetLength(XAxiDma_Bd* BdPtr)
261
 *
262
 *****************************************************************************/
263
#define XAxiDma_BdGetLength(BdPtr, LengthMask)                \
264
        (XAxiDma_BdRead((BdPtr), XAXIDMA_BD_CTRL_LEN_OFFSET) & \
265
                LengthMask)
266
 
267
 
268
/*****************************************************************************/
269
/**
270
 * Set the ID field of the given BD. The ID is an arbitrary piece of data the
271
 * application can associate with a specific BD.
272
 *
273
 * @param       BdPtr is the BD to operate on
274
 * @param       Id is a 32 bit quantity to set in the BD
275
 *
276
 * @return      None
277
 *
278
 * @note
279
 *              C-style signature:
280
 *              void XAxiDma_BdSetId(XAxiDma_Bd* BdPtr, void Id)
281
 *
282
 *****************************************************************************/
283
#define XAxiDma_BdSetId(BdPtr, Id)                                      \
284
        (XAxiDma_BdWrite((BdPtr), XAXIDMA_BD_ID_OFFSET, (u32)(Id)))
285
 
286
 
287
/*****************************************************************************/
288
/**
289
 * Retrieve the ID field of the given BD previously set with XAxiDma_BdSetId.
290
 *
291
 * @param       BdPtr is the BD to operate on
292
 *
293
 * @return      None
294
 *
295
 * @note
296
 *              C-style signature:
297
 *              u32 XAxiDma_BdGetId(XAxiDma_Bd* BdPtr)
298
 *
299
 *****************************************************************************/
300
#define XAxiDma_BdGetId(BdPtr) (XAxiDma_BdRead((BdPtr), XAXIDMA_BD_ID_OFFSET))
301
 
302
/*****************************************************************************/
303
/**
304
 * Get the BD's buffer address
305
 *
306
 * @param       BdPtr is the BD to operate on
307
 *
308
 * @return      None
309
 *
310
 * @note
311
 *              C-style signature:
312
 *              u32 XAxiDma_BdGetBufAddr(XAxiDma_Bd* BdPtr)
313
 *
314
 *****************************************************************************/
315
#define XAxiDma_BdGetBufAddr(BdPtr)                     \
316
        (XAxiDma_BdRead((BdPtr), XAXIDMA_BD_BUFA_OFFSET))
317
 
318
/*****************************************************************************/
319
/**
320
 * Check whether a BD has completed in hardware. This BD has been submitted
321
 * to hardware. The application can use this function to poll for the
322
 * completion of the BD.
323
 *
324
 * This function may not work if the BD is in cached memory.
325
 *
326
 * @param       BdPtr is the BD to check on
327
 *
328
 * @return
329
 *              - 0 if not complete
330
 *              - XAXIDMA_BD_STS_COMPLETE_MASK if completed, may contain
331
 *              XAXIDMA_BD_STS_*_ERR_MASK bits.
332
 *
333
 * @note
334
 *              C-style signature:
335
 *              int XAxiDma_BdHwCompleted(XAxiDma_Bd* BdPtr)
336
 *
337
 *****************************************************************************/
338
#define XAxiDma_BdHwCompleted(BdPtr)                     \
339
        (XAxiDma_BdRead((BdPtr), XAXIDMA_BD_STS_OFFSET) & \
340
                XAXIDMA_BD_STS_COMPLETE_MASK)
341
 
342
/*****************************************************************************/
343
/**
344
 * Get the actual transfer length of a BD. The BD has completed in hw.
345
 *
346
 * This function may not work if the BD is in cached memory.
347
 *
348
 * @param       BdPtr is the BD to check on
349
 * @param       LengthMask is the Maximum Transfer Length.
350
 *
351
 * @return      None
352
 *
353
 * @note
354
 *              C-style signature:
355
 *              int XAxiDma_BdGetActualLength(XAxiDma_Bd* BdPtr)
356
 *
357
 *****************************************************************************/
358
#define XAxiDma_BdGetActualLength(BdPtr, LengthMask)      \
359
        (XAxiDma_BdRead((BdPtr), XAXIDMA_BD_STS_OFFSET) & \
360
                LengthMask)
361
 
362
/*****************************************************************************/
363
/**
364
 * Set the TID field of the TX BD.
365
 * Provides a stream identifier and can be used to differentiate between
366
 * multiple streams of data that are being transferred across the same
367
 * interface.
368
 *
369
 * @param       BdPtr is the BD to operate on
370
 * @param       TId is a 8 bit quantity to set in the BD
371
 *
372
 * @return      None
373
 *
374
 * @note
375
 *              C-style signature:
376
 *              void XAxiDma_BdSetTId(XAxiDma_Bd* BdPtr, void TId)
377
 *
378
 *****************************************************************************/
379
#define XAxiDma_BdSetTId(BdPtr, TId) \
380
{ \
381
        u32 val; \
382
        val = (XAxiDma_BdRead((BdPtr), XAXIDMA_BD_MCCTL_OFFSET) & \
383
                ~XAXIDMA_BD_TID_FIELD_MASK); \
384
        val |= ((u32)(TId) << XAXIDMA_BD_TID_FIELD_SHIFT); \
385
        XAxiDma_BdWrite((BdPtr), XAXIDMA_BD_MCCTL_OFFSET, val); \
386
}
387
 
388
/*****************************************************************************/
389
/**
390
 * Retrieve the TID field of the RX BD previously set with XAxiDma_BdSetTId.
391
 *
392
 * @param       BdPtr is the BD to operate on
393
 *
394
 * @return      None
395
 *
396
 * @note
397
 *              C-style signature:
398
 *              u32 XAxiDma_BdGetTId(XAxiDma_Bd* BdPtr)
399
 *
400
 *****************************************************************************/
401
#define XAxiDma_BdGetTId(BdPtr) \
402
        ((XAxiDma_BdRead((BdPtr), XAXIDMA_BD_STS_OFFSET)) &  \
403
                XAXIDMA_BD_TID_FIELD_MASK)
404
 
405
/*****************************************************************************/
406
/**
407
 * Set the TDEST field of the TX BD.
408
 * Provides coarse routing information for the data stream.
409
 *
410
 * @param       BdPtr is the BD to operate on
411
 * @param       TDest is a 8 bit quantity to set in the BD
412
 *
413
 * @return      None
414
 *
415
 * @note
416
 *              C-style signature:
417
 *              void XAxiDma_BdSetTDest(XAxiDma_Bd* BdPtr, void TDest)
418
 *
419
 *****************************************************************************/
420
#define XAxiDma_BdSetTDest(BdPtr, TDest) \
421
{ \
422
        u32 val; \
423
        val = (XAxiDma_BdRead((BdPtr), XAXIDMA_BD_MCCTL_OFFSET) & \
424
                ~XAXIDMA_BD_TDEST_FIELD_MASK); \
425
        val |= ((u32)(TDest) << XAXIDMA_BD_TDEST_FIELD_SHIFT); \
426
        XAxiDma_BdWrite((BdPtr), XAXIDMA_BD_MCCTL_OFFSET, val); \
427
}
428
 
429
/*****************************************************************************/
430
/**
431
 * Retrieve the TDest field of the RX BD previously set with i
432
 * XAxiDma_BdSetTDest.
433
 *
434
 * @param       BdPtr is the BD to operate on
435
 *
436
 * @return      None
437
 *
438
 * @note
439
 *              C-style signature:
440
 *              u32 XAxiDma_BdGetTDest(XAxiDma_Bd* BdPtr)
441
 *
442
 *****************************************************************************/
443
#define XAxiDma_BdGetTDest(BdPtr) \
444
        ((XAxiDma_BdRead((BdPtr), XAXIDMA_BD_STS_OFFSET)) &  \
445
                XAXIDMA_BD_TDEST_FIELD_MASK)
446
 
447
/*****************************************************************************/
448
/**
449
 * Set the TUSER field of the TX BD.
450
 * User defined sideband signaling.
451
 *
452
 * @param       BdPtr is the BD to operate on
453
 * @param       TUser is a 8 bit quantity to set in the BD
454
 *
455
 * @return      None
456
 *
457
 * @note
458
 *              C-style signature:
459
 *              void XAxiDma_BdSetTUser(XAxiDma_Bd* BdPtr, void TUser)
460
 *
461
 *****************************************************************************/
462
#define XAxiDma_BdSetTUser(BdPtr, TUser)        \
463
{ \
464
        u32 val; \
465
        val = (XAxiDma_BdRead((BdPtr), XAXIDMA_BD_MCCTL_OFFSET) & \
466
                ~XAXIDMA_BD_TUSER_FIELD_MASK); \
467
        val |= ((u32)(TUser) << XAXIDMA_BD_TUSER_FIELD_SHIFT); \
468
        XAxiDma_BdWrite((BdPtr), XAXIDMA_BD_MCCTL_OFFSET, val); \
469
}
470
 
471
/*****************************************************************************/
472
/**
473
 * Retrieve the TUSER field of the RX BD previously set with
474
 * XAxiDma_BdSetTUser.
475
 *
476
 * @param       BdPtr is the BD to operate on
477
 *
478
 * @return      None
479
 *
480
 * @note
481
 *              C-style signature:
482
 *              u32 XAxiDma_BdGetTUser(XAxiDma_Bd* BdPtr)
483
 *
484
 *****************************************************************************/
485
#define XAxiDma_BdGetTUser(BdPtr) \
486
        ((XAxiDma_BdRead((BdPtr), XAXIDMA_BD_STS_OFFSET)) &  \
487
                XAXIDMA_BD_TUSER_FIELD_MASK)
488
 
489
/*****************************************************************************/
490
/**
491
 * Set the ARCACHE field of the given BD.
492
 * This signal provides additional information about the cacheable
493
 * characteristics of the transfer.
494
 *
495
 * @param       BdPtr is the BD to operate on
496
 * @param       ARCache is a 8 bit quantity to set in the BD
497
 *
498
 * @return      None
499
 *
500
 * @note
501
 *              C-style signature:
502
 *              void XAxiDma_BdSetARCache(XAxiDma_Bd* BdPtr, void ARCache)
503
 *
504
 *****************************************************************************/
505
#define XAxiDma_BdSetARCache(BdPtr, ARCache) \
506
{ \
507
        u32 val; \
508
        val = (XAxiDma_BdRead((BdPtr), XAXIDMA_BD_MCCTL_OFFSET) & \
509
                ~XAXIDMA_BD_ARCACHE_FIELD_MASK); \
510
        val |= ((u32)(ARCache) << XAXIDMA_BD_ARCACHE_FIELD_SHIFT); \
511
        XAxiDma_BdWrite((BdPtr), XAXIDMA_BD_MCCTL_OFFSET, val); \
512
}
513
 
514
/*****************************************************************************/
515
/**
516
 * Retrieve the ARCACHE field of the given BD previously set with
517
 * XAxiDma_BdSetARCache.
518
 *
519
 * @param       BdPtr is the BD to operate on
520
 *
521
 * @return      None
522
 *
523
 * @note
524
 *              C-style signature:
525
 *              u32 XAxiDma_BdGetARCache(XAxiDma_Bd* BdPtr)
526
 *
527
 *****************************************************************************/
528
#define XAxiDma_BdGetARCache(BdPtr) \
529
        ((XAxiDma_BdRead((BdPtr), XAXIDMA_BD_MCCTL_OFFSET)) &  \
530
                XAXIDMA_BD_ARCACHE_FIELD_MASK)
531
 
532
 
533
/*****************************************************************************/
534
/**
535
 * Set the ARUSER field of the given BD.
536
 * Sideband signals used for user defined information.
537
 *
538
 * @param       BdPtr is the BD to operate on
539
 * @param       ARUser is a 8 bit quantity to set in the BD
540
 *
541
 * @return      None
542
 *
543
 * @note
544
 *              C-style signature:
545
 *              void XAxiDma_BdSetARUser(XAxiDma_Bd* BdPtr, void ARUser)
546
 *
547
 *****************************************************************************/
548
#define XAxiDma_BdSetARUser(BdPtr, ARUser) \
549
{ \
550
        u32 val; \
551
        val = (XAxiDma_BdRead((BdPtr), XAXIDMA_BD_MCCTL_OFFSET) & \
552
                ~XAXIDMA_BD_ARUSER_FIELD_MASK); \
553
        val |= ((u32)(ARUser) << XAXIDMA_BD_ARUSER_FIELD_SHIFT); \
554
        XAxiDma_BdWrite((BdPtr), XAXIDMA_BD_MCCTL_OFFSET, val); \
555
}
556
 
557
 
558
/*****************************************************************************/
559
/**
560
 * Retrieve the ARUSER field of the given BD previously set with
561
 * XAxiDma_BdSetARUser.
562
 *
563
 * @param       BdPtr is the BD to operate on
564
 *
565
 * @return      None
566
 *
567
 * @note
568
 *              C-style signature:
569
 *              u32 XAxiDma_BdGetARUser(XAxiDma_Bd* BdPtr)
570
 *
571
 *****************************************************************************/
572
#define XAxiDma_BdGetARUser(BdPtr) \
573
        ((XAxiDma_BdRead((BdPtr), XAXIDMA_BD_MCCTL_OFFSET)) &  \
574
                XAXIDMA_BD_ARUSER_FIELD_MASK)
575
 
576
/*****************************************************************************/
577
/**
578
 * Set the STRIDE field of the given BD.
579
 * It is the address distance between the first address of successive
580
 * horizontal reads.
581
 *
582
 * @param       BdPtr is the BD to operate on
583
 * @param       Stride is a 32 bit quantity to set in the BD
584
 *
585
 * @return      None
586
 *
587
 * @note
588
 *              C-style signature:
589
 *              void XAxiDma_BdSetStride(XAxiDma_Bd* BdPtr, void Stride)
590
 *
591
 *****************************************************************************/
592
#define XAxiDma_BdSetStride(BdPtr, Stride) \
593
{ \
594
        u32 val; \
595
        val = (XAxiDma_BdRead((BdPtr), XAXIDMA_BD_STRIDE_VSIZE_OFFSET) & \
596
                ~XAXIDMA_BD_STRIDE_FIELD_MASK); \
597
        val |= ((u32)(Stride) << XAXIDMA_BD_STRIDE_FIELD_SHIFT); \
598
        XAxiDma_BdWrite((BdPtr), XAXIDMA_BD_STRIDE_VSIZE_OFFSET, val); \
599
}
600
 
601
/*****************************************************************************/
602
/**
603
 * Retrieve the STRIDE field of the given BD previously set with
604
 * XAxiDma_BdSetStride.
605
 *
606
 * @param       BdPtr is the BD to operate on
607
 *
608
 * @return      None
609
 *
610
 * @note
611
 *              C-style signature:
612
 *              u32 XAxiDma_BdGetStride(XAxiDma_Bd* BdPtr)
613
 *
614
 *****************************************************************************/
615
#define XAxiDma_BdGetStride(BdPtr) \
616
        ((XAxiDma_BdRead((BdPtr), XAXIDMA_BD_STRIDE_VSIZE_OFFSET)) &  \
617
                XAXIDMA_BD_STRIDE_FIELD_MASK)
618
 
619
/*****************************************************************************/
620
/**
621
 * Set the VSIZE field of the given BD.
622
 * Number of horizontal lines for strided access.
623
 *
624
 * @param       BdPtr is the BD to operate on
625
 * @param       VSize is a 32 bit quantity to set in the BD
626
 *
627
 * @return      None
628
 *
629
 * @note
630
 *              C-style signature:
631
 *              void XAxiDma_BdSetVSize(XAxiDma_Bd* BdPtr, void VSize)
632
 *
633
 *****************************************************************************/
634
#define XAxiDma_BdSetVSize(BdPtr, VSize) \
635
{ \
636
        u32 val; \
637
        val = (XAxiDma_BdRead((BdPtr), XAXIDMA_BD_STRIDE_VSIZE_OFFSET) & \
638
                ~XAXIDMA_BD_VSIZE_FIELD_MASK); \
639
        val |= ((u32)(VSize) << XAXIDMA_BD_VSIZE_FIELD_SHIFT); \
640
        XAxiDma_BdWrite((BdPtr), XAXIDMA_BD_STRIDE_VSIZE_OFFSET, val); \
641
}
642
 
643
/*****************************************************************************/
644
/**
645
 * Retrieve the STRIDE field of the given BD previously set with
646
 * XAxiDma_BdSetVSize.
647
 *
648
 * @param       BdPtr is the BD to operate on
649
 *
650
 * @return      None
651
 *
652
 * @note
653
 *              C-style signature:
654
 *              u32 XAxiDma_BdGetVSize(XAxiDma_Bd* BdPtr)
655
 *
656
 *****************************************************************************/
657
#define XAxiDma_BdGetVSize(BdPtr) \
658
        ((XAxiDma_BdRead((BdPtr), XAXIDMA_BD_STRIDE_VSIZE_OFFSET)) &  \
659
                XAXIDMA_BD_VSIZE_FIELD_MASK)
660
 
661
/*****************************************************************************/
662
 
663
/************************** Function Prototypes ******************************/
664
 
665
int XAxiDma_BdSetLength(XAxiDma_Bd* BdPtr, u32 LenBytes, u32 LengthMask);
666
u32 XAxiDma_BdSetBufAddr(XAxiDma_Bd* BdPtr, UINTPTR Addr);
667
u32 XAxiDma_BdSetBufAddrMicroMode(XAxiDma_Bd* BdPtr, UINTPTR Addr);
668
int XAxiDma_BdSetAppWord(XAxiDma_Bd * BdPtr, int Offset, u32 Word);
669
u32 XAxiDma_BdGetAppWord(XAxiDma_Bd * BdPtr, int Offset, int *Valid);
670
void XAxiDma_BdSetCtrl(XAxiDma_Bd *BdPtr, u32 Data);
671
 
672
/* Debug utility
673
 */
674
void XAxiDma_DumpBd(XAxiDma_Bd* BdPtr);
675
 
676
#ifdef __cplusplus
677
}
678
#endif
679
 
680
#endif /* end of protection macro */
681
/** @} */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.