|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! F8 f8 k* S. w6 e- [code]EDMA sample test application9 G9 ?9 U( U8 K8 p
- /*
' l; P1 c* j% ~3 L - * edma_test.c$ i' s, R% Y6 w0 I% [3 E
- *, O2 J* o( t/ r3 H
- * brief EDMA3 Test Application
2 _/ T7 Q0 q% N. F4 s% w/ S& Y - *
. c# S, X" ~; p$ u1 Z+ a/ E - * This file contains EDMA3 Test code.
$ Y+ ~* ]; R6 v3 x - *
! J- y4 o5 [" m7 q; |: K. Q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
4 K+ a# H. u# U S+ B$ I - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
) V+ g1 I' Y( g; s+ t1 P - * TO CHANGE.
! ^- \6 N% s/ X+ S - *4 Z3 K& U6 J) E$ ~
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 e; {5 J& ?# C2 }
- *
1 K( x: P4 X/ d# S4 o. B - * This program is free software; you can redistribute it and/or
/ E* `0 W! T% Z' J+ P - * modify it under the terms of the GNU General Public License as" G. r; q! I" g1 x
- * published by the Free Software Foundation version 2.
2 T, K V- M. a$ F$ ^' m, I - *9 U9 @5 f- ~' }# e7 |" h, A
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
7 H$ P0 ], ~- D" D; c3 Z& m1 _ - * kind, whether express or implied; without even the implied warranty
6 [& o' P/ E/ I - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ K* A* S; @9 g6 O. v% p
- * GNU General Public License for more details.8 A1 [' n- g. b& f
- */
- _* X. A7 D/ r7 ~3 S! T6 ] - 7 S; K8 K5 p8 t2 k. e
- #include <linux/module.h>
$ ]' f% q, J9 o2 r u - #include <linux/init.h>
, u# o) _3 W! W7 M - #include <linux/errno.h>4 _, A; Z0 U7 h! F0 Z
- #include <linux/types.h>
8 F4 A$ m7 G2 W; x - #include <linux/interrupt.h>
I: p( x+ E, m5 } - #include <asm/io.h>+ B% Y8 K: x: I
- #include <linux/moduleparam.h>+ Y q4 A, ?% d) T
- #include <linux/sysctl.h>. X( e# H+ g' J) s3 m: e
- #include <linux/mm.h>
2 ]$ D& W& |2 l) C - #include <linux/dma-mapping.h>% S# }$ x8 a5 r8 F; r: l
0 A$ @3 n. ~' D0 i8 x& X$ \* s- #include <mach/memory.h>! L5 a" \6 \9 @1 `' x5 [8 J, M
- #include <mach/hardware.h>
% Q0 c+ D% x$ V4 N# i" o - #include <mach/irqs.h>
0 b+ @9 s! ~# F5 A; T7 e1 d4 s2 k - #include <asm/hardware/edma.h>
0 m" N* @1 c* G E+ O! e5 o4 ~ - 8 X( y* ?6 w. i! Z, W; X8 e2 Q
- #undef EDMA3_DEBUG
1 j5 p1 f) l4 k ^) B - /*#define EDMA3_DEBUG*/( a. x( N' w. i+ `
- 2 Z& i1 Z, d3 b$ ]+ a: `
- #ifdef EDMA3_DEBUG
8 G* \9 K8 n: r* T; c - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)) m5 r0 j" e- I; M7 ~
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ P9 f$ [9 R: p/ }
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 Q' g7 ^# n. \9 ?9 j
- #else& c0 z$ G" W d; I( i! d3 `
- #define DMA_PRINTK( x... )- F) u8 w6 h! t7 i: y
- #define DMA_FN_IN N) t! A q* E* l- B1 S+ w
- #define DMA_FN_OUT$ M2 T! ? t- d0 [3 H, j4 V+ h4 b
- #endif
8 e$ t9 O! P/ C6 i. C
' F! _( p: t: A3 ~2 h" ~! t- #define MAX_DMA_TRANSFER_IN_BYTES (32768) N+ _$ P# `/ D% I1 j( A: Z
- #define STATIC_SHIFT 3
% r0 i: X3 J7 j2 S$ j - #define TCINTEN_SHIFT 20
4 E! o! e5 ?* ~ - #define ITCINTEN_SHIFT 21. Q9 g7 }/ W+ I0 T2 M
- #define TCCHEN_SHIFT 22
5 O4 D+ \$ i3 e* t! ~/ C - #define ITCCHEN_SHIFT 236 m$ P4 S1 M0 y& `
% L; v6 N; S2 |$ O1 r6 e( c- static volatile int irqraised1 = 0;% }; ?' \6 ^9 {' h& b: ]
- static volatile int irqraised2 = 0;) y2 R! `) t( t/ k1 }
+ u: ?4 l: \8 k- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 s8 e' ]6 x U9 Z5 Q* M8 b: l - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 o8 ]9 Z4 \" t
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) T& D5 \. ?6 D, W
8 K1 D ?# k7 p+ A1 ^7 Y- dma_addr_t dmaphyssrc1 = 0;
o* P$ x4 ^ c2 }' B - dma_addr_t dmaphyssrc2 = 0;- S& q# E+ P* E& v+ {
- dma_addr_t dmaphysdest1 = 0;
+ c6 J, ~* L! ?5 F5 e$ V4 R - dma_addr_t dmaphysdest2 = 0;
1 g# c+ f. ~+ O3 O8 R
& J' ]" p8 q9 Y- char *dmabufsrc1 = NULL;
* K4 T) A' J" p" J1 } - char *dmabufsrc2 = NULL;, Z* _2 n ]+ h0 K( [
- char *dmabufdest1 = NULL;
% v& u. B; F4 H# I$ d7 Y) y - char *dmabufdest2 = NULL;
7 v( y4 n. l, L8 k3 X( o* h) s# U
$ K: v8 v! I: r( n7 `- M- static int acnt = 512;
2 G: g& j J: R" ~8 w5 C* ^ - static int bcnt = 8;
" |3 z8 f6 l* }1 u8 l5 y; r6 b - static int ccnt = 8;
) T! G; |% V2 o
% Y; x, G s9 \. e" x- a: I" u- module_param(acnt, int, S_IRUGO);
- ]5 H7 @6 i0 E* |( U& [% O - module_param(bcnt, int, S_IRUGO);
0 {5 y- R# X Q4 X9 M* k - module_param(ccnt, int, S_IRUGO);
复制代码
! `, m: M0 P/ M: U% V
" Q3 p: j s/ r/ k4 R8 {5 z 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用: x) ` C+ M: c* n: d* S( q& T
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& v* f3 _) s7 W v! C
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 C/ |) f- a2 U8 \8 _# w' n4 _
8 z! n5 l9 x$ |. T
; d% y+ ]& c* ]0 q: a) j
|
|