|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 1 ?8 h. O! h" L7 j( o0 z8 p; r
- [code]EDMA sample test application
1 G* y- }5 [6 T+ {' K - /*8 A. m. L* `4 O( v2 n
- * edma_test.c
1 _. X: @0 \0 l+ g& W$ d3 _1 l - *( u- z# E# |& m5 H2 l4 m) ]
- * brief EDMA3 Test Application
& [8 f+ r/ }) D, g" Q0 B# \* ] - *
' ^+ ] r; u" [7 _) B - * This file contains EDMA3 Test code.% K8 ]$ q4 D, o% [! J2 I- U+ P
- *
+ U# _6 U; F, {" [ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
+ G, Q m$ d3 e1 n0 N( j- }2 H9 I - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
: ~8 K8 j8 ?; a; M& e9 _ - * TO CHANGE.* g9 [ E( M# f% n3 h/ T
- *. A6 c1 r5 W& v, N+ ~4 Q3 y: _
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! N. c$ M/ G# C' @, D0 @
- *
5 D$ S" }" {4 a5 A - * This program is free software; you can redistribute it and/or
5 X# d0 K' `: V0 R7 P. {! q - * modify it under the terms of the GNU General Public License as
% ]$ f! t7 s4 s* z& C E% P0 | - * published by the Free Software Foundation version 2.
2 p. O6 a( }8 R - *6 q$ ~8 f2 g1 T. b' e' b
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- O2 ]7 E$ ]% B: I \6 V4 m - * kind, whether express or implied; without even the implied warranty w$ |3 u$ K% Q9 N8 D
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+ j2 i7 E5 I [0 G% n7 |( c: ]
- * GNU General Public License for more details.5 v! @- {1 m4 ]
- */+ p$ Z9 T; T. h: A8 V+ D
- ) O5 v* z ]8 ~; E$ ?
- #include <linux/module.h>( W; k& H" `( X3 n
- #include <linux/init.h>, j9 N$ u* {7 F( e- f; G( f+ \
- #include <linux/errno.h>
$ q4 n5 F7 s: p- h3 f3 H - #include <linux/types.h>2 }: J$ B7 F, K1 G9 V- q
- #include <linux/interrupt.h>
* P& h$ I* A' s, T, R2 Y6 L& Y$ g - #include <asm/io.h>+ y5 p! R9 ^+ V$ e7 l9 `! c$ E
- #include <linux/moduleparam.h>9 e; S# D; n; f1 |1 v' i2 g$ K
- #include <linux/sysctl.h>
, f$ c1 `- r) u6 p% l - #include <linux/mm.h>3 m* j# E' c2 m, \4 E+ X( x7 Q
- #include <linux/dma-mapping.h>
7 {* S$ E- i2 Q. R. Z$ u2 E8 | - 5 \+ d- | Y, \. R% O, t m4 d2 \
- #include <mach/memory.h>
1 f" b- ?# k' c# b/ X1 Q/ T4 k - #include <mach/hardware.h>
4 G4 \$ G4 p, W- N( u0 X - #include <mach/irqs.h>; \ Z- ]7 M v
- #include <asm/hardware/edma.h>, v$ l' u7 \5 P) Y. o, B6 I& a2 R2 L
- ! F0 r8 w! k2 {
- #undef EDMA3_DEBUG
6 v% p( p# L' l3 \7 }+ ` - /*#define EDMA3_DEBUG*/
3 m# \8 L) v* U/ I; X5 f
/ ]2 m& w2 }. E0 [0 Q- #ifdef EDMA3_DEBUG5 q% F; W- B2 x% r: w& a: v
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( N( v5 s H* ]) ?+ D2 m
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
3 ] J5 ~8 Y5 g) q - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! Q7 o% z, s! c. }/ @ - #else
! ?6 z- C/ W8 p- s* J- m - #define DMA_PRINTK( x... )3 A6 y6 ?' ~9 y( G% a
- #define DMA_FN_IN' z$ J' i0 L1 p2 T3 x5 |" ~
- #define DMA_FN_OUT% F% \+ U+ X7 t4 g6 w
- #endif1 C2 y6 H9 N" ~2 t& w
) ^( q3 |/ K# J0 y9 f+ S- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) K0 u/ l+ B% {/ V6 |- L - #define STATIC_SHIFT 3
" K1 t# a+ ~# J* k$ B4 @ - #define TCINTEN_SHIFT 201 A% g" g! E% e V* A0 o5 V
- #define ITCINTEN_SHIFT 21
. I* [$ ^& A3 X) z" Y - #define TCCHEN_SHIFT 22* V: b! W4 r) u/ V* Q; i$ u
- #define ITCCHEN_SHIFT 23
2 Q& c" j# i- O# Z' q: @ - : q6 o4 H l. a' m n4 o5 G
- static volatile int irqraised1 = 0;
4 W t \8 `5 E: m" ^ - static volatile int irqraised2 = 0;2 c+ e: m- ?: ^2 f* n
9 p8 A( B. F( ?0 t( n: x. h" s- }% @- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; W* j$ c# m5 y4 }5 F
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ ^: A& J9 \; N! J: l/ s1 _8 k - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 t3 b2 F$ N u( m) f; s$ {3 `
; D* |8 I J# q; |- _- dma_addr_t dmaphyssrc1 = 0;
- ]8 A4 R& k i# s. G% w - dma_addr_t dmaphyssrc2 = 0;
" C' e) m3 H7 K' }7 R9 j8 g5 g - dma_addr_t dmaphysdest1 = 0;
. z1 }; H& I2 p( X7 t* S7 p: w - dma_addr_t dmaphysdest2 = 0;
$ t/ f& d. _. u) t' }5 \. I% t
4 e4 u e- y( T/ [7 V- char *dmabufsrc1 = NULL;% |/ f" S9 K4 O1 b1 d K# i( q" v
- char *dmabufsrc2 = NULL;; c; c) J. {& @) n
- char *dmabufdest1 = NULL;
+ i. F* a# p/ ?- C1 w; s5 l - char *dmabufdest2 = NULL;
! y! C7 v9 a' p7 E, ]6 [ ] - 7 ~8 y' V5 k9 |# a
- static int acnt = 512;
) ?# W0 d x' r- ?* m1 R - static int bcnt = 8;
* H* G5 \% N" [9 O- l - static int ccnt = 8;
r- M% g% u- v5 ^5 u5 h) Y: Y
# L$ y5 A. X" F" F, r2 `9 W: a3 l, u2 o- module_param(acnt, int, S_IRUGO);" ?/ h8 }* u- w) ]5 n# P
- module_param(bcnt, int, S_IRUGO);
( G0 s1 _" i- j2 t& K# O% _ - module_param(ccnt, int, S_IRUGO);
复制代码 R `/ Z5 ~( Q1 p" Z
( G; u) E% n) T1 ]) n: r
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用4 @, N; B9 y* `/ O% g+ |: t+ m/ t
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。, K# ^- O- ~: w
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# ~3 c2 H, q- z3 r8 Q8 K, A5 Y3 k
x' b W0 l1 w0 W6 p7 e: A+ g
6 f' I: V8 u# A: R2 Z& q/ } |
|