|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 2 U& V) Y9 F. b% [) L! G
- [code]EDMA sample test application
7 f) f1 f1 V' L0 A0 F - /*
9 @; j R) ?4 r6 b! M, B' Y& S - * edma_test.c
2 I% I0 S( T/ W8 } - *
6 Y) j0 K, k5 o( h6 v: X - * brief EDMA3 Test Application0 g2 A% v n0 F1 \. K
- *
# G1 [: I$ B# n% S! l - * This file contains EDMA3 Test code.9 H" N" X' D7 n ~$ T
- *
( q* }0 r4 P9 o, b% ]# [ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 a2 ]; l/ I/ h6 h, ^* j - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" A0 B4 v& k& U; e5 u# e, x4 {) F
- * TO CHANGE.* l0 q" \. l1 U" ^6 o& a- Q
- *
. c; k, O4 k1 {$ i% E% y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ d6 P% ~1 P! h$ j C4 M
- *' D, V# c5 J! {! v% ~) d
- * This program is free software; you can redistribute it and/or9 O& c7 N- f$ Z. q) k6 w: o" O) {7 _4 b7 p
- * modify it under the terms of the GNU General Public License as
% ~$ j% E! ]3 R2 V/ Q3 E4 p6 Y; A - * published by the Free Software Foundation version 2.
$ m# Q5 T8 n3 J2 a( Z" o - *8 G% w7 _# A6 V% \
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
) P. |2 P) \; @4 f! K/ x - * kind, whether express or implied; without even the implied warranty8 Z; g- z3 p: f1 N# A: W) k+ [, {% J
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3 g2 }5 Y- {* x8 H - * GNU General Public License for more details.
1 Y& ^/ E# D% Z9 z' o$ Z5 G - */
& ]2 L, _4 ]5 |! a) f+ R# t, p
8 {# Q: U, U( p; X2 O- #include <linux/module.h>
4 }* w" x5 v6 z' u4 R# F# ~5 K - #include <linux/init.h>; ` P* z9 Y0 @2 t- S
- #include <linux/errno.h>
5 L4 m: W! b; ]' {: X7 O O - #include <linux/types.h>
) R5 B" q( g# e" B6 h$ k4 L' Y - #include <linux/interrupt.h>, Z4 y0 t; U$ S) Q' U( K5 d# {# X
- #include <asm/io.h>3 s' n7 r V- o' h5 h
- #include <linux/moduleparam.h># @# w: Y- H( g6 |; F9 E
- #include <linux/sysctl.h> a# M8 x! f: }# A5 e" w
- #include <linux/mm.h>
. B1 b! K& y4 T# z - #include <linux/dma-mapping.h>9 O1 J5 e2 s7 M
- & ^# c, Z7 e# ?8 O! T
- #include <mach/memory.h>4 Z) i3 \* p7 \$ k( c v
- #include <mach/hardware.h>
! O) ~" _+ Q1 C$ F' N - #include <mach/irqs.h>
' w+ B5 D7 o; J8 R. m v, f) b6 V - #include <asm/hardware/edma.h>
" F6 i) A% R( F$ F5 q% J9 ?# T - 2 x, v! c) p* c
- #undef EDMA3_DEBUG/ x8 {) f) F+ ?: N6 l/ _( j
- /*#define EDMA3_DEBUG*/
# M0 f: @' ]6 o' `4 F f
0 i( m/ @" W0 l! O$ F- #ifdef EDMA3_DEBUG
) S( o( a! S7 \4 K- H- g - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
" E$ C: @ Y5 ]4 t/ \4 [( A - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)2 J. c$ r: Z5 K/ F( a) c: m/ i
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
0 @+ x, g1 ]5 B- M( u, @ - #else- W( T3 m% v0 ]" O9 ~. a2 A% G8 ? n
- #define DMA_PRINTK( x... )" i: t! G x% ]3 d# g2 q7 J; I: U
- #define DMA_FN_IN
, {8 R3 ]/ P ? - #define DMA_FN_OUT! N1 M5 f% o2 i1 b8 \
- #endif3 g7 |9 Q! o" _' C
: {2 M4 e: l% ?1 B; E, J- #define MAX_DMA_TRANSFER_IN_BYTES (32768)* A, C) C) p# j/ o X+ @ x
- #define STATIC_SHIFT 3
! h% X$ r4 C& ~# w k) @# F% ~" } - #define TCINTEN_SHIFT 20, [" _5 Y% W. E& ]. G( M8 P$ o
- #define ITCINTEN_SHIFT 21
& X: I6 a7 f8 d3 x) r6 o - #define TCCHEN_SHIFT 22: m/ A$ T) V) h% {3 ?
- #define ITCCHEN_SHIFT 232 S& w+ G2 n3 y6 D' J' b
- 3 W( o. v' \ Z# L: K
- static volatile int irqraised1 = 0;
+ A$ M" ^" `4 y5 u - static volatile int irqraised2 = 0;
2 s/ n: C# g( {& y& \ - , i+ t$ G1 D* B& J( M
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* C1 g$ U2 Z( `" b+ N; z9 m1 @
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! x7 {9 b7 D* {" h/ G4 d- I4 B/ _ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) D# b8 s+ F9 H$ F4 |: t0 u
- 8 h/ y5 l7 Z( X+ k. W* ]
- dma_addr_t dmaphyssrc1 = 0;6 q2 B# J% l/ c3 }) i( \
- dma_addr_t dmaphyssrc2 = 0;
* D" e5 I, S1 }: p% u - dma_addr_t dmaphysdest1 = 0;
6 i! b" I5 l1 |5 D j/ o" k - dma_addr_t dmaphysdest2 = 0;- o8 Q# `9 u( W1 k' M
+ S/ I9 @( F: `- char *dmabufsrc1 = NULL;& M1 O8 x3 O& A( p
- char *dmabufsrc2 = NULL;3 P( H( h& \( S$ S: [/ ]2 ?5 [
- char *dmabufdest1 = NULL;
9 t; K w: b" i. V. Q" ^ - char *dmabufdest2 = NULL;, @, Y1 W! j7 L; e5 i* n
8 v0 d4 v0 h/ y: f- static int acnt = 512;6 E/ j/ t$ z: M# f: r0 w3 _
- static int bcnt = 8;) U7 ~" J, z7 T# v7 ?( N: W
- static int ccnt = 8;
0 a- J4 d) [& L' l# ? - ! Q( c1 Z" n( i' M
- module_param(acnt, int, S_IRUGO);
9 e; h! T T6 b1 r( |2 o - module_param(bcnt, int, S_IRUGO);
6 Q1 V- L+ ?2 g' S) \ - module_param(ccnt, int, S_IRUGO);
复制代码
" L, L1 A* d: y2 l4 T. a
& _ i& Z# r+ B* p/ m0 C) n 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
T; j" c; p/ r- p& n B, 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
4 y7 Q, y! y9 u x 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
" N @$ F5 P& O; t: J- e3 t |
; ]+ w7 a0 R+ J2 a2 l Q/ K
) M2 E1 o% L: b/ e) W |
|