|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
3 c7 k5 j8 e- |9 u4 L- [code]EDMA sample test application
* X5 A1 U0 |' v [' w - /*( B4 h; x3 ^: o7 E$ t
- * edma_test.c
' a& v4 b. B+ v/ g1 I- N0 s - *
4 q5 f, a0 C; l( V- [: G - * brief EDMA3 Test Application2 U' \& t# A4 O' }- F
- *" _$ y5 b$ g7 @" o, H; A3 V) @. J
- * This file contains EDMA3 Test code.
3 l+ S6 n' Z9 q* o - *
. W- o/ c2 i' _, v" u% W! W0 _ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
8 N8 R5 j8 Y; ^ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, _+ r" \3 i. A# i w S0 h! ]
- * TO CHANGE.# e" G: Y+ s( c0 c2 \# M! ~
- *
+ {, A( `+ e: l- [ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/( a- d. p% T# [6 M( e7 C8 J
- *2 o- @' x/ S, D& C
- * This program is free software; you can redistribute it and/or5 @6 m; t% S# w' X$ Y6 p8 R
- * modify it under the terms of the GNU General Public License as
`/ h3 @6 D& {6 O4 P - * published by the Free Software Foundation version 2." I: X: x/ C; Y$ O3 k7 \6 ~* e$ ?
- */ Z1 y' t+ ^, m
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; U0 R/ Q; {0 I2 I- ?5 ` - * kind, whether express or implied; without even the implied warranty
0 f, i. \: V. V - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' t9 S. \6 e8 _: M r, s+ Y
- * GNU General Public License for more details.
" V: W4 P+ P% v& l9 R - */
0 U& T! P( m; o+ j* N/ M
9 V' g! G) P" ?; x9 B- #include <linux/module.h>5 h3 Q& B3 P/ O% Z9 x7 w& Y
- #include <linux/init.h>
, t0 w, X- f2 g6 r8 W. W - #include <linux/errno.h>
: \7 l/ V3 a, Z! v - #include <linux/types.h>8 C' p6 v4 R; Z# c; X- ]) U
- #include <linux/interrupt.h>& z! o/ t- `' D* ?+ @4 b; e3 X
- #include <asm/io.h>, l9 j1 ~5 I" S; y
- #include <linux/moduleparam.h>
0 z( P$ h; O4 h, Q/ u - #include <linux/sysctl.h>* s/ I& ~) k: @0 w3 K6 c0 ~
- #include <linux/mm.h>. W( \; k7 E' K4 L5 a L# }- S! u, _
- #include <linux/dma-mapping.h>
1 I! X+ B3 _3 O- |+ C/ M! y
3 Z+ C4 d/ C7 o- #include <mach/memory.h>
4 w3 n4 y- Y; X8 s E. r0 K - #include <mach/hardware.h>
3 ^6 Y, W+ b+ z. o% { - #include <mach/irqs.h>* G! \" ]: f5 }% L, c
- #include <asm/hardware/edma.h>
7 q+ d0 G: x6 I9 d* X/ J
4 f0 J5 P9 }' C w" o- #undef EDMA3_DEBUG0 J* w7 J& {/ d
- /*#define EDMA3_DEBUG*/
& ]7 [* W6 @. @/ H u
4 G7 c9 Z' ]+ d( l; p- #ifdef EDMA3_DEBUG/ ]8 O5 _( L$ x1 [! F
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
. f: z( D+ t, o4 p7 V a4 O$ R - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, n! T7 L0 w0 S: l4 E m - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 H0 J, [- s! s% `7 } - #else
3 T1 S" V _. i& @: ~& [" G- L - #define DMA_PRINTK( x... )
; R; V9 G0 Q- A" D& A! H2 J - #define DMA_FN_IN
, v2 J, L- a: h7 j6 w6 a - #define DMA_FN_OUT$ l j2 _/ V2 ~* ] o
- #endif
r# M2 H" D! f+ N3 g! n: ~
* Y3 g) y& U7 ^: ]: Q- #define MAX_DMA_TRANSFER_IN_BYTES (32768): p T/ c. h' f; t
- #define STATIC_SHIFT 34 i. e$ c7 v% x) `. I! D
- #define TCINTEN_SHIFT 208 H& A. }0 N- L$ ?2 b# K# U
- #define ITCINTEN_SHIFT 21
6 x7 J0 Y% [" \2 c1 m4 D - #define TCCHEN_SHIFT 22. |7 ^% U5 Y5 P2 o/ ?
- #define ITCCHEN_SHIFT 23
' y+ i2 e2 A# W6 l) W/ c3 l2 J6 s
' K, Y. P2 r7 G; ]0 Z! j. q- static volatile int irqraised1 = 0;
$ {! L, F: f' l7 U b/ K0 ^ - static volatile int irqraised2 = 0;
7 v2 M. |0 b$ W7 M$ F
3 H; J. V, t& f1 R$ I' H5 v! b- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);5 W7 |6 e0 x$ _- C. U5 Y5 Q2 c' }# r
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ K: E' |7 J) y2 C
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) M+ e+ R7 S. N4 z" X3 Y- r - , k' } d6 z* I2 ]
- dma_addr_t dmaphyssrc1 = 0;
' f9 [) z9 L' A% q0 x' ^' O - dma_addr_t dmaphyssrc2 = 0;, f' t9 f5 o! b: J s9 V6 N
- dma_addr_t dmaphysdest1 = 0;8 B+ i& o/ q) C. J6 `! E7 g# Z
- dma_addr_t dmaphysdest2 = 0;
. L6 W: `* X% u2 g: k7 H
% P: a$ ^# U/ H6 g3 z- char *dmabufsrc1 = NULL;
0 Y! a: {5 t( C R* i - char *dmabufsrc2 = NULL;
, L1 ]( k9 C( P. U8 ]$ \7 k% I - char *dmabufdest1 = NULL;
1 V- ]1 S, D$ L- g7 g3 w: A - char *dmabufdest2 = NULL;
- `& b3 K. \" e! y1 m
$ {) ]5 |# ` e$ T+ Q- static int acnt = 512;
, q3 F7 Z+ M. e7 I6 ^, [/ T - static int bcnt = 8;$ k: M0 Q$ K9 ]$ t
- static int ccnt = 8;
# Z! m; s# t' I6 d$ N
* z4 n5 [4 i. Z7 u4 t- module_param(acnt, int, S_IRUGO); l' q( ~3 j# N- K
- module_param(bcnt, int, S_IRUGO);3 R# J u) N4 l& X
- module_param(ccnt, int, S_IRUGO);
复制代码 : G* v% v0 }2 g x# K! S
1 \0 C. n3 I0 B' E7 X( [ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
9 _" q- k# P; c( parm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。8 p8 x( M7 A9 N: ^' Q6 Z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" Y' D8 V1 w- K% F$ `1 O/ I
6 o* Q3 D. O" m
/ q; B* N( A) I$ y
|
|