|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 4 R8 A/ i! } {+ K
- [code]EDMA sample test application
8 s& }; O& M- D1 ?( W. b9 H - /*
2 i3 c s$ C4 W* j" v) e - * edma_test.c) y4 c' {& z! M4 P' P1 i1 H$ z. l5 ~
- *
* N! P* g7 j/ M# v9 x9 s# S - * brief EDMA3 Test Application! U3 w& g& ~( R: z6 X
- *: q w- T8 ~7 L6 t/ g
- * This file contains EDMA3 Test code.( e0 \9 _2 u9 K( g
- */ S9 b. u! ]; R1 U
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
2 k; J: @$ l# P8 D/ k% v8 h - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ z+ e) c: p/ V T! u" ?, k) } - * TO CHANGE.* i0 t d+ g* Z6 O: G8 w: k
- *, c. D5 W% l6 t0 b! Y/ R
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/# R1 b. r' t: i+ d, {+ j' i
- *: d+ Q5 W$ [$ E, g A0 i
- * This program is free software; you can redistribute it and/or8 g7 v# _( q+ N2 G0 Q) P) {, h
- * modify it under the terms of the GNU General Public License as. `; K$ \) q. \0 K4 G, B
- * published by the Free Software Foundation version 2.
8 h8 V8 {: h. R/ t3 d - *! }; D5 }, E3 ]. `6 `$ v1 N
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any" Z! [' c5 [2 o1 u* a
- * kind, whether express or implied; without even the implied warranty& g" G! [. M1 }1 h* B
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 U# x, Z0 J+ ^* L7 c3 g- T6 I
- * GNU General Public License for more details., I) d8 @. ^7 _
- */
% O! e- ~; O5 D' K4 F* r, [ k
* c: w) ]* v! h7 b- #include <linux/module.h>5 k4 z" {) S6 G, P9 d6 F+ [: i
- #include <linux/init.h>- |. c r& P0 l; N! m1 E( J3 n
- #include <linux/errno.h>; f8 ~% c# |, F: {: J
- #include <linux/types.h> l7 u" ?! _2 J6 h: z1 p# C
- #include <linux/interrupt.h>
+ I8 P' U- [ u7 G9 y - #include <asm/io.h>
, \ @: X+ M. b. s - #include <linux/moduleparam.h>
+ Z4 C2 I7 D! O - #include <linux/sysctl.h>
' D. D8 D+ l6 y/ D3 w; f- {6 _ - #include <linux/mm.h>1 A+ \# d: e+ p: e
- #include <linux/dma-mapping.h>
* i+ P# g, I9 Z2 G: l( ~
( E% I2 n$ G8 O/ ^; g- #include <mach/memory.h>, ^: o F, g8 K$ H* z2 \
- #include <mach/hardware.h>$ w, P+ P- { d1 e6 l
- #include <mach/irqs.h>0 l5 J* f9 z: y+ E3 F" A' L: e
- #include <asm/hardware/edma.h>9 W R3 N# S% r7 h h
- ) M8 q- G- [% s. K; p
- #undef EDMA3_DEBUG- M% n, X3 d6 K2 R/ H0 ?1 h; _
- /*#define EDMA3_DEBUG*/ ]6 H/ X% b; k4 O! u
- / ~* H) c" U: I7 p; d) W1 X
- #ifdef EDMA3_DEBUG
! w% c( z' ?; O: E0 } - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( b$ r/ o. A9 m: ~4 x - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 N6 b% P, E3 D8 u6 ^" W3 h - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__), z0 r+ B& i1 P' m8 P: k$ t4 M( Y i' }
- #else, y; X' d) ^$ J4 x5 X
- #define DMA_PRINTK( x... )- @! K2 R8 t* c0 n+ m; b7 I
- #define DMA_FN_IN
- E3 Q4 |0 C* K8 _% f5 Y - #define DMA_FN_OUT: \* M+ m1 c4 Q5 k9 k) q/ Y6 B: Y
- #endif
. ]/ D+ A; g8 [0 A% h( V* J9 U - + f q" W+ J1 h) e
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
1 k9 F- v' \7 J$ y M; }' y6 R; t3 l - #define STATIC_SHIFT 3
7 Q( q3 J- h c. z% |! S0 t! G6 k% H - #define TCINTEN_SHIFT 200 Q {3 M1 E; k/ u! U8 o
- #define ITCINTEN_SHIFT 21# m! a! r5 w9 l& q5 p
- #define TCCHEN_SHIFT 22
0 e. T) L8 L8 @9 Z/ J m: g; t7 S - #define ITCCHEN_SHIFT 23; E+ _- G8 B5 h
- 3 m r% `% {" o6 r- [/ ^+ P, K9 \3 G
- static volatile int irqraised1 = 0;$ v7 R9 D6 L( B/ K& ]; _3 S- k
- static volatile int irqraised2 = 0;
$ X) I' \! r- R4 q - 8 \/ J( o6 |/ J
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) I5 a# G+ O2 @& k3 ~: l! M
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" Q/ t2 b9 |: O - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ r1 A9 D& S8 l* n( `, ]0 i$ T
- 5 k& u/ M c# O9 N4 V K
- dma_addr_t dmaphyssrc1 = 0;- W8 l' P/ i a, C% j
- dma_addr_t dmaphyssrc2 = 0;
: p( R; U& R! E3 _ - dma_addr_t dmaphysdest1 = 0;7 J5 p1 G6 q7 B3 U [
- dma_addr_t dmaphysdest2 = 0;1 `# _) p" q7 d; V/ s
- 8 e+ D5 w5 G& y2 N# s" B7 _: V2 C
- char *dmabufsrc1 = NULL;
8 x" I q" I) P5 |% u+ `2 N& j4 Y - char *dmabufsrc2 = NULL;
. b. J- z5 k, n( X2 B3 F - char *dmabufdest1 = NULL;$ n7 o) N! F8 t4 v: ?0 J" a
- char *dmabufdest2 = NULL;+ t- }& A$ ~# h+ ^8 s
- 6 z6 y! r: p- j, n! Y2 I
- static int acnt = 512;0 E$ o& U& }2 g
- static int bcnt = 8;; ^, J1 D6 r5 {
- static int ccnt = 8;& ~" Q* u3 y# v- |. A( C7 @
7 E8 i% t0 v* {; M6 s* R( T C- module_param(acnt, int, S_IRUGO);# a0 P$ f. K- k! ?, V& W
- module_param(bcnt, int, S_IRUGO);
1 q0 O- n h! }, x# g6 p8 @8 n - module_param(ccnt, int, S_IRUGO);
复制代码
) Z; v; x \. x" ]( ? |! a" B
$ T- }+ Y' U3 Z- R( c1 _$ }* R 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
) E2 F3 \# g3 k+ t4 ]# i( R* L/ U5 ?$ }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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& B: j2 y& ?' x4 ], T1 o$ S 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
- A" A( s4 ^6 V
( Y, E* e! G. Q/ @% l
6 I8 P0 V/ X- U \2 U |
|