|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
: \* \3 S- V6 z: e- [code]EDMA sample test application
1 T9 T0 y) ^4 i; R - /*
' i$ l$ u" y# r% l# w( q - * edma_test.c5 p6 r7 \) V7 Q- Z& }% `
- *0 v3 \0 B* w2 a$ _2 K! L
- * brief EDMA3 Test Application7 {4 D8 r8 D* a$ H
- *
0 G8 V- D( I/ N3 U& u - * This file contains EDMA3 Test code.
/ B. t; n1 t4 q8 P1 a - *
+ \5 Z% y( d( m, S - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE' q% m u0 n! h$ O& I* t
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 E- J1 B) Y: R' Q# Z* ]4 U! Q - * TO CHANGE.
0 v6 q- q, \% W' {5 y - *
+ k) f6 {, O" ^& M6 F. F5 w - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' X; t+ S+ w6 i8 O% o5 y - *
9 f; K4 R$ v4 s Q/ g- n, ~& x - * This program is free software; you can redistribute it and/or
+ G/ V' v& Z/ _- I9 p - * modify it under the terms of the GNU General Public License as
% }3 ?$ |4 H! O& h% }- O; p6 k - * published by the Free Software Foundation version 2.
. a* i, ^+ s) V; ?+ n w( ^3 z - *; F& T4 X) ^7 _, r q6 H, i+ U6 A
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any/ w! v6 l! U4 m( g0 a
- * kind, whether express or implied; without even the implied warranty
3 c7 e2 r1 O2 ^ c - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, ^; t, M- \0 ?# A+ U - * GNU General Public License for more details.: r9 w8 R* n$ K/ P0 M' x
- */; B& A4 ]2 V8 {& X. _ l
$ Y- \; I; y" N5 ^- #include <linux/module.h>6 k) H) T8 q( Z, s9 f
- #include <linux/init.h>" R- E7 d" v' b
- #include <linux/errno.h>& \6 H4 L' u/ G, v& v W, v" ~" K
- #include <linux/types.h>
% ~9 q7 T' i3 V) p" W - #include <linux/interrupt.h> _3 G3 C0 t h" {
- #include <asm/io.h>1 `5 i S; x l; n0 q0 P' A
- #include <linux/moduleparam.h>. G9 r6 E% ]7 [$ k9 A
- #include <linux/sysctl.h>
5 \" }. j2 e5 F2 Q - #include <linux/mm.h>
- ~3 Y) {7 x& Y: _/ s6 ^, z7 d - #include <linux/dma-mapping.h>
5 H% [/ }, W. D! j4 r0 ` - 4 f) H. X5 N; i; H
- #include <mach/memory.h>
- n4 @( K" m6 A0 n - #include <mach/hardware.h>
% F) a+ B; t, Y) n: Y- q - #include <mach/irqs.h>$ q" J/ i6 Y, E$ ?
- #include <asm/hardware/edma.h>/ p2 ^: l9 z( s" ]5 b- |% [
- / z1 ?( g) F# t: Y- w
- #undef EDMA3_DEBUG. o3 P+ T( D' A: k- \7 d* d
- /*#define EDMA3_DEBUG*/4 }, x8 z' j8 F' q* T
- % i6 S# T, T4 d
- #ifdef EDMA3_DEBUG( f% d9 B# r- A4 N% |( n
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): R3 l" p, b" \
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)- k2 b- v4 P0 D S& m
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
7 ?2 @; Z6 t7 W) I6 H3 l - #else
& i! I5 R1 D: J: o" H - #define DMA_PRINTK( x... )
; }0 V" _+ P) i4 ]2 b0 q3 P' L - #define DMA_FN_IN, z6 n3 V7 V0 }2 |5 T. z9 p
- #define DMA_FN_OUT8 R; o) q& y3 ` d ]* s: _( K7 x
- #endif" T; g0 `( \ {0 ?; U) e& n) I8 }. m
: Y( C4 p" b% G- Q! N' j1 [- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
0 @% N# R R1 A* H" m - #define STATIC_SHIFT 34 p; ]& x/ r: i6 d9 Z' a) F1 k/ D
- #define TCINTEN_SHIFT 20
3 c3 T- a& b. K+ M0 z - #define ITCINTEN_SHIFT 21% X" X$ x4 T7 O5 Y
- #define TCCHEN_SHIFT 22
% K- J9 o+ @, V' c - #define ITCCHEN_SHIFT 23' ]8 c8 H; \5 t4 G- b# p& I7 D, j: I
* `$ ?: O* B) y! l+ _- static volatile int irqraised1 = 0;9 n' z# \! |7 U7 n' n6 \
- static volatile int irqraised2 = 0;/ R. `, N5 ?4 Y% h6 L& h8 D' m
\" ]3 v! U0 S7 Q5 C- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ {& S. A) }4 y( O5 |' m8 o
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 o9 |" I" c4 I0 m6 P; r! a- X) | - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% k% N% e$ X# @% o$ E
# g" w8 o0 d# `3 {7 w* K' s- dma_addr_t dmaphyssrc1 = 0;
2 I6 f$ j1 t1 w) U& _! j - dma_addr_t dmaphyssrc2 = 0;" t! w+ W; z6 D# A/ J" T
- dma_addr_t dmaphysdest1 = 0;/ ^5 z3 K& S# R+ h0 U' e: a
- dma_addr_t dmaphysdest2 = 0;
, K C1 v/ N0 E
+ t$ f8 \3 y! ^- char *dmabufsrc1 = NULL;
- t' j4 l1 l# l, c& D; Q - char *dmabufsrc2 = NULL;1 B& V& h# R8 q, q, s! f8 G
- char *dmabufdest1 = NULL;
g& `4 j( R3 Y! M' r) `/ g - char *dmabufdest2 = NULL;0 W' n9 }% }: ?1 _
; [- |* q% B0 C6 N' B- static int acnt = 512;8 p& T, n. ^/ l% Z2 m" M1 L; o# o
- static int bcnt = 8;
; Q" l+ U7 ~3 p' t+ S& q$ a5 X; W - static int ccnt = 8;
+ u. j* z5 B7 \+ }2 Z z - + U. g! R& {' i$ H0 R. j6 X
- module_param(acnt, int, S_IRUGO);
( _+ I; s: D! d - module_param(bcnt, int, S_IRUGO);, u! K% X* g \- b! X9 P$ U
- module_param(ccnt, int, S_IRUGO);
复制代码
q- j$ ^4 U' ]8 ]4 Y3 x N: `3 @1 H
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用/ N! ]% P( p* |, ?; d) ~- s9 C
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( l2 i; b6 l- U$ a9 g
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。/ w/ K9 Y' l$ D; I! `
7 ^: d# t: R- i& N9 w0 G
/ }$ \6 `- \- u0 w: i) N2 n |
|