|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
- e& w1 o3 z' y3 P- [code]EDMA sample test application
^7 ?2 _: E1 d7 k% ~ - /*' j; a# X' T! f) D- w; M
- * edma_test.c
% m( K/ ?8 q% | - *$ K y/ @5 ^, ] Y
- * brief EDMA3 Test Application& D) H* Z% | W( y
- *
6 S3 [. v! }6 [4 h - * This file contains EDMA3 Test code.7 f9 N7 `# K( [; c y
- *
7 [3 o& s6 y, p - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
" [, ~9 D2 p- ^& F8 e - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# j( @- w2 H# ` t' _3 _1 e" `
- * TO CHANGE./ L; @! `& x6 T0 ?5 Z* a' f
- *! E2 D' G" j. b
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
3 s" u- L5 `4 g$ w - *
( _& y6 h3 K& c* Z - * This program is free software; you can redistribute it and/or5 ~$ c- u$ e" v5 _/ W0 t
- * modify it under the terms of the GNU General Public License as
$ {5 o5 O/ i& H1 J$ u+ k( F9 C% S4 v - * published by the Free Software Foundation version 2.
& A5 C; V' W; e! F3 t - *6 G# T2 Q6 T& K: `9 d
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any: `, B" D ?7 l) y& S
- * kind, whether express or implied; without even the implied warranty5 P! E9 k' M1 l. t5 j# D( P
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the3 ?$ o7 V5 j0 h( [5 M5 a
- * GNU General Public License for more details.
" V0 u3 E* o$ H' G$ U - */
5 T7 q2 h8 u3 o4 T - % s( |$ j& N5 ]; c* P
- #include <linux/module.h>7 ~# H) _0 h& Y! e Y5 Q% d' z( G7 D
- #include <linux/init.h>
5 c3 K$ t* N. G0 z6 ^. a - #include <linux/errno.h>
' A/ Y6 b) h: T6 X9 p* V% h - #include <linux/types.h>
0 T2 ~3 i# b$ g( L+ z& E - #include <linux/interrupt.h>
2 u; n! [* m8 p- q - #include <asm/io.h>6 q- Q1 h' p1 `; P% G
- #include <linux/moduleparam.h>
1 v6 z) e# w; h$ Q: i - #include <linux/sysctl.h>: v ^6 k; O. ?( ~
- #include <linux/mm.h>
: T' [4 y. p, I( v9 y1 F' M - #include <linux/dma-mapping.h>$ v: Q, r8 Y* o1 h
( Z/ R+ w( K: z- Q) Q; }* l- #include <mach/memory.h>
) x' |3 q5 m! [ - #include <mach/hardware.h>. z. E, I8 C. q8 ^' S
- #include <mach/irqs.h>) \# l7 e7 c9 \* f0 _5 ?( m
- #include <asm/hardware/edma.h>) o% v8 d8 {& S: d0 h- A) K; e1 R
- u/ g% G0 p& d5 u5 T- #undef EDMA3_DEBUG1 g- L5 e2 v g# s
- /*#define EDMA3_DEBUG*/
. k& G3 U6 t$ x6 P' k G0 U - 8 `. V9 [" E$ T) m: l& o
- #ifdef EDMA3_DEBUG
) i( B/ S6 w8 X - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; r; A6 r2 n- U4 W6 M4 [/ @6 U" e, O0 @ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 O A* r- B; [; H d& c/ W* m
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)7 i! C, y$ @$ d1 F
- #else2 h0 G' b$ m& _9 h* Y
- #define DMA_PRINTK( x... )
# M3 t3 y# A2 D1 Q: U - #define DMA_FN_IN
7 Z" `* G7 D2 p* p3 u: v - #define DMA_FN_OUT
6 S! h" E: y6 a- i. d: N7 i. Y - #endif
7 b2 S! }% [! a! G1 ?0 P i5 T/ B, x
' w/ U2 U! `5 E" A( d- Z @! N- #define MAX_DMA_TRANSFER_IN_BYTES (32768)5 x8 }% T- y/ Q$ L
- #define STATIC_SHIFT 3
/ V% z; \; {) C+ b6 E - #define TCINTEN_SHIFT 20) R. Q' O5 c. Y9 e' r( d3 k
- #define ITCINTEN_SHIFT 21
! E# r3 f5 I$ C- l: `& N - #define TCCHEN_SHIFT 22
' g1 |2 w. f0 {" S' r7 [! O7 [ - #define ITCCHEN_SHIFT 23. K- J/ ]1 y1 |; A% t5 h0 G
) ]: l7 K5 Z7 e; b% x" E) p- static volatile int irqraised1 = 0;
+ L4 M% a+ n$ n3 e5 C - static volatile int irqraised2 = 0;$ v% s3 E- I3 q! F* Y) k
- 7 Y8 I& K$ e& L7 Y8 v! E9 x
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! }- E0 A8 M0 Z( [0 k - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! w! t( f8 K' ]! q& U. l
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 P: F n$ Q$ ~, I9 y
5 d, i# h3 L+ O3 d L6 s& a+ P# @- dma_addr_t dmaphyssrc1 = 0;
+ u9 J* F, t7 y7 t3 R* v - dma_addr_t dmaphyssrc2 = 0;& X" N$ I7 t, S4 i! n$ K$ j
- dma_addr_t dmaphysdest1 = 0;. b! B: g l; b$ G/ G2 l: h
- dma_addr_t dmaphysdest2 = 0;/ w1 E% s& C( s
3 G: c( J# Y+ G4 X- V! ?- char *dmabufsrc1 = NULL;
3 R2 a5 V" d0 Z5 Y - char *dmabufsrc2 = NULL;$ v/ o% y' O0 Z3 ~
- char *dmabufdest1 = NULL;
+ _& Y& E' I5 I2 z, b - char *dmabufdest2 = NULL;
) N+ _. s& u0 X! g/ x; }& _5 z0 N
# u; I+ _% h" f- static int acnt = 512;
, n! X) v9 T/ v7 L4 w" r% w - static int bcnt = 8;. P$ p, g! m. E+ T9 F
- static int ccnt = 8;/ |0 X6 U7 Y/ e4 F
) S4 q5 I/ s. Y: Q6 F- module_param(acnt, int, S_IRUGO);
+ o5 N/ j, ^4 a8 |0 {9 l - module_param(bcnt, int, S_IRUGO);8 ?& J& J ?5 K' L$ y
- module_param(ccnt, int, S_IRUGO);
复制代码 : I% K( E, Q. J3 }/ @9 }: }3 ~
; p4 j* i: q+ Z$ k1 _
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用. j U' u8 p$ y2 v9 [
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。5 K$ }! F7 X5 E3 M+ M/ C4 u5 d* x
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。- _% b: T$ }) u$ \
. {; p" K. C2 u
( {' T& D7 b+ P' V% [ |
|