|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 E( Y" M& P: T$ p- [code]EDMA sample test application
v5 J6 D( J8 g H) Y s - /*
e* [4 ?& t* M$ f - * edma_test.c
I' G' P5 q5 Z' J4 ~9 ]: `( q5 d - *
' \. M( ~- \+ s5 I' u1 X - * brief EDMA3 Test Application4 }/ [2 V/ G: _
- *
3 }: v# T% r/ v3 Q - * This file contains EDMA3 Test code.
0 d- i! ]( B- i0 M5 r6 x7 @( Q6 o D - *
' X- R# I a) e5 V% D0 e: Z2 S1 d - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% V" _4 D0 K) \9 l- W0 v/ _ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, z' r* B2 B9 Y6 c+ E5 H4 Z
- * TO CHANGE.& u4 }2 _7 Z$ `' \
- ** v+ W" k. N& l" V6 [# R* t2 X! R' N5 F" _
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 j' u" D c4 ?& T0 U, E2 R - *' N% S# K/ }7 ~* \4 v |3 a8 y
- * This program is free software; you can redistribute it and/or. s1 d2 c* a7 j3 n* P" {6 R
- * modify it under the terms of the GNU General Public License as3 S& V8 ~4 t: \ L
- * published by the Free Software Foundation version 2.% D5 d, e0 P$ H$ k( H
- *
8 k/ c# A+ N/ W J% D% @' P# \ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
4 s2 L, s6 W m4 }2 }& c- ] - * kind, whether express or implied; without even the implied warranty
7 q: z! a1 E4 a6 G3 s% w - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the" ]) f+ _8 K; R7 C& q) N; ^# L9 b
- * GNU General Public License for more details.
- f8 k" \) t* ^/ q: j) ` - */0 T# L [6 z$ E9 r3 n" |+ q9 ]" g
2 t$ K/ W6 J4 S6 M( C. W1 g) t- #include <linux/module.h>8 k% c, K2 {, p& f3 _
- #include <linux/init.h>- P+ x% g: P d- N( e2 L
- #include <linux/errno.h>
. h( X2 }! w5 |: Z* n& l W - #include <linux/types.h># Y4 h+ k* v( f
- #include <linux/interrupt.h>; w1 {8 z, H" M1 E* k/ E
- #include <asm/io.h>
T, E+ e' O, b% Y, R, Z) B - #include <linux/moduleparam.h>" n' p! D; _2 }$ W, T6 f
- #include <linux/sysctl.h>5 D* n- O, s8 u
- #include <linux/mm.h>
% {7 W& S4 }/ g' I - #include <linux/dma-mapping.h>' k6 V) `; o7 W/ i# q
& D0 y' l: @$ D5 K0 V R) m- #include <mach/memory.h>
U. F. ^$ D" Z) C7 R! J/ C - #include <mach/hardware.h>
; G, X M" G% K7 ?2 U - #include <mach/irqs.h>
+ C! D4 b' g5 W - #include <asm/hardware/edma.h>& r, L- D7 B7 @- ?) P# P7 r
" A/ Z5 {$ N3 ?$ R- #undef EDMA3_DEBUG
7 Q! B# N8 Y/ d5 U. j4 t2 ~ - /*#define EDMA3_DEBUG*/! k$ C% \; M/ m' ^
( @ y- i: q0 P* P( Y' L- #ifdef EDMA3_DEBUG$ B' ?+ z1 `; M& i5 h+ T% l
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 T) s3 m1 o4 v7 `- n
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
0 @1 q. K9 ~5 A - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' m2 I4 ~) V& S" I# [5 C
- #else
" w& U3 o$ x! \* K; S% ^ - #define DMA_PRINTK( x... )% U) C$ I: o$ i7 {- B& Y& p/ k# S
- #define DMA_FN_IN
$ l, r, B$ ^6 w, a1 }: D: U - #define DMA_FN_OUT$ M: i5 j/ L& s. f+ k" C
- #endif6 S) k R3 l2 g) B
3 L) \- h. F, {0 a- #define MAX_DMA_TRANSFER_IN_BYTES (32768)# w X( v: D, c! y4 w' N% u+ e
- #define STATIC_SHIFT 3
( q7 S3 i8 N, N# \+ f+ l/ |( U - #define TCINTEN_SHIFT 20
3 k, R, r. O, X) @5 D+ c3 \9 S- W - #define ITCINTEN_SHIFT 21
/ |1 b1 Z* F6 D& a" l - #define TCCHEN_SHIFT 22
# B# {; f# }0 F# J4 G - #define ITCCHEN_SHIFT 23
, E4 V- I1 i" R2 f- h8 D; Z - % S7 f* D. A6 H1 H2 Y( b" y8 t
- static volatile int irqraised1 = 0;
$ \3 E* _: i, _( Y1 V' E( K - static volatile int irqraised2 = 0;: p* y8 ]5 r/ @
- 1 T- x4 Z9 T+ t: }1 Y0 S$ f
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ {5 R) P' Z2 d6 j6 r8 k* |6 I
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
; g* U+ R% C8 X% [5 e - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
) f7 @0 N- ~+ G3 X) H/ h
( L' G; r4 E3 }+ Q" h( V0 r- dma_addr_t dmaphyssrc1 = 0;4 s- a( V" ?' E7 K/ \
- dma_addr_t dmaphyssrc2 = 0;( m9 v8 M$ B8 o& o+ v2 c
- dma_addr_t dmaphysdest1 = 0;/ J Z5 {; c% I% V3 |
- dma_addr_t dmaphysdest2 = 0;
' @* c& d+ m. x# H9 V" m% c
+ U0 t* ^8 x- x ]( O' t- char *dmabufsrc1 = NULL;2 F8 \# f- q1 \6 w Z: b) A1 V
- char *dmabufsrc2 = NULL;
9 b4 B' D+ ^; N5 X, ], n - char *dmabufdest1 = NULL;2 N/ }" R4 ~$ I" W
- char *dmabufdest2 = NULL;
" U9 Y. l7 Q4 v; z
, G* P( z2 A. I* o4 o1 Y3 X% g' x- static int acnt = 512;4 ?6 ^# f3 b' ]1 j" M. m/ N
- static int bcnt = 8;
: l$ K4 |5 l' x - static int ccnt = 8;, w+ F2 B3 j9 U6 t5 q
- 8 s V) z6 t/ s Y
- module_param(acnt, int, S_IRUGO);8 ?. G7 l+ b4 i/ r
- module_param(bcnt, int, S_IRUGO);
8 y% h* X1 n5 a) X6 V/ i - module_param(ccnt, int, S_IRUGO);
复制代码
. e* o# x6 |1 J9 T7 N5 v. M) i* F
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
- R, g; Z3 f* q8 \# ^- h warm-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 Y2 P% x9 ?4 M% o- ?
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。. r& x6 `0 ~; f6 V [
$ Y' v1 u( H/ U) M! T
+ ?1 p$ G$ c- F: d& v/ v9 h2 d |
|