|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ; R5 v( Z* V0 j) z! u; a
- [code]EDMA sample test application: T+ U( E3 w8 H9 Q3 y2 B
- /*4 Z& M: V4 ~/ H& H) F: C \7 n
- * edma_test.c
" E0 {8 }8 Q; a - *
- t) I l: B7 S$ D( n$ S - * brief EDMA3 Test Application% u. I$ d( y* l0 r' k J7 V- s
- *
( M% M, z4 ?; n/ C - * This file contains EDMA3 Test code.
2 f/ p" I9 K- g0 j - *: D" h+ E6 N& o/ b" E: A
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" r8 R3 @6 U f - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
# U. b3 _' d- F3 A! T - * TO CHANGE.
7 h% w9 d, N _: T! Z, Z - *7 u/ G+ S8 ], y) C! x O
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/6 o3 o6 K+ U( y1 e' g, M4 K% F
- *& F4 p0 T4 d5 @0 G* F
- * This program is free software; you can redistribute it and/or4 B9 i$ E% c% h: d! o0 Z, F
- * modify it under the terms of the GNU General Public License as
) ]! D$ b5 ~7 V - * published by the Free Software Foundation version 2.6 R- I* q1 A# ~7 {' l
- *9 g) s) G0 n+ [" O- A8 N& t1 N
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 y0 \5 ~3 h( @ I2 {
- * kind, whether express or implied; without even the implied warranty3 v4 x! m7 j5 b5 ]2 }. @' K
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 U5 v. J4 }$ p+ u, ^
- * GNU General Public License for more details.
3 y6 [. {7 R" T- p" y1 F2 D - */
. U! U, N2 V# V; ~8 ~2 _ {6 n
$ L9 P& h1 [4 m% i/ t5 p! d; d- #include <linux/module.h>
; G# \$ c3 T' J9 a2 M0 R - #include <linux/init.h>9 E: N# o4 B1 T" R( y
- #include <linux/errno.h>
& r2 }3 Q4 d! m3 g! B2 n* R - #include <linux/types.h>; F! Q- o% `, \8 U8 g5 \" e
- #include <linux/interrupt.h>
, I' F. J# p4 S4 Q: q: B. T3 t - #include <asm/io.h>
, Q1 N5 w/ u% [5 n2 n - #include <linux/moduleparam.h>* V& E: d6 v6 f
- #include <linux/sysctl.h>: d$ m }8 w! U l" e/ c
- #include <linux/mm.h>- B& V9 ?" `3 W- z3 ~) C4 K6 W' l4 n
- #include <linux/dma-mapping.h>
, `+ H: b3 f1 X( D - - O, o) f! h" \- Q, M
- #include <mach/memory.h>! ?9 v. l* g# b @. {' @: H
- #include <mach/hardware.h>
/ x& q" L2 t. ] - #include <mach/irqs.h>) [. Y6 X# V/ o1 s# `
- #include <asm/hardware/edma.h>, ~! j+ C; @9 a; H) O; f. y
' ?2 J0 t6 y1 c% V9 N7 N! x) m- #undef EDMA3_DEBUG
' d+ N1 l* u+ v2 w3 C - /*#define EDMA3_DEBUG*/
+ _: J2 q3 o; c
6 [1 I, _8 }1 |0 |. ~& j1 ?- #ifdef EDMA3_DEBUG
# Q9 g% V. P/ M! K J - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- R( p4 \: [$ _* U: T; d - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): t% S) }* L! m% w6 H1 u0 E
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 n: c9 n3 D: P0 r
- #else
1 c8 \3 o( H) P - #define DMA_PRINTK( x... )- ~7 X# M9 I) d# N7 D
- #define DMA_FN_IN
1 |0 U5 j9 b, _+ n: ~ z8 ] - #define DMA_FN_OUT
- r5 K* N: q) ^' t$ c9 r! y - #endif
1 Y0 S1 m" X0 s, V7 |& G3 E. |* W - ) Z) Y: x4 i& p- w( C3 M7 Q# |4 N* l
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) X3 ?, }: E& O& q& r4 q - #define STATIC_SHIFT 3
' r7 x H3 g1 c6 S T - #define TCINTEN_SHIFT 20
9 m: K' k3 X! Y/ ]: Q1 L1 h6 v - #define ITCINTEN_SHIFT 21
) f* Q+ _: t. s A* Q" b - #define TCCHEN_SHIFT 22" C7 `, P' \: F- u- W I
- #define ITCCHEN_SHIFT 23) [, D2 k' C# b
- : y1 Q5 P$ ?" ~+ m3 c
- static volatile int irqraised1 = 0;& g1 ~9 `1 h/ Z6 ]
- static volatile int irqraised2 = 0;" }' R2 C7 D- D" `1 n [
- : l( X$ E( N; u% o( T
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 ~' ~ ~# H$ E7 w- J6 \0 O
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- F* R: e6 ^/ H0 y2 e - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 D& s6 m) r5 @
* Y Q# x* A6 u; P. l# G3 X- dma_addr_t dmaphyssrc1 = 0;" p5 R9 C& Y0 ?) {
- dma_addr_t dmaphyssrc2 = 0;3 o) ~8 c; `$ S/ A% b; S: H" F+ z
- dma_addr_t dmaphysdest1 = 0;
/ f% m1 P+ {. f. B! Y. F0 W: x - dma_addr_t dmaphysdest2 = 0;
* {, c4 h; F4 Y T% ~ ~1 S$ B0 l - . D$ P" S8 T8 @& ?
- char *dmabufsrc1 = NULL;
4 }) U& o7 V: o1 p9 q - char *dmabufsrc2 = NULL;9 t7 U% s# F5 ?) l
- char *dmabufdest1 = NULL;- }$ f* B! n& p4 X$ C& d5 K
- char *dmabufdest2 = NULL;2 R7 [# y( z. W+ ?7 V
1 g" X0 N3 S* T/ w v; R- static int acnt = 512;6 {* k% O# q- b( x( m
- static int bcnt = 8;
- X* a5 m5 J- w5 h$ X/ {# S+ W - static int ccnt = 8;
/ |0 X3 g- n/ N
: R* w9 F# }; b0 z/ C- module_param(acnt, int, S_IRUGO);
3 V) G& m! u& d8 \8 \ - module_param(bcnt, int, S_IRUGO);
, ^3 H# ^4 Q% U* o3 g - module_param(ccnt, int, S_IRUGO);
复制代码 9 p9 q9 Q# y. ?" G& u
# Q3 G; n) a' Q s" k/ @6 k% ^" Z; E
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- r; Q! a) M. {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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
6 C' W: y Q3 a7 e5 ^ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。/ R5 v9 Y6 O+ p: L2 [9 ^0 B/ z% n
" \/ @; Q3 f+ R, _+ Q- M+ V) t
, |: F7 w9 w9 x/ Y: g |
|