|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
4 M* e; W- w" Z- [code]EDMA sample test application
) r: [% w; x; I9 g6 d - /*( {* S m" X5 |6 [
- * edma_test.c
. M* v5 Y3 F& E# G9 k - *5 @; G4 ^, V% N7 ]/ M+ |$ V3 T
- * brief EDMA3 Test Application1 g$ Q% I$ F% |% [
- *7 z/ S% I" C5 R( o' r2 Q# U9 \; o2 s
- * This file contains EDMA3 Test code.( p) _* w- V1 T e# e M9 ?
- *) o; w+ ?9 W9 P3 |
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE5 @4 D- X9 @; C. n
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; n b' {1 L' D1 k, l" z
- * TO CHANGE.
+ }, U. {* g: G* _/ n - *
! S& H- K6 u( B# ^5 N - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
" O A. o5 S" |+ c/ O0 v - *
: x9 ~# S. m6 Y0 c. H - * This program is free software; you can redistribute it and/or
) d7 P0 a- `) ^& F' a9 Q - * modify it under the terms of the GNU General Public License as
H8 [. ?- x, y v0 g( O - * published by the Free Software Foundation version 2.$ P- P- h6 j, i) b1 Q J
- *
- @0 R* \. |/ R( X# I5 ^% { - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
# L( ~' A* F2 m! M* x# C - * kind, whether express or implied; without even the implied warranty, p0 O: B3 }7 w% L
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" k4 J/ F/ [. F! ]( j( |% o0 M
- * GNU General Public License for more details., [* ~0 Q& [7 q2 `+ x2 H
- */- X- G$ L6 [! [7 R% x
- " ^& b7 m4 @# A# w
- #include <linux/module.h>- I) h$ o, c/ R. r6 Z6 M
- #include <linux/init.h>4 _: V; F9 q2 N
- #include <linux/errno.h>7 w3 D' G) Q5 n! a
- #include <linux/types.h>
! y. I' z! N) ~4 A% l' J - #include <linux/interrupt.h>
" H2 W3 I' r. n: h - #include <asm/io.h>
& B( z) g l: i0 p/ s6 A. L - #include <linux/moduleparam.h>
+ K0 ~7 z7 X4 B, U. U - #include <linux/sysctl.h>0 u4 ~: u( u3 L
- #include <linux/mm.h>
) h" `& w5 Q$ M8 P) j' C6 Q - #include <linux/dma-mapping.h>' I7 z' Z2 [$ X, |6 l$ Y0 C
# R# R, V' ?" M/ T" c! E7 V- #include <mach/memory.h>
: u# H/ D) p/ U+ G( q$ v - #include <mach/hardware.h>
@' M( w0 x: ?1 B - #include <mach/irqs.h>2 U# B0 v4 N! O3 e" i
- #include <asm/hardware/edma.h>
3 r3 {1 s. W: b - * A- ]% V$ `( o; \' o2 l9 w
- #undef EDMA3_DEBUG
5 K9 v( }0 X/ S8 ]3 r - /*#define EDMA3_DEBUG*/
2 N. ]6 W* Z" R' T: j5 v+ Y
) r7 ?" y$ }& O) P3 c: |- #ifdef EDMA3_DEBUG# o5 P. D9 v6 u6 G
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS); E# R) Y A: i B
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
6 ] o+ j. ^# i' M - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)5 ~ l" C( u2 T
- #else7 K' x# @6 V6 h( n% N! c' d- d6 ]
- #define DMA_PRINTK( x... )
! \; q" T; i. A - #define DMA_FN_IN$ ~* x" p9 n# |% E- ]9 M
- #define DMA_FN_OUT
2 W" k+ C. q& K5 i* B6 P) N$ B - #endif% c+ [9 A M+ w5 |
2 @" `) y) Q' G( l+ ]3 m2 G" ?6 u- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 `* a$ q( P& L' S8 S, k* l
- #define STATIC_SHIFT 3
2 }0 g c/ z3 }; b, C; C; {7 i - #define TCINTEN_SHIFT 20
( ] n( |( y+ S. y2 c6 t3 O - #define ITCINTEN_SHIFT 21
`: g! b( q1 G* B3 c - #define TCCHEN_SHIFT 229 a" o9 u+ V- S/ S
- #define ITCCHEN_SHIFT 23+ O$ a- X# W+ p8 p$ z" K' z' B
# `, w. E, J* c/ B- static volatile int irqraised1 = 0;1 l% c: I& t* U( J1 H, g: P
- static volatile int irqraised2 = 0;( ]* u1 j i# l. k/ C1 D
! q$ w1 p7 P. s6 l7 k7 }( f" v& L- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 l8 K- d' Y9 m - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, j& T( f; [1 N+ z* N5 }; z - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ {- j9 M+ S2 {1 R8 M
- + [* }- a4 d5 ]9 n
- dma_addr_t dmaphyssrc1 = 0;
0 r& i( \ m$ R% I/ y - dma_addr_t dmaphyssrc2 = 0;) P0 L0 ]; p7 B8 s2 O0 h4 S( W
- dma_addr_t dmaphysdest1 = 0;' J( \" \ Q# F( N/ E
- dma_addr_t dmaphysdest2 = 0;
# G/ g# i+ H- L
, g1 E4 |8 I4 h/ M: d5 s4 Q/ `- char *dmabufsrc1 = NULL;
. b; Q/ R, P' o8 L - char *dmabufsrc2 = NULL;
9 W- C, x8 A1 ~/ X% O" E, @ - char *dmabufdest1 = NULL;3 S+ L% m2 w2 {
- char *dmabufdest2 = NULL;" r! m. E. x1 U: o" l
8 A0 l1 l0 D% J8 g- static int acnt = 512;- y/ C6 x$ K! W9 r+ L( F9 o
- static int bcnt = 8;+ x: X, `/ A7 M F9 @1 ^: P' c
- static int ccnt = 8;( \* F8 Z' V- j* u* r6 J
Z" @) K) O z- module_param(acnt, int, S_IRUGO);
! j* C/ t9 v! x9 ]" W1 R - module_param(bcnt, int, S_IRUGO);) Z( i3 S* F7 x* w
- module_param(ccnt, int, S_IRUGO);
复制代码
, X$ ?# j# U% p9 X! l A, B: \
9 f2 F, F, S3 p" {; T8 | 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用3 i( }6 n o8 T% T( N
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
2 _+ b5 ^$ }9 g; \+ g 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。/ v. x5 h1 _, J9 D0 A3 D: j3 @# F
2 b' |4 o: ~ M0 f; `
' b0 F$ b3 \0 ^8 i |
|