|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ c: X! P- W8 r3 Q- [code]EDMA sample test application
6 h" W: L- o( a2 ?1 U& D- ?) L3 C$ C - /*
' E# C4 D8 @, z& b) X @. m; p3 H - * edma_test.c" [8 a1 ^. ]' l8 S* R
- *0 U# ], v* D9 W
- * brief EDMA3 Test Application6 T2 W8 G# b' d& E. j
- *8 @9 \# ^1 ~4 U
- * This file contains EDMA3 Test code.0 r' z5 m J5 m/ v: w
- *
8 r b9 b$ S$ J+ F- |* A1 L9 j - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE% V7 U- [ \! b- c: E
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( d- ]7 z8 q* ^9 @) \4 V* m - * TO CHANGE.
0 W7 N5 b* b' Q% I2 | - *' P4 w# P2 \2 |+ ?* e, l2 ~
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 x& R: M5 u. n4 }- ? - *
3 O' k3 M+ V) A2 w0 D - * This program is free software; you can redistribute it and/or
* [$ P6 G0 U+ B% @# ~% ^ - * modify it under the terms of the GNU General Public License as
5 s" V: _3 @' K! R$ U6 r - * published by the Free Software Foundation version 2.! L# ?7 L( Q0 P. O! D o
- *- H6 C1 l( c1 o* H% P4 Q
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 F/ p- o8 @. E4 B
- * kind, whether express or implied; without even the implied warranty
( @9 o- D+ G N& Z- E - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the- n0 f- y9 E+ }! ]9 ^9 c
- * GNU General Public License for more details.
: l- B+ P! u: Z - */
1 M0 l9 B1 d: I. k: h- S- y5 C
/ H7 s2 _: V" d" E& x+ q- #include <linux/module.h>$ F' ^/ Z* a4 e5 e" f
- #include <linux/init.h>
: l) v6 [/ C* a1 w - #include <linux/errno.h>% V5 n% n- M% p& p
- #include <linux/types.h> m) A! k3 V6 ~. G: B
- #include <linux/interrupt.h># D+ m, U M7 ]1 l& |# o. Y0 m# Q
- #include <asm/io.h>/ H, I5 b8 {) v
- #include <linux/moduleparam.h>
1 r9 ~' B+ U) G+ \% _) \( _' h - #include <linux/sysctl.h>
2 o: ~; T5 U# c0 Z, ] - #include <linux/mm.h> w5 t6 A5 k: j) {8 u- R
- #include <linux/dma-mapping.h>" C: I$ ]9 G8 b' {* ^% ?
- 2 Q. q* S: w- G3 p3 v0 V
- #include <mach/memory.h>1 b. P+ J% Y; x% {! ?
- #include <mach/hardware.h>
6 R/ C8 m+ e* N4 ]6 q9 c* h+ Z+ Q - #include <mach/irqs.h>
0 c* o1 A. t& A+ h* A$ [ - #include <asm/hardware/edma.h>* o1 ]/ \( i. B8 o- L- }$ R# I
- 8 ]. B) n3 O& u S y7 D1 o
- #undef EDMA3_DEBUG
& s/ Y5 c) P4 ~3 J/ B/ h. O5 \ - /*#define EDMA3_DEBUG*/
( L5 k R& f& Q$ p - 4 \3 B3 u; ~6 T, S7 ~# ~
- #ifdef EDMA3_DEBUG
! B) c. G' n4 I, k3 C z$ F - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" F4 y6 q8 F( c7 B% r) F/ n
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. n1 m0 B0 f/ Y$ \/ p+ a: a - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
/ F. r* v/ d& j7 f+ X4 V - #else
8 c; A0 R$ \3 W0 j - #define DMA_PRINTK( x... )
6 y4 C* m# e# b# o# X* Y, @ - #define DMA_FN_IN
7 K- n) u2 R8 k; Z/ m3 n8 H - #define DMA_FN_OUT
$ T0 l9 X8 p, Q) t; U& j - #endif4 `( y% Q" L7 |7 w: t3 t3 ?
: Y* w6 W+ l$ i1 l# m( d- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
% `& H- A6 W9 k5 ^: } - #define STATIC_SHIFT 30 M7 S9 ?" |( j* o1 @* O8 B
- #define TCINTEN_SHIFT 20( E: s* K; s4 N$ D4 Y; S0 c5 w
- #define ITCINTEN_SHIFT 21
' V4 M8 L& D: q- @0 @ - #define TCCHEN_SHIFT 22- U8 I5 l/ J8 V, R
- #define ITCCHEN_SHIFT 23
, r3 K/ n- b8 Y' l h - ' Y6 r( w+ C$ u3 E; y# t
- static volatile int irqraised1 = 0;
0 K$ m. B8 g. m m5 q r# k6 T - static volatile int irqraised2 = 0;
; u9 n' [2 h5 \; q* X; g5 a
E! b& H' Q0 N, Q8 B- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- g% y+ R5 a, d4 ?+ j
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* a9 l# I; X m9 I4 z- J- @5 k - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. W, A; N. |, P( a: l8 a4 p
' o& w4 e3 O" ~ q$ D0 {( T- dma_addr_t dmaphyssrc1 = 0;
5 [0 r& v0 ^+ d( i$ g - dma_addr_t dmaphyssrc2 = 0;
3 _' n H$ j' m1 \ - dma_addr_t dmaphysdest1 = 0;* Q( ~% k2 d J4 j. F
- dma_addr_t dmaphysdest2 = 0;
: u$ s2 V$ c' o
7 w0 g' P9 `, R7 _- char *dmabufsrc1 = NULL;1 Q- l5 Z: l4 ?3 V
- char *dmabufsrc2 = NULL;
$ `) t4 `1 y- r/ ?4 y - char *dmabufdest1 = NULL;
! _6 ~3 e0 j; F: s5 K: l: v - char *dmabufdest2 = NULL;0 L6 c' r& A [1 \0 `
$ B% d+ V; y% \- I- static int acnt = 512;/ f' p; Y( |2 ^6 a0 e+ e
- static int bcnt = 8;4 ]- \# ]8 K# M. ^$ k2 ~
- static int ccnt = 8;8 b- C$ l' C7 E4 D
- 4 K& a% Y( J3 I2 q' u% Q
- module_param(acnt, int, S_IRUGO);9 d( ~- `4 G3 v& C4 _. i# R! ~: ]" `
- module_param(bcnt, int, S_IRUGO);; t9 R% @8 ?, ~; y, U' x# l
- module_param(ccnt, int, S_IRUGO);
复制代码
8 L* h% j8 |7 `/ B% n' x
9 a& n3 N4 w; y$ @ 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用' r1 [* f. ^( n% K
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
1 O) F8 L, e' T3 ~3 j( C 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 D) e l0 P7 L0 n! w# o! |* |5 r" x2 Q: ]9 G& n. f ^
5 ]2 O8 Z ]- N! D: u% R0 J |
|