|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 9 _- Q" Q- T0 d% c# L
- [code]EDMA sample test application
6 C* l$ N$ W4 T+ W - /*
1 O0 w! U! m& V L' K - * edma_test.c/ {! {( z% \. s3 N; A3 E, m8 Y8 O
- *
) N. x' Y' y- K; G4 H/ p - * brief EDMA3 Test Application- K( l4 }9 X' C" o
- *
% [8 {/ M6 v* i' E& \8 k1 G, r - * This file contains EDMA3 Test code.$ C, n5 _. q; P0 a& A
- *
2 D+ p3 R- ]' U. ]( h - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE4 b6 M8 j, @* x' N
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 m7 F8 E0 x% v1 ]$ b, g/ w V
- * TO CHANGE.
# I: z5 r( i Z: e/ i - *
8 U8 Q% C/ A$ f% x7 I- m - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& H' e" ?8 |/ g3 p - *( p$ ^: ~8 k; ?' ^ |+ X3 f6 a/ N
- * This program is free software; you can redistribute it and/or4 }5 a1 z7 g4 P3 C% X) b
- * modify it under the terms of the GNU General Public License as+ V& O9 [% l5 T* o* f! ?( ` y
- * published by the Free Software Foundation version 2.& f7 p; H" L& I* @
- *
, g% [2 F9 \# K' z& I; D - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
0 K" a) Q1 M# G0 g( i1 M - * kind, whether express or implied; without even the implied warranty* K- ?& l5 X- r- W
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ q" P6 S: S+ Z! V% i2 B - * GNU General Public License for more details.
4 P8 M+ U. o6 l( S3 D9 l - */
2 ^6 ?' @6 |: a1 Q: z
/ L' i3 n3 n0 C0 K- #include <linux/module.h>% _$ i$ N5 ~0 g% t% L# e
- #include <linux/init.h>
+ B! l. @! F2 @, s i1 x - #include <linux/errno.h>
/ I( K5 r9 [& U8 U# m - #include <linux/types.h>
/ F! q, y: y7 p% i: t# N" Z - #include <linux/interrupt.h>
N+ |! \; E1 g) V& O - #include <asm/io.h>
) M# z2 m: P3 y1 _& \( U. a - #include <linux/moduleparam.h>
) _1 O* X8 K* R9 z. u d4 l/ a* t% q; r - #include <linux/sysctl.h>/ {; `! U) ]- n/ X! c) S' ~7 }) X) @
- #include <linux/mm.h>
4 Q' C9 F' E/ G2 O9 s4 d& M9 \ - #include <linux/dma-mapping.h>
8 B G" d4 B$ e* K: S- L - ! I8 C2 w0 g% p4 X3 b
- #include <mach/memory.h>4 G; F6 s3 ~! R# \* W/ N
- #include <mach/hardware.h>
1 h2 B3 B/ _, M2 g - #include <mach/irqs.h>& x0 {! u' t7 X! C2 V0 N
- #include <asm/hardware/edma.h>
: k8 B9 Q5 [8 c - 4 e7 Z* w( o7 g5 \* w
- #undef EDMA3_DEBUG% C. y; U6 u1 @# L; B f
- /*#define EDMA3_DEBUG*/
1 X& @6 B% v6 U) H% l - 8 g' @2 b! v9 `4 Q3 P. \0 K
- #ifdef EDMA3_DEBUG
% r) C$ X& C( C* D - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
$ F- R d# Q6 W! x0 @6 L - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. N2 o7 `' ^* [% @5 a4 U - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)6 l! T3 V+ l0 U/ v# Z5 J
- #else' k; O H3 c5 {& S2 ]6 Q
- #define DMA_PRINTK( x... )
* d9 p5 b: j' |6 `% j8 A# i% A - #define DMA_FN_IN% `7 `! Q, H. ^5 i' _0 A/ E
- #define DMA_FN_OUT" n6 J- T4 z" Z! M0 U
- #endif0 S8 }. V# E J Z5 L2 q
- 9 N8 ]6 p' |: D% S
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" F. m$ E. d+ f6 T3 h9 T - #define STATIC_SHIFT 3" a4 b, e: {: o5 \) y: J' G9 ^1 Q, A
- #define TCINTEN_SHIFT 20
3 c+ u# _ K' U+ L0 ^- k' q+ I$ Y - #define ITCINTEN_SHIFT 21" A, M- L& H5 b' F; \
- #define TCCHEN_SHIFT 22
: V/ H8 x: i8 D( s% h6 D p8 W8 E9 ?- A- F - #define ITCCHEN_SHIFT 239 h4 u; m, |0 v4 ~ i% D) [' y
- 6 B& V0 Q& o3 h4 B& I I
- static volatile int irqraised1 = 0;& j+ U8 j0 r2 Y! G* o/ w: W
- static volatile int irqraised2 = 0;
9 `+ [, K) x/ B! k6 T5 C - + ?! O1 Z9 F, K' U7 j3 L
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 D- N. i) R# \0 \: f* X
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 x9 ~, w/ }& ~; D) V$ N
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, {# [$ _6 E5 v: J+ X
, \9 k* p2 ^9 b& O4 ` r- dma_addr_t dmaphyssrc1 = 0; Y. v" g3 R4 x. X5 D0 X
- dma_addr_t dmaphyssrc2 = 0;& E8 o6 z0 [- y7 J2 n
- dma_addr_t dmaphysdest1 = 0;
' Z' z6 o/ y$ ]3 Y: T) S3 v - dma_addr_t dmaphysdest2 = 0;
5 C& `$ s! H+ W* z+ }% j - 4 y2 ~, w7 U" C2 t
- char *dmabufsrc1 = NULL;
. Y% P" f5 }+ A! j4 x1 `! E - char *dmabufsrc2 = NULL;
; g- P* y/ @/ K - char *dmabufdest1 = NULL;1 O/ B6 k5 U, K2 d
- char *dmabufdest2 = NULL;+ G( ~" m6 E) j) P6 i- |) ]3 o
- * L$ y' Q6 y5 ^- ]% o) x. a0 \
- static int acnt = 512; l. e" [. E$ X% O
- static int bcnt = 8;2 O3 }# C! t& x/ C9 S
- static int ccnt = 8;
' X* ~; t4 D3 F( j' [3 @ - " U* v" k% U/ X5 c
- module_param(acnt, int, S_IRUGO);
8 N% I! B1 c+ \7 v1 E. z7 M. C5 h - module_param(bcnt, int, S_IRUGO);
4 U, H: o+ r* G' B# ^' a - module_param(ccnt, int, S_IRUGO);
复制代码 $ f' T9 E! E u2 Y
6 J) p H# R2 k6 @$ ^, K, s+ K. |
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用3 q" |" b/ r. E
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ k* l4 K9 c5 \, T4 w 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
" m T% \% i$ E, E' ~. _- ~( Y5 x. E( k) M! ^% }" L7 d
/ [1 ^, V7 q3 j8 _+ L, @1 e |
|