|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ' v! _7 N; n. f: Y. x
- [code]EDMA sample test application
( z6 V# S, ]0 i) H5 y/ b0 X - /*
( c* y9 g% R& v3 `: u - * edma_test.c, L* z, Y7 m7 I/ N6 M: ?
- *5 C* t3 {! k' `# z# J$ \+ F" F
- * brief EDMA3 Test Application
4 k( ?2 m. K$ F- z: L5 _ - *4 J" e/ H1 b/ A1 \, Q: k3 `
- * This file contains EDMA3 Test code.. E [- K. o$ w
- *. b" v1 A' t) {2 W1 W% Z
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE {0 G2 D; \' r8 M0 N
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, ~. g- r, I c) i4 |$ V - * TO CHANGE.) q* ~8 y- j E' l+ m9 }6 D
- *
" f7 ~0 ~7 r; \8 |0 l5 a2 I - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 S/ l% r% q2 t% K" Y - *: s T% c- Y) M9 h2 R
- * This program is free software; you can redistribute it and/or
: q6 b4 d. M7 ?8 J - * modify it under the terms of the GNU General Public License as
( L+ D; U2 j' ]4 h+ \7 v - * published by the Free Software Foundation version 2.
. l* O8 q, @5 G1 m) F4 h9 C& T- \# ]8 V - *" i: r; R( Z" ~# A
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
: v( Q9 E* u7 }4 n4 s% X4 K) M: d - * kind, whether express or implied; without even the implied warranty
0 q0 d: {* x( n1 j& P - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the( I! D2 M) ~, A) {# Y# [6 L5 O# j
- * GNU General Public License for more details.) C* s7 b5 X. F
- */
) ]! i+ s1 l* C# G7 e0 ?5 _
9 m* I2 i3 g7 i1 A# o/ m8 t; C- #include <linux/module.h>/ t) @( q" Z6 Q; w* U2 \
- #include <linux/init.h>
6 K1 q; a3 Q" k) J1 X2 ` - #include <linux/errno.h>* P I5 e; z7 L( M6 Z: o/ j) ?, ~$ Z. c
- #include <linux/types.h>% C: d! \7 b$ F0 g
- #include <linux/interrupt.h>2 A2 m' d4 g# }
- #include <asm/io.h># V. h% ]3 S0 X- h! @( u
- #include <linux/moduleparam.h>- W z7 q# u* G9 b% s, C5 B$ y
- #include <linux/sysctl.h>5 @# K7 i. H9 c! a, N) u* ^2 i. W+ `
- #include <linux/mm.h>
9 j3 u- j' W, a/ F - #include <linux/dma-mapping.h>
! j$ v4 i0 v4 j, D3 q. R - - [3 b( |+ ?- t2 X5 o+ V
- #include <mach/memory.h>
. N6 g( J! J9 P Y$ u) M: o+ f. J - #include <mach/hardware.h>
) B- j0 i' w+ a* q: J7 z o3 a - #include <mach/irqs.h>
( a- V# V( `6 _- K& s - #include <asm/hardware/edma.h>6 j+ Q" A' P6 F8 ~2 h: ?) x" y& }. u
% h, B, x* F6 ^ R; }- #undef EDMA3_DEBUG
& y1 n, x0 ^, T( @6 g - /*#define EDMA3_DEBUG*/
4 w$ W) e* A: X- E4 g8 X1 a - + E+ y- C" z2 E8 x
- #ifdef EDMA3_DEBUG
1 K, v% m$ n* p. B% I' n+ i& Y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- M3 O% o2 d! g3 X
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)0 E E" _9 ~& z) I& B- \4 w' O
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& S+ J4 @0 w$ n5 i; L% ^
- #else
x$ E9 [* b' } - #define DMA_PRINTK( x... )
- I9 Z% h5 k; m1 Z1 y - #define DMA_FN_IN4 E# N5 v3 f& z; p$ P+ q
- #define DMA_FN_OUT
# a9 }; Q2 S$ e0 S$ @ - #endif( p- l6 H- Z- z8 o7 I& A- e
6 w% ^$ u9 E/ ~7 P- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* Y' \) @! v/ W% ~; J3 v p2 d - #define STATIC_SHIFT 3
, Y! E9 L; a" s4 i' W- C - #define TCINTEN_SHIFT 20
8 Y# d0 d+ x0 E4 n - #define ITCINTEN_SHIFT 21
6 ]4 ^8 n( T2 X" \ - #define TCCHEN_SHIFT 225 P9 ~& T& I! l1 i9 \! ?2 G
- #define ITCCHEN_SHIFT 23
+ n3 w/ s8 m) K1 H - & l3 ^7 Y% A- I8 o4 {7 V
- static volatile int irqraised1 = 0;$ a$ [" b; r. x/ F+ S. M6 m) l
- static volatile int irqraised2 = 0;
1 T& V- [& h* h) t: F
; ^. j7 w6 r- E, Z( z# v" e- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# b- V7 z7 t! u% S0 _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 V' c3 i; y" n$ {$ m' r5 f" U
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
c) ~, _. X1 B( y* f - - c& |5 J% C6 N, j2 m) I3 K g
- dma_addr_t dmaphyssrc1 = 0;
Z5 s/ i8 p2 T& ^: H& D' G, j3 W - dma_addr_t dmaphyssrc2 = 0;. C! q o% b8 `: v0 Y
- dma_addr_t dmaphysdest1 = 0;
1 @: w" X$ B+ _2 @2 o3 H - dma_addr_t dmaphysdest2 = 0;4 y$ t- i5 O, @6 N/ T/ D- o
- 9 X" K% f1 }$ ]/ N- S
- char *dmabufsrc1 = NULL;
Q% K! u# b, v2 [ - char *dmabufsrc2 = NULL;
8 Z# B# E4 C, q2 [; L - char *dmabufdest1 = NULL;
: F% E; E8 L2 B, ? - char *dmabufdest2 = NULL;
$ M( F2 ]! S1 X/ ]- l0 \
; `# w/ Z: Y6 _- f% i- static int acnt = 512;
0 v' p1 g! L+ H* W* D9 K* _ - static int bcnt = 8;: T% a" y4 k. [0 H0 l* j n
- static int ccnt = 8;5 x9 l: p# d- f5 G5 p/ s
; K i4 |7 R4 i8 Z* R3 V- module_param(acnt, int, S_IRUGO);
* F' a- O9 R3 H" L - module_param(bcnt, int, S_IRUGO);5 M& V0 D( I+ g( o+ R5 V: o
- module_param(ccnt, int, S_IRUGO);
复制代码
' I, l6 R4 C3 B8 `* L& ~5 _
" H- @/ ^$ Z* P* |4 Y$ X0 ? 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
+ D$ E, Y! _1 P/ c sarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; |0 m" z" k, H8 R* {3 q
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& c. i- E+ _0 f1 @" U
9 M b5 o% K4 @
; S4 u% Z" A- C) r$ Z8 x |
|