|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
{ C; y# x9 t& o, k) }- [code]EDMA sample test application
8 `& [) F) }! | - /*
& P- t+ G! W3 [4 l" Z, H - * edma_test.c7 W1 e m/ m+ ?! d$ m! q0 t, l
- *
5 G5 o% L& N' @& \2 a; {4 H; T/ R, { - * brief EDMA3 Test Application+ ]+ h4 \7 ` e; ?
- *
4 y6 x2 u$ D S# @5 W& V - * This file contains EDMA3 Test code.% A& m: T; Y0 N4 ?) P$ @
- *$ D: a' q [# E( j
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE' W, j# l+ ~, i: ]5 R: o
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% e5 B5 b5 }$ M, H' K" d - * TO CHANGE.4 `) Z5 d2 F+ A5 [# L1 O
- *
5 N: u9 s1 ^1 D+ P - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) ]- x! n8 ?, T$ j- R, Y1 F0 Q# u - *
) C' V2 W/ y/ P9 V2 p) Y. s - * This program is free software; you can redistribute it and/or0 W& f0 w6 g7 u' a# z
- * modify it under the terms of the GNU General Public License as+ e, T& I+ q4 K
- * published by the Free Software Foundation version 2.) F$ x# Y3 \$ }
- *
( ~- [, ~/ D, S0 ~ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ `% ?2 `3 d& s5 e
- * kind, whether express or implied; without even the implied warranty
0 X( N w0 P( f t# \ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 k: ]! {9 G/ ~% } A# j4 u - * GNU General Public License for more details.
4 W G) B% G+ v+ k# g1 S p - */
3 G8 _8 ^, f8 a2 m) ` - * ^, h) S; g" B) i0 Z% C
- #include <linux/module.h>
5 o( p! e2 u$ G. W8 v/ v - #include <linux/init.h>! _" n% [) N! b) R1 ^" L1 h6 c
- #include <linux/errno.h>7 n; z7 \7 D! q1 ]6 d) F
- #include <linux/types.h>
3 h- X/ V! Y8 ~/ \ - #include <linux/interrupt.h>
& {, O7 j, O/ R7 V4 v( e - #include <asm/io.h>8 o, p8 O; o6 A2 b
- #include <linux/moduleparam.h>4 p" m2 V V- I5 r
- #include <linux/sysctl.h>. C/ B8 d7 _0 z) N# ]8 _
- #include <linux/mm.h>, T! P) l, q3 v4 K' o3 \
- #include <linux/dma-mapping.h>( @6 W& U% l* A- c( S+ c/ S# g
0 ~" C8 @6 |& f- #include <mach/memory.h>1 k; O# @6 K Z" U. ]
- #include <mach/hardware.h>4 p0 ^9 c4 W t- B+ O
- #include <mach/irqs.h>
2 e K7 ~# D. g- K+ `% W5 {0 n% u - #include <asm/hardware/edma.h>- r6 n% Q$ {+ a9 [ {% g1 A# ]" t8 Y
- 0 ^( m& P/ I, A. ~
- #undef EDMA3_DEBUG4 j! E @( D' G$ I% H/ o6 w
- /*#define EDMA3_DEBUG*/
' W- e8 Q- L& v7 G
4 j5 h) W% d* J" U! a2 l1 v- #ifdef EDMA3_DEBUG
: C$ l9 @* e. {) u# Z - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
# h2 B' M' m: ~* l3 E8 R4 g - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
3 ?+ B/ ~/ P& o+ N( w - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
' R( i9 d, L* k" x) \) w - #else
. R% V, Q! c' \6 T - #define DMA_PRINTK( x... )
% o6 Y" M: F/ a& ?$ |0 E: b - #define DMA_FN_IN
m5 m/ h0 Q( Q+ F, o6 l0 T - #define DMA_FN_OUT
2 d# N1 m k% q0 P' i7 c$ O - #endif7 K2 K! T! A/ ^! D1 F& e
- 7 T: c. e4 h: i# Z3 o
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: D4 t9 ]9 L) @+ {7 o# P: D - #define STATIC_SHIFT 3& q4 X9 g# y S* G
- #define TCINTEN_SHIFT 20
- l0 ]; t6 k- x. U. u" j - #define ITCINTEN_SHIFT 21
% M8 m' M1 [3 g7 b' L0 k - #define TCCHEN_SHIFT 222 M w+ F/ M; ^3 U' N
- #define ITCCHEN_SHIFT 23
. z* V3 s: Y) ~1 _/ l
& O) J6 Z' ^! t% ^- static volatile int irqraised1 = 0;
, L" R" H3 @+ K% J7 K. N4 F - static volatile int irqraised2 = 0;7 Y4 J0 \3 n$ @( {' V% d4 [
- . }' r& n, N; @9 Z$ o
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ R( t9 ^4 X, [. N, p* x* i/ f1 @ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 s* v: {1 m. \6 Y, o: V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue); r0 c; |2 h0 I* M. H+ S
; w4 i) N6 K- N# \) R- ?- dma_addr_t dmaphyssrc1 = 0;! a4 o0 |: a. X. c0 v) X( ^
- dma_addr_t dmaphyssrc2 = 0;
! ? s/ b& t: n8 R n- L, w - dma_addr_t dmaphysdest1 = 0;
# z0 f' M$ G4 |! h. X - dma_addr_t dmaphysdest2 = 0;( s1 O6 H9 {$ x, V9 H9 ^
- ; s# U8 A# g3 w8 a3 n5 E. P
- char *dmabufsrc1 = NULL;
4 l' Q% a E" F* h( A - char *dmabufsrc2 = NULL;
% d8 k- g# u% m' s - char *dmabufdest1 = NULL;
, G* _8 A2 S; P1 l - char *dmabufdest2 = NULL;
* q5 u: @% ~3 p1 T; z1 S; X
1 H/ m7 J+ ^& @5 W7 r$ J3 {- static int acnt = 512;0 w5 |9 f3 {5 O8 h
- static int bcnt = 8;; ^' y# \8 x: m+ u% D" Y$ p2 b* x4 E
- static int ccnt = 8;
) r9 u/ |$ s; Z% ?! h
" l0 U; T3 d7 B- F( Y/ M, q- u- module_param(acnt, int, S_IRUGO);
4 h7 R; | H/ i; d( G' i - module_param(bcnt, int, S_IRUGO);. h9 x: \0 t+ P$ _: M
- module_param(ccnt, int, S_IRUGO);
复制代码
' q/ }+ a" v1 t: V: S& X4 w- ^9 Q/ B$ L
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用5 |/ x: p9 t& j9 ~1 P4 G
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
# a9 ^8 O* D$ u# z. @ 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# y) |1 H+ f% l7 o( H! z, d1 d& L/ g/ I J4 h! d& {$ E# b
2 j9 X+ f" y7 `) s7 H( F$ v1 V7 z |
|