|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, |* X$ f" o4 @- P- [code]EDMA sample test application
5 ]; S; o. P* U+ t4 b - /*
5 V" m- _+ l1 @ - * edma_test.c
4 N( C8 _! D1 }$ j: z( u - *
' [; C/ A& U5 |* f+ ^- @ - * brief EDMA3 Test Application
3 Z- A& [( r) @ k" i# K - *
5 z0 E+ G8 A" M3 I/ I - * This file contains EDMA3 Test code.
) x$ y# I- B6 F3 n - *' L" O: @; W: C6 h9 S
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE8 I- _- w5 o! i1 J7 e
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 ]6 t" E7 d; Q& k# Q
- * TO CHANGE.
6 R; \, z0 K, {7 q: Z - *6 A5 N d8 C, w6 |6 g* A
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
: n" h! t" F4 ]% v - *2 q! w! m$ X+ N* f; R
- * This program is free software; you can redistribute it and/or
/ a! e6 I3 d* l6 r - * modify it under the terms of the GNU General Public License as
5 V9 R, W1 s' d; a( D) p - * published by the Free Software Foundation version 2.
0 @0 {% m E( Y3 n) | - *
7 {6 _7 Q1 c4 X+ T! {9 s2 z - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
g4 L0 [7 t, o1 E9 _! w; [1 @ - * kind, whether express or implied; without even the implied warranty
6 m d" {" K' y9 @" m3 t j' n - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 @8 V5 t9 L9 o4 }! _, ~# x$ [
- * GNU General Public License for more details.7 K1 s' J$ ?0 h5 k# Q) h6 z
- */' j$ m, X# }! C/ d5 F
- & E" d& ?7 a) v
- #include <linux/module.h>
* r, a! {) X) e: v+ X' L$ r" d - #include <linux/init.h>8 R; I/ z/ }! [3 t% R
- #include <linux/errno.h>: U: \' E: H4 r
- #include <linux/types.h> p& ?! y+ t! r: w
- #include <linux/interrupt.h>
$ w7 w/ R" {6 u6 f - #include <asm/io.h>: y/ R+ G$ D$ c0 Y! I
- #include <linux/moduleparam.h>
" k/ |# L' j4 ^, X& ] - #include <linux/sysctl.h>0 _7 L5 w6 @. F5 N7 L) B2 @
- #include <linux/mm.h>6 h+ V. r, N/ c, s' E2 J
- #include <linux/dma-mapping.h># T U' j+ ]6 |# _. ^7 t. C2 `
( Z" B8 [$ ]/ {: Y8 X5 V7 e3 M- #include <mach/memory.h>
+ ]2 K5 t' p* y3 @ - #include <mach/hardware.h>/ |5 \; j' I1 q B' Q
- #include <mach/irqs.h># Z: a- |7 y5 h* W i% r
- #include <asm/hardware/edma.h>, s. G* P9 K, S* Q: N: H8 F
- 8 d. D$ s ~( N7 Q+ ^$ I8 X
- #undef EDMA3_DEBUG
. H) k$ y" `; E1 @0 {" c8 D - /*#define EDMA3_DEBUG*/
$ g1 H9 T% U+ Y. X* O- }% }- J - s1 }: `- c+ w
- #ifdef EDMA3_DEBUG4 `+ ]3 i6 Z7 Q. p* w9 ~! H
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
/ w3 I8 F$ L; x9 K* f* V( w" s8 z - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 {: w' }- U/ \& H1 w - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)9 z8 T8 V; }+ n( Y" P
- #else( A. `' u0 s' l; L/ h' a+ }
- #define DMA_PRINTK( x... )" N$ Y& L( [" B3 @" m' [0 @5 r
- #define DMA_FN_IN
) ?' Q1 X- v& V - #define DMA_FN_OUT0 v C* G; H' ~/ v4 M5 P5 i
- #endif
+ B, k6 G. z' Q5 s8 c( i - 4 p _; h7 V @4 J9 w
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ W+ `* C" d3 j5 U8 K
- #define STATIC_SHIFT 3" e, d- k/ E: A$ X% E" E, |, y% C
- #define TCINTEN_SHIFT 20
9 w4 e. `( ]. f - #define ITCINTEN_SHIFT 213 Z; f& O9 l% j
- #define TCCHEN_SHIFT 22( ?0 W/ u+ ]/ L; u4 N5 Q/ W
- #define ITCCHEN_SHIFT 23
" w% }& F# S% e+ v6 E0 @' K
/ r1 w. R! U+ n, z! e/ i/ N$ E- static volatile int irqraised1 = 0;# H! t8 W# f( {6 Y# l/ Z( Z" Z
- static volatile int irqraised2 = 0;
; e; k) ?( h6 z4 t7 f2 g2 P6 B - 1 a: r0 m. S( [' y8 [- n
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 _4 j6 z2 J/ B& [: H7 H Q - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& t( M) X+ t& T* t2 G0 i' F
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) s0 ^/ X9 e" _- E' F! \3 x
7 t" g9 O5 f( M- dma_addr_t dmaphyssrc1 = 0;7 n! u% a$ c$ k" f$ U% a9 E" w
- dma_addr_t dmaphyssrc2 = 0;* W6 S1 d9 s" A, V
- dma_addr_t dmaphysdest1 = 0;# r0 u9 s1 j# q2 K7 b
- dma_addr_t dmaphysdest2 = 0;
% V/ K8 U9 D6 ?. d; t - - j. @0 u& Y6 l6 d8 B f r
- char *dmabufsrc1 = NULL;
" d w- d7 Q* ~ - char *dmabufsrc2 = NULL;* o4 p6 k' [, M1 { q* v
- char *dmabufdest1 = NULL;3 V N7 ]0 T+ l2 a* ]) K
- char *dmabufdest2 = NULL;
' S: D2 |/ h! i* H1 ~' S- k2 l4 y0 p7 s - 6 ]4 U [. o; }' S% ^& K3 L( L6 [
- static int acnt = 512;# }+ t$ ]; o* T# o$ N
- static int bcnt = 8;( C) y" M# [/ W
- static int ccnt = 8;) N& B- W7 t+ E, n- L2 r$ I
- ! Q% `$ U6 T0 v
- module_param(acnt, int, S_IRUGO);& M' c; t4 W o1 ~" ]
- module_param(bcnt, int, S_IRUGO);
- U% G! p6 K8 J/ U/ |# W+ W - module_param(ccnt, int, S_IRUGO);
复制代码 8 T, e7 X6 C! n, r* q9 t& K
3 Y& ~: _' w4 J1 r! L/ G. }6 B
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& N& L' ^ x0 q
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。6 {0 |7 p) [8 j6 K1 M
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 k( i" _& h& D0 ~9 f" B- v% h4 Z
, @4 w# e& }8 b: T2 ]1 O
& `) l m5 m, T- d6 H0 Y
|
|