|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
+ G4 F7 d1 J) h6 N- [code]EDMA sample test application
8 C- G; ~) d+ {) Q0 O4 i- C. I - /*7 v7 c- |, |4 s1 I2 `" Q, \' X/ @
- * edma_test.c
) y5 [1 x0 d9 |! V2 v - *
6 O4 o# |6 G6 P V7 w - * brief EDMA3 Test Application+ M3 N1 K4 C" u0 R. C( k
- *
5 ~, x) O( Y1 m/ V4 ~ T - * This file contains EDMA3 Test code.6 |% M+ A' ~1 ]! s* b$ x, b* T
- *
# ~, \9 m5 j7 L7 L" z1 G/ y' @1 M - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- S0 O3 U. e3 e0 ` - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 |# ^6 @! p8 o3 E5 F6 y* M) | - * TO CHANGE.+ x" Z6 ~% m. d2 N' J
- *
% [$ b J" O; W) N, O' j - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
/ Z' e" K1 V. ^* J6 i- m1 q - *
# `+ d G+ l7 W9 g9 V - * This program is free software; you can redistribute it and/or% t2 @3 ~; Q) r4 n" q
- * modify it under the terms of the GNU General Public License as
4 @3 r+ b. m, v* d7 E. V7 `+ M1 M2 Z' S - * published by the Free Software Foundation version 2.& t% f6 f. C1 ^
- *( i1 R+ O/ K$ a7 G3 G
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
# J. F0 \. s+ A* `! |: R& {5 u+ q* e - * kind, whether express or implied; without even the implied warranty% f3 L2 C7 {5 q8 L
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 u9 F' X, ]" A. a; v - * GNU General Public License for more details.$ r# l" w; M, a4 Q7 A; f5 J
- */
; x4 s* _# V. y3 P$ w - & \4 _: Q g5 h$ @( J( i' x
- #include <linux/module.h>
- y8 |4 ]2 x' r/ X% N6 s - #include <linux/init.h>8 U3 r7 j8 f+ k$ D% g
- #include <linux/errno.h>
t4 N3 S3 p, `# j& f - #include <linux/types.h>: c5 H. g# U4 S5 V* f! o# K3 _
- #include <linux/interrupt.h>
$ u3 \! R1 G/ J5 ` - #include <asm/io.h>9 ]; l Y4 I, f; b7 j
- #include <linux/moduleparam.h>
2 \$ Y9 L& x( W2 B8 ?4 G - #include <linux/sysctl.h>- {* f: e$ Q( }- O0 @% [0 D
- #include <linux/mm.h>6 T" w1 a; T" \# J) v6 N* B
- #include <linux/dma-mapping.h>
2 L& c* }0 G6 Z* T4 W3 t+ ]
8 \+ Y" i4 c) @% K G! U; c- #include <mach/memory.h>
, m" }+ r+ G( O6 F$ z1 e - #include <mach/hardware.h>
* E* I; U0 }! x; T! D - #include <mach/irqs.h>
2 k0 ~2 Q* m( H5 D, i: \ - #include <asm/hardware/edma.h>) N. [" I" u+ r2 a* [# x
* a0 [2 O, n% p" m' q. c ~+ o- #undef EDMA3_DEBUG5 c; `/ V9 q7 u' e9 c
- /*#define EDMA3_DEBUG*/
% S6 d) U% ]5 F H+ _0 Q - 2 r) P, p/ ]% m4 _
- #ifdef EDMA3_DEBUG- N' @8 a: y2 f7 F7 l- `* K5 \
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- t. Z$ d& U: i; o, S - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
" o5 r' l: _3 r. K( [2 D - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! G9 G0 i$ w3 [2 j4 q9 u3 _
- #else
4 N* {8 C6 R1 |8 [5 R: q - #define DMA_PRINTK( x... )# q4 u6 ?" t A' R) v0 X
- #define DMA_FN_IN
+ z+ b! ?( _5 S) O6 z+ u - #define DMA_FN_OUT
: D, k4 c: t& @; |2 q! E - #endif
7 \" `- U6 W0 n& q0 O+ S9 B
0 V% B* z3 f' S6 V- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 v0 j2 |6 ~7 T' P
- #define STATIC_SHIFT 3
& _1 \! R/ x3 P& z - #define TCINTEN_SHIFT 20 T9 p; X- e, Z! i
- #define ITCINTEN_SHIFT 21
0 N- H* u7 C( P. B& k/ P - #define TCCHEN_SHIFT 224 v. `* X8 c1 D7 B! `/ e' o% l) U
- #define ITCCHEN_SHIFT 23 g9 e- ?, E- l
. ~5 r% l, s- ` D- static volatile int irqraised1 = 0;
! Z! A: n2 e0 p" w% J - static volatile int irqraised2 = 0;
2 Z2 ?# H j* r/ t% B9 |- Y- B - 6 B. Q3 m0 O( j: c' Q- b
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- F# k* T1 I* |& O+ l* ~
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ r* W* d4 D2 G - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. S: C6 a1 X; k7 A
" H A) a2 ?3 ?8 E, n, A- dma_addr_t dmaphyssrc1 = 0;
$ T8 i d9 ?) O - dma_addr_t dmaphyssrc2 = 0;
- @" N% y( @2 m' r0 S9 t8 b9 h - dma_addr_t dmaphysdest1 = 0;
6 o: X" |+ g9 ?! g- I$ f+ Y$ x5 [ - dma_addr_t dmaphysdest2 = 0;! p, Y& _/ o+ ]* R' P
& ]( i9 L5 F; {% G2 Y- char *dmabufsrc1 = NULL;) n( y- r/ \* W
- char *dmabufsrc2 = NULL;$ L' R3 Z k$ V' e/ q* y5 D
- char *dmabufdest1 = NULL;; v T, H$ G, y2 n3 \
- char *dmabufdest2 = NULL;9 M) ~# h4 g( W7 s( C, k
! I8 t7 b# N: Q4 \; i. ]- static int acnt = 512;- y% g4 _3 A/ P
- static int bcnt = 8;* C& Z5 M7 ^3 ]* n3 a
- static int ccnt = 8;2 A y1 q0 G s( s# S7 x
; D. ]; u: v1 t, [: O6 ?& }) }( p- module_param(acnt, int, S_IRUGO);
' O% }) h0 m. ^- q4 ~ - module_param(bcnt, int, S_IRUGO);
6 ^" ~, g: ?1 _ ]+ Z0 C4 K; t - module_param(ccnt, int, S_IRUGO);
复制代码 ! E1 s; @5 h5 Y" F) Q
. N$ i9 j7 X9 K4 ]% b( p ^9 I9 H
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" C0 D8 @$ w% |2 X# n- b
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
$ L$ Q* b, ]4 O* f 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
& ~! |7 f5 h! {
5 p1 C: j2 s+ l% T4 c6 s' ^5 p2 g! C7 m3 @& h" Y/ p! y% \
|
|