|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . K; C7 x: M* o2 R* I
- [code]EDMA sample test application( s$ Q: V4 }( B: }4 ]6 i
- /*& D* K2 W h! B' x+ l- F3 V
- * edma_test.c
_# F8 [. C, F+ t' H8 \& E - *
9 A6 {: v, e5 [% {% k1 Y6 [6 Y- ] - * brief EDMA3 Test Application
9 _0 h, g4 p0 u7 ~, o - *
5 J! d, H% h8 t. i: y t- I& v - * This file contains EDMA3 Test code.2 x! I/ n. \$ a1 T7 q- ]! U
- *. H, o2 m: R& l1 l: v' N
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
7 J7 k( W9 r o* [' G - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" T1 E5 G2 B; @! a1 ]3 h1 ] m
- * TO CHANGE.! X9 a2 p3 f0 f& W6 u! W! h; d9 ^
- *
) j1 h: _' E6 h4 |* ]& s, Y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 Q, n2 c! L+ t$ N7 R+ M3 u9 E
- *$ }) l# K7 T, w% _4 m
- * This program is free software; you can redistribute it and/or
+ r7 S/ o Q V) F* g) v - * modify it under the terms of the GNU General Public License as
0 m O: U5 p" }% p+ T: T - * published by the Free Software Foundation version 2.$ G8 m& K0 z2 u+ F5 V: B& M3 z
- *
$ v& [) g* h. h. D. s! z% A1 w - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; ^& ?" u; W; b3 X9 R - * kind, whether express or implied; without even the implied warranty
2 z2 R7 j7 Q) n - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 w5 d3 p" z4 w
- * GNU General Public License for more details.
, [( [3 J6 u+ T( [ - */0 m; K8 i+ d" `$ i( F* s
- # e9 H& V0 H3 b9 s. `2 f# L& P
- #include <linux/module.h>; {3 I; t- S; C
- #include <linux/init.h>8 [" A8 R6 F( O/ d$ E$ ^
- #include <linux/errno.h>
$ {/ w& |6 `5 F - #include <linux/types.h>
/ a& t B" |# T5 S4 L; w! {0 E: | - #include <linux/interrupt.h>) ^- Y, `0 W( T( Y' S+ m: {; o1 r2 p
- #include <asm/io.h>- A4 A6 \9 C( L" `7 r" I
- #include <linux/moduleparam.h>
: ?* P0 J" M4 `' w - #include <linux/sysctl.h>8 P; c. j$ T2 G" Q! X2 b
- #include <linux/mm.h>
8 K* D- M+ o% i3 k; n$ | - #include <linux/dma-mapping.h>
" {6 t# a" P8 k - + D/ {% I- o+ C( ~ ^
- #include <mach/memory.h>( o5 [# q2 \" h8 ]
- #include <mach/hardware.h>
) i& g5 D$ x* {0 L - #include <mach/irqs.h>
, u& Y' |: P2 L& u9 t - #include <asm/hardware/edma.h>
$ B" f: g* l1 j' |. Z
, o S4 p3 G* ^6 X1 r# x- E- #undef EDMA3_DEBUG5 d4 e- @& f; J+ Y# U# S3 d+ U
- /*#define EDMA3_DEBUG*/! w9 c$ o( f h& o* Y& L
- & e- O7 N3 L2 @5 M- ?
- #ifdef EDMA3_DEBUG
' M5 C$ k) _3 C$ _" w5 k8 a: O9 D - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)) R( ]% o" J9 I3 \8 }
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; O4 } v4 { A* C( ~ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
( e4 w5 `- O) m- q8 {6 T - #else* ]4 {8 y% D; ]+ Q3 x% p) v
- #define DMA_PRINTK( x... )
) n3 M/ \# e2 k, Y4 O/ m% ?1 K - #define DMA_FN_IN
" d0 ~; _- k) B/ [ - #define DMA_FN_OUT% P% D; Z9 F4 t2 u5 z4 m3 f
- #endif, I; C% [+ O4 A, |8 w9 X5 s
/ }: t) h4 |; K8 S* u q/ g$ p- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. U+ F5 K# _3 \$ X# e - #define STATIC_SHIFT 3$ P2 J( K6 ~& x
- #define TCINTEN_SHIFT 20 E. L* Q' F6 | |4 z
- #define ITCINTEN_SHIFT 21# n9 H5 \& X. |/ d# {8 T
- #define TCCHEN_SHIFT 22
! v2 K7 I$ R0 a+ T0 C# ?, V, u - #define ITCCHEN_SHIFT 23
) N9 Y F. R& W2 l9 v, M! i
v% c4 E" a, A- static volatile int irqraised1 = 0;
4 h1 J+ E- b( W3 P' l8 o - static volatile int irqraised2 = 0;
7 g) M* B0 P( E) g* X' D - ' z* p: z) I0 X+ a7 H
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); ]- e3 h" ~& `1 a2 V& r, d* d) O" v
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ ]5 M# @: r; n" l1 O s2 J3 x - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ Z. l7 E4 c! w) P
- : P8 ~3 C0 P3 I/ M; u
- dma_addr_t dmaphyssrc1 = 0;7 j* `2 K1 P ~1 d1 H* \- k" x
- dma_addr_t dmaphyssrc2 = 0;
$ S2 B/ Y/ c' u( c4 e1 y - dma_addr_t dmaphysdest1 = 0;' g% k# @/ A; ~
- dma_addr_t dmaphysdest2 = 0;
9 O8 T m+ B, i - / V) s$ F% n; I0 [( e
- char *dmabufsrc1 = NULL;
8 {+ ^" g. |3 g; F - char *dmabufsrc2 = NULL;* ?4 \. Z! C! x- J$ m0 d% ?8 D( r
- char *dmabufdest1 = NULL;
6 [+ v; I; a: {& L( q3 t1 J$ D - char *dmabufdest2 = NULL;& e2 z2 X: d4 S' u2 H& c
& q0 D! y+ C7 X: @/ D% Q' N- static int acnt = 512;/ X8 _8 B$ f" T& p! c2 J
- static int bcnt = 8;
3 K6 l) p* D7 W: g( ]3 C - static int ccnt = 8;
8 C6 A; O2 i$ \0 ~ m8 D& r - 4 A4 u1 m M N( Z
- module_param(acnt, int, S_IRUGO);+ e" \: y) l2 E- O; _/ K6 F# I
- module_param(bcnt, int, S_IRUGO);$ i7 M( U+ s, }
- module_param(ccnt, int, S_IRUGO);
复制代码 2 }+ O/ H" M+ I# }7 h4 D
6 }9 r" u1 W6 v5 k5 M' w! q. A. z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) }6 Q- {% V% s- a
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
! I7 g$ ~6 u" ^- b% o0 m: _' n 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: O1 k8 z; U: ~5 `" z. f
2 Z. v- E0 _5 ~3 f2 x
! o! u; W$ ~7 _; Z* b C |
|