|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; s v0 m+ I5 R7 o. p- H) M- [code]EDMA sample test application
2 E' b3 B3 F( w+ C' L - /*7 `9 a- B; S# I6 f8 G; ^# p
- * edma_test.c
1 _4 X" e6 k7 l - *0 \/ O+ R3 {/ D4 f9 m7 R8 V1 [
- * brief EDMA3 Test Application8 v5 c' f6 I6 N
- *" h& O4 h9 v- d" l9 z
- * This file contains EDMA3 Test code.
& K1 _) K( p3 z' A- d: Z% T - *: R( l3 l9 N* _* H& z) a8 I
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE/ \2 l7 f" c8 q% t/ [# ? c4 V% A
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
9 _( ~3 T6 X3 p+ l; t+ F: x - * TO CHANGE.
4 `) v' h/ V" T9 @/ L: G4 x - *
, h8 i4 a0 `% s9 I - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 C/ ?4 A$ D( x. z5 U/ A - *# a7 \6 H8 P, q5 ~: N/ |9 [
- * This program is free software; you can redistribute it and/or
* j/ I$ ~4 d: U% x; d% s- X# V - * modify it under the terms of the GNU General Public License as
/ J* I1 U) F* V J! C - * published by the Free Software Foundation version 2.
- c3 q9 R) \1 r! W8 I0 j - *
% l# C! T9 D4 c! m0 o1 } - * This program is distributed "as is" WITHOUT ANY WARRANTY of any7 O4 ]- w) ~6 k9 y# V* n; [% I0 m
- * kind, whether express or implied; without even the implied warranty
2 O9 l& K% I1 b% Z; u' o - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ N& h' t7 L8 z! @ - * GNU General Public License for more details.5 S0 G- s5 |7 I) n& X* D: g
- */
9 U9 E" }3 M3 W- ? - : L& a8 j% |, X
- #include <linux/module.h>
# |) O% h8 O+ C" ^. V; V2 | - #include <linux/init.h>8 d" c( W; w) y) X
- #include <linux/errno.h>/ N, X {7 y4 o" g5 V j4 F" U. u
- #include <linux/types.h>
. f2 a3 T$ P p; Q0 w4 T - #include <linux/interrupt.h>
5 {" U: \0 G/ m- E! o9 |# z5 a$ E+ M8 Z - #include <asm/io.h>* Z: ~3 _+ V" Z* g5 a8 B
- #include <linux/moduleparam.h>
% {7 P9 g+ `4 ? - #include <linux/sysctl.h>4 t! I8 O k2 x+ l6 ]5 u
- #include <linux/mm.h>: C# Y h6 x& S D K8 f$ S- f
- #include <linux/dma-mapping.h>2 X& I* }" \- y6 m3 m- L6 ~* ~' [
* s5 O5 ~7 K7 J) h" M- #include <mach/memory.h>3 S0 `" D8 J6 i1 {3 p5 K- T
- #include <mach/hardware.h>) o& j9 W$ ?* c, r
- #include <mach/irqs.h>3 Y% q& e% E* b3 I
- #include <asm/hardware/edma.h>
+ d; P( i& U9 p. L* Q' v
5 e& v( T2 T$ Q8 j4 B- m- #undef EDMA3_DEBUG
9 l" J; r5 Z$ Y2 |+ u - /*#define EDMA3_DEBUG*/
. C$ ~( \* \8 |, h7 S3 c - ; `8 Q6 R# [ r/ I7 }" ~
- #ifdef EDMA3_DEBUG' E5 h/ U |) O" f3 ]% Y
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; K) r/ W) D2 M+ p! U - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 A2 N; B- J0 l M0 d - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& X" `9 C- S. @5 v. L; P6 l1 L
- #else
) L3 Q3 J/ z( g7 T) ` V' m - #define DMA_PRINTK( x... )( R' D! i& {' t% a$ d9 M! R) {
- #define DMA_FN_IN
; `: f! f) D" D' K5 u: h - #define DMA_FN_OUT9 `4 e8 g( q, u& w# T* u* A
- #endif8 y, c8 I- R" }! p, W
) I6 d1 l( N+ I) C, T: E- #define MAX_DMA_TRANSFER_IN_BYTES (32768)3 D" A( _. X3 l' y3 Z; K/ r
- #define STATIC_SHIFT 3
7 H c) D5 O. G0 D( V& i1 b+ ] N$ Y - #define TCINTEN_SHIFT 20. H* e0 Z; z' _! \' V
- #define ITCINTEN_SHIFT 217 e! I1 _3 T* D D' G$ @
- #define TCCHEN_SHIFT 22
) h4 D, k# i# o4 h0 t% I - #define ITCCHEN_SHIFT 23
# G: @3 c" o J, ]+ c; u - : Q2 b$ d# ?- G' S) \
- static volatile int irqraised1 = 0;$ |4 V9 H6 H( _. X
- static volatile int irqraised2 = 0;1 \6 S6 G$ J5 m6 a8 e
/ r! w; U+ a# m# ?/ q, |, d- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 K- v' u2 Q. Q N
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) n9 Z5 Z) Q! O+ z! h" q
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( r0 @* S. x, L; z# T0 L7 y
0 A' y! R/ f9 g4 D- dma_addr_t dmaphyssrc1 = 0;
2 T6 G* x& Q- o$ _9 N - dma_addr_t dmaphyssrc2 = 0;1 |* ^, m6 b; `8 O; o7 p) q& Z
- dma_addr_t dmaphysdest1 = 0;
& Q) P; b: q2 X2 Z5 { - dma_addr_t dmaphysdest2 = 0;0 M6 j2 m1 C, ]. c, z0 }' a0 [
- ; l6 h3 ?/ I; D. p0 [! E5 X
- char *dmabufsrc1 = NULL;
4 i1 s, ]7 h! C7 A - char *dmabufsrc2 = NULL; a; Q; M1 h/ b5 [9 ?& U% k
- char *dmabufdest1 = NULL;
$ f& s7 h. p/ X1 J! ~. T1 _ - char *dmabufdest2 = NULL;
6 K* `, o1 y0 l
n1 A0 p2 m) Y! _7 N+ y- static int acnt = 512;; D# F5 O1 b$ Y: M. C
- static int bcnt = 8;7 K, R2 L: ?0 B& B6 O9 Y; S% v
- static int ccnt = 8;/ S8 X3 q1 R, l, k- v
- " _, e v+ s7 B F% w
- module_param(acnt, int, S_IRUGO);
% r; O1 L% W Z1 d - module_param(bcnt, int, S_IRUGO);
- }1 c% v- S0 N1 y - module_param(ccnt, int, S_IRUGO);
复制代码
: i+ R5 F0 w; i, G, \% z" j6 \3 F* R' V9 ~ ]. F
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
( a6 E# o4 ^; K4 x. l4 K. d( N# k6 @( d6 farm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* w: f5 t9 N; A f
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; W" ~4 _; n2 W
* t; Z" [; Q3 A ^
1 D5 O0 x& f1 k' F& D! N
|
|