|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% ?: u) z* N% ~* _& u- [code]EDMA sample test application* `5 e+ n( G/ h/ |" N% E: ?; x2 f
- /*3 s; l. ]4 G# }# t
- * edma_test.c
) S+ l( Z& S& U4 H1 G: N6 x - *
+ \( \8 N) A; W; v - * brief EDMA3 Test Application
; T, \8 _7 H) l8 M' H3 t+ W - *
% f& b1 d* ^, c6 K: O5 t - * This file contains EDMA3 Test code.
9 H8 X; u- h9 n. z9 p9 z - *
7 T7 w9 J1 A& a2 m - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. O2 X4 B+ ^# C& Y/ f y1 o
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 F8 e( u; ^/ i3 h) h) H6 ^7 v5 Q - * TO CHANGE.
& X( z, F E* Z' w - *
) l4 }2 V( l# h2 f$ Z M8 P4 s) M( T - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
, n3 V, g8 A) u: i - *
; n u3 p; D6 P* ~! g4 d - * This program is free software; you can redistribute it and/or
# L$ ^( R% w8 \' R# T# |7 C - * modify it under the terms of the GNU General Public License as ^9 g: m, W A2 w4 q7 q. g# G
- * published by the Free Software Foundation version 2.9 f3 o3 }4 v% a& t/ }/ Z# Y2 @4 w
- *
1 F! i* \/ f5 c' e - * This program is distributed "as is" WITHOUT ANY WARRANTY of any) F4 e: i, o8 q+ X4 b) j1 j
- * kind, whether express or implied; without even the implied warranty" \7 t. T! M8 c3 Y2 W" o
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- H6 p M0 W2 Q, V9 } - * GNU General Public License for more details.6 Q/ N( Y2 z0 V, q6 |. d" Q
- */, n8 Q: r- \0 O/ i. y" b
- 2 `8 `) z' |* N7 g
- #include <linux/module.h>1 k2 W+ ^% ]. K D
- #include <linux/init.h>+ Y C* P$ S/ e
- #include <linux/errno.h>% R/ S! k) z& t3 v7 ]) k
- #include <linux/types.h>. E5 x1 B( X( i. [7 [. p( W+ Y' C$ _7 K
- #include <linux/interrupt.h>
, ~# O) @5 U6 F6 m - #include <asm/io.h>$ M1 E" \: a( `& c7 O
- #include <linux/moduleparam.h>
' `9 G/ ^% C2 V4 G; Q. C3 M - #include <linux/sysctl.h>
5 \5 e, E3 d; k( q2 G+ j - #include <linux/mm.h>
$ z7 _9 [' ]: s- o4 V - #include <linux/dma-mapping.h>
: k- d8 j" z a: K9 [- g
( s$ T$ u; Q0 u. o; F5 ~# T# Q9 H- #include <mach/memory.h>
* @4 g0 [6 I* V2 R. C- F2 { - #include <mach/hardware.h>/ D% \& J; J; O1 `" C
- #include <mach/irqs.h>% q' N1 z _/ `! q N
- #include <asm/hardware/edma.h>. d8 f+ `7 V5 t! k( M2 z. O
/ M& t2 e9 L3 b1 X7 Z. ?+ T7 x) Q- #undef EDMA3_DEBUG7 D. F) T% G. ?1 X
- /*#define EDMA3_DEBUG*/
3 j, |& ?3 ]7 l6 X( }% i - * h- s7 m9 ^2 D/ D! Z3 t" s
- #ifdef EDMA3_DEBUG
' f) k0 @$ X. J% F - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS) V# N) o4 j2 N
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# }% G% e2 @- i: U! a5 } - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' l, `* H; Z4 U9 B
- #else) Q/ v) n' T; W% S* q. v
- #define DMA_PRINTK( x... )7 p$ J# A& A0 u- H* | z
- #define DMA_FN_IN
% |" G$ u( s% A* D4 W - #define DMA_FN_OUT& D) M! N! R- J" c& i; U8 {; y
- #endif, b$ u2 u# S3 j
- " t' w2 n& m& H4 S2 t2 r4 d
- #define MAX_DMA_TRANSFER_IN_BYTES (32768). {7 l' ~: o7 f6 \' P
- #define STATIC_SHIFT 3$ m5 |$ F) W# ?, ~/ ~6 g- Z
- #define TCINTEN_SHIFT 20
1 B9 h6 r1 L8 D - #define ITCINTEN_SHIFT 21+ J* B. ], L6 L6 a3 n+ j/ }6 E
- #define TCCHEN_SHIFT 22
& `. I! v. V2 d" i6 q, P% | - #define ITCCHEN_SHIFT 239 r( I6 |( ^( I: o3 m! t" C& r
1 S7 ^* X4 c( k' A" p& ~- static volatile int irqraised1 = 0;
4 \- ?3 a& N2 i% M5 |& v - static volatile int irqraised2 = 0;& l/ ?( _+ U. t) O
- 5 O/ w2 b2 u% A2 W: ^+ h/ ]3 n
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: x$ i& O. O- h- b( Y9 J: A - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ D; e' e" H+ \- N. U* L - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# U$ W0 D, M2 i - % g) j C u5 y, b9 H3 z& L
- dma_addr_t dmaphyssrc1 = 0;
5 D$ W2 n) r- o8 ]4 q5 E - dma_addr_t dmaphyssrc2 = 0;
4 b# e* [& P$ L0 _9 m - dma_addr_t dmaphysdest1 = 0;
9 ^7 U1 Q5 f) h" I: F7 }- ] - dma_addr_t dmaphysdest2 = 0;
! D+ N! F0 k( J
+ b$ p! s5 B7 c' }1 p5 E- G1 v- char *dmabufsrc1 = NULL;8 J, q8 \7 I" W4 `9 e, R5 U1 n
- char *dmabufsrc2 = NULL;
6 X$ T& U) B1 M- I* g$ w - char *dmabufdest1 = NULL;
# i# K' H! Y @- W9 b; S& o# g- \2 X - char *dmabufdest2 = NULL;" f* h$ o* Z0 a8 _( c# U
& M( ^, }2 ]4 L q. E' h- static int acnt = 512;) @' }9 M& b* e2 I6 R$ |* i/ _
- static int bcnt = 8;
: O( {; Q4 Q1 R: i/ G - static int ccnt = 8;
O' i8 i: S3 \3 u
( R/ d3 G, }2 N# P- module_param(acnt, int, S_IRUGO);0 i3 Z$ m/ C5 ~2 O2 v
- module_param(bcnt, int, S_IRUGO);
9 ?' P+ q2 M* C# c" E2 G - module_param(ccnt, int, S_IRUGO);
复制代码
2 m8 j$ [5 U) }* \8 D+ O* g" ~* J- p( h+ ]$ l
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用' S1 j5 P, u" Z
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
- [$ z- o7 Y1 f* J9 o 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
X1 f* [1 Y+ G& S7 ]' I6 x6 U. y+ {3 {
. ?" ]: p0 N5 _5 `- ]
|
|