|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 / _4 I8 D/ q4 x
- [code]EDMA sample test application
3 A* ]) X5 g" I, H$ y5 V2 Z - /*' n! P! h, q7 N3 T
- * edma_test.c c- M( u4 h! R& f
- *
& G# v4 @ [6 c9 j- ?3 s9 X$ ?! z - * brief EDMA3 Test Application
W" {5 d7 s5 Q8 m$ E - *3 A0 b { r- a4 ^
- * This file contains EDMA3 Test code.
6 D' k; w T8 k4 Y1 z - *( e" Z$ B. L7 T6 h: O+ M) L( J9 I: \
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE l$ o* X( C( v7 g
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 T+ K& D. v# e8 U! q& l! g% v/ G - * TO CHANGE.8 m4 g3 V: n. r2 J2 C) k$ Y0 v
- *) O m" d0 n; ]" m" ]( \
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 I5 D) G3 [3 M3 f- K3 B+ S! f - *2 w$ q ]. \2 v U* \
- * This program is free software; you can redistribute it and/or
, d: {7 z- v) U' b" { - * modify it under the terms of the GNU General Public License as
# ]# o6 @: [$ ~! H( \) h - * published by the Free Software Foundation version 2.1 V1 H) F. K( D, M8 O: P- h
- *
w9 ^! h! f6 y$ i - * This program is distributed "as is" WITHOUT ANY WARRANTY of any) h4 f; g0 s$ J4 S& w
- * kind, whether express or implied; without even the implied warranty! u- Y3 X3 M) l- W6 f& q
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- D. u# M. i% u0 U- f' s; a! p" X9 { - * GNU General Public License for more details./ [+ g/ d% c1 R2 g* h2 b! E
- */
( R# U& f% j$ G' e V - ( E! D! s: b6 k0 z* p
- #include <linux/module.h>! T& Y- D% `" a% s. k! g$ L7 w% O
- #include <linux/init.h>- m8 s0 ?% b2 {7 j( E
- #include <linux/errno.h>
( T% u" {+ b4 L$ ~) i! H" L2 ? - #include <linux/types.h> J3 @' r- ^) |; t/ `, i0 C4 q
- #include <linux/interrupt.h>
1 y2 u7 o/ Z% F! B; D+ p - #include <asm/io.h>
" l9 m0 _3 X: y7 G5 m) P - #include <linux/moduleparam.h>0 n- r% @8 T! q( u5 j
- #include <linux/sysctl.h>
l( W9 Q& F! I) r1 Y' T9 M& @) D - #include <linux/mm.h>
& e5 {( W$ B* u) t9 C- S' { - #include <linux/dma-mapping.h>+ Q+ B( c8 H* h! \) }
- ! M! k! J7 {. w. S7 X3 A
- #include <mach/memory.h>% H7 b/ P8 h/ ?$ S m! Y
- #include <mach/hardware.h>
4 G3 w; U T6 H8 q" e* } - #include <mach/irqs.h>, u* U6 j$ L) d. B d1 F
- #include <asm/hardware/edma.h>
# B/ {( w; }& o
3 _3 N& S' x+ J0 V* p: Z- #undef EDMA3_DEBUG; u( Y: K0 P+ B* G) x
- /*#define EDMA3_DEBUG*/' e0 K$ M6 Y0 |: [3 @
- % H; [. u1 t3 P Q1 J
- #ifdef EDMA3_DEBUG0 c/ t" D- K$ E# A- ]
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): P1 R! Q4 z) `/ ^* Y( p; s4 U
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)# x( i% n/ J# p( K T
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
3 b' A: B3 ^5 y8 F$ B/ W; F$ E - #else
! B) d, O( v0 S6 {6 W( a4 { - #define DMA_PRINTK( x... )
3 n0 ~! ^8 E v/ ] - #define DMA_FN_IN0 \( t/ X! R& f2 d& X
- #define DMA_FN_OUT
4 G' u# p" {+ q" A% {6 y+ v$ t# h - #endif0 N* S6 U' d% P, n
% t. X5 Y% t+ _# y7 p- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
8 }% h6 ^* t& r4 q5 c - #define STATIC_SHIFT 3
5 w& `( Y' j3 z" s: [/ X - #define TCINTEN_SHIFT 200 Y. ~ k( k8 {: w$ m; N: e; ]
- #define ITCINTEN_SHIFT 219 S9 z% s. Q6 W( [
- #define TCCHEN_SHIFT 22% |3 q) v9 N' B& [, @- O
- #define ITCCHEN_SHIFT 23
9 ~4 D' E' r4 h9 l
3 U9 D8 u$ h: `3 n- static volatile int irqraised1 = 0;# m4 v8 Y1 Q. E
- static volatile int irqraised2 = 0;
$ U$ q- E9 b' U3 W" @3 H - 9 v6 u# z% N3 M- i f" h+ n0 A
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
M( }5 x9 _/ Y* o# Q' p& r- Z) w) R - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
g; S) ]) Y/ a) q, p - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ e( t6 B \4 t: l7 R - * X+ o* D- W3 C c
- dma_addr_t dmaphyssrc1 = 0;
) g+ P$ ~ p$ G% d* n+ r1 o - dma_addr_t dmaphyssrc2 = 0;* s. j3 V8 Z- ^* h7 s
- dma_addr_t dmaphysdest1 = 0;
% F, {5 v1 C" G9 ~2 F3 p+ \ - dma_addr_t dmaphysdest2 = 0;
' a9 Y8 S4 T2 s( G/ F) h A0 a
2 o; R5 ^5 J* }3 F/ X5 A& P' A- char *dmabufsrc1 = NULL;
+ o7 I" m! z S* D2 E) m1 A$ U4 B - char *dmabufsrc2 = NULL; ^# ^( z& W0 Q8 |5 A% _
- char *dmabufdest1 = NULL;
# d d- m1 k7 a( a( b5 r5 U - char *dmabufdest2 = NULL;, @2 X4 n% c' X. N8 x4 ^4 F
- # ^9 H4 c* x& Y- N' f# d9 ?, V
- static int acnt = 512;
* _4 ?* j; G/ N( `4 n' G - static int bcnt = 8;
0 x' s1 C( F, i+ Z" Y- e& q- K: c l - static int ccnt = 8;
1 R9 j% b# T5 F# X6 | - ! J6 b% H7 f8 } c* U: g
- module_param(acnt, int, S_IRUGO);& Q! O+ B K& f, @
- module_param(bcnt, int, S_IRUGO);) @* h G- T+ `: ?( U
- module_param(ccnt, int, S_IRUGO);
复制代码
& v! ?! @' K% R4 z3 P! y6 F# Q( R n9 a& K \2 I% `
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用$ e) c% O/ M% I8 Y0 W: G$ f9 Z
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
( L# C* e: ?, _ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。' p2 q6 {) i( E0 [, k
1 B% H* ], z- ~) M5 J% B3 f( j; Z
* B0 }* W! A3 k. {7 C0 ]! E |
|