|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ) |4 p' n; u" l; \5 v4 G
- [code]EDMA sample test application4 ~0 b/ F+ W1 V( P- g( n# ~
- /*
. H1 Z, R; |' m( k - * edma_test.c
' x/ b8 N$ a! S3 V, f - *
[# z7 X# l7 Z" ~# R" L - * brief EDMA3 Test Application( U6 c. r8 U! j; b
- *
* _; E! M" t6 w; ]! G - * This file contains EDMA3 Test code.) v3 h0 n5 \$ O1 I' {
- *' `# M& M1 K j P
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE, T# E: r4 e& r9 e/ I& m9 m& U. n
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT' b9 |2 \4 s- B- h3 ?
- * TO CHANGE.4 S- p; S2 l+ f
- *
2 S5 T7 z1 y' O& ~9 I+ l& I0 m - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
& w4 F( |/ Q5 [- @- } - *
/ e7 ?8 s) ^& N6 ?" r! y. R6 M - * This program is free software; you can redistribute it and/or. z {( U; D$ g$ n0 {' J/ P' s; |
- * modify it under the terms of the GNU General Public License as P8 z: G4 g, a$ l" x
- * published by the Free Software Foundation version 2.
' c4 {/ l, m( x! ` - *
4 ] s# a. f" E" |4 b! n - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
' i+ t% C* U) \! H) m - * kind, whether express or implied; without even the implied warranty
' o$ ?- ~" [- H$ X) N - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ p! y* U8 a3 g$ E - * GNU General Public License for more details./ B7 U' ?6 o: w; t7 X
- */
& I0 u9 H$ e. t - ; }. S Y$ D' M* y ]: u; @# \
- #include <linux/module.h>
+ B. P4 }5 L; S3 e0 s4 I4 a - #include <linux/init.h>
7 B' Y7 D* G, K6 o" f - #include <linux/errno.h>
9 H3 V2 V$ Z3 W5 x( B) Y6 \0 T: t - #include <linux/types.h>" n+ l- j) o3 Z% U3 Z6 l
- #include <linux/interrupt.h>$ I) U$ V3 i" u/ p5 g; S+ t q/ S
- #include <asm/io.h>
5 X8 L. ?6 M$ z% J - #include <linux/moduleparam.h>
6 T# ^2 f& Y: y' T X; M - #include <linux/sysctl.h>
1 j! U" c, A, x7 a( I( z& X - #include <linux/mm.h>$ K' a# C* R) p# g# H1 T
- #include <linux/dma-mapping.h>- Y' j1 H& Q7 o, j+ U: p' E
- . [% A2 s# ~& s! x6 \
- #include <mach/memory.h>
; Q* A# Z7 O+ E4 z# l - #include <mach/hardware.h>9 p" _! b' J* V
- #include <mach/irqs.h>0 q) R2 H' A1 X3 ~% o; z2 L
- #include <asm/hardware/edma.h> k3 k g; s; c; Z% i# p$ I
7 S" Z% f! X- P+ ^ H- #undef EDMA3_DEBUG+ T" ?. p, ], A4 R% R2 P
- /*#define EDMA3_DEBUG*/
% y. o4 i5 x- T* B0 R3 b+ Y! u3 W2 E
6 K0 f/ G& q1 c2 Z% a7 K- #ifdef EDMA3_DEBUG6 y, u" m9 w. J* @
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS). [5 q! @, O0 ]4 v0 Y0 H' E3 Y6 P
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)& r6 ` g' [, I$ P
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). ^$ W8 ]) ]( r0 _( W; f3 t
- #else; g8 a# R4 B0 r6 M* @3 [: \
- #define DMA_PRINTK( x... )
! b+ C$ [7 g. O8 \0 }9 A+ ?5 P - #define DMA_FN_IN9 O" q( Y& @ g
- #define DMA_FN_OUT
1 @, g. L* Y6 e G - #endif J/ s- ]8 E/ P7 p, d% y
- - O! K; h0 N7 H8 t/ }1 e) r* v
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( F2 P2 Q: r0 u& q( ~( m
- #define STATIC_SHIFT 31 _8 D) T% b7 p6 |# f t2 @, {/ f+ a
- #define TCINTEN_SHIFT 20
. c3 E& U X1 @# G5 H - #define ITCINTEN_SHIFT 21
; T! _) @: O. H& E0 V2 ~ - #define TCCHEN_SHIFT 22
2 o$ m6 v& q9 {" @" s& T - #define ITCCHEN_SHIFT 23, |% o% V% p! W2 S! b0 G0 c$ b
/ V6 |% Y" _$ g4 m- static volatile int irqraised1 = 0; i0 V, B: _1 s5 x8 p* m
- static volatile int irqraised2 = 0;
; q) |* {& t) V" }# b
; F N* a8 C6 G* c4 q( f- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* p( c3 V- u2 g' d' J1 Y) @ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);. w+ @" @8 \$ }7 n) x h8 O
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& X1 s) S/ f4 G# z9 C( f* K
- ( l; k# \5 w" l7 i$ a
- dma_addr_t dmaphyssrc1 = 0;( }$ j; U; h% `3 t d- f
- dma_addr_t dmaphyssrc2 = 0;% W! v8 K+ q. B9 D) s) @% Y
- dma_addr_t dmaphysdest1 = 0;
. D) P0 E7 o, x& t) i4 ~ - dma_addr_t dmaphysdest2 = 0;
k4 v& T' n* |) i9 P - ! F1 ]$ z6 t# {! ]' e; F! N
- char *dmabufsrc1 = NULL;
; H8 k- P' o, `) G! d6 k - char *dmabufsrc2 = NULL;
+ U w8 w- r0 `/ C - char *dmabufdest1 = NULL;
! o+ |# S! K. G2 |- F - char *dmabufdest2 = NULL;
- s" j# e/ L% O) T, Z' L; g1 `. ? - 7 x7 G$ d, `9 o. p+ q+ v7 c- h6 B
- static int acnt = 512;# B' c. ^' F/ X. Z/ g! [
- static int bcnt = 8;
3 `$ z3 t' L6 m7 U - static int ccnt = 8;5 H K2 V$ B% v- d3 M9 R
8 q9 W$ W; T/ u+ E# f- module_param(acnt, int, S_IRUGO);) n8 e% T3 V0 w7 ]: M
- module_param(bcnt, int, S_IRUGO);- A: B3 ~1 w: h' q) ], T
- module_param(ccnt, int, S_IRUGO);
复制代码
# F) A" A' J' b- l8 ^9 E' h6 W8 T, X: g' O/ K5 c# r6 B
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
" n+ Z5 [, Z3 z3 a& g6 e" Y j# d4 L4 O9 Yarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。: l9 ^' ], z: \" o; M
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
' |9 \! s4 U) E/ A. j1 @& a+ T G2 h/ Y1 }9 q
( ^! z0 M' E; H- O; a6 Z |
|