|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 : J1 z% {' r4 V! i. n+ M' }
- [code]EDMA sample test application, O+ D; p( z( U' N5 h" D9 v
- /*
" a/ |6 c+ i3 a* N5 a3 V D - * edma_test.c
3 _$ X: ^2 [% @( [- b6 ~) H1 m/ e! V- h - *+ f/ r. w2 h0 l. o& L0 u( E. a
- * brief EDMA3 Test Application. h* I* u6 S7 j* I
- *: _2 g: ]( Y6 ^8 u0 s
- * This file contains EDMA3 Test code.& Q* G! r+ m& P: |5 J
- *
1 S& A+ j n1 t ~) _, K$ t* U5 w - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 x1 A$ B8 b4 r5 u% t - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% z l" g( Y# U/ s' ^
- * TO CHANGE.
; d! G8 T9 G# q$ G- {, l. | - *
- |! A8 ]4 o' A! A4 W9 ^ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- ]% ^% t7 R9 b9 O - *; ~" I6 X9 n8 t! O
- * This program is free software; you can redistribute it and/or
. r$ d |+ C3 d9 X0 T+ y! t - * modify it under the terms of the GNU General Public License as8 | D3 | p$ k7 f* n+ p
- * published by the Free Software Foundation version 2.1 m+ P3 }6 s w
- *% W: C8 P1 q% @1 V
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any8 ^2 z; k/ n7 m& y# d- q. b+ C& U6 h
- * kind, whether express or implied; without even the implied warranty
) ?' \' Y# I7 k& t0 N - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the. Q) d( _7 j+ E% {( ~- R7 _3 s
- * GNU General Public License for more details.0 o- s9 L+ |" q: [
- */& w4 L9 B$ B3 x7 ^/ C
+ G ~# F4 ^& D9 L$ B- #include <linux/module.h>% W5 p0 ]# u) B6 s
- #include <linux/init.h>: _0 m3 u/ m7 [- f: U" k
- #include <linux/errno.h>
: B4 i: X8 i3 n: q+ A% z - #include <linux/types.h>% t1 [3 J4 s! ?% v. ?$ w+ B n
- #include <linux/interrupt.h>
2 P0 C2 Z7 w7 \# k0 o) t" w - #include <asm/io.h>) b0 j4 \3 s! J& q+ j1 [9 A* X# n" G ~
- #include <linux/moduleparam.h>
9 L- X5 I1 z# E - #include <linux/sysctl.h>
4 F+ k8 r3 j v1 Y, X. F - #include <linux/mm.h>4 y9 A* `, }1 W/ t) P
- #include <linux/dma-mapping.h>
& S0 ^- K! J1 _0 a' A$ g
& H8 x4 v6 I/ {4 o- #include <mach/memory.h>- S1 u) _; L- H8 ]9 \5 Y6 \
- #include <mach/hardware.h>/ i# f& K: ]( Q4 A$ S/ Q- A- p- d
- #include <mach/irqs.h>
J# u. d) C7 |8 V - #include <asm/hardware/edma.h>% T1 W4 @8 _6 o+ c# _
- 1 l) {/ c2 d6 u6 k) J
- #undef EDMA3_DEBUG
, p# c( G3 A W6 k1 ^- ] - /*#define EDMA3_DEBUG*/
# q) d5 B3 D/ I) c) ^1 M; I - ' a3 }5 j& q# u- `8 d, V
- #ifdef EDMA3_DEBUG" x. K' l9 b0 \9 B6 Q$ W
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# k6 p+ Q, k, l$ s% h/ V+ \ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__); u3 W8 T! ^( A
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ M6 @" h7 c0 L. j6 z; ?5 ] - #else
* ^( W0 A J% \3 X B' j - #define DMA_PRINTK( x... )
: N- L/ ^' {: g: u - #define DMA_FN_IN! M: S4 z2 @7 e! f
- #define DMA_FN_OUT' h, k2 d( n, Z+ [) a
- #endif
) }7 t# b, T$ ?( v0 h
+ }2 z$ Y6 l5 R* E9 F! G- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ R. L, R. N4 X, P$ K - #define STATIC_SHIFT 3 q ]2 n8 D+ a) E/ S! Q# G$ Q4 v
- #define TCINTEN_SHIFT 20
; T! K3 R1 j' g1 Q4 i9 | - #define ITCINTEN_SHIFT 21 L. [- m0 y# U& w
- #define TCCHEN_SHIFT 22
- |, ]* `; |9 _) {7 S- t- O - #define ITCCHEN_SHIFT 23
3 x! M {) L$ z0 | - & A2 O( U& f1 F( q6 b x8 `$ ~0 J
- static volatile int irqraised1 = 0;4 E3 `7 v* f( p2 ], z' I
- static volatile int irqraised2 = 0;" [5 @* Z$ k- d+ z( H
* r) J5 m5 C9 ^( t0 k9 O: D- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 x1 }, N* |8 s, z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! N. K+ _) _, X1 v: D/ V
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! E0 O7 G1 S* [4 P8 V2 s1 ]; n4 A* }
/ T, o( `) [) S, l- dma_addr_t dmaphyssrc1 = 0;
9 P' K3 p# Y( C; P- y - dma_addr_t dmaphyssrc2 = 0;
8 q7 {) c6 t( } u+ J - dma_addr_t dmaphysdest1 = 0;
' z' p6 ]! {& m' |1 d. v& ^ - dma_addr_t dmaphysdest2 = 0;
( l1 x& t$ A3 ]$ W - # p0 Y- M1 F) y8 L8 @: ^4 Y
- char *dmabufsrc1 = NULL;
3 q& @ w. C1 n1 U( m: V - char *dmabufsrc2 = NULL;
. Y7 x3 M9 h/ @4 C" C9 W - char *dmabufdest1 = NULL;2 D Z* L+ T* a
- char *dmabufdest2 = NULL;- T8 U2 ]3 C- p! P- G
- 6 [- P+ R5 Z+ { ?, q5 o$ P
- static int acnt = 512;
5 V% p6 `2 v" N+ m/ R; t; b7 `0 g - static int bcnt = 8;
4 T: e* J8 y5 m6 R. r k( T8 S - static int ccnt = 8;' b$ I' m- L& _- w: D
- 9 G: I* k' {, ^( @
- module_param(acnt, int, S_IRUGO);
3 A2 Z8 y8 {7 o6 S8 V$ H - module_param(bcnt, int, S_IRUGO);2 d! S9 \2 B3 v1 }- O. R3 m: I
- module_param(ccnt, int, S_IRUGO);
复制代码 3 L& I0 y3 g; N: C9 m ]' R! {
W8 F- [0 D. O0 x) d
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! f* G9 |' g+ Warm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。+ \8 V+ C8 R7 o( {
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。4 m* H" F8 e4 p! g; D& o
: p4 P' |. K" p X, k F
$ @% W0 x8 ~& V, Z" r/ P$ e |
|