|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 ^: {) |: g! h5 q
- [code]EDMA sample test application
( X& a6 g# ?0 o$ N ?; I* G3 t- R - /*
5 O. i8 \/ U+ w4 I0 Z! p3 I - * edma_test.c
1 ^/ V; G: c$ H- \& F2 ]" Y( J5 I0 y - *; g4 H; j% m) ]" |# C* e& R
- * brief EDMA3 Test Application
9 N6 d& h/ O) E5 I3 I" D. b' b - *0 A9 Z) s& w9 \+ y8 z: n
- * This file contains EDMA3 Test code.* K# S5 k4 X5 n! L
- *
5 r) u" U3 s0 r6 v H - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 H. h. i+ `. V9 q' D: d1 f
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT4 @ [6 t5 ]5 k) l( N4 c
- * TO CHANGE.
0 Z! l& p/ Q6 _ Y* R+ r3 D1 }. b3 A - *
' T: q* i# a! I/ ^6 G; [; w* m - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ a( O" L! ?& E. I# ^
- *
) }3 m8 E5 O! v# v5 Y - * This program is free software; you can redistribute it and/or& U! ~0 J3 [9 c0 ]; W
- * modify it under the terms of the GNU General Public License as
3 w4 _, k" ?- x' P% i) e - * published by the Free Software Foundation version 2.
) s- _" R8 R5 F1 ^0 Z - *
$ a" l( W3 ~: i7 G9 {8 K3 D - * This program is distributed "as is" WITHOUT ANY WARRANTY of any1 n2 p5 f- T! f/ t7 ]3 o
- * kind, whether express or implied; without even the implied warranty
2 }; r( @( l. {( A( h6 {* E% _ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. F* f& S# }8 C) k - * GNU General Public License for more details.
' Z0 K# f$ O* L$ p: U' U - */, x @% M7 N$ b
- ; g4 o, ^" F6 V, m* x& ]
- #include <linux/module.h>( g9 H4 H5 C. d S" o8 F
- #include <linux/init.h>/ ^( S( J) q- W+ j
- #include <linux/errno.h>: N. R; C2 ?' Q7 @% L0 D
- #include <linux/types.h>: }2 n) x" [9 \- L j4 x h
- #include <linux/interrupt.h>
" U7 ^& r% p6 `9 o$ {9 Y+ a, k" W2 A! u - #include <asm/io.h>; T+ B4 f( H1 @! A% l5 Z
- #include <linux/moduleparam.h>
5 }6 U1 E$ ~8 v5 c; c" w( A; A - #include <linux/sysctl.h>3 V9 b) Q) i- \; m: k
- #include <linux/mm.h>
& V) b& X9 g: `7 _; y0 Z8 o - #include <linux/dma-mapping.h>
' {% N* Y' Y9 E Z, }& m& O - ' r- k$ f! u3 j! X t) U" B T
- #include <mach/memory.h>$ L8 K; a- z* t x2 {) Z
- #include <mach/hardware.h>
" R% l5 t2 e* T& [: M- z6 B2 o - #include <mach/irqs.h>3 ~8 Z: b/ `4 V
- #include <asm/hardware/edma.h>; L& W1 `- B) Q [" d0 H; d/ }5 W
# C# K+ [5 j6 r# X) x( n- #undef EDMA3_DEBUG* ]: A8 E$ @* m! s7 ~. y9 m
- /*#define EDMA3_DEBUG*/
2 E, {$ O1 B5 E/ R) H' h8 ~1 b2 q - 2 Q2 l. @* [1 ?
- #ifdef EDMA3_DEBUG) Z) M6 Z' r+ I) A2 ]. T6 q3 x3 p
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; [8 p) r: Z, S ^" Q3 v. t; W - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
! `4 I) P) ]( R0 w; z3 G - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
9 P- W( l6 T+ e9 n+ I( n, m! l! w - #else0 y7 H7 R/ L% M8 h8 U
- #define DMA_PRINTK( x... ); y" @# ~3 `: T8 f' o
- #define DMA_FN_IN
/ e" D. d8 |3 w9 \9 W" n% d& X6 { - #define DMA_FN_OUT
0 h" F' T' [' C% S7 j3 m - #endif" ^# b: P5 b& `: r. r
: @' X ~. v, m* Q- O* P+ K( Z. u# h- #define MAX_DMA_TRANSFER_IN_BYTES (32768)7 i, k5 G( y3 b; ~1 R
- #define STATIC_SHIFT 34 T& k, F' f/ D6 H& q
- #define TCINTEN_SHIFT 20
' F& p. x& U3 ^4 C" G* z" i - #define ITCINTEN_SHIFT 21
/ F# J5 y! l$ D3 { - #define TCCHEN_SHIFT 220 D) s3 a8 f c/ d1 X% A) d/ n: F& x
- #define ITCCHEN_SHIFT 23
. H! N3 Z) U$ P( p3 k! D - ( P" q+ L" h. N h. i- C
- static volatile int irqraised1 = 0;
5 @3 u2 u. F1 c; b+ U: `- l - static volatile int irqraised2 = 0;
T1 x9 \) P8 O6 I2 z! |! K - ( q, A/ V* `1 v; h, b5 y3 Y" P5 W1 g
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 d1 Y" U4 v9 k6 e
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ g- S8 b3 u2 Z4 l: U5 e
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- G* F+ K+ y" `# R/ B, ~7 _
1 b5 A7 n j7 i$ K% Q( e$ O0 h- dma_addr_t dmaphyssrc1 = 0; t! Z3 R+ y4 S) A- s/ s& S/ v
- dma_addr_t dmaphyssrc2 = 0;
- E& ^- U: w: z" V7 r - dma_addr_t dmaphysdest1 = 0;
7 a/ k- {& U) A/ a+ r/ x4 P! T - dma_addr_t dmaphysdest2 = 0;
1 O1 l2 ?: o3 T y9 s* J( H
@8 c* U8 H% ~# C* |0 ~- char *dmabufsrc1 = NULL;: X5 X: N, G* Y; g% N
- char *dmabufsrc2 = NULL;
7 m; f$ c: @0 W5 {9 w6 `# M - char *dmabufdest1 = NULL;
) i+ o8 o9 z5 G9 ` - char *dmabufdest2 = NULL;# E" S, V' v5 [3 B
; k1 K' ~* g5 q4 Q9 F- static int acnt = 512; ^% }) K3 }7 W) ]( w6 W& ~
- static int bcnt = 8;/ O) z7 ~- g* B2 a" K: Z
- static int ccnt = 8;
% w' D/ T4 ?+ B$ e( @" P - 1 q4 Z- ?8 v |1 C
- module_param(acnt, int, S_IRUGO);, y S+ M: G$ X1 m6 `* Y+ h5 j
- module_param(bcnt, int, S_IRUGO);
. F, C; e# S% T' K F2 o3 ? - module_param(ccnt, int, S_IRUGO);
复制代码 . t8 S% I6 X; e2 N9 `
2 `$ H& o! x' n: _1 ~% N 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用: Q# Q% b9 [- L8 A& v/ \
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: X5 W2 ?! U g" F3 d, d7 P
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。9 b y r) L0 Q% G' F2 \. [
) |% Q8 Z; p/ `' h$ B9 l+ ~/ i, r+ R/ E9 {% u" [7 H
|
|