|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 / P) P) m z+ _' G* G
- [code]EDMA sample test application
/ F& z7 }# R4 O: ^ - /* ]' g" L" g& U* U; n% J$ A
- * edma_test.c7 n1 ] A2 d3 Q
- *
9 ^: l b- z; X3 x; l/ X- l - * brief EDMA3 Test Application& M" w# P G3 }# e, j
- *' G, V! q% t9 G2 |
- * This file contains EDMA3 Test code.
$ F3 M3 ]( V; p l0 [5 n - *
% y9 e. J. U; X5 p - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( i/ ~7 t2 p$ J( u6 \
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( v6 D; l) `9 m: ~3 D1 w2 X - * TO CHANGE.$ h* r o" H' T- p Q
- *; W" V7 a1 i/ H0 ^- H7 l" a+ }4 Z
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) a3 L& C% s! O! D& t% l& W5 m - *
" A) I* F; t ]+ A5 u - * This program is free software; you can redistribute it and/or
4 s5 n4 b+ I [8 n* l( Q - * modify it under the terms of the GNU General Public License as
O9 w7 \$ l" i) m' b - * published by the Free Software Foundation version 2.- _& y1 H7 V; V2 I
- *
8 M- m7 V8 u; t/ F - * This program is distributed "as is" WITHOUT ANY WARRANTY of any! \5 n. x' Y6 L
- * kind, whether express or implied; without even the implied warranty
7 c) ~- V" }% x. ^. a J" l* v) q+ O - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the) e( |; i) X- q: U
- * GNU General Public License for more details.5 Z6 @0 w0 @4 h C. S
- */
6 Q, ~" x( [; z9 y - . M$ N1 w% F* g% u
- #include <linux/module.h>7 j" v# f/ ]& J5 I
- #include <linux/init.h>
' a! Y* f! S$ @* S5 o - #include <linux/errno.h>9 @" S( o. s8 l- u+ M. X( K! Z* X
- #include <linux/types.h>% ~6 n5 u6 z5 X& t. m2 O
- #include <linux/interrupt.h>* c3 S* d% M. B/ |# T
- #include <asm/io.h>! G4 m( R3 ]& B7 _# j0 R( Z: n0 K
- #include <linux/moduleparam.h>/ e: T9 [; S+ q# w, C! ^' _; x& k; G& f
- #include <linux/sysctl.h>- i$ v2 r6 h* Y( h: t( j
- #include <linux/mm.h>+ t4 x' z! o4 M. e
- #include <linux/dma-mapping.h>( [8 }0 ]9 x0 f1 y" K7 n+ R6 Z
- 3 t. d7 ^5 u7 A
- #include <mach/memory.h>
, {. y0 t" E# G/ A - #include <mach/hardware.h>
+ F) b2 C# T4 ^. ?( z5 n - #include <mach/irqs.h>1 u5 ]3 N; V0 p- b: b; A
- #include <asm/hardware/edma.h>1 @/ J1 n/ P7 U. \0 u
9 J" |9 h! P0 _- N0 W+ \9 A9 X3 D- #undef EDMA3_DEBUG
" t( s. V+ x% f: A/ K$ b# w2 b - /*#define EDMA3_DEBUG*/
+ ? M# Y/ ]. ]4 x7 [ - 1 ?+ b' i2 f7 E0 S7 W: B1 g L
- #ifdef EDMA3_DEBUG
' M! S5 V, t* @) u - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" f# h+ C) `5 {* _ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 r! ?$ ~- {9 H' G1 q# Q$ E - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
- K4 Q2 _# q8 m9 }: f8 @) ` - #else
" ]4 z* I7 J8 V) R6 I - #define DMA_PRINTK( x... )
5 S- V* W' y1 k5 U; R, u - #define DMA_FN_IN; F6 F6 |9 f1 [2 Z( e
- #define DMA_FN_OUT7 y- p ?+ U8 O ?2 T
- #endif, r' e2 a& M' A& }( @8 Q9 l' {
8 Z" r ?5 M& S+ q, l0 B- #define MAX_DMA_TRANSFER_IN_BYTES (32768)) U1 Z0 ]3 K: |/ f2 Y6 N; }, K; R
- #define STATIC_SHIFT 3( S9 n: M3 I$ [$ O, D( S% X5 z$ c/ \; v5 \
- #define TCINTEN_SHIFT 20
" i9 V- l* z. F; _1 Q$ y' K: u - #define ITCINTEN_SHIFT 217 j9 J; m3 X$ U
- #define TCCHEN_SHIFT 22
4 \ Z/ g5 V9 ?* x - #define ITCCHEN_SHIFT 23
9 B* p* R* w: D2 t' C - 2 V: D% E8 S9 m/ C( a
- static volatile int irqraised1 = 0;
- L7 X9 z5 u4 R4 B - static volatile int irqraised2 = 0;5 D0 T0 O' X$ @% R" D( P/ u
8 v- c' f( U1 C$ t- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 R1 S" S0 A2 G9 i" }; s: `$ B
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* B% y7 x6 x% U/ O2 j1 f% l/ o
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 ~( P7 E3 _: B& } m1 q( t; _$ {
9 [! _5 y l7 Q+ S( g- dma_addr_t dmaphyssrc1 = 0;
2 l. C% ~) i/ a: f4 D7 s/ Y - dma_addr_t dmaphyssrc2 = 0;
* C8 [1 O( l n0 S3 v) U - dma_addr_t dmaphysdest1 = 0;1 `* k$ X! U" B/ [
- dma_addr_t dmaphysdest2 = 0;) \( U2 |3 a1 B Y% ^
- u& i2 V: ?' x, L: r4 a
- char *dmabufsrc1 = NULL;
# h, l5 E; e; J7 M& ]3 `% V, s6 b3 H, s - char *dmabufsrc2 = NULL;5 S2 s. R! L+ D9 X" X: L- [6 R2 L
- char *dmabufdest1 = NULL;9 D' p) b5 |& [' N, E4 F
- char *dmabufdest2 = NULL;, o5 K/ y t d8 v2 O* x! c
( O8 e+ Y) p7 ^. z! M7 e- static int acnt = 512;
3 A4 E& t" N/ w: w! a - static int bcnt = 8;
" a X. ~1 J/ k) R' f - static int ccnt = 8;
8 ^* ^& Z9 A! U9 M
! f; _( l2 T/ v# G# V$ W1 e- module_param(acnt, int, S_IRUGO);
9 J1 R: t* P7 @6 P( E7 G2 w' K1 c - module_param(bcnt, int, S_IRUGO);! ^( v2 D* R: F) U
- module_param(ccnt, int, S_IRUGO);
复制代码
: G2 o9 e" j, @
$ N- k3 `' V5 w+ j( @" B# c 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* Q6 U8 [; B7 W% r2 k1 g1 @$ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
) F5 x5 Y# Y. q! v 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。/ ]5 N& \" y# l" ^
+ g" l7 K% q$ j% b
0 V, [' ]' K9 ]6 \5 o- h
|
|