|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! l8 x0 b7 w: m! @. b- [code]EDMA sample test application
+ O. W& ]+ G) \5 s! k - /*
# Q8 Z- L/ X4 T, D - * edma_test.c
6 |( o# m% ?1 K' O; Y: _ - *
& A5 Y2 p7 \! m5 V% ^3 m/ ~ - * brief EDMA3 Test Application
5 ]) _7 Q4 K- g; ~7 d) h* h' @5 J5 o$ } - *2 q: T; o& D8 b" `# K* [5 M8 C3 l
- * This file contains EDMA3 Test code.
" h% S4 U. f7 R4 y - * Y( @+ X. X' [# K7 [
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE5 ]& s: h$ h0 m6 A5 m( R
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
w% I- a0 ~" j- J8 N+ i, g - * TO CHANGE.
3 {7 G9 r8 R% E: Q - *
( o& M7 u7 P, H - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! z" \( [& ~& q$ H# e% M! Z/ j
- *
3 ]/ _3 k. h( c - * This program is free software; you can redistribute it and/or4 B& X. ?5 Q) @0 b. [* L. k5 j
- * modify it under the terms of the GNU General Public License as3 Y! A) t1 w( F- }9 ~ y
- * published by the Free Software Foundation version 2.
$ `" I; m$ u' F) a A0 M - *5 F1 g! C1 k& `# O; f+ f$ n7 D
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 K: r$ ?+ K0 D, ^
- * kind, whether express or implied; without even the implied warranty
% d5 ~/ x0 Z5 h0 a5 u! p - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" k3 i- o( H: C1 E - * GNU General Public License for more details.
' }. U: g+ R/ r6 O2 P4 I - */
& J: l$ y" H; ~; O
6 w: {+ c" [1 Q. s- #include <linux/module.h>
" e' z* i4 m7 o2 t& `# {1 e0 ]) E0 G - #include <linux/init.h>6 u+ g4 C* s7 J) B$ y- O5 j* f
- #include <linux/errno.h>
. `- ?/ a0 b/ h" i# ]% q! c8 l - #include <linux/types.h>! J+ B, x$ n/ z! W! w( W
- #include <linux/interrupt.h>
3 f. ]8 y2 i4 i; i - #include <asm/io.h>
9 {% n5 k5 r4 P8 Q4 E( M0 o' e; F - #include <linux/moduleparam.h>
& E- C) c w. `* m; }2 F - #include <linux/sysctl.h>
. R6 g8 W& b& v2 p$ `& y1 B - #include <linux/mm.h>; x) g( C4 x+ g$ h, _+ z- K+ o
- #include <linux/dma-mapping.h>& f' o3 o5 s" o( w3 R) _
9 P$ h) J! x6 A0 {+ R- #include <mach/memory.h>* u, h! N. P6 m7 x- [* m, L
- #include <mach/hardware.h>9 c. _0 b/ g& F6 q; W7 S7 R
- #include <mach/irqs.h>" s0 G3 L0 Z9 |! v, ^5 a: J
- #include <asm/hardware/edma.h>
' n: t9 e! T' o2 Q& N: W9 y, I) b - % c8 q* z6 _5 h4 h+ J- f9 O
- #undef EDMA3_DEBUG
' j. s3 M# P$ K, Q' _, v$ b: | - /*#define EDMA3_DEBUG*/
1 `7 Q- w( z7 b
, m! I' _* z# j7 a% E- #ifdef EDMA3_DEBUG
7 \$ |8 {. t6 q3 D4 E+ r - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
3 ` Z) ^4 e. g* e4 Z - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# ~4 [7 e# q" ]- U3 E - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); u) M$ H' s9 B' Q( u; T
- #else0 H2 G9 y6 N% e4 e
- #define DMA_PRINTK( x... )
) S! N- B- `+ p$ }( Y! ? - #define DMA_FN_IN' H* { q; S6 b# H9 L9 Z
- #define DMA_FN_OUT
! x3 d& F1 @7 K Z. A - #endif
! v5 V q* i+ v0 d4 _* y* c' t0 T - 9 y$ ^' v3 o4 O2 z* I. N m
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( r; q1 L9 n! @2 x e0 [6 N( Z( i1 G
- #define STATIC_SHIFT 3; S2 a% T. Y% {& @5 [
- #define TCINTEN_SHIFT 20
- a4 c0 ]9 I% K - #define ITCINTEN_SHIFT 21; g6 x& q% i) Y3 w0 r! V( B
- #define TCCHEN_SHIFT 22
9 L3 A* S" F7 h) p @ - #define ITCCHEN_SHIFT 23/ v6 v7 M# m9 A4 n5 y, ^* N
8 ~8 l: f1 P1 w, @' q8 g, v- static volatile int irqraised1 = 0;
' i. r! O8 ]1 s+ Y - static volatile int irqraised2 = 0;$ Z2 ^+ G9 y. ]# f1 l0 d; O9 E2 |
& ]! a% L, z" J! S- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 q: a# m i" F% o3 G
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 d3 D M: O+ p( Z0 K4 K% F: }& ] - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( f; b) z: A8 k9 ?) d0 j/ Q
- ; N8 b9 i4 M* \) x4 }, T$ p
- dma_addr_t dmaphyssrc1 = 0;
! q U( c* |/ O2 M/ C$ K - dma_addr_t dmaphyssrc2 = 0;! p' @6 H. {* D, r
- dma_addr_t dmaphysdest1 = 0;" \( T' P& T; }8 J, H+ O! ]
- dma_addr_t dmaphysdest2 = 0;
" u2 }& |' ^1 s9 r( {, h& r - 5 \6 s5 H7 I/ o
- char *dmabufsrc1 = NULL;( q# D2 s/ R; Y2 `; k: h+ o( [; y
- char *dmabufsrc2 = NULL;
. p* n+ r' y8 Z. e( b - char *dmabufdest1 = NULL;
/ ~$ ~4 ?/ R( i1 B! } - char *dmabufdest2 = NULL;
' l. q- j: ^/ b1 f
% J$ Q6 s, ~+ A; v4 f$ i: }! e- static int acnt = 512;1 V6 [. r2 n7 A; C
- static int bcnt = 8;
2 h0 f; [ `1 P. Y# \ - static int ccnt = 8;
2 k9 T D9 o" w( K1 N4 X7 v6 j
! }" |& ^6 W, s: X, J& o- module_param(acnt, int, S_IRUGO);4 a0 C! h+ m @: W! b; ~
- module_param(bcnt, int, S_IRUGO);8 N8 a$ ^+ X8 r' s2 b4 S, R7 G
- module_param(ccnt, int, S_IRUGO);
复制代码
+ |; b2 W' ?! Y
% `9 `8 d! M W: m 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用6 B1 P+ N( f1 x, U$ @' e' B, B% C
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
4 o8 B0 W5 C& v: z 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 W3 N8 h V" o" J+ U* R {8 n
/ O2 L5 t+ _' l7 w$ _+ S5 T6 k
0 R! ?: b: }" n5 o6 ^7 t6 |$ i2 I |
|