|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , {: h' o! |6 p- t/ F1 _
- [code]EDMA sample test application
3 E C7 ]- I1 u# F$ z+ j - /*( U& J$ s9 D- [9 Q4 S, k( n
- * edma_test.c" q* m5 U/ s6 n. ~) v$ {7 r" ~
- *
9 ^$ z# p' I+ [6 ? Y" n) |8 h - * brief EDMA3 Test Application0 m: I/ f2 ^/ R# N8 B9 x
- *
# t: d" S5 @8 `. _ - * This file contains EDMA3 Test code.2 F! n( S7 o# @# `+ l; q/ R
- *
% n8 b8 L! A: h. y2 x; S7 H - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE! P( U2 b1 a5 \ P
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT- Z% ~ Z9 Z; x. m, {
- * TO CHANGE.
* J2 ?- T9 c: x+ Q7 d - *, j9 ~4 f$ i" k9 {
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
, Z) ?" ~: H4 x. E$ M* `$ X& n/ ] - *
5 x/ R a6 S* w! Q+ { - * This program is free software; you can redistribute it and/or' t6 F( G6 V- U
- * modify it under the terms of the GNU General Public License as+ Z1 Q2 l5 R4 [' o4 {) }+ v
- * published by the Free Software Foundation version 2.2 B8 ?3 P7 ^% t" ~6 p+ x; _
- *" ^; z) B& g1 z3 U- d1 ?
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any" q l- Q7 `7 M) r, u. Q. k
- * kind, whether express or implied; without even the implied warranty) X$ N) ~3 n8 S$ j
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 u5 C# x5 K# f Y4 g" a3 G7 U - * GNU General Public License for more details.
! e! a {$ V: r; q+ H+ _. l - */
1 k3 o; {7 t* E# w: _- P4 P9 ^5 l* \ - 4 }2 g; m q+ W0 ?
- #include <linux/module.h>) c' i4 I; R' C$ ~" Z
- #include <linux/init.h>* o! p# U8 a4 j$ ?7 K) q
- #include <linux/errno.h>
& k3 j* q6 v8 O. d0 I0 q6 z. \5 s4 \ - #include <linux/types.h>2 ~8 V3 ~- }- ^/ W n1 w' Q+ g
- #include <linux/interrupt.h>
; E8 ]+ c2 |4 R/ ?1 a0 p! s% u" r w - #include <asm/io.h>) l4 b# ~- e9 m$ z
- #include <linux/moduleparam.h>/ o3 @2 e% H6 C' X1 z6 F. l1 L
- #include <linux/sysctl.h>
( k3 q. X* }. } - #include <linux/mm.h>$ ~; h/ V3 C' @4 _; G
- #include <linux/dma-mapping.h>* u; V9 b# ?: g+ L8 N) w& F$ l& Z) M
- % X; F4 W5 @2 z& T6 c7 h
- #include <mach/memory.h>) g* X& V8 z3 l$ p( Z
- #include <mach/hardware.h>
0 e0 w% Q2 k' E1 P) z - #include <mach/irqs.h>0 [; J: L* G( [6 K7 z
- #include <asm/hardware/edma.h>
! v5 | }" n! y9 X' m' x - ( ?9 `, c5 r% [: U! h7 B
- #undef EDMA3_DEBUG
c7 H; i) a( q, p5 S n1 M# {8 k - /*#define EDMA3_DEBUG*/
( s7 k3 Z; U9 `* G% E$ a* N
2 s. Q) Y" X' _. ]- #ifdef EDMA3_DEBUG% o- q6 W' H$ p+ O
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
1 {8 p1 d' g q3 d; G9 k) o% C - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)/ B, m% U8 w" y, M* H- T. v% ?
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 E! s$ A) _" r/ _' x - #else
% i5 u. z$ [4 t1 u! N* G - #define DMA_PRINTK( x... )
0 \& N4 k1 M2 {4 D3 s - #define DMA_FN_IN
' u6 i) s# D+ Y+ T% A! @ - #define DMA_FN_OUT
& u" `! t3 Y0 C% Y% o - #endif: [* `& U% G7 n. E; C: U. z; P
- 6 R7 f, Y: a0 k0 p0 o8 z: X
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
6 n3 k# C( I1 y- k( v - #define STATIC_SHIFT 3
3 s" i: X# Y" ~* k5 ? - #define TCINTEN_SHIFT 20
' E( c9 B# D: {0 W3 L% T: @ - #define ITCINTEN_SHIFT 21- d/ m. g' X" _6 D
- #define TCCHEN_SHIFT 22
' r$ [& b" g$ o3 {, p/ l% m - #define ITCCHEN_SHIFT 23( }5 h6 Z; v; B* n6 b
- 0 W$ w: V( O) e3 u9 O5 h w9 M
- static volatile int irqraised1 = 0;
" z9 L* ]2 @6 x& N% {; R* @ - static volatile int irqraised2 = 0;
- A# q# I9 s1 ^* ]5 b7 t: D5 i
1 w4 O# C: G* d" c4 t; t" x% d- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);8 W9 Z1 `1 ?: G/ {7 l( q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 D' Q+ ^" h6 I/ o* V; q - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
' N6 h. O6 q+ q# ~ - 0 W- p" Y3 f3 J# N4 O7 ?# S
- dma_addr_t dmaphyssrc1 = 0;
% X% C6 c. C. k) L, n - dma_addr_t dmaphyssrc2 = 0;
5 p0 v7 E, U! G8 P* ]8 J9 d - dma_addr_t dmaphysdest1 = 0;
$ d- o; A# o! D5 Q - dma_addr_t dmaphysdest2 = 0;; A( a6 s& k4 Y/ L1 r, U! O' M
: V+ \, \( b0 A4 a- char *dmabufsrc1 = NULL;/ i+ ~8 @4 i+ E: c/ Y
- char *dmabufsrc2 = NULL;
( [4 z8 V7 ?, C+ J' i - char *dmabufdest1 = NULL;
8 n! {) w8 d& }2 n1 T - char *dmabufdest2 = NULL;
5 b- m* V1 G: [7 w& ^8 u - ' c( ~' M: D2 J$ q' w. c
- static int acnt = 512;! C2 O* r4 l9 ^- W
- static int bcnt = 8;7 F% V& c9 e0 ?; }0 H; A
- static int ccnt = 8;
, S+ H3 F$ r6 X1 m, }/ s
4 G* ^% d, R! W0 s f K @. @- module_param(acnt, int, S_IRUGO);
6 M. b5 R J* ]: }: ^5 G - module_param(bcnt, int, S_IRUGO);
1 ~ M) o2 Z! K5 @+ Q: G$ r - module_param(ccnt, int, S_IRUGO);
复制代码
1 d- R+ K- U$ [( y8 h$ ?4 n/ t9 f9 L
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用8 @% @, M8 A, [ x6 }
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
- D8 ^, Q/ m% }( u4 @# }7 ~+ y 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
& q2 N H1 ^+ m% n2 K: F$ I* I; l5 d o, r( X8 r
* W7 R" h' |; o |
|