|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 o3 A0 n& b6 |/ w& n( |8 m' p- [code]EDMA sample test application& V% o6 K1 G+ t* r
- /*
: F0 ?" p( k) v7 m' ~ - * edma_test.c
6 ?' ?. n, X+ T8 H# F5 e) s - *
. f* g' A( r! K/ @# Z3 _/ z - * brief EDMA3 Test Application
4 P$ L* X5 T1 F( w \" I - * `1 L. m. `' ~" `8 u( }
- * This file contains EDMA3 Test code.9 Q% }8 {% T" F7 e' V
- *
; z& Z1 m, F) O" | - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE b4 h# K; Z& D$ C
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! {+ t1 o( c" F3 A+ d8 t* l( w2 T6 u - * TO CHANGE./ f2 P+ \. I% R. [- a
- *0 K* Y( D3 i" N8 a
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& U& w P! U4 `% m' b4 G, r( r7 }, Y - *
: r. K( s( Q7 ^: Z0 }) P5 ~7 Z6 L3 ? - * This program is free software; you can redistribute it and/or1 q! D+ E' t+ n3 H
- * modify it under the terms of the GNU General Public License as
% I7 i0 G( {, G% u. l$ _ g - * published by the Free Software Foundation version 2.$ `2 a4 l( l, }) `5 Y
- * d1 U, a* b$ f8 c* I# c5 q" @- B
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any. V9 r# }* ~) p
- * kind, whether express or implied; without even the implied warranty
" Y$ C7 `" J) a" n1 |# _; [ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' m; @. D& z0 i4 o1 r! m - * GNU General Public License for more details.
! V3 v2 [) C0 d: @/ u - */
9 R8 W% B( r0 }* \6 A# U. Q9 J
. v, u! |+ B9 V" o% ~2 }( f- #include <linux/module.h>
. }: z2 I' i2 r2 q+ d4 Q0 i; _ - #include <linux/init.h>& o- N4 T* @/ T0 x* i
- #include <linux/errno.h>
# }' f$ H! P$ e( C& r7 Y0 v/ f - #include <linux/types.h>, s8 X' `6 z9 X/ N& j5 n/ S# r5 b
- #include <linux/interrupt.h>
5 J* k- O A3 t+ D/ C: n - #include <asm/io.h>
$ J! a- Z% l0 I# b1 B - #include <linux/moduleparam.h>
+ ]8 k3 O1 [1 x - #include <linux/sysctl.h>
# D$ }; ^5 {9 R1 x# @' Y - #include <linux/mm.h>% ^) h& o: V/ d* R2 e! D! O
- #include <linux/dma-mapping.h>
7 X* T% m% ^8 c2 C3 n+ e3 S4 H - % x' ^: R% f8 K3 N7 b
- #include <mach/memory.h>
" p* P* j+ x# x3 v, e - #include <mach/hardware.h>0 M# _3 R9 E* F p* q
- #include <mach/irqs.h>
% }/ X3 R( k& b4 ` a* x( K6 R" @' i' ~ - #include <asm/hardware/edma.h>* U' G) l! ]. N+ ~$ q/ z
- - a9 x$ `- u6 S# R
- #undef EDMA3_DEBUG
3 i5 D$ T$ N* B' L7 b J - /*#define EDMA3_DEBUG*/
( D* _ e5 q! h' { - / ?+ |6 M! n4 V! I
- #ifdef EDMA3_DEBUG
$ J3 |! c7 n& |2 \4 P7 n, _ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 S- m& x4 s# I1 v/ t. e
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
3 D0 a" g. B5 ~! K# C - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' L6 H2 o! E6 J+ \4 t# M, N
- #else
( T& C7 V1 ~4 ~5 O( d - #define DMA_PRINTK( x... )" t- u Q# t9 Z$ q7 a" T- e
- #define DMA_FN_IN
5 Y0 k3 o3 o& }! S5 F) X - #define DMA_FN_OUT
+ c% @5 j+ L! Z {. m q$ h - #endif; g7 C B6 n( z! F. N1 [, H
5 b7 `1 w' _1 j" c; W- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
& s% @$ B, s) t! D' W( n - #define STATIC_SHIFT 3
2 A: P: t+ q; o" ]8 _7 }* @8 p Z - #define TCINTEN_SHIFT 20
! [- X1 a; | v( h1 J9 }4 O4 n - #define ITCINTEN_SHIFT 212 o% s9 i4 i1 t. b2 F
- #define TCCHEN_SHIFT 22, K) k1 s+ T2 X' y6 F, H" p
- #define ITCCHEN_SHIFT 23. k) u2 l+ H2 s) g
! t# S" F9 ]# K8 j- static volatile int irqraised1 = 0;
! |( N1 f* } z1 c% V* {, e - static volatile int irqraised2 = 0; c7 N# N* `# i/ v8 @* j. W6 o5 @
0 c3 n+ q7 w6 T. `: G6 d: y* ], D- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ O) i% M8 P8 L" P& t9 F$ Y - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: W7 @2 u3 o1 M# Q5 ^( \ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ o4 a; Y) ?7 X) N, _! }& `$ R
8 s9 m2 E7 R; r2 ^2 u: ?& v( _- dma_addr_t dmaphyssrc1 = 0;8 Q9 `3 `$ y% V$ S1 z3 c
- dma_addr_t dmaphyssrc2 = 0;# ~8 \; d; z) L, U6 g: Q( t
- dma_addr_t dmaphysdest1 = 0;* j$ |/ v( h0 d. e3 L
- dma_addr_t dmaphysdest2 = 0;
2 i4 l5 T) t6 r! W2 o2 N - 8 Z( I4 e6 w0 c5 W( n
- char *dmabufsrc1 = NULL;# d0 }" O! \+ e0 ^3 x0 K
- char *dmabufsrc2 = NULL;9 `& A2 D% U" P F& [; k8 W
- char *dmabufdest1 = NULL;
1 u3 Y) n8 S6 ~2 H; `$ j - char *dmabufdest2 = NULL;2 c% p* f) v! y( n6 U/ p0 W
5 t6 a, @) z. F9 W7 w! b- static int acnt = 512;! r/ y- z; Z s
- static int bcnt = 8;" L5 u+ G" I1 L% A/ t' C9 i6 ]
- static int ccnt = 8;
/ }" E. A( d+ o6 H/ Y. V& b
5 Y9 O: \ E9 h0 G6 ^! w- module_param(acnt, int, S_IRUGO);, b# g! `: Q& l5 L+ r$ y# x
- module_param(bcnt, int, S_IRUGO);
$ W/ |& f8 X1 f/ z# ]; J$ a5 q( p - module_param(ccnt, int, S_IRUGO);
复制代码 ' e1 l/ H) E5 ]8 H, I
. }4 u( O" p. F
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! ^; _3 }3 Y8 X9 c/ warm-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 Z* r n8 P, w3 s } 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 ~- z3 [+ c' H8 a% f- a9 V
, \, O( H: e2 X* c
" R6 ?$ J; c5 F0 [1 N4 U% h4 \ |
|