|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
$ G( x8 G1 @" P6 |* j- [code]EDMA sample test application
$ J# ~$ Y+ `" U- M1 w - /*; Y4 a5 [ y, K' @/ o/ B
- * edma_test.c4 C4 f! R( v6 s& \7 D0 ~' f
- *
9 Y/ K6 g- \+ g! _ - * brief EDMA3 Test Application
- F* w/ L+ ~) h - *
O- I/ u/ G% l+ v - * This file contains EDMA3 Test code.
/ f" v7 m" j3 r! a/ ?: [ - *( z2 h4 u E/ G4 N$ Y
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE' \+ |6 ]$ n6 f; a! J& E
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT$ F) n* Y0 a/ B: S7 S
- * TO CHANGE.
+ m# Z- g2 ? X% r# H - */ U) h8 C1 T% Y# Q- t
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/- S- z% @) O+ ?, I
- ** r/ I9 `4 h. Y" Q/ C" q6 [+ }0 E( T
- * This program is free software; you can redistribute it and/or* ]1 Z! ^3 s6 {* O- J
- * modify it under the terms of the GNU General Public License as
9 F9 A) d% z8 B1 w/ Y" O5 q W - * published by the Free Software Foundation version 2.
8 `/ E8 J% ^* p. m4 @ - *
& I, ]& S6 Y5 F% r9 d- b: W - * This program is distributed "as is" WITHOUT ANY WARRANTY of any7 K& ?- l& Y- v( T
- * kind, whether express or implied; without even the implied warranty
6 w3 T9 s) Z5 y. J: N' a" Y - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
" p& |' W4 P+ G% ^% G* j - * GNU General Public License for more details.) i0 H! ?7 `0 s) R' d
- */& @' k% q- w: e
! d+ y, B: Z l2 j" d Y. c- #include <linux/module.h>
* L. b# E* m( M. p - #include <linux/init.h>
" m5 g; m- n4 e1 T! e - #include <linux/errno.h>1 _" w& F t; ^( W, z
- #include <linux/types.h> f- Y( V2 N( t% {/ E( i
- #include <linux/interrupt.h>! u+ J k3 q! x3 ?
- #include <asm/io.h>$ n* f; L, u, r0 E% k
- #include <linux/moduleparam.h>: }. E4 p1 b, D, C$ E' I* r: F
- #include <linux/sysctl.h>0 Q% n% A" `# l" R' ]. j" H3 Z" O9 @$ y
- #include <linux/mm.h>
; i$ E E w( N6 A2 @# V2 C3 I - #include <linux/dma-mapping.h>
% O, I7 N& }1 S2 r$ B9 Z- h - 8 E; @' @. I; S8 V* ~
- #include <mach/memory.h>
4 Q6 ]4 j/ ~( S s2 n - #include <mach/hardware.h>
7 {, x' y$ k* I z) p* k" U. U - #include <mach/irqs.h>
( C- Z0 Y. k, m! G - #include <asm/hardware/edma.h>/ R6 R& w- i: V1 [* s) l# M
- ( W( e# l2 `1 E7 @" W% \
- #undef EDMA3_DEBUG
6 v0 `, F. Z1 y. R- J0 l& C1 R) g - /*#define EDMA3_DEBUG*/2 t& O1 _9 C5 C% j/ f% J
8 B$ c8 Q* [6 o' @# c' F- #ifdef EDMA3_DEBUG" B: D# M! @4 R+ i
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 f1 ^3 V& X x. }- E4 W4 k2 e, c
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
* `5 s$ ?; a e8 q - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): J2 ]; j: S) i( V# E
- #else
: L% Z' M) R* _' h( M/ [& ~! w: t - #define DMA_PRINTK( x... )$ b4 F1 `2 v2 R7 ?
- #define DMA_FN_IN. h: ]& b) H* _
- #define DMA_FN_OUT
3 G( Z2 G7 l$ y" R/ g$ @7 \ m( j - #endif9 T! `% `, Y# ?" @1 W# a, `
- : g1 V1 s( G" z: F. C- F( U/ ^
- #define MAX_DMA_TRANSFER_IN_BYTES (32768) K2 x/ r0 H4 {$ C) P& [
- #define STATIC_SHIFT 3
# P' W; g [; j& d+ B- P - #define TCINTEN_SHIFT 20
5 A3 ~7 m0 K+ M# d {' u - #define ITCINTEN_SHIFT 21
/ ?# w- w- B9 b; b& ` - #define TCCHEN_SHIFT 222 X( n* _" I% E( p P
- #define ITCCHEN_SHIFT 234 Q2 b. |9 H# u& O/ o
) u* O! \! ?* r4 V# C3 C- static volatile int irqraised1 = 0;
9 l+ b& a2 [" ~+ |* q" t - static volatile int irqraised2 = 0;+ E8 C( g/ q, }) y x, U
- 9 L0 i- J8 C6 j" p2 O5 X% h
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); K6 d# L( {7 Z' S4 m# }) z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% x1 }9 ?8 D6 P0 ^# l - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* ~% O3 m9 G2 r6 C
' @0 Q% a# v8 x6 @- dma_addr_t dmaphyssrc1 = 0;
1 {! H$ T+ m U: O - dma_addr_t dmaphyssrc2 = 0;
C# _% l6 M$ U - dma_addr_t dmaphysdest1 = 0;
' r, _( d* N9 J* L. } - dma_addr_t dmaphysdest2 = 0;
# @$ X& K7 I+ C# I3 u - ! \. M! X3 X( C0 ^9 n
- char *dmabufsrc1 = NULL;" [) D$ I; l- [2 k. j
- char *dmabufsrc2 = NULL;
! X' j [9 T4 S9 V - char *dmabufdest1 = NULL;3 b- V2 }7 ^# i. @7 R& Q! d- U
- char *dmabufdest2 = NULL;+ j; l" M$ t3 n' l5 t1 D7 W
% B* r( M3 j. v% r2 _- static int acnt = 512;
6 {( W4 B3 L4 Z j5 C. v4 L - static int bcnt = 8;
. v: `; ]. @# T, b5 k - static int ccnt = 8;
W/ ?3 Q' m" L - % }5 ~8 K' h7 G' W/ C$ @: P- s6 T
- module_param(acnt, int, S_IRUGO);
9 ^; n+ U/ N9 c" ~4 X& a - module_param(bcnt, int, S_IRUGO);9 ^8 Q* Z. k3 U8 k( M! O
- module_param(ccnt, int, S_IRUGO);
复制代码 ; t" w; I( K8 B ^, G: D$ P( q
2 y( S; }0 O+ j W* ?! w9 S1 ? 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 m1 M" ?0 c$ j. ?, a+ ^9 marm-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 Y e# |; c* Q 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" M, V) w* f- W6 L9 O( k. `
* o' x' R* I9 A; S4 V6 Z( I( x. c
& a, w8 @2 h" o |
|