|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 r. K; y" @# [2 c- [code]EDMA sample test application! V% {8 p8 w( `* H( I1 ] I4 i
- /*" S5 M; R" F' T: D! T8 n# N) g3 k' v
- * edma_test.c
" y& j1 D3 u5 N& L% H - *; Q, [, G* T2 B3 j6 U7 A5 e
- * brief EDMA3 Test Application
- G. J$ Y+ W6 a- ?4 X - *4 d, q: |6 q4 E9 B
- * This file contains EDMA3 Test code.( C/ I, c' D( Y4 t6 n
- *
4 g; {6 ]# k/ j3 Z, b3 f - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE$ o( s$ h* T6 P' M% v( Y
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 i; H+ k, ?. j0 N; p1 J
- * TO CHANGE.) E2 h& x l1 b' {% G2 g/ H8 l" W
- *6 G2 B+ z7 G& X8 v& q2 C
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/. K g4 ]6 F/ P& p% Q5 a
- *; z3 R/ C% X0 w. J
- * This program is free software; you can redistribute it and/or9 M/ L; j: E3 }+ C: v. Z8 e( G) k
- * modify it under the terms of the GNU General Public License as9 ]9 U) z% K- z* i% K
- * published by the Free Software Foundation version 2.
+ T9 \3 }/ X% {0 h - *7 P+ l2 H" e9 d* a5 L3 A2 t
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
* c: B8 [# g. ^" @5 J - * kind, whether express or implied; without even the implied warranty
' f. i( j3 J r: y6 {7 q - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# e1 }8 ]# g3 R1 i t# \7 Z
- * GNU General Public License for more details.# r" _/ c6 e5 ~0 B4 {# B) q( C
- */1 n% u0 q6 o3 V$ [
+ l; Y- o! F0 l' O- q& K- #include <linux/module.h>; W) e4 ?7 ~3 i* A
- #include <linux/init.h>
# `6 h5 E+ R4 x5 Q8 E - #include <linux/errno.h>
+ |: i4 v; U3 _/ i2 w6 T - #include <linux/types.h>
8 h7 W- o$ Q- {( \ - #include <linux/interrupt.h>
" x) P9 U' K$ {! S - #include <asm/io.h>
: k2 A- n! I" J0 @7 n+ A - #include <linux/moduleparam.h>
) e& G0 C% L( H* [/ C; `) F/ t - #include <linux/sysctl.h>
/ `# N' U m4 z5 t3 v - #include <linux/mm.h>
o: f6 P% G) J) K, a! J5 _ - #include <linux/dma-mapping.h>5 L* }$ G+ Q- b9 l8 D" o7 f, N
/ k9 R$ A0 z8 U" A; @- #include <mach/memory.h>
; ]3 r1 _& h3 Q - #include <mach/hardware.h>
$ f$ ^8 O. y( N: c - #include <mach/irqs.h>
]3 }! a8 e' y$ u ?1 a' _ - #include <asm/hardware/edma.h>' |" L$ H4 N8 ^ X2 G( \1 h
- - S7 [5 `0 W3 S" u$ C1 Y5 P
- #undef EDMA3_DEBUG+ H* Q2 B% A, ^* ] p: a
- /*#define EDMA3_DEBUG*/2 z% | ~" S( d- d
1 b7 l6 f7 d9 F$ q# k5 x- #ifdef EDMA3_DEBUG: D' n; i) Y' m- U% s! Q$ w
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
) Q7 \4 a1 D9 ^; U0 i) h: R3 b - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
) L/ c ]; ^8 Z& Z4 k9 Z - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)0 h+ ?( z' _+ T7 |: A: C$ t1 Y
- #else
& `! J. B! l. M) }/ t - #define DMA_PRINTK( x... )
7 A p( M6 [' e# ] `* C - #define DMA_FN_IN! @( Q; m N- I" i
- #define DMA_FN_OUT
: n) V% G0 A2 D4 ~4 X- C3 j0 n$ E - #endif
+ q: h; l; z- a1 H; ?
0 f2 Q, r% K1 F, k' k- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 H. Q- T# h" N - #define STATIC_SHIFT 3
# w# X) N- k$ F. f% _9 ` - #define TCINTEN_SHIFT 20) [3 d, |) i" J" }: z0 c/ e
- #define ITCINTEN_SHIFT 21% f% ]# k: S& M' g, B6 C7 N1 W! y
- #define TCCHEN_SHIFT 22
* C2 y2 I# x1 Z5 Q9 K, |& w - #define ITCCHEN_SHIFT 23" e/ j" ?5 E6 ~, g$ L' p* p: c
4 W9 s: a, d$ J% B2 D o- static volatile int irqraised1 = 0;
6 x, R) C. ?. M - static volatile int irqraised2 = 0;
5 j4 j9 p$ u" q7 [- R& | - ! Y: V2 K8 F, {. {& `' i: ?- u& ^
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); k( w- F8 J6 g: [* i2 ], M- a" i+ p
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! z! L7 M: B! H3 L - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- e! s4 a1 K5 x
- ( O t3 S6 N! Q# l- U* w
- dma_addr_t dmaphyssrc1 = 0;
; L7 r3 F4 H: v# ~% M% r- p - dma_addr_t dmaphyssrc2 = 0;- R5 k9 ^4 }5 X( h3 Z4 f9 n
- dma_addr_t dmaphysdest1 = 0;1 G: l" i5 s& \$ d. ^7 @6 s
- dma_addr_t dmaphysdest2 = 0;" A/ n( n- G* u; K1 H4 ` t
7 {: D6 U: `( Q- char *dmabufsrc1 = NULL;) Q& L/ G5 D/ Q* P4 }
- char *dmabufsrc2 = NULL;
; a; U" v& Q! ^! @" p: n+ j& E - char *dmabufdest1 = NULL;+ F$ Y S. r" B, n
- char *dmabufdest2 = NULL;" W1 w5 I+ j1 @, W. x
- # t) U& z3 I% E/ j- A
- static int acnt = 512;
1 n. \2 y7 i: G; H/ S5 n/ N - static int bcnt = 8;
9 D, Q4 X) f% ~5 _% W - static int ccnt = 8;
2 N. p/ D5 M( f- a$ s" [ - / n. ~/ F6 {7 D3 i+ a
- module_param(acnt, int, S_IRUGO);
+ F+ O7 j Z! b3 z; x+ P7 W2 m$ F' a4 g - module_param(bcnt, int, S_IRUGO);
) J& v9 t8 J. F% Z0 @* o7 `" m - module_param(ccnt, int, S_IRUGO);
复制代码 & `4 @ _8 c/ y& M) n% v/ N3 ]
# H2 a$ z9 ]% p1 [0 @1 N" Z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用; C1 Q: [" F, B1 D' E' Y- w/ q# T
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% s3 h+ i8 W0 y! Q% D0 d2 W8 f2 w 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: b1 l& M* f" d5 l6 S( M2 \
- t! M3 t; m, O% e3 X! j! U
, ~6 Q3 a. e& f8 F$ L |
|