|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ( ?0 }0 P4 J$ }$ i& }
- [code]EDMA sample test application& G2 x. }0 d) y4 o% H9 C, e( i
- /*
2 e, O) T x5 a - * edma_test.c
* H/ M) n+ F5 C5 K# b. Q - *- S2 A% K! O$ X9 j) _
- * brief EDMA3 Test Application* p" A9 E# p& Z: F3 ?. ]$ |
- *' c; E0 N; Q" F7 @) |
- * This file contains EDMA3 Test code.4 ^+ E0 [; M" O5 S* ?
- *
U. Q2 b6 Z* Y3 Y - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
! e: i7 e; {: g - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
& R# S/ @: W. K/ D5 Y" V! j6 V - * TO CHANGE.8 l; f4 {6 u) Q5 |9 H
- *
4 O" Y: t: v) } - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/+ X) @, @2 {& O7 m4 T3 w
- *
! ~& k+ L. z1 y5 |5 W, `$ B - * This program is free software; you can redistribute it and/or7 ~9 q" h$ {! Z& A1 v! ~
- * modify it under the terms of the GNU General Public License as( @5 Q) L9 h2 n
- * published by the Free Software Foundation version 2., x. I. D$ r4 Z. k8 p7 ? A$ A2 L
- *8 I$ q# c$ w' J
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any5 R! m$ A @+ t5 [6 z2 E0 C
- * kind, whether express or implied; without even the implied warranty
: M! z8 N2 Z; }6 m) B - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1 D4 z f, \$ O- d - * GNU General Public License for more details.0 f# S; D. z! r9 Q
- */
3 l2 b3 k4 T4 U3 }. H2 V - $ Q, R O" t0 Q! `* E' \7 p4 w- @
- #include <linux/module.h>
! b% e8 {( I* o4 } - #include <linux/init.h>
8 a: {! z: v7 J& R# h+ W6 U3 } - #include <linux/errno.h>
2 n7 `" ^6 ^( B# O5 p# k - #include <linux/types.h>
7 ^* o: ?; d3 f: C - #include <linux/interrupt.h>. w5 A- O& l) d" u, E
- #include <asm/io.h>
7 x( e$ g* w- k+ L& X# ^' S% x! K - #include <linux/moduleparam.h>
8 a5 L1 n. o9 M( ~- p, ^ - #include <linux/sysctl.h>
7 t- J# ]9 e+ a, @% v. K8 V, R - #include <linux/mm.h>) G2 d$ j. L5 o9 ~$ `8 @
- #include <linux/dma-mapping.h>1 i C4 V6 N# `2 X
/ C& p2 H: Y% c, P2 P- #include <mach/memory.h>+ f. t$ u( a; T" W
- #include <mach/hardware.h>/ e, ?( `8 c6 Q# P3 A3 c! B0 z
- #include <mach/irqs.h>
* @4 h. J7 h* c8 w" c) Y* l3 G ~ - #include <asm/hardware/edma.h>& L6 I* I/ d. O$ O
- ) f" c" Q# ], w( l' x9 ]
- #undef EDMA3_DEBUG
$ Z; E- i! G" Q, |: O7 Y - /*#define EDMA3_DEBUG*/
6 l5 u5 S# {' a. x+ ]4 j% |
( U0 ]/ ?9 y/ Z! X- #ifdef EDMA3_DEBUG( m/ C4 x% f l1 f& T
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). V! n" o4 H7 ]
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), ]& B, N9 f& y7 @
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__), w% _% d/ g: a) r( p2 f
- #else
( h% q6 f; u* S. ?4 m, D - #define DMA_PRINTK( x... )
" u% d5 b; h" B2 V$ a& ^+ r# U - #define DMA_FN_IN
( ^ \# S i g( g/ c4 K - #define DMA_FN_OUT. E( G6 @3 g2 h
- #endif
( j$ w8 Z& u' }0 A - ( ^: W) H$ j% s3 x, G9 _
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)4 e9 s. q8 e5 B1 S {
- #define STATIC_SHIFT 3% j* O) Y# U8 K
- #define TCINTEN_SHIFT 20 G p1 K! U9 ^+ u! f; f& W
- #define ITCINTEN_SHIFT 214 f @" V+ Z- b5 }: k- ?) d
- #define TCCHEN_SHIFT 22
* p" y3 W8 U- M$ i* ^ - #define ITCCHEN_SHIFT 23' j9 A8 m3 t! G1 H( B3 O/ n
- ( C: r% `7 x6 p
- static volatile int irqraised1 = 0;
3 A7 Q6 r! j. }# S& |5 n* u f$ ]8 P& q - static volatile int irqraised2 = 0;3 A9 \ n/ `! J# S/ b
- ( T0 c! S. m; g" N
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- ]$ N+ C. B+ i% g* @4 p
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 T9 Y4 a, v6 l; X, @ - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ e; K* \$ d- i7 l& y
& D& P1 N; Q6 ~- dma_addr_t dmaphyssrc1 = 0;
/ N4 M( T% z: k - dma_addr_t dmaphyssrc2 = 0;
7 ?5 O' \" a; i$ V( W* K1 Y$ q8 W - dma_addr_t dmaphysdest1 = 0;
- m/ ?" [4 d, t+ ?9 x- V7 o6 w - dma_addr_t dmaphysdest2 = 0;
+ ~( W9 O9 s5 K) j4 c. T - , J0 C& l5 o- Q3 [# H
- char *dmabufsrc1 = NULL;
$ E. A/ X6 T3 p" t% M( |+ d3 J - char *dmabufsrc2 = NULL;
/ m+ `. e% y6 Q. D; ^: d( F) D - char *dmabufdest1 = NULL;: C% u/ i# t5 W3 N, M
- char *dmabufdest2 = NULL;
; V1 A$ z4 B" l
7 s3 A6 @% a* T" ^" K, ]; S" r- static int acnt = 512;
* U0 n1 Z' [3 i: k) s$ D m - static int bcnt = 8;5 f1 ], `7 L: Y, u$ t+ q
- static int ccnt = 8;2 h( }" A Y6 T* u3 w5 W0 x
. a w5 w1 H! r5 z- module_param(acnt, int, S_IRUGO);( }) x* X* b6 s# P* X( \% E4 ^
- module_param(bcnt, int, S_IRUGO);
. Y* Q" ~8 r" K3 c3 J - module_param(ccnt, int, S_IRUGO);
复制代码 # J+ a5 F3 |3 }
# [/ a, w7 G" L
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 ^2 c$ }0 I4 w% ]' {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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。0 S' t3 J! T( l0 `+ W* X! K" t. ]% M
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。: V8 g0 X7 `% N+ y9 D4 |
$ A) u6 M, _( d( i5 G% [; C
% h4 x r" \& s" |4 h |
|