|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 {% h' v/ ? R8 A
- [code]EDMA sample test application
: {) B. O3 S) ~/ `: H7 A- b - /*( t: ~- W8 F+ u
- * edma_test.c
$ j" F% l7 B6 w5 J" g - *9 C: Z& \4 M1 x% J8 w/ J3 t
- * brief EDMA3 Test Application. f1 [, q6 V, D& u& U6 o8 x
- *
) w, X+ Y$ O: _3 R/ R5 S' s+ k; F - * This file contains EDMA3 Test code.- r& e1 q- ?& ~7 r* N
- *
5 B; W4 v4 J9 C% o7 ]$ A - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ ^# G1 s- Q: p9 Y; _3 `
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
]" `8 ?- |! i* a" Y- j - * TO CHANGE.5 r* J6 |7 g) H% u% O
- *
+ Z) j1 X/ o$ H5 T - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
7 \4 f8 |) d0 z4 w u - *, S. v* D+ a) Z% T* R
- * This program is free software; you can redistribute it and/or
. a- p1 V1 Z. @' c; C - * modify it under the terms of the GNU General Public License as
. S% `8 {8 G7 B5 S - * published by the Free Software Foundation version 2.; D8 S4 E' B' w' P. v
- *+ Q6 `- D* i7 P, m- Q
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
0 e- I5 _2 N& z* A5 r! V! J - * kind, whether express or implied; without even the implied warranty
5 o9 T# J w. a g/ g' \ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the7 ?2 A# s* |6 |- X, d
- * GNU General Public License for more details.
5 H' G* L9 {) q" ` - */ Y% v! {$ d2 D
1 T$ [+ [; G/ ~. A: j; h- #include <linux/module.h>
; p$ J0 c! ~& Y - #include <linux/init.h>+ g- l! U1 m7 z
- #include <linux/errno.h>- C+ E( f5 j, h0 T9 |
- #include <linux/types.h>
, R$ ^. Y& q% I2 s2 i% ]7 i - #include <linux/interrupt.h># ~$ t/ b. u' F6 S, c
- #include <asm/io.h>2 ]4 o$ I+ m, @* Q- v/ `0 \
- #include <linux/moduleparam.h>$ d6 I7 n0 E/ X: ]" |7 X/ J
- #include <linux/sysctl.h>7 l- E W; x8 |/ ~! x7 P6 Z
- #include <linux/mm.h>8 @' d$ |% b$ y
- #include <linux/dma-mapping.h>5 k( K7 e* @2 m8 p
. I, R6 m+ ^: h- #include <mach/memory.h>
- E, U8 [- v- e0 U - #include <mach/hardware.h>
- r( A5 h/ S& K* W$ e9 s - #include <mach/irqs.h>* p3 C& @4 y; T1 O
- #include <asm/hardware/edma.h>
, @. Z% e' K/ i; v% x
/ l5 p4 L2 f, a- #undef EDMA3_DEBUG0 D" n5 m" Q! k4 G- B" }9 l
- /*#define EDMA3_DEBUG*/7 H0 X+ ~! `$ u! S4 N A# ?
* R( `9 Y# x6 r& s& R+ r" \- #ifdef EDMA3_DEBUG
8 ^9 ]+ m# S1 ?! B - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' @" O3 o* O- s! k/ ] - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) s' z$ t7 Z2 F8 }9 i
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( x. N U H. X8 L7 k
- #else. d. w' w# x8 J3 [1 ^+ R7 C
- #define DMA_PRINTK( x... )
9 j2 z) I+ I! Y+ Y. B - #define DMA_FN_IN0 L9 s8 g6 k9 E. M/ O- n
- #define DMA_FN_OUT
# U) l/ y/ `$ B( r! ` - #endif
# L: A! }) N/ R/ ~8 K9 P - 7 ]5 F- y, i5 j9 z* z# d; c
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
; N/ @9 f% F9 |/ S - #define STATIC_SHIFT 3( ?4 b& f2 k2 N4 g! `' _
- #define TCINTEN_SHIFT 20- o0 {6 M- v4 B" D* \& x
- #define ITCINTEN_SHIFT 21
7 ?# F- V+ w& u - #define TCCHEN_SHIFT 22
. s0 `" m' l1 D* h( N/ t5 S - #define ITCCHEN_SHIFT 233 s1 H( z @+ R$ F0 D# S
1 Z+ p. P8 l6 r+ c5 o- static volatile int irqraised1 = 0;
9 Z2 Y }6 Z4 B* _8 w/ \. I$ Q: [ - static volatile int irqraised2 = 0;% h$ Y% \' E: F( N. F
- O6 o2 f, @, i5 T- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 N/ m$ g4 _, X; k
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ F$ A) S' ]) X. q2 V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; a- C% i: R$ F% [# V4 p. w
- # q5 ]/ Z4 X6 y+ ^2 J4 l* ]
- dma_addr_t dmaphyssrc1 = 0;7 F# B4 X: t0 y$ a# f! f* C
- dma_addr_t dmaphyssrc2 = 0;8 O ^& @. w6 g" r$ }/ e. W
- dma_addr_t dmaphysdest1 = 0;4 X6 G z. Y. ~5 d3 ?2 |& ]
- dma_addr_t dmaphysdest2 = 0;; S, \9 d5 f0 m
- ( @# x1 I0 K! I8 V! B" A
- char *dmabufsrc1 = NULL;
d4 I8 M% c8 F% l6 E+ d+ e - char *dmabufsrc2 = NULL;- j) m6 `* @6 t L' q+ R; U
- char *dmabufdest1 = NULL;( B; k" d& x* V0 G! R
- char *dmabufdest2 = NULL;
6 M: E0 o# ?* I2 U6 t8 q q
6 t. F% ?/ O( B0 {; X, a$ Z$ G4 F+ Z- static int acnt = 512;: A, k' [: X" I
- static int bcnt = 8;
$ ?7 `. g( _8 H. R! s- A4 @2 m+ B - static int ccnt = 8;
% E$ g, S2 a+ S: Z - ; H9 k. c+ I. C9 M8 d- k
- module_param(acnt, int, S_IRUGO);
+ G2 E" @8 f$ M: ~; b - module_param(bcnt, int, S_IRUGO);5 q+ U. {# G, L+ G {$ S& Z
- module_param(ccnt, int, S_IRUGO);
复制代码
~" z- I4 G" X! V
7 r, ?3 F4 k* y1 l: v. g# P 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" K ^# R; R B* b9 X& A9 narm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。 P7 O3 Y1 o L: A) Y7 l, V
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 o; q" O& B, ]. V" k, b: ^6 s" U: Y) Z& v4 J8 v/ l
8 z! F K* n# V. {) P+ X5 `
|
|