|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ! k0 ?* _ t! [8 D) O( j0 D
- [code]EDMA sample test application
V2 [6 ~) m8 m5 N - /*9 M3 K( S$ k/ g
- * edma_test.c
. G3 x; x1 s8 j - *
0 `7 i* ^2 H" [2 |8 {% }5 G% a2 R: f/ @4 i - * brief EDMA3 Test Application& [9 Z0 {. A- H
- *
2 B% P( ?' j2 I' U( \: J - * This file contains EDMA3 Test code.. o: m" v# H/ y) l, x' R, m
- *
- \7 k) e( r2 B0 f I9 b - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE/ p2 b, f. D) N# Z* S$ ~
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT, P% A& W) b2 d6 h8 k K& {" B$ @
- * TO CHANGE.% G/ [& E) T4 A* u
- *
% n3 d, }$ x2 I; t; H0 O - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/! ~7 B2 o3 t" k; l
- *
7 s% n/ K" T" h& m1 ?, n' K% F - * This program is free software; you can redistribute it and/or& t1 n9 E$ ^+ T1 b9 v. T
- * modify it under the terms of the GNU General Public License as% x0 `1 x b% M
- * published by the Free Software Foundation version 2.
7 U6 U8 |4 K7 w! U/ y - *
6 w( |4 ^" `: q, M+ _, l C0 S - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
; S2 v; _# K; { p5 [: c - * kind, whether express or implied; without even the implied warranty, g$ L# x6 F) }0 w
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the3 s; ~" N; Q# z, H1 D; q
- * GNU General Public License for more details.
, [' s- d8 K( R' C) n - */2 r( `9 P% P, V9 i. t G
- * P" z- b! L- l: r) x& L9 @
- #include <linux/module.h>
3 w8 @- @7 n5 H5 A - #include <linux/init.h> p7 V. d" b1 H) X1 u& ?
- #include <linux/errno.h>
b6 t5 K- X8 b* e - #include <linux/types.h>
# W$ y% m% B3 q, J2 A) ^ - #include <linux/interrupt.h>8 ]9 H) Y2 A) E
- #include <asm/io.h>' f$ G- ^4 O0 T- v6 L7 S
- #include <linux/moduleparam.h># f9 z9 B3 c, z, x5 I
- #include <linux/sysctl.h>
, S' F2 \2 a0 D7 G' o. { - #include <linux/mm.h>( Y$ ~1 Y. y" t4 R
- #include <linux/dma-mapping.h>
/ X6 h3 S! E# _- _3 D
" `! Z2 n0 Z; h. @. c- #include <mach/memory.h> o, H, s. |6 \/ s. i' `
- #include <mach/hardware.h>
& J# P- f3 [6 `( i5 @ - #include <mach/irqs.h>
; Y# ~7 r- j2 G: G1 E2 ^ - #include <asm/hardware/edma.h>
* O0 g) w% C. f/ K/ H- k
9 u, m- A0 B) T9 A5 D! h6 L- #undef EDMA3_DEBUG
) n6 b. U! f0 T4 h) w* ~ - /*#define EDMA3_DEBUG*/7 Z2 o- I, t( j
9 [6 U' `5 G4 _3 x( c' b- #ifdef EDMA3_DEBUG, a4 q; G9 }( [. L) Z8 r9 C
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)* w9 p9 g7 r% g, W
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% G( S/ _, y4 s: E: o - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& H. o& ?9 b1 i
- #else
4 |7 k$ W, d* U* t4 } - #define DMA_PRINTK( x... )
' o2 O" _/ U, N5 P ~- R3 l3 W - #define DMA_FN_IN* L: _: I9 a( q% Q3 Z
- #define DMA_FN_OUT$ b) ^8 t2 i, x
- #endif, j/ N! b# t0 d4 B/ L
- 2 p& o* a- R9 j4 c3 D5 |( d
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)! B( q6 F4 S9 T- u% O
- #define STATIC_SHIFT 3
) P) O5 x2 m4 i# O ]: _; H - #define TCINTEN_SHIFT 20$ F& u' v9 E( ?! Z2 b
- #define ITCINTEN_SHIFT 212 s8 f& l" ]/ b5 L$ E
- #define TCCHEN_SHIFT 22& D# y6 I0 u+ u! I
- #define ITCCHEN_SHIFT 238 p# Z+ s- K3 M" Q2 k' \' X9 P
- / z2 T; H1 J0 R% ^+ g% K
- static volatile int irqraised1 = 0;9 ]. D$ T( {" h! m: Z, ~0 W1 L! @
- static volatile int irqraised2 = 0;* K7 Q+ n5 |3 ?7 q$ e5 U7 R
- m- {9 q: F! m; T6 Q6 n- E: ]- c
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
! y$ [6 q7 Z* ]1 w( r% Q& P) h - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* p) M* F# z- K2 @- [# V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 f6 [ b$ b6 I* r5 U
( P% d$ P4 J7 \8 u" p, d- dma_addr_t dmaphyssrc1 = 0;; p( |8 {4 F' x
- dma_addr_t dmaphyssrc2 = 0;
+ M, u! [; l6 ]9 T - dma_addr_t dmaphysdest1 = 0;
( q: T% I, ^! T& l j - dma_addr_t dmaphysdest2 = 0;+ C8 O$ ?% ^. t; p
- 2 \' C3 k' f d1 U5 g- f2 I
- char *dmabufsrc1 = NULL;
& @2 A$ |- O0 n! M - char *dmabufsrc2 = NULL;
6 E6 r8 J. j# U4 N& e- `/ R - char *dmabufdest1 = NULL;4 K8 t8 {. w# K% w5 L9 |" |
- char *dmabufdest2 = NULL;
+ B2 ^$ P8 g3 L8 |3 e4 q
: v' @# `5 e* l" r6 d4 ^ h, ?2 u1 q- static int acnt = 512;- U' g# T, c' G U
- static int bcnt = 8;
; a- I# B% T+ ^7 M% D4 o! l/ @ - static int ccnt = 8;: f ^( o6 {8 S0 g P' S
- ! z4 L0 I5 ?$ s5 m/ H
- module_param(acnt, int, S_IRUGO);# M" r: k4 l7 _* j8 b9 T
- module_param(bcnt, int, S_IRUGO);
" }% W5 h0 ?; m3 P' |+ m - module_param(ccnt, int, S_IRUGO);
复制代码 5 a) i' Q) }" K; E+ P
. H6 o3 Q) e+ W3 R S& F) ~" h2 W! Z
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
: O/ V- N# Z1 l: R8 r; k. [- a* Uarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
& w( D" p1 V) A0 Z7 J2 A5 L 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。; a9 U2 y g7 V' H2 N* S! P
8 Y! |, p9 C7 z. ^
8 V8 p, m0 ]) G& c4 b |
|