|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 8 v. B+ v7 V! T. i
- [code]EDMA sample test application
' R* d4 B* A4 L% z - /*3 a) o G: `& r( H$ o9 v/ U
- * edma_test.c
; ~4 M. G/ h: C# E c2 d+ }& U - */ k; v2 U7 G' d x
- * brief EDMA3 Test Application5 y* {/ C0 Z. {/ X
- *
$ w( L4 ^1 s: _ - * This file contains EDMA3 Test code.6 I& ^7 R0 O, U# Z5 v
- *& L2 X) B: Y: w$ D6 ]
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
# u& O3 A0 V; J8 y @' J - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; j" u6 h8 ?' ~1 R( y( u! e
- * TO CHANGE.$ b: Q1 z5 M6 V& {8 a+ L
- *2 ~4 B5 @ x/ j) R& G( ?
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/4 R7 K& M% h+ A) o/ S
- *' n3 n+ Q. n* L- z
- * This program is free software; you can redistribute it and/or
1 I' b5 e. Z* u6 t. |' s d+ c - * modify it under the terms of the GNU General Public License as
% i! m0 @3 `& R: b% b - * published by the Free Software Foundation version 2.& e" M. C" {: J
- *; Z5 w' t* v+ c6 `- [7 w" P
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
5 H2 i5 J/ R6 P1 B - * kind, whether express or implied; without even the implied warranty) f b( k' l9 n- l8 N1 G
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" Q7 {2 Y+ k3 `: }
- * GNU General Public License for more details., X7 X/ `; I7 D; o; o
- */
# A X. x( t, @* @1 O8 n
% }0 W% M ^; J) }+ Q2 R" G- #include <linux/module.h>4 G S4 F2 d* M4 ~; Q9 L. L/ \7 T
- #include <linux/init.h>
/ h) N3 i3 L" v9 ?- t/ u" | - #include <linux/errno.h>& _- X; G5 k: W) q
- #include <linux/types.h>
5 T5 N+ e# l6 C& X8 S - #include <linux/interrupt.h>. l% @' z. ^) Q. \7 w4 Z; n
- #include <asm/io.h>/ x$ J' r5 Z" U3 E1 Y! L# v
- #include <linux/moduleparam.h>5 Z p8 `5 Y- P4 _6 T6 ?
- #include <linux/sysctl.h>
, [* X3 t" c9 i# _ - #include <linux/mm.h>8 E P7 ]# F. y% W' ]2 z V# D
- #include <linux/dma-mapping.h>/ v. ^2 Z x2 Y" a; G
- 2 Q( [4 x N3 O1 ~3 B8 w4 q) b
- #include <mach/memory.h>' |# S7 C8 R+ T. u' {9 |
- #include <mach/hardware.h>
, e, v4 F" q( S6 y6 W% {, f - #include <mach/irqs.h># k6 U6 ?- L+ ]4 ~# R
- #include <asm/hardware/edma.h>
M! i; b$ s) r, A& U8 s! h - 1 z/ b1 I% z3 }" E8 P; j. ]. k
- #undef EDMA3_DEBUG+ O8 r5 Y. |! _6 u _
- /*#define EDMA3_DEBUG*/% ?7 g: E3 N0 E' V
3 K& n2 `; {4 n- #ifdef EDMA3_DEBUG
8 K" A$ h2 F8 K - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. m- {$ d2 I, `$ A& x - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
s% C" p! j+ y0 h9 t: A1 @8 U - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 g6 N4 \: G, C# J3 o! ` - #else. ]2 h$ g- E# {4 {
- #define DMA_PRINTK( x... )
7 y; g" S& j4 F H3 n0 x - #define DMA_FN_IN
% ]6 X% Y2 V6 K' B$ W% | - #define DMA_FN_OUT0 ^4 u( v5 v; a! m* f/ n' A, \- k
- #endif; h: W% _9 [2 z; G; A* x
- . F& X" m( F8 s3 _, p, E
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ M* [5 ^, _, t* N6 Z/ i
- #define STATIC_SHIFT 34 L: E1 g9 a3 n0 E( r
- #define TCINTEN_SHIFT 20
3 X; H% R6 ^ h( A& {& | - #define ITCINTEN_SHIFT 218 |: Q9 N- Y$ Y) A7 g
- #define TCCHEN_SHIFT 22
8 S9 }' ?6 N- x; \9 O* m2 O - #define ITCCHEN_SHIFT 235 j% t3 E% \% i: Y( K9 A
# R! ^* t/ Z' u3 [- M- static volatile int irqraised1 = 0;' e& t$ }4 }9 d( x# @
- static volatile int irqraised2 = 0;
7 G9 e' O& y* B; [, f4 F1 k - 0 y+ [) U. p9 ?9 S
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 p2 y3 H5 z h4 j( d1 L/ g* T; | - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ V( ?7 I9 v% L' y
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 ?# }; F# J; R; x3 b$ @
- 1 Z8 g. \! J9 v9 D w
- dma_addr_t dmaphyssrc1 = 0;$ r7 A$ X8 f/ o
- dma_addr_t dmaphyssrc2 = 0;9 d5 [1 ]4 ^( q- a k* e
- dma_addr_t dmaphysdest1 = 0;
" F) C" N' I7 l - dma_addr_t dmaphysdest2 = 0;2 x! w4 Z- _- Q$ q, ]
- ) E! U2 ^' Y. _/ q+ w4 J( Z4 S8 F
- char *dmabufsrc1 = NULL;4 I! m/ |. I3 t# D
- char *dmabufsrc2 = NULL;( L/ @- ]% h9 f6 Y- x2 h' v
- char *dmabufdest1 = NULL;3 T: ?+ p' L8 b$ p6 d; Z- A
- char *dmabufdest2 = NULL;
5 E& N/ t/ \* u* Z* ~: G3 s) v
8 c( o) [9 f8 l+ H9 H) } ^- static int acnt = 512;
% C9 w n$ Y; v; D8 m& Q9 S& v - static int bcnt = 8;3 C- p V+ ^6 l
- static int ccnt = 8;
2 s6 C: n' F& i( | - $ P8 S% B3 K' K9 s/ f: F
- module_param(acnt, int, S_IRUGO);
3 B6 Z4 E* h6 d" P: \ f - module_param(bcnt, int, S_IRUGO);
- X# e$ k& L. |- G1 e6 f. ? - module_param(ccnt, int, S_IRUGO);
复制代码 ( I: X- h9 ~: u% X+ c
6 s: K. q' v: ^& k( U 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; D, B2 B/ s$ D7 q( g! x+ j9 Warm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
, {: h3 Z6 A# w+ |6 | 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% G* v' ]0 ^3 J. t7 H$ i+ p+ U5 t! Y+ Y/ }* Y) N
% s4 w* L j# o9 ]- H. p! A |
|