|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 0 r' \6 E8 {" g
- [code]EDMA sample test application2 |7 K9 q8 ~; e6 {
- /*
# e% h- ~5 ?" C8 [- q - * edma_test.c
- @* j/ g! N/ g( ? - *! [& i2 Y& w% d5 C6 B
- * brief EDMA3 Test Application
3 W' g3 E0 U! \# ?8 ^9 W - *
5 K8 m& b) P* O4 \" {' F; j+ E - * This file contains EDMA3 Test code.: n7 L; L) r+ m
- *1 e& j1 N4 e7 c, B
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
C& {1 }3 _8 c! k3 X8 @& Z$ d - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT( g; q# ?4 p$ `1 O( J
- * TO CHANGE.
5 u* t2 j$ ~3 f: g" T6 y R - *2 B( r) m& [0 ~( I
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/" J3 _/ ]1 E L/ Q# g; A$ X A
- *
: @" R% H0 U$ J( c; L F J* m - * This program is free software; you can redistribute it and/or
% \2 @( y; z& l - * modify it under the terms of the GNU General Public License as- ]# ]% o- C$ t% |/ A' M6 a
- * published by the Free Software Foundation version 2.6 k* i4 ~8 U$ Z
- *
7 k" _" ?! \5 j N( H - * This program is distributed "as is" WITHOUT ANY WARRANTY of any0 I2 x# W8 T3 ~/ K6 }# {5 i
- * kind, whether express or implied; without even the implied warranty& a8 H# A- ]1 Z, m' I
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! v+ q% v5 H; R - * GNU General Public License for more details.: y f M! g5 g; b2 Q9 S
- */+ o& c+ s6 s9 |8 {+ r
2 h0 y' E, R- G5 `6 W! ^* P- #include <linux/module.h>3 J3 K" U- H0 O
- #include <linux/init.h>) ~ J* a7 @* O9 V, y6 ^
- #include <linux/errno.h>4 \; @6 O' T0 n( d; G$ o
- #include <linux/types.h>, C! _, V/ A: u) U* u/ t
- #include <linux/interrupt.h>* t; S. p) e; X) n2 k8 d3 j. l
- #include <asm/io.h>' ?& H, f) j" w! q C/ U3 _
- #include <linux/moduleparam.h>$ S+ L8 }8 P u: t J7 y
- #include <linux/sysctl.h>
/ E! {9 g/ f# o- ?$ r - #include <linux/mm.h>
& W, s6 j1 ~" P( |5 t% V - #include <linux/dma-mapping.h>
/ `: B0 `8 x1 \0 Q$ \6 P7 B
& N3 `+ U3 V+ N Y7 u# Y- #include <mach/memory.h>
) x5 ?1 _8 I9 J" P - #include <mach/hardware.h>- J6 v0 C& E) k) i, x. {6 L/ m9 H
- #include <mach/irqs.h>
) y) G8 M5 k' { T. N- M - #include <asm/hardware/edma.h>
! l E# Z z4 g0 c8 u - 6 t) L) w7 K# |& C! \
- #undef EDMA3_DEBUG
2 }6 o: {+ b' g' [- t* e2 I - /*#define EDMA3_DEBUG*/
1 [' }$ |, r# S" ?2 e
. l; \0 }& N y6 I- #ifdef EDMA3_DEBUG; ]; k, o! q9 A7 v. B- q) s& m
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& T% C8 A: c% j% X: i! _
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
) u5 ~, g9 \$ O. t: M" y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)4 W8 @( ~4 D& c* g) `. f2 M# m
- #else2 T- U9 v2 C; Z b) U
- #define DMA_PRINTK( x... )
* S& r( L: y% G5 H. C - #define DMA_FN_IN* O5 V$ Q! i, p" R% _
- #define DMA_FN_OUT: v8 j# t) T$ o- c* J( t2 H
- #endif, P! d! t& |5 T0 I9 R$ Q
7 T) ~7 x B3 [0 C% O! _( ]- #define MAX_DMA_TRANSFER_IN_BYTES (32768), V+ {7 Y2 F/ Q0 a+ ?, D
- #define STATIC_SHIFT 3
9 |4 _2 w1 R+ z - #define TCINTEN_SHIFT 20
2 X6 j: [. c3 p) q1 f1 f - #define ITCINTEN_SHIFT 21; p# e- ]/ g% G. K% B+ n* X
- #define TCCHEN_SHIFT 225 V8 P ^: g* y# t3 d3 n5 P- X5 M
- #define ITCCHEN_SHIFT 23
y4 ]& G4 ]* m. }# f6 W( X% }: } - 9 b- @. c9 M1 D
- static volatile int irqraised1 = 0;
7 M5 L1 k' m3 j - static volatile int irqraised2 = 0;
4 Q2 ]6 g9 u/ {' C
3 o$ S9 S" e; K8 b% O- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
3 I4 b# I$ x, K3 ^8 f$ J - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& K" B# b7 J6 V - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
0 f1 k1 g" P6 t8 b2 ?/ ~$ F
5 w' ?. r+ o1 B/ T- dma_addr_t dmaphyssrc1 = 0;
5 u0 O/ X8 G' `: Y$ O8 k3 B9 U5 S - dma_addr_t dmaphyssrc2 = 0;
2 A* [5 J W8 M, `" e1 j2 U - dma_addr_t dmaphysdest1 = 0;* F" \/ m( @& I
- dma_addr_t dmaphysdest2 = 0;
6 _3 e+ ~- k# I( m0 ^# R
. @ G7 o0 b" |: U3 A- char *dmabufsrc1 = NULL;" H1 |* u; z5 E# k, ^4 j5 A5 J: J2 }: G
- char *dmabufsrc2 = NULL;
3 y7 F5 _! {* \0 ]: g3 i - char *dmabufdest1 = NULL;
: l7 O. S& r/ l7 |* Q; R! M9 u - char *dmabufdest2 = NULL;) a* J1 E7 ?1 e
- u/ N ~ V9 z! H2 S( o/ Z+ Z& n- static int acnt = 512;5 C6 s" m* p, x& l P
- static int bcnt = 8;) x$ G9 _% K; M8 a7 r m
- static int ccnt = 8;0 Y9 m( `7 Q% w: Z8 w( I
- . V K8 @0 g7 }
- module_param(acnt, int, S_IRUGO);
+ T+ G2 |) ?& z' \9 L - module_param(bcnt, int, S_IRUGO);
( ^4 U- ^8 D" z) g. H9 W: j. { - module_param(ccnt, int, S_IRUGO);
复制代码
; H1 Z# [% M! E0 |3 S. Q: [! B6 M* }. B4 [' @
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
0 C- [2 `9 Q: \4 E# Q9 carm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 H3 L; j" C0 Q- Q
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
# r3 @5 q0 H. {/ C9 a2 F* t w0 q, E2 z3 }
/ W4 E: G C* e$ `4 }1 f; K |
|