|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
" t* p: x/ g2 i+ y- [code]EDMA sample test application
# |5 S6 e$ r7 m; T - /*# V3 \$ `5 Q$ {- F, R2 H
- * edma_test.c
9 n% c& I% A& s& g; V! H: R, a - *4 B7 S! `6 D% ^
- * brief EDMA3 Test Application2 V& B! h6 Y$ V+ Z6 D3 O/ |
- */ z+ u1 v7 a; B9 j( b# l; t6 R
- * This file contains EDMA3 Test code.; d/ i' d# h# V+ m
- *
/ G, Z# ~) z, e0 Z) m - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! }( \# R9 d, t6 J8 ~2 e( y
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% P+ q/ G6 H% z' D8 |2 w! I% k# n - * TO CHANGE.
2 V' a/ k) \) A) |, c V- j, F' Z - *
0 S) V6 o6 Y; l; o+ a+ b! B. ? - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/: E2 m4 y! X% K1 h
- *
( L+ Y( L2 d# B2 u8 I( R - * This program is free software; you can redistribute it and/or
" m1 h( v$ a, O T9 h% a1 Y - * modify it under the terms of the GNU General Public License as0 ^* i! p8 m/ S3 k$ E
- * published by the Free Software Foundation version 2.
c- e) L2 }, ^8 Y6 e0 | - *$ U# R l) Q$ d
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, [& f6 l: D% L! i - * kind, whether express or implied; without even the implied warranty
% K+ t. N& @1 ~, b - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the4 l# x7 N+ a/ p; a
- * GNU General Public License for more details./ @+ T" W* ] b2 x7 H1 w: D
- */8 J/ i3 y: h7 G+ }' O+ r: V
8 n# b7 M; U: i5 ^9 p. w4 @0 ^- #include <linux/module.h>' N# k* s. S# o
- #include <linux/init.h>
/ r( c$ b! E5 S2 a3 M( p& M - #include <linux/errno.h>
# ]. ?8 c6 Z' K6 X) d& d1 D - #include <linux/types.h>6 A! m5 E. g t+ Y- q0 Q
- #include <linux/interrupt.h>$ v: g8 w0 q; a- S
- #include <asm/io.h>5 ^' l6 K y' u, r/ L# ?- u! ]' C; b* ]
- #include <linux/moduleparam.h>
$ q$ |4 a. W, b$ O4 Z/ I2 ` - #include <linux/sysctl.h>% N8 S5 [% d4 v* R' n
- #include <linux/mm.h>
& e! _0 ^. ^5 g8 B! H2 I# Q$ n. c - #include <linux/dma-mapping.h>
1 B2 F( q& N- I' e2 G
) [2 ] q, @/ N' ?# L( k3 S- #include <mach/memory.h>4 H' L! [8 r7 z8 F+ P7 N
- #include <mach/hardware.h>
9 @% F+ ?2 v1 R% R. L - #include <mach/irqs.h>, S4 u0 K1 w- [5 M: W0 c: B' H
- #include <asm/hardware/edma.h> U$ b: B( R9 r+ s" d
- , w* i, d. E$ o7 y4 _
- #undef EDMA3_DEBUG
" X* t2 }- y+ t9 R; [( Y% T4 b& K - /*#define EDMA3_DEBUG*/" m2 S' e2 }8 w9 ?
- ( j, ~7 @- H0 T3 J o! k6 O/ F
- #ifdef EDMA3_DEBUG
! ]! H, c3 v# E7 Q, I - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)/ n' B9 ^9 T* ^
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; I. G1 U/ p6 Y& M- R, c - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
1 g: Y# E* r0 G0 w - #else+ [% f7 p: ^+ i+ H" q a
- #define DMA_PRINTK( x... )
S' |, M+ s* }+ E - #define DMA_FN_IN
T5 t" ^, n! L - #define DMA_FN_OUT
" \1 F2 s: z" F) y9 c - #endif! w; F* R1 T: i% Z
- 0 I, z) T G; b; n$ }9 e
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)& R% u5 G, n) J& i6 W$ r) M
- #define STATIC_SHIFT 37 G; [; E3 {" O; u/ y9 I# Q. W$ H2 L
- #define TCINTEN_SHIFT 20$ M0 O8 A$ f( a5 g
- #define ITCINTEN_SHIFT 21( t/ O3 o" J4 h: h( ~- U! W4 f
- #define TCCHEN_SHIFT 22$ ^' _: D% Y& g0 Y* p& \/ x* p4 s5 p
- #define ITCCHEN_SHIFT 23
0 ~0 T+ d2 a8 V" r0 x - 1 m8 a* g3 F! P. u
- static volatile int irqraised1 = 0;
: S: r& F6 V" {2 V* W; J/ c - static volatile int irqraised2 = 0;0 n5 N3 |2 ?, b# c
2 _: ]/ i9 Z4 Z, c% B" s- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ B, g% L5 u- M ]1 B" O
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 ?5 i9 g" i1 `& C
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) x1 J6 N+ W3 [! u" C
- 5 r% H" o' M4 H& N
- dma_addr_t dmaphyssrc1 = 0;. D% f+ T5 a" {0 t
- dma_addr_t dmaphyssrc2 = 0;& W! E5 K8 o9 E3 ~) ]4 q: V
- dma_addr_t dmaphysdest1 = 0;
M" k: b, R5 G - dma_addr_t dmaphysdest2 = 0;( F* J0 K0 Z3 h4 Y; g
3 K) I6 x" _) L6 x. F/ C7 [- char *dmabufsrc1 = NULL;2 p6 N" t" C- }, |1 f& {. X( A
- char *dmabufsrc2 = NULL;% w* u, _! }& e. f* ?8 E
- char *dmabufdest1 = NULL;2 m" n. Y. h( S) i: C$ K
- char *dmabufdest2 = NULL;$ }3 g0 U2 E- s: y+ @* n( ^
6 Z0 t W! s1 m- static int acnt = 512;! b9 U# t# C& y2 G+ {
- static int bcnt = 8;3 ~% V8 x+ X2 }$ i- Q* z: ]0 J
- static int ccnt = 8;
8 p& d; F( H5 K4 c2 M1 [ - - b) e. v: k! k* a( I
- module_param(acnt, int, S_IRUGO);
/ S6 `+ d( |7 t5 t2 ~. f0 Z% ?% F, v5 K - module_param(bcnt, int, S_IRUGO);2 g; W, |% ?8 |& s5 u% u# X
- module_param(ccnt, int, S_IRUGO);
复制代码
7 ]+ `) U5 r: y" L. {! {1 _% D
) j. ^5 y) g0 T- l- L! a8 ^ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
3 K( i/ z6 U. k7 k- jarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
3 b( r$ N& L4 b9 B1 w F 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 n! X! X1 t4 H( Z- u
2 l- _9 E0 J) |! b
) O" _; E3 _9 D. P* K. H* y
|
|