|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
" f4 ~& I( c( b: |) }9 l$ ]) Q- [code]EDMA sample test application
' u3 g6 a/ h+ S A: K - /*
; g3 v0 I* g* D3 }8 u - * edma_test.c
# P/ l8 y# K2 m* z4 D6 o& l - */ F! a+ A* y; q
- * brief EDMA3 Test Application/ o" w8 n, C) [! F3 p' e
- *7 n0 U, l& U0 j; ^9 i
- * This file contains EDMA3 Test code.
6 C0 s& f {. e) @8 x; z - *
7 q0 x7 ~1 E( @# C+ U, L8 x* I+ L - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE# d5 l( v+ G* A/ F" S9 C
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT5 ]$ \ ]& w$ ~( c3 X5 m( h9 h
- * TO CHANGE.+ U; \8 x' F7 d( ^
- *
& e* _1 _2 C) {) [2 K - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
6 W3 A; H) a4 b* v4 z7 t4 h - *8 ]0 O' b7 Q. t2 s# P
- * This program is free software; you can redistribute it and/or* T% @9 ?7 @8 b3 l2 W
- * modify it under the terms of the GNU General Public License as% P$ {7 K' h/ g/ m5 o& a A5 E3 b
- * published by the Free Software Foundation version 2.; E% ?! Y' G+ J \
- *
$ ~$ o' u2 ^+ A& I2 C9 u - * This program is distributed "as is" WITHOUT ANY WARRANTY of any+ Y( v- l c( F( I/ M
- * kind, whether express or implied; without even the implied warranty
& V8 h5 |. x/ v4 |# ?7 D1 U - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the3 {5 N7 V, Y) x/ S, ]& y; e
- * GNU General Public License for more details.& t& J" z: ~& R' ^
- *// A( t1 l' v: t; P
- 2 V3 j! p" P3 u9 m" E
- #include <linux/module.h>) h1 i% b3 ?9 D% }) J
- #include <linux/init.h>
. m9 y& ^! J- e, ]8 m; }) U - #include <linux/errno.h>8 F6 f7 N# g5 s) ]6 N8 g: y; g& J+ H2 Q
- #include <linux/types.h>, I/ d* F( \7 f3 M
- #include <linux/interrupt.h>1 O5 I+ ^4 p8 v1 O; n, E* f
- #include <asm/io.h>
: w: Z' q: t7 b2 E( O& f - #include <linux/moduleparam.h>
: p e8 r$ ^7 O! ], ?6 W - #include <linux/sysctl.h>7 R, J! w3 T: ?9 h; X4 f0 o, w% H
- #include <linux/mm.h>
( R9 e9 E3 |* |* x5 ^+ P } - #include <linux/dma-mapping.h>
+ q$ J) L+ I9 L! T
' s, q5 f% `9 X* I8 @- #include <mach/memory.h>
2 }) W4 T4 Q) z# Q! }8 Y - #include <mach/hardware.h>- A6 m$ Y& r& Q' O7 V, r: t
- #include <mach/irqs.h>
$ [( k8 X. H% I0 u) W6 F) u - #include <asm/hardware/edma.h>& E2 m( k5 U( y
0 w, t9 n0 | c S- #undef EDMA3_DEBUG
$ F, q1 _2 I3 R% m - /*#define EDMA3_DEBUG*/1 ^! m1 Q% {( `
! N' D$ a1 V" r$ v1 z4 @% s; G2 ?- #ifdef EDMA3_DEBUG. l" w3 e( `# F" {+ C0 T* }' @
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS), ^ E( t: p' @) C9 p3 a" U# }9 j
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)
" B+ R- ~2 q! f) P- x( v& H1 C - #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
; o8 L1 f$ P+ {3 R" V3 O" Y7 c - #else0 e6 g ?0 N$ ~0 P9 L5 Q
- #define DMA_PRINTK( x... )& R% I: Z) F! r7 s; `+ M
- #define DMA_FN_IN1 {3 G9 y: ?9 m$ q
- #define DMA_FN_OUT9 R# z8 e7 e. ]: W
- #endif
& W" \( E4 q8 R# H2 Y t9 O
, Z$ U. B# x9 N9 E- #define MAX_DMA_TRANSFER_IN_BYTES (32768)0 ?' v s. @/ X( Q, j
- #define STATIC_SHIFT 3! d. W# E2 P) l
- #define TCINTEN_SHIFT 20
. J) D. P& S7 N% }) q; s - #define ITCINTEN_SHIFT 21
# x: m" @" ?( j - #define TCCHEN_SHIFT 22
8 d9 J; v% I x5 \2 \ - #define ITCCHEN_SHIFT 23
$ F( L5 E/ m. W9 o+ o - . l% U" \# z: n( }
- static volatile int irqraised1 = 0;
/ d9 o. f% l+ F - static volatile int irqraised2 = 0;" M5 H, t3 p, v& ~% a- D# }
' Y H4 E4 s* |* A' ^- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);# K% n. Q8 t( r$ |" H1 j/ g9 ~5 X
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
" F o( l6 q1 \5 i; w - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
, O' h. Q8 g9 @+ g1 _
4 J' h+ f* N$ a- R! \- dma_addr_t dmaphyssrc1 = 0;! M; c0 N7 c8 {2 S3 I
- dma_addr_t dmaphyssrc2 = 0;
* y8 ^3 W: M- E! i4 b0 [( s - dma_addr_t dmaphysdest1 = 0;- `- }- j! g! c, G5 L
- dma_addr_t dmaphysdest2 = 0;6 e, E: y% F7 c! {! K( h$ d2 Q
7 S! Y6 N1 H, m; B5 M- char *dmabufsrc1 = NULL;" {3 p0 E H- |/ u" y* ?
- char *dmabufsrc2 = NULL;
: }8 C" \$ z/ { - char *dmabufdest1 = NULL;3 [* j- j- Y! l( _. {
- char *dmabufdest2 = NULL;
6 \# c8 S' i; l) C& E$ w
7 ]; l- e' ^5 ]; X6 X- static int acnt = 512;
( n$ S# F! _ n4 S - static int bcnt = 8;
4 `' V' M2 z. V. C: D4 a" b - static int ccnt = 8;. j2 u( Y: t" w5 o/ h9 m" h
- & L# A7 r% N9 a) J; @" p+ \
- module_param(acnt, int, S_IRUGO);
* |5 V' \4 r: O1 X0 c) K - module_param(bcnt, int, S_IRUGO); ?. K4 m& b# I7 N2 f q7 ~
- module_param(ccnt, int, S_IRUGO);
复制代码
l% Q+ D1 d- Y
: \6 K7 W& v% k+ N" l! J# ? 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
' F- n6 h4 ]& Y: O8 [$ t4 Parm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。) i( `/ Y: k' m
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
( R" N) A/ D. J2 ~" `0 o" L" ]9 h6 h% ~
! l, L0 S4 S `; e: A9 e% N7 G |
|