|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
F. k- \# I5 J5 n' y; n6 Z: d- [code]EDMA sample test application7 I. H/ Y7 x* X! e# K
- /*
/ \, J/ |+ v& V5 f8 s: J8 i - * edma_test.c' g2 N3 v" Q5 y; @& m2 N7 T
- *$ |5 i- Q. z$ F* K, X5 H' C' |
- * brief EDMA3 Test Application
9 R3 U4 X' l9 l# e( \/ h; X - *
* k" t4 t- I& C& W$ H" ] - * This file contains EDMA3 Test code., E9 X+ t6 }& [7 Y5 e' P& l: {! T
- ** ^! `. z" K9 }' ~
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE' Y/ ^! Y) W. L$ n/ ?
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
- _9 j2 M( W/ ]4 P - * TO CHANGE.
- |8 l/ r! P) F2 i/ e) C( | - *
* n. z& O1 a1 Z8 K, j" { - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
3 X5 ]- @' Y0 ?& Q; z6 e - *
% i, q2 M; _7 o; T - * This program is free software; you can redistribute it and/or. E: V9 J- b7 j) o) n& l8 B" W
- * modify it under the terms of the GNU General Public License as* T) L2 \ C; t: f5 _9 G% K, g- W
- * published by the Free Software Foundation version 2.
/ w) K, c4 z% D* D( g5 ^. G - *
& q0 k' u0 T5 [% v - * This program is distributed "as is" WITHOUT ANY WARRANTY of any3 p8 m8 w3 |; I% t& Q. d. S: d
- * kind, whether express or implied; without even the implied warranty8 C; a$ W" s8 R6 w
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
, r6 M' _" u% z- W9 F& J - * GNU General Public License for more details.5 X! G/ @1 Q4 a- U6 U
- */
$ J( K/ v& E: G- Q( [
5 m" R X* z0 I- b- #include <linux/module.h>
/ z! l& C( f* f* d; q4 c - #include <linux/init.h>
: E7 w7 x+ i0 Z. j' T; |( m& y - #include <linux/errno.h>2 F2 m# q/ p/ C/ @
- #include <linux/types.h>
( W, K/ q9 e6 @" w - #include <linux/interrupt.h>
$ \' [2 j7 l& k4 z* Y7 g - #include <asm/io.h>
# K1 c' M2 A8 f. k1 J9 B. @: B - #include <linux/moduleparam.h>
; Y- P6 [, F& O- E5 ?2 x# Q" Z9 I, ? - #include <linux/sysctl.h>
( A7 O0 @7 N( R \/ _( ]2 a1 ` - #include <linux/mm.h>7 T. Z4 V9 ~% ~- ^ d
- #include <linux/dma-mapping.h># l% m4 H3 P9 Q5 U1 h
7 v3 n2 k% ?* C. {& @- #include <mach/memory.h>0 {2 J3 i' D7 g! s# }) ], M
- #include <mach/hardware.h>. E' @' |/ a" ^) s' Y$ x) S8 H
- #include <mach/irqs.h>
5 Y& O1 C& ?$ f - #include <asm/hardware/edma.h>
! G- h% c) l5 D" ?; N& ~8 L - - D0 w) F) s M$ b, B, H
- #undef EDMA3_DEBUG* ]; k) Q9 i9 s* `
- /*#define EDMA3_DEBUG*/
- U3 g( V) t9 u
0 U, Y6 I& z! N/ Y% c% q% Q- #ifdef EDMA3_DEBUG; |+ u: q) j d7 s I+ R4 ~
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS), j8 |& o2 v0 P( v1 B
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__)7 s% B% q7 p' ]$ A7 `) p. A
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
2 S' u8 p( f. E) K - #else
D' H5 i& A) q" I$ e; P - #define DMA_PRINTK( x... )! u) G. a+ q8 w& H6 O
- #define DMA_FN_IN
" G+ @/ z7 |$ e2 C, g5 [, O - #define DMA_FN_OUT
1 P- M( K9 ~4 Q( s: s6 V5 w - #endif
% T7 E* @" N2 L - 4 {0 W1 s, _- r
- #define MAX_DMA_TRANSFER_IN_BYTES (32768): E, x( R& o. V
- #define STATIC_SHIFT 3
' j4 a5 s* M x: ~ - #define TCINTEN_SHIFT 20
! A& x- O( k$ @2 o" u- c - #define ITCINTEN_SHIFT 21
7 c O: ~* t$ \# H" y" Q - #define TCCHEN_SHIFT 22
o$ D. |: A6 ?- c - #define ITCCHEN_SHIFT 238 A. |9 ?- c N5 ^
- + Q" P# H& }, X' g* s7 g; O! a
- static volatile int irqraised1 = 0;; m0 O' `- t* K
- static volatile int irqraised2 = 0;- J4 Y7 M5 c8 Z2 E0 p' p5 V
$ P9 P9 |2 w: c3 q& k- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 j8 A/ a; K b4 \" M$ t
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
% x1 }: ]' h5 N3 c, q - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
9 Z' k, e" C# I5 M - ' g& J- s r" a Z# g
- dma_addr_t dmaphyssrc1 = 0;6 e; k4 ]1 l& d. R5 |9 J/ W
- dma_addr_t dmaphyssrc2 = 0;2 w% Z" f& ^5 P% F$ Z
- dma_addr_t dmaphysdest1 = 0;
' l0 @% j3 M F1 r0 }9 _; b - dma_addr_t dmaphysdest2 = 0;
! f2 |5 ]' C; r+ x - 3 A( \4 c9 A8 d* P& ~0 A& ]
- char *dmabufsrc1 = NULL;
6 J2 \& p/ F. i% B7 { - char *dmabufsrc2 = NULL;
7 b) s+ y& l' \3 r2 S - char *dmabufdest1 = NULL;
" X0 N( _- s+ y7 F; j; k - char *dmabufdest2 = NULL;
% ?! X7 V' }4 V% X6 _" r8 r4 u
( b: @7 O6 A/ d$ f- static int acnt = 512; O2 ^ z0 I% F; d' R
- static int bcnt = 8;+ e$ W7 D3 I% x8 T( S
- static int ccnt = 8; p9 V$ N* {4 v2 G2 S3 f7 L& Y, F
- & o. i9 Q/ T/ g
- module_param(acnt, int, S_IRUGO);8 z: I& n/ v# ^' ]" R
- module_param(bcnt, int, S_IRUGO);- ^, [& \+ |: l$ p5 a; j
- module_param(ccnt, int, S_IRUGO);
复制代码 8 s9 M. x+ c! v' C
; O r% V+ M# u. h) K8 w, n
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用$ V: [. W/ K8 a Y5 P! Y
arm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。" [# {: P& b: `9 {
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。& z8 a. x2 g1 c
# V2 F# E6 i! I; a
6 ]+ r- y1 V2 s" N |
|