|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : j5 P$ G+ z/ A" [# ~
- [code]EDMA sample test application$ L9 k! [# ?1 L" N4 V3 T- m
- /*
/ k. [' b% v# G& \6 } - * edma_test.c
" e# k% v# B# Q6 e- Q - *
. w$ p3 W/ x% E6 J - * brief EDMA3 Test Application
( r: D4 s6 F6 i - *
4 P! V+ ]+ [2 g5 _4 b7 [0 \ - * This file contains EDMA3 Test code.
) i; @( E: U- B$ ~ S7 Q - *% I% b x& i0 O! ^. q
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
, E7 Y+ B4 M/ N4 M: l! T - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
. Y# y; {# `0 b& y - * TO CHANGE.' e& T, X1 A; H- O
- *6 [3 {) ~7 _3 x0 K3 G, _. f. f
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
$ e5 U/ ]0 f) y! c) \8 U6 v) }3 V% E - *+ k# w4 D8 a ~" t
- * This program is free software; you can redistribute it and/or
; N% m3 o" X6 Q* |8 U# g* |& [ - * modify it under the terms of the GNU General Public License as
! {; t) N7 P0 f3 S/ w9 D h - * published by the Free Software Foundation version 2.: v+ G# y* k& E) q- j
- *
/ n5 `+ l R9 ]/ N- K) ^ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
3 Y% e8 U* M: i0 ~( z7 v - * kind, whether express or implied; without even the implied warranty
5 J& R+ U1 B, d - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the' F1 T: Y% n9 m& g) t( x/ `
- * GNU General Public License for more details.
+ E$ |: v4 k( j - */
2 Q& s. g3 \8 F6 g$ M - 7 I5 j. P4 }8 \3 `
- #include <linux/module.h>
! Q7 j) K* |" c9 U7 q( Y - #include <linux/init.h>
5 d! F e. b# R+ t! v6 Q! Z* e: L1 C - #include <linux/errno.h>
" ^3 t$ \3 y* I& a9 Z4 p - #include <linux/types.h>
# \2 Z' h9 q( x% w! D - #include <linux/interrupt.h>" a$ x; k) Z; Q/ f) H8 ~" X
- #include <asm/io.h>
1 ]3 V9 b& Z) a6 f+ u: O% t( K - #include <linux/moduleparam.h>
6 ~: P. Q d: Y( g0 _4 H8 [8 l - #include <linux/sysctl.h>
& Z0 g/ s4 | t! f5 S# ?. w& g+ a - #include <linux/mm.h>
; [1 I; E* H4 V; w - #include <linux/dma-mapping.h>" L3 w& l2 l9 B) D; C, u8 l1 S' d
# M9 m9 ? d; [: j) V' D- #include <mach/memory.h>
* B+ f+ p8 _5 h' m - #include <mach/hardware.h>+ A8 j* y$ D, Y- I
- #include <mach/irqs.h>
0 V/ V r1 C# k% s4 _+ K; c1 h, D - #include <asm/hardware/edma.h>- Q5 v9 V/ Z1 H4 K4 m; V1 ^8 n" f
3 m3 `0 d3 H7 L- #undef EDMA3_DEBUG$ Y. e' c/ w7 }( S) F
- /*#define EDMA3_DEBUG*/
! }+ ^5 J6 K% _2 F$ s - 5 n- t" H, \4 @4 |1 `, z, b
- #ifdef EDMA3_DEBUG
! K3 P. K7 K5 Z1 q - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
9 ?" O. d; U4 T* o+ p, p" v - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- E! }' N: P2 [! `3 e, [. b: V - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
; E2 F4 A1 [4 l - #else
0 w) o' y. K5 |, e - #define DMA_PRINTK( x... )6 y5 _! l& Y1 u5 C' Y4 G5 m; Q
- #define DMA_FN_IN
: A: f3 G! O! l - #define DMA_FN_OUT0 `( h: }/ I% \5 _
- #endif
+ y1 |& y) @1 v4 D1 G. g* s+ ~- u - 2 T* k& j- ? @) z5 q' X( F- o r: x
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
, f# ~& E* ~. x" P g! t& G - #define STATIC_SHIFT 3
( C" v) b1 s2 A1 o; a0 M - #define TCINTEN_SHIFT 203 C- o! m8 F# {: \5 e
- #define ITCINTEN_SHIFT 21
& e; d# f/ }2 N g/ `3 u0 u5 G - #define TCCHEN_SHIFT 22
8 [. M2 F4 ~0 U. |6 h% h3 M - #define ITCCHEN_SHIFT 23; z9 J0 ]6 L2 L4 v' R: I
- 2 f; ~) _4 @5 ~3 m1 m7 r) B
- static volatile int irqraised1 = 0;
! Q! Q9 i$ D. J/ c - static volatile int irqraised2 = 0;( O2 y* O v* u3 B$ g* V+ b
$ z. h9 D# y' p% d) x+ h1 n6 T- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 [. i+ M* K5 L1 ]$ Y& V
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; `' Q' F9 m. o; G$ N! ?. ?, a/ \
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
5 P' J: F, f; V - + D. V9 r) P2 x; X0 |. r6 J- k
- dma_addr_t dmaphyssrc1 = 0;& A9 D4 a1 C" A/ S& u
- dma_addr_t dmaphyssrc2 = 0;% s- V, H9 u' l
- dma_addr_t dmaphysdest1 = 0;
' T4 k8 N4 D) H: G: |" b - dma_addr_t dmaphysdest2 = 0;* N P. T/ s- y9 a" L% ~
. A! _; _7 G, o6 m* E2 n1 P4 [- char *dmabufsrc1 = NULL;7 d" w% G/ c: h- Q6 _9 O
- char *dmabufsrc2 = NULL;$ M9 m/ ]2 e) v7 f! ?! }% Q. [3 t! G
- char *dmabufdest1 = NULL;
; x( y, g% x v8 O# ` - char *dmabufdest2 = NULL;
/ e; b3 k9 s; E1 \/ h+ n - . y7 a% s0 J# Y/ N; I7 d& ?$ q
- static int acnt = 512;# T' @7 ^# v4 ]% k* P6 o2 O8 l, G
- static int bcnt = 8;. K( x( {' R+ L$ m
- static int ccnt = 8;0 a3 U( p% {! L
- & s7 Z+ i) w, i% ^
- module_param(acnt, int, S_IRUGO);* u: m+ r$ i$ U1 `( a+ Z
- module_param(bcnt, int, S_IRUGO);
7 E% a: x; e5 l5 K" n' j" A - module_param(ccnt, int, S_IRUGO);
复制代码 ! G, A3 r2 Z3 ]! m. s& s
1 E$ I) w3 C8 k, |% z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 s. b8 v9 H$ @6 w/ 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。# _$ D" ?; I, o! q: [
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% a+ F( \$ B9 e6 V1 l+ u0 F' ]
' q: n( q0 Q, h% [- s3 y( _; L9 @
4 t2 B9 `! f6 [# Q. Z/ ] |
|