|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. S2 @& K0 A$ i: E4 T0 Q- [code]EDMA sample test application
% Q0 B( l/ B. r; k8 k3 q& }' T3 u - /*4 [2 T3 m K9 k5 z
- * edma_test.c4 C9 q. P( ?; A7 k X* z7 s9 B
- *
2 }& |0 p+ C& I/ y" z - * brief EDMA3 Test Application
4 J7 ^" a0 _0 f/ N+ g$ A - *. J; D: w# S3 [ k+ F% Q: M& B
- * This file contains EDMA3 Test code.
- d- J5 o8 Q# |' }. C0 T - *6 b0 w5 D( k% d
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE. P Z, c$ x. g- h
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT" Q$ W& D% v7 V- ~% p. g5 h
- * TO CHANGE.( y! a, a _0 v: k6 `9 S: I
- *3 G. f. R5 b' ?" N% u7 ?+ o
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/; p' h! n7 a3 n7 f! L
- *
) }/ x& }# D# ~2 ~8 F* b5 K - * This program is free software; you can redistribute it and/or# M2 {/ R& W% E' {/ }9 S
- * modify it under the terms of the GNU General Public License as
' v# s6 u2 G! p8 n7 B - * published by the Free Software Foundation version 2.' v: J% t a `* Z+ |: J. n, j
- *, k+ R' W% O- }2 v7 j( e0 g
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' r3 N! K0 R; z6 d- v' M' U - * kind, whether express or implied; without even the implied warranty
* u- n# X* D1 q7 ^/ f! E) b R A- Q7 [ - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# W; t% ~) K+ o. w% y6 V. c - * GNU General Public License for more details.
; E, t( R0 [+ X' J( ?8 L) `9 X% D - */' D% [9 d1 v) o' i7 |9 u
9 o3 Z; Y* B: O( A) N& ^: z- #include <linux/module.h>1 }1 h; o1 K& I; f$ a3 D6 O# P9 M4 ?
- #include <linux/init.h>% o1 D9 E& R7 O J
- #include <linux/errno.h>
5 e% e8 W* b: x3 G - #include <linux/types.h> t3 H p; s! i8 j0 X$ k$ L* R. r
- #include <linux/interrupt.h>; {. C$ q/ w$ G
- #include <asm/io.h>1 j. j. S7 d) D
- #include <linux/moduleparam.h>
/ D9 j% J9 X ]+ P* a - #include <linux/sysctl.h>
" N/ p& J9 [! x* Y7 Q0 I - #include <linux/mm.h>+ J; Y% j2 p, u8 e) ?# U
- #include <linux/dma-mapping.h>+ \0 l' i& A, E9 d
- 5 t9 \8 `# x$ v5 u/ M
- #include <mach/memory.h>
' a1 n2 ~5 C) h - #include <mach/hardware.h> |3 Q6 d; c2 s5 g9 T! c
- #include <mach/irqs.h>
X. S8 Y4 K( H- q& {% ` - #include <asm/hardware/edma.h>
8 a7 Z" r: Y3 d& y8 I( Q, u! g - : [2 s2 b6 p( A: A' n
- #undef EDMA3_DEBUG8 a' A* p. q. ]8 w
- /*#define EDMA3_DEBUG*// {& y* s H* u# s
( K7 L) g) @8 {9 x0 x) N" l' l- #ifdef EDMA3_DEBUG/ _3 p1 V6 x, Z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)/ Z& N. @2 L4 U' j
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
2 ^/ V3 `* H# |4 D; y - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
' e* t T. a. B0 C - #else
& Y- i" ~/ P/ H3 ?1 {# C% Y - #define DMA_PRINTK( x... )! T0 }8 o( z" E% V# u( X* r
- #define DMA_FN_IN$ m: w8 d* O/ C
- #define DMA_FN_OUT+ \6 n4 Z3 U$ \8 Q C1 \4 H, }
- #endif
4 b- H5 b" y$ S9 \& U& R& a' k* Z
- k: B3 o. S6 h/ W2 N8 m% U1 X- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
3 B5 \( L8 c+ K5 I7 h - #define STATIC_SHIFT 3
* F8 M/ Z, R8 _% t( O - #define TCINTEN_SHIFT 20' v1 _( c6 O4 Q' E2 h$ w
- #define ITCINTEN_SHIFT 21
- o0 \/ N, d" Y! }6 ~1 l" z - #define TCCHEN_SHIFT 22
4 h. F& M. T3 c4 ^2 b7 L - #define ITCCHEN_SHIFT 23
2 P6 Q- c4 H4 g; k- a
: B9 J/ g c+ k# D- static volatile int irqraised1 = 0;
6 `6 l& T. x0 P+ E' j% u - static volatile int irqraised2 = 0;
8 A( t. {9 E T& |! _
3 R0 n4 R e( N9 P- u4 z8 o5 q- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- o0 |, j4 d* I$ z' S
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);+ E6 F- A T- e9 _- \0 Z4 ?
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ }5 m [: }. v+ Q/ g& i1 E; m - ( \4 m5 u/ ]8 `9 `: @
- dma_addr_t dmaphyssrc1 = 0;
( D7 p; d+ ^: |8 b$ B - dma_addr_t dmaphyssrc2 = 0;
( P1 N' A. {; m7 i G3 j/ | - dma_addr_t dmaphysdest1 = 0;- A+ B8 t" ^& p
- dma_addr_t dmaphysdest2 = 0; q( u4 l6 y4 D, L5 o
1 a, L( O$ e+ W" t* F; O0 A5 c- char *dmabufsrc1 = NULL;
6 P: y& g7 J/ O/ R# D7 A3 s! j - char *dmabufsrc2 = NULL;
7 S% O* t2 L* ]7 Y! u+ F - char *dmabufdest1 = NULL;
9 {* W5 P$ x, c* N9 Y# Y, d - char *dmabufdest2 = NULL;& y( o4 y" a! Y2 n! o' w3 z8 j1 W
; m' s B2 A0 [) [) z7 i n- static int acnt = 512;
$ s8 ?3 @- e' j- R( ^: ^9 u - static int bcnt = 8;/ a% W# V$ b) Z
- static int ccnt = 8;
3 I; v0 k, C2 L' L6 s
1 }' _6 Q: H! a4 z( _2 t$ \) E- module_param(acnt, int, S_IRUGO);8 d; ^) g3 u# V1 T5 T( ^- b
- module_param(bcnt, int, S_IRUGO);
$ P+ L A1 h; ^. y* B e - module_param(ccnt, int, S_IRUGO);
复制代码 5 [2 y: k' @ K( O6 o# S# u5 [7 _
' q& i, k2 c& h3 E, W! g
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
$ A) F6 _3 Y3 {* Tarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
2 ~3 g5 m8 E& s5 a6 W( A 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ S( D7 v. H. |* C' j
7 m# ] h0 f0 }
, f2 r4 R+ Y7 {) H |
|