|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 8 F! ]0 K4 G0 C6 a, w z5 v
- [code]EDMA sample test application. Y: H6 I H8 j) M4 c7 E
- /*
8 \$ Z, m+ c0 e1 e$ W - * edma_test.c
& W N3 F0 p+ V4 I1 L - *
' k c5 \$ ]; Y - * brief EDMA3 Test Application, d) I7 a2 k- T, i8 C* Q
- *
7 K2 [# q* A1 c7 }, b s; @9 H5 f - * This file contains EDMA3 Test code.% _' E4 @! u8 m8 N2 J; [9 T
- *
' T: W7 n; P5 e/ T9 y# x& {7 h - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! {8 U$ \. x1 @( ]
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, p$ E% V7 o! Z/ E
- * TO CHANGE.! b1 Q5 P) l! n
- *6 A( s3 Q* D: a2 K; q6 x' s
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
+ R0 J8 `3 K! r/ A - *( z/ C9 w C+ `5 K$ A2 p. p
- * This program is free software; you can redistribute it and/or
. k7 W& e8 s: r/ U& ] - * modify it under the terms of the GNU General Public License as- l3 b3 r3 M/ ]
- * published by the Free Software Foundation version 2.& p' I5 x, @/ Y1 `- V3 h. N" z
- *, u, I: F$ w2 d$ {
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
# s) A6 q4 Z- _5 R - * kind, whether express or implied; without even the implied warranty
# N l: {) Y% \ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) |4 o s9 I" D9 L4 [* ]( u& x" e. ]: j - * GNU General Public License for more details.
* J6 Q% i! P- x5 k' z2 Y - */
9 C) J" A! P# e; {7 J - * }0 m; H/ {4 `# Y9 R0 S, N7 u
- #include <linux/module.h>
: L$ T5 I- L( t - #include <linux/init.h>! z) A9 v. F. g- t G
- #include <linux/errno.h>1 `* M, X: N4 ^9 ]( W: ^9 }
- #include <linux/types.h>% b% r) w( k# ~2 [
- #include <linux/interrupt.h>$ O/ A; m- F$ _# g$ ~ J
- #include <asm/io.h>& u! n6 q) X+ ?# c0 T9 Y: I
- #include <linux/moduleparam.h>' u" f4 J5 l$ @$ @( k
- #include <linux/sysctl.h>
: p4 D/ q0 Q3 d4 t! _' E% S3 F8 { - #include <linux/mm.h>0 O& ^4 D; I, N
- #include <linux/dma-mapping.h>
s, G+ s1 r2 C% S! r - ! `3 ^ S( Z) e. }: J
- #include <mach/memory.h>! a- S( O. m: q. H) ^* y c
- #include <mach/hardware.h>
* p, e; x1 _# m2 P. S% W9 U% M9 v - #include <mach/irqs.h>
$ L$ \' R: v6 H5 K+ X0 P- f5 a" [ - #include <asm/hardware/edma.h>+ k- F* G& q, H& Z0 F. O0 F5 F, U( G
- . V3 Y% H1 t Y% y
- #undef EDMA3_DEBUG5 a9 m) s- h2 c7 t( } l
- /*#define EDMA3_DEBUG*/6 B1 M' v7 g% \9 `( e
- + I* }& s' T4 h" u- m
- #ifdef EDMA3_DEBUG' ?. k$ I a* r8 m/ X" p& j
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% a3 s/ T; \- p% w9 Z: @ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)9 C) t2 z0 ]% {
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 D9 `5 J7 F) N! o% R( ~ - #else
9 \' q; H# d1 O4 y! L - #define DMA_PRINTK( x... )
* i- E8 M/ b) t4 U+ t0 j- t3 @ - #define DMA_FN_IN
* X7 Q% S. {# r* r2 Q# D - #define DMA_FN_OUT
& {5 z: o, @: l i3 k) ^ - #endif
. i# O* _. e$ K- ?4 H! n
& M( |) @2 q# H K- #define MAX_DMA_TRANSFER_IN_BYTES (32768), ] L7 ]2 D) x" ^
- #define STATIC_SHIFT 31 Z8 a$ k9 z8 y; @6 I$ h$ I' C
- #define TCINTEN_SHIFT 20
( U" ^6 ?8 A7 |6 f - #define ITCINTEN_SHIFT 21
& N: s) X/ v% _% X! W* { - #define TCCHEN_SHIFT 22* s% T; `1 l a, O1 p) q3 B3 c5 p6 m
- #define ITCCHEN_SHIFT 23( r0 B9 ~) A0 C, b3 b! \3 t$ L
& Z( B5 K6 `, o- static volatile int irqraised1 = 0;; l) I7 ?$ O/ ?6 H% e& w
- static volatile int irqraised2 = 0;
" l P) v( R7 E/ H5 I4 l - - u" w& v! P' \4 ]
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 O* k% n# T# E
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" l1 `9 k- u) n8 j N; }* j' C - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) ~% p' {$ z# _4 t
0 s. b7 F. o& {9 s- dma_addr_t dmaphyssrc1 = 0;
7 q+ |* u' D9 Y& o - dma_addr_t dmaphyssrc2 = 0;
! L; w* ]* {4 V4 `& h - dma_addr_t dmaphysdest1 = 0;
) u- Z5 `0 N. E* U - dma_addr_t dmaphysdest2 = 0;
2 u& S3 ]1 k; V% J - 9 H% z5 T/ t- n' W
- char *dmabufsrc1 = NULL;7 x' O/ {: v1 i6 w7 B. U/ |
- char *dmabufsrc2 = NULL;- g# R( ^* R2 @! \( r: g/ a' y
- char *dmabufdest1 = NULL;
% A6 Z G* G3 G1 ^' W - char *dmabufdest2 = NULL;
( j; Q( c0 ^9 Z2 L* r0 R - ! \4 Y& J# { l5 x p3 S+ D
- static int acnt = 512;
: d& w+ M! B: H" b6 y+ r - static int bcnt = 8;& i. s/ c. D6 C* B* a
- static int ccnt = 8;- j8 f) |% N3 T0 W
- ; D6 a7 u" i Z7 c; b
- module_param(acnt, int, S_IRUGO);9 J2 z K) |+ C# E$ f) p+ B3 F
- module_param(bcnt, int, S_IRUGO);! Z( N$ ?9 ~; o1 L: t/ y
- module_param(ccnt, int, S_IRUGO);
复制代码 4 f; o$ {1 j+ r* d7 b) q
& w7 p' R Z% m) f3 b) s) q8 {) w
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
( \' q( ]# X1 X) p2 Tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 e1 W2 S# N" u( f
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' B$ p, S0 {2 _) @" B' n4 ^
. h G3 a& z5 n1 s
5 s2 g! J5 j2 U8 v m/ d |
|