|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( T: a5 j0 V9 o. K. [2 ?" ]- [code]EDMA sample test application
2 W$ G4 y) V5 B - /*
' ^& t1 K* A5 Q/ h( ~: N2 r2 Z - * edma_test.c
2 K* [( v' v2 z {' c$ C - *
4 s+ i9 X# [2 e$ {1 p& y' ]8 G: C - * brief EDMA3 Test Application
" _+ H6 L( ], J' P) k - *0 `$ \5 J( V# [* Q- d
- * This file contains EDMA3 Test code.' s! p3 ? K2 M: E% f0 a) f5 o3 t/ t
- *9 H4 F, r- B) ~9 i. K- O- _
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE5 V7 x' k, I1 {& Y0 w
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 E# y2 K7 O+ J& e5 }/ ?
- * TO CHANGE.
6 }' x1 B" W2 v& x0 }/ X2 @7 H7 L+ Y. H - *
" L( U" i( W- F5 u0 p! f# o - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/6 N/ A5 ?7 r3 q. Z; [+ w
- * @3 {( d- t) [' {( A0 `4 T
- * This program is free software; you can redistribute it and/or
$ k! L! F+ y7 v! W& q8 |4 Z) q - * modify it under the terms of the GNU General Public License as8 U, l+ {. Y, l5 x
- * published by the Free Software Foundation version 2.6 p( J0 _1 p% s2 I, u6 c
- *1 U( Y4 q, G& h( k7 ^& s3 u
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
( D5 \9 C% m" Q, I! ]/ d% Y6 Z - * kind, whether express or implied; without even the implied warranty3 }3 W3 _. T" C2 S' W+ c6 U
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
L; B) W. w: ]0 W+ l, x5 Q$ L - * GNU General Public License for more details. P. }& }" J# f, ]7 `4 R
- */( C3 H- ~( F+ U- P
5 @& O" W- j; r# @6 L7 ^- #include <linux/module.h>( | `, s1 U( j8 _9 E. K4 a" k
- #include <linux/init.h>$ L$ w; [. q0 j$ _+ ^! _/ q$ G
- #include <linux/errno.h> L+ x0 \& n( j/ o6 E! X, Y
- #include <linux/types.h>
5 D% f8 }$ Y" u9 g+ `6 X+ ]% w - #include <linux/interrupt.h>. ~& {4 h% B6 J: c/ h; [; H' k
- #include <asm/io.h> R% l( W1 T: X
- #include <linux/moduleparam.h>- W( V' N' N& Q: r1 ?
- #include <linux/sysctl.h>7 W4 [' `( Z- d9 M/ L) l/ t
- #include <linux/mm.h>
) _7 q- L: v( p( p - #include <linux/dma-mapping.h>
* t# |% Y! L% k, h( Z
, w4 S$ v u2 M- #include <mach/memory.h>
5 C3 g9 z- a7 i1 m Y2 L( D$ E - #include <mach/hardware.h>' h9 t7 N! J. m" P3 \0 R
- #include <mach/irqs.h>
& f- O8 s5 i0 ]4 S8 z7 s, b$ X: t$ t - #include <asm/hardware/edma.h>
+ ]& @: F& h8 f& R& s/ R# ` - 0 \' z8 j! f! ^4 M8 S v {0 P
- #undef EDMA3_DEBUG
# C. \% V! }4 e3 J" L2 g - /*#define EDMA3_DEBUG*/9 s" N. M9 e' V- P$ J, E( K# |
- + C" A; I) |8 v7 V! y! q, }4 }# [6 R
- #ifdef EDMA3_DEBUG
. @/ o0 _" f4 W( u - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( R/ [9 I( a0 W/ ` - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; h1 ?6 u) v! _7 S$ h9 {4 x3 i - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 K9 [( q$ e1 `6 \5 h6 A4 ^( s
- #else
1 _! z6 M+ L* n4 @$ Y - #define DMA_PRINTK( x... ): T- Q$ T' Y. B. n
- #define DMA_FN_IN+ m* R% T# P+ ^( g& W
- #define DMA_FN_OUT
& X; j& U8 I# j5 q: b" n - #endif5 ~/ V) r2 G. D6 ]" t9 @0 p
- 0 T2 y" }% K+ ?) ~6 l, G; h
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)5 v6 }/ E t ^& n$ z6 L3 X& p( x4 d
- #define STATIC_SHIFT 3
1 W1 {; }% ~* k- V6 a5 d - #define TCINTEN_SHIFT 20
1 X/ W2 `. X8 o8 o* A7 U$ g, H4 E - #define ITCINTEN_SHIFT 21, v" P& X2 f8 p6 K* k1 J% q7 a! d
- #define TCCHEN_SHIFT 224 G& Z9 h7 J+ e2 \7 K+ V
- #define ITCCHEN_SHIFT 23
* m' }- z, s/ p3 u" T& G9 T2 e
" E! D5 K# h# x, f0 p, H5 ~% @- J% ?- static volatile int irqraised1 = 0;) f0 [) Z! S/ e; F* B$ {+ z% [
- static volatile int irqraised2 = 0;, R0 j. j0 }: f* F" K4 K
- , I/ B* ]& k1 p( S
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ Z/ i+ M0 b! e% r
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 @& y: p+ k2 o4 ]
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);: ~. C/ I; a7 C. a! f- Q1 [
6 ? {% t. ?+ Z- dma_addr_t dmaphyssrc1 = 0;3 r+ E& f( N+ ~. i
- dma_addr_t dmaphyssrc2 = 0;" j1 A5 P2 R3 {
- dma_addr_t dmaphysdest1 = 0;
3 @5 u: N- [0 X% m6 P - dma_addr_t dmaphysdest2 = 0;- v4 k7 g$ E O2 O7 r! d- a
+ P3 p+ M1 U l8 Q& ?0 x- char *dmabufsrc1 = NULL;
6 T7 l( I8 ^- [+ C% d - char *dmabufsrc2 = NULL;
% k& R2 Y0 p4 p+ W - char *dmabufdest1 = NULL;/ a2 v+ k7 Y1 {/ V8 I
- char *dmabufdest2 = NULL;+ `4 `* l. @8 _- \; F, P
! X# Y& f' L1 j: o- static int acnt = 512;1 l! T1 E* R' U( }' Z
- static int bcnt = 8;2 Q9 m) y4 o. B2 z8 \7 S$ ^
- static int ccnt = 8;+ z5 x- c4 {6 @! l. O1 G; I
- ; V1 o! ?; b! T
- module_param(acnt, int, S_IRUGO);5 C! ?% j7 _( D- Z3 S
- module_param(bcnt, int, S_IRUGO);/ Y7 L5 Y. H0 r
- module_param(ccnt, int, S_IRUGO);
复制代码 * V1 _* \' x& M
* z- `( v0 ~9 B; ^* h' ^( [$ ~6 O 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' B' T/ {5 N6 y$ K' I* farm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ M! n% s3 ~* B 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
" [! U" G7 e: @7 _( f4 _6 X0 L4 J; H O1 Y
3 J! n# f, O; j
|
|