|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 % B n+ C* U" I4 |. E
- [code]EDMA sample test application/ e8 l( I7 T& S
- /*
% |& K! K5 A' c# y9 v+ D+ t - * edma_test.c
+ C7 k3 a/ ~+ [ - *
! _" m# p; o, J3 b - * brief EDMA3 Test Application
* D1 X' s3 B% k3 n, i: a8 o+ h - *0 d5 ~6 L: H' b2 C+ d
- * This file contains EDMA3 Test code.
+ y* M. C7 s. J+ Q2 J+ ~8 ~ - *$ R' v- w+ Y6 _& H+ x! T# Z
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE4 w) }9 M0 n5 ?9 w! P
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 |5 Y/ a+ F0 a+ B, s. }% v Z
- * TO CHANGE.
6 [ v5 F; E8 ^% {9 L) @: X2 A - *
, R/ v D8 N6 I; _4 Z - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 z# G" ?$ w6 }) w v
- *
* Y& }, ?2 A- U' U - * This program is free software; you can redistribute it and/or
- p7 \6 o2 ~5 M+ H! ?, n - * modify it under the terms of the GNU General Public License as+ D) c1 z& {0 v3 N6 s; e4 X( ^
- * published by the Free Software Foundation version 2.( Y* a7 ?4 x% Z: V+ O2 j
- *9 J) V( K& w, _- W5 O
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any; F& i% C* H, @, Q3 G7 y+ \4 l* g
- * kind, whether express or implied; without even the implied warranty
. D* g4 C/ p: r9 U8 y - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the$ _3 { B* S6 n! ?# G+ m' ] _
- * GNU General Public License for more details., `, F9 k3 J7 f5 ^, a4 L" N
- */3 Z4 Y! d; e8 o5 \" G/ O) n; ~7 p
- ( U3 Z5 X, x" c! \& ^6 {- f! _
- #include <linux/module.h>
; {& b$ P4 k' V3 b: X! G - #include <linux/init.h>1 u# f: |3 e9 G; w; z; s" C
- #include <linux/errno.h>" M- f4 D( |$ R* D( K, J
- #include <linux/types.h>2 Q8 {# I3 w: _! h2 _
- #include <linux/interrupt.h>
& s2 k- y7 l: N" d - #include <asm/io.h>) \# @+ f+ L/ Q A2 G {- E
- #include <linux/moduleparam.h>% A9 t \2 {. m% U! V- E( T0 ^4 O
- #include <linux/sysctl.h>9 U& X- @ s/ z9 S7 x
- #include <linux/mm.h>& |- P3 N8 y( [1 Q* S! C8 V
- #include <linux/dma-mapping.h>6 r2 L6 P; j1 R, I. w) e
- ' K+ c3 \( a' r h F* X$ o
- #include <mach/memory.h>) O5 {/ D3 k2 o
- #include <mach/hardware.h>
- r9 K) P! G" l - #include <mach/irqs.h>: @8 c& \. J0 w+ E* z
- #include <asm/hardware/edma.h>
2 J9 n* y' k* p - & \$ S& b3 v. L1 v7 T( ]8 m+ I6 ]/ G
- #undef EDMA3_DEBUG
, G. M/ O- ]( i( U: {+ N9 U/ k7 W - /*#define EDMA3_DEBUG*/7 ~: @) C$ G. p: l, Z+ _0 A/ i) [2 S
- 2 u. s- v; x0 }7 b- W$ k# V5 d z
- #ifdef EDMA3_DEBUG/ p0 G' z' o+ O; j* K- Q( U3 p! f
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
( y; Z+ D5 ~8 ?; v7 R; ]# S( ~9 g - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
9 q4 T. r- R* i# Y$ Q) h6 P - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)3 @6 r0 I' ]/ ^: Z+ X6 g6 {& ~
- #else
8 c4 S6 ? g+ i3 Y. L' u: e# H - #define DMA_PRINTK( x... )
f" s: u4 ?0 _7 q9 N - #define DMA_FN_IN
) Z7 [- D9 T$ R - #define DMA_FN_OUT) ]& d* z* a# Y7 j. Q# ]
- #endif
( P. O& Y2 @6 j( p9 E t
! J z/ i3 s" ~& {) x& z4 S+ Z- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
! t0 `! @0 w7 f3 J& i - #define STATIC_SHIFT 3+ j x# y; o# X5 r* _1 U
- #define TCINTEN_SHIFT 20
6 f( z$ a* t6 d4 V4 x# e - #define ITCINTEN_SHIFT 21% F9 X- p! m, a `3 X% T! S% U
- #define TCCHEN_SHIFT 22
- D! l% j( N) w - #define ITCCHEN_SHIFT 23
# B" |0 U, T) d: O
5 @7 w2 B. k! T0 r/ l- static volatile int irqraised1 = 0;
" D5 K1 X; R% s* {6 g1 c - static volatile int irqraised2 = 0;
7 q, B0 w, k+ E1 B* v& g9 L8 y
& ^0 ]: y3 U4 } e+ s5 \# t- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 e+ a! R5 i* x9 K9 ^
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% G" N6 l/ ~6 y
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; t$ F5 _, f* X; ~* H9 ?$ D% a
1 z" S, H+ e- J4 S- dma_addr_t dmaphyssrc1 = 0;
5 |0 D5 s) p: R3 z - dma_addr_t dmaphyssrc2 = 0;
$ Q; d2 x0 Y0 \8 x - dma_addr_t dmaphysdest1 = 0;
6 r, v, ]/ e$ R* F- e' F' j - dma_addr_t dmaphysdest2 = 0; x& |: \8 p( A, N. @2 o; X& V l
- ! R3 n! k) B' m' L7 F/ C
- char *dmabufsrc1 = NULL;
( z7 V& M/ ?. f+ Y2 o) x' O5 R) T' F9 n - char *dmabufsrc2 = NULL;* g5 S& O4 k+ x8 X" _# @& F3 C' g
- char *dmabufdest1 = NULL;) i' Z `" {1 z$ H& k C; Z
- char *dmabufdest2 = NULL;
$ ? j' |" o* H- G( d
* ^- C" b( F& m' A" {+ n4 l+ G- static int acnt = 512;
1 o: n! A$ u a4 @% F - static int bcnt = 8;" M1 C; q) R$ ~2 {6 E
- static int ccnt = 8;
2 D; z7 F* m# u3 \, o+ x$ O& o j, \
# v# s# n. i, \7 n( H2 f- module_param(acnt, int, S_IRUGO);
! i2 U. A( y9 J/ X9 `& L2 @7 t - module_param(bcnt, int, S_IRUGO);
+ C& Z3 L1 R% y* ` o - module_param(ccnt, int, S_IRUGO);
复制代码 3 [, f3 Z: m9 m9 [
$ L2 \% V+ s0 G9 v3 n/ [7 J 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用6 _- ~0 ^2 c* d$ b
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
3 {0 j `' ]6 p& ]: K9 v 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
0 @2 a8 r8 M f T A1 c; J X+ j& @
4 m q# \2 F {# ^! K8 h, i1 b( E |
|