|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
0 o; R! ]8 l9 N, r* N" z( N0 a7 }- [code]EDMA sample test application
. f$ `% |3 r* k a) a' j% F - /*' s ?. A9 D! M( I8 b- _
- * edma_test.c
! ]! B/ S3 G1 z: R - *2 L, z) i% o+ K+ L
- * brief EDMA3 Test Application
1 u. V# o- i3 y2 H0 Y2 z- S - *8 Z3 @1 R6 a/ ?3 Q, V7 Y# `
- * This file contains EDMA3 Test code.- J: i7 r( t O. \5 }: c2 j
- *
3 {5 g9 c$ Q R) o! @! D$ O - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE7 H0 p# m% P( y* |2 Y3 \, U1 P1 Y& a
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! d% N/ b; o& G! ]
- * TO CHANGE.$ e* l: R3 Z: u5 P
- *0 W) V& P* `7 L' s
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& d% y \/ @8 \2 B3 I - *
7 s1 |% p% u+ H8 ^0 m( K - * This program is free software; you can redistribute it and/or6 a* O- N6 Q/ j1 [3 k; f8 `* W
- * modify it under the terms of the GNU General Public License as
. F1 S* C6 X% D8 F, f; J - * published by the Free Software Foundation version 2.# f3 K+ T6 p9 M% i3 F
- *
0 [8 z: ^8 ]1 B+ W: w! X - * This program is distributed "as is" WITHOUT ANY WARRANTY of any" T' `! U i d4 v! s" M
- * kind, whether express or implied; without even the implied warranty4 E7 J! S3 t% @+ H [! Q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' w: [8 ?; [( j) l8 l& R _ - * GNU General Public License for more details.0 B. M, F2 v- S/ O" A1 G4 H
- */
`$ O8 U: P7 h P
) q1 S8 S8 k* \0 m" n1 A- #include <linux/module.h>
: g# L& N) E+ I7 _ - #include <linux/init.h>
$ X2 s4 k" c- u% U0 S Q6 t( P - #include <linux/errno.h>
' M2 d' j0 S* _4 U - #include <linux/types.h>
5 Z9 ]5 B$ `. D+ U, `4 c( L - #include <linux/interrupt.h>
; q8 Z6 E4 W" d- i4 m; m+ T3 W - #include <asm/io.h>- x; y, g& |9 k" X
- #include <linux/moduleparam.h>
: h0 u" b1 I( v. J - #include <linux/sysctl.h># P+ w) s1 X, w1 O6 r7 D
- #include <linux/mm.h>
C9 i* w$ {0 q - #include <linux/dma-mapping.h>
- P9 L8 q- r4 T! y/ P# _
9 f7 T! u0 e' V! |/ d' E9 B- #include <mach/memory.h>" [* B. c( p$ F. g( ?! r
- #include <mach/hardware.h>( n( ~+ J. Y2 g6 j* E
- #include <mach/irqs.h>+ p9 ^* q+ A( M# o' l1 K( j) F
- #include <asm/hardware/edma.h>
2 L7 N. V& o, @# [
# o% X/ \6 O3 i* m- p- #undef EDMA3_DEBUG, @9 q. ~8 m0 u: L
- /*#define EDMA3_DEBUG*/: g. v1 P! G$ K3 g" S" Z* J6 ^( t
9 I) x9 e7 b, } I: Y K( P% _- #ifdef EDMA3_DEBUG
" C3 j4 E4 u% A - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)# Z+ n$ p/ a9 l# a& H" v! M( P# v! j
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
/ F% m- p+ x; r4 F) q - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)" t1 `, _ V/ M. i* Y
- #else
9 i1 J5 q0 T) V% S& r4 m. c4 r+ t - #define DMA_PRINTK( x... )% F8 p) V0 a* x2 f# J; @ Q
- #define DMA_FN_IN
$ B1 g) h, t. Q# I2 Q5 V - #define DMA_FN_OUT. L, x, \! y4 H5 [+ J. j0 p4 w
- #endif
8 i B" W* P5 N
8 s( i6 b3 P3 e- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 V( s8 s, _; S - #define STATIC_SHIFT 36 }! a }" T1 q0 P( L$ v' ~
- #define TCINTEN_SHIFT 20
0 G' q; y. e8 H - #define ITCINTEN_SHIFT 21: Y! {0 E9 n* k, q6 W5 g
- #define TCCHEN_SHIFT 22
4 U1 Z8 P) n+ {- _' _4 \ - #define ITCCHEN_SHIFT 23
$ ^& V% h3 n' u
6 }: P1 B% B, w% C$ L- static volatile int irqraised1 = 0;' z: m/ \8 G0 N8 W- P( u( O
- static volatile int irqraised2 = 0;
- c& i9 `1 ?7 G, f
: ~# D- S5 w8 c- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 n% X/ w: o; ?: z4 M* @9 p9 M6 W1 j5 c
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 U) N3 q1 s% R - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" V6 _% G, x* F1 T6 i
2 U( h' ]8 E4 }! V- D- dma_addr_t dmaphyssrc1 = 0;
8 A1 C# |4 N1 ~! j8 ~) G( i+ Q - dma_addr_t dmaphyssrc2 = 0;$ {0 J7 M, q9 J0 d9 `- I, w
- dma_addr_t dmaphysdest1 = 0;3 {0 m4 e! ?- B# f
- dma_addr_t dmaphysdest2 = 0;4 s* n, S9 w2 Q6 A
- & ]4 l3 D$ k' V/ V- M a
- char *dmabufsrc1 = NULL;9 i. y. I$ C# A# \7 m. ~
- char *dmabufsrc2 = NULL;
' ~$ i. Y9 Q1 M; L: y4 r6 M# U: l& t3 E - char *dmabufdest1 = NULL;
! k: s% f' r* { M, p: E$ S) S9 z - char *dmabufdest2 = NULL;
# o3 T2 G& u3 ~' _. M3 `" A
$ N( M& f& g0 f$ ~8 i- static int acnt = 512;7 [- s$ m" X" A$ i/ s1 `1 c$ ~
- static int bcnt = 8;
/ K& T: \* B5 j/ f2 W8 P! i - static int ccnt = 8;+ Y* d) I2 J/ i
0 S+ j: _& J9 q/ _, i: k: I- module_param(acnt, int, S_IRUGO);
( _" e) V4 N! S* E5 q# j( j- w$ [ - module_param(bcnt, int, S_IRUGO);
& X* f, F, H- G3 L - module_param(ccnt, int, S_IRUGO);
复制代码 - _ p% Y3 _( s; F4 W
" w# s5 B% R2 S# w# p3 Q
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
# q- c- P8 x% {4 varm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. L" Q/ Y1 u. P2 T8 a P 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; t0 z& z8 u. P: _; [& ?! X, r
# ?9 s2 `. |" s$ f0 Z w0 O: D* Y
|
|