|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
8 \6 G* F) u2 w% d+ ~' U& v" B- [code]EDMA sample test application
7 f, g8 H9 V4 A8 j- d r - /*
' }5 [+ T* ~5 ^ - * edma_test.c. ?& k; h( O, e5 M, L h
- *
0 ]) h7 b# N* | - * brief EDMA3 Test Application
& W, B+ U& N& c9 k/ }# |# R& X - *
6 s/ O) a) }9 u3 ~2 p - * This file contains EDMA3 Test code.
. n3 v& n: {8 W( B: l5 Z) P - *
$ K+ |% n: C( i! o9 ?. G |9 V - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, Q6 C2 O' E/ p* {5 k+ n - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
5 [5 O( t' _9 G X/ Q; Z - * TO CHANGE.
% v! ^& Q9 @- X - *
3 n9 n0 { f: g$ l$ B2 j1 q+ m& C - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/& D0 H0 m# d9 V
- *
$ r' k: N& E- M2 L$ Q0 U- M - * This program is free software; you can redistribute it and/or) I T+ y9 m& G5 D2 N7 f5 V( p2 x p
- * modify it under the terms of the GNU General Public License as( x5 u7 G4 z/ P' Y4 k# R9 E
- * published by the Free Software Foundation version 2.
! Z4 [6 Y/ G5 q- T5 R - *
/ r0 ]* j. |+ i- P7 _" r1 Y, U, ? - * This program is distributed "as is" WITHOUT ANY WARRANTY of any$ J% Q3 M5 f* s- y
- * kind, whether express or implied; without even the implied warranty
2 }; I* X# W4 v/ { - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the2 n- _6 q/ j0 R- u" U- N
- * GNU General Public License for more details.9 ?' S& ~, ~+ M9 K, r8 r7 n
- */; \. O' l* X% Q; S) [4 j
. u' A& R$ d2 m- #include <linux/module.h>$ ^ u7 E$ t2 v
- #include <linux/init.h>
9 w# s9 H( N8 T1 {7 m* Q" P1 E - #include <linux/errno.h>' O3 U2 b! A% g2 {. x- J& B- h2 {) G) I
- #include <linux/types.h>" C2 t ^/ E1 j& @: z: n
- #include <linux/interrupt.h>; A5 Y1 @" i3 z$ O% w U8 b
- #include <asm/io.h>3 o+ a4 ~- b8 @7 `
- #include <linux/moduleparam.h>+ }$ a5 n+ }( E, Q9 V
- #include <linux/sysctl.h> \3 w$ e1 w$ d+ d. T, H
- #include <linux/mm.h>
% D1 X+ D' ^4 F3 X - #include <linux/dma-mapping.h>; S* {+ K3 p# d' A' E
- 3 T' E/ ]/ F, m8 t' {. T
- #include <mach/memory.h>& B$ M, {" p5 p! p, V
- #include <mach/hardware.h>: B1 ^! s; Y# T% a! U6 `. ]
- #include <mach/irqs.h>
( B3 c% F/ B" t5 Q' v - #include <asm/hardware/edma.h>! t3 N+ i$ j7 _/ Y1 _ s5 Y$ {, b
- . ~1 M$ ^% m" a; v
- #undef EDMA3_DEBUG( Q$ [4 }, s# a& p& K0 w
- /*#define EDMA3_DEBUG*/
/ R& w' R9 ?- Y: p$ c; v+ H8 G: a+ | - 7 P) b7 u, N, n
- #ifdef EDMA3_DEBUG2 ?7 X2 T. m ~; W; R
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% ^; L [& o: Q
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' _9 `( ^/ e2 W6 [% t- w - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& t# p/ U: Y% R. @
- #else
! S$ f9 }/ i! }2 Y0 `' N - #define DMA_PRINTK( x... )
' ~% ^2 n- P" R) \ V" F# E- Y - #define DMA_FN_IN
$ [0 d2 i0 L& R$ l0 p) t$ ` - #define DMA_FN_OUT! L# c( N% Z2 W/ a
- #endif( f# Q8 M/ C" f: l! v1 R( l- y
- - i9 K8 T0 f) |# Y
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
6 D$ f! a2 T5 N: M: y - #define STATIC_SHIFT 3
: k' \- u5 N9 f* T - #define TCINTEN_SHIFT 20
. _5 `! D/ i. a; Q; v' V - #define ITCINTEN_SHIFT 21
: e- i" ]" |" H" D( W5 @$ F& x- t - #define TCCHEN_SHIFT 22, Z( s4 I8 Y4 j& m. |
- #define ITCCHEN_SHIFT 23
* [$ Z. f8 M+ u% @' b. @/ i
' {" K) \, v; A* W. ]& l( c- static volatile int irqraised1 = 0;
, ^. v4 H& |9 v4 n8 _. e - static volatile int irqraised2 = 0;8 T; c: c# G7 h
- 2 U z5 f. @3 U% m. w. }
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' {% ?! j; n, M" F
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 o4 P' p4 z ^
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" ^1 n7 ^2 `4 O* r% Y
* Q, p4 ^/ [% n Q& a, p5 z- dma_addr_t dmaphyssrc1 = 0;8 y! f: B0 Z2 m+ x& p
- dma_addr_t dmaphyssrc2 = 0;2 g: K& J! [4 `3 O( h" L5 _" @
- dma_addr_t dmaphysdest1 = 0;
* V# H- I: f6 v. X - dma_addr_t dmaphysdest2 = 0;
, C: [& K. K3 J- k7 ?/ e8 ]
' n3 @5 d" F( x# P$ i( w- char *dmabufsrc1 = NULL;3 g5 d8 _- q# ]# \( p. \0 N3 }
- char *dmabufsrc2 = NULL;
, N3 t" |5 O5 g! p - char *dmabufdest1 = NULL;
7 z5 w7 k- k5 q - char *dmabufdest2 = NULL;
6 I5 h% k! G1 _: i
" z7 j( \: Y; H' U' z# U. a- static int acnt = 512;8 ?. [; \" H3 Y+ V/ Q
- static int bcnt = 8;- g0 i4 G: K5 F- @! L
- static int ccnt = 8;: S5 X/ W. T* ^. Z' J$ M: ~6 j
2 V( K1 D% B" j/ n |5 k- module_param(acnt, int, S_IRUGO);5 z* R) t5 M! W2 ?! y
- module_param(bcnt, int, S_IRUGO);
" X/ d$ h: q& \" g& B - module_param(ccnt, int, S_IRUGO);
复制代码 $ p, j6 @7 c2 _* x1 Z% i$ Z6 G
) t' t7 A& J- m) h
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
, M. ?, f! O$ a$ n' I. l/ @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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。+ F- D5 S6 K( w6 {6 o, x
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。6 @! ^0 Q/ z5 h$ I% E1 a5 `
3 b9 ^2 k2 m: {# a- {
' V7 n# S' t5 f( }
|
|