|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑 * k4 v3 m( B8 R7 D, T! U
- [code]EDMA sample test application
7 B2 z7 u! L: v/ d B. P - /*
% m; e$ |6 b Y, F. Y! p - * edma_test.c, ?6 ?4 Z6 {/ `0 k
- *& j; a: |% a% w, c
- * brief EDMA3 Test Application& b4 ]! w) P8 J" T- ?
- *
( r8 B' y8 [9 V6 E J5 z, Z/ I - * This file contains EDMA3 Test code.
l( Q5 A. D6 E' b# \ - *2 ~ [4 U8 u! ~$ A/ u. `3 }
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
3 y8 p! A$ [8 l% z* E) l: U - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT7 S" B1 E0 S3 g5 M5 n8 S
- * TO CHANGE.* z& O4 c/ c* x+ _ ^7 Y
- *
& M9 J6 j3 U" G8 L6 n+ s - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
9 g7 p# z3 U- j; w* @( ? - *
$ ]; x8 @0 y6 g! D& s - * This program is free software; you can redistribute it and/or: c, F# e) F& u ]" d3 p9 o% I! [
- * modify it under the terms of the GNU General Public License as2 M& T; e2 M$ ~1 z
- * published by the Free Software Foundation version 2.
0 Z9 M% j: R' k5 M9 Y - *! A# h( [$ m0 ~4 o/ H# e
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
% t6 l0 \- E4 ?- ^3 f - * kind, whether express or implied; without even the implied warranty
# P* ?/ Q5 ~: X" L6 Z; I/ W* x9 M- K - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
) { m1 ~/ U# `7 ^3 ] - * GNU General Public License for more details.
( i: g) N! b4 a& D4 q- M - */
% _( j* V: x) Z* y6 |: j
8 x5 O0 I- o' L' ]4 Z- #include <linux/module.h>3 \ h9 c4 t! @$ L; `/ f& D1 s
- #include <linux/init.h>1 D( O2 u5 [- N# |4 j
- #include <linux/errno.h>/ y- L+ L7 ]2 f% y
- #include <linux/types.h>
) @1 `$ I8 o" b$ m - #include <linux/interrupt.h>
- L( o, M+ h" f/ I& j) s - #include <asm/io.h>) Y5 A% r. t/ Z
- #include <linux/moduleparam.h> }- s2 f9 {0 q0 M6 U
- #include <linux/sysctl.h>9 E8 b# i/ y" J7 ?' d
- #include <linux/mm.h>
1 D$ w' N7 b' ]+ B8 |* E+ i - #include <linux/dma-mapping.h>
9 L* |3 s2 o- B( \! e
& n* u- u( K" l: L: v5 t$ E- #include <mach/memory.h>: [" @" f3 @( E
- #include <mach/hardware.h>+ j; N8 ]& e7 `& p- x7 `
- #include <mach/irqs.h>
9 c% m M& f8 u - #include <asm/hardware/edma.h>
* G, O. L. v' L, Z: W" Y: q - 4 k$ ]' o- r% w/ D( E
- #undef EDMA3_DEBUG
4 _# J* b8 \0 {" B% ]. M - /*#define EDMA3_DEBUG*/& ^1 d# Q# ^# x! e! W
- , l6 {/ q: F# e% m8 |) j2 v
- #ifdef EDMA3_DEBUG
3 |: o: ~9 E2 F+ A - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)0 o7 N" Y9 O6 v8 E4 h9 d8 e
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), C! r: T2 \, W* D' E; u* M
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)# s4 b/ e) O# @( g; c9 w
- #else
[$ Q( M4 u" @# U, }7 r4 }0 x$ c2 v - #define DMA_PRINTK( x... )
; U- z9 E1 u( l- Q& E( u8 M8 B - #define DMA_FN_IN
8 T7 C& R5 O3 j# B - #define DMA_FN_OUT" g2 `1 r0 ~' o' Q4 B+ W$ c% ^$ K
- #endif3 q6 [! A( U. A- I; I
- # g( R- m: {( C* Z- S
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
* ~% @( b; N6 S, H/ G4 W: I - #define STATIC_SHIFT 3. K# a/ @4 v @4 N1 [! b
- #define TCINTEN_SHIFT 207 j+ c: o; |8 V7 @
- #define ITCINTEN_SHIFT 217 @+ x) I& t: f7 U* ^/ ?
- #define TCCHEN_SHIFT 225 ]# I8 p1 }) V. ?
- #define ITCCHEN_SHIFT 231 U7 O0 x$ i4 x6 v0 |7 v% [7 _* u; K* t5 y
6 B) c* }! f* |1 M# g" w- static volatile int irqraised1 = 0;. g5 G1 n2 [) J9 G
- static volatile int irqraised2 = 0;
4 i2 S1 l" b4 D4 }" R: } {1 P
+ X! m0 e1 |& N7 Q% f6 [* `* s1 N- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
7 J4 s$ `. D1 O- w0 h5 ~ - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 T$ {/ Z! e( s/ w! X
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);& `% [* H! {+ ^0 H3 g
- 4 s$ h& U5 O0 f% N+ s2 c
- dma_addr_t dmaphyssrc1 = 0;0 ?1 E0 d0 p$ S- Q0 h9 [
- dma_addr_t dmaphyssrc2 = 0;
" m6 Z+ o8 G- k0 C6 l - dma_addr_t dmaphysdest1 = 0;
4 T# U8 v1 h" `. { - dma_addr_t dmaphysdest2 = 0;2 u, p2 n6 T" ]$ w+ y9 V
( ]1 L4 S1 y! \- c4 ^$ f: Z9 i+ `- char *dmabufsrc1 = NULL;* L8 h& n2 O1 Q- p
- char *dmabufsrc2 = NULL;7 Y0 K$ m& ^& D$ \
- char *dmabufdest1 = NULL;) C% `7 T1 O7 L9 n+ D7 a" ~
- char *dmabufdest2 = NULL;
. L+ w; Q8 Z I - % e- U7 x6 u2 {& {2 V- H
- static int acnt = 512;1 k. `. T+ q! z+ z) ^
- static int bcnt = 8;
4 G& a @. |# i2 E - static int ccnt = 8;3 k; j) A+ x, z7 G7 t1 V
- + E3 h' v: L7 q$ J4 x1 T# ?
- module_param(acnt, int, S_IRUGO);
& C" I7 c9 n6 S1 q - module_param(bcnt, int, S_IRUGO);1 x- o) o# b* V# t7 ?% ?3 m
- module_param(ccnt, int, S_IRUGO);
复制代码
3 Q! }( |6 d6 n2 d2 H5 _/ v% S; o! I/ D
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
! ^4 G& ~5 a. t* Karm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
7 l6 T' j' ?0 M. p# T1 m 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
% E# ^; u/ k& U, Q: H% t
- e3 C% L% P+ [4 I5 ?8 }
. V3 }, G2 y! ?! r6 N |
|