|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 v& B" D9 | g. ~0 \8 y# p, r$ A- [code]EDMA sample test application
8 m8 y' v9 a$ J8 Q - /*
& B& H; ^% u9 ~. j/ J, ? - * edma_test.c
6 `3 M" N C9 B M- l! ~% M - *
* I2 Y0 N# ?( y: A! m8 I. F - * brief EDMA3 Test Application5 p( {2 y* v0 G, M. i' i* U8 C& O
- *
7 v$ A# m: c" C& M- `3 R) ^2 y# Q - * This file contains EDMA3 Test code.' X6 w' w/ d K0 [- v, k6 i( Y7 M/ d) ?
- *; x1 V" W6 O4 ]" l
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE' w2 O; z; F+ [) u0 u# }- s; o
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT3 q1 t5 |* j% o4 e2 c5 O& |
- * TO CHANGE.6 j9 |! h* v$ H- r9 x9 r
- *# R- U; P, n( G, h
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/. n) W R3 y5 P* p% R
- *9 b- v8 w3 u8 {6 ?; X1 y; }4 u
- * This program is free software; you can redistribute it and/or* Y9 Y* V" ?* x) A
- * modify it under the terms of the GNU General Public License as6 r5 v6 S' K( C- | f4 w$ Q
- * published by the Free Software Foundation version 2.
+ V2 b) Y# K3 K/ u - *! u/ l) m9 [1 h# Y
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any$ W3 W" P0 W: o- ^& S
- * kind, whether express or implied; without even the implied warranty) {- @5 l$ l s/ }) g% j
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ |" P) m4 P1 e) ] - * GNU General Public License for more details.! `4 \4 f& G% T" U8 x
- */( p+ G, K; z; i; J& T) l2 P
% E- M2 Y9 a* O3 U- #include <linux/module.h>
/ U! j: G _! E I' v - #include <linux/init.h>' m8 i* p0 y# ]. w5 O
- #include <linux/errno.h># D0 [: T" v1 ^
- #include <linux/types.h>
$ H& E& p1 {: L9 R6 U6 f; v - #include <linux/interrupt.h>, G0 |: c& x( K7 M1 ]/ i5 S
- #include <asm/io.h>
2 v$ T0 {: v; _7 d: B - #include <linux/moduleparam.h>
) z; l1 b3 d$ w- a$ i - #include <linux/sysctl.h>/ ]6 V$ ]4 U: T0 Y% P6 l
- #include <linux/mm.h>! @8 G1 ]- ]7 g3 D7 ^
- #include <linux/dma-mapping.h>! I7 m# {3 w2 s) }% r7 K1 V
- % L/ {4 c/ ]- c1 v( x/ D
- #include <mach/memory.h>
/ N6 U% M. j$ j4 M% d( t - #include <mach/hardware.h>' P, ~' F4 z; I s. r y
- #include <mach/irqs.h>
5 v7 U8 j9 ]# @; E; o( }8 R0 g% j - #include <asm/hardware/edma.h>% c# Z% ~, L- f
- 5 P# c% m+ l2 i: \
- #undef EDMA3_DEBUG7 n; _ n, V$ S5 E" R
- /*#define EDMA3_DEBUG*/
" l$ o- w k2 {, Z3 D - 0 g0 g' \4 C5 p, }# } n+ v
- #ifdef EDMA3_DEBUG
i. l0 o* ]4 F+ Q9 p7 q - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)' R, [( R& C y# L5 T
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
$ S) d" x4 Z. D* h9 l - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)$ F; z9 E5 z9 S' B! e2 z
- #else
2 J7 V {8 | e+ Q* ? - #define DMA_PRINTK( x... )
, b7 j( f- d5 `, C$ B( j/ w0 ] - #define DMA_FN_IN
' |# F/ K, S# y' Q2 @. D5 ^ - #define DMA_FN_OUT
. ?% z4 P9 L1 `( @% }+ W1 N - #endif
' A, I' p. A2 T9 Y - ; O# ~) v& [4 K
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
+ z% |" C) l& O) N3 @ - #define STATIC_SHIFT 3
. e' ]6 I6 ~/ q( k& {' W7 V - #define TCINTEN_SHIFT 20
9 @, y+ e$ M( U5 |; w - #define ITCINTEN_SHIFT 219 c/ l) c4 u( M# S6 t. |4 ^
- #define TCCHEN_SHIFT 22
! P8 ^4 J/ u- D - #define ITCCHEN_SHIFT 237 x) r C! H1 x/ e/ J2 @" }
6 c8 W3 L- V( S3 @: R- static volatile int irqraised1 = 0;
. n+ F6 J* t" m* u, s- f: e" K3 w - static volatile int irqraised2 = 0;+ k9 i% t3 d& l! r, S; z/ D% M
7 \" h9 F3 o, i# G, s. F- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
: o+ r# u: T; v - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);! [- O2 s6 c- p; g
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
6 x! V8 X) j/ E* D - . |5 K1 e! f1 P$ M" k- a. G3 A
- dma_addr_t dmaphyssrc1 = 0;, o; B3 X) E1 y; b" o% u$ i
- dma_addr_t dmaphyssrc2 = 0;/ |! {" I% v# a0 \
- dma_addr_t dmaphysdest1 = 0;
2 j- b1 v: ~* j! [ D% ] - dma_addr_t dmaphysdest2 = 0;9 N( A" Y b0 I) r) F! {
7 |8 M3 t9 B0 q0 Q5 W( ~- char *dmabufsrc1 = NULL;$ T' D" B4 H: s6 @. y* R) k2 @
- char *dmabufsrc2 = NULL;
5 l% i# s# ]# C) |. K- v- F1 B x - char *dmabufdest1 = NULL;# C l: ~- F4 |! N+ A) w
- char *dmabufdest2 = NULL;
6 W4 Z/ }7 a6 w6 i - : O. _! ]! ~8 h0 N( s- B
- static int acnt = 512;
n" J- c' ^7 V - static int bcnt = 8;" F; K3 r+ W6 l! C
- static int ccnt = 8;
+ Y/ `4 K% a: {" h# U2 i2 u
- V5 I+ \0 e2 a6 y& `/ q8 ~1 C: {- module_param(acnt, int, S_IRUGO);- c+ I+ P" L4 I+ i
- module_param(bcnt, int, S_IRUGO);, D0 d. h( G( F
- module_param(ccnt, int, S_IRUGO);
复制代码
" W8 A _1 f" }& O3 ?
( h$ }6 c2 v( u. B' B8 X: F 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
8 E+ ^% s0 Y: W o6 \, 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。$ y ~1 }4 n5 ]0 G$ g7 Y5 |6 _
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。8 j0 o$ n1 e; c$ W
7 e9 ]% l! r3 f* w% h6 X# U8 v. _+ A- w# G2 i) |4 X' o
|
|