|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
7 B1 I( T' p H% B4 T. E- [code]EDMA sample test application
, u5 z# i" I+ s7 x: r4 L5 f - /*
# h: O# k( t' V( v& q" e - * edma_test.c
+ {; T( C% Q: J3 Q- C; H - *
; V9 H$ H, q ~' O7 ]/ H; W2 | - * brief EDMA3 Test Application @) {7 J4 W; B& y$ E% C+ }
- *' C7 p7 s" C( b+ s6 W: I2 x7 y
- * This file contains EDMA3 Test code./ T7 `5 d' p; j6 z( \( l- F
- *
/ i1 {$ \+ r/ Y; q7 x: @; {1 X - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
4 K1 O0 T. _# }' |' F4 G) e; p1 e1 _ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT/ B. v" E1 t$ U/ V
- * TO CHANGE.
+ _, y' ]2 s1 {8 L+ k( t - *
" p+ J2 p. x8 [7 Y' r# ?1 y - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/0 t' p9 J$ U, X. w4 C" P; c c
- *
( Q% G2 @% l0 a* y6 J - * This program is free software; you can redistribute it and/or
' G+ L1 `* T9 f) e7 p3 z, p3 J9 t - * modify it under the terms of the GNU General Public License as
% H* q8 F; \9 J0 d, n - * published by the Free Software Foundation version 2.
+ @0 e5 T- D" a$ `* t - * R S: {/ S0 E9 w9 }9 y+ ~/ K. q
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
& Y6 z2 g0 f$ I, }& L0 T - * kind, whether express or implied; without even the implied warranty
, Q M2 ^+ G% T; ]" R - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
. s& P2 [* ^; v, z - * GNU General Public License for more details.8 z1 O, }- ]/ ^
- */% [6 O7 W, L8 X& d, A
% Z7 ]/ Y1 ?; z& k! @- d- #include <linux/module.h>0 U0 p+ L' \+ \% c, Q
- #include <linux/init.h>9 r8 ?: ^' x+ H" o9 y) M2 z1 v
- #include <linux/errno.h>
S/ d. m/ U! U" ]5 Y& H) B ] - #include <linux/types.h> T* R, j( v4 ]2 q, w+ D* ?
- #include <linux/interrupt.h>
; {; w6 j+ ]! \* m - #include <asm/io.h>
+ C, E6 ?9 i" O% @" d3 e* R! i" | - #include <linux/moduleparam.h>
& w3 e6 P7 I i- s! [ - #include <linux/sysctl.h>! P$ c: e8 w9 [5 h- t' \
- #include <linux/mm.h>
: o S9 |5 o3 h: P( C8 _# o" G - #include <linux/dma-mapping.h>$ `& d6 e" S) k9 _
- 6 s9 c0 H9 w* K/ V* o2 d
- #include <mach/memory.h>, C9 N0 d; _# z# C9 t
- #include <mach/hardware.h>6 ]5 Z- e4 O) t1 D* T
- #include <mach/irqs.h>& Q) U4 j9 P' O: H3 j) m, [
- #include <asm/hardware/edma.h>, _3 K3 ^ @6 f- f
* e0 O. `; B9 ?8 c- #undef EDMA3_DEBUG
9 H; x1 V2 i* i( ] - /*#define EDMA3_DEBUG*/
% m" j: a) r8 k$ T S0 J8 b' Q# ` - v- e( [0 Z6 V3 n. J0 q% m Z
- #ifdef EDMA3_DEBUG
, \ z9 x; n s, O" K) A$ C - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
: d9 I/ h7 v# F7 E4 I - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)" q2 ^) w9 c9 D; J5 x% D& o
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
& h8 z* K9 [' Z6 O) B - #else5 Z& t4 u; N4 e6 H5 \7 z4 `
- #define DMA_PRINTK( x... )# q3 \5 A" v' X! y1 Y* Q
- #define DMA_FN_IN0 _ U0 A* Z3 b3 N" N% N* {
- #define DMA_FN_OUT1 T+ E! S8 ~+ A, v& |/ E
- #endif
2 e' q4 {$ E9 @( {
' R: s6 A; G6 Y0 K, J! [; w7 ?- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ N1 t* z8 t4 c( s2 T/ I5 z - #define STATIC_SHIFT 3! T& t! b3 A0 s$ T( R+ V
- #define TCINTEN_SHIFT 207 t# D1 N7 k2 x- N
- #define ITCINTEN_SHIFT 210 G$ r3 J2 B4 y
- #define TCCHEN_SHIFT 22) T; a F; \% ?4 i4 E7 i
- #define ITCCHEN_SHIFT 23
( V$ }7 G; T. e' L4 \6 x - 4 o0 b: ]1 |# O% X5 K# G
- static volatile int irqraised1 = 0;6 E& i; e" T; R/ p/ Z% g, C
- static volatile int irqraised2 = 0;
+ H- K8 X0 z2 p0 h ^8 F6 t" e
" P9 w) y8 ?: E2 W9 t) b4 s- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 z' X9 H, |1 a7 U- q% q - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 x: y8 J3 ^: p2 q' |, E
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 K% q2 \8 g8 O! p7 I' [
- 6 n: u4 C$ A' R3 p+ ^
- dma_addr_t dmaphyssrc1 = 0;* }7 }6 f; J" F4 Q9 ~3 v& ]4 c, L
- dma_addr_t dmaphyssrc2 = 0;9 i. _: b( B1 R- i6 j
- dma_addr_t dmaphysdest1 = 0;
" j; l7 a* M M; ]0 Z5 W5 J, _. n0 P - dma_addr_t dmaphysdest2 = 0;7 L; X% E; I0 O1 f6 x$ b% |; |4 O
$ v; g/ n- F! r @$ ?; r A% I- char *dmabufsrc1 = NULL;
1 y; \7 W" P# P5 K - char *dmabufsrc2 = NULL;
/ m. q. ^. {( ^. }. W4 \ d# m - char *dmabufdest1 = NULL;. B" {1 t! }0 w6 f
- char *dmabufdest2 = NULL;+ q7 r4 Z1 w2 p
- ! v g3 r, Q. V" L3 m, k8 G1 {
- static int acnt = 512;5 U+ l' q0 L' M. g9 D$ A2 E
- static int bcnt = 8;* g% C. d+ w2 d8 @, v, B
- static int ccnt = 8;
2 O3 e, \" C$ }, j S+ ~ - ( L0 J. B- b6 k8 }8 k
- module_param(acnt, int, S_IRUGO);6 i# h* m2 ]' }, j+ }" y8 P
- module_param(bcnt, int, S_IRUGO);
. k2 W- x A% p! ` _; c - module_param(ccnt, int, S_IRUGO);
复制代码
; | w5 t+ W. X; a& f+ }/ a( S4 z" z* H& ]/ @
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用2 V" o) \+ d# u( Y8 O
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 R/ F- r' J& `2 {1 N+ }% }7 Q; k 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
! [7 C' B3 m" D9 p4 c6 B" U
" |( d* A1 @& i
) w; s7 @# q- d& q/ U" w& O |
|