|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 - W3 c$ i+ ^! O. c% l7 y! X
- [code]EDMA sample test application
3 I1 L, J7 \+ R" A" w8 p! i% U8 K - /*. v2 y( m6 C# T5 ]2 W' `
- * edma_test.c
1 W1 A. ?* S6 t1 N$ Y - *
4 {+ b, N" b; x9 m4 m% h - * brief EDMA3 Test Application
: c2 A+ s1 m: I; N) u - *
+ e, `9 T% ^- v W v9 [) g - * This file contains EDMA3 Test code.9 m3 P6 V4 d& f8 j
- *
: V2 C4 U- e- J8 _8 w9 o$ t: F1 D - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 a0 h, F5 W; Y) m8 b9 h S | - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
% B) s9 m) L# t, V8 r a1 h$ x' W5 N - * TO CHANGE.' ^8 Y; _) w" u) V
- *7 X" Q* E. a' \9 b9 I6 W6 i
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) x3 q5 V) M3 g1 t. B0 V - *) k+ g# P% x3 O& P2 b! T$ s1 p
- * This program is free software; you can redistribute it and/or
% h% i8 v q( k) c% ^( k$ s - * modify it under the terms of the GNU General Public License as: f/ L: _ j& y& p; A/ l' ]
- * published by the Free Software Foundation version 2.
2 A4 c* _$ { m' r4 ] - *
/ W7 f* X: K$ L: f" P# K' d - * This program is distributed "as is" WITHOUT ANY WARRANTY of any9 H# w$ Y' V, |8 U/ e% h: H0 m$ _
- * kind, whether express or implied; without even the implied warranty
' m% w! s m" a! W, k& o' e - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the6 {+ j3 n8 I7 t. \. @4 t
- * GNU General Public License for more details.$ c! V ]5 v- p* ]7 x8 |
- */, X. R- v$ ?3 b; l5 E
9 \5 @6 V8 J/ _) z/ r, W! ^- #include <linux/module.h>/ H- Z4 \7 l( X/ C) k, f& l/ l
- #include <linux/init.h>1 Q" v1 v7 c; `% x
- #include <linux/errno.h>. }7 n1 P; @: _- U; C9 U2 _) T$ |+ I6 q
- #include <linux/types.h>
9 T/ Q' W4 I% F. r - #include <linux/interrupt.h>
( L v, n6 {3 y. l `2 j - #include <asm/io.h># |' I r' h- \: f. R, w
- #include <linux/moduleparam.h>, T( C: n) h$ s
- #include <linux/sysctl.h>
1 J& o$ g- e, P5 r( d' ? - #include <linux/mm.h>
) n# E8 y- @0 l3 v: z' k6 E - #include <linux/dma-mapping.h>& S7 V2 w1 A4 s# i' x
' o) s1 @9 u( J" ?/ J8 r# A! _- #include <mach/memory.h>8 _$ W$ e+ I4 f/ n
- #include <mach/hardware.h>
0 X N6 J1 f+ I- w - #include <mach/irqs.h>
7 Z/ w; Z H% S& m9 P0 Y+ v - #include <asm/hardware/edma.h>% f1 c5 J; ~' P4 M+ ]0 D
- 3 E0 q) t" e# ?; L6 P' {
- #undef EDMA3_DEBUG1 o% @" [0 G v% U
- /*#define EDMA3_DEBUG*/0 n w! p. s) q5 h. @" C
- & ?. o+ g- y9 H6 G. ?/ Q( ^$ |
- #ifdef EDMA3_DEBUG k& j. B+ {* b( |
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
, X; L# k+ z& Z2 O2 f; a* C& X0 U - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
( X5 x9 E x, r5 b, t7 [ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). A# @+ s. t: h' i& o& B
- #else
- V e% c w/ d7 ~ - #define DMA_PRINTK( x... )% Y; U$ X; w! e( j1 Q' {% b* r' v
- #define DMA_FN_IN# \/ _1 F; d4 V! y( _
- #define DMA_FN_OUT
: q7 ~5 p, ~. i; I& c - #endif8 X* Y( Z) X1 ^! @- y* n3 B
- 3 x7 j( `+ V" d
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)" F7 X, D: r7 E
- #define STATIC_SHIFT 3
+ k* F7 h, ?, @$ U8 i) H1 A - #define TCINTEN_SHIFT 20+ |1 L' L& Q+ Z/ ] M! a! A/ E0 M
- #define ITCINTEN_SHIFT 21
( z H3 |5 `) ^ - #define TCCHEN_SHIFT 221 E: f" Y$ R9 a2 B+ @3 H1 m; @
- #define ITCCHEN_SHIFT 23, p2 J+ x6 p2 d. {' |
- ; X) C% D" g% P
- static volatile int irqraised1 = 0;
; ?7 C4 I: v: P \) e& s3 i5 [$ Z9 U - static volatile int irqraised2 = 0;
4 v% G7 \6 w5 Y$ ^- q6 }
. f$ }6 r- Y o- B# w8 P, ]- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);) C/ @5 a, y4 A! [
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' p: z( b2 i* f' ~
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 F: [ S" d9 W( V: X
- 8 |5 p1 Z0 ]1 q+ K& W
- dma_addr_t dmaphyssrc1 = 0;
$ r+ }+ _% q8 c* f, i - dma_addr_t dmaphyssrc2 = 0;
/ K4 r4 f8 z9 G - dma_addr_t dmaphysdest1 = 0;/ }9 Q9 e. H/ W; r I
- dma_addr_t dmaphysdest2 = 0;
! u8 i* t4 @7 w - / s3 z+ D& u& H: P3 q2 I
- char *dmabufsrc1 = NULL;
. t: l/ \: W* U7 U5 `9 }7 W% ` - char *dmabufsrc2 = NULL;4 H& p) j0 T m L% s3 K2 C
- char *dmabufdest1 = NULL;
M& ^5 d, x; j# x/ h - char *dmabufdest2 = NULL;
; _" i: x. n+ e
6 H$ V/ L( G1 P7 m( U- static int acnt = 512;
0 ? _5 y5 n4 a7 \$ F - static int bcnt = 8;! T! @7 J/ l7 ` z, {
- static int ccnt = 8;
$ I- Y% f) Z6 C3 g3 N
0 H7 v; t6 H; f5 l' a- ^- module_param(acnt, int, S_IRUGO);7 a7 ~, j3 O) j7 `
- module_param(bcnt, int, S_IRUGO);
: w* l4 ]& T, I7 [1 }# d2 v - module_param(ccnt, int, S_IRUGO);
复制代码 0 ~: z& l- q9 u1 ]& O8 C; J) z; e$ y( q
4 |: z: C* {# Q6 y' [ u% k7 r 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ k" z2 Z' H9 M! Uarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。; x, n5 ?3 J) h* b
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
( b6 ], A8 h- ~* @$ Z4 o6 Q) I
- T1 d# d8 j( A8 G& N$ L7 z3 j
/ m' L$ ?9 b+ F4 X' p |
|