|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
. N2 z" h* Q0 u) w- @$ U- [code]EDMA sample test application
! n b1 C) l9 X - /*
* \4 d5 _2 b+ ], f7 J - * edma_test.c
0 r$ X/ w, o5 h [2 `5 o - *6 _- }/ L$ X: }2 J5 H4 ~; N9 J
- * brief EDMA3 Test Application
3 n3 x0 U" f1 ?5 S - *5 E [2 P2 X9 n% ~3 I; V
- * This file contains EDMA3 Test code.
3 }9 @' G# o5 Q5 E2 b - *
5 X2 o: n- q C) L# J - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
( I8 o* _; h7 ~$ y; n) j4 { - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT% j0 j% r, \( d# H; V9 C' M2 P
- * TO CHANGE.
6 _) v- q% Z$ ?+ \6 H$ \) q - *! m2 n. E2 C& [1 n. H$ b
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
% R; T8 [3 G+ ~% b: u - *$ o& e7 H" q# M; j ~/ x' G5 \
- * This program is free software; you can redistribute it and/or
' w, ^' `- U: l# |$ w$ k - * modify it under the terms of the GNU General Public License as, {% R1 I+ G' @' Z1 p
- * published by the Free Software Foundation version 2.
0 c4 A7 o" _; ^+ @# p8 q& r - *7 F: ]! N2 S. S* f( ?( ?
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
! s1 T7 [" _0 f0 N - * kind, whether express or implied; without even the implied warranty
6 A5 d4 F! y2 Z' Y6 G* n - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
( H5 [0 J* g2 f) z# T7 T - * GNU General Public License for more details.. S" g/ m; g; I* h0 J
- */
) T* Y) A3 Q" O2 h! M
) V% e, { B. v4 R# c* @7 S- #include <linux/module.h>: R0 t: h1 \2 c; f
- #include <linux/init.h>' G# h* ~9 K; K$ y* Q" k: |8 M
- #include <linux/errno.h># Y, T4 _: P! R0 D8 j
- #include <linux/types.h>1 ]' J2 j+ H; X% c
- #include <linux/interrupt.h>
% c# j7 J. \% ^ - #include <asm/io.h>
7 b3 }( J+ I4 F2 H: e$ S0 P: F - #include <linux/moduleparam.h>' K1 m6 H/ Q* V2 A6 ?5 G! S- }
- #include <linux/sysctl.h># r. t0 V1 H- K0 e5 }% H
- #include <linux/mm.h>! u( q5 _2 p: Q$ ?
- #include <linux/dma-mapping.h>* B" ?" ?9 D3 |9 Z
7 s8 B4 k' Q9 Q( }, [* w# Q/ k% ?- #include <mach/memory.h>
. U2 M4 V6 a3 B- b9 g - #include <mach/hardware.h>
X: Y4 r& l! L - #include <mach/irqs.h>
7 q" j& H7 L- j0 ]6 W5 b, j - #include <asm/hardware/edma.h>
r% \: \/ a6 L7 l G
; q* ~# `% K5 x# T9 e7 |) k# R! l$ q- #undef EDMA3_DEBUG/ K' c. u# x1 T) q: O
- /*#define EDMA3_DEBUG*/0 o; |% {0 N! S0 ]5 ~, m: z
- 1 v* K# l2 n* D5 K
- #ifdef EDMA3_DEBUG; _; E6 O! F4 l# ?
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)- V; F+ M, H7 S# @
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__). i; f+ k0 b( m. c9 F9 x
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
& k- ? X5 i& V7 s5 P3 Q5 ^ - #else
$ A! Q" s" Y0 ^0 F - #define DMA_PRINTK( x... ): z1 A$ i2 c! D
- #define DMA_FN_IN0 F( X7 I5 |5 o: N2 n% j
- #define DMA_FN_OUT
p; R2 y6 q8 k: b) p, h m$ I - #endif" Q; j/ X" O+ L8 X5 o; ?9 j+ C: y) b
* L' I- B$ V& n% R8 j- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
. p, ^6 V% M/ E! n - #define STATIC_SHIFT 3
( w- X# z: F, B0 l - #define TCINTEN_SHIFT 20
# f) I" E) M" Z+ R* Z - #define ITCINTEN_SHIFT 21" p1 e& K2 u7 _
- #define TCCHEN_SHIFT 222 i. m7 {4 m" t; d" ]& x
- #define ITCCHEN_SHIFT 23( W/ ?0 u3 X" ~; J6 l3 J0 y$ X, [" L
- 3 H# Y: Y, V* T) h) C w
- static volatile int irqraised1 = 0;
3 [. a" U9 O, w: P - static volatile int irqraised2 = 0;
5 y6 c# w. E) o8 n7 R% _7 c, y' | - % ~2 L0 E, u$ o% |2 d
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
8 h( N6 [( z' x - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 B8 O! s1 T6 ~
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 b( Z; j7 `3 s: K( V' b
6 E7 z8 l0 `7 l2 W- dma_addr_t dmaphyssrc1 = 0;: [" `' d- T/ _, y
- dma_addr_t dmaphyssrc2 = 0;, t' x& ]* V& j
- dma_addr_t dmaphysdest1 = 0;& y- V6 s! X G7 b U
- dma_addr_t dmaphysdest2 = 0;; a! `) y4 P, k V5 S( h! e' d* n D
- ) M3 w+ G' R7 w& Q- C( x
- char *dmabufsrc1 = NULL;' P" u9 M4 N- @+ C- t5 K
- char *dmabufsrc2 = NULL;
5 d8 M2 N; D, Y- R - char *dmabufdest1 = NULL;
) h9 k. G9 x- P3 e. Y0 l - char *dmabufdest2 = NULL;2 A9 p5 B) D" W7 [
- + |% P/ D/ L& Q: o3 V+ ^
- static int acnt = 512;" A# S. u5 d% ]8 v; N
- static int bcnt = 8;
% Y4 ~6 ]% x6 `8 [( S$ Z - static int ccnt = 8; }' P6 T0 }: M' ~2 w& G# U; ~
6 j( ?; S# z" k2 B" {4 [% r; d- module_param(acnt, int, S_IRUGO);
. H+ K& O$ m6 t7 I6 l3 e' C - module_param(bcnt, int, S_IRUGO);) }0 K" V6 s5 y1 s
- module_param(ccnt, int, S_IRUGO);
复制代码
6 B8 o$ R0 `$ e3 b2 i$ k3 Z' P
$ u2 I$ f* x7 T 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用* ^: W& ~# }$ r9 I+ e7 S
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
. W: }5 N# ^, k 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
6 R" A# t$ P! p
0 G; S& ?+ K1 h& i3 G, g' }9 Q
3 W! ]- F- U P! y0 u |
|