|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ! X) C% ]8 D+ @: Y+ \
- [code]EDMA sample test application. r2 M: A* I: _/ L
- /*
3 P9 y- x7 [* S0 M- v - * edma_test.c7 ]3 [ K7 D& V5 D3 }9 v
- *
) a* C1 a% X/ F! N - * brief EDMA3 Test Application* o6 ^- J- i5 [; x$ O
- *; A: G' r2 ]( a- h( V
- * This file contains EDMA3 Test code.# _6 s+ n9 ~) e' W
- *0 I7 t3 T( w; u% r& T7 Y' t' q
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; o2 b+ B. U; ~& ~* J1 t' a
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
4 L% K2 t3 b0 ] - * TO CHANGE.
. t( T7 w$ @) o* G0 H3 g: a( z7 V - *
9 o( \7 f- e9 r! N) g. A; d - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
: n' _% Z8 e! Z& c, E - *; h- D {3 B7 w; X% G- G9 \; v/ G
- * This program is free software; you can redistribute it and/or5 a5 A; @1 c1 L. A
- * modify it under the terms of the GNU General Public License as. O7 p3 y9 x1 X# E* p4 U: @0 z6 C
- * published by the Free Software Foundation version 2. J+ J* C7 Z# Z$ \
- *
! C4 o5 L: \& M$ R# @ - * This program is distributed "as is" WITHOUT ANY WARRANTY of any- j8 N ?8 t! O% H; ]
- * kind, whether express or implied; without even the implied warranty
/ P+ c) M! q- v& x7 V% H# ? - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 P1 K* Q! V. C0 L4 Q" T2 p
- * GNU General Public License for more details.
' r8 z" K3 ^; ~, a; ` - */6 P! l$ i' B0 w+ P- J
, n3 ?2 @5 B& z3 ?# a- #include <linux/module.h>4 I) v2 j) S! a4 l) W! l( g
- #include <linux/init.h>
) Q5 N ?8 `) m, {9 E% k% I - #include <linux/errno.h>
. C. l( C1 m5 D! B+ F - #include <linux/types.h>" J* {9 O0 a* `' J
- #include <linux/interrupt.h>6 a$ ]; M4 q. B: c
- #include <asm/io.h>
/ Q- P' R" p7 n - #include <linux/moduleparam.h>
f& P$ U3 r7 g: T& L$ i" G - #include <linux/sysctl.h>& W# ^' o+ Y8 i/ J/ ?+ a
- #include <linux/mm.h>
& v7 V, `: G9 x, ^' J6 [+ R - #include <linux/dma-mapping.h>
: F# Y+ `' U: |' l9 q6 `( H
7 p" U* O- k0 M, a, [9 f- Z6 ^+ f* b- #include <mach/memory.h>! H2 b$ A5 J. B4 ~4 K+ |
- #include <mach/hardware.h>5 w7 j% N9 a) F
- #include <mach/irqs.h>
% J8 c# D0 ^5 r& M3 {- P. J3 E6 } - #include <asm/hardware/edma.h>; O3 D# N! ?0 Y. b# m; K
! {9 i, G4 ?$ s5 G1 i. j& w& G- #undef EDMA3_DEBUG8 ~ A1 N* Q3 j8 L8 Q
- /*#define EDMA3_DEBUG*/% z# ?/ G8 ^; f# ^9 v. l) f
3 {- C* L5 b/ ^- P3 [$ k% G3 Z- #ifdef EDMA3_DEBUG: u H, c/ m! q9 Q9 E
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
2 z& W& G$ _1 z5 X D& @8 u - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
+ f1 p/ {. ^* n+ s- U$ F: d - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
* ~' |0 f6 v w. v. x" L* t$ C6 f2 J - #else
6 m( `. C/ \2 A9 @( T% |9 c+ y - #define DMA_PRINTK( x... )
' E, `$ W4 V% |' e* Z - #define DMA_FN_IN1 b( ], ?( b* K7 Y
- #define DMA_FN_OUT
) T5 S7 o1 y/ ^5 F/ ]9 ~' T - #endif; [, f0 Z9 i' O6 G( a* U
0 z: x; k: _+ H( S- #define MAX_DMA_TRANSFER_IN_BYTES (32768)) u2 U( j, s( ?/ k' _
- #define STATIC_SHIFT 3
5 D7 j, J/ P. c - #define TCINTEN_SHIFT 20
5 S* [9 Q# A4 E% R) U4 N8 M" C) u5 v - #define ITCINTEN_SHIFT 21
m; D3 J4 a0 n9 f8 @2 l7 n - #define TCCHEN_SHIFT 22% Z3 ]' o/ d' t! C) G
- #define ITCCHEN_SHIFT 232 A7 A9 K2 p5 F" ]' m
' a3 F& W3 \! J$ P D2 ]- static volatile int irqraised1 = 0;2 p- Y: N' _& t# I( t+ n8 P& {5 i
- static volatile int irqraised2 = 0;
0 J/ p0 p4 b }0 V+ V2 R. R# h+ |
9 [4 x, W& Y3 x8 M( ~- i9 O5 @4 x- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) j! ~+ E8 J5 `; y. M/ \
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! h6 \; C2 U& }0 \
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 T" M5 w; L! i3 E7 x& L. ?& S
6 v! |+ f, G, N; n% a7 `- dma_addr_t dmaphyssrc1 = 0;
" k" t! S2 O' Q - dma_addr_t dmaphyssrc2 = 0;+ ]& f7 j- o) z0 [( R1 D6 N0 m
- dma_addr_t dmaphysdest1 = 0;
- ~& @5 I# |2 R+ h) z7 J' c8 p - dma_addr_t dmaphysdest2 = 0;; r, f% C9 X o
5 y6 ]8 ~2 D; e2 U- char *dmabufsrc1 = NULL;
) Z1 h0 F/ Q. A1 a" N- B9 ~ - char *dmabufsrc2 = NULL;' c; b* v' b: J; S6 C Y* G
- char *dmabufdest1 = NULL;
9 `' @- l4 V( }3 V* B - char *dmabufdest2 = NULL;
& ]$ V/ K' v9 Y5 O2 H: d - % |( @" h w: V
- static int acnt = 512;8 {2 \+ G0 |8 J8 H: e4 Y
- static int bcnt = 8;: C' @( @& I6 L- d& p+ {: ]+ ]
- static int ccnt = 8;4 d$ S& k' A7 Q# g$ Y5 }
- & q4 }! ]7 u8 W# |# }
- module_param(acnt, int, S_IRUGO);
0 J, j! m. ?, C0 A# E; I - module_param(bcnt, int, S_IRUGO);
, y) C$ p5 |1 c% {! z% e - module_param(ccnt, int, S_IRUGO);
复制代码 5 t. Q) u, c: U4 y4 }
" a P' Z" T) P7 C* \2 ]
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用( M( d. O" ^- @# P& b* K
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* P! ^% R8 y2 O/ N/ P! Q% M/ S
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
4 ~# A6 H' A; e1 c; ^( z; Z; B; X6 x/ T% i* m+ U8 U4 g
* ^2 j! N3 A3 p6 s# n1 A% |
|
|