|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
/ b- ?3 b% _ w; {4 u6 I- [code]EDMA sample test application
8 V2 E& E/ X4 t9 `, v7 M, Q - /*2 v- C9 E& f+ |0 i3 h/ u1 y# q
- * edma_test.c
9 e- y; ?0 T" }, R' c/ e/ E4 H - *
8 d! p; _) j3 E" d w6 z7 s2 Y - * brief EDMA3 Test Application
, U5 L3 d/ C3 {( N6 y - *' L. [9 _- ?# `7 a$ X8 y
- * This file contains EDMA3 Test code.8 h! ~* w8 E1 I; ^# {% R, Z
- *
/ E9 a# \( G0 i( B - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE1 `1 y- j! n$ S, I
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT/ |( B6 m- A) i* s {# o
- * TO CHANGE.
( g0 h# `( y! Q* B, Y3 e - *5 u& h, o/ m& C" a+ l+ r6 y# M! k
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/6 v2 J8 }, i. {8 u3 G, ~+ F+ H
- *' D6 W$ Q4 z8 B' A/ o% ^8 p
- * This program is free software; you can redistribute it and/or
; X. b) ?. o2 X1 D% { - * modify it under the terms of the GNU General Public License as
5 e6 ]& |" M. O" S - * published by the Free Software Foundation version 2.
# I( G @0 c) ]5 S - *
6 F9 g7 Z d5 c, t+ i! X - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
$ M9 I7 n9 V1 L1 G - * kind, whether express or implied; without even the implied warranty
1 \. R: `* V" o3 L/ l; I - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* I" |3 x" l0 M5 O5 b - * GNU General Public License for more details.
; @- A9 [& x; U6 q* | - */
3 A) o& p, Q2 k' Y
( i0 f( B: c& ^$ V4 C* e. E- #include <linux/module.h>
, t1 h" y1 \- Z) i - #include <linux/init.h>+ T4 ~* X2 l) N$ h+ `0 c6 l
- #include <linux/errno.h>: _! @; p& e4 j+ Z: }# a
- #include <linux/types.h>2 C' l1 l& Z. [% U z2 g- M
- #include <linux/interrupt.h>* N+ ]' u. C' l* {
- #include <asm/io.h>
, b. R( a; R$ \, a% _, X: I, B7 D - #include <linux/moduleparam.h>
+ z1 J3 I0 ^' z$ ?2 x - #include <linux/sysctl.h>8 z \, D' o# A) V& X/ ]9 T; E
- #include <linux/mm.h>
$ B: g) U" ~( D0 Q, K - #include <linux/dma-mapping.h>
* F4 {4 ?% `" V. W) B* L* x
" D2 G4 h4 _- p- {8 O- Y7 \6 ?- #include <mach/memory.h>& T' F# U0 O% b; l. q7 z
- #include <mach/hardware.h>& C8 d; u3 ^7 M. L; A8 c+ e
- #include <mach/irqs.h>$ V! y' v3 Z) V! o. }* e/ T
- #include <asm/hardware/edma.h>2 J, X: U( a) N9 u D# p
- 0 J! |0 w* T9 _1 H" @- B ]# }3 U
- #undef EDMA3_DEBUG
7 e! C/ p( v N0 l% m - /*#define EDMA3_DEBUG*/
$ P- m* c, k1 q8 D! E* b: Y - # M0 I+ x# h3 J5 D' P
- #ifdef EDMA3_DEBUG
. o* Z! f1 X4 `3 |2 ~ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- b5 h8 K$ n; b5 g% H( O/ D s/ L, @
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 M$ i! N$ C# f4 | - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)9 D' z* J. N1 R+ |
- #else
; o% F3 K$ v5 c; Q- W; ~; g1 ?9 j - #define DMA_PRINTK( x... )
/ @; V5 q: [8 |- C: c9 e2 t3 T& S# _ - #define DMA_FN_IN
P; H2 X) [) y! L7 O9 r - #define DMA_FN_OUT
0 l! d! M" L# k- ?' }; a - #endif2 G' J& b6 j6 b0 m
& w( r+ @# [, E0 r6 i% v3 |- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: w$ ^3 t% @- f" h' M' J9 x - #define STATIC_SHIFT 38 R; n; R _. A
- #define TCINTEN_SHIFT 20
- {1 K1 E3 _, X1 V - #define ITCINTEN_SHIFT 21
7 H8 f5 W$ C& Q# a+ s* D - #define TCCHEN_SHIFT 229 ?3 M) s8 p1 k' Z! P9 ]* {, i7 p7 z
- #define ITCCHEN_SHIFT 23! s' d5 Q( n( e
- 4 Z6 D+ E9 h* S F, Y, K! N
- static volatile int irqraised1 = 0;9 e M- g, D F8 G3 x5 j
- static volatile int irqraised2 = 0;
2 s- K% [0 x+ C2 O$ ^
9 s. i8 U' Z5 a U- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 Z* U: }$ p, o' ~1 _, E# y - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" b; ] n, [) _. P3 f4 R- V, ] - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);7 G4 N9 s! z# Z* Y! v1 I$ `
- % V# ?5 i. s$ d0 y! `: n$ d
- dma_addr_t dmaphyssrc1 = 0;5 Y! y8 Y0 j4 T, O6 X& p' i% M5 s
- dma_addr_t dmaphyssrc2 = 0;
+ I3 L( o. s8 H- H. Z5 h3 U - dma_addr_t dmaphysdest1 = 0;
e; ^2 J- Q+ V! B8 D. w; f' D8 T - dma_addr_t dmaphysdest2 = 0;1 i3 ~5 x4 q2 j) c1 Y
# p, x# v/ I) D8 a4 H3 c. Y- char *dmabufsrc1 = NULL;4 C- }5 D2 C. P: ~7 G& l; y
- char *dmabufsrc2 = NULL;
. e: c- Z0 j/ E - char *dmabufdest1 = NULL;, _2 H8 M: f' _) k- o- j X8 q/ s
- char *dmabufdest2 = NULL;
y/ \' J! y% v6 R9 l5 W& Y- F
' N) [# L0 I; |6 z- static int acnt = 512;1 ?/ J' W/ U: U) E$ E& F
- static int bcnt = 8;
7 Z5 m3 Z4 l% K0 ?; @: R( T1 o1 T2 P - static int ccnt = 8;
( v6 f& R; b! O - ! V1 k2 G, u( w* x' U
- module_param(acnt, int, S_IRUGO);1 p' I+ n; d; B* R# l6 K
- module_param(bcnt, int, S_IRUGO);
" r) t- G) M7 g _; Z+ \- C - module_param(ccnt, int, S_IRUGO);
复制代码
* y% Z" a3 z* j+ C! j8 E& v. O6 H: Q/ U. \9 r/ |6 `
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用$ r1 Z* Y5 g7 a, O) Z% H
arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
7 t2 C1 }: I2 z8 C" _! r0 w 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# U; L$ x. i* I" q/ A0 K/ S( g9 x) E" l8 A* F
7 u1 E9 L; b8 e* M$ _, k! Q
|
|