|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : Q+ h( w- _" j9 C& s k
- [code]EDMA sample test application
0 v! B; {5 ^5 R0 s$ O - /*
2 I# j) j% X1 Z4 [0 ^- @ - * edma_test.c
. A2 d! t; d9 {# R' z2 y - *
& s2 a/ P0 W9 ~- B, \ - * brief EDMA3 Test Application
8 o" v- q: h/ Z) ^- Y5 _ - *
2 z, z5 x8 j8 R% h }1 d" q - * This file contains EDMA3 Test code.
0 W: `0 z0 z& ? - *
1 I/ S. w6 D: f. f - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% V6 e/ B3 p! G6 C' s- i - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
* [" X( J2 r' U! K# c8 U$ v. } - * TO CHANGE.
9 c/ ]3 J3 ^0 v - *# y3 d& I, H% c) C! U3 s
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
9 S. E3 {6 m" d" h* O0 W" J - *' n7 [; l: K& ?3 ]! L
- * This program is free software; you can redistribute it and/or
2 K7 n% P- q/ a0 \' L2 f. u - * modify it under the terms of the GNU General Public License as
! Q: _6 V3 _4 }- s2 L: e( F - * published by the Free Software Foundation version 2.
# z5 f0 l5 x5 K3 B( G& z% A - *
. P* `- l4 N2 D& |5 L& _: } - * This program is distributed "as is" WITHOUT ANY WARRANTY of any' G M2 E# b7 x* E" N9 V4 t# c
- * kind, whether express or implied; without even the implied warranty. ~$ [% z( F" ~; v* t9 p: G$ n
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 ^ |( y5 ?4 J. \4 z - * GNU General Public License for more details.4 J# q1 x4 i+ p5 U
- */8 T! N2 i/ ]3 {! ^0 F+ O! b
! F" w+ Y3 \( a9 x: j0 Y- #include <linux/module.h>! B: b! s; z/ |$ `
- #include <linux/init.h>
( _$ H- B( i/ t - #include <linux/errno.h>! }+ \; m; x8 Z2 d4 {& u
- #include <linux/types.h>- Z, ^+ o+ c/ H8 {) K1 _: T
- #include <linux/interrupt.h>+ V- f' h$ X! j& b9 Z, t) W
- #include <asm/io.h>
# j& v. @1 m% F) [- t - #include <linux/moduleparam.h>- h' b- _3 j; K
- #include <linux/sysctl.h>4 R. n' T3 }! }6 G0 e' u2 \
- #include <linux/mm.h>; b) m: e( g, R( A: {6 F# V
- #include <linux/dma-mapping.h># E- k0 T$ p3 L- B6 {! h* T
6 Z9 B9 [3 y( _; D) Z- #include <mach/memory.h>2 B! z/ |$ @. a! A" c
- #include <mach/hardware.h>' p% P: u$ ], [
- #include <mach/irqs.h>
" [/ }2 R. Q2 b. z* O- i, L - #include <asm/hardware/edma.h>
2 p; @* j( K0 u' g
0 [& m) R0 z: k4 E6 \3 ~$ _" o- #undef EDMA3_DEBUG
9 g( W+ @* G! f" p' i - /*#define EDMA3_DEBUG*/$ N" o) l! p# }: g
- 2 X+ k) y* [ z0 W4 c: X. X1 T6 V
- #ifdef EDMA3_DEBUG# Z* u, s+ {0 S, D8 u; x
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! g6 S( S" F# r" W - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ h* @$ E v/ E6 ~6 T, G( }* D+ \
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)2 D7 \5 [& Y7 K: N4 b
- #else! a9 B& D* d1 L
- #define DMA_PRINTK( x... )
1 d) Q/ P( Q: K5 ~1 c - #define DMA_FN_IN
- C: c$ m+ i1 N' V' R, u - #define DMA_FN_OUT$ f2 W3 r, q N6 w5 m' E" A; V) z
- #endif" k, q" o ]* l) l C G: ^
- 5 n4 ?0 W( c+ O# Z" {: `; u
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" Q. |$ t9 Z- H. P; q7 u. y
- #define STATIC_SHIFT 3
0 i; V8 v8 E9 R" e* ?9 S - #define TCINTEN_SHIFT 20
- x V) B; I6 ?, l- | - #define ITCINTEN_SHIFT 21# s1 s k9 C" _. X1 B/ R
- #define TCCHEN_SHIFT 22
6 A$ p5 i& V5 r- V% M+ j/ h# P - #define ITCCHEN_SHIFT 23
& }2 ~9 e5 c# v - ' m1 n. n7 B* \/ _' Q
- static volatile int irqraised1 = 0;: ~ a( T$ ~" a7 i4 v5 t2 a
- static volatile int irqraised2 = 0;: a8 N" {( s, J) b9 y) I L% u
- 9 z% f1 H. P6 b& T/ g
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; m& D* U/ @% y- D# f5 O - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, \- X1 y, n G; j. V: ~# {
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 h! [5 b) l' |* d6 |( ` U+ N
m0 m" ]0 L. x& v% }- dma_addr_t dmaphyssrc1 = 0;
+ d* W. Y/ v; _3 s - dma_addr_t dmaphyssrc2 = 0;
5 k0 o3 J7 g- F - dma_addr_t dmaphysdest1 = 0;
% M7 e. y ?8 ?. ]2 H - dma_addr_t dmaphysdest2 = 0;& e; R% k1 Z$ g- g; ~
- . Y) |3 E- J/ e% `3 t) @( }
- char *dmabufsrc1 = NULL;
& H( ]" b% K( b2 Y+ G - char *dmabufsrc2 = NULL;6 J& {$ Q) |6 U! w4 ]7 c8 s+ {2 N
- char *dmabufdest1 = NULL;
/ |2 M3 ?4 i/ S1 y7 T1 f7 n - char *dmabufdest2 = NULL;
2 B3 y" d9 g/ }4 v0 i A - * X7 k* c9 f& i) j, T! T" z0 C
- static int acnt = 512;
' J6 {( [' x" ?: N# e - static int bcnt = 8;2 I% }( v& j/ k/ p% S% C
- static int ccnt = 8;. ~2 }) \8 `" v
- 9 ]+ _- q6 O0 e, @7 P3 ^9 B
- module_param(acnt, int, S_IRUGO);5 H" h* F2 h, r: n0 ~+ z ?
- module_param(bcnt, int, S_IRUGO);
. P0 s# r9 e2 E - module_param(ccnt, int, S_IRUGO);
复制代码 1 A3 B, R1 J" T& L
" h0 j" |7 q$ D) g* b
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: {) {* \5 {+ Q t& Varm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
- L/ Y% j# Z1 v$ R) { 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
/ O: {8 B Y- K$ v* U
- ?) t3 U+ ]2 k
& u8 P$ I+ d9 M0 x |
|