|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 & h+ @' a8 b& s2 z' O
- [code]EDMA sample test application
8 m1 {' n, T) Y - /*
. R! B9 ?' o" d. \ - * edma_test.c* } y: F. o! ~1 c" _
- *# _4 l1 b2 s; N \1 j& Z
- * brief EDMA3 Test Application1 O; C5 j/ G% I3 V
- *7 [% B/ c9 v& X
- * This file contains EDMA3 Test code.4 w {- b8 V0 p; ^8 t
- *
# y3 q" T2 _# I& |' [8 H5 W - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
- X& l: f9 t1 g* b - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
+ i7 y* ~( { C0 N* ^) t; z) }" B - * TO CHANGE.
% i9 I4 b) _4 r0 F! J$ S0 V - *
' c+ I& E8 F7 M7 G' U# B9 X - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/* }4 r0 d4 ~5 {4 W' I
- *0 F; l+ R5 ?" E q
- * This program is free software; you can redistribute it and/or" a3 _ v. N6 K; j. b+ p/ Q0 q9 A5 y
- * modify it under the terms of the GNU General Public License as
& W$ q# E# j: z6 X7 u+ d1 T - * published by the Free Software Foundation version 2. O' H! ?1 {3 g2 M) g7 I
- *
, l2 ~* g4 L# w8 |8 S0 j - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
7 w4 u3 T% `* Q' ~1 B* ] - * kind, whether express or implied; without even the implied warranty
5 G+ ?# `" A2 K. i: i; c6 ~ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2 T. H- M2 \6 n. l: R - * GNU General Public License for more details.+ n* b Q6 ^1 T" p/ I& E
- */
0 m. |* J2 H* T9 d
! Q, Q( E6 e0 ]* M% m/ K) N' l- #include <linux/module.h>
a$ w9 b. b/ E: q; X& _ - #include <linux/init.h>
: {' [' J' u! I8 J# L w - #include <linux/errno.h>
) }0 P1 \, A x7 K) ~' q. k - #include <linux/types.h>3 n: B; ~: K F: B+ X( q
- #include <linux/interrupt.h>
5 y* O0 R6 X. C - #include <asm/io.h>
1 l, W1 \0 n j: D9 u4 s - #include <linux/moduleparam.h>
! D- D# C8 v: w! p. f6 r" L+ e - #include <linux/sysctl.h>
+ r) [7 x3 _0 X: h - #include <linux/mm.h>
$ V0 k9 n9 g1 F+ v/ R' p r - #include <linux/dma-mapping.h>
" }, b6 j2 a8 ^# S
* @* b! a" R9 }. |4 k- #include <mach/memory.h>7 v4 z7 R4 _3 H/ e
- #include <mach/hardware.h>
( b( h* ~' T$ H+ J& i# q, D0 L - #include <mach/irqs.h>* {! |! Y+ ?( H/ V
- #include <asm/hardware/edma.h>- T6 O) m$ \4 ]
( N- T6 Y! k: A+ |- #undef EDMA3_DEBUG
- k+ X, E$ g* C/ p y: A7 Y& M - /*#define EDMA3_DEBUG*/
6 `- Z( e' i% l- V; E4 F+ w0 _
{) W6 W/ f% r5 d( }- K- #ifdef EDMA3_DEBUG& o4 @7 c( S7 o; N
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)( V* l, H4 E4 l* q p6 ~
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)* F5 u4 Q5 I- D7 _8 S% t
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
& L' Z) I2 D: y* w/ X/ f. b - #else- `( G" ]& X; O. V, E/ O
- #define DMA_PRINTK( x... )7 _: Z) v8 A4 K/ b, |' [) `7 i
- #define DMA_FN_IN
9 u' p" G5 K. V2 y3 Q - #define DMA_FN_OUT' M& ?* Y; H" C
- #endif
$ e) k2 C0 f4 u - - _, G4 a) k' S0 {' }1 Z( {3 q2 s
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ W. R c% m. ?; k* K
- #define STATIC_SHIFT 3
) r% E7 b) E! I, Y9 u8 o - #define TCINTEN_SHIFT 20
- h v! H) y! f2 O1 M - #define ITCINTEN_SHIFT 21' z+ }1 W: q+ T9 {0 E. E
- #define TCCHEN_SHIFT 22 `; L( |2 L: {7 w/ \
- #define ITCCHEN_SHIFT 23+ S0 X' P0 f' i" b5 k/ @) Y
& E* _' Z: m( G& R" C+ t- static volatile int irqraised1 = 0;. `+ {2 u% l) e
- static volatile int irqraised2 = 0;
- @! @3 o4 q! t) u4 ^& B$ S
8 ]" n/ Z) G9 n8 c1 h- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 E2 ~# ?3 i# _9 a; o
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) r$ N7 F7 e9 s: D' b! f! r" p
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 ?" c0 c' p1 _
- 3 q! o% W( s7 C# d- U% l1 X
- dma_addr_t dmaphyssrc1 = 0;4 d$ r+ J3 K/ O# P3 N2 }
- dma_addr_t dmaphyssrc2 = 0;
2 m/ L9 c0 n, `- _+ ?( L. m/ t - dma_addr_t dmaphysdest1 = 0;
0 O2 v8 K, W- r' ] u$ w - dma_addr_t dmaphysdest2 = 0;
6 E3 K$ K1 I* |, [' z) e - * e& B4 x1 ^5 M$ W, o p
- char *dmabufsrc1 = NULL;" N' c b2 \) j+ ]- ?9 B. w6 P
- char *dmabufsrc2 = NULL;
# Q9 w9 @3 O/ m! H: K2 L" |* U - char *dmabufdest1 = NULL;
; b7 m& W( w6 r5 Y( B6 E/ U/ A1 u - char *dmabufdest2 = NULL;. M& u1 s; T$ m4 E5 R2 T+ R
- - b3 A! I7 \! G) Y# v. y( J0 \
- static int acnt = 512;
) K9 F ?+ r6 }- w4 f - static int bcnt = 8;4 ? H) U, ]7 D& u1 H* I2 s
- static int ccnt = 8;
" \3 s7 H' d5 U1 `- M$ E6 W3 E - 3 @0 X4 L9 D& q( M+ N, m
- module_param(acnt, int, S_IRUGO);7 t6 C& p3 @8 l
- module_param(bcnt, int, S_IRUGO);3 I3 M4 S5 N) b6 A# S- |+ O
- module_param(ccnt, int, S_IRUGO);
复制代码
9 s" p) s( S4 {" U6 F L' t Y5 [* F: Z i& Q( X' E1 R8 n
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用) x2 q4 s8 h7 A6 H; }8 x( k
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。* b* p3 z# W" D, q
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。1 h* p8 I2 Z$ I/ X
2 h) \2 M6 M' y& G; ^7 b4 l, { ^- F6 T6 q7 O/ [% |+ L3 \
|
|