|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 . `8 [8 o4 r+ [* U# x( \! J2 H
- [code]EDMA sample test application& z5 O% x1 q. w: a
- /*. c! T+ e6 ^4 n# {2 b/ E' r4 w
- * edma_test.c6 Z6 E7 y `) w) M1 s, O
- *& B7 v/ m) w+ i
- * brief EDMA3 Test Application& ^% b! R# R1 F
- *
1 l& M" c7 S& s, G5 c, |0 T) Y' G - * This file contains EDMA3 Test code.
" g* I/ h* R _1 e3 F - *
& y% m2 j" a0 ]9 z. ~, O - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE8 `* j/ p# E& j& O3 _6 g
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
* Y) G- e: I& h - * TO CHANGE.
- g( s& b7 R* v( Y, ~3 x - *8 n, J' O4 v% K6 G) t2 W
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/+ l9 p; c/ J3 t' @# ~% [
- *4 K3 y/ z. M0 }. K- Y, b& Q9 L
- * This program is free software; you can redistribute it and/or
( x/ O0 F- d/ Y! A) `) R0 F, t. W - * modify it under the terms of the GNU General Public License as
: M z! Q8 V$ U, [ - * published by the Free Software Foundation version 2.
- A6 R! L/ T) Y1 Y - *' ?! ^ d& x% D% E" x! L- G
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 E; E3 v P" @8 ^ - * kind, whether express or implied; without even the implied warranty
3 C [, I) E' [% ? - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the: H3 s1 Q) J) ^9 l: V
- * GNU General Public License for more details.
. u1 m4 M, E) b1 E2 {7 s0 n - */
$ w3 b; V- e6 Q
- b* B1 p& b+ y( g: S* q9 e. W. b- #include <linux/module.h>* h- w h( `, D# ?
- #include <linux/init.h>: z5 [# b) U7 f' P
- #include <linux/errno.h>
& J; j& U: D* i+ t, K( d7 h! B - #include <linux/types.h>
5 v! `$ o( f2 l+ x& v j - #include <linux/interrupt.h>6 b* |5 h O; x9 t9 G
- #include <asm/io.h>
- D h, J3 a8 ]; H - #include <linux/moduleparam.h>; U1 I& q3 N$ Y0 O
- #include <linux/sysctl.h>
8 u+ Q9 D/ {2 V- w5 S# x' T - #include <linux/mm.h>
}) k; Q8 U! G2 A' Q$ E - #include <linux/dma-mapping.h>
2 l. D8 P5 o0 T; s - 1 k- p8 S2 U: X9 ~, T( }9 V& Y& i9 L
- #include <mach/memory.h>3 |: U0 l$ ?0 c' g9 c
- #include <mach/hardware.h>$ R: k( E4 r2 k& j
- #include <mach/irqs.h>" y8 I4 t& @! @
- #include <asm/hardware/edma.h>3 ]6 o1 p8 P2 x$ m4 Q. b0 n. v5 l' u
- % h6 X/ C# v9 Y4 |8 q! u- P3 j$ u
- #undef EDMA3_DEBUG0 A% l4 I" t! a2 t
- /*#define EDMA3_DEBUG*/% n4 Z9 ]% u; w: v" L* s
. m9 m' e# _9 Z0 `$ d8 T- #ifdef EDMA3_DEBUG4 F' P$ [0 p9 w$ H
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)2 S+ {. L5 f7 G
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% l7 l. S: A3 B5 _5 E M" n# E8 S - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
8 |6 v6 w7 n8 ~/ f - #else
4 X/ W8 O7 ^6 O* [" F2 f5 b$ L( M - #define DMA_PRINTK( x... )
- w/ T9 S$ m# C0 T [$ M4 M$ Q- @; C - #define DMA_FN_IN; o' Q* F, m% u1 `3 ?/ b
- #define DMA_FN_OUT7 m5 W0 c/ A z$ k
- #endif
0 s+ Q# @! N/ y2 _
2 |8 c& {, y. F, n+ t- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
T! c% l+ Z, _! B# U. `+ o - #define STATIC_SHIFT 3/ ?! h: |1 k. i# D! G
- #define TCINTEN_SHIFT 20
1 V6 ?) Y; A6 `- o3 V' v8 [ - #define ITCINTEN_SHIFT 21
, _* d! D5 u; _' k& v4 ? - #define TCCHEN_SHIFT 22
0 v$ {4 e( l. Z; a- | - #define ITCCHEN_SHIFT 23
. K8 K* V T9 T - / j I. |% ^5 s! d$ Q4 }
- static volatile int irqraised1 = 0;$ E* ]1 S0 x* k+ }* p& I9 d% k6 o
- static volatile int irqraised2 = 0;
5 a6 h0 N2 o# A$ ]. l9 p* M
0 L) |1 @; b2 u* k* y F- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; Q! r% _7 u& S& u+ P) v& n! g. n
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 \6 L& q( ]2 m9 T; v$ J- [+ M- H - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
$ ~4 `4 Q9 O( J# z- M. |1 c
+ v' u: ^% E" S1 d" {1 ~- dma_addr_t dmaphyssrc1 = 0;' k; T+ }9 ?: P
- dma_addr_t dmaphyssrc2 = 0;5 d. q7 w3 N0 ]
- dma_addr_t dmaphysdest1 = 0;
7 o0 b \, p& T f. h" Y - dma_addr_t dmaphysdest2 = 0;+ i& o; c- j/ M% l: `/ [8 c. p2 E
- ! E- n4 y9 Y- X
- char *dmabufsrc1 = NULL;
8 L: H! { d" V! Q - char *dmabufsrc2 = NULL;
6 k; A s- B3 c2 J6 y# u6 r4 w - char *dmabufdest1 = NULL;
2 g8 a9 F7 R3 x( d4 i! H - char *dmabufdest2 = NULL;5 d X& n; E. P
% g: l. T! m Z- static int acnt = 512;
3 [; y& g' O* x/ ~6 W - static int bcnt = 8;. G% D/ \ p8 ]8 }2 x& H; |8 x+ q" E
- static int ccnt = 8;
8 a& n/ S4 V7 r: |$ d: ?& ^( G - 9 G* m7 l$ [5 N- {; k' T2 W
- module_param(acnt, int, S_IRUGO);
; z, n; @- g# R) E - module_param(bcnt, int, S_IRUGO);
: m k+ a$ Q$ n/ \) v - module_param(ccnt, int, S_IRUGO);
复制代码
2 ^+ y- c% Y! j* e( E
. h" y: Y7 W) g* L% x2 u# W( K% V% r 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用; J* |6 y9 m$ A( J0 _, 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。0 y% D+ Q$ m$ m" N/ Y1 H
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 y: N. ~1 m) F) j# A _- x
+ {5 G9 K! x+ ^' Y( U1 g; @; p( F# Q
|
|