|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 3 `! K" a+ a$ U! `2 \4 I1 ~
- [code]EDMA sample test application
- P% Q3 T( a" F1 m' P( t& D1 s - /*8 R; V5 a. [ t) Q- T6 h
- * edma_test.c
, b9 p0 q4 Y2 J0 t) ]8 Z& { - *
. |( N6 q6 I8 b1 T0 I' h% A# j0 ?$ n - * brief EDMA3 Test Application! e" i1 Z" A$ E
- *; `: K: P+ Q: z
- * This file contains EDMA3 Test code.( p( i+ V) V3 z8 Y1 Y0 [/ ^
- *
3 z' c2 }$ S t! ~; Q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE2 N2 V% d, F8 u* e. V2 ]# H0 o' T/ Y
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ b2 B. j5 q" s+ h" b8 @ - * TO CHANGE.
; ]# D$ b" a8 U0 B/ n+ f4 Q& X - *) ]+ n- y) H) q
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" [" q# I6 m/ R
- *
" ~& _5 H) o6 u8 j4 G' s H& k* e( p - * This program is free software; you can redistribute it and/or
$ k" O3 C* x4 V- }( Y - * modify it under the terms of the GNU General Public License as
/ L" H" X2 ~% ]( z- a3 H" v - * published by the Free Software Foundation version 2.; l; w) }6 v: I
- *8 n& L4 c+ S& l8 r( U$ j% b3 w" s
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 [/ J% N n, V
- * kind, whether express or implied; without even the implied warranty
5 P$ ~2 }5 W9 {+ } - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) U* r, e' \+ y5 f
- * GNU General Public License for more details.* \. R) R' d p% I: @ s; Q9 H
- */
3 S- _2 A$ h5 t1 L/ o) h
) \1 x: N6 b% _- #include <linux/module.h>
4 l8 w, |" \9 E o( B2 T% k" D - #include <linux/init.h>! P3 H0 }1 e9 J+ w1 e
- #include <linux/errno.h>
: t" C; o) y, j* K# k5 n+ T - #include <linux/types.h>/ a5 {# F; P1 U3 u3 C3 U
- #include <linux/interrupt.h>5 U# l+ H8 b, } U) s h
- #include <asm/io.h>. W( f! y2 b; S6 `2 i& @6 Z& b" S
- #include <linux/moduleparam.h>
$ X) W5 q# s" d; T! F0 q - #include <linux/sysctl.h>; d. N7 F6 L: D0 Q5 e, k5 `* v% _9 _
- #include <linux/mm.h>
# T8 }0 G; s h0 L) _ - #include <linux/dma-mapping.h>
i, F2 \9 L m4 J4 w' d
' J! X t3 M- p! W, v7 g8 \+ M- #include <mach/memory.h>
- X: K7 j; M( i# R5 _2 [ - #include <mach/hardware.h>
- N* F+ O) A+ D* r- h7 d - #include <mach/irqs.h>
+ @. k9 M0 ~: V2 | - #include <asm/hardware/edma.h>
1 @' L. r& L9 ?4 [, K0 x3 ?# W - $ p7 R, q: l% E; ? k
- #undef EDMA3_DEBUG* ^5 m8 X/ S. n% J
- /*#define EDMA3_DEBUG*/
- a* h. j) r' i$ M9 N, L
S8 G4 S2 `0 h# c+ f4 L, a- #ifdef EDMA3_DEBUG
& p0 N* f% c% P: j9 I: Q% b1 N - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): S, s" ?. i& s P/ T, u/ `+ Y% }
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)& F' ?4 @+ D+ p; Q5 n
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
' I( }/ t# |. B0 j3 m" D8 L - #else3 ]4 n9 a1 l; ?' f3 x7 }2 h& U4 J$ O: q
- #define DMA_PRINTK( x... )
$ p( S0 R( w, b( ^8 N4 T - #define DMA_FN_IN. D4 E; Q# X4 A2 g I/ o
- #define DMA_FN_OUT
" _9 E* T+ Q: E1 b& Y- H6 c5 W - #endif3 z* `& d f8 R2 \ ? f+ h; W9 d
$ z! `# F( V0 T; [% P- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, c% @- f+ }/ E1 J( c - #define STATIC_SHIFT 3
8 S2 c! I* K1 p9 ?) F' j1 z% O - #define TCINTEN_SHIFT 204 g3 ], s9 w+ b6 @! z5 L2 a" A- O) P
- #define ITCINTEN_SHIFT 21" [+ i# y+ v# `( d
- #define TCCHEN_SHIFT 22
( H$ ~/ L8 `/ Z2 `% Q3 z3 y ?' w) X - #define ITCCHEN_SHIFT 231 U9 p# P" b2 C( W, W
- . \% k w0 H& x# t9 U$ I. I. ~
- static volatile int irqraised1 = 0;
2 d7 \' y- Y3 F" j4 t9 { - static volatile int irqraised2 = 0;' _3 v( W8 ?* T! T% R |
& w4 r* U. |" ~6 y+ g* |# y- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. j: L# C" z- d1 f - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. t/ D4 {) p; }$ K2 \5 t% X
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 T o3 q& S, P) j, p, ?
/ n/ z. w: }, s, {1 |1 r9 U- dma_addr_t dmaphyssrc1 = 0;
6 T& b O$ m& b - dma_addr_t dmaphyssrc2 = 0;
; Y7 Y: m; _9 E" q0 T0 P - dma_addr_t dmaphysdest1 = 0;1 D; _( G0 v! I# v$ |
- dma_addr_t dmaphysdest2 = 0;) e+ ?, s3 H! k" [' _% j
- " X% e4 |. E9 W* P, _
- char *dmabufsrc1 = NULL;
# x5 W# s' `7 t4 p3 w/ F$ u, p+ L - char *dmabufsrc2 = NULL;* N0 ^, t% }5 Y7 L5 M: k+ U& }0 z
- char *dmabufdest1 = NULL;
* C/ ], q0 q& [ - char *dmabufdest2 = NULL;0 X; ` i: ^- ?2 x+ l) P8 _
- * ~8 I. ]1 K% H2 _* D
- static int acnt = 512;; z. l5 K( B3 S, B/ Y' C
- static int bcnt = 8;- d: |" `& {0 i7 Y. c! d
- static int ccnt = 8;
: I; n3 \2 @$ c5 o/ ~, k! n - . E, N' M5 _% l6 i: `) O# d# f$ }
- module_param(acnt, int, S_IRUGO);6 ^& B" L6 L6 _5 g
- module_param(bcnt, int, S_IRUGO);
3 |5 N# }3 D% R) S1 L - module_param(ccnt, int, S_IRUGO);
复制代码 $ J+ A2 ~" }5 p9 _& v4 E; ]) L
3 n1 \# B o6 W. P 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 u! w1 T# d; k8 Q5 z3 Q
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。3 R1 @) I4 E. p9 P: V m5 E
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
" a% x2 K* q- ^; M, L! r8 o. j$ t; l7 }' [; @) q
* x, W( w' E) w( a: R
|
|