|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 i( G+ x8 }% u" j/ f
- [code]EDMA sample test application
& N, A6 z9 Y/ @ - /*2 d7 I* h: G! C S
- * edma_test.c
: I. J; \7 @9 p7 j - *- p% k* s `0 V: @' r( z$ P. H5 v- k
- * brief EDMA3 Test Application% R8 p, x8 ?0 i2 N) | d' Y
- *7 R$ S' P7 i7 G& B
- * This file contains EDMA3 Test code.
3 |. Q: f! T9 {9 U$ x8 v3 u - *& u0 d: J) b/ [3 s+ P
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- F1 E' M$ X2 J4 h3 ` - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 J. r- \+ j' u$ }2 R# l3 v" p4 l8 D - * TO CHANGE.9 Q( H& Q3 v0 Y+ I) o1 v
- *
1 a- B& y3 }* X( t' U% w# T i7 _ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
; {# j+ g9 a$ l" f3 W8 N7 m9 V% S - *
3 d. A. p8 o6 j( F$ V; s: { - * This program is free software; you can redistribute it and/or
6 U, B3 |) V3 V. O" z# w y; W0 O - * modify it under the terms of the GNU General Public License as
/ M/ s- @5 l6 o4 n) t6 \ - * published by the Free Software Foundation version 2.) T& ]( f# p4 i- O9 O
- *
$ C! g" h- A: L2 G - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' C% s; W! u/ g5 J- W+ B - * kind, whether express or implied; without even the implied warranty
" K$ X4 o$ `8 y* f - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. |# a- o8 h0 O) o) L% s - * GNU General Public License for more details.. ~6 g3 z, i5 u4 ~5 X0 X8 v
- */+ a/ E# R" ^+ {$ @9 `7 X. q
[* r3 b) _' D8 K' N9 V8 G* l- #include <linux/module.h>: x5 v2 ?9 \& q
- #include <linux/init.h>9 D* L0 z5 z! X" B
- #include <linux/errno.h>9 j( E: r" V f
- #include <linux/types.h>
" G- E9 G$ a0 A, C; b' H - #include <linux/interrupt.h>) k* W' R! `$ w
- #include <asm/io.h>! }: ~; `! `6 l. F2 V
- #include <linux/moduleparam.h>
1 l! m9 x" ]) x# T - #include <linux/sysctl.h>$ W9 K2 ]7 m. C7 M8 E7 i
- #include <linux/mm.h>( N3 g" ^+ i& _: f$ e F0 Y) Z
- #include <linux/dma-mapping.h>
/ y! x1 B% F6 ^. D# N2 s6 Q1 j6 v4 N
( _, x/ T( E/ C$ s# m- #include <mach/memory.h>* D+ ^+ c; [6 c* l5 i. p. |
- #include <mach/hardware.h>
4 p% B3 W: o5 ]( j- } - #include <mach/irqs.h>$ \4 E% v1 p7 C4 M1 `, U
- #include <asm/hardware/edma.h>+ P& E8 C0 m, f$ d% y* ]4 k
% l: e0 a; C: ~3 C( b, ]. Z2 K* P- #undef EDMA3_DEBUG6 n% h* h5 I4 |7 G
- /*#define EDMA3_DEBUG*/
- L: _: [, v$ g }" _ - + Z( x( r' Q2 T
- #ifdef EDMA3_DEBUG. d! { c: Z3 {0 w" R+ c% p$ m
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; d( `" f: `, y5 z0 h - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, @" r% l3 U6 n; L7 ]6 O2 s - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
! g1 |, t( e6 P- R+ d - #else! c" l8 G2 F) t; j! l& X3 M) Y
- #define DMA_PRINTK( x... )
- B _* N, I, E5 ^ X8 G# ?8 S* ~ - #define DMA_FN_IN5 j/ _" P1 `' X. g" y' f( \
- #define DMA_FN_OUT! y6 l! K J; J! e4 G4 T
- #endif
) F0 B9 B3 q' Q8 c/ s
9 s9 o7 H7 P/ P$ E5 U! P- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
% `* ]- K) t( h1 _2 J- F( \4 M+ f - #define STATIC_SHIFT 3
; |1 F, S5 Q! B7 g5 { - #define TCINTEN_SHIFT 202 }- m) `) b: g3 L, e: w% v
- #define ITCINTEN_SHIFT 21: |& `, |7 ?+ V, O* H
- #define TCCHEN_SHIFT 22% T+ x( G# [% u
- #define ITCCHEN_SHIFT 23
. M% G* g% s" D. w: m" p2 N
' g% g- p6 a, O$ M2 d. e3 ~- static volatile int irqraised1 = 0;
2 J# h! r# e+ e" |& B - static volatile int irqraised2 = 0;( e! k }! ~& z/ V) |: N1 ]) E3 h
- * G: V5 v$ Q- K# x- j0 O, r
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 l7 K6 ?9 m, X$ H. E# g' m- q - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( j1 s: `, ?9 }+ R - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- h: H2 |3 U: r( M4 I* V" m
- " i* h; L! f U5 a' }0 J
- dma_addr_t dmaphyssrc1 = 0;
5 |# [/ y! Q" N. l% t9 s - dma_addr_t dmaphyssrc2 = 0;
2 D6 J; I5 q: F* y - dma_addr_t dmaphysdest1 = 0;
8 V; X8 f* S2 ~/ G: L9 J - dma_addr_t dmaphysdest2 = 0;
) ]6 L b% H, m - 0 s$ W) H# N9 r: Y7 a9 N
- char *dmabufsrc1 = NULL; ^; e7 T: y% E
- char *dmabufsrc2 = NULL;
) `. }9 R, k& {! k' B2 ]% D! C - char *dmabufdest1 = NULL;( v. \; u X0 S' D
- char *dmabufdest2 = NULL;1 s: x* w! O6 J5 v" g" L
, E1 k# s& A* r- o- static int acnt = 512;
4 B5 Y: e; u0 X - static int bcnt = 8;
i/ J9 G" L+ b - static int ccnt = 8;
7 K" c( U. b q1 S - g# _, W" {+ y1 V' _: L4 `
- module_param(acnt, int, S_IRUGO);" W, u, K, I6 u1 o" a' i
- module_param(bcnt, int, S_IRUGO);2 o2 H, G: _. b2 ]
- module_param(ccnt, int, S_IRUGO);
复制代码
9 i S4 f" B( U2 \" }" s! \' Z3 H' h7 ?- h# W1 [
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; I r. F# ?/ t% W$ Darm-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 M3 R* Z2 U5 Y6 X
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 m* \ H* [$ L$ [6 _) W1 U/ v
+ D3 Q8 W) C: _+ S3 B( n
. b* E- w6 I& f' }5 G) @2 N: I |
|