|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 l" `+ H% F9 K- [code]EDMA sample test application
7 ?: G+ i5 a4 n; g - /*
; z% r! H3 P# X& u( e [ - * edma_test.c
% E7 H' l& k {: K2 }+ p. [& S - *
. [' n3 Y ~+ Z - * brief EDMA3 Test Application
9 B" _) ^4 f; V- l% \! v. z ~ - *
% x( v# ]4 p4 L/ R9 r3 j - * This file contains EDMA3 Test code.
~3 u: a6 _; N1 g - *! [, e7 D$ P$ b/ p
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& V* J: Q5 t$ r& Z8 i% z) Z j
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% m I$ R( b# L V - * TO CHANGE.4 d% p! }, i8 E/ k1 C8 C6 P% _6 W
- *. b. y/ \* s: j8 c6 l
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- W! m; h5 N$ g) d8 D- e
- *& L/ S6 v0 I6 K8 ^3 v; Z& H2 }
- * This program is free software; you can redistribute it and/or! Q! d- m+ d, B4 u0 [; O
- * modify it under the terms of the GNU General Public License as% d" K! |) u I9 Q% P& _
- * published by the Free Software Foundation version 2.
2 i9 Z2 L, {1 Z- ~ - */ G; o' c* ^2 r: g! X. M/ ~$ d
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any7 Z1 Z s! i. m3 p9 ` o
- * kind, whether express or implied; without even the implied warranty
# ^- D K% \) K; [0 O( {8 a1 m: A# p - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 X0 N) Y: _, s; e/ {, J6 X
- * GNU General Public License for more details.( M. w/ ^8 d, b. y
- */, X( m0 U- f4 P4 o
- 0 ^. d6 N: v: Z& z
- #include <linux/module.h> H& J5 u! E* ~
- #include <linux/init.h>
5 n& Y5 ]0 u3 P5 _* y - #include <linux/errno.h>
! P3 u& d+ k; M N - #include <linux/types.h>, S' y/ u7 | |1 c; O
- #include <linux/interrupt.h>
/ h% Z5 k8 k: R, W3 x# m - #include <asm/io.h>( V; r# ?" R) U) `
- #include <linux/moduleparam.h>
; @' W3 u4 E/ ^" Y7 r - #include <linux/sysctl.h>2 }# I) Q% |7 h
- #include <linux/mm.h>
6 s6 o2 J! W( g - #include <linux/dma-mapping.h>9 N) g% s! C* z
- 3 {; ?/ @* s0 H8 h0 E5 q
- #include <mach/memory.h>& C# B3 L0 g, N
- #include <mach/hardware.h>- L4 ~. J Q* |; a
- #include <mach/irqs.h>1 B6 r; x- l0 Z! M* x
- #include <asm/hardware/edma.h>
, Q. p& O- a5 t, m
& V! K) m& x2 S( r2 w: @' |+ K* [2 C7 f- #undef EDMA3_DEBUG5 {. x9 B' T/ ~: V S+ k5 X2 @
- /*#define EDMA3_DEBUG*/" e- _' X1 p1 g4 I3 |1 S/ c
7 J" {- r+ V5 w7 R! u0 o- #ifdef EDMA3_DEBUG; z4 B7 y. i+ F& ~) P2 P( J
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 `" L) \$ Z. y* M0 @: w* S3 g
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)0 B% ~% z" V! l% O' w
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* p! v! W2 E3 O" \& p3 {# P - #else
. b8 Q8 F) p$ }9 R0 m - #define DMA_PRINTK( x... ), g$ ~3 ~) S8 ]5 f$ C- j
- #define DMA_FN_IN
7 y+ r6 `" |/ v- j7 P: Q - #define DMA_FN_OUT
/ @9 z8 k0 K2 Z% }. k; F3 D - #endif( v1 d$ K1 C5 a G9 v
7 a/ V0 e1 H0 h& `7 {- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 N* c' B+ U* E+ s7 `& R8 | - #define STATIC_SHIFT 3; M& m7 g- e1 l& `) B( r2 `
- #define TCINTEN_SHIFT 20
; K2 G' s/ G$ J0 K - #define ITCINTEN_SHIFT 215 b4 F, W" X# L- B) k/ i
- #define TCCHEN_SHIFT 22+ p3 f+ ]. T* L A9 Q
- #define ITCCHEN_SHIFT 23
2 ~( ]7 |6 z* Z' ^
' X, n: Y* B% h4 U- static volatile int irqraised1 = 0;
. S9 v2 x. ^. s+ F( z \( e' s - static volatile int irqraised2 = 0;/ _2 t+ c' P, ~' d/ @1 n1 C
. K4 N* ^7 S+ H" {6 O( F( z- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) m9 |7 t, h w. { - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 t% I2 ^/ @2 p' f" p4 i- m" W. E+ D - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 g" V% B7 m; T, J' B - 8 H' o7 f7 A: K% q* b
- dma_addr_t dmaphyssrc1 = 0;
3 L$ ]7 q: l# K6 A - dma_addr_t dmaphyssrc2 = 0;
0 s0 U5 H0 P8 M* ]- o/ k - dma_addr_t dmaphysdest1 = 0;0 w% t2 U8 D" T4 ? K6 S
- dma_addr_t dmaphysdest2 = 0;
9 m: a3 I7 f' a" l) [9 a
) e3 r4 f$ _7 t4 h8 f- l. \' p" K4 C- char *dmabufsrc1 = NULL;! h+ X! h6 m1 `
- char *dmabufsrc2 = NULL;3 ~* s! B$ N( I$ |' W
- char *dmabufdest1 = NULL;
% T( R0 E+ w* v/ \7 y9 i - char *dmabufdest2 = NULL;: p! z& c. K9 b0 A4 T* B
- ; B: t8 z+ ~! E) x" n3 ~
- static int acnt = 512;
7 O* I' [, O! ] - static int bcnt = 8;
2 n/ }- A3 N0 _+ j$ Y. N% p5 e - static int ccnt = 8;
0 a, a8 {# U1 o3 X$ r1 M5 w - 6 W$ g6 k2 Y* Y- I8 O9 N
- module_param(acnt, int, S_IRUGO);4 G- j" }$ H. Y5 |. }; }7 _
- module_param(bcnt, int, S_IRUGO);) S. O7 k' C7 D$ G6 f; f9 F
- module_param(ccnt, int, S_IRUGO);
复制代码 8 b3 ]; Z; q5 i5 t& s
# b: z* X# B, T 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 P, M7 Z0 _$ B2 f5 s9 D
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。. w9 }4 A r, H, t! f9 A
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。/ O5 H' j0 r# ^
6 K( }! S. a( c
' Q# }& F0 @* o8 Y( a7 I$ _
|
|