|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 m: v( B3 e1 Q0 D" d2 o. S- [code]EDMA sample test application
u4 V7 X; W+ j - /*% J3 ^# ?0 R# N' A
- * edma_test.c* }4 F- S1 j" i4 g+ F
- *
& e0 ^, e+ g- n% T1 r. v4 y - * brief EDMA3 Test Application4 _" H. q3 B, C$ _" P
- ** P3 m+ O8 ?2 I8 b. Y3 G
- * This file contains EDMA3 Test code.
: H9 C9 Q1 u# m2 ~ - *6 ]% Q5 {% h% a2 ^; M/ ^
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
2 U- A! C5 u- @ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% C8 K% [2 e$ }) q4 U - * TO CHANGE./ x' a1 a% i- ?% G6 g$ w
- *& j6 E6 A S' e5 b% ~
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
/ ~/ I( K' f; B# M - *
5 o3 n" i( i7 I3 E5 V" `' `, W3 z+ [ - * This program is free software; you can redistribute it and/or
9 D2 B& H$ U5 w% r5 g - * modify it under the terms of the GNU General Public License as
8 L9 C" R, G% S- h - * published by the Free Software Foundation version 2.0 P E4 X6 ~ s( v/ O6 q- r9 U
- *4 k1 n6 m: r" ~6 F* R
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any M4 S! p. h K$ O7 {$ p" K( i
- * kind, whether express or implied; without even the implied warranty1 k* }! r" f& s5 ?8 a
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ ^; w- g4 W' ]$ J - * GNU General Public License for more details.& {6 D+ \1 d `1 ^# f! E& H
- */
: r: P4 i, \0 A6 u0 } - 8 @9 n0 [- S- O
- #include <linux/module.h> T& D' b* ], b# P" q
- #include <linux/init.h>
+ I1 {$ N% l, j, ^' g+ \4 Y, a' m - #include <linux/errno.h>
4 K/ L+ t* M& @5 K/ F/ Z - #include <linux/types.h>
/ Q2 G a; G+ Y4 l9 j5 v" P - #include <linux/interrupt.h>
1 t5 u$ n. \/ c, q3 o8 H - #include <asm/io.h>, z/ \3 V+ {7 R+ J; E8 |4 q
- #include <linux/moduleparam.h>
6 _& @3 p3 r3 K8 g - #include <linux/sysctl.h>
4 M6 w W" |3 c/ M; d - #include <linux/mm.h>
# ^# ^+ d0 Q# w( Q/ i8 B* E - #include <linux/dma-mapping.h>
I9 v* J$ h' u
1 h5 m, }$ ~1 i2 ^; ]$ S- #include <mach/memory.h>
8 i$ @. }- ~3 w& U - #include <mach/hardware.h>4 j+ U( U+ N- P: \. N; U9 I2 L- P
- #include <mach/irqs.h>
# l4 Y. L' Z( u' d H, r7 m. S - #include <asm/hardware/edma.h>! g" {8 H% j8 D% E) z+ y2 I' g
/ i) M3 w" `% A- G- #undef EDMA3_DEBUG
2 ?+ L, H! u; p6 \. Q- P5 z - /*#define EDMA3_DEBUG*/- [. X5 j. e% w" U4 h
- a% d1 U4 D1 w- #ifdef EDMA3_DEBUG) U9 f: Y1 w @$ \1 Y. d% V' }; N1 W
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, V4 Q# M( d/ J0 o1 \: @ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. ^9 `- D5 @: S& _ Y% T - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 C2 t* c. W3 U4 p N/ H% r) E - #else" S$ U* a: I. B. k/ }
- #define DMA_PRINTK( x... ); _( I, S& A. C* i& w
- #define DMA_FN_IN/ B% `+ W5 R& }, E! |7 R: N
- #define DMA_FN_OUT
/ G2 N: b9 y: u. F - #endif
3 Q3 V) F4 i4 r% p2 N9 z( ^/ ^4 A
. B2 N+ Y7 |. M/ y) D5 m) v- #define MAX_DMA_TRANSFER_IN_BYTES (32768)! U; @* O' r+ h5 R: d$ [6 o: b
- #define STATIC_SHIFT 3
8 p- J4 }5 j4 i/ w/ Q, N' k - #define TCINTEN_SHIFT 201 l$ G; d% t% t7 ~ J
- #define ITCINTEN_SHIFT 21% d2 r+ Q1 I8 R9 t1 B! G3 T) s
- #define TCCHEN_SHIFT 22
/ h& i! p2 a$ Q6 G- u O" } - #define ITCCHEN_SHIFT 23
9 [5 o) F5 F4 [) s+ c% H - " H: U; w7 e* F) z H
- static volatile int irqraised1 = 0;% n% L; f- M5 i: s# k! b
- static volatile int irqraised2 = 0;0 d8 W1 l( p, R" }
$ K0 o" q: g+ o4 C- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% ]' _2 g+ g; h! |$ d: v0 X, T, ~
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 M- i# b+ {' ]0 N4 L
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ r6 O8 L& ]* v# M8 f$ T( S
- , b3 x( X+ ^6 j/ a7 U) H) k' B4 q
- dma_addr_t dmaphyssrc1 = 0;: b7 M8 I" `' M5 D& \6 ~
- dma_addr_t dmaphyssrc2 = 0;9 [+ V& w0 D2 E$ z% @; W$ f( L+ ?
- dma_addr_t dmaphysdest1 = 0;
% a1 {- p1 ~. [5 w- y# ^0 D V - dma_addr_t dmaphysdest2 = 0;
8 @" V2 W- i, Q$ h! ~$ j9 n1 x2 i& M - 7 ~/ H/ l# \! b
- char *dmabufsrc1 = NULL;
$ u: g! o- W. Y. ]8 a& d - char *dmabufsrc2 = NULL;
4 e7 K7 @, g; f& M( ?, v: F - char *dmabufdest1 = NULL;# z: G! N4 T9 L7 s7 |
- char *dmabufdest2 = NULL;
0 Y; A& s3 W) P$ c" O7 N, B: z
9 s ~; N# S8 u; [) r1 ]8 c8 @- static int acnt = 512;
/ f) a$ O/ {$ F. R5 A( O - static int bcnt = 8;: Y, I0 O. ^, V, j; w+ M
- static int ccnt = 8;" d1 X/ B6 X" I+ l J/ P% T7 ~
n$ O4 Q# z% O+ b1 L- t8 m- module_param(acnt, int, S_IRUGO);# l4 n! v: ]+ O( Y
- module_param(bcnt, int, S_IRUGO);
6 ]: `$ i0 |, [5 u& D - module_param(ccnt, int, S_IRUGO);
复制代码
& n6 }% Q7 b$ x+ z9 p8 {( [$ h0 d7 g/ h- _4 ]
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ p$ t. H( M" {# y9 V* m8 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# t) G9 ~: W7 y, N; C
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% ~8 g, G8 [" Q3 f; A
2 q% _. B& `6 W0 d7 w# {1 k7 o7 O& t7 A1 A; D9 \) y- ^, D6 {% D
|
|