|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 1 ~& \$ Q. G) N- W. X( U+ b
- [code]EDMA sample test application
! }% T1 n) h6 \8 t( C! ^ - /*5 h! t9 ?: s6 S1 a7 V: u4 s
- * edma_test.c
; y" q2 Y9 o" {: ?9 ^( `! }# h/ | - *
8 H3 v! [0 [8 p7 h* M2 G8 E - * brief EDMA3 Test Application$ Y+ A9 U& p' Q# T9 l" L- U* d3 L
- *6 O$ U4 [, m1 s+ P
- * This file contains EDMA3 Test code.
$ ^# h3 O" g- R- }% S9 @" z. E$ p - */ b4 n) W3 G F R/ Z* n) N
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, n0 v- Y4 K" [ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 q: E! X6 p6 T; E" G! b
- * TO CHANGE.
% o+ v9 |8 f( t6 B2 U - *; c' p6 z' M+ b% g/ Z7 y" Y
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/& g* }/ m# K# |, ?
- * o" m+ `0 `" p. s& d7 ]" O
- * This program is free software; you can redistribute it and/or
" B. F, m/ W& {, h - * modify it under the terms of the GNU General Public License as6 E; Z8 s- w$ o" V! Z# y
- * published by the Free Software Foundation version 2.
4 z+ C4 M' ?2 i( r0 Y - *9 e; q: z$ f; |+ m
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- I$ W- p) P7 P. o& l+ Y - * kind, whether express or implied; without even the implied warranty9 A0 b6 Z+ D1 u( ^% P* Y; k \ A
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ B6 v2 {" a0 U5 m" w - * GNU General Public License for more details.: F# `6 T' l1 U0 t4 N# a) r
- */
2 q, ^. R5 X$ x% h6 v* f# W
( ? |3 N. E7 R9 A4 e- #include <linux/module.h># y# \. |: T7 \( N- U* O! Q
- #include <linux/init.h>( p) \$ @: V# _: Q& V8 e% g+ u7 Z
- #include <linux/errno.h>
& c2 N9 A+ K) @# m% r - #include <linux/types.h>
9 I; T3 V b4 H" K, }, G S2 P - #include <linux/interrupt.h>( b1 @' f) o& m4 S* w& J/ |3 Y
- #include <asm/io.h>
( e% [6 d% U. U' n% Y - #include <linux/moduleparam.h>- `9 @5 N& v& \5 ?- k
- #include <linux/sysctl.h>
0 r1 l8 g ^8 }* r T& h - #include <linux/mm.h>( W3 k% _$ Y/ A# s
- #include <linux/dma-mapping.h>3 F5 w( a5 v* ^: y
4 x: ]8 r0 q0 G: m/ ]$ \2 i' l- #include <mach/memory.h>& z; F. q/ |# I; @
- #include <mach/hardware.h>% z8 x, Z! ^* d2 N. J: D
- #include <mach/irqs.h>
, @+ i) j- F: O4 A) A- W' U - #include <asm/hardware/edma.h>
' D; s) m* j% f" M) R( g - + p* x9 a/ M% V1 u0 u
- #undef EDMA3_DEBUG
, ^1 c/ x0 O, H+ b+ D* ? - /*#define EDMA3_DEBUG*/
5 a9 e( f( {& V+ V& S( H - 1 G3 h9 H( l2 J; z
- #ifdef EDMA3_DEBUG6 Y- i6 J8 j7 X# n
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). S5 z6 w) Q0 Q, F% X
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 r6 ?! \( _4 [9 U: {0 K! U/ Q- X - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
t+ F& U5 V' ~, L% o2 P - #else; D% K8 I, K4 g- L4 Q) ^
- #define DMA_PRINTK( x... )
$ L% q8 r' L6 v, C9 y - #define DMA_FN_IN
6 G- H6 F- t' p' i0 j0 S7 `9 G! o - #define DMA_FN_OUT
W* n* i4 k& D, n0 B - #endif
5 l, \+ _0 c5 G+ {, s; N: t) g
2 l6 o3 u. ]( e6 M7 a- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
$ a7 E1 f7 I' W7 K - #define STATIC_SHIFT 3% Q4 J% a6 l$ p; o
- #define TCINTEN_SHIFT 20
$ A8 B. Y% i4 {) Z( ]% z3 M! I- _& ^5 [ - #define ITCINTEN_SHIFT 21& i ]+ X3 t8 H5 R/ z- b
- #define TCCHEN_SHIFT 22
8 g( @: M7 u9 |7 g - #define ITCCHEN_SHIFT 23, D9 ~' [8 i4 _& Q, q5 H# G
3 Q+ x- L/ R) A- static volatile int irqraised1 = 0;, p/ _. }! K/ e; e! `
- static volatile int irqraised2 = 0;
" ~8 i+ X# G, K, H1 k* ?7 j - " ]4 T* t. `) P( F" Q
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# s# w# P, P5 K2 m7 K - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 u, l. e; [* i3 T# j2 o
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 h1 _8 a8 l9 ]* c! ? U
# v6 i' h$ v: i9 Q0 y- @7 c6 r- dma_addr_t dmaphyssrc1 = 0;9 l( x8 J, D u: l1 F7 i
- dma_addr_t dmaphyssrc2 = 0;
1 I$ c5 `5 M' M0 f1 D. G - dma_addr_t dmaphysdest1 = 0;: @5 V" x7 C& F5 @9 u3 \4 P
- dma_addr_t dmaphysdest2 = 0;0 h$ n: e3 U# g1 ?0 X% v
. A) e# ?, C' i( Q- char *dmabufsrc1 = NULL;
& s- s5 i. D( t4 l3 M - char *dmabufsrc2 = NULL;
# z$ u$ K! C$ L - char *dmabufdest1 = NULL;" z0 s7 B% E$ e* \ S2 Q, x
- char *dmabufdest2 = NULL;
& p! l" s8 a8 W - 7 s* e! }+ P! J! h7 l
- static int acnt = 512;! N6 Q' z5 ]6 ?/ j& T L$ q. {
- static int bcnt = 8;* c n1 A @9 e1 G& ?
- static int ccnt = 8;
: h! S. \ G B {$ s - % w% u) r$ v' R+ v% T9 W
- module_param(acnt, int, S_IRUGO);1 \0 ]& A/ m* `0 a7 J; p w
- module_param(bcnt, int, S_IRUGO);
7 W4 V+ H6 a3 G - module_param(ccnt, int, S_IRUGO);
复制代码 ' x/ W* q1 L8 b5 ?4 A7 ?5 b" a) Q+ @
5 s4 q$ _) [9 G3 Y 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
% K# c3 F/ O5 l$ }& _+ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& V* [8 Q% |# A+ _ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; [7 _" w$ `" }
% ^9 k1 E$ C/ d" e, m: @4 u
2 S" y x; X+ _( q3 t. D6 z1 r |
|