|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
+ ` S7 ~4 n+ ^. z- D- [code]EDMA sample test application
" {+ Y2 e- _) l) ^# Q% }* F4 A2 a - /*' p) Z* q- i* F$ c& i
- * edma_test.c
9 v, a7 J: p# _; s ~! U% \ - *
, s9 i1 ~; K1 A+ N7 V - * brief EDMA3 Test Application
7 }( O _' k0 G" s" r' N f - *
9 c5 ?; ` G) x6 Q1 E" ~3 l - * This file contains EDMA3 Test code.% [/ D/ l/ w: I: M, y
- *
( t& P% Y+ c9 T - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE0 x' n9 I( M6 G& C; k0 O) ]6 Z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT1 W1 \. ~* ?9 r7 z( m
- * TO CHANGE.
' N& r8 P0 u7 v - *1 k1 k& R; J' K+ s$ o4 D! `
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
' V( i: O! q; S* o B$ _- k+ l - *) G- b' s1 G; v$ }8 ]$ m( [
- * This program is free software; you can redistribute it and/or( I5 S6 J, r8 |- W* Z9 Z2 L
- * modify it under the terms of the GNU General Public License as8 A# h4 ^5 y' V, N+ U
- * published by the Free Software Foundation version 2.1 ?* \5 O" ?0 j5 r
- *
3 B5 \, u8 U q, C# D+ H - * This program is distributed "as is" WITHOUT ANY WARRANTY of any6 C- B" p8 c/ w$ J) k6 W% ?% W
- * kind, whether express or implied; without even the implied warranty) u T0 ^- i3 X+ ]# W- j) B
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; w5 t$ p: [* p$ u8 G - * GNU General Public License for more details.
4 \8 L% O+ I- j" z- w - */
4 S" b$ D. r& }
7 [, z% A6 y ] W! w1 h- ?4 W$ h, K2 _- #include <linux/module.h>/ z# C4 ~& o; U- C& {( u! C: }
- #include <linux/init.h>) \" J9 _* `! N4 B
- #include <linux/errno.h>
$ p4 \4 x3 b+ l) R, @, z* |2 o - #include <linux/types.h>
0 J# O5 z1 k% q+ Y* W. S - #include <linux/interrupt.h>* d: ~4 [# c2 l! g' X
- #include <asm/io.h>' K* a" s' s+ l u3 H, r
- #include <linux/moduleparam.h>: n5 W$ W5 N+ D5 _- _; P$ x- _
- #include <linux/sysctl.h>
3 J5 z# A4 ?" k8 V8 [& h X - #include <linux/mm.h>
$ [2 q( I6 r6 u1 B; t - #include <linux/dma-mapping.h>
5 Y/ H0 m4 X# c0 B8 [1 G7 S
) f4 U2 ]' u3 Y l9 E* |4 X- #include <mach/memory.h>
/ J$ l* Y& O2 Z9 u' |( M - #include <mach/hardware.h>/ r& P! D# t3 f, \% I. Q& m% k- X
- #include <mach/irqs.h>: {6 D5 h7 @+ Z5 m8 A
- #include <asm/hardware/edma.h># Q2 g1 ~/ v2 R- Y
. f; j6 N. b2 p( `7 m+ |- #undef EDMA3_DEBUG
/ f C! t; v Z' Q+ s( | - /*#define EDMA3_DEBUG*/: y" R; W+ \$ J4 e$ W& q! L1 A
- 6 @, E: r# c, @- j0 O% R- ?
- #ifdef EDMA3_DEBUG
; z5 r; {9 T I - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 ]0 i5 x/ d' W* p" t3 ~2 B
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)! ~5 T1 C$ W0 t9 U
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)( ]: K5 g# r! `. ~8 z. A
- #else
! Y. [; L* V; m% ~( S/ U, z! e5 y1 t) ? - #define DMA_PRINTK( x... )& d3 V. f& Y% Y+ m* h7 n
- #define DMA_FN_IN( h/ B" ]2 l/ m$ Q
- #define DMA_FN_OUT
) K3 O! S: S; f1 u z - #endif
6 N$ _1 o5 D! r) t
4 H1 D) D7 _7 j: \: t' v: q, o- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
& N1 ^ c. M- H5 F8 z5 ] - #define STATIC_SHIFT 3- {5 `1 f* }6 i _
- #define TCINTEN_SHIFT 20' K. ^3 Z% U8 ]
- #define ITCINTEN_SHIFT 215 R* a7 Y j+ X' K
- #define TCCHEN_SHIFT 22
5 k" ]+ m. A- h* ]4 X( c' _' U) ] - #define ITCCHEN_SHIFT 231 M. b" T8 d& ~6 { [( b/ e
- $ P& Y0 g2 m7 y1 r
- static volatile int irqraised1 = 0;
% y6 p3 w2 a# l8 I- g - static volatile int irqraised2 = 0;! R' G/ v( q/ b1 ]5 P" t. \
$ @: q: p. x& |- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);0 V& v- s+ {) [8 s
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
1 u( }' ^( |% s - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; S4 I! i7 s3 I( E+ d) a
- ( F9 a- w& I- ?2 A
- dma_addr_t dmaphyssrc1 = 0;: d2 ~) z4 q# g* }, k+ s
- dma_addr_t dmaphyssrc2 = 0;0 O0 C& I1 \* \* g8 N% w9 [5 ~1 C( R
- dma_addr_t dmaphysdest1 = 0;
5 t+ `+ s% T& M& }- R - dma_addr_t dmaphysdest2 = 0;
1 G' C6 P5 P" l5 d, [
/ a# p1 C: B- T/ [, k3 W4 o- char *dmabufsrc1 = NULL;7 [( ?+ }- g$ H# ~3 a b
- char *dmabufsrc2 = NULL;! O: G$ b4 j3 q7 R! i h
- char *dmabufdest1 = NULL;
4 g7 ~! X5 C/ Z6 H( J1 o - char *dmabufdest2 = NULL;# V1 v, T/ p4 o# V3 E* o) E2 A' ?/ Q" `
- d' N! Q& T* g9 _. x
- static int acnt = 512;5 v4 X# Q0 c5 E/ J, M
- static int bcnt = 8;
0 o4 f& w7 U6 n7 H O - static int ccnt = 8;
! s/ F. E) H0 o8 P+ \3 z - # T7 V' }! u& Q
- module_param(acnt, int, S_IRUGO);
: D' f n. M$ w3 [% \- d( | - module_param(bcnt, int, S_IRUGO);3 l6 x2 y6 w$ t- L
- module_param(ccnt, int, S_IRUGO);
复制代码 - S5 q9 _8 [. x+ Y
- _3 ^7 ?5 V6 b) m4 W 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
/ `* G$ B0 B4 u9 ^$ Harm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。1 q; v6 l- J; e2 n* m; ~" ^
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
; r% d: {5 n! ]- K% s
' d+ K8 ]' ]" U0 b7 u9 c. a3 n% X
6 v% H/ x4 S9 ` |
|