|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 e- N6 C! r# a- [code]EDMA sample test application
/ W0 X1 B. B+ U$ _9 l- V d; I+ J - /*- D1 K; p& ]( w0 k$ x# A9 p
- * edma_test.c
! v9 j/ n/ T: u - *4 ]5 c1 N/ _# Y) P N
- * brief EDMA3 Test Application7 S. |* f. B( @) t4 S
- *! o4 S4 m7 T6 f. c1 Q
- * This file contains EDMA3 Test code.
2 P$ X" N% B1 v! a+ |! v5 Y2 y' \ - *
" d. ]+ K9 @% B+ R - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( j+ B' A1 I4 }3 b1 Z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
; ~ ]* ~8 C, N. k ^) ]) L( [2 | - * TO CHANGE.
M2 y/ {% g! a+ V1 r3 q" j - *
+ n5 t3 z' W1 T! U4 I: P - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( ]& v4 {+ k5 p4 _2 w
- *# p: B, B% @" y# z4 J
- * This program is free software; you can redistribute it and/or5 r2 M& M* X# i- G3 Q) L9 P0 B/ P z
- * modify it under the terms of the GNU General Public License as
2 r3 v% j4 G$ e# f - * published by the Free Software Foundation version 2.' V+ y9 g) v( |; Y: Z
- *6 T; F; v+ ?7 n) A. ?
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 o# n6 c+ G# D8 v* {+ a
- * kind, whether express or implied; without even the implied warranty& \9 F$ e% u6 I9 f
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8 d9 Q8 @" E0 E/ Y, O& S( @! t: C - * GNU General Public License for more details.
# y: m2 k1 M. I0 T: H# X - *// }& D( U7 z3 N! U6 y8 N) b+ Y
- ( S2 o3 m9 I% ?7 T9 {1 A, s
- #include <linux/module.h>8 M& e3 |" Y5 `
- #include <linux/init.h>
- _3 ]4 y+ R0 l. c4 L - #include <linux/errno.h>
# X' k, {3 L! N; k% Q$ R - #include <linux/types.h>+ N) J0 B6 A7 L! U0 n# d/ j7 L
- #include <linux/interrupt.h>
, `& d/ Q0 Z) i. r - #include <asm/io.h>
* U' ~& c/ K( f4 ~. C4 B! g - #include <linux/moduleparam.h>$ e, W8 l- N, J, Q
- #include <linux/sysctl.h>
$ _ L* t- q: u+ d1 D - #include <linux/mm.h>
l! |& I: E0 V7 U: N& b - #include <linux/dma-mapping.h>
+ J* ^$ l) o0 m3 n& s6 N - % g% F- g+ ~! m1 ~1 ?4 f# e
- #include <mach/memory.h>
1 {% Y- i6 f y ^ - #include <mach/hardware.h>
. k& T6 X5 i; r- {7 t2 g+ } - #include <mach/irqs.h>
# [& B" l9 j) D5 A- c7 B% y9 ]# _ - #include <asm/hardware/edma.h>2 @" {: U5 J& F
2 G! n& k/ L) }2 ]+ D7 n2 d& o- #undef EDMA3_DEBUG0 g/ N& I- L- R" L4 J4 n
- /*#define EDMA3_DEBUG*/$ [' U) r# E2 ~. g7 l
- - A* Z* l# e/ t( I+ O
- #ifdef EDMA3_DEBUG
) Q( p o h8 u! N - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). W' ?: N( b. l5 D/ {
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) M8 [, N/ d" X2 L# E8 A' u4 S3 x2 I
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)- U7 ~+ _9 C/ ?6 p& ^ o! M
- #else; K: ]9 Z4 o% m0 Y: D5 U& u
- #define DMA_PRINTK( x... )+ Z* |8 ~* e: |0 f4 ^% Y" A
- #define DMA_FN_IN
' Z) V( ~1 k9 k - #define DMA_FN_OUT
4 `; F* r( P% H: F& Y - #endif' U N5 G M4 b# v" w. e$ w1 Q& M9 k
- ! r1 W2 D" f, i% {$ p: a
- #define MAX_DMA_TRANSFER_IN_BYTES (32768). y2 b( M2 N$ R. e X+ \2 `) |
- #define STATIC_SHIFT 3
" _, z% E( }7 ~4 A - #define TCINTEN_SHIFT 204 ]! w% n5 T) {& |, v
- #define ITCINTEN_SHIFT 216 z7 _- m7 g+ o# U( l* U2 H
- #define TCCHEN_SHIFT 22
$ C: H# F2 Y; v. }+ V' w. n& G - #define ITCCHEN_SHIFT 23
+ R$ w' y( O# P3 ]/ A3 p
x/ s2 O3 U2 @8 A* D% K- static volatile int irqraised1 = 0;
7 C& X; |+ k) A- v2 k - static volatile int irqraised2 = 0;
: V: K1 l' c$ Q2 o7 }0 B( u+ a - : s/ W% W1 T; U) l
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 r; K* n- e6 I* _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: _0 H, R7 q/ z3 |. Z) W& l' s
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 y( V; q: v4 t6 ]8 v# S1 E
7 q$ n+ E9 b+ m, X1 X- dma_addr_t dmaphyssrc1 = 0;
) Q2 R4 U, r" N* D: M3 z- w$ m3 o - dma_addr_t dmaphyssrc2 = 0;
x ~- O" V+ i+ ` - dma_addr_t dmaphysdest1 = 0;5 _: d; G- s6 U7 Q" o" c0 v
- dma_addr_t dmaphysdest2 = 0;* y' Y- S# [/ i3 O$ X' c
- 3 G/ W, ^# ?3 ]4 f. j l
- char *dmabufsrc1 = NULL;1 a4 l) \# \6 m9 q9 N0 ?
- char *dmabufsrc2 = NULL;( P1 y3 i" Q9 P9 d4 k, Y9 k
- char *dmabufdest1 = NULL;
' {8 M: s+ B0 m3 Y, z* Z* h - char *dmabufdest2 = NULL;. A/ e7 \! ^6 V5 {/ ?& h! ~5 M
. x- D4 y/ f0 ]/ G0 v: ~; N- static int acnt = 512;/ h4 Q9 u8 T& Y7 X G
- static int bcnt = 8;
Q: t- D$ m1 t+ d! c* L - static int ccnt = 8;
/ N9 z+ c: h! P' [5 E8 w - ! L: s" R9 e! A5 h9 c4 S( |, p: E
- module_param(acnt, int, S_IRUGO);
. J' @( r& b9 q - module_param(bcnt, int, S_IRUGO);
, M t8 G* }' E1 {6 Y! Z5 x* \/ [5 n" V - module_param(ccnt, int, S_IRUGO);
复制代码
7 J2 f7 X( _- s+ c$ |- F: m2 S( r) k
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用: v( j- x& g+ V& y
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; }: s* Q8 p# E! J- c* u
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) l) ]0 X" @' {, i' {8 ]! j
8 F% i; J2 j0 j1 d5 @9 B ~# D$ [
- I: F) E! u5 m7 |: n% J) s* ?) i |
|