|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 f' X- U+ G, z7 y2 @- @6 w- [code]EDMA sample test application a% C& s' l* M& Z1 _* B
- /*8 g& @5 s% B! i( _. N
- * edma_test.c! P& ^' l6 I( ~4 ?0 q
- *
, w6 K$ N/ j! b7 I$ G- g6 | - * brief EDMA3 Test Application
1 W4 e8 ?$ ~, H( R - *' u6 I% V$ i" N+ x
- * This file contains EDMA3 Test code.: t: e0 H2 f8 d: J! q+ t
- *
# s$ I. h7 Q- L& g - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
M& b- p$ X9 t - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
0 M- b, }: z. ?- k4 P - * TO CHANGE.: O7 r9 ^4 ?5 A+ j8 ~* U2 r( Q
- *2 d z3 P7 T0 `9 I2 j* M
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/' L3 H* ^" _' T% I4 j
- *
. R7 V _. g0 e. a+ @) A/ L - * This program is free software; you can redistribute it and/or
$ L! f5 n d& A c. R9 j - * modify it under the terms of the GNU General Public License as+ J5 e; Y3 z8 p8 n L. I
- * published by the Free Software Foundation version 2.
0 w W$ v! H" J! R7 Y2 B/ M - *
9 I% Q, r" h- [* c1 }, S - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
1 Y1 R+ L; U$ [( F# j - * kind, whether express or implied; without even the implied warranty
# J& g, V9 }2 h ]4 A - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
: o& z1 L% t$ }( T8 `# a - * GNU General Public License for more details./ {* Z; p& G8 w7 ~: B
- */0 P9 p; O2 }2 H0 W% N" K& S+ F
- ! [6 O; W3 X8 B6 w
- #include <linux/module.h>
C# d6 J) o7 T6 E - #include <linux/init.h>$ D" r% @7 ]1 J
- #include <linux/errno.h>% J1 z& p) A3 j$ ^% Q, p D6 c
- #include <linux/types.h>
: J: ~" l6 N4 ~+ q- o - #include <linux/interrupt.h>
; Z9 i0 g" ?! J9 e. \# p4 A - #include <asm/io.h>
7 T3 m/ q o& I! b. x - #include <linux/moduleparam.h>& l1 T- ?+ c X, V6 ^" q1 {' _ J7 O
- #include <linux/sysctl.h>+ @' i( v. x* I$ |+ D0 m/ @. e: Q
- #include <linux/mm.h>
6 j$ Y7 q2 v: q' w# ~ - #include <linux/dma-mapping.h>( S. G! ]/ o* K) `# G; `) g7 V
$ x: n% o% W) ?7 l4 p! G/ O" ]- #include <mach/memory.h>) D7 V9 w; P5 @2 n) {1 J
- #include <mach/hardware.h>+ U% a$ |' b: _, U' O% q
- #include <mach/irqs.h>4 O6 r$ D6 L% Z' ^6 |1 |2 r# R
- #include <asm/hardware/edma.h>
. C7 N, E* K8 K, K& `, B( ~ - * }* N5 N$ A0 D
- #undef EDMA3_DEBUG k c0 U; Q' t- R
- /*#define EDMA3_DEBUG*/
* D- ^5 ?3 X. H$ X
`/ _" K- T" ]9 q& T8 A/ u% ^$ i- #ifdef EDMA3_DEBUG
5 ?$ w0 P3 \# W - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
^6 o `- n* { - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
5 _1 p$ `5 \0 v7 ] ` - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)) s( v- J& d; z
- #else$ ^" j& o' W7 R) v9 N7 s
- #define DMA_PRINTK( x... )" I9 ~$ a, u1 P' ]7 n; _
- #define DMA_FN_IN2 z4 w+ X9 A s0 x: K
- #define DMA_FN_OUT3 d0 s! z, ~( B5 \& a& j6 Y; X
- #endif5 X/ Y/ n! {3 b, u
- * F6 r; E% K$ j+ k+ a! b
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)3 N5 A! {4 e) ?% Q# Y0 ~
- #define STATIC_SHIFT 3; p p: q; W+ G
- #define TCINTEN_SHIFT 20) M# P" [5 ~9 I0 i! U' K; ^
- #define ITCINTEN_SHIFT 21
, s3 A, {( q5 |" G9 B# u W - #define TCCHEN_SHIFT 22
. B v- @; w, T0 A$ _ - #define ITCCHEN_SHIFT 23
8 Y) \5 C0 w0 p) I& V* j - 3 {% K9 |9 V0 c
- static volatile int irqraised1 = 0;6 r4 G1 I2 r5 {( M! @1 m, F
- static volatile int irqraised2 = 0;) Y" ^6 n& Y2 x' z
6 l! P8 c: g0 ~; B9 u, h* H g$ J- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 R5 y5 F6 M n9 O7 P; Y
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 f0 e7 k/ l9 K# d - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" s- C6 t4 \7 H! y1 n9 g! P0 q - 5 Y3 o4 z* Z0 }; Q4 Y9 f; C0 M
- dma_addr_t dmaphyssrc1 = 0;
1 ~/ k6 |- q/ y5 V) s - dma_addr_t dmaphyssrc2 = 0;" v5 W# Q9 S1 v+ d- ^
- dma_addr_t dmaphysdest1 = 0;
& c7 |+ I$ F; ]3 g5 J - dma_addr_t dmaphysdest2 = 0;
2 s, a X! d5 i# K- W. b/ c
/ d6 V* t, v; s: `" g! s/ A- char *dmabufsrc1 = NULL;) }0 Q, B! R& C
- char *dmabufsrc2 = NULL;
$ ]5 w2 O8 v9 l9 d - char *dmabufdest1 = NULL;
) ~ G- P" j k. a$ m: d: I - char *dmabufdest2 = NULL;
( w5 N; `6 S/ y$ q
! @5 Y; `4 G; `2 b- static int acnt = 512;
- u4 @0 ^( X4 ?/ Q* l5 S - static int bcnt = 8;( Z0 {9 N. Z1 F$ t- J5 W
- static int ccnt = 8;
: C$ a" @) i8 i9 Q( M3 U2 Y- Z4 x - 0 M" Y; f+ G, J) K A3 w7 h0 x) j/ C
- module_param(acnt, int, S_IRUGO);" ^( J6 Q( e% o) y3 D
- module_param(bcnt, int, S_IRUGO);8 F- w1 w7 [9 a/ A% Z2 P
- module_param(ccnt, int, S_IRUGO);
复制代码
; A, s Z. P% r0 |% y) x! F9 E% u' r9 M7 x
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) Y( P, \7 M+ B( o5 ~5 M% O3 Z
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
; _, \* \4 {( `$ h 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; }$ O/ k! O- r6 i" |1 G
. t) B3 T/ L9 R! {$ c2 A
9 o: @: m, \+ C0 L |
|