|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
1 U: a; N* _5 e5 u, z+ w- [code]EDMA sample test application
( X0 R/ z* y. l% M: Z - /*
5 T- M4 n: N. b/ y( g - * edma_test.c
8 A* i* q. {" @' Z: i; v | - *2 G, K- B" E) _" v9 K7 l( E
- * brief EDMA3 Test Application3 J0 v. a7 e S; c+ j4 b
- *
& \- E. e3 t; s( _ - * This file contains EDMA3 Test code.
7 ~4 m A3 ]* S. K# f8 m - *5 \/ b6 t0 {- e# g9 i0 m
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
6 ^6 R, D$ Y4 b% A - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
6 s0 B# t M2 @0 ~# g$ d4 S - * TO CHANGE.
$ n$ L+ {3 m5 w. k9 U/ C - *; ]8 d6 X/ ^0 h9 A% f
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
, K5 h9 z" a' v b$ [: h+ }, b$ b* B - *6 S& b# P' g) V0 Z) m. ]
- * This program is free software; you can redistribute it and/or6 }0 T' o/ x# J9 @2 z% k
- * modify it under the terms of the GNU General Public License as( \$ X* q. I9 \8 m
- * published by the Free Software Foundation version 2.
4 L( N' U& ]8 x/ t [ - *1 Z& v( _0 B( X7 a; B8 q3 }
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
1 P8 @) n0 N- {( ^0 c+ I7 Z* t - * kind, whether express or implied; without even the implied warranty$ y6 @: [% U( w+ l2 l
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) ?8 @$ A& I8 W0 ^4 p' E) b - * GNU General Public License for more details.
% H& E* x8 F3 U, B3 P - */
9 K4 ~% x9 d: U+ f: v; C
! G" A# ?- o. x8 g, p$ A( n- #include <linux/module.h>
8 @9 U1 \3 ~1 _! v - #include <linux/init.h>: a Q4 |4 R& w6 X! R# Z
- #include <linux/errno.h>( Y3 O9 I6 s' E9 T5 t+ Z; h/ P! \$ L* \
- #include <linux/types.h>! }1 c( `6 L; Q% n" y
- #include <linux/interrupt.h># ?6 s: Z3 F2 Z& [) h" b
- #include <asm/io.h>
+ F! o9 d7 g, d7 O% {; s! e - #include <linux/moduleparam.h>
" s7 O+ D2 O S2 A4 X - #include <linux/sysctl.h>
; Z8 P* j- O6 p - #include <linux/mm.h>9 N) G& I3 o$ D6 I* a5 O( |$ r- @
- #include <linux/dma-mapping.h>* l, f* m8 p; D# `8 ~
- ; T/ P( v9 [; @, G1 t8 t
- #include <mach/memory.h>
6 Q- x" |5 ^4 z7 i - #include <mach/hardware.h>0 p1 P# \+ o) Z7 G5 H% f! V" v) h* o
- #include <mach/irqs.h>
2 p3 I& \8 B7 L; V% U+ H( L - #include <asm/hardware/edma.h>
; E& c& P5 e+ y5 [0 R
3 r7 T0 v* u B! t4 S* e- #undef EDMA3_DEBUG
; M! P+ ]7 o9 U' [- w - /*#define EDMA3_DEBUG*/
/ j4 I* |: @* r4 L) x - " I8 H+ G2 d1 c. Q; i
- #ifdef EDMA3_DEBUG
$ Q: C+ ~# L+ e0 @6 g - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
% _3 w5 [( V+ O" Q+ I1 o2 ]. _ - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
3 Z" o8 A. w1 O! v& s- s) f - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)' O E1 g* O) V5 k
- #else
1 b( j. L M' J - #define DMA_PRINTK( x... )" o5 X7 d# j' m) Q. W* N
- #define DMA_FN_IN
: Y2 h- _+ l8 O - #define DMA_FN_OUT
- `* }7 k8 l- }6 \7 V" w - #endif
/ j- }+ h8 _( l7 |
( V8 x$ n) `0 k) j4 o+ S2 j- #define MAX_DMA_TRANSFER_IN_BYTES (32768)$ Y1 x6 ?' h2 V1 k
- #define STATIC_SHIFT 3- k* B$ y$ v5 b5 o6 M( M8 X
- #define TCINTEN_SHIFT 20, v) v- R3 i: k
- #define ITCINTEN_SHIFT 21
. T. L- `7 q$ T! i3 U0 f% r - #define TCCHEN_SHIFT 22
5 A) x3 \. S& E2 L0 | - #define ITCCHEN_SHIFT 23
6 A* @7 r$ h, L# ^( ^/ k0 T - $ g, Z+ R+ E' l- B% o- {& U
- static volatile int irqraised1 = 0;3 B, x5 x/ ~. D" F0 p8 s
- static volatile int irqraised2 = 0;; D( I' s! D, D. C. G% d4 W
+ Q% Q% p) a. o' }4 l- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); ]+ E1 A& E: l! ~# R2 i1 d: q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 ~% S5 j% ]5 |; L/ ?: F1 _& r
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- E/ r' Z. u C# n* K
- ) }* ]/ b7 m U' w" G' q5 m
- dma_addr_t dmaphyssrc1 = 0;
4 [# T8 P, Y. v* `) ~; e# x - dma_addr_t dmaphyssrc2 = 0;
* |4 S8 L, M; v7 ?$ s. i3 g - dma_addr_t dmaphysdest1 = 0;
8 ^( P1 @4 A# u% `: z }5 k - dma_addr_t dmaphysdest2 = 0;7 D: g0 C. t! z6 L; @! S
1 j. }! V# q0 N# ~% P4 _& `- char *dmabufsrc1 = NULL;/ o6 D1 B9 ~* h
- char *dmabufsrc2 = NULL;2 `& d9 @. E# ?" L8 N
- char *dmabufdest1 = NULL;; a+ l3 z x; K: Q7 \' p
- char *dmabufdest2 = NULL;+ e% m" k# V: Z- b
- / _7 k3 L0 M/ ^; x3 F r
- static int acnt = 512;
! t$ [" O8 q: X: D& D+ @ - static int bcnt = 8;
/ t2 t4 N) ?1 C - static int ccnt = 8;4 Q" N/ {( G# J$ ] u$ M
- 2 j( h$ [7 j* O/ C, Q( T# N' M4 p6 O
- module_param(acnt, int, S_IRUGO);
) g I5 q2 H `$ i9 } ?' [9 f - module_param(bcnt, int, S_IRUGO);
* h. h* ]" g" K - module_param(ccnt, int, S_IRUGO);
复制代码
7 i3 P" t/ m& M$ @+ ]' p0 l+ y0 k& i
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
1 v0 F7 C9 E: f" n2 ]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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。/ t; b( S( u+ }& b
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。5 _* p4 d+ a" `5 V9 e* f
& }' {, {4 }: r8 U8 T. E
( ^; u* j3 N+ k5 @9 D9 K: t* K$ o
|
|