|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 8 p% _7 U+ q; k0 Y z4 z$ S
- [code]EDMA sample test application
1 `* `) W- ~/ r. ^1 x2 X - /*
/ g- [) g4 K e+ Z& N - * edma_test.c2 x( x$ D; c2 j I) @% A, F, z" T& {
- *) ^3 B3 Q' C' F
- * brief EDMA3 Test Application$ l) }# m2 B& }0 }: Q* ]/ e5 y9 Q# m
- *$ Q8 o' [$ ?4 ]# t4 e9 U& i
- * This file contains EDMA3 Test code.
5 D1 J% B1 r& Y. e a2 z! G - *
) \# b8 c. `6 I* ^: c8 v! ~3 v - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 \) `9 C c# y6 S$ k - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 ~4 z4 }& A t/ R - * TO CHANGE.
) T. U* x+ a- @% _* ? {0 I9 h - *
: y7 `: Z& r, }) S( t$ K4 _. Z0 K - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4 o9 H9 u2 z( W0 O8 q - *
3 Y0 c3 ^/ k# }* W - * This program is free software; you can redistribute it and/or
) H8 f6 {2 Q! V# j - * modify it under the terms of the GNU General Public License as
8 v& Z0 x+ T' v( T9 T) l/ W( t - * published by the Free Software Foundation version 2.
6 A+ }5 g4 F3 ^+ P - *
% ]/ l/ W# o! G2 o - * This program is distributed "as is" WITHOUT ANY WARRANTY of any' {9 `" L { K) n% _* E# U
- * kind, whether express or implied; without even the implied warranty
, Z6 j6 P$ i! [ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) c6 R+ H \* a. B6 Z
- * GNU General Public License for more details.! o5 s- i2 g* E- {, N
- */9 l* |3 k* o( e2 e) \
- s0 l+ Z7 s# x8 J/ a
- #include <linux/module.h>$ H M4 ?# _9 G, X0 D+ s
- #include <linux/init.h>; V) W' a! o3 D4 i" Q! D2 m% Z
- #include <linux/errno.h>! I _$ ]$ Q. p. R
- #include <linux/types.h>9 a* r# e( I& v* j8 v3 h# T+ h
- #include <linux/interrupt.h>
E; J. \& J: Q6 J: ?* w h6 x - #include <asm/io.h>
" l; C+ {" h% |: O - #include <linux/moduleparam.h>; \+ n! M, Q/ q# s$ |4 I) s9 E
- #include <linux/sysctl.h>
# ?8 J1 j% T. y3 l6 R2 K# K! D - #include <linux/mm.h>
% m- Z3 m% e0 {- g. Q/ B/ @8 i - #include <linux/dma-mapping.h>0 _1 k& D7 d' G- k: f' w
- - P! ~$ D) Q# `( p1 O; N) m( k
- #include <mach/memory.h>
& j: l0 t" Q6 @ - #include <mach/hardware.h>
5 q- ^8 W* C; T2 ]5 ~ - #include <mach/irqs.h>5 h( I$ W. h" B& i7 B2 t9 ?
- #include <asm/hardware/edma.h>
3 s8 S% W7 q+ J, {5 d: I& Y
) s8 Z1 d6 X3 K: O: Q2 q/ Y) ^$ ^0 T5 `- #undef EDMA3_DEBUG; C, g* o1 I. m& z2 O# R
- /*#define EDMA3_DEBUG*/
& r9 K+ @* J7 U6 s0 c& ^; S
" T4 l' _, \3 ^- #ifdef EDMA3_DEBUG8 Y# |# ]" m- c) L* X: D3 h; ]
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; X4 x: Z' r# m/ W# f; O9 M: H+ L+ D - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 @; w8 c6 P; t( y5 s1 Z7 n - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! L" o, \! j$ w8 Z! d5 @ - #else
# c8 x, x6 y. L1 n: e - #define DMA_PRINTK( x... )
7 `6 K; n: d- y8 P - #define DMA_FN_IN2 S1 F% u6 @+ V+ O8 O& o
- #define DMA_FN_OUT
v- ~8 q% J4 @. |* ^& D - #endif
* Z. @) m' M8 n0 x' }) A$ P
; M: c' V+ L! [% j6 O2 Q1 B7 I- #define MAX_DMA_TRANSFER_IN_BYTES (32768): h) T ]* ]& Y7 n* `. J# s$ a4 L" H
- #define STATIC_SHIFT 36 N, h* j' V5 |5 |9 D
- #define TCINTEN_SHIFT 20$ f# E. `$ G( e4 W
- #define ITCINTEN_SHIFT 21
4 V( u4 Q' ?5 g- }* i - #define TCCHEN_SHIFT 22
5 ?( ]; Q' x% P4 I9 W6 Y - #define ITCCHEN_SHIFT 23
* v* c1 [$ |7 t; N3 T8 l - 2 i5 a2 S: U: C0 f+ s; W
- static volatile int irqraised1 = 0;
; _- g$ M4 `0 G7 A! u- H+ A0 m - static volatile int irqraised2 = 0;
( r3 h' O2 C0 M: G+ a/ {+ r - 1 O3 C$ }( A1 H" L9 ^
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( R% V+ o* G9 G
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 o, K$ E, ?' B
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) N4 R/ b [' N% R' y0 |
- ; h& u Q- o! ~
- dma_addr_t dmaphyssrc1 = 0;
1 L, F& p5 X6 Z+ l) E8 X5 _ - dma_addr_t dmaphyssrc2 = 0;
2 L' p5 y0 f! Z% G9 h5 @ - dma_addr_t dmaphysdest1 = 0;$ z- I" ^' s: U. |, F6 g
- dma_addr_t dmaphysdest2 = 0;
1 w S" `' m" l" q5 [3 c2 C
0 P7 n4 x4 M. W* b ?- char *dmabufsrc1 = NULL;" J# [: F2 r2 P" M
- char *dmabufsrc2 = NULL;
4 |: G& x" o7 O/ X$ | - char *dmabufdest1 = NULL;6 e% \3 N$ O; s( H9 `7 I N
- char *dmabufdest2 = NULL;
. \& N$ y% O7 _& G" l$ h
6 z! g) S$ {5 E3 _( u, i3 n6 K, c- static int acnt = 512;+ A+ d6 n1 h7 M) s
- static int bcnt = 8;# K( F6 o- W* L& M' @: e. Q
- static int ccnt = 8;
: K' t5 K9 C4 e$ Q, m - ; \9 M0 n# Z o2 J* s, _$ a
- module_param(acnt, int, S_IRUGO);
$ E/ w8 t5 G; y- g! S$ a0 d4 l- i - module_param(bcnt, int, S_IRUGO);, { N7 j# a( z+ K0 s
- module_param(ccnt, int, S_IRUGO);
复制代码 1 n/ W6 } @6 b" Y- ~
+ M' z. w& S) }. k- S. A+ y 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) x; W( F K1 w: Y. `4 n% a. `/ Carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
3 I% k+ O9 f" c5 l 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
- R, _* D0 Y/ `% o0 s- r! R6 m9 d5 L7 g% T S; J* z' y
9 R- K4 e1 e. z4 ]' r& V |
|