|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : L7 ^( x3 g6 F2 r A X
- [code]EDMA sample test application
) R; F& u7 u. P7 G - /*
. [1 Y' f0 O3 E! O - * edma_test.c
, L+ b* I, u; L# c7 D; A0 Y1 E, ^ - *
) o. l. Y6 S$ h$ h4 a - * brief EDMA3 Test Application
2 V; t" h8 v* T! k4 [% u0 Y* B1 R - *
2 o- E/ L7 p6 M6 O/ Z - * This file contains EDMA3 Test code.5 E" N' Q) ]( @" J4 T
- *' B6 ^) T- o$ Y7 f; m
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ F( T0 e. d# M# Y. G - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT- k; s9 \6 K" |' t
- * TO CHANGE.
+ Y$ C6 Q: @$ t* {+ m - *
! _ _' f" h* \! C. M# K7 f - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ V8 K9 n' S9 Y% d( _ - *" L6 V3 |6 i r- e* X
- * This program is free software; you can redistribute it and/or
: x1 h- s! g1 r: A& y | - * modify it under the terms of the GNU General Public License as( n( e0 d) L& i
- * published by the Free Software Foundation version 2.
# v3 P& c! i) ^! a" y5 r4 f0 U) V# \ - *
; ]3 O# K: t$ j! B. g5 T% S) E - * This program is distributed "as is" WITHOUT ANY WARRANTY of any' z1 S4 J- e4 g9 B4 I. ^
- * kind, whether express or implied; without even the implied warranty x+ a' c/ d3 D" _' F% l
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the! j, g5 n; r3 Y' H' Z
- * GNU General Public License for more details.- x& L7 ], p' l
- */1 F' H6 Y# w( k7 R, Z. O2 H
( v3 A% H J s- #include <linux/module.h>2 v+ W" v' n) d6 F D
- #include <linux/init.h>
, n; Y# A+ Z: A - #include <linux/errno.h>! p" v4 S' Y( e# c$ |: h( w- z
- #include <linux/types.h>( `3 g) `" S3 ?- E3 I; L7 y: K
- #include <linux/interrupt.h> `# ^6 w+ I1 M3 o: _6 O
- #include <asm/io.h>
6 V2 c) D5 ]4 u! E8 X6 w; R( z1 c$ F - #include <linux/moduleparam.h>, e' o: E0 Z/ E( s# g/ h" n
- #include <linux/sysctl.h> G, @8 Y% D5 R0 w/ |, N8 M7 d. j
- #include <linux/mm.h>
6 a' \+ N$ J% s8 g - #include <linux/dma-mapping.h>
2 Q4 N+ B' O, Z! O! N8 H
2 f; y) e% R; |- #include <mach/memory.h>) q& m) V: r$ p; C: d) b8 u
- #include <mach/hardware.h>$ [6 m) V0 r% H) k: w) R
- #include <mach/irqs.h>
/ r7 \& G4 E- a6 o - #include <asm/hardware/edma.h>
# `" x3 Q7 M7 | - q; _* t0 y5 s& d& S" O5 `" _9 ^$ ?: s( U
- #undef EDMA3_DEBUG+ M1 `' J$ ~8 t8 v" Q+ s, O
- /*#define EDMA3_DEBUG*/% E. G* P, T" {6 y0 p& @5 |
% ^' c0 Q; l; B S' p- #ifdef EDMA3_DEBUG+ F z; c- Q5 r+ `' C2 @" E
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) g: q U0 j' G2 P1 p6 {
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)& O" C6 N- B6 \9 J, i+ w' p" X* h
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
( Q' i; G* K8 N% p5 F1 q - #else3 o$ n2 G* l$ T' k; l8 C* t0 \
- #define DMA_PRINTK( x... )$ Q) H% f+ V. B+ P1 }7 U6 v
- #define DMA_FN_IN! C" N5 V! \) O: ]8 h6 g p1 N
- #define DMA_FN_OUT
/ C4 B1 |1 k0 x+ l! a - #endif- d3 U* }1 d3 i e- R( R- n) Z
4 z/ I7 x. K$ x; h0 D$ Q- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
" Z5 ^1 @$ n! x7 d3 h8 {5 U - #define STATIC_SHIFT 3
# f R8 x9 X( J: p, B - #define TCINTEN_SHIFT 20
; H2 f9 F+ U& n( \2 C# l, H. v2 z - #define ITCINTEN_SHIFT 218 m1 w9 ^" N1 V. P' N% Y
- #define TCCHEN_SHIFT 22
, F) U) h Z7 `) _& ?5 ~* q - #define ITCCHEN_SHIFT 233 i W# L. Y% l4 {7 h/ S
- ; C2 z) p1 Y$ O. A. ?( W
- static volatile int irqraised1 = 0;
) k6 d# v8 N* s; x5 ? - static volatile int irqraised2 = 0;
i+ Z \7 x& B: P5 I- h
' Z& _& x. L; K3 A, W* N R5 ]- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' G: X M# H6 G/ E2 I8 d* g U - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ c# [- X Z2 M- W( [ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& W. s& O7 K- T - % e+ r9 d+ j A9 {) y& ~
- dma_addr_t dmaphyssrc1 = 0;
7 k B8 ], s% O2 m - dma_addr_t dmaphyssrc2 = 0;
: n, @& m. X, a: Z - dma_addr_t dmaphysdest1 = 0;6 n; p) F) T5 Y! c
- dma_addr_t dmaphysdest2 = 0;5 Z# y& @ Y6 g. r: Q
4 @9 u# e" [ z( Z7 R9 O- char *dmabufsrc1 = NULL;
& |0 f$ q- ]/ t! U6 } |0 U& @ - char *dmabufsrc2 = NULL;6 ? x5 T9 C2 O0 {$ W+ h
- char *dmabufdest1 = NULL;
( l+ N1 U$ L% q( i4 y) o& ? j+ ` - char *dmabufdest2 = NULL;$ I3 l: V' _0 c/ B3 ~1 S$ R% M# L( y
- / G. J. q# z: d4 V5 E3 P t
- static int acnt = 512;' M; R. z. |0 R) V% N
- static int bcnt = 8;
# c6 A8 m" [% _7 g - static int ccnt = 8;
' z6 J2 |: }; E; o& M7 \& f7 a - ( J) ^7 s) ]$ {/ M" q3 V. R
- module_param(acnt, int, S_IRUGO);5 X1 x7 B8 b; ?. Z8 J' G2 ~
- module_param(bcnt, int, S_IRUGO);
, w* j" [% N G- W% U0 t - module_param(ccnt, int, S_IRUGO);
复制代码
% m! L8 \/ {4 D$ l
1 e6 e5 B' {0 c3 m) o- I2 q q8 L: e 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* J' P( a7 D2 A- E: z' ]0 R- f
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
; U: s1 i7 W8 g) Q; t3 d3 j4 \3 o 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 Y$ B) L! m- s
+ O7 \' G& B2 o p5 b, ~7 u; @
% H8 m: ]* {; Z9 i |
|