|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% v% m8 X9 a' V' _7 T2 q- [code]EDMA sample test application
0 R1 G4 w" M- b7 H: p8 ^2 l- B - /*
: P# V4 Z3 t: R$ d+ e# k - * edma_test.c
- E& m7 Z6 q, N" k# g3 Y$ h - *
0 v% ~( a- x7 c - * brief EDMA3 Test Application
: s+ Z1 I/ U7 N- k6 @ - *0 [$ H! _7 X3 P. O+ R1 J+ \
- * This file contains EDMA3 Test code.
5 P4 @5 ^! k3 F- M( x - *+ `! ^8 z" [0 h' X/ O5 m
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- w8 F$ _$ s# `+ {& C! d' r: y - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
- ~$ G; @$ [' i - * TO CHANGE.* ^* `: C% V" R
- *
8 T( { d1 I$ d0 @ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/0 |- K& `5 r& S& d3 Q
- *
( \* ?' y1 V' s% c: o6 k% T7 g - * This program is free software; you can redistribute it and/or
" t2 v, M' o" g! D! k - * modify it under the terms of the GNU General Public License as8 g& b, h" Y" p/ [7 i; f
- * published by the Free Software Foundation version 2.( C4 P3 S ~' y+ j- Q- |2 k0 U3 Q
- *
. d! I# g3 o; S- p, b+ W - * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 c1 n0 f* G: c: I
- * kind, whether express or implied; without even the implied warranty9 O: y2 w5 J) C
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! n; Q6 Y- M) @: P! _, ` - * GNU General Public License for more details.0 l# U7 H$ s8 t( M
- */
* o" F8 P5 k* B( `
h" p& D+ X2 x& W0 h5 h- j0 p- #include <linux/module.h>& ~0 ^) a7 W& H) t+ G
- #include <linux/init.h>) t9 \7 k4 ~6 H' V8 T. u
- #include <linux/errno.h>
9 g. C7 u7 W7 }; ?9 |% c2 w3 x( q - #include <linux/types.h>
1 f. P- Y+ Z E/ x, V - #include <linux/interrupt.h>) g" n& D4 I& F4 Z
- #include <asm/io.h>
& L8 ]/ Y7 x/ {3 t$ P! [8 w - #include <linux/moduleparam.h>* n, i+ ]' I% D% E! b+ i( L
- #include <linux/sysctl.h>
$ @ f# |4 [; \" o* C) r& w - #include <linux/mm.h>9 }# U2 {* O( E J3 M R
- #include <linux/dma-mapping.h>
& k `- X. X/ X" ?- W$ Q - 9 y9 j$ t6 }$ m# V5 u; _; ?
- #include <mach/memory.h>- P T" I( d: [: H( R; s
- #include <mach/hardware.h>
2 G7 a/ }7 E- ^9 C - #include <mach/irqs.h>& o2 U2 z0 X1 B# R" F5 M
- #include <asm/hardware/edma.h>4 `6 L& Z2 }. m2 {. ~
- $ g) p- {! n8 U$ C' w% Q( w9 t/ Q/ X
- #undef EDMA3_DEBUG: b! [* A, t7 a2 E
- /*#define EDMA3_DEBUG*/
: x) S. I7 ]% ?5 e
1 N# [% a2 R* n& {2 M+ F9 ]- #ifdef EDMA3_DEBUG3 j5 ~0 _$ v' ~4 \
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
7 V% T9 b6 B6 d/ ^ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
9 i$ P2 Q8 g) i3 H) Q - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)% g' S8 R4 ?5 |4 }& E% `
- #else
( |( d% M# p1 w( U# S - #define DMA_PRINTK( x... )
% }6 U; w6 @3 E4 j - #define DMA_FN_IN- M4 `2 b7 W. J O
- #define DMA_FN_OUT* M5 s0 W( j. X6 t
- #endif
( S% i$ z( Y3 s1 W, ]/ j
# g. U9 c* F9 K$ Q" \- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 b- r, T( w3 @$ x2 {
- #define STATIC_SHIFT 3
% G" u2 {! V W7 G5 C1 \+ f - #define TCINTEN_SHIFT 20
. S+ b; C' w! ~/ T6 B! B7 r0 \ - #define ITCINTEN_SHIFT 21
0 T0 @2 A3 g3 A- h$ P+ J - #define TCCHEN_SHIFT 22
: @; I5 n8 A6 R6 F - #define ITCCHEN_SHIFT 232 S: `" H1 J C1 h: O: r! `. ^4 S
* k0 S V& `, n9 y: S, j; S& m- static volatile int irqraised1 = 0;% k' U, d4 V* R, s2 l3 l" l/ c+ d
- static volatile int irqraised2 = 0;5 g. m1 K1 S6 e& n3 W+ n3 w
- R& e @5 m& f& r- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% |! X0 q! a! {) V5 `$ @7 l - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ ?. v9 P. }* J4 |' g# s, U! U9 L - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, f' Q* t+ S) i& ]! u: `
- ; h# U5 |! x( t/ j9 @* I5 b
- dma_addr_t dmaphyssrc1 = 0;- X b. {5 ?0 t% k; \, x% H+ k/ J
- dma_addr_t dmaphyssrc2 = 0;
1 Q. x4 Q3 `8 W' v7 N - dma_addr_t dmaphysdest1 = 0;
1 l$ m; \# b: y9 g( ~; Q% _* G$ z - dma_addr_t dmaphysdest2 = 0;) n: t2 g# L+ H) [( c2 M2 H
- ) x* }4 M, k7 J# `; ^
- char *dmabufsrc1 = NULL;2 j- A( |+ @9 J6 B9 T5 u# Q* A! R
- char *dmabufsrc2 = NULL;
* g( Z4 _; }0 b) g - char *dmabufdest1 = NULL;* f4 H8 v" z7 O1 z& G' B9 @
- char *dmabufdest2 = NULL;
) h+ J5 K9 M* k3 O6 t' h! Z, u - + h! J& L/ b9 O, j4 Q; g* C
- static int acnt = 512;: |: M" w3 W& t2 b) J
- static int bcnt = 8;
; n, Q( p! c& m I; U - static int ccnt = 8;0 |& K; I( h2 I! W1 S
- 3 \0 [" _( E0 u
- module_param(acnt, int, S_IRUGO);; \* ~; f5 F( w1 z
- module_param(bcnt, int, S_IRUGO);
6 Q8 d4 y) t7 R; d% X# k$ i; x1 \9 p7 B3 I - module_param(ccnt, int, S_IRUGO);
复制代码
" V7 b% a* ^. S) D0 y3 |" s+ b0 t% r- o8 Z/ U
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" e0 b. T2 X* A! 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
( X4 y3 Y: M/ r$ s5 j 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- q5 c1 J" i/ m5 Q; X6 ]" E
% K4 @# e" W9 u, S- I: \3 N( Q" A+ D
|
|