|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ) k) H N, t( X5 b6 V- [
- [code]EDMA sample test application
2 r# e5 t7 c" U, e# ^; a+ V" X( [/ z - /*9 v$ u) Y5 g/ i8 t0 H) R7 i( P$ Z
- * edma_test.c
2 |; l" ?1 m* Z/ f; {+ E1 _: [: T3 o - *
5 `( M! N6 _2 S: B: m: O' K# @ - * brief EDMA3 Test Application" V# h }( Y( s! y) p4 W
- *8 \" u+ u) y' N, h# I8 }$ z' S
- * This file contains EDMA3 Test code.
/ }% Q. R7 ~ L( o. ]- O/ A - *
& p, `$ j. l+ c* ~9 @ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE% N* j; W, u; f( I
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( e& Q# e( d% Z' l4 v - * TO CHANGE.
( D/ h( H0 `7 j' X6 D1 R" S - *
6 H9 N ]4 n' j, n5 [2 s2 \/ H( ? L - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
2 O/ G2 t P: U! J - *- ?5 P' G4 z! P" Y
- * This program is free software; you can redistribute it and/or/ T; y6 K. z: Q* y2 T3 \
- * modify it under the terms of the GNU General Public License as
! W3 _* P* j! z m. v - * published by the Free Software Foundation version 2.- W- q2 R+ j/ H/ `* e
- *1 z; d! W* g1 W) H
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 p& n' T' T0 r) K' k7 T
- * kind, whether express or implied; without even the implied warranty( i6 a+ X/ U \& F$ `
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the! Q) Y. |* L& n( i) g. l
- * GNU General Public License for more details.6 k. }( B* p$ {& x
- */
6 U( |; Z3 p5 k j; Z9 \ - 8 O9 G; `+ o8 l* y
- #include <linux/module.h>
" E; F7 b: h8 @, j. z - #include <linux/init.h>
' I* S+ p; c$ ?) s, Z8 z$ d - #include <linux/errno.h>1 o9 W% V8 w1 \5 N# J; `% g
- #include <linux/types.h>% N5 J4 b2 X. I, H+ r- Y- K
- #include <linux/interrupt.h>. D; C2 t F8 h# y* h
- #include <asm/io.h>
: i7 a- e& P3 s: k - #include <linux/moduleparam.h>
V7 k8 Z+ b! R& @ - #include <linux/sysctl.h># q) f& x$ i7 e4 d) {) L
- #include <linux/mm.h>
+ J+ u/ r. F1 f% @ - #include <linux/dma-mapping.h>
3 w9 Z9 p* y& O2 n; a: S - / Y9 ?( {) o$ K ]0 R# Q% X3 c. i, \8 g
- #include <mach/memory.h>% g; F# {% P5 H- d
- #include <mach/hardware.h>! Q; A) b0 ?/ }- m, U; _+ d M
- #include <mach/irqs.h>
9 V# M. v4 t+ p5 b. a( D, A9 } - #include <asm/hardware/edma.h>/ B6 c# F8 D$ v
: \; @& k9 n1 m* D- O- #undef EDMA3_DEBUG& K9 }4 d* t9 ? n- {
- /*#define EDMA3_DEBUG*/
$ _$ v9 N1 b: {% g9 j - * m4 x( x2 h ?9 {: f
- #ifdef EDMA3_DEBUG
" C$ t, p" O0 k/ t7 h2 \ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)7 f6 u9 d) l f: O$ S* R, x
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* s1 W7 ]6 ~9 q - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
( x) X3 }/ U; G: A - #else9 i G# h: F5 O1 M
- #define DMA_PRINTK( x... )& j* q7 \2 d) W$ |0 n3 D
- #define DMA_FN_IN
! z! i! F. O: Q; k1 M7 L7 ]7 ? - #define DMA_FN_OUT
5 N- u, V$ F! g' { - #endif: _* o$ u, l' f% p: L( s, \
- 1 }( x" ~3 e: [9 g+ _
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: n8 E9 d0 ?: Q' |3 J) m - #define STATIC_SHIFT 34 Y) ^! n3 m6 e
- #define TCINTEN_SHIFT 20
- ?! h. a' d! \: P - #define ITCINTEN_SHIFT 21
, C- P1 k' X0 o; }0 _ - #define TCCHEN_SHIFT 22
4 E! |; O. \) u" a1 a - #define ITCCHEN_SHIFT 239 v5 t( y* M3 _, p6 G( i& p0 L
) Z8 `- P4 [& M- static volatile int irqraised1 = 0;8 a# }' H6 {5 T' e4 @
- static volatile int irqraised2 = 0;
2 y- E+ z* c7 \( n) O - 2 k2 W# q( G9 K- U3 `
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);" j6 i9 t9 i' \/ y# h
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 A B2 s; v4 |( g$ Y$ S" |; \
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 [* x3 P8 t8 G5 B. H& V9 w7 R
3 S( O2 C1 n( H% \- dma_addr_t dmaphyssrc1 = 0;/ _0 a" V9 J) P; X- F7 O+ `0 o f+ q
- dma_addr_t dmaphyssrc2 = 0;1 ]2 o% @% L4 x0 o* S- q5 \+ |
- dma_addr_t dmaphysdest1 = 0;
z! g6 ?7 U; g" b7 n* n - dma_addr_t dmaphysdest2 = 0;3 {3 p( [+ ?% J( a2 G
- ! U! t' ?* e6 n3 p/ p" b
- char *dmabufsrc1 = NULL;9 W6 X4 i7 K: p0 r9 _3 t5 J
- char *dmabufsrc2 = NULL;
/ ~, N4 {: m/ h( ^ - char *dmabufdest1 = NULL;
; H6 h1 V1 X) n - char *dmabufdest2 = NULL;* T& R. d! z1 Y$ r" }& h6 F, N8 [
+ D) \1 X' }" c( S0 \- static int acnt = 512;& G+ t+ I* P' n3 m+ Z# \3 R& W
- static int bcnt = 8;
( @7 q3 f* s/ N3 g - static int ccnt = 8;
% \* B8 d% b: j8 \ - 0 d( s+ `7 ?4 i% j* v
- module_param(acnt, int, S_IRUGO);; v! \0 t1 r6 V# L
- module_param(bcnt, int, S_IRUGO);2 f, O8 g3 T1 X$ [! g
- module_param(ccnt, int, S_IRUGO);
复制代码 3 k2 R, p3 a% ^) M+ U
. L& E7 U! U1 R. g6 F, x0 ~1 U! b0 Q' w 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用& K) G, \* W& p- ~( m. c
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" p9 S. Z; u2 A* q& I
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。0 u+ O+ [; a3 M+ D, O4 s, s
' c( l' B, _ K8 I6 ]# J) S
# \' q% g, }( U( g) F |
|