|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . ~3 e$ A1 ~+ e
- [code]EDMA sample test application
; w1 A4 U! _' m% _ - /*
: \2 ]+ S$ C: O, Z# z - * edma_test.c
. Z% Y' I& C" T ]* D8 C - *
2 _5 W0 R; D) s" p% _8 r# S* G9 p5 J - * brief EDMA3 Test Application3 V, K4 c% U6 @, @
- *, Z$ I3 G6 L5 A- o" P
- * This file contains EDMA3 Test code.
0 w3 p$ Q5 ~! `- m - *
5 c& Z. p: [2 N - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% Q/ g* g- E4 Q2 b. \5 C. n8 t1 l) I - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT- f6 z1 X! W9 Q, Q3 r- u6 h% l
- * TO CHANGE.
5 O: l4 K5 j4 m9 h* \* y$ j - *
- K: d* J6 L% B! j - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* g; q9 Y$ l, K8 S
- *5 j, J6 s- l8 U4 d4 B* K6 c( `
- * This program is free software; you can redistribute it and/or
! s3 J' P+ G) {+ Z/ Q. { - * modify it under the terms of the GNU General Public License as
& f* B; ~; L, ^* n - * published by the Free Software Foundation version 2.0 G0 A$ e* r. C5 V
- *
1 {, e, a6 a ~: m) N | - * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 |" X4 U+ A2 Q: A" o4 k6 V9 X# E
- * kind, whether express or implied; without even the implied warranty A, n2 A7 o* Z: m
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# J) d, v/ a5 E1 a+ ` - * GNU General Public License for more details.2 G9 _" K1 T3 y; i4 p4 _# O
- */
0 o/ W( ]) {8 {' G - 7 [+ ?$ L3 `* Z: M7 D9 p
- #include <linux/module.h>
8 p; U4 n! i5 c8 v - #include <linux/init.h>3 [* B$ k& H" j) C J" T7 J! Z/ j
- #include <linux/errno.h>6 O S6 D* a% x% i5 e" W
- #include <linux/types.h>
5 S) ^6 u$ Z7 \4 s: O. K - #include <linux/interrupt.h>
7 i+ J) a; t! O! C: o6 \* N. C - #include <asm/io.h>
& ], l6 K% @/ P7 _8 w3 ~7 m# k3 z, L2 _ - #include <linux/moduleparam.h>
3 ]3 M, S9 k3 ~6 x: x6 v" u - #include <linux/sysctl.h>) F' a- p4 Z$ I6 A# K
- #include <linux/mm.h>
" I* A) N: q- F0 P' i3 a \" ` - #include <linux/dma-mapping.h>
+ z4 B4 A7 j, n+ G2 A7 ? - 8 ~. v6 K4 ?5 j
- #include <mach/memory.h>
% `3 E# r' ]6 }: U( [ q! x - #include <mach/hardware.h>. R4 ?9 g _, k
- #include <mach/irqs.h># ?! Q) F1 b0 c/ P' {% l
- #include <asm/hardware/edma.h># L. Z) O9 S9 C
- 9 m K0 S5 a" M- Y) p
- #undef EDMA3_DEBUG
' r* Z( P) c! u$ Q2 R8 j& h - /*#define EDMA3_DEBUG*/
4 O' `" H- R7 I+ e$ q0 @ - 4 f" a# C0 m! ^" x# A( N5 h q
- #ifdef EDMA3_DEBUG) K- n9 {! C2 ]6 P
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
9 u1 w' V0 B4 B& a - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 J" I- V& G- B) N; p' G
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 \# z& P- Q, s' j8 Z5 u
- #else
7 b0 w& W$ z) D* l; s - #define DMA_PRINTK( x... )
" j1 |7 r# b1 z - #define DMA_FN_IN
! {2 }( n- g& ^ - #define DMA_FN_OUT* u; z' X( }+ o7 y- K, P
- #endif
6 B k# f+ g2 p& U. P( R - P( P8 J4 H0 i* k0 O
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
$ ]. J/ G) X* l - #define STATIC_SHIFT 3
" J! G; E1 o* k& \ - #define TCINTEN_SHIFT 201 I; Q# f& `6 e; Q( \
- #define ITCINTEN_SHIFT 21. P* c3 D$ H% N" }% b
- #define TCCHEN_SHIFT 22
2 r; B9 X6 Q; I+ B2 t' F& K5 u - #define ITCCHEN_SHIFT 23
. K. Y) `/ q5 w6 F. z w( v
Y; y+ l% [5 P$ \- static volatile int irqraised1 = 0;
% j: T# R" f. A" t5 v# F% I6 y - static volatile int irqraised2 = 0;9 E- @# K7 K! M' R* R0 s
4 a5 e9 ^3 K$ r5 E# z" v3 D4 {- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( R) z, X) C; l- q, i) @ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- i2 `& D1 m+ R" d# Q* w4 ^ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ S6 A, [ v3 x1 j/ G8 p' G/ n: g - " @% Y) m2 |" K% E. |
- dma_addr_t dmaphyssrc1 = 0;, u! R! x% j( o0 j, ]% l) L' ?; W
- dma_addr_t dmaphyssrc2 = 0;0 K: c! h3 V% u: H0 y2 z1 W/ \
- dma_addr_t dmaphysdest1 = 0;) Q: Z' v' _6 E* |! [
- dma_addr_t dmaphysdest2 = 0;
/ s' x. j H0 Y7 U - " |) F9 g! a. o2 t) D! u6 c
- char *dmabufsrc1 = NULL;9 e+ c/ S; u: G3 O' r& B
- char *dmabufsrc2 = NULL;3 S. B( L0 M9 u. S7 R# U! g+ n
- char *dmabufdest1 = NULL;
7 m3 | Z# T& B, X - char *dmabufdest2 = NULL;& G4 s' w( A8 O8 g7 D
+ f- W4 Z' n7 p! m7 `- static int acnt = 512;3 B2 f3 }1 h. j$ ?
- static int bcnt = 8;8 ^1 {$ E! J: o# c/ U8 n
- static int ccnt = 8;
2 m8 `. _! J' h2 q8 v5 ]6 s% N - + d4 Q! x+ O: U7 }) B$ i
- module_param(acnt, int, S_IRUGO);, Q Z2 Y0 a/ ^6 J& o9 `
- module_param(bcnt, int, S_IRUGO);5 w1 p- E# x9 q9 b1 g% {; C
- module_param(ccnt, int, S_IRUGO);
复制代码 " {2 X. J7 j q0 @2 {' V
! ]& ~- U- G. V Q1 K+ \6 } 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 \; D8 C& b+ X- B, s
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。. b. I* l* }9 j! }0 ^2 H8 l4 b
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& J# E) Y* E7 ~# `7 C+ R0 K6 |) Z
1 _: L$ _, ^% ~. o! A& @, h" X
* o5 R" \0 v9 g( U2 V2 W" n |
|