|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
& H }2 A2 ]" p- D1 J8 c- [code]EDMA sample test application
4 \" Y, l/ [7 e9 Q0 [ - /*
& `% r5 b# D, i3 B% O3 m - * edma_test.c% C" i: @2 N' e
- *, i5 M7 i: J( l! F
- * brief EDMA3 Test Application$ E: r# @, @+ m* `+ I. `; T
- *
4 J9 l$ T9 F& ]6 Q; Z - * This file contains EDMA3 Test code.
; s% O3 l6 R7 {9 r f - *8 \8 b) u) j" g! s% ^8 y
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
1 e! s+ v3 W7 m7 Z - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
7 O& T- v) B" [8 o - * TO CHANGE.5 i# v) B% v8 l% }- Q+ ? \
- *3 X% `0 i7 B" d% j
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
- P$ R% E- @# d" B4 B; M - *
; b7 z' B+ I' O* ]8 D8 L$ k1 P1 d% w - * This program is free software; you can redistribute it and/or+ b J) I. K0 b+ P6 A. I* X' u7 i
- * modify it under the terms of the GNU General Public License as2 W E! H2 B; F5 B, s' \
- * published by the Free Software Foundation version 2.
: `# ]9 z4 F- j- c, b" ? - *
- W8 b5 p7 i) R5 |9 Q% L9 _6 o2 n - * This program is distributed "as is" WITHOUT ANY WARRANTY of any( W) h9 ?" i/ H& [* ^6 }7 M+ e
- * kind, whether express or implied; without even the implied warranty6 e1 X9 U `) p p. o
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 g) U# A: w* R1 J6 w3 ^
- * GNU General Public License for more details.; g* \, B0 `0 W
- */( V% W) Z6 L9 l. X
- " |6 C/ \8 `2 f, K2 L- P7 \% m
- #include <linux/module.h>
2 X) ~3 V6 j+ F( f y" i - #include <linux/init.h>
3 \; J) Y# N, I4 m - #include <linux/errno.h>
7 `. f4 }. |& }& P; T - #include <linux/types.h> x) N, A. m3 C# O+ W; K
- #include <linux/interrupt.h>
/ M5 G3 @' s1 `4 l/ {6 G - #include <asm/io.h>
) v& s, @6 @0 C* x2 m! | - #include <linux/moduleparam.h>0 _% r/ D* O$ h. E
- #include <linux/sysctl.h>
7 e8 n4 O. M/ a1 W% L# l - #include <linux/mm.h>
) V! Q) |( o6 `" o, _2 s- H1 l - #include <linux/dma-mapping.h>5 C% Z Z# T( k9 P/ i0 B
' J6 h# [- E# R# a- h- #include <mach/memory.h>: f" d; e* v l: N
- #include <mach/hardware.h>% t/ }' a, j6 S( T4 u7 I
- #include <mach/irqs.h>
& F. C# N9 D" F5 T( S$ e6 P6 H b - #include <asm/hardware/edma.h>
" j* ?7 b; S+ |! M - " F" m" K' k/ G# ]+ r% u1 M& `( d
- #undef EDMA3_DEBUG
6 e. l' O5 Q5 R! X' d z- _- b - /*#define EDMA3_DEBUG*/
( C8 ?) \, l2 V! j
! q6 O3 b* A+ i( g$ _6 n2 X- #ifdef EDMA3_DEBUG
7 o$ q: h. h8 D! ^3 f - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
6 O, s' \8 |) F" ?- I/ W& E - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
1 w9 C6 D" v* P) e - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
1 e: R* t1 P' H0 I - #else3 H4 |- c( }; h; ]
- #define DMA_PRINTK( x... )6 K! c. s, a* h5 J: [
- #define DMA_FN_IN) P6 x [' c$ X2 S3 O, d8 x) E
- #define DMA_FN_OUT
3 s, }/ N5 G+ S1 f - #endif
, _/ K, w; s$ _3 m. y
" m' g2 e/ {0 K/ i7 U7 C- #define MAX_DMA_TRANSFER_IN_BYTES (32768), j7 x$ t" ^: S, Z, o1 A- D
- #define STATIC_SHIFT 3
m3 S: W { G( z/ i6 Z - #define TCINTEN_SHIFT 20* Y3 f1 e/ L; K! H# M
- #define ITCINTEN_SHIFT 215 k7 a' T$ }; [# h+ Q
- #define TCCHEN_SHIFT 22
+ Y p1 L8 Y. q* {0 w' L - #define ITCCHEN_SHIFT 23
' n8 J; l( h( ^" e
* O' I3 d' i' l- K- static volatile int irqraised1 = 0;3 P4 n9 {7 u0 J) d
- static volatile int irqraised2 = 0;# r( a$ ?, v4 z" Z; N, {3 c, A( ~
- & X* L3 N) Y- Z4 t' X" g: p" t
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
4 t; [. d9 t5 m" J - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* ^7 S" O& X3 F8 g - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);/ k) |7 {6 C# n8 J4 \5 r
- 1 _- B( {: Y5 o4 e8 X) ^- J7 {
- dma_addr_t dmaphyssrc1 = 0;. H2 z$ I! C# T9 X. v
- dma_addr_t dmaphyssrc2 = 0;
2 ]1 E7 M" e& E- h, R - dma_addr_t dmaphysdest1 = 0;
! ~) S2 h6 k3 i) Y: i& G- n: L - dma_addr_t dmaphysdest2 = 0;8 L) R' q0 Y# t1 R+ F
( J }$ f6 @+ s- char *dmabufsrc1 = NULL;: U$ ]; b' @: o' m3 V1 ^
- char *dmabufsrc2 = NULL;' Y" x4 }" X% p
- char *dmabufdest1 = NULL;9 f, Q' ?2 u* h8 I7 b6 G
- char *dmabufdest2 = NULL;
: R. t/ w2 k0 X" D! g( y4 j" Z - s7 H% Q# D9 B9 E' t/ A" W. u9 n- g% Z( ~
- static int acnt = 512;
1 c( |! |$ W8 u/ p. | - static int bcnt = 8;1 k5 H Y/ y/ f. ]( H( d' M
- static int ccnt = 8;. o$ l$ a' c7 F% E' R
7 K2 T$ [: K: ?' \- N {8 B3 _- module_param(acnt, int, S_IRUGO);' n0 u2 T( N0 M) G! S
- module_param(bcnt, int, S_IRUGO);6 Q2 K- b! h4 Y: a- |; S+ O8 @
- module_param(ccnt, int, S_IRUGO);
复制代码 ' s9 s7 x& _% k% k
, V# s* @0 `& a% E' j4 V) y% s 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用 `1 N6 W8 h+ B9 K c
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。& H: X/ O9 L# B1 K$ a/ q
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
9 O9 ]1 }! X; Q l5 R6 x, f" @; G2 j _
9 W. W% ?, o& | |
|