|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 q* n% I/ q' D- [code]EDMA sample test application* k l$ Y/ j) w! A; Z
- /*
. g( f8 E& U: `! a - * edma_test.c
. c! r: o! U7 R! ` - *8 N$ Z1 N) w" }* r+ F0 @
- * brief EDMA3 Test Application4 k- b- b# p w! ~ n. f
- *# N k5 `2 P$ F/ e
- * This file contains EDMA3 Test code.
/ b0 t# i! u6 o! I7 J7 k - *' K4 k4 z0 T7 f2 e
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE1 d3 c& _8 ?" ]7 M# G9 r% S' A7 d8 d
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! B% a5 ], _4 E- y' O: E1 f' ~ - * TO CHANGE.
6 D; M5 r) B* J( b - *+ ]. d3 c* p4 G* n
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
4 S4 n& t( T) d. a) m - *. ]0 c$ Q+ b3 f( S; Y& t& U
- * This program is free software; you can redistribute it and/or7 K5 L- s# n8 Z/ V) t
- * modify it under the terms of the GNU General Public License as/ P/ B- H4 U3 [5 J- b% R- K
- * published by the Free Software Foundation version 2.7 |& U# S% _/ ]$ @. |8 P
- *! u+ x, r* Y8 e
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ P6 ^. c& a+ ]+ w p4 ] - * kind, whether express or implied; without even the implied warranty# }' @( c3 I! s8 |
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- T+ j9 H2 C: D4 m: ~2 x - * GNU General Public License for more details.7 ~3 ? R; C ~
- */
' u; g! {# {7 u - ' a) ^1 }, h) l9 s8 {) n/ l
- #include <linux/module.h>
, y# J( s" W! [+ t' P - #include <linux/init.h>
* G0 F( ^ s$ f2 ] - #include <linux/errno.h>/ E4 b$ Q* r& _' r$ \1 L
- #include <linux/types.h>, b. d* _) T' E0 @; l0 e8 G8 z
- #include <linux/interrupt.h>9 L' ^9 y! m- u) X2 z
- #include <asm/io.h>; E" J% q$ {; s
- #include <linux/moduleparam.h>2 `. F7 O% h$ f
- #include <linux/sysctl.h>
: @* j& E% d3 i! W9 y - #include <linux/mm.h>2 d. U% \3 L& X& m$ q
- #include <linux/dma-mapping.h>+ W2 l9 G( C1 }( N" T
* z& F0 F" B# b' R* M7 y, X: ^- #include <mach/memory.h>1 D6 }) J- a9 }1 w
- #include <mach/hardware.h>
3 G1 ~. a- @: R - #include <mach/irqs.h>% K1 [: X7 Z* ^
- #include <asm/hardware/edma.h>
: q: o( g3 X$ ]2 l# N: `; _/ h - 5 W* y K% r% p M; r" W8 H6 v$ V
- #undef EDMA3_DEBUG
+ d2 q, l% I: V4 Q6 D- p - /*#define EDMA3_DEBUG*/, d# n1 B3 b6 G. f/ b3 K- J9 \, N3 A0 [
6 F$ z9 ^. r# }# ?2 v3 y0 \. O- #ifdef EDMA3_DEBUG
, Z4 K! M3 B2 }, M - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 u5 Y3 Q0 C: S: ]/ F; {- W - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)2 i$ d9 W h' C4 R! }6 q3 B
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 V: x% |# I# p* m$ _/ X7 b; b7 T- ^
- #else
U" f5 E4 |6 ^7 C/ R: M L - #define DMA_PRINTK( x... )
/ `7 o. t1 g6 @; ?- B& M0 p0 B9 j/ ] - #define DMA_FN_IN6 ?9 \& t1 A0 Y6 v" \% R- q: h
- #define DMA_FN_OUT, b" r) b) Z2 u* x V" X
- #endif0 }" V8 [! R8 Y$ ~+ y# ^
- % n: g& b5 h2 F& x; T
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 H: o" _ K! @( N' ^( a7 b
- #define STATIC_SHIFT 3
& w6 l. G, a0 E4 u/ m1 N - #define TCINTEN_SHIFT 20; T. m* f2 n6 V$ m& {8 Q" r: {
- #define ITCINTEN_SHIFT 21
; [7 L! q M) w - #define TCCHEN_SHIFT 22- X3 A% ?: S/ `& w2 r
- #define ITCCHEN_SHIFT 23
* j7 V% O2 T5 c$ z; [: E o' F
2 B0 W# e& j! y2 ?& f. W- static volatile int irqraised1 = 0;$ T* }0 Y2 V9 W' M: z3 e9 M5 _
- static volatile int irqraised2 = 0;
& O4 n; B3 B0 ~1 n0 n - ; P* r: y# f; H5 q* d9 S9 f& A2 S
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. J' a4 N; F# y/ g) B6 E+ N - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- I* ~8 p- E% c u1 q
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" E X( Y% F) A& y0 B( y
- # n: q0 c8 g+ T+ x
- dma_addr_t dmaphyssrc1 = 0;
' T+ _( J ~- o9 [ - dma_addr_t dmaphyssrc2 = 0;% [5 r% H$ L: A
- dma_addr_t dmaphysdest1 = 0;
, f( N/ \0 l' }$ [& e& g - dma_addr_t dmaphysdest2 = 0;$ d' d2 X" n* Z' K
- & U: u* p4 w- P+ o9 t3 Y; N% l \
- char *dmabufsrc1 = NULL;
; _) ~$ _. F# Z; E - char *dmabufsrc2 = NULL;
& X6 [, T! F7 a/ t& W& j - char *dmabufdest1 = NULL;+ v8 w3 ?( _) X& V
- char *dmabufdest2 = NULL;& a# U2 L) Z9 Y+ d% e3 F
- 9 f { e' P! z
- static int acnt = 512;
; j( Y- y8 U. K8 {) z3 i - static int bcnt = 8;
( R6 r6 T) p( _1 \ l2 r, X - static int ccnt = 8;
5 d2 ~5 k2 V' g/ f - , [( ` o# n9 Q, v3 `# J( y
- module_param(acnt, int, S_IRUGO);
. o0 i) b3 b5 h' Z; j; n5 Q - module_param(bcnt, int, S_IRUGO);
* y1 i7 }$ M1 N9 C - module_param(ccnt, int, S_IRUGO);
复制代码
$ L p" j: G: f J& Z( x6 b$ ?* W7 M
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& D9 S' F7 C! W& z
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
' _( J0 h3 j9 K3 R" { 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' c @3 Z2 Q" ~; |2 _" R
$ T0 _* A$ D8 s# V/ V
8 g. z5 K5 r* Q* A |
|