|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
6 f2 Z0 l/ e$ q- y' _. l4 c- [code]EDMA sample test application
' T2 A! a) P+ V* ` - /*" M$ M, L) l% S! E" V' Z
- * edma_test.c
( e$ g5 m) R& y/ j5 ? - *
i/ x: G: X% R- H p+ i$ h* T - * brief EDMA3 Test Application" X4 f8 j( C+ M( N6 e; L% t
- *5 y/ m( j. g% A/ R+ \+ @0 [
- * This file contains EDMA3 Test code.
! m, ^+ V6 o. L1 j; B% D2 Y! x - *& S7 S' Q* D, Z. k$ F
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 p% n$ y* t/ ]' V5 I9 K1 X - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 v4 @$ `$ v0 ~8 l
- * TO CHANGE.8 ` x+ m4 o5 H, T$ r
- *7 k. w8 H% S& C$ a
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
# S4 j z7 j2 g6 P - *4 p" i3 s1 b- c
- * This program is free software; you can redistribute it and/or
( }" J7 f8 W4 E: O0 x; E0 R* v - * modify it under the terms of the GNU General Public License as
* b& P, |$ j) q$ B- @/ Y - * published by the Free Software Foundation version 2.' R8 e- U$ g, Q3 o% O7 x
- *. E1 V: | Z. Q: g& A1 o
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 G% K1 t# M% W
- * kind, whether express or implied; without even the implied warranty
' c& L" Z. b4 n& h. ]; A, R8 x - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
$ i( a7 r$ F g1 @! ] - * GNU General Public License for more details.# C+ K3 k# W, J/ }, g4 ]
- */
& u& E' U+ ?& o& J
( ~$ }0 T5 s+ p$ M# E, m* V- #include <linux/module.h>" T# F" d s( \- q
- #include <linux/init.h>0 n0 G% A1 @5 L$ P) t
- #include <linux/errno.h>
0 j) m, p. N9 B2 C8 s - #include <linux/types.h>
9 m5 H C3 m, t) ?2 P9 j& ^3 k - #include <linux/interrupt.h>1 _8 {6 k- L" F5 \0 P0 `
- #include <asm/io.h>) t1 n& v5 r& V, b4 k
- #include <linux/moduleparam.h>
9 R" V7 e0 _/ e" _. d - #include <linux/sysctl.h>; g' \1 V8 r1 p* z4 \
- #include <linux/mm.h>
1 }- }: q* ?' w1 t2 q% p7 I) s# W - #include <linux/dma-mapping.h>: d& u% A. f5 f( ]
- . ?% r3 d0 z; F1 @' z
- #include <mach/memory.h>
: ]1 o2 Q; d3 Z( B/ T. ~ - #include <mach/hardware.h>
; @ X5 ]$ _$ L/ } - #include <mach/irqs.h>
( r, i: B4 {4 v) @3 c6 _" L - #include <asm/hardware/edma.h>
' m5 c4 Y0 e" l j% [
: @3 f" x: D7 X- #undef EDMA3_DEBUG: }7 V. u7 A9 l1 W& X- }7 ^4 e
- /*#define EDMA3_DEBUG*/5 C5 M0 l% X8 F+ n" q1 J* ~+ d$ x
- # o4 ^6 z0 T' Z1 F8 Y
- #ifdef EDMA3_DEBUG
% u6 ^- d6 \* {' H+ `& H* Z) ` - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
' o6 E7 p- c a: [, o - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
4 Z. ] X* x( Z( N. z - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__); M$ L: k0 V C- t
- #else
% q, y* Q& D" z( ?# t* e6 \ - #define DMA_PRINTK( x... ), W' i- Y8 I" P
- #define DMA_FN_IN& X, |, }7 p+ O% f
- #define DMA_FN_OUT
% u1 X4 i' G% a - #endif
2 U8 K0 D0 c& \5 x* j) r7 M& r - " |( B9 n4 f0 |6 z/ V5 [5 Y
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' x X" ?$ c( L" g" j - #define STATIC_SHIFT 3
! T4 i4 s' v) a* l1 L7 \1 f4 ?& y - #define TCINTEN_SHIFT 20
6 N+ ^8 ?7 E- p$ ~2 P) ? - #define ITCINTEN_SHIFT 21& H' s+ _+ j* p7 X+ B7 y+ A ]
- #define TCCHEN_SHIFT 22) E; \( i) i& @6 {5 @5 D2 r* `
- #define ITCCHEN_SHIFT 23
. y, J% Y3 s, P9 w% U. {2 K9 U - - Z7 c. y, y" B" f
- static volatile int irqraised1 = 0;4 c6 Q) R9 v; y( g3 h4 r3 D( C0 u8 s1 w
- static volatile int irqraised2 = 0;
4 G7 V0 @. d/ p% d: J( F5 S
. P2 `4 S& x0 {/ A4 J# z& B8 v- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 o! h: n; x! B$ x - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' c3 i" ?, X. P N8 V- t
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; y! \2 }9 o8 t4 f, W& P
( R! K s/ d& @7 X% r- dma_addr_t dmaphyssrc1 = 0;
3 |, C9 |" x/ N+ _* S. \ - dma_addr_t dmaphyssrc2 = 0;
8 x% O7 [" E3 z) m1 w - dma_addr_t dmaphysdest1 = 0;/ P: z* u* l% O* W: p+ V1 t
- dma_addr_t dmaphysdest2 = 0;
4 h* W F3 r1 Y( N/ j' r - * s) [# W! ~# B( B2 j: q
- char *dmabufsrc1 = NULL;; i2 l0 ~% N0 g. ^
- char *dmabufsrc2 = NULL;# B8 Q. c4 ?+ A
- char *dmabufdest1 = NULL;
6 z+ ~6 f2 f# j" E& `! A; A - char *dmabufdest2 = NULL;$ v5 c" n, P1 ^' z# g# d
; r' q/ [$ y* p7 Z, A7 |* W' ` G5 O- static int acnt = 512;$ H: X7 h! V' z* t& U5 g+ P
- static int bcnt = 8;
! T0 a8 z9 L) o! g2 E - static int ccnt = 8;! a% \( d, Q( `. C$ Y
- ( t4 T3 F( g# L6 X* j+ U5 w
- module_param(acnt, int, S_IRUGO);
' \: n6 t+ T3 E - module_param(bcnt, int, S_IRUGO);
( X h9 N/ L/ e( l+ |. T" ], [ - module_param(ccnt, int, S_IRUGO);
复制代码 0 H- [; [% x3 l7 p& I/ N% g; M
* [' y& ~4 Y- ]# c7 x1 Y; g6 H1 }
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用, e7 D) F, u+ S/ a! E- k- ]0 Z
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
7 A# _8 C' L. O 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% j- Z" U! |8 ]2 J: q# \
6 w: }! M/ _$ T, Q4 L. ~8 T
# l( V, B% N% b5 E |
|