|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 & P: y8 O" n5 Z5 W
- [code]EDMA sample test application
% | }; n$ p' E$ a7 T - /*
+ B- o" Z, J! S' f. C3 s- O+ P - * edma_test.c8 [5 J5 m; [% o- b
- *8 |: [( z: G. {
- * brief EDMA3 Test Application+ X4 L! U# C4 N9 ?8 T+ {
- *
" P* F2 f/ ~/ @ - * This file contains EDMA3 Test code.
t7 h2 U# c; ^$ j - *
" A: N- p$ O1 F0 F- o( L( _# A$ D - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
6 g# B; m$ b# s* @3 D3 H8 U - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% F( p. s$ m3 I& h9 M
- * TO CHANGE. {& d7 P8 ^* y6 ^
- *
* W I' W" u3 G7 h1 Z - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/8 y5 a0 @/ J0 f0 v; Y
- *, u% u$ q* l& B5 n
- * This program is free software; you can redistribute it and/or4 h/ B8 l2 R+ A; t8 b
- * modify it under the terms of the GNU General Public License as
: k, A4 V; o$ _4 K8 Q9 x3 l - * published by the Free Software Foundation version 2.
: \2 m. _. q. b- R- i - *
, v5 V# V4 u2 i. D" ` - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' _% }3 W3 K, ^* v" v; W - * kind, whether express or implied; without even the implied warranty) O+ ^6 w- e/ }$ m
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ M6 r6 \* J8 S
- * GNU General Public License for more details.- ~2 r; b7 Y0 D: G7 N' F" ?* W# O
- */
: H! X* I7 s8 a5 S - 3 `7 ]0 S! \9 i; ?3 ^0 r$ F
- #include <linux/module.h>2 x' V& ^0 w& T ]( i
- #include <linux/init.h>
2 ?- \. x7 g) p, Q9 G, {; O( o: B - #include <linux/errno.h>8 L6 ^* c+ X, O
- #include <linux/types.h>
8 }; i1 b+ q( {1 e g - #include <linux/interrupt.h>+ m# V0 {9 B( Y
- #include <asm/io.h>
L* [" v c) f6 F - #include <linux/moduleparam.h>1 e' c: _ J# x" F' x1 W
- #include <linux/sysctl.h>* X* k* m8 m5 b) x. F5 x
- #include <linux/mm.h>, G. \4 C2 }" M4 N4 W4 }
- #include <linux/dma-mapping.h>( a& J3 t( b/ ]: x* V
' O5 O0 C |* r* O& [- #include <mach/memory.h>! u6 D" N7 o. j5 V# z
- #include <mach/hardware.h>
, H8 W" x5 m% @ - #include <mach/irqs.h>
0 n( E+ t' S9 r0 q/ J - #include <asm/hardware/edma.h>
0 z5 t$ O% v( @" ~ - - i c5 `7 F2 X% n# e8 y- O
- #undef EDMA3_DEBUG$ ?2 _1 e( g2 {' Z, `
- /*#define EDMA3_DEBUG*/
$ L: o" }; k, y5 h; d# }
6 i) R4 F1 W' k4 h- #ifdef EDMA3_DEBUG+ \* M/ Z1 u0 h! d! B# X+ J
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
; U; Y. g$ A5 e) y- Z - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 G% m0 C& F/ v; N - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) B) L; n- M* x& W' `- z
- #else; {7 ]2 B% d# o
- #define DMA_PRINTK( x... )
/ l6 L! T2 `, d: ? o7 i - #define DMA_FN_IN
- i' ~" N6 [8 y - #define DMA_FN_OUT: N2 c, K) H4 Y7 ]0 S
- #endif
# `' T. t5 {- i) e
D/ v; e& i$ l# b3 k: o/ V- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( C h3 g6 J. c- @7 H! e
- #define STATIC_SHIFT 3
+ i3 A! e) B9 C4 m- B6 S7 j - #define TCINTEN_SHIFT 20* l) K8 V! a8 k( H
- #define ITCINTEN_SHIFT 21
4 B/ I3 `- {' K; s0 p- y - #define TCCHEN_SHIFT 22+ T5 `5 x7 R* ]
- #define ITCCHEN_SHIFT 23
, m8 I' U7 Y( r" [3 b s - 7 `, X9 Y2 B, P+ Z( I) ]
- static volatile int irqraised1 = 0;3 R/ a( @ b& |1 L& Y
- static volatile int irqraised2 = 0;
% e; ?& ?4 y1 I3 a5 n
Y7 T9 W5 i Z: e& B2 x) O- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 L5 q. S; s! N# Z" i
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ V/ h- w$ w" V" y, y- {) D+ s - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! d; V8 |' K* O+ T( q6 [% y
8 a4 u+ N E; i- dma_addr_t dmaphyssrc1 = 0;7 B$ |+ F1 e' r/ M! d4 {7 y
- dma_addr_t dmaphyssrc2 = 0;
) `1 x& A* ^% d5 ]+ m- R" c - dma_addr_t dmaphysdest1 = 0;
4 k; E* @. i; y8 l- c0 P: } - dma_addr_t dmaphysdest2 = 0;: }& b6 M% B- J4 O
+ S1 `4 }5 i# g0 Z, ]( q- R- char *dmabufsrc1 = NULL;
0 \# q0 V% y0 n0 `/ ]6 k) k - char *dmabufsrc2 = NULL;
1 v U. C* n& X - char *dmabufdest1 = NULL;
5 h6 w( S( U( ]) D - char *dmabufdest2 = NULL;" I2 x$ J$ O" r7 U; }& o9 b& W
- ' L; Z% m- w0 ]0 _
- static int acnt = 512;! q$ m. V$ w' ^5 ?' F
- static int bcnt = 8;) X1 D! g$ L) u. ~. u! P6 L3 U
- static int ccnt = 8;* B. p$ f r! k1 z2 P2 @: T0 m
- # S( g- T Y+ I5 Y! Q
- module_param(acnt, int, S_IRUGO);* Z2 b3 J8 C4 B3 z$ x+ U$ g4 _& E
- module_param(bcnt, int, S_IRUGO);
* }- E( C+ G6 H S - module_param(ccnt, int, S_IRUGO);
复制代码 " t, H- [& F+ f% T5 @
- \( G5 F, |- C$ z/ O) Z( i& V4 h
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
0 u5 U! [2 j5 R8 j! u. Qarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
3 R. c {8 m) ?: R$ O2 V7 l3 s9 h 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' N6 k$ Q9 L4 q; R5 u2 b* T# R* a9 g4 W+ A& A: B$ I' x/ A1 @+ Z# V& s
- K- O0 D$ Y5 H; z" y
|
|