|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 7 r. l6 }, c+ f. v. i
- [code]EDMA sample test application
D% K* K8 c! j7 ? - /*: ?/ ~$ r* {; i9 x) A# }5 ~+ E
- * edma_test.c
2 G& { i d1 I! I - *: ~$ I' S, b: `3 q( P1 Z/ k
- * brief EDMA3 Test Application
( V+ R, a' I6 L - *1 o4 T+ ~" P2 v! `' d" K
- * This file contains EDMA3 Test code.
0 [ D7 y& G8 ~) \; F% [4 D - *
& L: ~- N% L4 R8 ` - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
: y2 L' n+ v$ L/ \2 B! D - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 F i* D% z2 V/ J, q X' Q
- * TO CHANGE." v; f: u0 }+ Z' F8 E
- *1 Z( S5 ~0 R2 o* r
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! e3 P( m+ H% C
- *
) U4 k/ f8 Y- G! | - * This program is free software; you can redistribute it and/or
5 D+ i N5 i/ o5 o - * modify it under the terms of the GNU General Public License as* A* Z4 Z' R' c& D. |4 @3 ~
- * published by the Free Software Foundation version 2.
* u' G% ]5 v* _' q5 }) ]5 q9 v" o - *
' g' ^0 X5 ]! a' \; `' u - * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 P( x2 T9 s/ l3 b& N
- * kind, whether express or implied; without even the implied warranty) Y) n9 h, S' s, f
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% u8 P! w9 l: x9 x: E/ D - * GNU General Public License for more details.
: l, _+ o0 N' w: m7 O+ k - */
9 c3 J) @9 e- M* M& J - 9 p0 T, {7 G; l( h9 m! A
- #include <linux/module.h>" Q8 r* e n+ z7 m
- #include <linux/init.h>, e8 k# e$ l. C% j1 J. p) o% v
- #include <linux/errno.h>! M9 n4 l& n! ^' Z
- #include <linux/types.h>% t' T/ b! u- T+ h3 _4 ~' `
- #include <linux/interrupt.h>
# k$ b, Q' c2 V - #include <asm/io.h>( A. c: k5 Y G: C' v
- #include <linux/moduleparam.h>
- j7 Z0 X6 ~0 ?- A( [ - #include <linux/sysctl.h>
. t( ` T3 r7 K% P0 X6 V - #include <linux/mm.h>
/ @; ]- L3 ]8 w" ]" {( H' I7 U2 K( T - #include <linux/dma-mapping.h>
" m* j- g% p3 J) s
' I: e2 \% N; k3 h3 o- #include <mach/memory.h>
' H- t/ e' s9 x - #include <mach/hardware.h>* |0 P) f' D. ?: c
- #include <mach/irqs.h>2 B" q" [( p' S7 x( P- l1 E9 q
- #include <asm/hardware/edma.h>. A5 O! O, w. ]2 T! N
- e+ o# i, x* ]5 [- #undef EDMA3_DEBUG7 y9 @4 M! v, W' c; A% y
- /*#define EDMA3_DEBUG*/7 d$ V$ h0 c, P0 b4 `, u: \
" F2 b) `+ U9 Z# |) @- #ifdef EDMA3_DEBUG# d( N7 S1 q* v0 ~
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)) o4 H8 [- T& K5 n+ N8 ~4 P: w
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)1 d2 L! V$ C0 b+ r7 C& A
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 t, H/ ~/ B4 b - #else( ^8 V2 J8 [1 u; \7 L. u6 i3 R* V
- #define DMA_PRINTK( x... )4 d/ Y6 B( Y0 q3 @
- #define DMA_FN_IN
7 G8 l+ N* T. Z& a - #define DMA_FN_OUT' D. F% m5 T9 k$ _5 R0 I( D5 y
- #endif
' M# S! G5 Q4 G% D- _' Y/ y - & p7 v0 s5 r* u$ F7 d
- #define MAX_DMA_TRANSFER_IN_BYTES (32768), K0 J8 K9 R& p8 |5 ?
- #define STATIC_SHIFT 3
; B. h B( } { - #define TCINTEN_SHIFT 20
) Y7 ^% E7 f8 l - #define ITCINTEN_SHIFT 21* V3 s7 @* H* J4 G! \( b S
- #define TCCHEN_SHIFT 22
+ ^- D% h+ ]( W+ q* I: C" D - #define ITCCHEN_SHIFT 237 J; o2 c2 D2 e" Q) s
6 `6 o( A6 k2 d1 k* T9 @- static volatile int irqraised1 = 0;2 f K0 w) P4 s' F1 M( K! D0 ?; q
- static volatile int irqraised2 = 0;
; e( r% W8 S% @3 q( a
! {1 u. D$ v- n/ u! S- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
- q' t3 h, C5 G% G, I - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ ^; @6 ?, j: {8 g3 ^ i - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 w/ e/ ?% `( i& ?; b
- 0 a) o3 i3 Z9 R9 b2 O
- dma_addr_t dmaphyssrc1 = 0;
5 j7 `' C/ H" ~0 ^) ]" V - dma_addr_t dmaphyssrc2 = 0;0 f5 z3 l% Z0 [) ^3 p
- dma_addr_t dmaphysdest1 = 0;- V# ?( Y5 m2 z. B7 r" T
- dma_addr_t dmaphysdest2 = 0;' v& k9 N7 O8 L
) X# p: d6 {. T) m+ e0 q- char *dmabufsrc1 = NULL;& A Z6 N W7 \/ {' n% d; o/ F
- char *dmabufsrc2 = NULL;0 G/ U" o( [& C* w7 ~" E- C( M
- char *dmabufdest1 = NULL;9 A8 b, b; P; {! G/ R* [- m
- char *dmabufdest2 = NULL;
2 ~" b& l( M7 l- w5 X' A
. Y; Q' J" M' K' k+ u- static int acnt = 512;
$ P) j o$ |0 ]3 H( d - static int bcnt = 8;; H* Q, C8 g( X7 ^7 d; r k: @
- static int ccnt = 8;5 j- F; {3 b; \6 m4 x( h: r
- - {4 W! f* E7 }: c' F
- module_param(acnt, int, S_IRUGO);- u W6 F a! d9 p0 p' g7 M
- module_param(bcnt, int, S_IRUGO);
) I6 {1 P' { g! N' e; S% S% a1 W - module_param(ccnt, int, S_IRUGO);
复制代码
2 Z! W- g4 h* o! }" p/ q
^* R& y' c( ~% l$ O 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 N r" a- c; V3 G6 @3 Barm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; F/ I; E9 o$ H7 C+ q% I J
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
& Q$ q4 ?6 [! K1 ?6 R9 D0 ], Z: F7 K) K) [- B: q6 D& H+ |
c8 n2 \* B% O; r1 P |
|