|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
0 I1 ]4 {+ c6 H- [code]EDMA sample test application4 D- ^6 O$ X- O: p/ K3 h* ]
- /*
2 G/ N) X2 B, S, k6 `0 H" `: f - * edma_test.c
% T5 f' ^# {, k1 E/ n) T, I( W/ y: c4 u - *1 f6 Z0 q( G( t- }
- * brief EDMA3 Test Application
. l, C. Q- C/ ?: y - */ D- c' d% d7 u3 M$ c, I( ^
- * This file contains EDMA3 Test code.
# L) \( ~& ]/ ^: t* ?2 ] - *
& i2 J% V( a0 |( l - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
$ Y, w" e" Q/ J6 _) p/ x - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
& d* q9 R6 _( r6 t - * TO CHANGE.
2 R2 O1 g+ o. o3 |! _& M- k - *
+ {" |& B1 Q6 W3 p. Q - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/) X$ a9 _2 [3 m! g! {# {
- *8 n, y9 e8 T% F6 b3 y7 y, k, |
- * This program is free software; you can redistribute it and/or
; d; n( M- K! Z6 p3 b' }4 v7 I! w - * modify it under the terms of the GNU General Public License as$ \. v7 b: C" Y7 x$ u9 U
- * published by the Free Software Foundation version 2.
6 Z& G; t3 q. W: A& z, j1 ? - *
; W( ^. f) ~9 {+ p5 I8 a - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
8 k5 R" \* z1 [( T. Z4 c - * kind, whether express or implied; without even the implied warranty( M: @+ c' F3 e6 Q1 E* }' d
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the1 v/ B8 H. {+ }% s, z2 K! T6 \
- * GNU General Public License for more details.
' s3 d; h/ n( a6 X - */
) f* u2 @: {6 { O% H - + o+ h6 g U7 t% r3 B# b4 }8 V
- #include <linux/module.h>. [7 X' Q1 S! w
- #include <linux/init.h>
8 @ B# N. Q% M - #include <linux/errno.h>: c# P) j) v! d) z, f
- #include <linux/types.h>
/ i5 T H1 C* I5 i4 l - #include <linux/interrupt.h>
* d) X9 u9 _9 U7 r - #include <asm/io.h>0 Z6 M, A4 s. o3 y' u) l* t
- #include <linux/moduleparam.h>
2 y. V8 {, a: y H3 A7 S0 } - #include <linux/sysctl.h>
. D0 P3 F5 I2 v/ Q" r- A - #include <linux/mm.h>
. o5 ~ J' n" W& J6 q - #include <linux/dma-mapping.h>6 D* D5 Z. [* k
/ L! x3 e0 z5 E+ l5 s! C- #include <mach/memory.h>1 P( g3 x" L7 c4 V7 v
- #include <mach/hardware.h>
( c9 H" r# Y$ O' ^ - #include <mach/irqs.h>
- }* D- F( Y) b+ k- ] - #include <asm/hardware/edma.h>
8 t" Q% X0 ^8 [0 j- _$ y: I* P& n' E - 4 X% R0 A. w. h; o% |
- #undef EDMA3_DEBUG
" T- A v- V% U! i7 L/ H - /*#define EDMA3_DEBUG*/
/ C0 C9 B+ _; |5 U8 I X7 U) O - 0 N, w# n* `$ a) s3 X4 x+ u7 s* C
- #ifdef EDMA3_DEBUG
" d0 g7 F+ H5 u2 z! t4 X - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
- i1 w) [, }9 N( ` - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)' }& {* \" P( o1 z( z% \
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__) T- F( J9 B0 L8 A! C8 p- Y+ Z! k
- #else
. I. S5 ~4 n. h9 _ - #define DMA_PRINTK( x... )" \0 U' O5 A1 z3 E7 N" x
- #define DMA_FN_IN
) a" y* z1 Q1 e- l - #define DMA_FN_OUT0 w) ]5 @/ v4 n3 w1 ~0 A
- #endif
& }, z4 H) j% G; N- W
1 y/ F- D3 c' b+ f6 S$ i1 I- ^2 r- #define MAX_DMA_TRANSFER_IN_BYTES (32768)8 x7 h- E! W$ E' C
- #define STATIC_SHIFT 3* Z1 P+ E* V1 e" [: `+ _( F
- #define TCINTEN_SHIFT 20
! X# Q3 I3 [: e1 X" j2 I - #define ITCINTEN_SHIFT 215 ^. d8 K( X& S% o$ H
- #define TCCHEN_SHIFT 22
- C+ t* e- o9 @+ A! `* b - #define ITCCHEN_SHIFT 236 B& ^/ G2 j6 v: [$ A
- 8 p( x* E1 K" C9 T$ ]: o" [ b- z
- static volatile int irqraised1 = 0;
) i7 Y' R9 s% ^& n' q& g; ~ - static volatile int irqraised2 = 0;
, v( \( O7 d T5 r) m( V
& A# {! G2 T5 [4 d" a- l* l- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& ^+ T' e' ]- ^ o - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& \3 a3 G# z' v4 X3 v/ v% b, n
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
s, ^: K! B9 S1 f& s6 Q1 e
4 Y1 `# D' l. _! R- dma_addr_t dmaphyssrc1 = 0;" x0 u# s/ J) n2 u
- dma_addr_t dmaphyssrc2 = 0;
; C5 x- C& m6 S - dma_addr_t dmaphysdest1 = 0;1 F ^! t! A. |! [1 R
- dma_addr_t dmaphysdest2 = 0;
; ?, {% t1 g& `% l: Q
( n; m0 h5 j# o7 u( R! _- char *dmabufsrc1 = NULL;
1 ?( D& X' }1 }5 `# Q- O4 Z8 |# J - char *dmabufsrc2 = NULL;
, m) g, K, O4 d6 P - char *dmabufdest1 = NULL;
8 F" A3 y; f; u* i7 z' @ - char *dmabufdest2 = NULL; b3 \% C" y5 f' C, g
- 4 P9 l$ h* n9 A
- static int acnt = 512;
7 e5 x, q7 F0 |& N - static int bcnt = 8;) `, f+ g2 ^7 Y, R1 ]6 n
- static int ccnt = 8;9 s: B0 `9 F$ o! z
* k$ f, Z" L0 G# e& P( L+ `- module_param(acnt, int, S_IRUGO);' d3 D- \% X3 d' z/ n# N
- module_param(bcnt, int, S_IRUGO);0 d# C( g; A. G3 Q( X9 `
- module_param(ccnt, int, S_IRUGO);
复制代码 ' W6 z/ g( c% Y( t8 ]6 f
; l& }$ e* x: E% _4 Z6 `4 z$ x! s
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
0 {/ C. h* O5 ]2 B" V) k% Sarm-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 M4 f y/ g- F
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
& X# [) }1 ~6 ]3 K5 Z0 c, d$ S0 p( N; v% G
: \3 U" l }* v0 k
|
|