|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 g! E, ^0 k# m4 p* S" o
- [code]EDMA sample test application( J0 J: F8 I* k9 @7 n6 e
- /*1 q+ G; W2 F$ R1 N
- * edma_test.c
) u! L1 o6 E5 N# l5 r4 ? - *
6 w) ^# W- K! u( ] |' l# C - * brief EDMA3 Test Application0 \* X9 ]0 ]8 N$ R' N8 M
- *
. S7 Z7 K, Z+ s- m! L1 B: H - * This file contains EDMA3 Test code.
2 ]4 E" |1 }4 d - *! M3 N2 J/ A9 {# V
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 c7 E/ b0 Q+ a - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ o4 x( |# U& h% ^3 s, H( z. {' v
- * TO CHANGE.5 I- W* x: b$ Y* f& Q. b* v" k
- *
5 \0 `" |4 b& A, w% D - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ H" D( n6 v7 m" B1 _* ~' s/ p
- *
* U. b" d j/ J1 [ - * This program is free software; you can redistribute it and/or0 p! |$ T+ k- V# T5 H' ~! }" p3 j
- * modify it under the terms of the GNU General Public License as
& n+ E) Z1 L4 y% [ - * published by the Free Software Foundation version 2.
3 x- u' G: B: Z- y - *
/ [% {! L7 R/ x/ P - * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 ]0 w! p7 ~5 Q0 v# k
- * kind, whether express or implied; without even the implied warranty1 M! o" Y4 t1 L
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, s/ k# G: Y+ A( [9 t1 T& M - * GNU General Public License for more details.
. b+ M7 ]# m5 n! F: z6 j0 N! ] - */
1 K J" t! j: J I - ) Z5 E2 a% K0 x n/ B0 t
- #include <linux/module.h>2 F6 ]. K ^1 f. Q6 o) L: h
- #include <linux/init.h>6 B, l* j0 J2 e7 i! q) M# a
- #include <linux/errno.h>
$ e3 w# B4 D1 R, V# R - #include <linux/types.h>, Y( d6 K& N8 {% O; _6 N
- #include <linux/interrupt.h>
/ O; I, `& l! f) g - #include <asm/io.h>
: N! m2 X% t# d, V( f - #include <linux/moduleparam.h>4 B1 C- q/ ]' g/ a/ u3 _2 ^* {
- #include <linux/sysctl.h>. P; ^$ q9 }( P: J8 J
- #include <linux/mm.h>
( o: ^$ c; D2 x' J3 ] - #include <linux/dma-mapping.h>
0 l+ L5 B# Z0 M5 t
5 J5 p! C: n* ]" c4 f7 \8 ]' e- #include <mach/memory.h>
) t5 k$ j! F. Q3 H7 C - #include <mach/hardware.h>: G+ N; e6 v# R/ ~; ~
- #include <mach/irqs.h>( m L: V+ M! y) K5 ?
- #include <asm/hardware/edma.h>
" N; x, \7 F4 t0 q! J- k
. @" u. a5 ?- b- #undef EDMA3_DEBUG
' E( a* n2 ?! k - /*#define EDMA3_DEBUG*/
7 I4 W- N- _1 L- j
, O* Z0 P& F8 j- #ifdef EDMA3_DEBUG
2 D7 ~" M% Y- p9 J- W - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 n) I" W, J- u5 V* a
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)2 n" t4 Y( P0 b+ s+ a" j( n
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* U2 D; H$ l% J% o: H& ~
- #else
1 |4 C) n! h& F0 e* x n - #define DMA_PRINTK( x... )/ K% S# s/ Q/ X- b+ T* Y, K
- #define DMA_FN_IN
, \! p1 Y! W9 V3 l8 [/ p; s' \4 J - #define DMA_FN_OUT8 V6 C/ E/ p2 ~: Y/ t
- #endif- \5 B0 q1 A+ R# J- w) t7 i1 V9 p
- ! {+ ^0 ]8 E2 O) V
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
9 }& }- Y. F( K% C; S Y2 k - #define STATIC_SHIFT 3
+ Z/ B: _0 {$ C5 F3 l" B- e" ` - #define TCINTEN_SHIFT 207 [4 K3 R" [( K0 j+ n5 h5 r0 W
- #define ITCINTEN_SHIFT 21" J) ?: k4 g2 Q7 Y7 D& F. |" w
- #define TCCHEN_SHIFT 22
% D2 _6 R6 o) u5 n7 b( H: I - #define ITCCHEN_SHIFT 23
5 W3 }' n" w9 w - # f: U6 u2 U3 h# J. u4 f: A7 w
- static volatile int irqraised1 = 0;
5 Z+ N" @. }/ w - static volatile int irqraised2 = 0;
' m4 B" B* C; C
5 t2 O. D9 b# J$ R l- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% w3 L/ n6 i- ]3 g7 q3 N2 O - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: w7 s; r( Q" `
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 A/ { B1 k0 ?) h( p - 1 x. A+ L7 w0 D. p T+ _: d6 d( F
- dma_addr_t dmaphyssrc1 = 0;( J D# u" {+ L
- dma_addr_t dmaphyssrc2 = 0;
% q9 x4 M" [9 D: H3 Q$ i: o/ [0 z - dma_addr_t dmaphysdest1 = 0;
! |2 z* z/ y; d- n) D - dma_addr_t dmaphysdest2 = 0;( S6 P( Z% v1 b S. y
- ' G, A( x# J- D9 S7 O+ K( i8 f" Q
- char *dmabufsrc1 = NULL;" g+ @3 a) w# c+ e9 P
- char *dmabufsrc2 = NULL;
6 r5 e, O7 Y% i0 U' O2 G8 d - char *dmabufdest1 = NULL;
7 @5 `# [; `' t/ j( m - char *dmabufdest2 = NULL;- u% W3 V) {$ X! l
% z; p% p( N" F4 g9 _9 D- static int acnt = 512;
/ p: H9 j% i) Q/ B! z; F3 ^* q2 B. d" k - static int bcnt = 8;
8 H0 V& S6 P8 X4 R) K z- J - static int ccnt = 8;! \4 U/ l: `8 z g
- 6 Y$ A% L N2 H5 G1 k: Z9 m
- module_param(acnt, int, S_IRUGO);8 {' f* v5 a1 ^6 M
- module_param(bcnt, int, S_IRUGO);8 O2 D- @7 A1 B |
- module_param(ccnt, int, S_IRUGO);
复制代码 % F8 a) ?0 Z6 |- V+ v7 j9 ]
# Q: C3 b" I% E
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用5 E' P/ @7 s! c \' _* z; F0 V
arm-none-linux-gnueabi-gcc -I /home/tl/omapl138/linux-3.3/arch/arm/include -I /home/tl/omapl138/linux-3.3/include EDMA3test.cpp -o EDMA3这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" `1 }- H n j( Y+ l. j 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
* F) O$ z# j) A2 ?, Q! ?8 G2 R# C" {- V
8 K* ~; q1 J+ }8 |( K |
|