|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 8 b6 L# E; v1 i1 s, V+ E
- [code]EDMA sample test application
) F O2 Y/ x/ S5 n% K2 S: ^ - /*
) T- T: j2 Q: U - * edma_test.c
' E3 W( A2 [/ I( P - *
0 [; {( `+ F9 a1 M - * brief EDMA3 Test Application1 P3 _1 e3 j' \1 h! m: v* R
- *5 @, B0 H4 l' _$ g+ l% |& L- [/ @
- * This file contains EDMA3 Test code.
! k( ]# a* g0 D; R h6 I$ W+ ^3 z - *5 z: ?& Y2 N, r7 O- |6 f
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
% V. c6 v6 ]. E9 H; k" G - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
2 X% r. u4 r1 t9 q - * TO CHANGE.! i1 r3 A8 P' L' p$ K
- *% s4 a# [( ?$ H# @! B
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
. H4 M" j( h& c6 T: t( i - *
5 K1 q- A( l$ r/ e, M# _8 U0 O+ I& M - * This program is free software; you can redistribute it and/or
. B3 u& ^8 \6 C2 b3 j# ] - * modify it under the terms of the GNU General Public License as; x( D! V! P9 q1 e# l L
- * published by the Free Software Foundation version 2.
8 x0 L" u" ^2 V5 P9 { - *- A% v- H6 U- h4 w. b( }
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any* m3 E0 }) P! \' P. b* t( m
- * kind, whether express or implied; without even the implied warranty
) S4 S- C$ ~* E" [1 U) h3 A - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the* p; b; _+ F* P! W- q0 Y
- * GNU General Public License for more details.
1 S- L6 K! P3 C- ] - */) i: F* ]+ b- J( S Z: s1 ?5 W
; ^: M+ B3 m$ \/ V- #include <linux/module.h>
+ s- [7 r# X" p m8 S - #include <linux/init.h>
) [! }; n3 ]7 f - #include <linux/errno.h>) u, X: n: L! c5 R% M: I
- #include <linux/types.h>, w# P; O: o: \$ @$ o
- #include <linux/interrupt.h>
7 C6 y! Y2 v6 e1 j% @ - #include <asm/io.h>
$ C* r0 m2 T4 q9 s c - #include <linux/moduleparam.h>
$ |% j/ F9 G+ S' W" }2 e# N$ V+ o - #include <linux/sysctl.h>
6 L% R2 Z1 B( h+ \5 l. i - #include <linux/mm.h>
' Y* r5 z1 t+ l) D7 ~ - #include <linux/dma-mapping.h>
2 E2 f" m7 G, V5 p - 2 k! v4 w! S* G9 W0 x, a
- #include <mach/memory.h>
* \$ Q/ m) x; j6 B - #include <mach/hardware.h>
& N! Q8 V- |# _ - #include <mach/irqs.h>
0 \$ @6 n! V/ Y c/ s+ j- A. { - #include <asm/hardware/edma.h>
7 {. J. s+ @; q
; x# }1 U; \" m' U n, Z+ T- #undef EDMA3_DEBUG
2 ~3 P4 @; C Y% \( A h. Q - /*#define EDMA3_DEBUG*/8 n" C" J+ L5 E' X: R% P) Z. [
0 _' `0 W% z: D: t- #ifdef EDMA3_DEBUG, t! A0 L5 R" R% s
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)% I0 }/ S& \6 Q9 B- t- O, X4 a* r3 w
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)3 o, m, _; A9 n# w3 h! q% ~/ g: c
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). e" V. E) W& I, F
- #else `* `5 v) k/ Z T$ p9 J8 k+ b' A
- #define DMA_PRINTK( x... )
* K3 z. c+ E& ^4 Z5 M# v2 x3 V - #define DMA_FN_IN; t. {8 \$ L" ]/ P4 ^$ s
- #define DMA_FN_OUT
; y. ^. K+ V w. f( Z! ~ - #endif
9 n$ L& S4 n. m K
, `+ T) s6 W G" G- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: ~ V6 G. `2 L8 t - #define STATIC_SHIFT 3
2 h/ b. k5 t2 y* O# O - #define TCINTEN_SHIFT 20! k* d+ @0 b0 k7 X: m" W
- #define ITCINTEN_SHIFT 21$ f' f/ D$ V9 _1 i
- #define TCCHEN_SHIFT 22& G8 h/ x( L6 B4 q
- #define ITCCHEN_SHIFT 239 h- A5 J7 _ W6 J
- $ z0 n/ A- w" ]2 h4 V' v% P
- static volatile int irqraised1 = 0;. b1 W8 Q% m& C6 i9 c
- static volatile int irqraised2 = 0;
C5 Q0 u Q; x9 P4 Q2 H
7 O0 `6 o8 u' D4 A& Z( R6 u" o7 |- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" F4 ]: e6 q4 k- _7 ~9 ~& S - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
* G1 E3 `) c$ Y. @6 c1 ` - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 \; u; \# L- z) j. R
* v& n4 W ]* B3 E( m3 `$ {- dma_addr_t dmaphyssrc1 = 0;2 V1 p' {: o5 G5 v0 M# z8 {8 ?7 l
- dma_addr_t dmaphyssrc2 = 0;
9 J* t0 S. V& m+ V( N - dma_addr_t dmaphysdest1 = 0;
5 a; _6 t# `! l. X - dma_addr_t dmaphysdest2 = 0;
4 |( c/ ^% p7 J; C( A6 v
?( b1 v- @ a6 W$ d% H1 l0 O- v- char *dmabufsrc1 = NULL;9 h8 h5 o1 Y( Y2 P
- char *dmabufsrc2 = NULL;
+ U+ D" ]* C# A4 [4 `, {7 d - char *dmabufdest1 = NULL;& I: T+ A# Y0 d1 v' W9 m/ H
- char *dmabufdest2 = NULL;0 y3 L& q" g" q. R( S$ F3 Z
- # h! M" v, q6 B8 t
- static int acnt = 512;
& g6 g* x# {& {, B# P7 ~3 F - static int bcnt = 8;
! b- H V+ q/ o4 i) J5 {' k6 W - static int ccnt = 8;
9 p( H* N- f1 o9 N* b - % X! r9 T" O: P
- module_param(acnt, int, S_IRUGO);' S' p- f- J: e* w- T7 a6 C/ \
- module_param(bcnt, int, S_IRUGO);) @8 H& L n6 b7 g2 j3 [$ a* U
- module_param(ccnt, int, S_IRUGO);
复制代码 ! A/ F: D, z" L: E
8 w% e( W5 B" F# m4 D% M
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
; A. T! `0 l$ Q- Z; f+ {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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
2 ^1 V9 ]( B4 u# |" T% p 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 z i) N% i! ?4 h# R
" Q# j9 T& e0 z) v
# h4 D# \+ W. H; ? |
|