|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
, f( [) J# w2 c, \: N- [code]EDMA sample test application
6 u f# P8 a- J- h3 b0 e. ^9 L3 d" G% _1 d - /*
. Z- w/ |2 T2 \ - * edma_test.c; _7 n) I8 b0 ?; B0 q- r3 e+ U
- *
. b" F$ c' F9 E$ g - * brief EDMA3 Test Application+ y# f6 D' a, s- f* O
- *
) ` a/ L4 @% P6 \3 V! I - * This file contains EDMA3 Test code.
1 E# O9 Z; Q3 _% \ - *
6 N9 _. @2 A7 Q! e - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE& F' [$ [6 b& c
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
$ ?: \" K3 L# i' \' | - * TO CHANGE.! p6 p) F2 P2 i; F! a2 Y( S
- *
/ [# j8 n& }% W - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
: I3 i, R0 D/ Q j - *# f& j5 j+ e7 I5 O6 ~' F+ n( z
- * This program is free software; you can redistribute it and/or
/ Z! o) e( e o1 o4 O0 i3 _ - * modify it under the terms of the GNU General Public License as Z; _, t; T4 O0 N: O
- * published by the Free Software Foundation version 2.3 I: B" G8 b3 D" K
- *
6 Q B( H# q7 q. a0 G - * This program is distributed "as is" WITHOUT ANY WARRANTY of any; n. P# z; @/ t5 r" c& f C+ Q1 c
- * kind, whether express or implied; without even the implied warranty2 k$ ~% C! d% M1 ^1 ^6 ^
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 P2 a2 b" c8 R% N; W# ]
- * GNU General Public License for more details./ U( z4 i6 K$ i2 j* t0 G+ `; g
- */& w7 p$ L! e9 z' V) Z
" g* z* k! _5 U- #include <linux/module.h>5 q6 S3 w) L) l! n5 A
- #include <linux/init.h>
9 Q3 h7 p2 Y8 I- F0 T3 _ - #include <linux/errno.h>
2 H' }6 A+ V2 p3 ~$ ~ |$ [ - #include <linux/types.h>
+ Q( y& A' ^% t: ~ - #include <linux/interrupt.h>2 a2 g7 [- Y# N# v0 o
- #include <asm/io.h>
0 g/ ^$ x( n, N& h' I - #include <linux/moduleparam.h>! v: p9 ?% {8 A9 B# r
- #include <linux/sysctl.h>
: C3 e% Z) \3 Y# ?& m - #include <linux/mm.h>3 J9 l, K; n" e$ k) G) z1 b5 [
- #include <linux/dma-mapping.h>
6 Z" d1 l- u8 }+ _2 i - 0 c# t1 t9 Y# l l$ \# W; }2 I
- #include <mach/memory.h>4 ^( q s& h: z( r- [3 n
- #include <mach/hardware.h>. N4 M- K7 E6 }/ U
- #include <mach/irqs.h>& q+ w5 a# e7 k
- #include <asm/hardware/edma.h>
2 y$ u: ?* U. I! Z' i# |
% n E6 Z+ M- L; z2 J- #undef EDMA3_DEBUG
& e5 ]/ T6 i) @7 C, B5 N+ E( g - /*#define EDMA3_DEBUG*/* X& ]8 O" a) ^& n
- # \* f' u$ u, u5 |, ~: b' ? b
- #ifdef EDMA3_DEBUG8 O2 m2 B6 F9 n9 b, L
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% |- \% x/ x% C/ h6 r3 ?0 C - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
. H d7 E8 s! ~: ]; \, } - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)0 o5 g1 H" C i g- C
- #else% r( ~ M& i9 q
- #define DMA_PRINTK( x... ), @' M6 g5 Q; q& d( K
- #define DMA_FN_IN
% h/ L/ j% O: n1 x3 C) c1 Q. s - #define DMA_FN_OUT
4 L2 S2 x7 F7 L- F4 z2 V8 c* o- ] - #endif4 L/ K( g- ~, C7 c2 M% c0 T1 \
- / @$ m J) Y2 w, P. U; p+ Q! S
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)3 W; W1 V1 n( Y7 E' ?9 |+ y
- #define STATIC_SHIFT 3
|* I* Q+ O6 q& _$ J" I - #define TCINTEN_SHIFT 20
$ T& J' j" `/ N- ?& f2 Z - #define ITCINTEN_SHIFT 21
0 t6 z+ W, Y: B, D* x) J/ Q - #define TCCHEN_SHIFT 22
9 Y, P7 ^2 ^# Z/ |. _ - #define ITCCHEN_SHIFT 23( j0 U5 U6 B- e/ K" Y
- 1 P* E7 U' s: b; f" k+ K. M
- static volatile int irqraised1 = 0;
& c$ M" o% t7 F$ q - static volatile int irqraised2 = 0;. h8 @) @0 p) |5 W& Y% a2 h l0 H
- / J: H; a- V; t3 J, Y
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 m+ o! v! `9 D4 e! N8 x
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ T& J( I3 y* H) m U9 R
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 ~6 P( f3 P% G8 J: b `- H/ a9 v4 m
- 8 w: i5 ?) l6 v
- dma_addr_t dmaphyssrc1 = 0;
' L! s o3 a: _" j5 _ - dma_addr_t dmaphyssrc2 = 0;
3 ?1 y+ o( \ @& z% ]4 G1 y - dma_addr_t dmaphysdest1 = 0;- C! {/ c0 F3 c6 o
- dma_addr_t dmaphysdest2 = 0;
3 }! g0 Z7 v1 M. _3 ~) h
5 K- |" z% P8 l% L% o3 h+ ?: ]- char *dmabufsrc1 = NULL;& w8 x$ v) B4 A' h# Q+ Q+ O
- char *dmabufsrc2 = NULL;
9 ]7 ]7 g$ `5 J. F @ - char *dmabufdest1 = NULL;0 y3 X# k4 p. s
- char *dmabufdest2 = NULL;
8 l2 r7 c$ T6 ]* b& w" {+ q7 V& z+ F0 o A
- E l* V8 K; _( H# W/ I3 F* X, B- static int acnt = 512;
% g6 ^; F* [# S# v! F9 z - static int bcnt = 8;! c9 q1 p4 L" [
- static int ccnt = 8;
" l9 _# o5 B( o% r$ R - 3 N& U9 s1 |6 x) p
- module_param(acnt, int, S_IRUGO);
, r1 C$ z+ B1 Q9 Y - module_param(bcnt, int, S_IRUGO);8 q* h( j- w, {+ f% u: q% T$ ^
- module_param(ccnt, int, S_IRUGO);
复制代码
. ]8 B2 B6 j3 T, ^! M( c7 h+ l$ J5 ]" z6 e& q) n, _3 U$ R
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
8 w3 |0 J9 o% Darm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。, p4 w) f1 }7 p* E3 K. N
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
- P5 b% X0 r% [# E
9 \% {, w h% f8 B% J j/ e O
7 T5 F, \2 p! v) {4 N. _ |
|