|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
+ \& v( U9 k- J C# y' I- [code]EDMA sample test application
* B8 @5 |* C8 v. ] - /*. B9 r; q( T d
- * edma_test.c
) J {# ]! }* ~* f% V" [ - *
/ c. a, l8 {. V+ ?* _ - * brief EDMA3 Test Application: o) _: d/ M% B' G
- *6 n# v' [# S4 g. {/ n
- * This file contains EDMA3 Test code.$ z5 q' s& f# t( | k
- *8 Y$ }) J5 a% ?6 `
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE: W. r. k: ~& j2 |7 U3 \
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( O% Z0 q, U+ L+ f
- * TO CHANGE.
# _; ]: R/ \' u& E - *
9 G k0 L2 ^: C* o/ J - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 V1 x" G0 G8 t$ _- Q
- *8 b# ^: r3 o# u
- * This program is free software; you can redistribute it and/or, w8 Y3 \% e! W6 L5 q: y; S) _
- * modify it under the terms of the GNU General Public License as
1 T. i9 ]0 n$ h9 y( o& C - * published by the Free Software Foundation version 2.
7 t# f" L: \. |; C - *
8 [( }" R# p6 @5 i - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
0 M5 Z+ P2 }5 l/ U7 \; l' ^% x4 Q - * kind, whether express or implied; without even the implied warranty% z8 V7 D' x) B6 z. J8 V7 l; @
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5 { m- `3 ~3 H' L - * GNU General Public License for more details.
6 h1 ?5 W l" c1 S' j7 ^, }$ H - */
( \ q: P1 W" R
+ P/ @9 h% ~. h- #include <linux/module.h># C/ Y0 K* a. ~4 a
- #include <linux/init.h>
7 h) f- I% v% q4 B- o" W - #include <linux/errno.h>
5 `4 `* c8 l/ s8 N - #include <linux/types.h>7 a/ r6 L3 [. W0 f) s
- #include <linux/interrupt.h>- L" S/ j0 I5 Z7 v& h0 ?' e6 O
- #include <asm/io.h>6 m0 V# ?" U& v5 Q! O0 a$ V
- #include <linux/moduleparam.h>% R- \+ ]. a |0 k6 H) z$ ?
- #include <linux/sysctl.h>9 X5 c# D- S" U w. K. L
- #include <linux/mm.h>
; K' Z, L! Q6 E! l6 ^# e3 l - #include <linux/dma-mapping.h>
2 O5 C7 X3 @" c4 _6 K" f
4 V! G+ P* |( w- #include <mach/memory.h>8 f6 s2 r# s {' \& `' K
- #include <mach/hardware.h>/ W3 Z- G7 {. A; A
- #include <mach/irqs.h>7 @, B( Q# y$ O3 j4 n
- #include <asm/hardware/edma.h>+ w( @, f. |/ r4 `+ K' V
- 1 _ a! Z' w6 A7 S6 g2 w
- #undef EDMA3_DEBUG' U" J- a, X6 w7 T: E {
- /*#define EDMA3_DEBUG*/: V+ g) L9 }4 g, E. e
, T, G3 [% e! x7 S+ y q2 o2 b" A- #ifdef EDMA3_DEBUG
- M* `. I+ Y B' A& `$ Q3 {' R - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( e/ M( \5 H) m* Y. p
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! C9 n# o* U9 K! Y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 {6 g; O: U G+ `- ]$ _ - #else
% s9 o+ |) y) s" P/ D9 K1 i - #define DMA_PRINTK( x... )
9 W) M% G( q# e' m# l7 F& w - #define DMA_FN_IN
0 x. _3 [. _4 F, ]0 ?5 M - #define DMA_FN_OUT
; f8 i* q- k& h - #endif
s' D8 f4 f; E' {5 g' F - - [# u; C$ s: S
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 o( ]' r$ S R" c
- #define STATIC_SHIFT 3
% n2 L* @' `/ Q0 I# E - #define TCINTEN_SHIFT 20
: r: W9 n& I: [% \2 W - #define ITCINTEN_SHIFT 21
8 [9 P$ X2 e$ I/ C( s2 i- c4 u, h - #define TCCHEN_SHIFT 22: n t) x9 u! H& f
- #define ITCCHEN_SHIFT 231 {( P1 o$ ~# p' J/ x4 D3 ^! E
- 9 _( G$ ?( x3 K( J3 Z2 g( v
- static volatile int irqraised1 = 0;
9 B" `% m% V3 m" w" @ - static volatile int irqraised2 = 0;
( A* T! o9 z; S - # \4 p9 g$ y# n9 @$ _1 ?
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 e, Y1 N8 j1 n8 z" L) n: d - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: x4 @! W0 O; S# t( ] - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" W; _( d1 R' v* A5 v, J - & l) R: i$ E& P4 |) f, l# ^/ t
- dma_addr_t dmaphyssrc1 = 0;
. p* m% _# F$ n2 W - dma_addr_t dmaphyssrc2 = 0;
: c4 k/ h5 ~# U/ X - dma_addr_t dmaphysdest1 = 0;
4 a- U0 Y8 E7 [/ k* [5 {3 T0 X - dma_addr_t dmaphysdest2 = 0;* G2 E- i2 a3 n2 g: A, i) }/ g$ r% ~7 ~
8 H( { {3 h4 H. d- char *dmabufsrc1 = NULL;
5 i* M. b! t2 Z; e* R: ~' y - char *dmabufsrc2 = NULL;: g( y) \8 V: {; y4 y+ D* j/ n c
- char *dmabufdest1 = NULL;% C0 [: X' t# S2 ], a( m4 W/ U: s
- char *dmabufdest2 = NULL;
& ^1 j) C4 U9 q6 ?, v4 P - * C+ f' }( ?. j
- static int acnt = 512;6 t' m! i8 }$ k; r7 o ~
- static int bcnt = 8;
/ E4 P" `8 b3 q* x, {/ \( r. j - static int ccnt = 8; n& b7 U% D2 ]3 j& @
- 2 w" T) @0 `+ L; e* `# Q) v
- module_param(acnt, int, S_IRUGO);: J2 n/ [3 p$ R; s' _+ i) W
- module_param(bcnt, int, S_IRUGO);( B/ W. I, Z4 i0 D- ~4 G
- module_param(ccnt, int, S_IRUGO);
复制代码
# f2 v2 F% C9 _$ T& {& n8 x! S) Z( H5 @' H' W
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. L' O; @& M8 E3 H1 P; _4 carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。/ J- `: y* x) F
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。2 M8 T# L5 r( e
* \/ Y$ x/ F3 A9 |- s$ h
; C( M/ q8 x) T |
|