|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 5 [4 @6 L0 H w: P1 ?
- [code]EDMA sample test application
! Y- ~/ B* h2 H - /*
/ E, \7 E y3 P1 f* L - * edma_test.c% ?0 M* y2 H: K. `+ ~ L
- *8 K: Q" \6 E3 L7 c# [! j9 t! s' p. u
- * brief EDMA3 Test Application3 `' @, o; L7 D+ o6 Z! F
- *
7 o' A* g$ O1 u6 H) \ - * This file contains EDMA3 Test code.
" L8 M3 X6 G+ j$ C2 R7 y9 e+ S" g - *
: r+ `: r( M H- {% t$ J - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE3 x% H# r* i. O% Q
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT* y. f/ X; V' ` V
- * TO CHANGE.0 p6 B& \9 c4 Q
- *
" S1 y. E8 p& ?' V# E - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/7 l A& F' S. X: W; g- L m; [
- *
: n i# @; b) h( \7 K$ `2 G# W2 m - * This program is free software; you can redistribute it and/or
' L& T$ u% M4 [; P! d9 c - * modify it under the terms of the GNU General Public License as
* V$ s1 C2 C& |, V5 w6 i - * published by the Free Software Foundation version 2.1 F4 A( k+ a) U' y# B/ w
- *
5 {3 r/ {8 f9 v! O - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
# `, M/ N7 g- o R2 I" \ - * kind, whether express or implied; without even the implied warranty! k. e4 R. t1 P- e, a1 N9 W
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# Y0 Y3 F, L/ T) m8 K+ K9 c. x
- * GNU General Public License for more details.
0 J7 e1 J, @, A. k - */
) K4 o1 p) {3 Z" p# x6 t, y - , Z2 k/ V2 a" l# |
- #include <linux/module.h>' K& X D' e- W! q8 O! f& [
- #include <linux/init.h>
; G( K8 ?3 T1 w2 l) h - #include <linux/errno.h>8 |8 c8 m$ f9 a. L2 ~
- #include <linux/types.h>
8 f3 t2 k2 a! Y* ] - #include <linux/interrupt.h>
( A+ Z. M I' \; G, T - #include <asm/io.h> {" a% K* d7 ^, V
- #include <linux/moduleparam.h>' E% _$ C7 k" q+ w& P: o
- #include <linux/sysctl.h>
# d1 u) ?$ k: U+ n+ H3 F - #include <linux/mm.h>
c5 F4 _3 q' ]4 U& y8 o$ k - #include <linux/dma-mapping.h>6 Q- A( e# j0 J! m4 T6 M2 d
- + c4 v) X( R0 H( F2 z. z
- #include <mach/memory.h>3 W# C# I( z2 d4 ^# B9 [
- #include <mach/hardware.h>
* h3 X, J7 p( x! r% i- g& _ - #include <mach/irqs.h>
# m3 X! I! [8 l0 l) N - #include <asm/hardware/edma.h> ?7 J; n C. O3 \5 \
9 E+ l- v- B. B5 R- #undef EDMA3_DEBUG9 A T1 e# s2 `6 T
- /*#define EDMA3_DEBUG*/
p% s- k* l4 ^9 T( r8 K8 h( I
" t0 n8 u, I2 V9 v- Z: O, F- #ifdef EDMA3_DEBUG
& s. ?" g5 ?4 Z! p6 H6 B. C - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
& y# v- I8 ~1 R+ a - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
( z9 X" |! }4 t* Y+ ?- a% |0 ~ - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__). l) p6 }) Z( l6 L9 w
- #else: f& E' H+ }3 y' e
- #define DMA_PRINTK( x... )
) i' i1 V1 }8 f3 ^$ s - #define DMA_FN_IN
1 a' ~2 ~! v% C4 |; _4 \) o6 U1 R- E, C - #define DMA_FN_OUT
+ h$ \' d* ~3 p/ D2 g% D' n - #endif
) u( m( d1 p! I+ e/ u+ _1 k7 D1 B
. M9 Z9 K! h& v, Z! h: l1 q7 r8 h- #define MAX_DMA_TRANSFER_IN_BYTES (32768)6 l# F. P3 e) ~. F. x* w
- #define STATIC_SHIFT 3: h8 y. h! `2 R4 i5 j
- #define TCINTEN_SHIFT 20: M( M6 s M. h% Y
- #define ITCINTEN_SHIFT 21& r& n. x0 r5 u! ~6 J
- #define TCCHEN_SHIFT 22
2 @. D$ i& g+ P0 T) g: N0 ^ - #define ITCCHEN_SHIFT 23& {0 L( {. J" q7 \, R$ }
3 m2 D1 N3 Q7 E- static volatile int irqraised1 = 0;6 l8 G" Y4 \( F6 \- B* W c5 I9 V8 A: G `
- static volatile int irqraised2 = 0;, `$ x( K9 x3 o' }8 Y
- # P% n6 G P. M) w
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 |" [% Q' X+ ^" R$ s
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);- D8 u4 f, X1 V. j
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);' B8 L9 n. D, e
) l$ y6 K/ ~0 j& I+ {/ h$ H8 }8 g- dma_addr_t dmaphyssrc1 = 0;6 R9 |$ o w) g. t' A t# G R
- dma_addr_t dmaphyssrc2 = 0;
, g% C$ K) ?/ \ - dma_addr_t dmaphysdest1 = 0;, ~8 g' y4 v8 C, u( H' P6 i
- dma_addr_t dmaphysdest2 = 0;" Y* i0 y6 K* w2 [& c6 i
- 5 `# s1 @$ f4 n3 D- L
- char *dmabufsrc1 = NULL;8 O# H9 u( j. C7 u! Z3 O% ?
- char *dmabufsrc2 = NULL; i1 h! H" o( ~4 {9 V- f
- char *dmabufdest1 = NULL;
D/ C* i$ s0 E( } - char *dmabufdest2 = NULL;
: `4 S$ U( J6 @3 B) u# _
" G* `3 _/ N) j6 x) e/ H# [( u- static int acnt = 512;6 e( {' ] J8 A. ~5 f8 P$ C$ H
- static int bcnt = 8;- h {- V! E7 t$ i u
- static int ccnt = 8;
+ K. Z3 e! [/ ^+ I; O
- u2 A Z% ~' H2 o4 i- module_param(acnt, int, S_IRUGO);
4 f% I2 B% V$ i2 o' L- z - module_param(bcnt, int, S_IRUGO);7 |4 l l7 f# A j0 u
- module_param(ccnt, int, S_IRUGO);
复制代码 + ]3 n9 v7 F5 o; w( W) G+ H; p
- P& e8 b! g7 V, y- A$ x5 U. N% }
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
. X( u7 o1 e; farm-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' x; h( o' Z1 E5 H: ] 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。7 T; e& y2 |+ x4 ^ Z1 Q
6 q2 \) v5 J+ Z7 f( @
2 a- d, \; [0 D4 P4 Y4 {6 p% e |
|