|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 i) ~: b8 S5 a8 k6 h" U- [code]EDMA sample test application7 F5 P% j' x! O5 z! P) O; m' l
- /*
; f9 N- @' \) ^8 M - * edma_test.c0 _1 Q4 h' g3 n0 ?
- *
6 _. U5 C% Y$ c) o* S& O0 \5 h - * brief EDMA3 Test Application1 u+ X' X) @, K0 E) A$ U8 x5 V3 H
- *9 _: R" t! ?! y1 X
- * This file contains EDMA3 Test code.5 Q }, _5 I/ ^9 L7 S. }) K. G
- *- X' h4 s/ v9 A8 {
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE1 f D* k) @! m+ ?) l
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( ~% t' } P* d: @! l6 d& F: N
- * TO CHANGE.1 a3 F! M" r4 a! j7 \
- *
|% d) F1 E6 V& o0 Q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
/ l4 b# Y- Q) h6 ? L8 s - *+ x; G/ C/ v4 y5 G9 ~
- * This program is free software; you can redistribute it and/or. g6 V- I9 U( {* h% z3 Z
- * modify it under the terms of the GNU General Public License as" P K% e; ~1 m& R$ T
- * published by the Free Software Foundation version 2.6 X6 J3 z; ?$ ^6 Y2 Z
- *, C" |5 d: V6 S1 ?* [; a% A [" H
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any( ^. H+ i% V) E ~5 j( I
- * kind, whether express or implied; without even the implied warranty
% [! |" g' s5 d" s# v" H - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the0 U# b0 E2 Y1 t# h H7 q
- * GNU General Public License for more details.
/ f. c- l* ~/ C' f - */
: [+ c u/ X2 `& U3 ]& H
* {+ i" o$ C9 v A8 |% V( t! i- #include <linux/module.h>9 c- @, g$ k( A+ v8 F: A
- #include <linux/init.h>
6 Q& Q4 j G$ n2 u+ v - #include <linux/errno.h>
2 ^/ B# E7 T* D6 \( P. [+ a - #include <linux/types.h>% S5 D- |) x4 K2 b" A* V8 B2 Y
- #include <linux/interrupt.h>
0 y- ?+ V1 k8 i - #include <asm/io.h>
9 T& Y" e9 g: L9 y - #include <linux/moduleparam.h>
3 c) B/ ~6 R$ h( c \ - #include <linux/sysctl.h>
7 j* H+ ~. f6 T z8 Y) q/ O - #include <linux/mm.h>4 I$ H. F& u, j' E1 w1 M
- #include <linux/dma-mapping.h>/ ^9 ], L R9 b" c6 q
# f5 L: E: C/ K f" x/ s- #include <mach/memory.h>
, u2 M. z" o+ F0 Q7 G" @" @ - #include <mach/hardware.h>
$ Q$ v1 u5 y# \) }0 G( Y - #include <mach/irqs.h>
+ a5 _$ a0 ?( Z3 L5 u* P - #include <asm/hardware/edma.h># n; C2 x4 i7 ]$ q" ?. G/ `
- ; b, _. [6 p0 n7 r
- #undef EDMA3_DEBUG1 c$ S5 N5 X4 `" Q. `
- /*#define EDMA3_DEBUG*/
' u% k* @1 t$ d - 5 p$ ~8 I2 S2 W3 a p: i
- #ifdef EDMA3_DEBUG1 I: A9 V3 t/ C! c& g+ G; f
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
9 r( q& E3 |: p% C' a* k - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
# e5 R% F' D$ T7 v2 `. X - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& f, E: p7 |$ _8 h
- #else
* V1 F8 H3 W; Z/ I$ J - #define DMA_PRINTK( x... )
9 X( }8 X, `+ ]$ M3 x/ `% B - #define DMA_FN_IN
. K4 Q! w- f5 I1 M3 P# A+ G/ U - #define DMA_FN_OUT
l% ~4 T' E: Q6 i" ` - #endif* `5 }% y5 K$ k: O9 E( ~5 O' u
- % x; Z2 i1 X0 a1 f! O8 T- m. D
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* X* L' d! D* A) ?; U - #define STATIC_SHIFT 3
% S! c; C) V: w( Z, z, y - #define TCINTEN_SHIFT 205 W. o4 A8 t. o( Z4 r
- #define ITCINTEN_SHIFT 219 f# @. |/ ]5 i: d; o' ?# n+ P
- #define TCCHEN_SHIFT 22
4 `% M _1 |4 h7 M% n/ j - #define ITCCHEN_SHIFT 23
3 Z+ W4 Q' N0 O. _
. i: ]( h$ }, J- O7 E: b4 E- static volatile int irqraised1 = 0;
1 G! G% ]$ C& S" C! b! j - static volatile int irqraised2 = 0;: {2 h% R# d. e+ F0 k6 {: \* ?
, F3 S. K5 j! \! Q+ R. O- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 ^. G% {" H! y# _" u, r! @! r
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, x. c9 }. u0 Y6 D5 I
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);2 O* Y6 L. F5 T
# K: u& G+ ^' \- ^1 M- dma_addr_t dmaphyssrc1 = 0;" z" x F0 X% q- R
- dma_addr_t dmaphyssrc2 = 0;
- y5 G V3 \; Q" }7 T) R - dma_addr_t dmaphysdest1 = 0;' ?, ^' R- }- N; t& q
- dma_addr_t dmaphysdest2 = 0;" s4 @5 n! z# _% j- t( {% i
- $ y: {* {3 A! {6 N+ u2 W
- char *dmabufsrc1 = NULL;7 n. B7 W. S6 z0 {! F( L3 v, p% a
- char *dmabufsrc2 = NULL;' j8 `' X( R+ R/ W, f5 R& H
- char *dmabufdest1 = NULL;
8 t+ F7 \" K' _, l0 ~# d7 k- T - char *dmabufdest2 = NULL;* h$ v! l7 n4 T9 @- E
- 3 u3 A# O6 Z; j7 f" p' g
- static int acnt = 512;# x: o z# r9 K- ^
- static int bcnt = 8;
: U4 B0 A; K9 W b - static int ccnt = 8;( L; Z4 u. q1 F
1 `0 C4 r" B0 ^- module_param(acnt, int, S_IRUGO);
0 v/ C4 X3 u, d, @: h* W - module_param(bcnt, int, S_IRUGO);
: t7 T" w1 `3 ^ - module_param(ccnt, int, S_IRUGO);
复制代码 & N- t; @; |! g
9 V" A% X6 C8 i6 U* \: J& V
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
6 k" ]0 n- r+ H5 `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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
/ c# S, j, m5 C6 J 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。, v+ M, H$ D/ H/ P' k
. {/ Y! F6 X1 V$ U
, Z& @, q4 j& T" P# c) t
|
|