|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
/ F! x c" b5 q& s+ j+ {" x- [code]EDMA sample test application
4 f- R8 }0 g. I$ M; K. G+ w( p - /*
! q* E4 u+ `1 u/ N) x7 E - * edma_test.c
1 ]0 X0 c- d U3 q - *
9 O9 ^' g7 Z+ g2 w% B* x - * brief EDMA3 Test Application7 W* e m8 Q8 g1 l; \
- ** ^& K$ T0 Z3 f1 V, |5 @
- * This file contains EDMA3 Test code.1 k/ [* j3 @9 K v
- *2 g0 c+ S- f# b# g3 A
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& U/ U! [4 r8 Q8 ^ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 m, b+ k% }( N, }9 d9 } - * TO CHANGE.* O' e. R0 ~8 e. q0 Z$ n
- *
3 Y" ~9 x2 q4 S. H - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/6 d/ D, f1 u! \. Q& [9 M$ x
- *1 m* ~6 K& ^. \" z7 j* d w6 Y
- * This program is free software; you can redistribute it and/or+ X9 `, A& a7 T1 L- Q8 d/ i
- * modify it under the terms of the GNU General Public License as! _2 @9 j3 K: k/ @9 w( M
- * published by the Free Software Foundation version 2.
( y( I/ |5 V- d0 F - *
0 d% L/ V# G" [' o3 N, O2 Q - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 b) F6 r* k# i; v+ H: l5 i - * kind, whether express or implied; without even the implied warranty( O. q# B) D( n. L
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2 q, O; v2 j# Z) l# x; Y4 d; O
- * GNU General Public License for more details. W2 C. c1 _3 w0 z) A0 e% d6 n& |
- */. _8 {% J& e+ ^5 ~, D( m% r" ~: \! C
- # w5 ?: J6 M5 ^- L6 Q/ b
- #include <linux/module.h>
' c; j1 g8 m( s/ }* p - #include <linux/init.h>! ~! \2 t3 w% A, m. W$ H
- #include <linux/errno.h>
8 Q- W! p: y4 q; F. q6 L - #include <linux/types.h>! q4 G+ Y: _1 a
- #include <linux/interrupt.h>& }: Y$ t f9 y
- #include <asm/io.h>
( x( U5 C4 H$ ]5 Z8 _( v! _ - #include <linux/moduleparam.h>- {& Z4 N: _7 P; h0 u1 b" D4 g7 F( n; I
- #include <linux/sysctl.h>
[9 S7 s+ l. i8 @ - #include <linux/mm.h>
* c V, T1 V3 p0 B& [) M - #include <linux/dma-mapping.h>% [% z5 V0 \ i+ I
- ; a$ S% I' |4 N8 Z6 V0 \1 u' p
- #include <mach/memory.h>* D A( k4 B1 I; ^. ?0 |! H
- #include <mach/hardware.h>" L, }9 i5 [. E2 P& [% w
- #include <mach/irqs.h>
6 ` |3 T+ L4 ?: L1 V h6 v - #include <asm/hardware/edma.h>2 s2 R3 s _8 \' z2 U
# ~6 e; w A- l6 Z4 S) v( @- #undef EDMA3_DEBUG
# t4 P# u4 y' \8 Q& e5 i) ^8 j. Q - /*#define EDMA3_DEBUG*/
' i, c- b9 F! T. u/ }
+ Q# p9 {6 J9 ~, d) {+ q- #ifdef EDMA3_DEBUG
/ t b2 }: [% r# x - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
* o, k$ _, P( M4 G+ _; f) W ^ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) }% h) B& f5 Y3 t
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)- Y2 g- U1 r; T
- #else
) e* z% b+ ?5 R% A- e9 B - #define DMA_PRINTK( x... )7 H. o6 _5 o' O: x; I
- #define DMA_FN_IN3 }8 K0 F" m5 F' ]: b' R
- #define DMA_FN_OUT
! k- K# y- V% u4 A7 X: u" g- ^7 h - #endif
( p9 K1 P8 h2 C, o5 G
b% i# H0 n! U# L& A3 X4 P& |- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( J! K) L$ {# m) b+ c
- #define STATIC_SHIFT 3
% }+ |' e% e- c, V' ?& ~# P - #define TCINTEN_SHIFT 20" b1 h P/ A7 `5 R+ k
- #define ITCINTEN_SHIFT 21* D" {6 h2 ^4 j
- #define TCCHEN_SHIFT 22
, ]; c, m @7 E - #define ITCCHEN_SHIFT 23
' y- @+ C+ M0 Y) w! q+ V - 3 S! r* d$ q- X
- static volatile int irqraised1 = 0;
0 ~3 x( U0 Q, X5 R8 N - static volatile int irqraised2 = 0;
0 _; u2 h' N- R: L8 n u+ P2 K, y
( ]$ b6 r- t6 S0 @! R( a3 o$ v- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& B$ u( \$ } q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! c" M( h# L$ [/ e3 { - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& x6 Q; R/ u4 T - * |0 u+ n# f1 Y. A& o0 W: P
- dma_addr_t dmaphyssrc1 = 0;) k* H! y; z6 _* q) [3 n
- dma_addr_t dmaphyssrc2 = 0;6 I6 a5 p4 }& a% _% b Z9 b2 m
- dma_addr_t dmaphysdest1 = 0;7 [5 C/ a3 M! a6 m2 j' ?
- dma_addr_t dmaphysdest2 = 0;6 _: Z4 w U e5 W8 W; a) f
2 w1 j r, v% b n4 G- char *dmabufsrc1 = NULL;; B! a: O; y. T
- char *dmabufsrc2 = NULL;' P& \( i8 d" X' B3 k0 Q, v4 F( Y
- char *dmabufdest1 = NULL;
# X) p! s* x5 {5 o3 r) Y+ _ - char *dmabufdest2 = NULL;
0 ~! M* n4 k. Z* u - $ _8 {9 s( m+ E3 \# {( L0 u
- static int acnt = 512;* z( Z1 D3 F( E
- static int bcnt = 8;4 j7 S# L8 B6 b; r- x' I
- static int ccnt = 8;
z+ Q J8 I3 [# u: _ - , G8 I# a* `- x
- module_param(acnt, int, S_IRUGO);; s {8 ], D% p+ P8 h: n! Z, [" Q
- module_param(bcnt, int, S_IRUGO);& _# _" ^5 T# o) c( x- p: ? j! U0 l
- module_param(ccnt, int, S_IRUGO);
复制代码 , f9 M9 @8 z/ ^1 ]
0 A/ s' r. a' Y1 J. r" j; v
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& y' V# n. d: e$ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( d! O! I3 o+ a* Y. }% `
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 F9 j" n( A* j. S
7 o& i& `' ?* e, `% j! w' e
$ O' |& ~5 O) A; `3 t7 h |
|