|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 ]% c$ X) \4 Q" r- [code]EDMA sample test application
# W* X" |5 ~. c0 s - /*+ g; _5 f- T- E+ G' I; W# d" ^, _
- * edma_test.c
6 l# Q$ k! B, Z) i0 W+ z9 I - *
! ^, C' a$ a) N5 j" S - * brief EDMA3 Test Application) S8 F; `7 `2 x( x: b/ Q9 D
- *( F! ?$ n! _, A. g
- * This file contains EDMA3 Test code.# e" q, D3 R6 K/ M6 r1 J
- *
% T" [, ^" E0 o" A ~3 b - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! K" T+ _1 m1 J& Q, A1 {5 b% \
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
0 H9 K, {0 z/ c - * TO CHANGE.
2 x5 C+ Q. e- o - *& U7 ~/ ]3 l1 f( x0 p4 J5 k- m
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/8 L+ f% t# X8 r7 W! O* Q( U/ i
- *
) _" ?0 o6 ? S8 n. I8 V - * This program is free software; you can redistribute it and/or5 z2 z# G. H8 ^# q. z
- * modify it under the terms of the GNU General Public License as
) j# @; L. a' d; d- Q - * published by the Free Software Foundation version 2.7 W! S6 S3 S3 _4 ^+ Q9 G& o0 I
- *8 @# m+ d, b; ~4 w3 f; P2 U4 w* O) ~- N- q Q
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any" p4 p3 T$ {/ x, i
- * kind, whether express or implied; without even the implied warranty
* ~" ?) R6 @' Y! N# F1 s7 X+ l" ] - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 Q5 p R$ \4 Z! l( t - * GNU General Public License for more details.& p' P; _5 O- K0 ^3 g& Y& B. r
- */8 p" {$ G, \/ p2 U# I, c
; F) @, Y: _9 f# Y- F9 H- #include <linux/module.h>
+ m. l: x5 o8 W/ d/ X - #include <linux/init.h>
6 @* t7 n7 F. o$ f - #include <linux/errno.h>2 }" \+ H* W) m7 a
- #include <linux/types.h>1 T/ d/ c3 m/ v$ a" B& t
- #include <linux/interrupt.h>
$ u5 j* }9 R' p5 P - #include <asm/io.h>
1 v* f- u) r+ G- y - #include <linux/moduleparam.h>2 {4 R7 T a+ d" {) e
- #include <linux/sysctl.h>& u3 m. j/ E/ h+ k9 P
- #include <linux/mm.h>- A8 R, j% \# u+ w+ R4 l
- #include <linux/dma-mapping.h>
. B- s4 j; M s% _: j3 x1 L, z6 r
1 p+ q, a* V4 Q8 E! e- #include <mach/memory.h>
, d$ ?* a( M3 p1 ~: I% a7 k1 ~* s - #include <mach/hardware.h>
0 e; N) b2 a2 z0 R& \2 x" i- q - #include <mach/irqs.h>7 o1 X3 p" r P3 M
- #include <asm/hardware/edma.h>
+ k! ? e( f; _
U( U/ B6 k( P0 p- #undef EDMA3_DEBUG
( x& `+ Z; F% C - /*#define EDMA3_DEBUG*/
( t" A- a1 A% O7 W( X6 F# Q- ~: p! M - * J- O- G0 B3 V P7 w8 K
- #ifdef EDMA3_DEBUG+ p% E* p+ Y2 H7 S+ O! F1 ~
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" D: p0 [( F1 D8 W, \% _& Y - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
; K# n/ E1 W/ l3 g0 \! T0 [9 q: p - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* i: {+ E, ~$ v5 p4 A* I- Y9 I
- #else
0 w/ e c3 x6 C0 P! I% O - #define DMA_PRINTK( x... )
% m4 b( y3 r+ ~$ Q1 B - #define DMA_FN_IN
: w) x2 E) _6 [) I - #define DMA_FN_OUT* h& U! P: D$ g) J
- #endif5 `1 T9 }& d0 l) v5 p7 y0 k4 l- l
- / v& A; y% H3 b6 O* f
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 `) K+ f9 S5 h8 e! @
- #define STATIC_SHIFT 3+ C, g6 b, L: b. H( K5 f
- #define TCINTEN_SHIFT 20$ Z4 F) a; [! C+ o. f( u, x! r
- #define ITCINTEN_SHIFT 21
+ F5 m0 R) M% T1 C/ E - #define TCCHEN_SHIFT 22
- R2 | r/ i3 R - #define ITCCHEN_SHIFT 23+ d: y( G! K. e; R% Y2 P
8 n" {3 E0 |% W( P. Q$ B4 F" Z- static volatile int irqraised1 = 0;2 g5 i( |4 ^ p) E6 i2 ]' O) g
- static volatile int irqraised2 = 0;
# I# c# P; d9 [" L4 Z: I6 t. g8 D
" f8 K) o; \- M( J2 @- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% o- y* T" G5 ?# K9 |$ `: T - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 v& |1 i' v! z# y8 e1 g* X - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# U% s! E7 }7 V0 u
5 T! j# }6 q& U( A/ }! W' {- dma_addr_t dmaphyssrc1 = 0;
+ N5 {+ q3 L8 d1 f - dma_addr_t dmaphyssrc2 = 0;* V( w1 @; P' a2 B( V! H0 O
- dma_addr_t dmaphysdest1 = 0;
& }5 s/ B* w1 s0 a7 A - dma_addr_t dmaphysdest2 = 0;
0 t, H" ]( |; Y& U, p" X
+ L8 D0 B( ?0 f! I* y. [, N- char *dmabufsrc1 = NULL;+ x* U- z9 B' l ~1 a
- char *dmabufsrc2 = NULL; B. K' F3 g, Z) x4 Z
- char *dmabufdest1 = NULL;
) ]7 S' f# z& j- \, \ - char *dmabufdest2 = NULL;
. H; I' j' C8 U3 W! H( ^+ b" R" G - 9 I: t3 J( v, x5 \5 f( s: L0 n8 y, t
- static int acnt = 512;
, V! D2 n# Z! O, B - static int bcnt = 8;
5 D% e% G" X2 H4 M( D9 G5 U- \: u - static int ccnt = 8;
0 \+ q* M& w% b$ F - * M4 z; j* x7 S* M4 C
- module_param(acnt, int, S_IRUGO);
: o/ Y7 c2 I% p, | - module_param(bcnt, int, S_IRUGO);# }# B) F# |% o7 @
- module_param(ccnt, int, S_IRUGO);
复制代码
! U5 {; ^- Y# H4 e& \8 j& U8 S5 T( I5 u2 i
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
5 l$ k# |9 R. i; Larm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
" s1 O! `. g7 F" d7 [( x 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: j6 q. t* r% R# }- v' y0 o/ r
) \+ w$ r8 P, D
% _; G0 J$ G5 m- L! A, m" _3 f5 Q |
|