|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 w m: V7 S' l! q0 X- [code]EDMA sample test application
4 l2 f, G8 A6 a+ K5 x B - /*4 ^( t4 }# b3 n) r. n# o% x% s
- * edma_test.c' v$ G6 W$ n6 T5 a3 H- `0 D' M
- *' ]7 G" A/ d5 i# i2 D3 U9 g
- * brief EDMA3 Test Application" e0 {, |" V+ o! N' h1 @- w
- *
+ `9 m: ]5 {. \6 Y7 ^1 R. v( d - * This file contains EDMA3 Test code.$ L' b( b! y: C- S$ j6 t
- *
! w4 b. V( F3 p( f# [7 T U5 r - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE+ D7 P4 b- Z c" b! ]
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
* A4 p, a0 D, J s' ?( }) ?: H' \ - * TO CHANGE.
* y9 ]6 t) q& F( k( `+ } - *
1 x, ^9 ]: ?7 x, b. W0 u5 y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 F0 ]& n/ c6 q& G4 g& B - *
: `7 ^; k) f ~8 x0 O, C - * This program is free software; you can redistribute it and/or. M6 m5 ~2 J* z* |' ]2 t0 e( V
- * modify it under the terms of the GNU General Public License as C& z/ z( T5 N0 u/ J
- * published by the Free Software Foundation version 2.& w- _4 Y3 Z" [9 @. j$ a7 T) Q% {
- *
, p2 U% y: Q/ o9 ~ Q5 p4 C - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- m5 ]! A0 g9 R) a - * kind, whether express or implied; without even the implied warranty
9 ^, { l9 f9 M* b% T1 T. _ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- ~4 L f; B' B) f4 ~
- * GNU General Public License for more details.4 W. j, o h5 ]6 O: R1 Z& f
- */- F1 p. Y1 |6 ?
- % x8 E' ]6 x0 X) y9 R
- #include <linux/module.h>
% r1 ~" o$ C0 ?! V0 _ - #include <linux/init.h>3 M' [1 {5 w& ~% T9 P) Q: u
- #include <linux/errno.h>
0 H/ f* q& H! g) p - #include <linux/types.h>
( g( a! n8 N$ P2 p! P( F2 i, D - #include <linux/interrupt.h>
6 x/ t5 T6 L' l' S& v- w - #include <asm/io.h>$ E2 H) ^" D2 }# F7 N$ F
- #include <linux/moduleparam.h>' B# B- l( u3 J' B' a1 h' D
- #include <linux/sysctl.h>
w$ x; e2 c: ~ - #include <linux/mm.h>5 I2 [0 p o5 {# P+ F
- #include <linux/dma-mapping.h>
- j. Q5 ?3 E* F4 k: m4 s$ T! I
) P. v' n# L& Z; J2 I- #include <mach/memory.h>
+ F& y, e, S( l3 D- X, m - #include <mach/hardware.h>! k) k" |/ S6 P0 y% w
- #include <mach/irqs.h>! g6 |; t) T2 c3 Q0 L4 J. @! ?) A
- #include <asm/hardware/edma.h>
5 O( z2 M1 x3 J5 ^9 u/ E$ E - 0 A& P3 i5 D# ]
- #undef EDMA3_DEBUG
1 l) A0 x& v/ I6 k2 L. x - /*#define EDMA3_DEBUG*/
1 H) W& q' P6 G0 N' _
3 f+ R- d) i l3 \' r! S5 W% }' Y- #ifdef EDMA3_DEBUG
. a8 M2 {- o- T+ [0 _ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)+ d; @: `2 n% j+ T2 F/ N
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 G* W: {2 A# Y9 M9 y" \
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__), y' n9 j+ n* i S3 B( b
- #else
; F* s* i+ i5 `! u/ C - #define DMA_PRINTK( x... )
1 b$ X( M! U# L' l- `. C - #define DMA_FN_IN% |, S4 P, F9 d7 W6 M$ O/ t
- #define DMA_FN_OUT" ]; }( _# C) ?" _. R6 ?
- #endif
% O* q1 y) t/ p( | - " N1 |# i- M* N, ^
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
6 B3 s) W& Z) J. n. \- T* L - #define STATIC_SHIFT 3
) [2 D& m4 P7 B, d s2 o7 L - #define TCINTEN_SHIFT 20
1 o0 s' F" n% q1 s - #define ITCINTEN_SHIFT 21
* f$ h" Y. G" z- j/ l% |1 N - #define TCCHEN_SHIFT 22' K8 h" M2 D$ {' N6 r4 ^
- #define ITCCHEN_SHIFT 23
4 f" q3 ]% x4 I+ d* Q2 V8 F - 6 m) }+ e3 @5 E7 G3 M6 A
- static volatile int irqraised1 = 0;
4 {: ^' S1 O4 ]0 m! E7 Y) L - static volatile int irqraised2 = 0;& S- u4 E. i1 i
! [/ Y+ S8 Y# A4 j& ] M8 T( ?- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# y1 [9 E+ P; t0 b0 p3 O/ q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! Q4 J2 x, r- U& T7 z! I D# q
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 S7 c0 U3 ^" X; m - , f' C0 u2 D r$ |6 E" u
- dma_addr_t dmaphyssrc1 = 0;
$ _/ Y0 f2 b& s# ? - dma_addr_t dmaphyssrc2 = 0;) o# z2 \ a0 S0 f, _1 E
- dma_addr_t dmaphysdest1 = 0;* s$ A: R$ ]; l- s
- dma_addr_t dmaphysdest2 = 0;! k8 J; m* b1 b
- ; p2 h& g+ d5 p; a8 U: a* y
- char *dmabufsrc1 = NULL;& B+ z& M* u- B
- char *dmabufsrc2 = NULL;- W& S1 `# S' W9 U6 C5 {
- char *dmabufdest1 = NULL;, R8 U6 u0 I/ ]* }* n
- char *dmabufdest2 = NULL;- S. X B) j2 B$ O& s S9 k3 d
- 0 Y# \ g: `' W, u0 S# J4 {: q
- static int acnt = 512;
9 ^+ f; c C0 w% z7 }5 K" W - static int bcnt = 8;
) p( R* F; j* | F# a/ R2 L - static int ccnt = 8;3 e0 a3 L K6 n/ z2 r; H
- 7 ]+ c+ u& v% [ P0 c
- module_param(acnt, int, S_IRUGO);6 P2 d* d9 s# a4 X: I
- module_param(bcnt, int, S_IRUGO);
* m$ a7 Y- s1 C8 f - module_param(ccnt, int, S_IRUGO);
复制代码
( T0 j9 V# \! t2 X( t$ G8 R
: _$ @9 T1 _2 e0 j' l7 l9 n; Y T 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
c0 V2 b4 E1 H5 r! Tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
9 V! L8 Q T! L$ z; X 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。2 X7 Y' H2 F0 K% l; ?
v7 j0 c7 v {; p9 X3 L5 r
) N6 b; X. X- W: n5 F |
|