|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 8 W7 N( u# {8 _2 e
- [code]EDMA sample test application
8 P: Q2 Y$ ?- Y: y - /*
- a0 `8 c. m. @; J6 B- t5 c - * edma_test.c. Y+ |' |. K& r3 G/ h5 }( p
- *
4 @# P Z8 u- T2 \$ `% K8 @ - * brief EDMA3 Test Application0 K( { @6 P4 i5 w2 Y' ]
- *
" y% {, a5 w( R, a, L% S7 ^ - * This file contains EDMA3 Test code.0 p. M" l$ i2 @+ k& Q. p' `# ~
- *
) b' E q" Q& [6 |' z - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ v( _ r- D/ z) w
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
" u y l7 s; V* Q1 N5 i) T* ] - * TO CHANGE.
3 c: Y5 i, T! j - *
0 r; d5 R4 r7 N& { - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
2 f4 S' h8 ]/ g - *
' I- g, g E8 V7 R8 L, h X- C - * This program is free software; you can redistribute it and/or1 g: ]% p/ B. G! X; O
- * modify it under the terms of the GNU General Public License as( O$ i5 N y1 F/ l1 F2 A' e6 E: Q
- * published by the Free Software Foundation version 2." y4 k( t8 E8 a: E4 K3 W: u6 H! c
- *
. }! c; y, _2 |& [% P7 U - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
" ~3 `' I* c; J+ K - * kind, whether express or implied; without even the implied warranty1 a$ b, F; \! C! V5 X: y
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" Y d0 l/ m4 d! }/ e* C
- * GNU General Public License for more details.
8 s, S) \& _1 E; g3 k( [; e3 e9 d+ C - */
/ {* [8 |. R+ ~# I - 0 l4 I7 \2 I, W; b9 {' L3 O
- #include <linux/module.h>
7 { [, N/ U' g! e0 V' P - #include <linux/init.h>: z9 s7 T1 W- m6 d) [! w. `* ^. b
- #include <linux/errno.h>9 d' i l) _; }, w. q- j& T
- #include <linux/types.h>
, q8 q% ^& n2 B/ L1 N - #include <linux/interrupt.h>
9 W7 s/ i0 W, g& f( Q. e }6 c - #include <asm/io.h>
% _0 ^" }2 ?9 J! t+ `( h: G7 u - #include <linux/moduleparam.h> H( I3 D2 B( ^+ \$ z) V: c
- #include <linux/sysctl.h>
5 Q! b4 b" F: y' N3 W9 D - #include <linux/mm.h>
! M, b h3 M/ K; Y3 Z - #include <linux/dma-mapping.h>
8 q" c9 d: ?( ]( P0 B4 w4 o
; O2 S6 u' y1 a! J. c- #include <mach/memory.h>
! K( z) a9 w0 B( w" c2 ^2 |3 l/ S - #include <mach/hardware.h>. ~7 p9 a* g) G/ F! ]7 A4 A
- #include <mach/irqs.h>+ F+ C: Q2 F/ H- s h
- #include <asm/hardware/edma.h>+ |$ \" L% D- Y6 n' J
. M' K4 u* b9 }% X. y- #undef EDMA3_DEBUG
" A/ z! w* [" I - /*#define EDMA3_DEBUG*/
( X) U" {) L7 L4 B
: Y- n% R5 V2 i K+ ~+ H5 l- #ifdef EDMA3_DEBUG
% g& |: f" M: D0 F9 Y - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) x1 u5 S9 Z3 t5 l& }
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
) N# m/ F: }4 A! W/ E6 E0 \ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! n$ z) I9 A5 N
- #else' v: _9 _. C: @* v; ^5 A
- #define DMA_PRINTK( x... )
* n3 P. m6 j7 i9 k+ o6 d - #define DMA_FN_IN, I- }; R/ w7 o; g4 k2 _- K) j
- #define DMA_FN_OUT% W3 U @1 N _- E5 T0 O5 U8 t& N
- #endif4 ^- W/ b5 Z1 X
- - [1 ?$ x L! P
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
- Q; m0 f0 i$ t' @ - #define STATIC_SHIFT 3
8 F- u" x/ l) @2 p- l& E$ X: G) ] - #define TCINTEN_SHIFT 20
' x2 o* g4 N8 ]: h8 X) e. J - #define ITCINTEN_SHIFT 21: v) {0 e' p* h
- #define TCCHEN_SHIFT 22
) E. w7 _7 _) I* n - #define ITCCHEN_SHIFT 23
" m3 o( [+ o( Y7 Z - 6 `8 O2 F& j! x
- static volatile int irqraised1 = 0;
3 N4 P* n& T* O# r, R# J3 L - static volatile int irqraised2 = 0;
6 t7 d# k1 l7 l& P
( a; p/ D5 J5 h5 V3 g- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! x- U- C2 a) m' ~/ t - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ @: M3 ~9 @! m, v
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' R; X6 y0 E" p0 Y1 d& @. J2 ~ t
" A3 X/ A0 K* c) o- dma_addr_t dmaphyssrc1 = 0;
/ P1 P! E& F2 H, Z1 `4 o - dma_addr_t dmaphyssrc2 = 0;
+ h" H& X2 }0 ^9 ?/ C7 O- I - dma_addr_t dmaphysdest1 = 0;
/ E/ S4 q6 X& A- f - dma_addr_t dmaphysdest2 = 0;. S( I+ ^1 ~$ {4 D3 G& B. T
: K, ^% y5 u" L: c2 f( @$ T- char *dmabufsrc1 = NULL;
! N8 x0 D& |% S - char *dmabufsrc2 = NULL;
* y+ V, Z3 U: v5 _ - char *dmabufdest1 = NULL;: p: H& B% K+ }0 V# Z: L2 ^4 ~
- char *dmabufdest2 = NULL;
: _9 D/ ~9 F4 O3 k
0 c0 X- v, f5 r6 [. B/ i" F$ Y d- static int acnt = 512;
1 M& z, {! g7 L! H( F- G - static int bcnt = 8;7 @" i5 _! v8 q; d C& n
- static int ccnt = 8;
4 @( L0 b$ t7 v% q - 9 ]& t8 u7 z2 E# N8 t& d2 C
- module_param(acnt, int, S_IRUGO);
' @: ~% _# x2 N( n, W0 Z - module_param(bcnt, int, S_IRUGO);; y# T) M: F. {% H3 C4 [2 [* D* C! N
- module_param(ccnt, int, S_IRUGO);
复制代码
O) S- K7 i( c; \; ]) h! N! I5 _0 a* i1 R4 h
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 P" o8 k7 D% a$ M' J
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
[. O0 _$ ]4 h) V O 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 C7 o. k! X& K9 y" A. z/ a' ?0 W
' C# r( U* ?8 R: I
6 m+ y4 }/ s# ` |
|