|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 * f1 D9 x' m# [2 }' X: Y/ p5 ]% D
- [code]EDMA sample test application
- s$ u2 ]; Y) e1 L' U4 [( M - /*- E" }5 Q; x2 A! V
- * edma_test.c7 o" `8 ^5 S- _' Y
- *
. m3 N& h; p8 N4 L$ | - * brief EDMA3 Test Application9 J" c- v4 A9 K& p, m' Z. Z
- *& y; [* a( a, a2 v1 G
- * This file contains EDMA3 Test code.7 I7 B7 `9 k& f& e/ n$ J& c O
- *9 g. a" Z6 A& E1 y+ h1 ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
& U. ?" v( j! | - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! H f8 s2 a. b+ N
- * TO CHANGE.
& N u* o! P+ [. F+ N0 K& X - *0 x8 Z* l, H5 c/ |' j. V! l8 X
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/3 I9 Q% l* h3 V
- *
[+ |1 Z$ p8 i# _, c0 P( Y: B* i - * This program is free software; you can redistribute it and/or/ k2 p) g! s; ?6 R; l+ y/ d7 Q% ]
- * modify it under the terms of the GNU General Public License as
0 v3 _$ H2 N9 q8 w3 k# s/ {8 p! K5 v - * published by the Free Software Foundation version 2.4 p3 Z* h% M6 k8 r g8 m
- *
/ @6 N0 |$ d$ F% t8 C( t |* W - * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 U7 E3 |9 ~# A7 Q) b# I+ X
- * kind, whether express or implied; without even the implied warranty( U/ F! Y/ u, L5 i# M8 Z Z7 j
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3 \! O R5 ^8 ]. I& Z - * GNU General Public License for more details.
/ ~5 z3 G9 F6 C) Y% d5 o - */- |4 |1 q1 o: L
- / Y8 p* O$ @: F
- #include <linux/module.h>) J8 I* Z2 n" I/ q/ l( u
- #include <linux/init.h>1 J1 l8 ?5 Y) R! v- h) u; V8 I
- #include <linux/errno.h>9 r R x% g9 t* x
- #include <linux/types.h>8 g/ r: L2 h" J2 h* H$ n
- #include <linux/interrupt.h>6 M5 j; C/ R4 R* q0 f
- #include <asm/io.h>% x b, |- J1 I% _. b, v. C! ?; h
- #include <linux/moduleparam.h>
9 t* t) ^7 G# ]$ A% u, C! q - #include <linux/sysctl.h>0 n9 i) d: l+ e6 V
- #include <linux/mm.h>
! A' \. P* U( {. l7 J' v, ]1 @ - #include <linux/dma-mapping.h>) \7 g7 T: G3 x% |) A$ W, V% ~
0 e: o$ V; e2 p) ?6 i5 s- #include <mach/memory.h>* x2 S* [ ~" q# t
- #include <mach/hardware.h>. ?2 |2 u* g3 N
- #include <mach/irqs.h>& k# W4 z8 W: E' b( N! z6 b/ a
- #include <asm/hardware/edma.h>
. h4 F0 j+ W) a; I, P4 m
& ?# \* C4 S/ W! A+ B0 H- #undef EDMA3_DEBUG9 b" D3 \! u, G+ r; ?& E7 b' Z9 @5 b! h
- /*#define EDMA3_DEBUG*/- F$ b# Z8 Q% |" N
7 Z- H: D. ]# T+ K- #ifdef EDMA3_DEBUG
$ J% }) F" ^& ]) B8 z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' u* I8 v$ t5 d' n, W7 m1 V - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
' ?& v3 v, q; g v - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
, ]- l- K5 y9 j0 }) U - #else
) M% A1 h5 A' v* W3 a. c - #define DMA_PRINTK( x... )
( n1 u+ s A+ U& G3 A - #define DMA_FN_IN$ ?) K9 X: S' n
- #define DMA_FN_OUT+ V) O; [! l/ L$ D
- #endif0 X2 q* B. Y" e5 C" \% [& t
- % C: {% a9 J- i! b8 J
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)1 K5 |) ^ v2 e+ ]0 w
- #define STATIC_SHIFT 32 N& @9 X) v0 D+ ]5 J* y
- #define TCINTEN_SHIFT 20
$ W$ W# {8 q0 o( s2 N. f; e) D& o - #define ITCINTEN_SHIFT 21
! P: t$ |/ |: @/ E - #define TCCHEN_SHIFT 223 g6 ?& u" c6 E
- #define ITCCHEN_SHIFT 23
6 \. w5 H. k E1 q - - I6 @( b+ K7 T) t. Y1 V1 b
- static volatile int irqraised1 = 0;) e( ~3 w0 t9 F% o: M# b
- static volatile int irqraised2 = 0;" I6 M" I% F4 z! h _
- 3 E" p; Z, h( I1 @+ O' R' j' U" ` M
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# }, s) b2 w' A* F$ k+ i u
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. ?) b2 e) j% R. I& Z
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) F; ~% E* B: B' I$ }% G% [- B+ s - 5 L# s' f6 {+ x! D! T B# B
- dma_addr_t dmaphyssrc1 = 0;
9 }* F M8 U) O* ]# I, L1 c - dma_addr_t dmaphyssrc2 = 0; e2 c6 P. }8 q3 w6 L0 Z
- dma_addr_t dmaphysdest1 = 0;
: `$ u( i; f" o g9 ^8 S - dma_addr_t dmaphysdest2 = 0;( r5 e; x- O8 @( ^
- " }6 |$ y' J) ^
- char *dmabufsrc1 = NULL;, i3 @2 A9 b3 p- V0 U
- char *dmabufsrc2 = NULL;# U' o1 z! u; A8 Y, L2 g1 x: G
- char *dmabufdest1 = NULL;
6 q4 Z' e/ [- [9 P- r$ K - char *dmabufdest2 = NULL;
- a. ]* ?3 c; A+ Z/ u, e& {7 j z- {
# _# T. }( F1 M' G8 y$ O- static int acnt = 512;7 w: m) y# F2 W1 o! J! D& T
- static int bcnt = 8;
9 t+ v+ H1 _3 M, T" x6 F - static int ccnt = 8;% i- D/ k }/ B0 j* V% Y' a% Z
3 a6 X* t2 v: f4 } u1 x/ u- module_param(acnt, int, S_IRUGO);9 |; l1 S) ^7 X6 Z. a& W
- module_param(bcnt, int, S_IRUGO);! V7 i l. ?' y: w3 L5 P( W
- module_param(ccnt, int, S_IRUGO);
复制代码
# u7 T. P; J1 O4 U7 q8 p0 m
5 Z' H1 m0 i, [0 I! N5 \4 d; z 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: P$ u9 h7 A' M3 X+ S# iarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。( K! m/ d- T$ h* C
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。* A9 O' {4 A) f9 A+ f: n0 ^$ b8 A
+ c/ I( K; ^/ q) ?# A7 ~9 A, w! A
* v$ r( \7 [& f |
|