|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 5 m* k6 L8 b" f7 m6 ?( j1 T
- [code]EDMA sample test application
, E6 f v$ V, I& j# l+ P/ u( u( i - /*
+ |2 v1 }' e$ H - * edma_test.c
. j8 E& P$ K. E3 \. ]. J - *2 H) s5 t" C* }; o$ z4 q5 R
- * brief EDMA3 Test Application; ?: t. @$ Y e/ m
- *( k, p: n( T, }" a+ A% G( t
- * This file contains EDMA3 Test code.& K6 ]! b' y1 ?- _8 r+ B9 ^/ X
- *
! b% I6 r, F: d) r' I% o - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE: G4 v% v) V4 s0 {
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ R9 K" Z- E4 P0 {2 x6 T8 }
- * TO CHANGE.' x5 E/ f: k- f1 c7 {/ Q5 ^" x2 Q8 Z' d
- *2 N& ^0 W9 o L x/ g( p' Z
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 {: N6 }$ o1 a' a: i
- * U" E$ P3 L2 J: g# `
- * This program is free software; you can redistribute it and/or
* \$ D9 _' G: w( T* a - * modify it under the terms of the GNU General Public License as. D3 t1 t2 _: M2 |
- * published by the Free Software Foundation version 2.
' G' {0 @1 V2 L; j' n - *2 i9 e0 t! R' K F/ d. [( n! r
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any7 A9 M' M, \) G& |' l6 s
- * kind, whether express or implied; without even the implied warranty
H% a8 i8 l; u2 T' w$ _8 k - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 i0 e# |0 E- S$ m0 i% R* S
- * GNU General Public License for more details.6 j" e' i: r6 I7 v) {
- */
* R/ m6 B9 g/ D9 o - ! `# n6 a# q% R! ^, V7 X E
- #include <linux/module.h> i/ j# ~5 a* {" O- T' ~& a
- #include <linux/init.h>
8 B+ n E* b+ _- U" ^ - #include <linux/errno.h>
9 T5 S1 x0 l3 a' } q! G4 D9 R. y - #include <linux/types.h>6 u* @* Y+ o ?
- #include <linux/interrupt.h>7 `; Y$ v( y6 I, O: I9 k6 D* ]
- #include <asm/io.h>
# m/ H$ d; N |3 z2 P- L - #include <linux/moduleparam.h>
! z7 O" v# m- r8 p6 { - #include <linux/sysctl.h>$ U" q2 }. j2 {! r; f
- #include <linux/mm.h>9 }6 N2 c) D. b6 o7 ~; m
- #include <linux/dma-mapping.h>) U+ @6 r% x9 E' E0 t) G6 j
9 u0 G" Q8 u- ^' n2 j- #include <mach/memory.h>2 S5 U/ @' |. F- o, m% m; r+ P$ r9 G
- #include <mach/hardware.h>4 r; n6 a) W- k t$ y
- #include <mach/irqs.h>! o, f$ c. V6 a- T1 y
- #include <asm/hardware/edma.h>& N8 @- A3 D# l" H
- & H: ~0 u' D- B! k( Y& \) E; c l
- #undef EDMA3_DEBUG
0 H: `- r- ^5 z/ I/ D6 m6 M - /*#define EDMA3_DEBUG*/
1 n; C& X' j7 l5 B& C) J. R - 4 G4 P" d7 Y7 c( p3 L& g+ T
- #ifdef EDMA3_DEBUG
% c/ O% s- j. m. Q - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 A/ U6 S9 M9 S - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)% r5 k0 @& m( r7 J$ c* l, ?! Q8 k6 D/ M
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
0 y/ G" @+ {! {2 ], } - #else% X% i) O% S; z) r
- #define DMA_PRINTK( x... )
% w' Y+ u. G8 b: j5 U V+ @ - #define DMA_FN_IN( B% n- Y/ u5 l; l
- #define DMA_FN_OUT
7 x$ ~' q! [3 k5 J4 p; z: C - #endif
/ U+ D' K2 P- ?! o, Z* i U$ S, k
, x- r+ K' V9 D" P- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* s1 G# C) b9 W% e - #define STATIC_SHIFT 32 o0 w. o: L5 G9 x7 p! o* `* N
- #define TCINTEN_SHIFT 20
/ t( r+ G0 G" |) j4 w - #define ITCINTEN_SHIFT 218 m% q* \+ h$ q
- #define TCCHEN_SHIFT 22
+ Q5 n h) e6 j; I3 S - #define ITCCHEN_SHIFT 23* w3 k1 Y+ o/ C$ z
, N7 f( ?% W" ], U: R- static volatile int irqraised1 = 0;
+ {. z7 g; H; y; g/ B( a - static volatile int irqraised2 = 0; K/ d. U7 _: R0 Q
- 8 A/ @% I! |3 W$ w; \! G) @
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 y P6 A8 a9 Q" z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: a' E! M C( d: J
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 `% }# ^, z$ p6 j/ M5 V - " @. v u0 z$ g; \/ W) n
- dma_addr_t dmaphyssrc1 = 0;) {/ q* K( A9 A1 _1 X7 k( }
- dma_addr_t dmaphyssrc2 = 0;
# C8 v; R7 x' e0 w - dma_addr_t dmaphysdest1 = 0;
( n3 t& Q/ V, R! |5 ] - dma_addr_t dmaphysdest2 = 0;
; [1 Z# r( ]7 M( ^8 r0 m/ I+ k
2 e& o A* z9 L' }% f3 Y- char *dmabufsrc1 = NULL;) y4 y& X5 V! w
- char *dmabufsrc2 = NULL;! g$ ?) P* E% ~/ E; b* F& w
- char *dmabufdest1 = NULL;. \2 l1 o1 l! @2 R* F, @8 l+ u3 a# S
- char *dmabufdest2 = NULL;* z- y5 c9 ~4 g% o
4 g: ]( w. V: ~' f- static int acnt = 512;
# A2 p$ J9 w9 z) f$ j& |3 z @ - static int bcnt = 8;
0 V! B( e T- N' C* ~6 S4 [9 T9 e2 u - static int ccnt = 8;
% w+ R" ^2 n# r9 \: R/ r; t
) I4 p9 Y: `2 u. D/ l- s- module_param(acnt, int, S_IRUGO);( z7 b& j# ]% P& m9 H; J$ o: G* Z
- module_param(bcnt, int, S_IRUGO);
* A0 q) | v2 q- t9 U - module_param(ccnt, int, S_IRUGO);
复制代码 6 G \7 s6 j" x# y0 z
/ w: z0 [& {( ]( W" t7 j
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- K0 \& I; j! Z2 s5 Q3 Z5 G6 {0 P0 karm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
: M f- D- t K; R9 ] N5 p 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# [6 Z7 F# A5 [( v7 V r
2 A8 \* [. w7 U1 I9 }9 V( O& {) q [ g' W
|
|