|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
* K) @' q7 H" X- w- [code]EDMA sample test application
. @6 t9 }6 S% J% F' x- f - /*3 P2 Z2 Y1 h& u/ a5 U9 I
- * edma_test.c2 Y! q# {# b4 V
- *: y9 ?) W1 [+ z: y0 F
- * brief EDMA3 Test Application
: h+ \; h" L% R/ Q - *
4 l0 [2 ?0 H! y& T- |- i/ v% b - * This file contains EDMA3 Test code.
% A7 o. v" I: q0 | - *1 C; ]! w1 J% h2 ~1 P$ L/ H/ p- z
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE# ^! ^" I" K+ F6 y* V4 M- \
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 x8 d4 ^% N$ z: p; B _! P- q
- * TO CHANGE./ D0 ~- L7 \; s$ G
- *: B: U2 b* H4 x& r1 R
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/& H% G& N! p p, p
- *% ?' o6 M% U: p4 M1 } G
- * This program is free software; you can redistribute it and/or
/ u: a, \8 a; T9 [$ _ - * modify it under the terms of the GNU General Public License as* P2 Q" b# U8 S% \& s
- * published by the Free Software Foundation version 2.
& F8 s, h+ V/ o - *9 D. i( W* ?7 F& g0 Q4 d& _( Y7 P1 T
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 y/ B8 v1 a% E$ j
- * kind, whether express or implied; without even the implied warranty
( @4 O, L, b$ _2 m9 p* w9 A; N - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
r' l9 g s( U+ y9 W6 `& v - * GNU General Public License for more details.: u5 T2 o' U: |- s5 H
- */
3 `# t9 l; o3 z0 C
& Q6 q6 A; @5 Y) u( w8 I: E* L; @- #include <linux/module.h># y6 i$ W1 S/ F c7 q% @7 c! |
- #include <linux/init.h>% n, S, A g8 T; e/ g4 r) [; e9 R$ B/ H
- #include <linux/errno.h>( q! A- Z# i) h t
- #include <linux/types.h>
8 q# {0 U0 i5 z8 i - #include <linux/interrupt.h>! h$ P* ~( x; l2 ~# p3 @$ D9 p
- #include <asm/io.h>6 {7 i, G( _$ @+ L
- #include <linux/moduleparam.h>
( n0 R6 {0 O6 D" J4 B1 i - #include <linux/sysctl.h>
' w' O' i/ c; D% {5 [2 ^) A - #include <linux/mm.h>
' }/ w0 k& W8 Z1 n- n+ X - #include <linux/dma-mapping.h>3 h3 I+ L$ ^# F
- ' S* _' q7 e r+ ^5 M3 E5 \ X
- #include <mach/memory.h>
0 }" h* x7 J# L/ F; b& E - #include <mach/hardware.h>9 \ I z1 i! e% w$ [
- #include <mach/irqs.h>
+ f" a4 }( K7 n6 S/ n - #include <asm/hardware/edma.h>8 z5 T9 F# f. Y4 K- r8 S3 ^
- 6 ~0 L9 i8 Y7 ^2 C
- #undef EDMA3_DEBUG
* {( E- l. y* _ - /*#define EDMA3_DEBUG*/7 M; p' e' h# G, ^
- : X# a2 y+ h% l
- #ifdef EDMA3_DEBUG0 x) F" }4 E, k9 k' U0 O7 |
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
! K+ y& W" {; f @+ n - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)+ R; S( T; F" Q1 R0 A, B' o
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
7 ~0 m1 n7 y/ g9 W! k- S; E - #else; U- v# |, R; v4 \$ ]' ~( h
- #define DMA_PRINTK( x... )% f7 d: f; F( b4 b. ?: p/ g o2 A
- #define DMA_FN_IN$ `' F* g. j. I/ K0 |1 a- Q0 K2 I
- #define DMA_FN_OUT& C0 _: ?% a- I9 j }; a: Q7 [
- #endif q' m* ^% M4 |* e3 j! \
# I8 D5 I6 D# [- c% }! r0 O; V0 _- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 f8 G0 ^! S. P( e4 j/ N3 W' z9 `) `
- #define STATIC_SHIFT 35 Q! R# j" z. _. o/ c" C
- #define TCINTEN_SHIFT 20
2 M% ?; |! w0 a" U - #define ITCINTEN_SHIFT 21' } w4 h I; p2 p6 c
- #define TCCHEN_SHIFT 223 i2 w! { Y/ z5 H1 B1 ~" Y
- #define ITCCHEN_SHIFT 234 [8 I& t! ?* X& K* q' g
- , p3 N/ n) K- G5 v$ j% E2 y' i
- static volatile int irqraised1 = 0;
* V: K' Y- @( x1 o9 v - static volatile int irqraised2 = 0;
8 r2 e0 v* d* F# F
7 d. s1 Y( m/ _- f+ u& t! V- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& N5 [7 ^& Y! ]" Z( \& O, p, j* H - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! V% N. P& f5 F, y) n
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. K: k, |+ J& b! P! w: B5 ?
# ]0 f M' C# U; I) b6 C! R& t- dma_addr_t dmaphyssrc1 = 0;" R6 C/ z2 y- s; p) j& W
- dma_addr_t dmaphyssrc2 = 0;
8 d" B N& `1 p* j: V - dma_addr_t dmaphysdest1 = 0;' i3 O" m+ A( A# ?
- dma_addr_t dmaphysdest2 = 0;1 u* _2 _" d$ i- A- B- I) J
- % t1 h3 g$ j: e7 C! O
- char *dmabufsrc1 = NULL;
8 d! _3 }& J2 u( j- M/ b" _% d - char *dmabufsrc2 = NULL;- g$ d/ M) |" E7 ?
- char *dmabufdest1 = NULL;! d! ~! Y% `2 X0 @* o% H# D
- char *dmabufdest2 = NULL;9 i- i; C5 K" g( y0 i
9 B. Z) _2 a' p9 u( p$ {: W- static int acnt = 512;
, H* h9 P8 q5 E7 {& X H, W( z - static int bcnt = 8; `: h% I" {: L, m1 A
- static int ccnt = 8;8 R5 k, x4 }+ f6 U7 q
; {& W0 k: O Q/ S* P- module_param(acnt, int, S_IRUGO);# N6 D3 b' z, R5 x) r
- module_param(bcnt, int, S_IRUGO);+ J( g) J ]* B! |
- module_param(ccnt, int, S_IRUGO);
复制代码 " p4 D- e# E0 k* s" L# {
! V8 U( A* ]' C' B& a
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用7 b- o8 W b9 d6 [0 ]- R
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ a* `; M) [$ K& B
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
2 I0 _- ]) M1 r U: Y5 Z+ F9 q& Q! R. k
0 T5 D- _# O: E
|
|