|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
! t% j, |- w1 N" E5 m- [code]EDMA sample test application
. p2 ~0 X; s* _: c* E; s+ R - /*
8 H$ ~; W$ k' U) P& \- i0 y. r - * edma_test.c
- a$ U$ b w2 a4 b - *
( G3 S: V+ a: T - * brief EDMA3 Test Application
; y+ L& Q3 @8 k( U/ n: s' G6 P! W - *; u0 \6 g3 j2 C. p8 w
- * This file contains EDMA3 Test code.+ [) g! X4 ?2 S4 g0 G
- *
0 I7 L I+ U: q0 [; y - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
6 ] ?" X* Y/ W2 J - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
* \" `. \; v6 q - * TO CHANGE.
/ x2 ?, O0 Y' T; p% }* ~ - *
8 \/ X7 I$ m; x4 Q0 U. M- B - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' M) ^" x$ e2 g7 v' F7 ^4 O9 I0 T0 Y - *
* x: k: k4 ^2 ^3 D7 L$ e( A# M3 S - * This program is free software; you can redistribute it and/or
+ N, C" s6 f# _$ X3 v4 L - * modify it under the terms of the GNU General Public License as
) j. c; z& h# H4 p5 O/ j; L! z - * published by the Free Software Foundation version 2.% D& n8 m2 s' a% ^9 d& B/ v" a* W6 ~
- *
% m! V9 L; g: Z& y# j+ S - * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 m5 T! D B% Z9 Q+ [* b8 T0 u
- * kind, whether express or implied; without even the implied warranty
2 e# `7 q, |. A7 { - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7 ?$ {* e) E+ e+ B; c" A - * GNU General Public License for more details.* B$ Y4 D, q( k( Z! d% t# a' ?) t4 }
- */
" W/ H( C R3 u - ) P0 ?2 V; k8 W( ?9 }% c. s
- #include <linux/module.h>, `" D" t6 ~. v8 L; e% y% u7 G
- #include <linux/init.h>; Z4 O0 m7 W+ f; r
- #include <linux/errno.h>! G1 f* u% _ v: ~9 y
- #include <linux/types.h>6 w+ e% N( c0 n
- #include <linux/interrupt.h>: X" _9 g' v; P1 k- Z9 I1 q
- #include <asm/io.h>
u% x0 F- p0 h - #include <linux/moduleparam.h>! j& N0 S1 q" q* B8 U' I' D4 n2 X- v
- #include <linux/sysctl.h>
2 ~. r5 {2 ~4 r( K* l6 k - #include <linux/mm.h>: A% m% e0 I; G+ u$ _5 a+ E5 \
- #include <linux/dma-mapping.h>' M1 H: I' a6 S) A3 c, G7 i( n
; {- W- o% D: r. v- #include <mach/memory.h>
& i* u0 g7 _2 r - #include <mach/hardware.h>
) S' l/ X8 Q; I. l - #include <mach/irqs.h>' n$ O# A' ~4 \8 L& m- z+ r7 ` p- y
- #include <asm/hardware/edma.h>
9 L/ P: U, Z3 b7 x8 _- j% L
3 r0 }! |: }' ~, g* J- [- #undef EDMA3_DEBUG
4 T: `( P) L: F# l- n) Q& u - /*#define EDMA3_DEBUG*/
7 h$ }7 F0 |. z: \ - $ \2 V# k$ o9 p3 z
- #ifdef EDMA3_DEBUG# e9 ]1 K: }; S, @* A; ~; B
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS), V* C+ Z' v8 O4 t
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 j+ D: _, q2 P
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! C! ~% _+ m* D
- #else
2 X% T* e! k* x. c, |& m. A1 g" X - #define DMA_PRINTK( x... )
2 R6 F! t$ a* E: n3 f - #define DMA_FN_IN9 Y& @$ @: w4 W3 r0 q
- #define DMA_FN_OUT, [' } a: H# \$ E- \
- #endif* U% R% c: a# x% C& ?/ J
- 5 K1 `- z' c3 B" Q6 T' ?4 J7 o8 O1 f
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
5 J5 V( F: n) g y8 d; O& v s( h - #define STATIC_SHIFT 35 ~9 }1 f: h* R4 U* p) K; |( w& G
- #define TCINTEN_SHIFT 20& [& z7 c; f; [! [ f9 |8 k
- #define ITCINTEN_SHIFT 21
, R) W3 N( G1 t( H4 @. v/ ` - #define TCCHEN_SHIFT 223 K3 ^. W2 ]. g; ^" U; v6 L
- #define ITCCHEN_SHIFT 23- s8 j7 ?- ?# q$ s
- & P) A) p4 Z E
- static volatile int irqraised1 = 0;6 U0 P0 T8 z% `$ O
- static volatile int irqraised2 = 0;
# e( I6 j/ Q$ q/ l! M' A6 X
. w( ^' @9 O# |; b E: J- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; J: j# d; L" y( F' N- S - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' r6 v- g$ a* ~/ ?
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 B: V9 R; s2 e
2 C; L) _+ Q3 |/ n- k3 S7 w# k- dma_addr_t dmaphyssrc1 = 0;
2 N2 f% Q5 E9 e( C) [. P - dma_addr_t dmaphyssrc2 = 0;
; J u6 l6 k( w$ E/ s4 d t6 g - dma_addr_t dmaphysdest1 = 0;5 {" c d( b+ d# H
- dma_addr_t dmaphysdest2 = 0; M1 B9 }4 T8 L; _( c& r, l4 j
% v/ B) O' g. ?# h1 k9 l- char *dmabufsrc1 = NULL;' ~1 ^# T& |( I+ h4 D
- char *dmabufsrc2 = NULL;- ~; {8 `) W# m* {) y* Z: R
- char *dmabufdest1 = NULL;
% Q. O" ?- M7 F - char *dmabufdest2 = NULL;
/ x. h6 C" I3 G: R# |" [) U
$ p/ G0 j6 D/ I" ?, Y4 T- static int acnt = 512;) U) r! Y' Q' [
- static int bcnt = 8;
' z+ k6 R) d& g/ o - static int ccnt = 8;
( j* A& r7 ^+ J" e! X5 g0 X5 f- z6 U7 o/ x
% t" L' X6 Q& N) }% \5 ^- module_param(acnt, int, S_IRUGO);
8 _" \* G2 ]% z - module_param(bcnt, int, S_IRUGO);4 v7 x' k. w! g1 U/ Q3 V! y# ?
- module_param(ccnt, int, S_IRUGO);
复制代码
" U- o' T$ I( }5 s; d6 _
1 T! j' O' T" Y1 q) J 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
7 @. [3 Q! c4 C' Q7 ^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+ `2 c* n2 ]8 I8 X) l 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
7 v. F; D+ U0 Y, t: E$ `; O
% {& r; a0 u" H. r j$ Q. Q. o3 O0 g; t; m: J7 z& b9 X
|
|