|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 3 u) v) Q* M" s" ~; q: @
- [code]EDMA sample test application# X) N0 b, a& F: j$ Y) \
- /*
2 J" k9 g. P$ S ` - * edma_test.c8 a) c. N/ k" s8 Q u7 _& ]
- * ~* U/ \+ L t1 j6 H; G
- * brief EDMA3 Test Application9 O7 Z1 K9 \( X& `- i+ M
- *
) u- Q. Q( t8 X9 P0 u) | - * This file contains EDMA3 Test code.6 S; q5 [8 W3 W3 s F( @
- *) }) o( P1 @. t7 F$ U
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE, Y- G: @0 U8 d
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; f& ]; j# g6 z ?% o+ l) N7 b - * TO CHANGE./ ]: y c$ X# n
- *; `* a9 S0 h7 j- n7 z
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
* h. n3 ?! w3 r' ?8 L" S. t. m* q - ** q% J6 r ?1 f: }! v, i% ~1 S
- * This program is free software; you can redistribute it and/or A% }1 }4 b. h. k( d
- * modify it under the terms of the GNU General Public License as) W9 K9 u1 Q0 M* n2 ?4 N$ `9 M
- * published by the Free Software Foundation version 2.
" ~0 H( c: x) u4 c9 r j! \ - *
, h1 |+ F0 h2 Z+ I4 x - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
/ h& d8 z- v2 U - * kind, whether express or implied; without even the implied warranty1 _8 G, G$ e; s& _ y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/ z& _3 G; r- S1 q* R3 ^ - * GNU General Public License for more details.
1 `* t, K5 B/ w0 m( E - */
/ W9 \( p, Z- v# C - j$ x+ e, x( B7 D
- #include <linux/module.h>
; W, F. {' {: h, ` - #include <linux/init.h>! y' K, l# K$ m: v' o0 t X
- #include <linux/errno.h>
& y1 P2 j7 I* S! ~) t9 h, } - #include <linux/types.h>
5 _: [" x3 `5 P$ v, L* x - #include <linux/interrupt.h>
. P6 R t5 C6 U. V - #include <asm/io.h>% h7 C7 `0 G2 r6 u. P* ~; R s
- #include <linux/moduleparam.h>
0 j! w7 L/ M5 n) p - #include <linux/sysctl.h>: L- F8 ~, y6 v# x/ {% ^4 ~% ^
- #include <linux/mm.h>
8 ?! G C. y |+ ]# Z6 y - #include <linux/dma-mapping.h>
1 B6 S3 a% T* m% a5 \, @2 [
- k& k, c4 ?/ ~3 p- #include <mach/memory.h>
8 D+ C! w5 O; H, Q* Z - #include <mach/hardware.h>* a+ q. c7 q. r4 O! H
- #include <mach/irqs.h>
6 q L& j* ?! y4 [% p/ U. _ - #include <asm/hardware/edma.h>
2 J) Y& {! x1 c6 B3 v
0 o1 v9 n2 e! S+ T' L! u- #undef EDMA3_DEBUG/ o% i1 D; t' M4 N% p u q2 D# j, ?
- /*#define EDMA3_DEBUG*/
+ s* Z! ^4 {* d$ A6 T
f9 n$ r* v+ G( l- #ifdef EDMA3_DEBUG0 Q! B5 G1 G5 e0 C6 L
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ O! q, C" L h7 ]" J* D$ [# b$ b) \
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 \) g- p7 V8 v* Q& P( V: o' H: j
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) ?6 \- Y! k; N9 }- p3 a( K
- #else2 S& `4 D: z' l8 o# ?; O4 b
- #define DMA_PRINTK( x... )
) M2 k6 W E4 @6 g2 J& i% J; O8 Y - #define DMA_FN_IN
& _8 A- e, L4 D' e! ^ - #define DMA_FN_OUT5 v; O' T g$ M+ M, \8 e
- #endif
. S* p7 {: r7 _$ o) v* z [( s
+ L U, }! y' K# H/ K- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 Y3 U+ ~1 w1 r7 A3 x7 G; I! Z - #define STATIC_SHIFT 35 c/ W) F$ ?* A- Q+ N
- #define TCINTEN_SHIFT 208 y6 k! s9 G: p+ F) R0 R
- #define ITCINTEN_SHIFT 21# P( L4 @& S6 S" g3 A/ @$ V
- #define TCCHEN_SHIFT 22 c( ~' u1 G3 o6 ]! w
- #define ITCCHEN_SHIFT 23" J" Y& x" R$ H0 ]* |/ F
2 g& P* Z. j* R _$ S* [3 a* v! b- static volatile int irqraised1 = 0;9 z$ \9 {& e, ?- i7 n% ~
- static volatile int irqraised2 = 0;6 Y1 C: n8 }8 i0 C0 | @9 P
- 2 ~$ J) S; g+ c
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& }, Y8 y8 R% C! C
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ ]; N! v5 D0 g# Q* A9 Y( [
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 R0 ?/ z6 J( w0 K, w Y
- . L% V! n9 X" b: A; c. C
- dma_addr_t dmaphyssrc1 = 0;# N/ K' o4 y6 I
- dma_addr_t dmaphyssrc2 = 0;
: W: N' W$ E- [, Y& S- C6 t; } - dma_addr_t dmaphysdest1 = 0;
: c6 ^$ {8 H( P1 G! K" C4 J, f- S - dma_addr_t dmaphysdest2 = 0;2 ~1 K2 i+ ^. }
/ L' q; C, a7 S0 R2 S6 r- H- char *dmabufsrc1 = NULL;& w0 c) Z b2 J* P: u
- char *dmabufsrc2 = NULL;
' W# R- C! t6 z9 c; G2 |/ g - char *dmabufdest1 = NULL;! B) ]# y* @) G- |' n
- char *dmabufdest2 = NULL;1 R/ w) w6 Y- t/ j
- / k* m' ~: D+ e* o: s: M
- static int acnt = 512;4 z7 ?6 |$ _" T9 u
- static int bcnt = 8;' }0 I2 ` m! X, i
- static int ccnt = 8;' `: Y. J% y! {$ M: Q& I& W4 m: s3 D
- ) R6 c8 t, F: ^1 x0 ?$ x
- module_param(acnt, int, S_IRUGO);: R+ m0 Z* K8 Y8 u/ b4 d% C; q
- module_param(bcnt, int, S_IRUGO);
3 {8 H5 s! B* n A/ |+ b - module_param(ccnt, int, S_IRUGO);
复制代码
, H+ @5 C4 r" S( K1 s3 B7 b+ \; C3 o
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
G% _9 y% l' O; P$ f: B2 X, H( t) @1 Yarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 ]8 p$ j# {' u+ h n- M& {7 T3 a 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。, @3 F9 J2 M, ^3 E6 ~
, R7 t! J1 k2 X; k U! H
& Q ?7 H+ Z2 b9 k" H |
|