|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 D. S0 M7 m1 c( Q" S- [8 t
- [code]EDMA sample test application
5 @. P" g9 ^1 U; ]+ Q( {3 i! l1 P- i4 D - /*2 M1 f' w: x- t+ n1 `( J
- * edma_test.c+ p8 Q o) f' \) V! ?$ Q; b7 e
- *
' N4 s3 I0 D s! `" g - * brief EDMA3 Test Application
# u' z8 l" ~6 v - *
0 F, o9 ~3 V1 R0 Q6 S - * This file contains EDMA3 Test code.* c# ]# @4 V. d$ x$ o
- *; c+ q o% |/ C) U
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) O& `0 A- D1 z1 _$ r
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! i9 Q8 `" H% ]: K, t - * TO CHANGE.
9 j/ }2 p8 }5 L) X- Z - *
7 M6 i6 ^; _1 y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ ^6 a6 P: H _9 u0 W
- *
0 y; b) m/ L! K' g9 J - * This program is free software; you can redistribute it and/or
w4 U: v4 r& u. {" X, n - * modify it under the terms of the GNU General Public License as
, |& r) I) |0 \+ S5 r - * published by the Free Software Foundation version 2.2 Z* z/ S- G# c8 ^6 k8 d6 m
- *
# H; S+ X4 d. t, Z$ R% J( q# I - * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 _" y/ \$ c, P; k* @& Q
- * kind, whether express or implied; without even the implied warranty
. b) k o* C* ?8 q7 o8 s - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 U% d' j6 s4 n& c2 m4 U; {
- * GNU General Public License for more details.
3 b8 M6 F; K s* w! i& R3 I0 N - */
6 O: K8 a! Y# X3 [6 }9 f; S
. A/ t. ?& K/ C- #include <linux/module.h>
* `, Q1 c) C: W5 @7 E - #include <linux/init.h>
2 t, m% d, H( C1 P5 x& B+ `! e - #include <linux/errno.h>
) U. l- Z0 o, ^; ?) m: q - #include <linux/types.h>
7 e c7 A M; Z& `4 l - #include <linux/interrupt.h>
3 \# J4 e K# S3 ?" O1 k5 W1 [ - #include <asm/io.h>- u% D5 @' E0 k% I! B# I
- #include <linux/moduleparam.h>; z( b9 S4 I+ `" V" Z) G5 s% o
- #include <linux/sysctl.h>9 y6 {; F; q( h |' y
- #include <linux/mm.h>! T( V( U1 l/ @- P: C
- #include <linux/dma-mapping.h>
2 K$ D: I9 C) ?# l" k8 S3 m
; O# Z: h4 h q0 K/ F- T d" ^- #include <mach/memory.h>( K8 M1 U0 R% } F1 Y- t
- #include <mach/hardware.h>" S' F( l* F/ F* t& j5 k
- #include <mach/irqs.h>
. C5 Y3 G I' }# W( W+ t - #include <asm/hardware/edma.h>
. m, a n3 P! A, r, m3 `" B
; G; K! \* Q2 W. D- #undef EDMA3_DEBUG( a7 D+ Q7 L7 o: k
- /*#define EDMA3_DEBUG*/
( m( q. I) u1 \2 g! n( e - * G6 n. T3 P" E. H
- #ifdef EDMA3_DEBUG; U1 j9 d+ B8 S6 l/ _4 ^6 X
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)$ p' Q% i# n) U, m
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) E% U; L |4 W+ v- v
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& {: P& d" _9 J
- #else
$ J% c8 e! e X' S2 h - #define DMA_PRINTK( x... )
! X7 w" `% r8 {8 `$ m- R" x - #define DMA_FN_IN5 ?/ W. {8 R6 G/ c" s0 f
- #define DMA_FN_OUT0 f3 g& ?- L6 E. v, `
- #endif7 I2 Z+ l5 X8 f4 f; p' z* I
- Z& u" _5 v, t6 f4 ?0 o- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. W& ?- c9 W5 ]! X+ f1 \ - #define STATIC_SHIFT 3
, p" p2 z6 \+ D( |% s% N8 X7 b. }) |: { - #define TCINTEN_SHIFT 20
2 B7 P0 t9 B; b% h/ g6 S. o - #define ITCINTEN_SHIFT 218 c+ C* c" b a
- #define TCCHEN_SHIFT 22( [! Y+ U3 c; s- z
- #define ITCCHEN_SHIFT 23
! G! P( Y* \7 w3 E - 0 J. Z$ G: d! f0 s
- static volatile int irqraised1 = 0;( w X7 `+ U8 L3 |' h8 e; V6 T5 i$ H
- static volatile int irqraised2 = 0;; O7 W$ k9 w; y/ J- K! x) m
6 g1 E" ]- r, y7 Q5 y6 c- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ d0 `" F7 w, }8 _3 x3 I( \% ^
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: O3 t- m9 V1 X3 b0 \ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 }) Q5 `+ f4 Y# x# o
- - c8 n7 d5 P( s
- dma_addr_t dmaphyssrc1 = 0;
( ]$ ]# c" w* u; I$ K! f - dma_addr_t dmaphyssrc2 = 0;
1 S2 t" v$ F' s+ E3 l! F( t - dma_addr_t dmaphysdest1 = 0;3 l4 H: ~5 x/ ]3 \
- dma_addr_t dmaphysdest2 = 0;- z# H* s) L/ T `- M4 t+ ^ r1 B4 p
# ]6 k2 }8 [. B* r; E( x4 l4 b' m- char *dmabufsrc1 = NULL;+ }6 y0 s$ C- f% d2 i4 ]
- char *dmabufsrc2 = NULL;) y9 a* ?* @: _" R
- char *dmabufdest1 = NULL;/ Y2 R& @' T) a. @3 U
- char *dmabufdest2 = NULL;
" U0 J0 \" `+ Z( S2 _) v7 g# n
0 X3 R( T K5 Y! v3 A- static int acnt = 512;- A0 h/ f! h3 _ Q0 s: m9 @
- static int bcnt = 8;* U6 q# {- P+ a1 W6 f
- static int ccnt = 8;3 I7 F2 Y" ]: S
- . l. P6 a1 S% b- X3 l4 ^. q1 u
- module_param(acnt, int, S_IRUGO);5 C( l* [ G2 {5 e8 t& |
- module_param(bcnt, int, S_IRUGO);# }& E2 ?- v; s A5 M5 y
- module_param(ccnt, int, S_IRUGO);
复制代码
! N6 E' F( G* Y; y, s. a/ W8 [8 X: a2 \9 M
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& {, d! z# ?( l, m8 z: e* 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。3 |+ j/ u) \2 ^! Z$ O& y ^; m
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 ?: ~/ O, W; k, \6 H
8 `! Y7 @( A- i3 K, c5 e0 \& y- o2 A9 S8 P, e2 B
|
|