|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : {( B& j: C5 v* Q( U7 L
- [code]EDMA sample test application
# n$ P, X7 J6 q% x. g' o - /*
1 t3 ~; x' I H' i - * edma_test.c
! T5 u. D- Q- w9 ^. q3 e - *
3 t" u" a% }. X1 X* w5 ^2 h - * brief EDMA3 Test Application
" X0 T# P( v9 V6 X b1 r: Y0 n, q - *) i. W4 U' Y3 ?# E7 d$ T' R
- * This file contains EDMA3 Test code.8 O7 U; }* R# m
- *
; D" J, s* V3 X& o9 l3 U - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE( ?* E0 S5 B" u/ [# o7 f
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT) }# }" j; H+ K
- * TO CHANGE.. z% Y+ B9 L z
- *
" B1 s& Z4 x3 G# {( N7 @ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ @4 M- r$ s X
- *: s5 v- x; O1 r3 q c9 _
- * This program is free software; you can redistribute it and/or
0 c$ [" t1 L6 x5 S# Y. C - * modify it under the terms of the GNU General Public License as
; U2 d2 j( D& b - * published by the Free Software Foundation version 2.
( D, B- H3 E2 W& n- v2 ^5 i% j% | - *
" H6 X) q1 l+ G# w - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
5 C2 s9 @& `! t- D - * kind, whether express or implied; without even the implied warranty! g4 G( J; k. L# @
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the! {: M/ U" k4 [* n2 @
- * GNU General Public License for more details./ q( O( w, z2 ^4 k
- */, z3 x+ W8 @, |! s/ T( m" Z' g
2 R; c1 \" v% |# k- #include <linux/module.h>
4 O# a4 m7 `: A - #include <linux/init.h>- m2 R7 f+ L7 Q$ R
- #include <linux/errno.h>
( o0 d0 S! s" q/ p - #include <linux/types.h>
. A7 o) {) |% z; Y, s - #include <linux/interrupt.h>+ l- g! q' P: e- j
- #include <asm/io.h>& J2 l2 M, l Y( v0 S% j, `, y' z
- #include <linux/moduleparam.h>
8 N- A# _% h' [% l N, `0 M' m - #include <linux/sysctl.h>4 t2 q6 O$ B6 H7 F. Y& q
- #include <linux/mm.h>
& F0 p+ R* Z* B/ X7 R - #include <linux/dma-mapping.h>' y L: O% t0 `! {2 N% ]0 A- \1 {
* X" E% I2 V7 K( M4 V) `! R' Z- #include <mach/memory.h>) c" f+ I2 i5 i5 f8 k
- #include <mach/hardware.h>
7 |8 g* [* `( i - #include <mach/irqs.h>' f" Y& D6 R) [, l' Q
- #include <asm/hardware/edma.h>
. o$ R& ~2 X3 M* R* Z! [ - + d8 v# K1 W$ I) ?3 c9 m
- #undef EDMA3_DEBUG2 { _$ v3 `- A
- /*#define EDMA3_DEBUG*/
/ F$ Y. f$ z2 U$ J, G1 t; e
" ^; o) M9 W( Z" C- #ifdef EDMA3_DEBUG
+ H; K1 Y% k) a0 {: V - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)" ~, {; z) t4 f7 U7 p3 E
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
6 x8 N9 b1 w) f - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
' ]2 ]* i! ^" K& L d - #else
. ]% n. \4 C, }( M9 V& k( i - #define DMA_PRINTK( x... )
$ T% K8 Q$ H0 X: A6 ]$ W$ S6 l# F - #define DMA_FN_IN1 u+ g3 X6 f9 S) ^
- #define DMA_FN_OUT# ?$ ? o+ @% K' e4 p
- #endif
6 R7 ~6 ~5 W5 d+ ]" e - ) i% H r, j1 a1 a/ c# S: r
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)% r8 p- {) C' b3 W/ u$ J. `8 Q* \/ C
- #define STATIC_SHIFT 3
. ?, S: p$ T' f% V. V) Z - #define TCINTEN_SHIFT 201 {0 [' x8 o, X8 A. h
- #define ITCINTEN_SHIFT 21
r+ M$ t$ L8 b; n - #define TCCHEN_SHIFT 22
7 t7 V+ n% b8 N# r" i - #define ITCCHEN_SHIFT 23
- o$ f0 E% j$ x7 S. {4 D - - e+ O# k/ D( V: c
- static volatile int irqraised1 = 0;( D$ V# U/ M6 d; U3 b
- static volatile int irqraised2 = 0;
5 @4 ~3 J& C' r+ z! m4 ~6 U
; O4 o; r* x0 p) H; W- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);$ Q1 v) k# A5 M0 d/ x! _
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 Q( G) x9 m! i - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& l3 Z, `8 g$ `6 N
. _$ C' V# N8 ~- dma_addr_t dmaphyssrc1 = 0;% k8 P6 Z: y: d0 Q! {0 I& B+ | ]
- dma_addr_t dmaphyssrc2 = 0;
! s& V- P$ w9 l" Y! C A O! q* i - dma_addr_t dmaphysdest1 = 0;
, {7 } G! Z7 B8 D* S1 A) j - dma_addr_t dmaphysdest2 = 0;
! n+ [+ S+ {/ p1 ~- ]/ i, ` - ) @4 n9 |# C& H; u( R
- char *dmabufsrc1 = NULL;) d4 [* z+ z( g( A1 w3 ~
- char *dmabufsrc2 = NULL;
/ I. w& J1 `" K( N9 d- c( P, M - char *dmabufdest1 = NULL;
) ]& F2 m& R+ T# Y - char *dmabufdest2 = NULL;
5 k ]( ~; a! `4 _9 e+ R) p8 y - ( R+ o% q; h0 n/ H
- static int acnt = 512;4 a- r) N) m& V( G# J
- static int bcnt = 8;
9 V# O6 E/ X7 b' B9 S8 j& h - static int ccnt = 8;
/ y; G# ]8 K5 Z+ ^5 k' r
) M7 ]/ Y ~" ^- O( p' h- module_param(acnt, int, S_IRUGO);
* z4 u- ?" A, T3 Y! u - module_param(bcnt, int, S_IRUGO);
: N* @1 P+ P; p; d! a - module_param(ccnt, int, S_IRUGO);
复制代码
$ K$ k, y$ V' r8 \& U5 o$ h; t9 J
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用1 O/ O: x, |# H# V' j3 i6 F. ]
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. v+ `9 W2 t8 c6 v6 C* D. g$ v 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 E! V/ R+ U) s4 A2 P' ]0 s/ Z% h& G% r6 n, W5 E6 \
* a( o% k E+ S- H) X( @
|
|