|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% l6 f: ]8 P! a' C3 B! M8 s- [code]EDMA sample test application
& H6 z" z; x) O4 r1 D - /*
) v5 n$ T( X. t; V/ k - * edma_test.c
5 W6 R6 W" ]1 \1 Z - *6 O; v+ f: h) U5 P" _9 F
- * brief EDMA3 Test Application* a+ _* p- [" i
- *' E2 }# ]0 _6 ?$ V* _
- * This file contains EDMA3 Test code.- P! d s, ]( K3 W# a- U
- *
) a2 H% U' e" t - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& }) _5 l3 I' k- E7 s% ]1 K, F
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT8 S$ m; r7 W6 i( a) O1 x" h
- * TO CHANGE.
5 \4 R7 z" z/ J& U0 S4 j, \2 r# ? - *
; c5 Z+ u! t/ m' G' Q4 p9 m% ~ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
8 Z5 T0 w. C0 z: Q v - *
* _; r2 J2 R/ M4 q# B - * This program is free software; you can redistribute it and/or" k' a8 T7 ^ L" z: o* l# p, J# _' D
- * modify it under the terms of the GNU General Public License as
; l. M6 R4 h& U, u6 n4 B - * published by the Free Software Foundation version 2.# \" G( H" [% r; w# a
- *, { L7 w- D( L7 x) n3 D) O
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 [8 A; U `% y# b# ^" r+ V' ~0 | - * kind, whether express or implied; without even the implied warranty& P C3 J1 `' s8 d
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" D& I+ D6 W$ o" d3 A2 ] - * GNU General Public License for more details.
( K2 @/ E( R8 b' m! Q - */! u7 t& i+ S1 z; z* s% d9 f: e, a, @
- 4 K7 u$ `, }2 W. M3 O
- #include <linux/module.h>5 y: H2 K" b4 e: c. ` o s9 N9 ]" k, f: j
- #include <linux/init.h> C% p& K2 c, _; w2 k4 |2 O
- #include <linux/errno.h># {4 a5 f! ~4 g3 H- w
- #include <linux/types.h>% H; q! F7 G8 V) t8 z
- #include <linux/interrupt.h>
. W* T( N5 ]: G9 ? - #include <asm/io.h>
& [9 T Q' S0 b) O7 |( y$ {9 p - #include <linux/moduleparam.h>- @6 h3 N$ J/ w9 w; ^7 t: L( O7 p& D3 ^
- #include <linux/sysctl.h>5 C$ n+ x7 u/ L3 |8 W# [5 [( S$ C
- #include <linux/mm.h>
: W( F- k: D0 e9 S$ d* ]; f - #include <linux/dma-mapping.h>! l- i2 f3 L) Z& X0 E
- 0 Z6 h O% N: h2 ?9 \# Z
- #include <mach/memory.h>
" q- n8 K7 a2 N2 g: m! t7 D - #include <mach/hardware.h>
7 ?( z& F3 y/ { h - #include <mach/irqs.h>
; E0 t. F2 n- x/ G1 H - #include <asm/hardware/edma.h>; F1 ^4 R' d" m$ v+ H+ _
- 7 D" `# `+ ?3 z( n
- #undef EDMA3_DEBUG. Y3 ~7 S2 z- h& R4 s
- /*#define EDMA3_DEBUG*/
: m' N' @! h0 R( H$ |) l" t - ( p4 o" \: l: i! C A: t
- #ifdef EDMA3_DEBUG
2 ~0 ?& b/ D! K3 d2 w+ s - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& S, y s: z5 H - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# `7 K& _. |' x/ {. G1 O - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! {4 R. T6 c& x* d4 {; v, _
- #else% z, f1 g" {" f: F: S: @ M7 K) @
- #define DMA_PRINTK( x... )
+ ?9 i; N/ w" P% Y/ }' R* M - #define DMA_FN_IN
# k2 F; t$ z, o - #define DMA_FN_OUT
, P, f3 ^/ `7 ~3 W0 v. a - #endif3 C% A. g5 k) Q2 U6 T' i. |
# j* m4 u$ @2 y6 f/ g, X; L& h- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 U7 ~$ a! K1 t! B0 G
- #define STATIC_SHIFT 3
' X. p- {' O: ?; \ - #define TCINTEN_SHIFT 20
1 H) V8 H E" b4 A$ A# D. p6 E - #define ITCINTEN_SHIFT 215 p# h. z' k4 G5 G4 K6 C) r5 f9 H
- #define TCCHEN_SHIFT 22
( ^1 W4 j8 N+ O - #define ITCCHEN_SHIFT 23: Z3 T+ y9 Q# K7 j. ]6 h9 t
- Y, O/ c: o: _! j- static volatile int irqraised1 = 0;/ W# u% Y) s& x% j$ D9 Z
- static volatile int irqraised2 = 0;
6 ]. ^/ _: U1 }3 r- |9 O
: W+ Q1 v' x6 b+ m3 I! H- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. n. P; m( E; d2 k% |
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
2 c/ A5 U0 Q% C* \# u; } - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. v$ M1 V5 [ l& ~+ ~7 H
: z' @( ^, n2 ]6 c8 O5 A" z% J+ g- dma_addr_t dmaphyssrc1 = 0;# A+ C3 e, O: I
- dma_addr_t dmaphyssrc2 = 0;
7 b/ p! }2 u) f$ L2 n. K% e a - dma_addr_t dmaphysdest1 = 0;
8 S M4 _ H9 G! F8 ^( ] - dma_addr_t dmaphysdest2 = 0;
7 r3 ?; R( I; s( E# \" e
* V1 X5 L( f7 M3 ?1 J! ^. o: c/ P4 y- char *dmabufsrc1 = NULL;6 y+ D, d0 L# p0 X! v( p& J8 k
- char *dmabufsrc2 = NULL;6 v& e: T, q6 T+ F
- char *dmabufdest1 = NULL;
) G& B1 z1 U" s# v. V, D - char *dmabufdest2 = NULL;
7 d: e# m4 \8 }* n( X - 1 K" w( ?# ^5 E: Y- e- g
- static int acnt = 512;
7 _+ |; W* B' M2 F7 R - static int bcnt = 8;
q: w3 Y) s1 |; q - static int ccnt = 8;' f1 {) J( h$ _$ U; N* |
- ]9 K5 W a$ I. g
- module_param(acnt, int, S_IRUGO);
/ m+ j" D) ]9 ` - module_param(bcnt, int, S_IRUGO);& V( z% D2 |$ O1 r! U- N
- module_param(ccnt, int, S_IRUGO);
复制代码
- U6 s$ I: F- |. F9 m' c3 U$ P: k4 |3 F5 n
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" W, Y4 ` w& j& O, \3 T+ d
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。, D; b) a' P1 T. ~
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。3 g9 B2 H3 t& v1 w! E
% t- H, f" Q) ?& c5 {5 g h
0 `, |! z/ x; Q& A' i# w |
|