|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 7 W$ p; M% J; X6 W
- [code]EDMA sample test application
! D( _; }" R( P. S1 s1 g+ l - /*5 z3 ^) P( P) y$ K" S) N! E
- * edma_test.c: s3 M+ i/ L" G/ k
- *+ w# W5 q( ~- V+ e; W% A" b
- * brief EDMA3 Test Application
# x, K+ Z u c. O - *9 S! w8 b0 v, m/ H% O9 _
- * This file contains EDMA3 Test code.
5 b2 l$ d* s3 i# F% Y+ D% p - *1 Q1 ~' _5 E3 {5 u4 s% {
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE4 ?: S, _& [. W7 [7 Z
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
. B+ @, ?0 d% Z# o/ H/ S* p3 M% D0 k - * TO CHANGE.. g; }) f6 y: W: _
- *
: A: H/ i7 Q" {8 O: U, q. m7 ]8 s* A - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
5 ~9 H2 F0 b$ R6 {* t - *
7 a0 P: \. B0 G- O0 z) O. Q3 v - * This program is free software; you can redistribute it and/or
$ G) o+ o2 ]$ W - * modify it under the terms of the GNU General Public License as
2 y3 j8 K4 x9 M" n4 o3 z - * published by the Free Software Foundation version 2.; p7 h6 c0 E2 f+ A' k
- * J7 B' J) i4 m0 T3 L
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
! g. s% C1 t$ p - * kind, whether express or implied; without even the implied warranty
/ {9 |0 K7 w& V" | - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
0 P0 Y) C/ |+ w) y1 M - * GNU General Public License for more details.
5 E' ?: W+ }$ B6 a4 u. m0 `5 m - */1 u, ?1 f0 a$ b) r, ~% ^2 ]
! ]# U8 @# v/ B% p; e' \4 `- #include <linux/module.h>1 F9 d9 R8 X" V7 Z3 P6 t
- #include <linux/init.h>
3 M2 H: m+ |3 h5 Y, l8 O% V3 M0 w - #include <linux/errno.h>
9 G$ a5 L4 n- p) `+ T - #include <linux/types.h>
# W! {1 l; k/ v2 @' F8 l9 |. x - #include <linux/interrupt.h>
/ y) L9 g4 C8 J- i# [; ^/ | b - #include <asm/io.h>
0 w9 [) C# c: p. d - #include <linux/moduleparam.h>
0 ?5 a2 t9 d. a. |' i4 Q% w - #include <linux/sysctl.h>6 T$ d, r; K2 j2 A0 T/ P
- #include <linux/mm.h>
2 t3 R) L- E% q# p - #include <linux/dma-mapping.h>/ I4 ^) j* _' I7 d
- 1 x7 `* l* F+ s' ?4 {2 `1 l' f
- #include <mach/memory.h>
# U9 @6 V) s2 U: K - #include <mach/hardware.h>$ j' i$ Z+ D) v: u! J
- #include <mach/irqs.h>
6 l' u2 p' C2 G2 S& a - #include <asm/hardware/edma.h>5 } ]9 {& `4 `9 e% C" P6 ?, ?
, c; a! |7 i3 _$ V. q- E9 {- #undef EDMA3_DEBUG2 }. O& O! x' g h- J! I' E1 h
- /*#define EDMA3_DEBUG*/% m, Z7 v% j( n3 l! u
1 r6 v8 p6 t8 x: Y- #ifdef EDMA3_DEBUG
8 l6 _- H! u. Q& ^ - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)5 b: F4 ?; J- e4 m9 x
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
, r8 E7 E; e& b; x1 j8 a9 V Y T- d - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)& y2 r n' @5 W1 H' _+ v
- #else/ Z! I; `! J/ |) c
- #define DMA_PRINTK( x... )
) S$ h+ q B. U8 g - #define DMA_FN_IN
# R- O& B0 k; m) F - #define DMA_FN_OUT
' Q4 d8 D% u: a5 s& f& | - #endif
. y6 g3 l7 ^' ~2 |% c - " J! u" e; `0 P; Z: X& X
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)9 [- Q2 S) Y5 Y- R
- #define STATIC_SHIFT 3* C6 T+ s) W2 y7 n1 j. F2 H! m, f& |3 I5 E
- #define TCINTEN_SHIFT 207 R9 {/ v& X* o2 s- Y/ P
- #define ITCINTEN_SHIFT 21
# i+ i S3 A( x7 h- \9 m# T - #define TCCHEN_SHIFT 22
; d E1 m8 _/ F1 X - #define ITCCHEN_SHIFT 23
. p0 q* i9 |0 ^0 c0 f0 x; u$ n- \
1 d* ^6 y/ u: f( S- static volatile int irqraised1 = 0;% m- \; D! v7 \; ?- y( X" P& i3 z$ X
- static volatile int irqraised2 = 0;
9 L2 J' A+ [1 ^7 I: b- ` - 9 X! ?$ @4 n7 P- i4 F
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, p a5 Y8 Z" r - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
v$ E) _8 n4 N. r& v3 f( g" ~+ c - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
# {% {( L2 s3 Y3 t! ^% W8 z0 K - & s6 h( u' U5 Z, s- Z) X/ B0 B' h
- dma_addr_t dmaphyssrc1 = 0;
) }& M+ E. y+ }& V8 S0 { - dma_addr_t dmaphyssrc2 = 0;. d% O& t6 m! [5 f' n _
- dma_addr_t dmaphysdest1 = 0;6 k: T1 b# g# R6 I( G9 z. f" `
- dma_addr_t dmaphysdest2 = 0;
: `! p6 h5 t/ y0 d t+ z - 2 E( x: V+ H. y4 V$ V. p H
- char *dmabufsrc1 = NULL;# F- L6 \1 F, r* B, L( E
- char *dmabufsrc2 = NULL;0 w0 u: {& X8 _$ B; E3 V
- char *dmabufdest1 = NULL;
+ c% J3 c" o$ E - char *dmabufdest2 = NULL;2 R" m2 u, }; y% o# N
- z {0 q# s2 S6 L
- static int acnt = 512;
& Q" A9 M0 B" h - static int bcnt = 8;9 Q$ O) w1 {/ M0 f) K
- static int ccnt = 8;9 U" @6 Q& M) B. O& b" e
$ w- K0 G/ ?3 |% n9 x- module_param(acnt, int, S_IRUGO);
# g. v/ Q: I. @" z - module_param(bcnt, int, S_IRUGO);
6 d0 C) Q1 d5 H+ h. Y7 u# i- P2 f - module_param(ccnt, int, S_IRUGO);
复制代码 5 \' _7 g5 T( w' R
: d$ R7 D# a+ U+ E6 t3 ^
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
4 e0 a% b0 P+ h* p% N8 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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。- _4 ^6 v$ e" h4 K/ Q) N, Q: Q) I6 ^3 Z
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& S) n" ]$ b) Z9 k6 C
: D4 F, J6 K; j& N8 m
" |( n/ ~- D" w8 D0 O |
|