|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
( K3 f& ^$ e% B1 e- [code]EDMA sample test application4 w: x& W" D& Q0 R
- /*/ B! r& J: C p8 s: A% T' ]: @% n
- * edma_test.c
1 B: v3 j, h7 L+ D' Y6 T - *
, C. i! d* m* N* }0 D% D0 s - * brief EDMA3 Test Application
$ ?3 ^4 u& `2 i* s. x J g - *
. n2 j3 J) `+ y5 }+ E$ z: ^ - * This file contains EDMA3 Test code.
& h, f6 K7 ^" z* } - *; \, F4 f% G" K7 r! O& i0 g
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE# u( v D& H/ H' [" n6 k
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT
( o) X. w7 E" Y - * TO CHANGE.: d" Q% s( R# l# V* F1 J, F
- *% R" c9 v! \ [& e$ p* X( e/ A
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
" f( |3 C: }% j5 [$ D - *+ m& C. K$ ~7 o! Q
- * This program is free software; you can redistribute it and/or
( P2 n3 e/ h% M - * modify it under the terms of the GNU General Public License as7 @+ c5 }9 Z7 B8 R' @ s/ s$ H
- * published by the Free Software Foundation version 2.8 O; `1 J' e: z. x2 C) U7 P
- *
! _% ~ \2 Q0 V1 R - * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- g) j! C, I/ H& Z6 T9 L0 H8 U - * kind, whether express or implied; without even the implied warranty+ `% s7 \% Q( b P( w* O. I4 x
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9 S* y+ S# X4 H9 G! v. c, F) G
- * GNU General Public License for more details.! X2 N4 w/ g2 W& A( ]
- */" _; B1 X6 L9 N0 Q+ x5 R; b6 _4 h
. t9 N+ E' L2 z) E2 z+ `- #include <linux/module.h>
6 {" f. P6 ^- o% u+ y) e - #include <linux/init.h>, L+ }0 y: i7 c2 i: c6 u
- #include <linux/errno.h>3 A3 a: F6 G8 q: e4 |
- #include <linux/types.h>% w6 H, d4 P# }7 X3 W4 s( R
- #include <linux/interrupt.h>
1 D( |* T5 C" S2 C - #include <asm/io.h>: L' S3 V- t$ s* p
- #include <linux/moduleparam.h>: Z( C( C0 F& x! k7 o
- #include <linux/sysctl.h>
; u) R5 d1 E( k3 W - #include <linux/mm.h>
, Q. a2 n) P$ B2 l0 _) ~ - #include <linux/dma-mapping.h>+ k3 `9 _5 z8 E+ _; C2 |9 T+ o3 o
3 |9 H6 p, Z6 H. ~% P& \; J4 q- #include <mach/memory.h>
9 D' h/ F+ U9 D' t0 C - #include <mach/hardware.h>
* X$ @/ o3 G: r. A6 L, n - #include <mach/irqs.h>. s' [$ |+ G- P; _6 Z2 H
- #include <asm/hardware/edma.h>
' i" m1 }' K/ }3 O h - " v3 q3 |( m& u/ s5 o% ? U8 |
- #undef EDMA3_DEBUG+ k @ V1 g- O+ X) q* X7 `1 g
- /*#define EDMA3_DEBUG*/8 q! V- `! o6 W) L D( u- J
- ' T2 F0 x' A" r9 c$ s3 s+ m+ F" ^" I
- #ifdef EDMA3_DEBUG
. w. z3 E2 K4 E3 @4 } - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)& A; [2 y9 Q% a/ T4 Z9 y: ?
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__), [3 a; n; X# V
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)! [2 w# d( G/ z& a& Z+ ?
- #else" k% [% K3 c' [! E( \0 ~
- #define DMA_PRINTK( x... ). G5 G- r Z8 u, x- y4 _
- #define DMA_FN_IN2 y+ M* b& N8 V4 e* l# S R3 Z- C
- #define DMA_FN_OUT
7 Q& _0 r/ @( S1 V - #endif
9 V9 e3 @- Y' t - 7 T. i, H4 W( c8 z( j
- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
2 N* v% a2 c$ M4 n7 o1 u - #define STATIC_SHIFT 3
$ n5 D( r7 e+ P- K" B% F3 {* ` - #define TCINTEN_SHIFT 20
6 m K2 m: e. P( A& E - #define ITCINTEN_SHIFT 21
6 T3 y* `: ?, w9 X4 p - #define TCCHEN_SHIFT 22) e; e% d% n4 ~# v0 d+ f/ A
- #define ITCCHEN_SHIFT 23
. s) o7 t- ?) K7 }
# N( }3 `- P9 o: j- static volatile int irqraised1 = 0;# B# U* q: _- j& z1 w
- static volatile int irqraised2 = 0;3 q3 @: p/ z: [1 w+ a* k
5 D; @" b6 P2 T: D- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
+ y1 J; I5 x& h- h* e8 p J - int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);% d2 H& \/ z! R- N# M, n
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);9 O, V% ?" e( _- P8 I
8 K- X4 O0 ^/ G$ [; e/ M- dma_addr_t dmaphyssrc1 = 0;
* W& K; i" Q! w/ A/ [ - dma_addr_t dmaphyssrc2 = 0;
$ r; C3 h: h$ G" p" T - dma_addr_t dmaphysdest1 = 0;
3 b- d3 R; m! X3 G! s - dma_addr_t dmaphysdest2 = 0;
9 k4 o7 i& I+ a; v. X* ~! \ m - + B, M* x( w3 U7 q; q
- char *dmabufsrc1 = NULL;8 l9 k% O1 X0 ~+ r* v3 E
- char *dmabufsrc2 = NULL;
: e+ L5 H8 ~6 A - char *dmabufdest1 = NULL;
: e" O( K+ B) @6 W6 w: @* Z7 E* d* d - char *dmabufdest2 = NULL;
/ q: l1 D: B. ^( o: |2 ?4 L4 N - 2 j, U" x( G8 L9 o; O; d$ S' q* j
- static int acnt = 512;7 i) I3 ]& ?9 f9 R1 @
- static int bcnt = 8;
- i$ \, h0 x8 v) n) f X2 N4 H ~ - static int ccnt = 8;2 O- y' D5 t% x2 ^3 E' o" i
- 5 S. @8 c" k D. z; M3 p6 q
- module_param(acnt, int, S_IRUGO);2 ~4 z1 a& i/ P2 q+ O6 e: A/ i( b2 k
- module_param(bcnt, int, S_IRUGO);' h y1 h& m+ I' S( J
- module_param(ccnt, int, S_IRUGO);
复制代码
! i+ V, V; l' o, [, Y: L' U9 A1 `; Z; N
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用
2 A3 C, K% x z2 b# Q7 ]/ N9 Yarm-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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。5 J; N$ h5 C) Z" C4 D
我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。+ V% m, g" K" K3 G$ Q* W
, \! O' w" R/ W; {2 K" j% E z, k( V0 [9 K
|
|