|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
/ s% i. G0 G9 l/ r' a" t- [code]EDMA sample test application! o8 F+ N" g: }& d7 Y: v+ G* @
- /*( x/ I7 B# S8 `4 D# b: g9 n
- * edma_test.c$ D+ F* a9 O) M
- *# e! p4 u0 l5 I ^: J/ }1 H# \
- * brief EDMA3 Test Application
- V0 x4 y1 j/ `1 Y; u5 ^+ w - *
# x# Z* }0 k! ]& b8 }9 c$ K( e - * This file contains EDMA3 Test code.% k+ f9 G1 h- b
- *
: P2 ]! x) k% T v7 z7 j* W - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE) C. f! x1 r/ f6 H
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! R- c: {- E- e- R# x1 X3 _" U" n
- * TO CHANGE.6 [! E {" R2 Y+ G7 m
- *
- S& H; S& x( O# Q% [ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 P$ \4 D# ~6 j* s - *3 k6 P2 U0 f7 j @
- * This program is free software; you can redistribute it and/or1 q- B4 g J- M5 }8 l
- * modify it under the terms of the GNU General Public License as
$ Z! @# t9 C3 N' C3 t5 G$ x - * published by the Free Software Foundation version 2.
; I5 }7 q9 E4 P& A - *
7 [! v& Y1 z( d1 t) V5 m) Z( j - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; O4 @( n; @ V# n - * kind, whether express or implied; without even the implied warranty7 P1 y$ X+ N4 d1 t6 g# ^8 V1 a
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. v( z0 X% m1 D. G - * GNU General Public License for more details.+ j& @; t5 a/ j g1 C
- */
0 e. @! ~4 {+ _ - ) Z/ A3 {+ y$ \7 k5 d
- #include <linux/module.h>
8 D, ]! B( ?# }8 r3 G6 L$ H$ ~1 P - #include <linux/init.h>
- M; t2 ]& r- S) ` - #include <linux/errno.h> S8 a- t4 B1 o; t y% n2 S* F
- #include <linux/types.h>
( l* \6 {' p2 C) N - #include <linux/interrupt.h>+ z" U# P' P; O/ G/ K8 e: v
- #include <asm/io.h>: y# b# i' B+ a) `4 d0 M
- #include <linux/moduleparam.h>8 t, ?6 j7 E5 L% O6 P( g
- #include <linux/sysctl.h>
# Z0 g' @+ p2 C6 W - #include <linux/mm.h>
5 @# R7 L, x. E7 V3 ^7 n1 b% K- J - #include <linux/dma-mapping.h>
$ S4 {' V. x9 E1 \5 ~ - & i% v9 u5 k- d8 b
- #include <mach/memory.h>% }, P* ~9 I1 U# Z
- #include <mach/hardware.h>) n4 t9 @6 ^0 [6 o# @9 `' o S
- #include <mach/irqs.h>
$ N; r- G3 Q' u4 O$ s& Y, S1 F) Z$ V - #include <asm/hardware/edma.h>; ~" i" z8 J6 S/ M! s
8 J& X q9 R; A3 C- #undef EDMA3_DEBUG
% f, h: _0 V2 E - /*#define EDMA3_DEBUG*/
6 ?4 g9 \3 a/ r+ w0 L7 K% F
' i7 v6 F6 W; ?! Z6 _$ N3 a- #ifdef EDMA3_DEBUG
9 N6 M. d1 |9 n - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 ~$ I. w7 m: f0 e+ I. o7 n$ n% v( u9 d - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 G% k- w% e4 { - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)+ ` s5 P- E. O7 r* h& F2 ?% m
- #else( g/ _9 z, j3 M! u( t
- #define DMA_PRINTK( x... )
% q" m5 U& f B - #define DMA_FN_IN
7 ^) j: m+ l7 m5 M - #define DMA_FN_OUT
7 M1 ^3 m. e" t4 A/ r - #endif1 s9 |4 ?/ i! b1 r. o
3 z' S. t. _' C2 M- O7 k, o- #define MAX_DMA_TRANSFER_IN_BYTES (32768)& `2 p; P* U3 ~
- #define STATIC_SHIFT 3
0 t6 b+ d+ f: r$ O4 p z. ? - #define TCINTEN_SHIFT 20( i+ B: Z3 y2 J/ d
- #define ITCINTEN_SHIFT 21
5 O' C7 E: X+ W% H$ ?0 u# _! X - #define TCCHEN_SHIFT 22+ J3 a8 V5 T% ~/ Z4 x5 I
- #define ITCCHEN_SHIFT 23
+ j/ p* x! K( p' f5 U* W2 o9 Y - $ N" W) Z$ C; A# X- B5 J
- static volatile int irqraised1 = 0;
! E2 |( _. H& d X( F/ v0 j2 A - static volatile int irqraised2 = 0;! R u5 ^) \$ _' q
# l, N# a6 J+ n( I8 L4 m- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 ~6 G( R! p. A8 c F8 M
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ B- A X' ] p9 z5 \+ ? - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ l, Y7 C0 S& S! ~% ^
o+ D5 b# `$ g4 c9 w3 y& Z, q- dma_addr_t dmaphyssrc1 = 0;
) q2 v0 N3 ]' S) m9 l - dma_addr_t dmaphyssrc2 = 0;; q* H9 Q7 O! @& g: c
- dma_addr_t dmaphysdest1 = 0;( m9 B U- U2 u$ Y7 y0 d
- dma_addr_t dmaphysdest2 = 0;
7 ^( F* \. b, p) f - $ ^- L7 ~1 C# f2 V2 S' Z; ]* q# o
- char *dmabufsrc1 = NULL;1 [! r% I0 D8 Y# i/ \/ A, q
- char *dmabufsrc2 = NULL;
$ I1 t+ r( ~* z1 T: @ - char *dmabufdest1 = NULL;, O5 O2 ]3 M' X
- char *dmabufdest2 = NULL;: Q+ O/ B; i! S1 X
- ) |) V" o+ ]# @8 ]$ j+ O
- static int acnt = 512;# K; p# y O* [9 @% e* D5 m
- static int bcnt = 8;2 V* P+ S1 D7 g
- static int ccnt = 8;
6 j) Q; K- z+ i, w' m/ c. j - ' x" p* ^6 N& }. k
- module_param(acnt, int, S_IRUGO);+ x' \2 H0 h$ C: z
- module_param(bcnt, int, S_IRUGO);
' V/ t8 ^2 H6 Z- S" z - module_param(ccnt, int, S_IRUGO);
复制代码
: w! B+ u; n# n& l8 z
( Q$ X) ]7 Z6 G- K( d 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: j0 ^" y; Z2 T9 k* J5 Larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: Z& t* K2 v) P! c. N
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 H$ g5 k: n" r7 |3 H# ?
, |0 { A4 X; X% @/ Y2 w {* ~
& V4 [' t- l" F+ l) x; A5 B& c/ ? |
|