|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # w b6 [) [* c- f
- [code]EDMA sample test application
: W* \' T- y: H - /*
: x9 \/ M3 v$ v5 n - * edma_test.c
i6 R9 n# J4 v- q( ^" j+ n* C8 F( k - *8 k4 v$ N i9 Y8 y/ t& z/ d2 a* T
- * brief EDMA3 Test Application+ p" Y" B8 H& h1 f
- *
" @8 E; w' A, T+ g8 ?) n, N - * This file contains EDMA3 Test code.6 {8 l6 n- W* r0 @+ q' l- x/ G9 G
- *- f, g+ h: {* ^5 [. o& P
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
* W6 Q+ S2 E! o& A) ` - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT. ~! A, C; ~3 x0 M& R" e3 F
- * TO CHANGE.. |: i! A n% v+ {& b& N
- *
/ z3 R6 c7 J' C- i5 y+ V - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ P7 e+ y- W% |6 C6 n) ?1 H% l5 | - *
6 K1 Q3 } Q% b% r! O - * This program is free software; you can redistribute it and/or
# h6 m; T# y/ s - * modify it under the terms of the GNU General Public License as x/ i) u( M6 O- e
- * published by the Free Software Foundation version 2.! H n J1 ? U/ B
- *
3 V# O8 ?7 W# v( t/ w - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% T' B7 G6 @! P8 R - * kind, whether express or implied; without even the implied warranty, a+ I; K1 e' h0 e
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* i. R% r2 X; A% {* L: p( G
- * GNU General Public License for more details.
6 q3 o" A) P* _5 w z( ?4 k# o1 M - */
' S# [ N) w8 q8 ~
* F. \0 b- c: q8 Z. ^6 E4 R. e- #include <linux/module.h>
?; j4 a& [( x! x9 j1 L4 M - #include <linux/init.h>
0 ~) _8 L- s4 u! S4 ]' z; V/ L& d8 R: Y9 R - #include <linux/errno.h>7 h6 L7 g- e" n5 q9 r+ g d
- #include <linux/types.h>
9 ?1 J* z9 f) A: X; q) l - #include <linux/interrupt.h># s( P$ n; Y e+ O) {1 O0 u- p* F
- #include <asm/io.h>- ?2 y. h0 O9 V j1 s
- #include <linux/moduleparam.h>: S1 x. b& h. J- f
- #include <linux/sysctl.h>: }$ U) D3 a% R! l9 l3 v
- #include <linux/mm.h>& R) H' g4 t4 @8 \4 r) c& y; B
- #include <linux/dma-mapping.h>4 N( n% q2 ^* l7 R; h; b
( |) R' C9 W5 D% y( R7 U; w# e& d- #include <mach/memory.h>
8 F* a0 t1 d; N2 H - #include <mach/hardware.h>
5 X1 n6 D7 q- i0 k9 F6 T6 y - #include <mach/irqs.h>( k n0 y% G- J
- #include <asm/hardware/edma.h>
! E) E6 [) a+ Z - 1 Q% {2 T5 n- l% Q+ c6 Q' c! _' d
- #undef EDMA3_DEBUG# x" s M5 _# t, t
- /*#define EDMA3_DEBUG*/2 ]* K* W" } w
- 4 k/ }, \ Z6 u: B% |3 T5 d6 k
- #ifdef EDMA3_DEBUG) v5 y5 m, ?) A$ i3 j
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 _& b0 @. X% h- ~0 {9 Y
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)4 f i% a' f! t% t* T% }
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
9 y. S- v, y0 e& \ - #else
5 X; m2 X+ u% ]; V5 I - #define DMA_PRINTK( x... )
" I+ O5 c# H/ Z: x( D8 {1 e: ] - #define DMA_FN_IN; ]: k, h7 S5 G1 V6 E4 Z8 B) v
- #define DMA_FN_OUT
, u" g0 h$ T3 w% z - #endif3 U; C# t: o k
& ]# k, b( k% u Y; @& G- #define MAX_DMA_TRANSFER_IN_BYTES (32768)/ y3 |% Z; [$ e% o" Q
- #define STATIC_SHIFT 3% ^( ?3 z! h3 V; k2 K3 T+ Y4 Z
- #define TCINTEN_SHIFT 20
2 c1 Y0 A+ A+ t u- B& ~8 y - #define ITCINTEN_SHIFT 21
1 f+ R0 B k* c3 U, L0 l2 W; v - #define TCCHEN_SHIFT 22
# z2 U# R1 K# \- { - #define ITCCHEN_SHIFT 23
! b% b! Y8 [7 y - , D8 F3 }$ ^+ V, M
- static volatile int irqraised1 = 0;
3 Y- x+ n& T2 y: E: d - static volatile int irqraised2 = 0;+ u" ?' F6 b0 u/ Q
- * ~4 A: k- \7 d2 R1 W- y& o y
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- P! Y9 u1 R8 \ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ U% k! ^; }1 J7 L5 H" E
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 A0 t3 H" k% f5 E+ M+ z7 L# `4 l
$ I1 E B8 ]" i2 r% |3 d- dma_addr_t dmaphyssrc1 = 0;5 g% d& {: I2 P n, h" r2 x' Z" H
- dma_addr_t dmaphyssrc2 = 0;
2 K, c6 J4 L4 _8 M! R: J9 n& [ - dma_addr_t dmaphysdest1 = 0;/ j4 x; n3 s8 A( ^" O: K
- dma_addr_t dmaphysdest2 = 0;
$ S' z; {& U4 _! z6 ^ - + n2 \+ m+ c0 t8 G
- char *dmabufsrc1 = NULL;
6 ^% {0 x Z3 b) s4 G" m, j - char *dmabufsrc2 = NULL;3 M2 \. F; V& b2 V* i: z' C
- char *dmabufdest1 = NULL;" @! W: ?: |7 c2 p5 y. ]. z0 D
- char *dmabufdest2 = NULL;
, {, b1 `+ l( z. k
5 P* Q& V3 j9 V- static int acnt = 512;, m! E! K7 p4 [% A9 |
- static int bcnt = 8;; u3 u9 `: ]0 O/ H* E
- static int ccnt = 8;2 R+ l& i+ F9 q$ Z+ F5 M
) x+ [) ~6 W2 y- B- D! _- module_param(acnt, int, S_IRUGO);7 u t) a! Q& }9 B# p8 y9 e. x5 p. x
- module_param(bcnt, int, S_IRUGO);
4 u7 l; F8 |! G! z( z4 {! g- d - module_param(ccnt, int, S_IRUGO);
复制代码
?! X- G+ o3 m
1 k* N, f. ^1 [0 r6 { 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% l1 s. n8 \: Jarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。% R# U& E) W9 e/ t* V
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% A- f6 E9 s' C8 o; ^& Z: ^
, w$ i \& e) e3 v; @- G3 i4 S2 v2 P; Q9 W
|
|