|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
) @& c+ k' |0 Z; v, l9 b% ~- [code]EDMA sample test application
x# @8 G1 H5 J3 M8 N - /*& x+ |" F" Q) P1 n' `$ X( |
- * edma_test.c
0 S) ]1 L" t( K# i - *, h( _6 ], j+ z1 N) r6 L
- * brief EDMA3 Test Application
" E7 P0 V$ X, ] [8 s- K5 h - *" Q+ b s* o1 M! D, I$ J
- * This file contains EDMA3 Test code.- D- a, N4 y2 O
- */ I7 p& d) x- J* _& V' |$ W
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE, S, ]: J0 w$ H, L% F* S
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
. c: |2 g! O* P+ N; R - * TO CHANGE.
4 X$ v. c; R. w* F$ ^0 Q# h - *
S S# y W; H - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
( r% _- B: ]" w" w+ t$ A+ f; N4 R - *
- W1 U, y j; V, ]& a8 w! P$ ~+ e$ Q - * This program is free software; you can redistribute it and/or
2 k6 {6 k* F. d$ R" L! c8 b0 a - * modify it under the terms of the GNU General Public License as
6 n! B, [( c$ Z; l4 ^ - * published by the Free Software Foundation version 2.' g$ w ]/ F( o7 Y8 @
- *
' R$ ^; l/ f! |5 u - * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 W. G4 q$ R* g- m, |1 e$ k
- * kind, whether express or implied; without even the implied warranty, q1 V7 t0 \7 g0 w' k- g
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; u4 R, U; z2 D9 h! }) h - * GNU General Public License for more details.
/ Z+ R. \ d/ J* z" f' v - */- W$ L! e! O4 |' c
( q0 m4 U2 O7 e1 x& g- #include <linux/module.h>
0 K4 H$ h2 X Y6 A8 R6 o - #include <linux/init.h>2 O/ E: ^: k0 P* f( C7 g. [, x! I
- #include <linux/errno.h>/ H0 \( ^1 e$ o$ [( N
- #include <linux/types.h>5 K; v% m0 b( x
- #include <linux/interrupt.h>
+ _3 O5 e/ I$ R/ | - #include <asm/io.h>0 j% X: i; D* P
- #include <linux/moduleparam.h>. R* v E; d/ `1 l3 J. l
- #include <linux/sysctl.h>
3 J3 E) c3 I7 y9 [6 o. L. W% V6 ^( y - #include <linux/mm.h>, }& t. z, G) K; a0 Q2 T
- #include <linux/dma-mapping.h>2 B7 {4 j/ q$ c/ ^! M' o
( L. ^, O$ e( L# A- #include <mach/memory.h>
2 }% P' u8 x/ _! f, E' M2 o1 M - #include <mach/hardware.h>
7 y! C6 w5 N5 z1 C1 l% p9 e( U - #include <mach/irqs.h>$ e$ E% a ~ |) i; A0 R
- #include <asm/hardware/edma.h>
w" A" n; d7 Q2 x% K2 h |
; i% V' z3 R! `9 q6 ^" d& N# b' N- #undef EDMA3_DEBUG' s! {% |: n: J a+ L
- /*#define EDMA3_DEBUG*/9 W' O. }+ u! D
$ N$ a* {( _% K- #ifdef EDMA3_DEBUG1 g0 a }( D& F' l
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
l5 J/ q2 t& I C6 c- Q$ p - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
6 u3 N4 m& G9 y1 ?- R - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' g5 _' p1 }% Y. A9 d9 O9 P
- #else3 | Q2 c9 [0 H) @- M" v d
- #define DMA_PRINTK( x... ); D$ ~% R! i: k& [0 C/ s( D9 A$ ^
- #define DMA_FN_IN
8 Q1 Q" }2 ?5 Q) n0 m$ W - #define DMA_FN_OUT
: n! @- m' x$ b; |& h! h4 e& D - #endif4 X( b" a8 ?) ^7 J7 v! U {9 ?
8 V1 b6 [$ X6 _- q# ?* \- #define MAX_DMA_TRANSFER_IN_BYTES (32768)1 Q& y3 |4 q- k
- #define STATIC_SHIFT 3
; y% t) `; V& Y" p4 G$ V - #define TCINTEN_SHIFT 20/ P9 F5 c: Z u+ V; e
- #define ITCINTEN_SHIFT 21" y# g! b, O6 {
- #define TCCHEN_SHIFT 22
; p9 h: a0 _7 e4 }3 {9 I - #define ITCCHEN_SHIFT 23. C2 ~* z0 E; J0 T+ g. r
- 4 ?- Q! ~# k" T7 x$ B
- static volatile int irqraised1 = 0;% D1 e9 z8 ~: X# q2 G1 p h+ H
- static volatile int irqraised2 = 0;
& Y! i0 Z+ B3 |8 ~
x0 M1 H' P* N" Q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# l' s9 O( T( U
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ N- W' W: O3 u# p - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 c6 R0 ~- ]0 G9 [6 r' l - , X9 x8 e3 Y2 ~8 I ^2 e
- dma_addr_t dmaphyssrc1 = 0;
r# z, g ^8 o( v4 s, z0 W/ \ - dma_addr_t dmaphyssrc2 = 0;
" b( \, b6 ^9 r' N0 ^8 x0 b P - dma_addr_t dmaphysdest1 = 0;
& R9 {: ?; y( V- g - dma_addr_t dmaphysdest2 = 0;1 H9 a# o( F( v$ F# c
( X# J3 \2 x' B% [3 @- char *dmabufsrc1 = NULL;0 f' I: y% V4 q8 r2 Y3 k
- char *dmabufsrc2 = NULL;
. o) b2 [, C B( o$ A* Y - char *dmabufdest1 = NULL;' C; I1 \* r: O3 v! R
- char *dmabufdest2 = NULL;
% g8 T' S) h! A ~1 u+ g' X
: P# t; v3 {* ^6 w0 p! }( s- static int acnt = 512;
( u9 I5 |$ h/ X1 n1 q - static int bcnt = 8;# c- \' Q! O. L* s6 a( M2 B+ ~, B ]
- static int ccnt = 8;
, x0 L. A5 ]9 f2 }! L: n - # |! O% o( p3 c0 M Y
- module_param(acnt, int, S_IRUGO);- j6 M% d. ]. I' N
- module_param(bcnt, int, S_IRUGO); I5 y1 z& v. y E( A
- module_param(ccnt, int, S_IRUGO);
复制代码
' B( k" `7 }3 ^0 \
' V0 w9 ]" S3 r" q 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用- E' T) z2 H; i
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 J, l4 u$ h) b# Z9 Y4 P 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. ~" O: O" g1 v
% O. ^4 |; y* D
1 T8 U- @% r- X( F" T# w- } |
|