|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . x3 ^& ~+ v7 ?6 Z4 w
- [code]EDMA sample test application
& s8 G; X5 ^! `" S - /*
3 f5 x" }9 {; ^! N3 ?9 e - * edma_test.c
( @, k4 |7 Z. m; w/ u7 ?- I - * d4 E C! `: @+ g% V
- * brief EDMA3 Test Application
8 W7 r" N2 _" b- f. ?& N - *7 g; y" X3 o4 y, Q8 C* t% w6 g
- * This file contains EDMA3 Test code.3 y% m8 D: Q. u- \
- *3 E/ a2 u( X( P) Q% n @3 P
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% m, g) f7 T+ ]2 e2 N, y - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT0 ~( D) L, o$ m! O8 G9 J
- * TO CHANGE.
5 ?; K2 R; L8 {. ]) U- G - *% [, y& d* I+ \
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/+ C! v8 H& C; Y
- *
! h4 |, ` L. h R - * This program is free software; you can redistribute it and/or ]! k) D; [. E; m4 N; h2 p
- * modify it under the terms of the GNU General Public License as
v P) K7 r' r! Y5 J7 M1 W - * published by the Free Software Foundation version 2.
. S+ I; r' X) i1 b - *# t r/ t+ n) `4 }( H5 {! L
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any% y, u( R9 R, w, {; R
- * kind, whether express or implied; without even the implied warranty! {7 M2 a; A4 Q) o7 Q/ U
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ g: S4 G, O) Q" f5 g" j
- * GNU General Public License for more details.
; l9 ^# q1 v) o# F - */5 J3 o& }. _7 ^# B& g- L
- & _6 ], {, F1 J" }0 w
- #include <linux/module.h>
% W8 o: h- R* ]7 j# e# T( t - #include <linux/init.h># v) C; a! w! G- c8 [6 ^1 D
- #include <linux/errno.h>
1 {2 i1 I* c! w2 G - #include <linux/types.h>
8 y2 y, o! J; @ N - #include <linux/interrupt.h>
& @+ b- o" x; w6 ~: J! w - #include <asm/io.h>& Y$ P# s2 T5 E% H$ H
- #include <linux/moduleparam.h>" u f/ S# i3 `- O3 t
- #include <linux/sysctl.h>1 r, r, g" D- S, b5 f, h7 N! F
- #include <linux/mm.h>' K3 n& }0 w2 A4 F9 c, D
- #include <linux/dma-mapping.h>4 s+ d6 T' Z w7 n( j& |; \. ]
- & L. \5 N! I) m2 J, k
- #include <mach/memory.h>
7 c; N/ V7 z6 t# u' b7 C6 T2 Z - #include <mach/hardware.h>
! T+ p. Z: A3 [$ v - #include <mach/irqs.h>
6 ^# E/ _: u; z T. ~# J - #include <asm/hardware/edma.h>
3 Z4 t) d8 O( k8 C. J. o
( `& n' R# Y1 O- #undef EDMA3_DEBUG
1 t: R: I8 N( ?: C1 i - /*#define EDMA3_DEBUG*/
- K, `7 ^7 T8 Q; J( x% O8 @6 \$ b1 ?8 v
) P; e6 N5 k9 x" i/ o8 Z* {- #ifdef EDMA3_DEBUG
8 q4 y9 z; S5 f T( ~/ x" q8 g - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)/ B7 q3 X6 h5 j/ S3 q% m
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 z2 Z5 Q9 Z1 R* S. r* o& s0 k
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ H) Z$ g/ ?! [0 M
- #else
! Z7 s0 B) k4 n4 x1 w" [' T* C - #define DMA_PRINTK( x... )
+ K2 _. ?. N) D4 U5 Z/ ? - #define DMA_FN_IN% l6 ~6 q1 j. M* u/ _
- #define DMA_FN_OUT" k( o9 _3 T4 q* ~ m- S" N
- #endif
: V) t3 k% R. y3 `& P
1 B2 J3 k& |+ Y2 D, i- #define MAX_DMA_TRANSFER_IN_BYTES (32768)! N, F# ~7 B! d
- #define STATIC_SHIFT 3/ f6 I3 a" X3 m
- #define TCINTEN_SHIFT 202 h+ b. v9 ~1 o( O- Y
- #define ITCINTEN_SHIFT 211 Q# a9 R1 k8 y' Z4 o- X
- #define TCCHEN_SHIFT 22$ C: s: H9 h W6 R* F1 u+ S' W# L
- #define ITCCHEN_SHIFT 23
/ i0 I, ]; K) Y4 ~) e
* H/ D# J) m7 P9 @- static volatile int irqraised1 = 0;
+ H9 x, Z$ e. \+ i4 e. x1 w+ a8 I4 F - static volatile int irqraised2 = 0;5 ]5 [- i% u2 M& P3 U" C' I" C
. A4 Z4 d! Y( E5 p& ?- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. [7 M# b1 V9 ]
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& V' W/ h- l! I$ e
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 Y @) v; S" f0 Q! o0 F7 H! f
+ v/ o7 a: x" o. A# e- dma_addr_t dmaphyssrc1 = 0;" @& G* j m! f, X( ~ }
- dma_addr_t dmaphyssrc2 = 0;1 Y- d5 K3 U( n0 J9 b4 x
- dma_addr_t dmaphysdest1 = 0;
( e5 h! d' J' @- q2 [* G - dma_addr_t dmaphysdest2 = 0;3 {/ [6 `- O9 W. F5 L$ A+ K; y
% n& e2 R$ R7 x: r& Q# V( Y- char *dmabufsrc1 = NULL;
4 U$ G% D; ?7 Q* q+ D C - char *dmabufsrc2 = NULL;, ]" G' Y9 @) w3 F4 S% J
- char *dmabufdest1 = NULL;7 V, g- ^: o) ~8 \# D7 ]
- char *dmabufdest2 = NULL;1 t- U4 n. o Q @
- : x' g! j) F7 K9 X \! E3 l* _' B% K
- static int acnt = 512;
( \$ u) h. g# ?( X - static int bcnt = 8;1 l2 ?: m- ~! G& r' J
- static int ccnt = 8;
, K# x4 c. V, ?1 ]: q2 i$ y - U% i3 `- _' I Z) c' q8 d
- module_param(acnt, int, S_IRUGO);
) {, G$ [% s9 ? - module_param(bcnt, int, S_IRUGO);
8 D) v4 i0 H! h* \, l2 o) e6 n3 U - module_param(ccnt, int, S_IRUGO);
复制代码
$ j& y; _1 [! W+ N
; f& x4 D8 `' i+ @; t4 I. Y 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用% M: L( x f+ X3 W" A- d$ c/ Y; H
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' N7 Q& `. |. P/ j Q 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% ~5 V9 U' l6 f3 q7 E& T! z9 k5 m0 \5 T- J, f& B) {& Y
) O2 Q! v7 B0 m+ X1 x& ]; b |
|