|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 |/ S4 l% }( C% \- [code]EDMA sample test application
- [: G2 I6 H. N, |9 K4 k - /*
6 o' ]8 b; `: N) Z2 Q- S5 r+ _ - * edma_test.c7 ~4 u& Y; ]6 x" H0 g, {
- *9 G" c: }2 N; ?' e
- * brief EDMA3 Test Application* k4 ]# y3 t4 a; f* U
- *
& i8 p& x! k# D9 K - * This file contains EDMA3 Test code.0 \) G2 d, f$ {4 U( b
- *5 x9 I6 {' \ D+ x9 h
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, P2 L3 c8 ?. n) o, s& m - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 x: Z& n0 M' j/ z9 J8 q9 s
- * TO CHANGE.
, K" ]- n/ H4 \3 o9 I* v - *) S U% O3 u C2 f3 a
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/2 e- j ~, C/ V" R7 t
- *
. T* j! W# E/ j* m, S$ j - * This program is free software; you can redistribute it and/or/ l. c! k! H& `6 i. T& @, n& T
- * modify it under the terms of the GNU General Public License as3 ~7 V1 K; F- f6 A x) [
- * published by the Free Software Foundation version 2.( N4 M) m& E9 s- U! E8 K* `7 t
- *
# K5 a/ p8 l& a G# i* n5 @ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 w; R" ^& r6 F. U& T, `. v @
- * kind, whether express or implied; without even the implied warranty
" s; {: I" s/ d q7 L1 I" | - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the, \4 p( t6 @! v3 O) x3 a: I
- * GNU General Public License for more details.
7 R* B4 e7 P* ^9 v3 ~: L/ f6 b# V - */
9 g1 s' i/ {9 |4 }3 Z9 b- E& `
4 r% r/ ~5 `; a- #include <linux/module.h>
) Q8 t# ^- k/ i, t% S" x: J* ?6 b- | - #include <linux/init.h>; q4 C4 y7 Y' C3 o" |! C) I& |% V
- #include <linux/errno.h>
2 a9 B5 |" X. s. T - #include <linux/types.h>
) V% i5 s' D, D3 K! Y - #include <linux/interrupt.h>
o2 \* M8 N6 b - #include <asm/io.h>% o9 z& z% q. A% J' W
- #include <linux/moduleparam.h>
# I' v, b3 K! E U+ v3 V7 ~( X- Y - #include <linux/sysctl.h>
! ~1 l$ B: U$ ?; B t - #include <linux/mm.h>
5 F. R! {- k" m9 \/ E* F - #include <linux/dma-mapping.h>( Z( K. ]+ n: w+ U
- 9 Q' G( b1 @1 `+ S0 k
- #include <mach/memory.h>3 e5 q. v' g D3 f/ i/ A, u( ]5 M
- #include <mach/hardware.h>/ r8 Z" `& |% P J- f
- #include <mach/irqs.h> _5 L+ L/ n- Y! ]8 I- _+ `
- #include <asm/hardware/edma.h>
3 E. E" N/ z" @- [ - # J- {! c3 g, C0 j. O, c, z
- #undef EDMA3_DEBUG. L) o. n0 T% N* }
- /*#define EDMA3_DEBUG*/% T: o: K w n) W/ U' c
- 3 ~# H/ n* g h/ V. g3 c
- #ifdef EDMA3_DEBUG' R# s" E$ S) e6 Q; @
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)* \! J8 b; x; c, K& l$ M4 z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 S! b. L" ]2 N7 N N - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
, w3 D4 I Y" | r) @5 y- G8 d; d1 h- } - #else- X3 t8 P5 @ Q) ^ N$ `( Q! M
- #define DMA_PRINTK( x... )$ P- `/ P. ?1 o8 e7 V8 q( q5 `
- #define DMA_FN_IN
7 ~+ Q: S8 f$ K2 R9 ^8 T$ L$ L1 d ` - #define DMA_FN_OUT
% g, O. }0 g( B2 t) o* N/ w& i" Q - #endif
6 r4 W7 i+ V# g* Q8 R& C: D - 7 Q% X9 e/ e1 M4 v' U
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, M9 f/ r9 o* |. o& u1 L - #define STATIC_SHIFT 3' w- l( f8 p# K7 P
- #define TCINTEN_SHIFT 20
& @; X% G6 n/ b - #define ITCINTEN_SHIFT 21
+ r, D0 ]+ K% y2 j. U8 ]- l - #define TCCHEN_SHIFT 227 s7 S0 w0 W% l7 E g {/ L5 k
- #define ITCCHEN_SHIFT 23/ H* O* C. [$ n
4 t8 g8 G& J( i4 Y% k7 T$ T7 i- static volatile int irqraised1 = 0;+ G/ r( P9 I, |( H& V
- static volatile int irqraised2 = 0;
4 [; U& t b8 z! _+ r# i, ]+ P - ( I' i, h: a: F0 ^- i1 H8 B
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' D" S2 T( _+ a+ c& p
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 |+ i) G! h. s# f2 Z1 z
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( N" V7 R2 g! F5 T8 f
% j- A& t$ o4 O% {- }- dma_addr_t dmaphyssrc1 = 0;
1 P0 c- j. ] c) y - dma_addr_t dmaphyssrc2 = 0;
1 _+ v1 h" J) e5 _1 } - dma_addr_t dmaphysdest1 = 0;5 j" k* T! |" |* L
- dma_addr_t dmaphysdest2 = 0;
: Y- b B% Q; }- _- X
4 B4 R y; a0 `& {7 o5 l- char *dmabufsrc1 = NULL;; \. k v/ ~7 p, x: `& K
- char *dmabufsrc2 = NULL;( E1 S0 p; V, u! }
- char *dmabufdest1 = NULL;
+ @& J: `6 { d* ~. C" |8 T - char *dmabufdest2 = NULL;3 Z8 y! K3 Y8 |( r) C
! a6 A. E+ E7 y4 }4 F2 R- static int acnt = 512;- _& C. M! f& j( }+ C# p" Y: h
- static int bcnt = 8; |# p! A3 a, a: N# o p
- static int ccnt = 8;1 i' q$ H3 {0 f" O& U; e w
: L0 ], \7 G7 }" r" w" d! D) w- module_param(acnt, int, S_IRUGO);0 e7 w4 s* S$ Y
- module_param(bcnt, int, S_IRUGO);: X/ J% {+ k) e' a
- module_param(ccnt, int, S_IRUGO);
复制代码
3 x/ N. W+ {' _, ] n, [; J' M$ r& w/ n
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
( X# q" P2 v3 l8 |% u. y$ q% `. `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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。+ X' Z5 L3 N4 y
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
$ ^: H5 L2 k1 v& i8 D2 C8 |, s
- Z( Y$ k8 l; M8 C1 A; {$ d
" D/ ?4 l7 w# h' N& E |
|