|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- ?3 _) s6 I3 T6 s0 H2 F2 V- [code]EDMA sample test application' L# K2 L' `- x# X& e' I" e% G0 q
- /*
: R* z- s: f) Q" H1 \ - * edma_test.c
i( u% \# n! l. q- \9 k - *
) X/ C' V; z p) m2 a - * brief EDMA3 Test Application
' Y E3 B% k7 ?3 m3 M3 L - *% O1 m5 ?+ ]" o; N2 C
- * This file contains EDMA3 Test code.8 l- l$ @ k/ q( i) D/ U( D
- *
& l) R e! q w: P+ z' _ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! P. V1 Y* _+ F# }6 v7 A- x
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
+ r5 |+ ^7 ^; U+ I+ H' U% ` - * TO CHANGE.3 L+ ]) G$ v! |, Q
- *
8 O& x: B. }; p* F; g) M5 [ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! Z5 Q1 T( N |- r0 I) @1 H
- *
& q: j8 D* j8 P4 @) }8 M. t0 [; S - * This program is free software; you can redistribute it and/or
I: V; X2 B$ _" ? - * modify it under the terms of the GNU General Public License as# y( w: {( D1 J1 ^6 n
- * published by the Free Software Foundation version 2.
+ W. T8 a4 b& ~. i4 Z - *
/ k9 M! [. {+ A8 T( c: S - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% t# b3 x. j3 t; e - * kind, whether express or implied; without even the implied warranty1 H4 R/ @, ^4 P2 R/ R
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# d! v) q2 v3 Q: ^% m9 i M - * GNU General Public License for more details.1 K9 }8 K9 V$ A. S
- */
* g1 T! Q, X' \7 d. P( k; r" h - : O4 ?1 @% ?, k5 u- N
- #include <linux/module.h>
/ I! d' L. [+ c, N; |6 j/ M9 o - #include <linux/init.h>% k1 D& }: w* W" i! ?3 q
- #include <linux/errno.h>
4 N+ W6 Q5 N( n. d - #include <linux/types.h>
% F5 L) b1 V4 {! w3 H1 e - #include <linux/interrupt.h>' \ {+ b6 s/ _6 H8 J& q: |
- #include <asm/io.h>
* { j/ g8 s1 j4 [6 u - #include <linux/moduleparam.h>
. e" U0 y7 h/ I7 Y7 Y; A - #include <linux/sysctl.h>9 Z5 `2 A5 J3 ?; [" F6 S1 Q
- #include <linux/mm.h>
5 I1 N8 f0 B0 ]& C' { - #include <linux/dma-mapping.h>
. w$ G4 w" M2 t3 I$ Y - ; W: F: p% [ `0 D6 I
- #include <mach/memory.h>
; }5 u1 N1 x( Z6 M( } - #include <mach/hardware.h>
) w2 j6 b6 y9 L- Q1 M% h# _ - #include <mach/irqs.h>
B3 |- o. J. q4 b - #include <asm/hardware/edma.h>
' j/ J( K4 _0 `- r+ R - * N: t/ s' Y/ f# L9 }$ a
- #undef EDMA3_DEBUG
5 M5 q- q F% ?& p: o! _0 f - /*#define EDMA3_DEBUG*/
$ r3 T4 x/ g2 n+ i2 Q
2 n" n/ u$ L+ g) c9 x/ d/ ^3 ?7 O7 Z- #ifdef EDMA3_DEBUG
* f" ~" S" `0 z, Q1 r - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 ~% N5 m- W& I; v8 M - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
7 R% j" {4 I4 ^5 }2 a4 l: i - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' J* @. p; c& e- Q5 X
- #else
& T0 @# e( q' M. p4 N - #define DMA_PRINTK( x... )
2 s! x7 K8 s, E! Z5 W2 g; Z - #define DMA_FN_IN3 f b5 Y( V% w' {
- #define DMA_FN_OUT; G" ^. E% D4 q+ Z0 _$ B9 j
- #endif7 `. T# P( u5 d- Q7 L) H- A
% s1 M0 U) A) J' C6 b/ n- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 J' `7 h1 G/ ~/ f7 O
- #define STATIC_SHIFT 37 m- M1 P; `! x" w
- #define TCINTEN_SHIFT 20
! ]3 h" G5 t2 g% N+ h) u" a* B4 ~ - #define ITCINTEN_SHIFT 21: u' ~ w8 r: b8 c! p }/ N, G
- #define TCCHEN_SHIFT 22 K0 X( d7 \% c# {5 H
- #define ITCCHEN_SHIFT 238 D6 }- V% Q" A% N/ q4 J9 }' |0 o. b
- 4 ?/ z) m" _3 k4 j5 w
- static volatile int irqraised1 = 0;; H$ e9 x! f/ D/ z7 B/ L; H
- static volatile int irqraised2 = 0;
) G' s. Q9 @. v0 W: o% E
6 m+ L; w: T" S( j. r# q# F' @- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" h e5 n, s6 G( R9 y4 @; z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! q% ^4 E! N; b: B2 | - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ X" J: e) G8 y2 R
- l( E8 h" O" Q* V8 W$ j9 C, V e
- dma_addr_t dmaphyssrc1 = 0;1 u6 }& c2 V& E, |" z% i
- dma_addr_t dmaphyssrc2 = 0;! E! d) Q# G9 A3 [. O
- dma_addr_t dmaphysdest1 = 0;" c( M E* M0 y; I# c/ E
- dma_addr_t dmaphysdest2 = 0;% K$ X; z6 N: a o' J
1 q$ M0 w4 h, u( b" p, H- char *dmabufsrc1 = NULL;
. ?# _( j2 T8 L, d$ f - char *dmabufsrc2 = NULL;! n6 V6 W; t/ f# m
- char *dmabufdest1 = NULL;/ e3 p6 s: m, \: W' ^% z: b
- char *dmabufdest2 = NULL;
$ D H) E9 S, W8 X r3 ]5 U0 m
9 @# p) {0 a- L9 x( o0 v4 i- static int acnt = 512;
) r3 U3 F1 O: n: O - static int bcnt = 8;) E# J) v* r @+ D/ s
- static int ccnt = 8;
4 e7 P" D* k( P - 0 l" u0 H% u( x- p2 O! q
- module_param(acnt, int, S_IRUGO);
& a. j* U7 i' Z8 r+ B4 R - module_param(bcnt, int, S_IRUGO);
' g$ C2 `0 s+ Y - module_param(ccnt, int, S_IRUGO);
复制代码 & C$ F$ _/ p" E' L: m$ z
( Q0 s7 g6 f$ l& M: M' N# s 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用+ f6 e! ~4 c1 p
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。4 D( j+ A0 Z8 k" H
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% r+ Z1 t( L1 ?( L1 p+ ?
6 `) B: d7 V8 _! d. M1 _
( x( w6 J% i+ y! J3 k* d) c |
|