|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 h5 c2 v" X6 |. i- [code]EDMA sample test application
/ Z5 H3 a% t5 c4 E - /*
+ h: p- S- S9 F4 z - * edma_test.c1 N* ?3 T% Q. F* G+ c
- *8 m1 F1 R% O6 e* z! `/ ~2 v
- * brief EDMA3 Test Application3 X- c& w9 v' z
- *% O2 g" b; h, P/ \, W3 I
- * This file contains EDMA3 Test code.
( o5 T, v7 T4 U6 j ^ - *
; p% j# o" q" i8 ~ - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
( D1 j( l1 d" P" N# g3 p - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 \4 E( W8 k R8 f: `! ^. o - * TO CHANGE.9 B$ D) Q7 Y0 D# L. F; l. l
- *
6 U& T4 c& ]3 z) H1 b - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
1 |0 z$ W$ Q% u0 f - *
1 s* s5 |- Q6 Y - * This program is free software; you can redistribute it and/or- Z- r. k+ I& A( A1 Q
- * modify it under the terms of the GNU General Public License as8 t N- a8 A( Q5 M( G
- * published by the Free Software Foundation version 2.
4 i8 z% m V. Y( l& A1 h- W; m - *
) D' T/ m! T! l9 a f - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
, ?4 q: l( Y$ v0 C5 v - * kind, whether express or implied; without even the implied warranty2 _5 c# R& v8 P
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! l& C2 g6 i9 u, T - * GNU General Public License for more details.& Z9 L. C8 N% b \
- */
6 w1 y) d$ V5 `! y6 w5 y7 H - : U. M0 o$ b8 d2 z
- #include <linux/module.h>6 f7 `* R, w( `: J& ]- _8 o
- #include <linux/init.h>& X8 o$ |4 @; t3 w& b) k, T: Z8 }4 s
- #include <linux/errno.h>
4 z5 a3 \6 Z/ i6 u: w - #include <linux/types.h>) [& ^# L0 M5 S, Q3 u* {+ s: a9 W
- #include <linux/interrupt.h>2 Z" g* ]3 `+ A! H/ I
- #include <asm/io.h>5 Z$ }! G& W5 n, d, B& R" @7 z: I
- #include <linux/moduleparam.h>2 j n3 P( }5 }* l" ~$ d$ D
- #include <linux/sysctl.h>
4 m# e p$ v) c - #include <linux/mm.h>" X% s' |, y* H5 n0 k! U. A
- #include <linux/dma-mapping.h>
4 T3 e1 Q. ?2 T% r - . G! A9 x% Z/ P& V. j9 q
- #include <mach/memory.h>: K+ v! j1 N k3 o, x5 P( _
- #include <mach/hardware.h>9 _; q/ ~! R t) z1 P
- #include <mach/irqs.h>
( d/ Z* O$ k) q5 q8 C9 W - #include <asm/hardware/edma.h>
, `" a0 `4 ?% C: ~/ z: Y, T
8 V l9 i3 G, n8 ^! \5 B+ g( T- {- #undef EDMA3_DEBUG
5 f7 X/ l; x* | - /*#define EDMA3_DEBUG*/! c j4 o# W0 I
. \5 P v2 }9 u+ E+ U; G' J! G- #ifdef EDMA3_DEBUG& t" _, G( d) W9 Z* R, S6 \
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS): V. D- j3 I3 [9 g
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
8 @) v3 I* a% m5 ] - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
# b+ g/ u: x8 {! P - #else3 H' ?9 d3 o* n9 G' g3 l
- #define DMA_PRINTK( x... )3 n' G0 \# w. N/ U
- #define DMA_FN_IN
0 A* V" _1 u0 Q) U - #define DMA_FN_OUT7 \8 H5 B" P" X* P, h! i! V' p
- #endif
# j0 `' A: o) G: P( @$ E! L
# b# y- _# C" I0 k9 L- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
' h: o0 q$ h( L - #define STATIC_SHIFT 35 b) y) s1 v% j3 M
- #define TCINTEN_SHIFT 20
. R0 q0 b4 ]5 I0 W- B) f - #define ITCINTEN_SHIFT 21
8 x; M, x; K: O ]2 D7 G9 u - #define TCCHEN_SHIFT 225 O3 J( c7 A" q, ?( Y, H
- #define ITCCHEN_SHIFT 23* U/ @* ?. |, x! Q7 \7 e4 J3 O4 Z. \
- $ D6 N& W, k, ?- k
- static volatile int irqraised1 = 0;4 s% P% Q+ `6 Z$ W8 f
- static volatile int irqraised2 = 0;
( m3 m% o* Z" e H8 b
% M# i# V, x* O6 O; _9 Z- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 Y2 {% l* b5 x( | z - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& S- K% v) f& A! p+ d
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# I' V' ]% m1 ^, h+ Z
) S4 n0 v/ _1 D; |' [- `% b- dma_addr_t dmaphyssrc1 = 0;4 o8 E b6 h1 |+ p" O! `) W
- dma_addr_t dmaphyssrc2 = 0;# T* ?5 {3 [9 ^3 V- r& K: P
- dma_addr_t dmaphysdest1 = 0;
& G* v4 C! E1 A7 a - dma_addr_t dmaphysdest2 = 0;: d! y5 W3 H8 O
- 9 w y' @ z' M8 E' R* I) a
- char *dmabufsrc1 = NULL;
a6 W+ v% y$ u8 g- @9 J# E" y& ? - char *dmabufsrc2 = NULL;- X" O/ a, n9 M9 D& c; A; n1 H
- char *dmabufdest1 = NULL;
) }( t. ~+ F# ?2 ^- \" U4 z$ K - char *dmabufdest2 = NULL;
Z, H6 N) H" }/ l' a7 M8 t
0 Q) {; E2 @/ I7 O+ U1 v- static int acnt = 512;+ w2 |$ {/ l2 @5 D( ?" J! C0 l W* r
- static int bcnt = 8;1 C& ~% k3 z0 f4 B# L% o0 {9 F
- static int ccnt = 8; p- u( ~: F, |% |
- @( W: D3 P7 H. x7 P+ i8 C' ]8 m: [ E- module_param(acnt, int, S_IRUGO);3 L7 l5 f( S1 {5 \1 |2 @" q
- module_param(bcnt, int, S_IRUGO);& z A9 h9 q: t, q8 H, m
- module_param(ccnt, int, S_IRUGO);
复制代码
# U6 v2 l- a2 `8 @; [+ I) j4 `* i i3 h5 v: n
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ t1 |( l$ I# e* B4 F7 q% {' [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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。- ^+ @# y# w; G" _: U
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
" ]7 T& f b; n n( d# U. G, e& ~5 x/ V! E% b
Q: q0 @5 Q f
|
|