|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 , t( s3 p( y9 m* q; Z
- [code]EDMA sample test application
! t7 v+ F: u/ g4 ` - /*, K- _# g0 w/ [, S* x3 _, F' n9 ^
- * edma_test.c
3 P$ h' B% ]1 O) ?9 f) S: ]- K - *" G) W4 @/ @* j6 y- W2 }
- * brief EDMA3 Test Application q- L: r& l# C1 E; m7 Y" Y* I
- *
* W7 s3 b- {( R- b) P4 | - * This file contains EDMA3 Test code.
; o1 V* d9 m7 x+ W/ r - *
/ c% y, }! w, G. Y q - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE n& v% i9 M9 E+ c9 l5 x
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT# ^( t& V; X# L" Q
- * TO CHANGE.
/ w# D) W- m S1 u7 L# G7 E% v - *
; F0 C O9 c. }. T( M1 {) [ - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 N% F1 c/ g' P% ^6 u) K! q - *
) n% h% r/ r4 F3 C% {3 U6 U - * This program is free software; you can redistribute it and/or
7 f5 m0 o7 V3 p& H! v/ h - * modify it under the terms of the GNU General Public License as/ W% u" l0 s( P' K& L% }4 H" C
- * published by the Free Software Foundation version 2.* Z- Y% r2 b! A8 M# P: ^
- *
" i4 \% f6 L8 W# O - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
# Y0 K* N- b4 Q: M& j - * kind, whether express or implied; without even the implied warranty
$ ?2 I) E1 k8 L/ S- R! G) p - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* q6 V* y; I* j' U G+ W - * GNU General Public License for more details.$ [: z6 g, [* j2 [1 c k
- */
& A1 Y0 o+ q4 V4 n - 4 j8 r: G" a0 e& r8 R2 l
- #include <linux/module.h>8 H$ e4 B4 d- ?/ S
- #include <linux/init.h>8 x2 P" r& ?" t6 u& r/ K, Y
- #include <linux/errno.h>
- }5 J$ R# Y0 q( k: ] - #include <linux/types.h>
* `7 Y- j. S$ x3 g, T" k - #include <linux/interrupt.h>5 Z: h* T! h' d. y" N
- #include <asm/io.h># G9 H6 I- r" e' X* R5 c; q7 R; |7 N! P
- #include <linux/moduleparam.h>2 \; j3 d: d" K" X/ u6 K% Z9 i+ d
- #include <linux/sysctl.h>
! o: C- G6 R2 W, ^8 [# X& y& n4 p - #include <linux/mm.h>& o- z; n% y- y* A0 j/ _ f8 `% C T: ?
- #include <linux/dma-mapping.h>
' K; X7 }- B$ P7 c( y; e - # d; U0 {$ o" ?
- #include <mach/memory.h>+ h# q7 D5 \8 @- c/ P2 p* q
- #include <mach/hardware.h>" F- X/ J) X' n1 o
- #include <mach/irqs.h>/ {( H! I+ ~2 x( Z
- #include <asm/hardware/edma.h>9 @) m# Y6 H$ r- }& m
- " C/ G, k/ w# g2 R6 }- t# c8 W
- #undef EDMA3_DEBUG
: W; G$ X3 F) y! \' g9 E - /*#define EDMA3_DEBUG*/
* _- ?) E8 m# S* T% H$ d; x
6 j+ i4 F) Y0 L6 i+ F* \5 d7 |& q- #ifdef EDMA3_DEBUG
9 I1 p4 u$ A* R+ e) H6 I9 i" [ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)# }" U$ \3 f2 U! o9 ?
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
3 D- J2 j7 Z2 Q% G - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)* r6 [! P5 U" M) I+ q4 F5 G" A6 |& k
- #else
+ c v2 ?: \ U0 }) l - #define DMA_PRINTK( x... )
( T4 X* h I$ c' t' R. j - #define DMA_FN_IN$ E/ m$ ]& ?" w2 W. V% B+ p
- #define DMA_FN_OUT
$ C6 D% P. w% n6 G. f - #endif
$ \& m9 @6 f @8 ]- `$ ] - 7 A3 }' v8 x8 ^
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
W" ~% B- a: v) U @ - #define STATIC_SHIFT 32 ? x# w/ M7 d- P4 b' F4 z+ @$ Q0 I% |
- #define TCINTEN_SHIFT 20( x5 m4 U# t$ L0 v# s
- #define ITCINTEN_SHIFT 21; S- C4 X) b+ }1 k2 a9 G4 Z& T1 S- T
- #define TCCHEN_SHIFT 22
( J E5 [. U X# X% U - #define ITCCHEN_SHIFT 23
$ u# o, p) i- n6 U( V/ M
4 z6 ]* C9 B" u$ ^* ^- static volatile int irqraised1 = 0;
) e% C. K7 ~9 c- E& y - static volatile int irqraised2 = 0;
$ m! D4 e7 X; f9 m' h
+ M& H9 q5 E& I( K- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 O' \' V, M* @/ x7 S4 ?3 i. a
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, y0 G4 I' U1 c. b( {+ @* h - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 f9 y1 q/ q0 G7 x" r8 V5 w
- . l. q* L. v' t$ M
- dma_addr_t dmaphyssrc1 = 0;3 C8 Z7 C) O+ v
- dma_addr_t dmaphyssrc2 = 0;
5 L- a) C% G% r& b: i( @1 D - dma_addr_t dmaphysdest1 = 0;
$ g5 X& m* s( c `5 | - dma_addr_t dmaphysdest2 = 0;: A7 ?: Q6 z6 ` x
( c1 f4 h% k# d) \) x, n- char *dmabufsrc1 = NULL;
/ n' K, }$ i9 n# q - char *dmabufsrc2 = NULL;
# F2 M9 C* E- o7 n( m# d - char *dmabufdest1 = NULL;; G% k$ D! {" U+ p
- char *dmabufdest2 = NULL;% W$ l) r S6 \- n( S- A/ y8 `
. v/ Y; z& J6 ^- static int acnt = 512;
b0 z1 R5 u1 [, E) z - static int bcnt = 8;+ {: n3 j; h j8 C* w
- static int ccnt = 8;
" h! X% x2 c# ^/ K8 D% Y6 G
) N3 z/ |; G5 J- module_param(acnt, int, S_IRUGO);( |3 [" T" Y5 I
- module_param(bcnt, int, S_IRUGO);( {2 z) h/ v& Z& [% m3 \7 M
- module_param(ccnt, int, S_IRUGO);
复制代码
7 K2 y7 H g" Q0 K+ \5 m; }1 J, s4 T- Z1 N9 x7 G* A, J( o
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. m" M5 Y& x( c9 Zarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; |5 c8 ]- @$ y* \4 m5 e
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。" u# Y8 B. u7 H1 ?( t
. i* n, r# ]& z7 v( e
3 g2 h0 v$ T$ c: O4 j# o. r7 l |
|