|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
5 r" k9 l! E- z$ F- [code]EDMA sample test application
; h! I/ z, V9 M9 P( [9 w0 J - /*3 k' V$ H6 C" b! {$ h f, j$ w+ Q
- * edma_test.c
. R% D. G2 [& s - *
: G2 D9 u+ ~% D" _ - * brief EDMA3 Test Application
* x5 y& |5 {" G# K' W3 z - *7 `5 L# M( S6 v( Q
- * This file contains EDMA3 Test code.
* L4 y# @; e$ ?4 ?( \4 u3 A - * a1 N. Z! Y9 |1 s2 B+ N
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
: a( n& _ p* f H! _ - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT+ g3 j- k$ S" T( j, D+ q/ x- {
- * TO CHANGE.
+ z6 \) ?9 e& `0 l$ i% g* l* W - *
. p3 t! m; y* r# I& l - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/+ e0 d- B' M% x' |+ c
- *
l+ s# L5 O1 L- I& r t6 u0 U - * This program is free software; you can redistribute it and/or9 U! s) i1 v c' L R, _
- * modify it under the terms of the GNU General Public License as
5 x0 Z" V7 Q5 `$ h - * published by the Free Software Foundation version 2.
% S, L6 j5 i0 S - *+ \' q) ^; {$ C% u0 R4 y
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
. \+ N X. q" P) B6 w) [( r" W - * kind, whether express or implied; without even the implied warranty
4 u7 U2 U* L+ |2 r! ^! V - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6 b; i+ ]; e' \- s9 T5 D& l - * GNU General Public License for more details.( K5 N3 B- [7 e
- */+ s" A2 P# z9 h b) ~( z$ f3 B4 j
0 f0 B% s% Y1 Q* U7 h. s- #include <linux/module.h>/ Q L3 t! x8 _# L2 D! o, i6 p
- #include <linux/init.h>% y: h9 j- C: O+ c6 D7 D
- #include <linux/errno.h>
7 S3 q# |, P4 K- m/ e% ] - #include <linux/types.h>
3 s1 o2 c& g% l, q - #include <linux/interrupt.h>
$ p8 A3 l4 w- [7 a1 k1 c - #include <asm/io.h>
. v1 E1 e2 `( \# \8 x0 c! y+ e0 T - #include <linux/moduleparam.h>/ L; ]* P8 B& V. L; V8 q! Z0 _
- #include <linux/sysctl.h>$ N; {3 @5 b; E* i P# [
- #include <linux/mm.h>
* L7 [/ p( Q8 a/ X+ K - #include <linux/dma-mapping.h>
' k! x5 \( ^1 P8 N7 b' A
+ v l) ^2 B5 Z0 s# U0 t* W8 p- #include <mach/memory.h>
1 D. s& e: l! ~& ^4 E2 H+ V4 F+ `# J - #include <mach/hardware.h>! C4 Z C: ~. @8 c+ o( {7 n
- #include <mach/irqs.h>8 o0 G- p; N) X. I, i
- #include <asm/hardware/edma.h>
/ @& V. Y# G8 V! l2 @7 n9 f9 }
7 `1 C/ ^5 l9 z) i2 }% [7 s- #undef EDMA3_DEBUG/ f# e: A& s3 h8 r+ ^9 k& o9 w
- /*#define EDMA3_DEBUG*/
, q9 I( f( \: j6 p! V: F0 g, t* O - 3 p4 ]0 ?; T2 m$ ?
- #ifdef EDMA3_DEBUG; X) O4 I/ ?5 D, o2 R
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)4 ? g) M+ R. Q$ R: S0 ]
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
% o* I0 X6 ^# {; Z$ K# | - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)8 T) C5 A; i' F
- #else
; N' f" B* i" s8 D# i" W - #define DMA_PRINTK( x... )
& ~5 b5 k! P; Q, {/ c! M - #define DMA_FN_IN
9 Z; O8 f+ s: L; s9 g - #define DMA_FN_OUT! V( `5 q A5 s& q7 `/ f: t$ W
- #endif% ]3 Q/ W6 y& X" I' M* i/ J
- - u2 s8 x& Q+ Y5 w2 F( m
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)( `+ h) I% K! t# M6 o
- #define STATIC_SHIFT 3
+ A2 k+ {- ?) [. p - #define TCINTEN_SHIFT 20+ U" E! a V j. u
- #define ITCINTEN_SHIFT 21
* S6 k; I' u4 D' I' z5 H - #define TCCHEN_SHIFT 22* F5 P7 t2 z: s
- #define ITCCHEN_SHIFT 234 x ?( C7 o! J2 t" f
- f2 B8 v1 F" m& p: Z4 R- static volatile int irqraised1 = 0;6 e' t5 @2 v' {, {' H( X
- static volatile int irqraised2 = 0;
3 m$ e f7 N0 ?% q" s# u' p* h6 ]$ r
/ q4 l2 ]8 e5 M* ~7 t- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);6 T) p4 q, Z/ P
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 ], i- L( G) b+ K1 F' _
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( `# v, ?% r! J, u3 a/ f - & \, ^5 R+ g- c8 F0 z' O
- dma_addr_t dmaphyssrc1 = 0;
% r" t$ V; d8 |/ o - dma_addr_t dmaphyssrc2 = 0;+ F4 z6 N) M( o8 M+ ?; a& `/ |: H
- dma_addr_t dmaphysdest1 = 0;
, |/ L5 O% T' F7 ]- O {6 m0 g - dma_addr_t dmaphysdest2 = 0;
$ V. k1 W/ R: }9 y: e3 [- g+ c
, y0 a' y9 v5 T( ^% E2 v5 p- char *dmabufsrc1 = NULL;0 d4 g l$ a Z
- char *dmabufsrc2 = NULL;
; j- H0 q5 R- ^2 x - char *dmabufdest1 = NULL;9 w0 G& e( C' v
- char *dmabufdest2 = NULL; d+ d- C+ a s, i+ d6 ]+ {
' T2 O$ R0 V! }6 B- static int acnt = 512;
9 m' n8 f |) {+ a+ ? P - static int bcnt = 8;
* L& E% R7 D% ^# v x - static int ccnt = 8;" p, g: V% d2 @' [& S3 |1 N
- 1 P% j& R& m+ M
- module_param(acnt, int, S_IRUGO);5 u$ V% x0 J% k. J$ D" F$ L5 o
- module_param(bcnt, int, S_IRUGO);( [ i9 j, e9 v
- module_param(ccnt, int, S_IRUGO);
复制代码
, |. h+ c4 z( g7 ?, v8 M1 _) [, H. q% A4 h- Q* h( X6 A0 T- S2 H
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
B2 O4 d0 I* O! [( I/ ?2 z) Marm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
3 v) u4 E, ?4 S7 C 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) I& c2 b- ]5 R& y0 `
+ Z' ? J# k T0 s- a: \+ c H; ]7 h# b% d) R$ [% a4 R( o1 {% b! V
|
|