|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 # Q: |( e2 l1 A' L& y
- [code]EDMA sample test application
& t) q' \, `. J/ F7 d& Q - /*
6 M9 b0 K, L! g$ R* C; V - * edma_test.c
( u! K" s3 X) ~1 Z - *
* Z) h# c* R5 U* W9 L: G* R7 P$ W. Y - * brief EDMA3 Test Application9 H# J$ p, C7 N/ ?8 {
- *
3 s# d) m2 Y1 y- p1 k% i4 a - * This file contains EDMA3 Test code.* S2 O1 T7 ]& \8 g4 j, V
- *
2 w6 Y0 }2 m* k9 e: ? - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 A' M2 h% O# ?, q - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
! P5 P! e' a/ n( M+ d k - * TO CHANGE.
* r n' S1 L1 w - *. ?* Y: X- Y& [% _6 }& Q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
% q1 g( `5 o$ G8 T - *; S+ W {( d o8 K# @! n% k/ t
- * This program is free software; you can redistribute it and/or
2 i' O% t3 a& k7 M - * modify it under the terms of the GNU General Public License as
" r; q6 h2 ~& c S* H# ?" j, h - * published by the Free Software Foundation version 2.* [- ~+ [+ e, ~, {, m
- *
; l$ o0 j" j5 {1 K! S' l - * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 z- n! ?3 F' }% j# Z1 x
- * kind, whether express or implied; without even the implied warranty- n# p0 ^* R, v2 b! Q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 O. d7 N! t1 J' [ - * GNU General Public License for more details.
$ H- R& w0 Z0 k3 M! l# r" H - */6 o6 M" l9 X' g; v) F' E
- ; u; e: O; p. b7 t" ] ?; v
- #include <linux/module.h>
9 K" b4 X% o5 y# _ - #include <linux/init.h>/ q- T1 ^* \: C0 ~4 t6 @( |) r
- #include <linux/errno.h>
. x9 U4 G( c p( {) T# g# r - #include <linux/types.h>
1 i+ x8 q- d; r; _; M& O - #include <linux/interrupt.h>
5 k4 V/ i+ g6 U - #include <asm/io.h>/ n1 Y. p3 J# f
- #include <linux/moduleparam.h>0 c- ?5 C# a: o9 ^
- #include <linux/sysctl.h>
, t! z* i+ b' T9 t - #include <linux/mm.h>" ?! i" [, b' t: d/ S9 h" c G Z8 O# j
- #include <linux/dma-mapping.h>
6 C4 M) Y7 `( k! I; a7 r
8 {5 O% O. G/ {2 r, ?- #include <mach/memory.h>: d: d" j7 J9 J
- #include <mach/hardware.h>; H3 \" |0 l+ f; G _; w
- #include <mach/irqs.h>) z+ I& R' K4 {, W, G
- #include <asm/hardware/edma.h>0 u3 V. ^( T" I2 n( A
- " _, w3 ?0 p9 o2 }
- #undef EDMA3_DEBUG' f+ ^ T6 W/ Q! @
- /*#define EDMA3_DEBUG*/
' X8 J" N$ H0 q7 R1 T1 N
/ f8 V2 x( }. \& ~: [ J/ W- #ifdef EDMA3_DEBUG
4 j. f% U' u! z% u/ A* T/ ? - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: l* G4 t2 O ]5 h$ j - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)+ }9 _( f) ~$ _, i
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
- i4 H8 i- }$ m - #else+ L1 @5 i |: [( f
- #define DMA_PRINTK( x... ): H. T- Z. d4 ~) s& w! O& X
- #define DMA_FN_IN
Z1 F/ s* {: Q1 W% E( d- } - #define DMA_FN_OUT
7 r+ K# j! f' L9 {! |6 C - #endif5 [" W( o8 F( s" F! g; M" m; E
! u% Q+ q2 f* u; a" {- #define MAX_DMA_TRANSFER_IN_BYTES (32768)1 i! i! }% _0 o2 ?/ s8 T! U, i
- #define STATIC_SHIFT 3
+ u& T, n) k7 H) U3 M* t - #define TCINTEN_SHIFT 200 s+ T" t6 z$ _2 x( b6 }" m
- #define ITCINTEN_SHIFT 21- Y3 d$ e* n% o( X" B6 _, l
- #define TCCHEN_SHIFT 22
2 A# F: m+ G, P7 E+ `' C3 ^7 Q - #define ITCCHEN_SHIFT 23
# s/ n# `8 c7 ^. R( ~; D
6 k o9 }( }3 ~- static volatile int irqraised1 = 0;0 R/ t7 h3 | V9 u6 h, l+ m9 X
- static volatile int irqraised2 = 0;
- q1 m" y& P* P y* V. U - # [1 J l; A) ]& M
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; _! X! J; C* t - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: q0 `9 b" }+ i, N- B- o5 C
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 w7 d/ b1 [: S. t: w - 2 R) R: X- y9 E- R6 E6 q% z2 {
- dma_addr_t dmaphyssrc1 = 0;. [5 ~9 g+ Z9 P8 H) x
- dma_addr_t dmaphyssrc2 = 0;
$ K$ w- }. y- l$ K4 s% M3 c - dma_addr_t dmaphysdest1 = 0;% s- s* h8 N8 y0 J1 ]/ o& C
- dma_addr_t dmaphysdest2 = 0;
& s' O, X( Z& }3 @) `+ [% [! a! ]
6 s* I% j; R/ |: n$ K$ R- char *dmabufsrc1 = NULL;6 [( ^9 H( T7 H7 L/ g* k( H% S
- char *dmabufsrc2 = NULL;* _6 c) C8 ]. V. o
- char *dmabufdest1 = NULL;
# O7 [5 L- S3 \ - char *dmabufdest2 = NULL;
( S0 ^& p* Y2 j
9 o c/ N9 R9 W7 l- static int acnt = 512;& R! J4 W: s+ Y( u; B
- static int bcnt = 8;; I, K3 L( j6 P U
- static int ccnt = 8;
5 Y" @( ~2 B3 t# N: v - & Q5 n3 [1 c3 I- q6 m* V
- module_param(acnt, int, S_IRUGO);
3 ~# X' \7 `# P5 J7 y3 k! p/ r- m - module_param(bcnt, int, S_IRUGO);; u; ~+ Y3 T9 z4 J }
- module_param(ccnt, int, S_IRUGO);
复制代码 7 O3 t r, Y- L: a% a
& |9 D) t# J/ m |' v2 l 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
, h' U: v( G, C: b Narm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ v! V g5 H/ H6 e( I4 `
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
3 j2 ?; `) ]$ G% W6 N h5 J
9 B& k/ Q; [6 m1 k, r
- T9 x! n- ]) J6 O4 b. [ |
|