|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. I. Y) y7 P1 U( B7 H- [code]EDMA sample test application
( p( T$ j% m" j. \. @ - /* s0 N" I+ Q) j8 V7 T
- * edma_test.c3 K9 e3 P% c# b% a0 j
- *8 {. g2 j% w& G
- * brief EDMA3 Test Application6 O k6 i& \5 [4 L$ G% l; v. c: t
- *
9 N4 r6 S" ~) {: U) V+ V, G - * This file contains EDMA3 Test code.
% H" N1 Q9 I9 C( m, t+ ~6 A ~/ A! B3 t - *
4 d3 s* x7 v2 r! G2 i - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 X4 t8 k4 y7 k
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
, k! v$ a+ g! M - * TO CHANGE.
. `; p4 \/ b' |* h3 @' [2 g7 C! `+ v - *" Z5 x. m) c0 v7 m9 a
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
0 K. W, M! W, Q7 O$ t - *
1 M) N+ f: h$ T# S - * This program is free software; you can redistribute it and/or
/ t. G H. e4 _9 k0 C. A7 Q - * modify it under the terms of the GNU General Public License as- E1 b; ^* I+ F0 i
- * published by the Free Software Foundation version 2.! h Z/ Z+ i5 Y7 j( T! R
- *
) i, v; Z: e8 \9 ]$ N: Z/ s - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& A* Y5 l. D- i% s$ B& j; ]- v - * kind, whether express or implied; without even the implied warranty
* s- Z6 a+ Y l" Y; _$ | - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* {* y0 m- w0 x, ~3 ]0 k( W- x: G
- * GNU General Public License for more details.9 ]4 u9 S* L% t/ c
- */
0 \( K9 ~4 s3 z# H$ s, a
. C9 Y! P3 x: i# o/ {- #include <linux/module.h>
9 v! _1 ]) F! D# Q% ~, y - #include <linux/init.h>
# \% r! Z0 f, s2 C - #include <linux/errno.h>
/ C6 w7 p" y9 d7 N8 W: z# d8 s - #include <linux/types.h>
' j5 E; [+ u; H1 `7 ]9 W - #include <linux/interrupt.h> D* @9 q) z1 U
- #include <asm/io.h>
3 j9 W8 w ?4 z' O4 z - #include <linux/moduleparam.h>
+ Y5 ~* }8 C+ R6 p1 x- y( Z( ^ - #include <linux/sysctl.h>
. D* _. J) q5 K: u% C% w - #include <linux/mm.h>
! y/ k1 a" m" v8 F" k% | - #include <linux/dma-mapping.h>
, ~0 f2 U2 ]; M# U# \- I* R
; `# a* \" Y" g5 {! P1 _- #include <mach/memory.h>
4 T4 _1 t+ Z5 O/ u, Q - #include <mach/hardware.h>- U) L' h/ K- s) Z0 {5 j
- #include <mach/irqs.h>
- e4 o: Y8 S F - #include <asm/hardware/edma.h>" X8 l7 v3 ?7 i# \- X c* Y
: u7 B/ |, N z$ L5 W0 g* s- #undef EDMA3_DEBUG
" z1 X' f$ {$ }" s - /*#define EDMA3_DEBUG*/5 r3 {- e: X( j4 V! m
- 4 ?% K! z5 f6 q( g
- #ifdef EDMA3_DEBUG
. n, T6 e+ c, m6 Q) ^ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS), S: R0 |; i8 E# z u* }
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)' Q# c% ?3 v- x/ o
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
5 d! a5 I- B3 S4 |# t7 I1 u; T - #else# X, J+ W+ e$ T0 G7 [" v0 G. T* H
- #define DMA_PRINTK( x... )5 S& T' g5 Z* r% ~3 F) T1 h; a8 D
- #define DMA_FN_IN0 n- l/ R. L% J' g
- #define DMA_FN_OUT: E/ B" @& z/ m+ w# C
- #endif' t3 u, \6 m" R
- & F$ `1 V; r) r2 j5 m! r+ b1 e
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)% L Q+ M4 s* Y, @3 W, p) d2 c9 L
- #define STATIC_SHIFT 3
" y+ p5 L. d+ _% L - #define TCINTEN_SHIFT 20" w( O( j, b ?( ?. e, H
- #define ITCINTEN_SHIFT 213 }1 r. Q3 E6 p" X, v& T
- #define TCCHEN_SHIFT 22) [$ d: ^6 {; _
- #define ITCCHEN_SHIFT 23) v0 |. S( ~0 K, ], ^+ d$ l/ F
+ R/ I! @! |: q) U; V- static volatile int irqraised1 = 0;
/ L1 d1 s3 w9 g6 \6 v0 x# u% { - static volatile int irqraised2 = 0;+ v! k6 a6 {/ [$ v3 c
- 5 c8 _' @% f& o
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 O% b6 a$ d) v' U
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 [/ L# o9 Q9 ~ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 ^& J8 M/ Z. r; `: ?
0 W3 E+ q; r& p8 @ ]- dma_addr_t dmaphyssrc1 = 0;' {5 P4 H7 f- T8 h
- dma_addr_t dmaphyssrc2 = 0;( v8 C Z z# w. ?" d5 x& i
- dma_addr_t dmaphysdest1 = 0;" a0 Y. k' G. M3 z
- dma_addr_t dmaphysdest2 = 0;
) f' E- m% \; @7 X' J8 Q7 f - 8 U; i1 k4 O- d3 ^
- char *dmabufsrc1 = NULL;4 u- ?0 C+ T7 C8 h& ?. j p4 r
- char *dmabufsrc2 = NULL;
# N5 `& }. E/ w' q' y/ } - char *dmabufdest1 = NULL;( }% L- z) y( e8 ?2 g9 m/ L* X2 O
- char *dmabufdest2 = NULL;
! U! I0 i3 }6 O/ ^% _- Q* @ - 5 i3 L1 c- ^9 z# q
- static int acnt = 512;
/ U1 l" p N+ E+ V% i - static int bcnt = 8;
. \4 E" Z$ n" j4 y% Y( p! W1 j6 D6 c - static int ccnt = 8;1 u$ N1 p, @9 g- g0 n( t0 M, Q
2 d9 G$ I3 N8 t- module_param(acnt, int, S_IRUGO);
" G" E8 U9 e* s/ @ - module_param(bcnt, int, S_IRUGO);% c* |/ O2 d3 Z: }) [$ Z: G5 k4 Q; m2 w
- module_param(ccnt, int, S_IRUGO);
复制代码 ' J. b b0 U. n5 M6 H! q
& a1 b$ P0 [) n! _3 Y( ^. [1 X
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用7 n% x5 D) V1 o/ [5 R
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% i: i+ R o) r& h, o" \9 ?/ q U 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。( m. S+ F! O3 s$ {( n S- i" u
: j- ~" E2 d, {1 Z
3 {) ]2 T+ J# q: G |
|