|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
9 O! ]" g; l( \* o! q) E- [code]EDMA sample test application
# i+ V) [! X* B9 N - /*
1 m" C8 V9 }6 r7 q - * edma_test.c1 {6 O% Q- W3 c8 M! ?& a3 m
- *
8 V1 \$ o7 q) ~6 ] - * brief EDMA3 Test Application
- j3 @% P: J: g, L$ _ - *2 y# j( Z2 T5 e, j$ }" S
- * This file contains EDMA3 Test code.
. V Y/ f# {/ ^( S/ H - *9 M* d* Z: _8 ]) Z; i3 P* K
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE6 j9 h: \2 P' z+ u$ y" R# n# v9 V0 Y
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
8 }) T5 ?1 y& i6 t - * TO CHANGE.
& F( y; s6 S: [" z# L& @" b - *1 o/ R& Q% q3 m6 P- H6 C
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
# i7 v1 z% [& P: A* u2 |9 t- E# k; W3 M - *
$ c6 o i; F$ q2 k7 f+ M4 v - * This program is free software; you can redistribute it and/or
6 d" D& ~0 U+ B7 r/ e1 ~/ ]# H- t - * modify it under the terms of the GNU General Public License as
_9 x! O; y4 [1 u( ~' { - * published by the Free Software Foundation version 2.& ~0 f* s0 b4 I) g* T9 k( |+ N
- *2 U& Q$ H4 x* c+ m
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any4 {" v9 L4 [! R% A% i) ^2 P
- * kind, whether express or implied; without even the implied warranty4 R4 Q, o2 o' V1 M! N; z- ]
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% E) w/ \4 c+ } R7 _ - * GNU General Public License for more details.
1 Y$ ]. J. Q/ a8 T% |3 d - */: p ?* A2 \$ G" K R4 @ [
4 E+ v m9 `: E" F6 L- #include <linux/module.h>
( W) a& |5 A) l) y - #include <linux/init.h>
$ f: S: t$ w" E- J4 T - #include <linux/errno.h>
) r! L# ?; L% _" w1 s# Z - #include <linux/types.h># D) D% ~: _8 S
- #include <linux/interrupt.h>
: B0 k) u. A/ K( A - #include <asm/io.h>
$ p: `- x# i- I7 N% W+ a' a- X - #include <linux/moduleparam.h>
' ^: ]$ v) q+ q4 _ - #include <linux/sysctl.h>
& o: D; r7 N. C w# @. O - #include <linux/mm.h>: @: r! [: S" K! U% Q2 e$ ?8 ]
- #include <linux/dma-mapping.h>
5 A% G- i9 p( ]7 N - / x! y8 G* t2 y$ H0 _
- #include <mach/memory.h>
2 h8 O( s8 q& r2 @5 @3 i - #include <mach/hardware.h>
" F1 P* \# {* m8 G c; X - #include <mach/irqs.h>
" T+ B$ y8 e; |2 ^. w/ _ c - #include <asm/hardware/edma.h>
1 {; B" o, l7 L- M* E9 K0 r
! V2 o+ i9 `& ] \5 s! M- #undef EDMA3_DEBUG
7 E' j M; ^0 y5 u/ m - /*#define EDMA3_DEBUG*/
- l# V5 p2 b& R0 f" v - 1 `, r1 `/ i+ Y! u8 r$ _4 O5 y
- #ifdef EDMA3_DEBUG
" }+ ]/ l v: g- e" W& P C' V - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
7 L2 r. V! C+ c4 Q) w - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
- j* k, [) E ?8 s& m4 L2 r* v) [/ a - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__), \0 H( g* U/ }+ O+ ?
- #else: e [. l# r8 C, L
- #define DMA_PRINTK( x... )8 c1 b$ J9 s( f' v8 ]% l
- #define DMA_FN_IN" Y8 o! r- D$ F& D' D9 f, b% r8 g
- #define DMA_FN_OUT r1 Z$ V' a7 D$ }* c/ Z* Y# ^
- #endif) }; b' o) m) d8 e/ r9 m* B E
- 7 Q- h( Y8 I+ O5 y' _; s
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 Q8 K/ l4 b- Y0 Z S8 G% M/ c3 u
- #define STATIC_SHIFT 35 G% c* p9 @" ]7 ^- a4 ?
- #define TCINTEN_SHIFT 20
# ?$ W* }" A T4 R - #define ITCINTEN_SHIFT 21
' |6 M1 ^, Z+ {1 W- Y - #define TCCHEN_SHIFT 22* \4 w+ |+ t6 E
- #define ITCCHEN_SHIFT 23
) C. Q( ?' q/ }4 Y
, y! ]* a' h( F# k4 T- static volatile int irqraised1 = 0;
$ i( w* e0 a9 D2 h) X - static volatile int irqraised2 = 0;% m; u8 X" p6 ^# E4 `
- C* Z3 R+ R+ k6 E1 C! \. y- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( Z1 S. ?( g; h9 _5 N# N' R3 G; O R - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' s& \. a1 d2 N! y2 ^
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
/ s9 e' f1 _% _. J. l- H - 6 T6 Y P+ U" w& G8 s
- dma_addr_t dmaphyssrc1 = 0;
4 F6 y* h& }1 g - dma_addr_t dmaphyssrc2 = 0;) Q! f8 t! w6 Z1 |$ K
- dma_addr_t dmaphysdest1 = 0;9 H# G! W" U" J, f
- dma_addr_t dmaphysdest2 = 0;
' Y: l( k" z+ Y9 L b - 3 Z6 i: k" r2 \! S
- char *dmabufsrc1 = NULL;% i% i7 b% E* M d
- char *dmabufsrc2 = NULL;
* {! N& g7 ]2 @( h/ X - char *dmabufdest1 = NULL;
" T% z. ?" f) d - char *dmabufdest2 = NULL;8 j3 G( V( Z0 b' x
- 7 E, I: L. C) [2 y
- static int acnt = 512;
/ }6 Q+ o' R. e, z - static int bcnt = 8;
" w, g7 X$ M. b9 X, m5 y; O - static int ccnt = 8;
: n, f+ k0 y3 a) c4 M( q
# W3 s; a3 u* ?/ _- module_param(acnt, int, S_IRUGO);
- V6 [0 [% R' o2 U u' n8 y- X - module_param(bcnt, int, S_IRUGO);1 A6 h/ t4 j9 d
- module_param(ccnt, int, S_IRUGO);
复制代码 9 w; p" W5 D2 X$ v
4 Y5 [& m0 z; u+ v, p
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用, J5 @! g( Y3 m
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。8 S: @" r% Z4 i0 v/ M; c
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。, a, H& E, w9 `& r8 J
' P& g, j# a& Z: q5 ~
. d! d2 u; ~ V5 t2 r+ o/ f$ K3 B' g; v |
|