|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
0 P1 A. l* P1 ]6 u+ Q h1 O- [code]EDMA sample test application
' i. P6 K% r) _8 d: i Y) l - /*
9 L9 [% G; w; s# t7 d5 U - * edma_test.c
) P- I5 X2 M( B i* {) ^ - *
: V, j9 ^& V$ n# q. M - * brief EDMA3 Test Application
8 @ d; m5 l! n# H8 Z - *8 M- D. A- E) }" x3 j8 |! `. W. o: V
- * This file contains EDMA3 Test code.6 ^! M) ^$ w1 S) x6 j5 L" H
- *
+ Z5 d) j: ^; h9 V! V0 Y - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! W) S' C) d5 h) N' h$ ]
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT* m! [) B! S, S% F: C+ v! x
- * TO CHANGE.6 c @6 v( E6 }1 n
- *1 `: `2 P. {" n+ l
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" @8 x ?: m6 S
- *' {! s' J( x1 o3 b H$ r) \
- * This program is free software; you can redistribute it and/or: N4 e3 }. K7 L9 r0 e5 T$ P) b2 N
- * modify it under the terms of the GNU General Public License as) \" E& Q7 N1 \& }* F) G
- * published by the Free Software Foundation version 2.9 t& e: Z0 H, P# L% L, _6 j
- *2 R2 N( M8 F+ u! z$ L7 c$ `+ g
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any7 i# q! r( n. Z
- * kind, whether express or implied; without even the implied warranty
& A5 }+ {( r/ f8 a# R8 l( I/ b - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 ?$ n; d% _* Y# M6 a - * GNU General Public License for more details.
+ l4 a* y2 f: h6 o' w8 Y/ \ - */; [) n6 m; w2 {, R' b1 s* t
7 ?, w" k3 ^% s5 X0 Y3 I- C- #include <linux/module.h>
/ {/ r7 P! u3 k Q& Q - #include <linux/init.h>$ x& k7 l7 K! a C7 P8 x! z
- #include <linux/errno.h>9 \0 E3 x# I0 Z) b9 O
- #include <linux/types.h>
' K. A+ n1 z7 f$ |* H7 q, G - #include <linux/interrupt.h>, k. w/ X3 @' [$ Y! U l" k' y$ C/ F
- #include <asm/io.h>
0 r: v: J4 l" n6 G1 |+ s& W4 n8 z3 Z - #include <linux/moduleparam.h>
\" s5 d& {. o9 e3 R- f4 { - #include <linux/sysctl.h>' y4 x+ E0 S8 x: S, c0 C e) D
- #include <linux/mm.h>
- X X( P( h0 G c - #include <linux/dma-mapping.h>
6 l( Z! n% P2 z( V/ e" r1 @. f - ! O E: x6 _- K1 B8 X" ]
- #include <mach/memory.h>0 z9 ^- y, C* ^4 H* V" R- ? K& F) a
- #include <mach/hardware.h>8 D$ y+ w# v& C: R) s% i
- #include <mach/irqs.h>
/ G5 g: H% n" K ]0 i - #include <asm/hardware/edma.h>$ `" ~$ O# W- E3 f1 _
2 Y% P% f8 ]* E* Y- #undef EDMA3_DEBUG% t$ e" D& q( \* ^! B% w
- /*#define EDMA3_DEBUG*/ P9 V X- o$ w" n' Q0 E4 ^
( s- `9 m. E3 ?+ ^4 i- #ifdef EDMA3_DEBUG
J9 M6 Q$ g0 }6 q$ ~; I3 S5 ~ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- B% S) O( j# `) ]) ?* b - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' H! `5 ?' k' n, y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
7 s4 [4 `7 f. M \ - #else
" |! I3 z$ M2 n# O' o& H R; z: R - #define DMA_PRINTK( x... )
- P2 Z# ?1 A2 @2 P9 h2 [ - #define DMA_FN_IN
6 I n& O5 v/ X - #define DMA_FN_OUT
( h j6 Y4 |2 Y- Q( i - #endif8 }0 W/ o7 B N+ B: E
- # y1 f( a I4 Q: `' m' ^
- #define MAX_DMA_TRANSFER_IN_BYTES (32768). N! D( P3 f- u0 S( x+ ]
- #define STATIC_SHIFT 3" | a* e) Z% [4 F" I, r
- #define TCINTEN_SHIFT 20" e* ?5 `& c' Z4 C. i
- #define ITCINTEN_SHIFT 21
. u5 f6 x. n- `- |4 o - #define TCCHEN_SHIFT 22
6 k6 N" t/ C6 t# v8 V& ?. ], q - #define ITCCHEN_SHIFT 23" m: C( F+ D5 y; u
- ) o+ c6 A2 e4 j
- static volatile int irqraised1 = 0;* J# k0 Y5 {) C3 I9 H0 }- C3 D
- static volatile int irqraised2 = 0;
$ Q$ E/ S% n3 a& E4 M
( J" P8 @7 H1 c; |) `; d- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 K# N) H! k! x - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 P$ m+ @& w Y2 @# u4 c - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 U; J4 }( e! v
3 b7 C" J& L/ B' ~8 Z8 ]- dma_addr_t dmaphyssrc1 = 0;6 W4 F0 l( o2 C/ Z
- dma_addr_t dmaphyssrc2 = 0;
- a8 z O" K S+ K( S+ G - dma_addr_t dmaphysdest1 = 0;
3 |$ D+ k% \9 x& {5 y+ f1 ?* S - dma_addr_t dmaphysdest2 = 0;
. p/ R2 F# g4 i& y; x - 9 _- Y9 B: y! }$ B% o
- char *dmabufsrc1 = NULL;
, `, g. t; ~' p- k - char *dmabufsrc2 = NULL;0 ~" J" ^) ~) j x$ A
- char *dmabufdest1 = NULL;
( j- a; _' O& g! o - char *dmabufdest2 = NULL;# t; p+ {; ?) F8 h5 @- y- F# a& h, F
- e- S! M% O+ @0 q- static int acnt = 512;# v; {2 I% s# P5 g* Z
- static int bcnt = 8;1 s1 c4 e, q% j! A7 q f
- static int ccnt = 8;- c4 |' } [0 k: \/ P, j8 @
- * X" Y5 z7 E& `3 z9 F5 A
- module_param(acnt, int, S_IRUGO);
: k/ l+ e g0 j, y/ G; Z - module_param(bcnt, int, S_IRUGO);$ F7 Z0 I7 B2 h/ k& [4 y
- module_param(ccnt, int, S_IRUGO);
复制代码 2 ]+ l* o* d; c5 D
# G# U- t# [' I( P! B5 ? E
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% a) c7 x! i* C- L) \, o& u
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ G' P! }9 k1 G. M8 _( j. ^/ F 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
7 h- T. G0 e2 u5 o7 K" C7 ?* b# D% J& {$ ?+ Y' c
+ b; e% H8 t- W* o: _" Q
|
|