|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ( P3 d6 v% G" I3 v9 _) g
- [code]EDMA sample test application4 i( c8 d0 V8 B
- /*
2 Q* n2 g( r" B) Z - * edma_test.c
# } h. {+ m0 y! g5 |8 Z - * @: z; W( T# o- @) h8 G
- * brief EDMA3 Test Application
& N3 }* k3 m: s& j \9 g - *: F t' O, b+ |& ~ ?. @! d2 \
- * This file contains EDMA3 Test code.! ~8 k. w8 g+ d% X; G
- *- {1 Y% V3 _$ ^
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& A' m, o+ u O; w& r) j - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT6 j" ]; ]4 {& q+ p& k
- * TO CHANGE.% i" J5 m$ O( F3 h, [3 p$ r
- *5 }! ?4 \0 g- t4 @( i: f
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! r h7 r' d7 k
- *' w% ]) }7 N7 {4 |* u
- * This program is free software; you can redistribute it and/or! Z2 y( R" D8 {' B
- * modify it under the terms of the GNU General Public License as0 C6 r$ B+ i% x2 w, m8 n* x9 G
- * published by the Free Software Foundation version 2.
/ ?* Z& C0 \# g4 P2 W) ?4 H - *
) }, e0 w) y" H6 k, T4 H - * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 G# j8 [" u% _5 F
- * kind, whether express or implied; without even the implied warranty; I! n4 Q& e* Y, }7 c; c2 a
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% C2 e1 }5 b* g* p: Y' V* V9 ?
- * GNU General Public License for more details.
) o: C- |' z/ w. _ - */; T2 {( o5 Y# B, k6 ]
$ T# w* F/ p/ k9 V- #include <linux/module.h>- k/ P) V' b, M O. ?4 @/ h; \) j
- #include <linux/init.h>
1 |) y N$ V% w' | - #include <linux/errno.h>, \& p/ m V. Y
- #include <linux/types.h>9 {" _9 W n* b# I* v# Y+ d) n5 L
- #include <linux/interrupt.h>& F" i9 M1 x& z* P
- #include <asm/io.h>
1 ~7 G1 L2 ?$ h8 |; V& f# @0 x - #include <linux/moduleparam.h>/ Z5 P" P0 u; I# C- b2 W$ i' [/ Y
- #include <linux/sysctl.h>* ~/ t6 W/ Y" h# L6 U( c
- #include <linux/mm.h>
* }2 o3 O5 Y1 F+ f, A( ] - #include <linux/dma-mapping.h>7 G7 p( H- ^1 d# }
; p3 K, Y1 k! F9 l3 C4 o- #include <mach/memory.h>, c6 G- Y' h& @9 S$ t0 n9 v
- #include <mach/hardware.h>
9 y3 s" }/ ]* u: }& Y - #include <mach/irqs.h>8 n6 [6 U, q) F' \, z% s$ C
- #include <asm/hardware/edma.h>
5 [4 T# L6 \! n3 R' O
3 O$ s+ p, K, \- p& Z- #undef EDMA3_DEBUG
: l! ~( T: Q# R( B5 S4 i - /*#define EDMA3_DEBUG*/5 Z' X9 b9 y3 m3 I( ]
& A5 q1 F# g) G* z0 }- #ifdef EDMA3_DEBUG' j0 z. E. x1 }, X& O5 a+ {
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)) m+ _" E; |+ ]+ [: J
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* C/ g! g+ X* O. c - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! C, _" d8 m0 \3 _. G
- #else
1 j5 L4 v6 B' K. n8 p7 p& t - #define DMA_PRINTK( x... )
7 U$ e1 C U, E, d - #define DMA_FN_IN0 m2 m @, Z5 s! p
- #define DMA_FN_OUT- I" c* j( Z2 i
- #endif
6 {) u% j$ a# p% R& U) g- D - ! `& J/ E! P6 W9 v X. C. r1 S
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
7 |8 L" H! U) o7 s - #define STATIC_SHIFT 3) M8 }" y1 l6 w# _) g
- #define TCINTEN_SHIFT 207 s, j& Y4 ~3 G) U1 s
- #define ITCINTEN_SHIFT 21
; w5 _/ n% y' E( [; ^8 W7 _ - #define TCCHEN_SHIFT 224 n/ _; g- ~/ @; E3 F5 Z% e
- #define ITCCHEN_SHIFT 23
+ }% t" m" t+ e& b4 } - * o9 r$ b5 j! s9 m
- static volatile int irqraised1 = 0;
4 x9 l5 W" Q! T# J4 ^* T( c' v - static volatile int irqraised2 = 0;
k/ Y8 P/ A# v3 s
1 B E; x0 I. I1 C r" G( h- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ E' j1 o8 D) B
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 D4 ^6 j. a5 F7 Z - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 N, ?. z5 E/ x
# H; ?0 b T3 I, B( O, q6 z- dma_addr_t dmaphyssrc1 = 0;# @: B+ v' V3 w4 G! }3 C# m' b
- dma_addr_t dmaphyssrc2 = 0;8 E: @, S+ R/ L/ H# ?. m* _
- dma_addr_t dmaphysdest1 = 0;
: G7 E6 T4 v: D8 H1 X) O3 \ - dma_addr_t dmaphysdest2 = 0;
! }; o4 O7 t# E - : ^6 z+ { a p% B: S
- char *dmabufsrc1 = NULL;
! I4 ]1 A3 Q+ {; ?1 x - char *dmabufsrc2 = NULL;$ U4 }* q6 {* n
- char *dmabufdest1 = NULL;
% l% Z+ y9 f% K! T h e+ S8 w - char *dmabufdest2 = NULL;- Z3 I1 K/ G7 k1 Z
- ) U6 N7 U( N3 c5 r. ^* V
- static int acnt = 512;5 B" r4 v0 S* z) x
- static int bcnt = 8;
2 X( H( W+ l9 j - static int ccnt = 8;
! |- }$ w2 d3 \# V3 \1 n - * i* s4 H3 d# G5 W
- module_param(acnt, int, S_IRUGO);3 |( T Y w' u! i, ?
- module_param(bcnt, int, S_IRUGO);% F9 Y. T' K8 |% ^: m
- module_param(ccnt, int, S_IRUGO);
复制代码 2 l$ S3 H6 V8 a1 w
# S$ x7 ~0 n* N2 T
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 v* I' t5 M. Garm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
3 t7 _3 l) U9 H6 R& X 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# o1 i, A+ ~$ ~3 l: r9 S2 f* p
5 ]# P, {9 b, }9 v( d& {0 _1 s5 N% i- b) D" r1 Q& G6 e
|
|