|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
2 A% l$ L2 k `1 x8 ^- [code]EDMA sample test application
2 G9 R. U5 S7 f, Z$ p: ~ - /*) p# j. {8 Y2 P( L5 n
- * edma_test.c
5 Q; e7 x5 @4 N' ~( u# h) y - *
3 Y' u' d' s( ]$ w - * brief EDMA3 Test Application
$ S8 o) x0 H) k8 i9 L5 T- a - *
7 M" { i/ T( J1 t1 O - * This file contains EDMA3 Test code.
* t1 k o) \* |$ F& i1 P# {4 u - *6 r1 H+ I3 ]6 s0 G8 X* M
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE
6 e2 p# L, G8 X1 ]# M - * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT! I) O% v9 a% z0 [, w& I& N
- * TO CHANGE.* W. k) @3 e& s1 R% N" }& ~
- *8 W x' H- V( o; S4 A! |
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/$ x8 w/ a7 A; X9 z8 V
- *
8 z+ N2 y% L0 A - * This program is free software; you can redistribute it and/or
* B1 F5 |' u; V: y3 k - * modify it under the terms of the GNU General Public License as
2 b/ \. u C r5 y - * published by the Free Software Foundation version 2.2 F1 X w9 S! U3 S( c6 ^+ j+ b6 V
- *, J3 k. w8 m0 N
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any. V) [# H4 w' ?) H+ B+ b
- * kind, whether express or implied; without even the implied warranty; Z+ S+ }" O& F
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
: r# z% z+ h. L$ l- s - * GNU General Public License for more details.; ?8 i: S& {% C' b. Y
- */
/ C" v# W; I9 I - 7 R# J6 \0 {/ _6 e1 R
- #include <linux/module.h>
1 W s* x' a% R4 C' Z - #include <linux/init.h>0 D2 R$ q# F$ I
- #include <linux/errno.h>! i) b( r, T1 p! N- `
- #include <linux/types.h>
! Q+ p1 R- I; q% h; D c7 ~3 {" V - #include <linux/interrupt.h>; u* N* B1 ]+ i9 ]
- #include <asm/io.h>1 @, F% T8 I7 M5 | Y8 Y3 n3 T' X
- #include <linux/moduleparam.h>
, T% c3 d* Y9 {! z! N- |) c7 G$ | W0 F - #include <linux/sysctl.h>
5 |9 z. g: y* D' A0 o& k - #include <linux/mm.h>
R2 X6 A, g' c! H - #include <linux/dma-mapping.h>
# V+ b D; S8 b# x - 6 m" Z8 h8 n! }+ S7 L
- #include <mach/memory.h>
. O- Z0 k% {* N( f; c. l# o+ b0 g0 L - #include <mach/hardware.h>; T3 Q. D. J. h& J9 t# v( q
- #include <mach/irqs.h>
" G8 p& F: n8 k - #include <asm/hardware/edma.h>( o- V, V0 u& ?$ `
- i- c! R0 t+ S
- #undef EDMA3_DEBUG
4 }! P7 s) ^, g$ D4 M - /*#define EDMA3_DEBUG*/. j! A" q' r: q" @5 }5 \
0 o4 H- P/ F' x M# W4 b% W" q2 Y- #ifdef EDMA3_DEBUG
]/ G! O) M' M - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)
8 s0 C0 `& j3 C9 d# x - #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__) z- q& }/ f% ^& Q% H
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)4 p/ }! Y! h# n% S& S$ C
- #else1 p$ q) L2 A0 U5 }1 {
- #define DMA_PRINTK( x... )
# I/ e3 D! d# N8 L - #define DMA_FN_IN
1 m+ ]" T# j1 _7 \7 b - #define DMA_FN_OUT g) y- @) g* g- B& t m" J1 Y
- #endif* J( b: w" h- z' G0 x
- " a% g. x, r5 c h
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)! F- |* S6 E( e
- #define STATIC_SHIFT 3$ E* m: x3 M# z% h
- #define TCINTEN_SHIFT 20
- S( q: k) v4 B6 w& L% H - #define ITCINTEN_SHIFT 21$ f( M# \* F) E. ^, l+ Z
- #define TCCHEN_SHIFT 22
' v' E; a% _' `3 j1 @9 m } - #define ITCCHEN_SHIFT 23
& ^/ X# a& P" E% {( S4 P3 W+ F- J
; ~4 H/ l( X/ E8 }- static volatile int irqraised1 = 0;
% o. \1 p% I$ ?: J0 [; T% O - static volatile int irqraised2 = 0;
. ]( S _, T d - ! O+ b; ^9 r/ D! A( w
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);4 o# P# N4 K [; m) Y1 x
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);1 F1 n5 o' @) \
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
( M. @; B C- F3 Z
7 b. d* A& u% G% l* @! p+ L `- dma_addr_t dmaphyssrc1 = 0;* u0 Y) l$ r) G
- dma_addr_t dmaphyssrc2 = 0;7 v, |7 _0 X3 E1 u3 _
- dma_addr_t dmaphysdest1 = 0;3 |8 K0 R, g Z7 ], j
- dma_addr_t dmaphysdest2 = 0;6 y9 ^) |, R, l6 M# |
0 P' t& l# Y/ ^8 f& s2 J- char *dmabufsrc1 = NULL;' a- g8 r! c5 K4 d- j
- char *dmabufsrc2 = NULL;' I2 o1 \ W/ [ J7 e
- char *dmabufdest1 = NULL;6 B$ u9 D8 x) C, [: x& u+ G
- char *dmabufdest2 = NULL;. d. Q- E6 s/ _3 ~+ e* ]5 a8 Y
- * [& X# j9 w, ?( y5 i( y: _0 |
- static int acnt = 512;
" P! L9 X. a- e - static int bcnt = 8;
! k+ i' T! L8 ~! Q3 M# Q5 M8 [ - static int ccnt = 8;) G8 a/ N* a0 Z2 A
8 [8 z8 W# c, d- module_param(acnt, int, S_IRUGO);: x4 P5 e1 A1 P* ?0 I' Q: U7 B
- module_param(bcnt, int, S_IRUGO);( T$ U$ _. T7 |0 k6 F3 y7 m; K) i
- module_param(ccnt, int, S_IRUGO);
复制代码
0 O3 q b0 K: O5 ~6 f2 e; \8 t3 m' l- R1 @, `8 z+ [
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' Q& P( {8 U2 T: Sarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。% r# X4 A7 J0 h) Q
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
: E' v" I" e$ `4 a. L
: X$ W' J( R& M# A. S
2 n0 ~2 {- i% F# P( A* ^* o |
|