|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 3 ]5 B! y( W1 d4 [* U4 W
- [code]EDMA sample test application8 N" U/ [! ?2 f# f3 z
- /*
7 ~1 M4 p3 V/ [/ ?; Z- o8 Q; _7 w - * edma_test.c
; }# G6 K0 ?7 v1 ~9 `8 P - *
! q7 k/ N/ l$ ~- {+ O* u6 C% V - * brief EDMA3 Test Application
6 t1 f/ c! h3 J' \! h/ n - *
1 a& V$ m; @$ T, C+ p - * This file contains EDMA3 Test code.& s. r& A; @, P' L
- */ g) ^" Q+ }+ K! x# z
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, M" [4 Y" C3 V( \ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
# |, y+ t. b6 O% k+ h7 R) B - * TO CHANGE.
' r4 P$ g: F' o+ b. ? - *
! Y3 O2 b/ g# Z; `5 T& P5 _ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" T/ |. J# q5 v5 G
- *. }" f& P4 F$ Y, E/ M7 J2 o+ I8 X
- * This program is free software; you can redistribute it and/or
& n7 D2 b! G$ }0 g, X% c" j* ^2 l - * modify it under the terms of the GNU General Public License as
! W, r1 D. q/ { u( L* N8 o: U( w - * published by the Free Software Foundation version 2.7 Z3 F [3 |+ N" u& ~
- *
7 H. T5 Y- `" a; j- r' \9 ^ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
1 R6 q6 M H% ^0 n - * kind, whether express or implied; without even the implied warranty4 r7 s$ L, @' w: ?4 t8 y# F1 q+ i
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 }7 x, r, K& i8 T5 D6 P/ O# d! w1 K - * GNU General Public License for more details.7 ?) I+ \1 c& J
- */3 X. Q/ a/ C' k$ |2 C* M3 d8 Q: ~
/ }! q- G2 ]% @% @0 C3 K& _ T" B3 L5 i' J- #include <linux/module.h>
$ u0 ]4 d4 A% X" E* o - #include <linux/init.h>0 y9 U( W6 S3 M: \, F% o
- #include <linux/errno.h>, P! e% X2 |! A a$ k, L7 O
- #include <linux/types.h>
9 C j6 G- l' ` u3 j - #include <linux/interrupt.h>0 m3 ?8 I, h: \8 R' v$ ?
- #include <asm/io.h>; @' M$ Y6 l. g' x
- #include <linux/moduleparam.h>
" a r0 e1 P# F% g: Y - #include <linux/sysctl.h># [. {: j2 F6 M
- #include <linux/mm.h>$ g3 ?* t5 Z5 U' G
- #include <linux/dma-mapping.h>
4 C+ [' J; l% v @) e" f. m/ }
2 n, D3 }, b; d7 y& [9 V- #include <mach/memory.h>! a( O; t6 ?7 e0 |8 O% s! {6 v! F
- #include <mach/hardware.h> k. J- ^5 V6 ~9 I+ L
- #include <mach/irqs.h>
2 O) Y% d8 s% c/ R8 a - #include <asm/hardware/edma.h>
3 h y; f" S' \0 a
, c* g3 H; }2 V1 ^- #undef EDMA3_DEBUG
' H* Q$ q$ B* h/ q, ` - /*#define EDMA3_DEBUG*/# ^6 t7 T4 @; g3 J/ t: H
* `3 ]1 K/ e2 y& A- #ifdef EDMA3_DEBUG
3 [7 E- z) p0 j9 R - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
5 l% I7 s! A% N; \) u( s+ W! m - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
$ w! ]# [1 v+ [. o6 Z1 y& b - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* Y# V, p) }/ f/ v8 d) [; \' a3 y
- #else8 z: F! x9 Y( f! X) m( L
- #define DMA_PRINTK( x... ): C' Y( r/ h5 Z
- #define DMA_FN_IN
+ i: P9 O' O2 D J, t& H - #define DMA_FN_OUT
8 w/ m$ ^) E! {: Z - #endif
; t6 n! B. g8 a3 ? i/ F0 b - " [2 F* B/ M( T& X7 A& u; Q4 l: T
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ i0 `) o2 n1 P3 F4 g - #define STATIC_SHIFT 3
: H' @! m1 X* U( E9 f. \$ s3 ~ - #define TCINTEN_SHIFT 20
2 A7 `* ~" D8 s i - #define ITCINTEN_SHIFT 21
: e# v( o4 g" d+ d! p - #define TCCHEN_SHIFT 22
! t" g/ V7 l" |0 q3 K& \' z% d - #define ITCCHEN_SHIFT 239 j. J% G1 c7 [# A' g) a8 Y: ?* D( S
8 d1 p# L0 \# O; C; Q7 s+ Z- static volatile int irqraised1 = 0;* C) |" F* `2 E- h
- static volatile int irqraised2 = 0;
6 l7 j; |5 _, t% R% c4 O
% j+ a& \1 y3 V/ z7 W$ I" c! [# p- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- `2 h6 u R8 n% r$ b - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- I# w. ?) X5 M1 |$ |: s% p0 \ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 u z' M- E; }# e) d, M; _2 \0 _
- l9 m2 Z& A* G: ?' _" m. I" i- dma_addr_t dmaphyssrc1 = 0;! _; O( \- M0 A
- dma_addr_t dmaphyssrc2 = 0;) M! }+ A' z4 M& {9 L3 s
- dma_addr_t dmaphysdest1 = 0;1 r$ P8 [2 Z4 }7 D
- dma_addr_t dmaphysdest2 = 0;! i7 X z7 ]9 S* o
- q. X/ @/ t! \9 Q" U* y4 c- char *dmabufsrc1 = NULL;
4 T% n5 h2 @1 [: _- U1 k - char *dmabufsrc2 = NULL;
# m% t7 v0 O. x4 Q" z - char *dmabufdest1 = NULL;* ^9 W9 i# r2 C, m1 c$ Y& }$ C
- char *dmabufdest2 = NULL;
+ c: t" [. t& \/ E) M8 X
! y m* M, K* O2 |$ g. \; }5 C- static int acnt = 512;/ a; {. B. ?% d2 n# e
- static int bcnt = 8;
c7 A. e2 L/ U2 `- a3 F - static int ccnt = 8;# _2 a, a# _! X9 d) I. Q9 y
/ ~% `! p) R) M+ i2 u4 p( S9 v- module_param(acnt, int, S_IRUGO);) D0 _; X* R1 `& e, h, z: I
- module_param(bcnt, int, S_IRUGO);
( u9 K2 d" b/ E) m& h) m8 { - module_param(ccnt, int, S_IRUGO);
复制代码
9 w& \: w, b/ y6 k+ k: Y( D' r4 s+ g9 C
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用5 T3 }6 ^' m6 u) X& \
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
3 m6 O$ S) S5 ?' o+ G; n 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
5 P8 c5 d' h, [# R) [
4 c( l1 L2 {0 H2 N9 a1 P+ K! j- h: L! V: D) i4 _+ q
|
|