|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 ( r2 y" Z! R- E8 Q/ a
- [code]EDMA sample test application. r5 f* f8 g# f) d v& a( b6 R: x
- /*
6 w1 [4 R0 g1 c! c: W - * edma_test.c
2 D! w- {0 [+ }7 B+ u - *. N, }0 c2 z3 W. @6 T' Q
- * brief EDMA3 Test Application$ d4 t. Q: ?& Q+ r5 ?6 V( e5 x4 L
- *3 ^% m3 {, D& \2 Q7 p3 O8 y* {9 M
- * This file contains EDMA3 Test code.
" _/ `4 G9 b/ w5 W - *
8 L9 D8 v8 m' _$ d2 g, @5 H - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
5 l! M. c' m1 t$ v - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT2 U8 t Y9 f- c( c0 h/ G
- * TO CHANGE.
! u2 j( U- J& r8 b9 W; q8 a* ` - *
: k9 [. l1 Q# @; j5 P! c - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 q1 {( Q& m. G, j8 R' V
- *
+ b0 \" `- x( E - * This program is free software; you can redistribute it and/or
+ B C, y) K! F N+ e" m X3 L' `" l5 D& D - * modify it under the terms of the GNU General Public License as
; F2 b+ G: V7 c - * published by the Free Software Foundation version 2.3 v' L$ v: G/ H2 d
- *9 U, j+ q9 u I, S/ |8 R8 }' _
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
9 e% p6 d9 c y - * kind, whether express or implied; without even the implied warranty
& ]; T# X4 y; {- {. a1 M2 y: ~) Z - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the8 J: V; b" w$ k: j
- * GNU General Public License for more details.
% k+ F) y1 e! M/ p - */
- \( g2 q! d+ K1 X4 v
+ u! U8 E! f! h8 ^- m/ f: m- #include <linux/module.h>. C/ ~: M8 A5 @$ z
- #include <linux/init.h>
C$ V& y" |; R" k o: ?" ~; W - #include <linux/errno.h>7 `: o: ~$ H* _1 M" c/ R- n
- #include <linux/types.h>/ V( S8 k) G) F9 C+ z. U
- #include <linux/interrupt.h>
8 Y6 d, Q- B( a: f5 N7 w3 l - #include <asm/io.h>2 G+ m: r- y+ a4 i( K' S
- #include <linux/moduleparam.h>
5 m, p# y2 \- Z, F; `$ K - #include <linux/sysctl.h>
6 h- X* d0 r2 T# ` - #include <linux/mm.h>" K# ~0 l* G2 h$ D: o3 a
- #include <linux/dma-mapping.h>
Q$ T2 F x% C
- m# n1 V, @; }- #include <mach/memory.h>: V0 P7 w' V+ ^. P/ }
- #include <mach/hardware.h>
. m6 F! b" `: a( B5 Z9 x - #include <mach/irqs.h>
1 ~" o1 y, X" S- H& d4 D - #include <asm/hardware/edma.h>
* E9 N- A& D% N6 x6 }
. L$ y8 p+ R% L* q! a* a" U- #undef EDMA3_DEBUG" z4 }5 N; o" T9 H" c# _9 {
- /*#define EDMA3_DEBUG*/
1 h2 m) f, V7 ]: H
1 n: F6 ^6 {8 ^/ m4 f/ G( e- #ifdef EDMA3_DEBUG
. J/ ?3 g+ k% ?# Y! `5 q# M# Q& e - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)8 z. P- [, W) c t' b2 z
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)6 C0 \5 a0 G0 K& @- R4 _
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__): T, N: \- m# a* p7 S) X
- #else
( m, S* r8 Y2 N6 j ~ - #define DMA_PRINTK( x... )
* B1 I% A9 e, z - #define DMA_FN_IN
% |- a) C; H. J" z" E' y - #define DMA_FN_OUT
5 @8 [* z$ E5 t! v; D/ e. U - #endif
, {2 R& [* c) |1 R% e6 f - 6 @' a& d4 [, J& N1 @ V
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
: {' q6 o8 t% p2 z; p - #define STATIC_SHIFT 3' `+ Q7 b/ z6 C& |4 W1 Z
- #define TCINTEN_SHIFT 20
; L/ [9 P" c* m1 c/ _ - #define ITCINTEN_SHIFT 21
# o: ~4 o7 w& g" e" r1 I; _ - #define TCCHEN_SHIFT 22& o6 ?! |! [/ W5 l5 K* n
- #define ITCCHEN_SHIFT 232 b* m1 X% c/ n, x! _( X
- $ a. [! ^* T) u& }1 h7 s, }! c; F
- static volatile int irqraised1 = 0;$ w1 @# A$ I9 l; |: K5 R' G7 t
- static volatile int irqraised2 = 0;
' ]6 M7 ^+ D5 [2 T/ _ - ! H1 r* [* N' I5 |4 Y7 r
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 m1 r* O! F: n: O5 B: H- Q
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);, m4 P! U- x7 o
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, N9 g: \1 ?' W j/ V/ L
8 D! k2 _1 L, l- dma_addr_t dmaphyssrc1 = 0;
3 I5 y8 L6 z# S6 X6 z8 O - dma_addr_t dmaphyssrc2 = 0;# e3 k0 r7 Q2 G$ z
- dma_addr_t dmaphysdest1 = 0;# Z$ a; J# ^5 M8 ]
- dma_addr_t dmaphysdest2 = 0;! l. C8 b p. j w# E
- / k/ Z6 m Y8 |5 Q9 D% d; {
- char *dmabufsrc1 = NULL;" U% l9 t, n. s9 M- d$ V. p$ }: u s
- char *dmabufsrc2 = NULL;9 a3 |4 }9 \) m8 ]- d J. g
- char *dmabufdest1 = NULL;3 f3 ?7 M4 ]& w
- char *dmabufdest2 = NULL;
( g# K. D$ S$ a/ [8 f
$ |( d J; w- \! x8 G/ `2 U) j- static int acnt = 512;4 S. ~" |+ X3 a, @5 }0 ~
- static int bcnt = 8;
0 I1 I" W6 r& Z/ F' w+ h% U+ E - static int ccnt = 8;3 U. f6 N; M/ O9 E) _
- , W9 E; H* P) W& U/ j" ^3 a3 K
- module_param(acnt, int, S_IRUGO);
# h: Q4 `3 K" J3 \6 n6 m# [ - module_param(bcnt, int, S_IRUGO);
6 _# _& {( k( y3 S" {# @7 l0 I - module_param(ccnt, int, S_IRUGO);
复制代码 / B" D$ v, q/ w3 s; [
3 O1 z& v1 j. m9 _1 u% U 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用" w& v( F& X- w9 V7 v, W, P' |
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 e7 V* d- O. e
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
: H! V0 X' E2 W' c! B! o9 e4 T8 A
9 h6 B0 }5 {* {, r2 i5 z, b8 ] |
|