|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
; k( `% [, z2 X4 L. j F: }: h7 U- [code]EDMA sample test application
9 G) w1 @7 U% N+ u+ M" M* k; d: } - /*
4 l" H6 q6 \8 G0 l0 ] - * edma_test.c
/ ?+ i$ w. y6 h% U' L. \ - *6 Z$ z* q% n! B9 _- w# t6 V
- * brief EDMA3 Test Application% o: x1 M* |( Q4 F* Y
- *3 D6 j9 x6 J+ |4 {( n3 F& M# H* m$ }; B
- * This file contains EDMA3 Test code.
4 }9 w' K( s; z4 @# B# {: _ - *9 U& l& ]4 g% ]. c" Y% @* O
- * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE; t3 l" t: s8 J3 ^/ m0 W, F
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT9 o7 q8 X. x6 W& @- V. `
- * TO CHANGE.
8 ?8 d" k8 k: H) `( Q - *
0 o, ]8 z5 ] J0 o- R9 z0 F, } - * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/0 L- H( g, X, D6 N: H, n3 f
- *2 E/ P; x! ~# V& }3 n# y
- * This program is free software; you can redistribute it and/or) A- a0 B% R8 ~5 r) q
- * modify it under the terms of the GNU General Public License as# _& ?4 w4 n- ]
- * published by the Free Software Foundation version 2. K; k D+ H1 R
- *
. w3 s/ m( D+ K1 l' m/ I - * This program is distributed "as is" WITHOUT ANY WARRANTY of any' X1 _) z, _( G( _+ {
- * kind, whether express or implied; without even the implied warranty- p* ^# y- O, T" f6 Q* _( C
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
: w9 J9 J) E F& F. n - * GNU General Public License for more details.( C8 l: g/ X X$ _7 c6 @
- */
_3 u: W, N* ?8 p - `7 f9 ^8 A) V4 @ W9 S
- #include <linux/module.h>7 P) U1 o, ^* I6 q1 f8 H
- #include <linux/init.h>
. ?& f3 e5 n: }8 i- ~- S+ M - #include <linux/errno.h>
8 P4 b& ~! [0 t& P* {' ?# [ - #include <linux/types.h>$ \- m1 `, C" ] _% A" R# I' A4 ?
- #include <linux/interrupt.h>0 a! S1 S5 S# `, s8 K
- #include <asm/io.h>
) U$ D( Z- ~" ?+ q* u6 J; E - #include <linux/moduleparam.h>' s( V( N' ~& Q# g- E& \
- #include <linux/sysctl.h>
/ o% P. _8 r7 T3 m a - #include <linux/mm.h>7 |$ X# C3 O8 n( z' @
- #include <linux/dma-mapping.h>7 t: c( W$ ~5 p3 d6 C
/ B6 m4 `$ h2 q9 V- #include <mach/memory.h>& R) d6 x: ~' C; ]9 |
- #include <mach/hardware.h>: o. O* |6 y! h' h3 C+ ]9 S
- #include <mach/irqs.h>
4 S3 ^: N: X. }1 N6 L - #include <asm/hardware/edma.h>
3 Q# w& Y4 d) e) l( T' O; o
1 b, ~# l/ m# w0 c- q& B9 b0 x$ B- #undef EDMA3_DEBUG
2 a, y+ A* M, T - /*#define EDMA3_DEBUG*/
1 L/ w0 W" ~2 K% `1 M' `9 A& {# m
5 d* ?1 N5 H. d* o; J# H ^( W& U- #ifdef EDMA3_DEBUG- o1 ^' [( ^ R7 Z
- #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)3 x3 O$ s: C( D, e( `. a# W7 j% E: S
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__); A- M$ u2 A5 x: F9 {
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
6 N- E' C# @! d& L; K4 c - #else
5 ^$ K. I L3 }* f - #define DMA_PRINTK( x... )
3 r0 I) i3 W& X7 Y$ N) k - #define DMA_FN_IN
- C, r( h2 p& T( m - #define DMA_FN_OUT9 s; e5 f- k4 ], C5 z
- #endif! p1 g1 w ^+ k5 x$ G+ {
- 6 t& k% Q4 F# Q0 y8 n% R7 H S% A
- #define MAX_DMA_TRANSFER_IN_BYTES (32768), F8 x2 o) K8 `, D- i& W
- #define STATIC_SHIFT 3
0 J6 i; a( r& F! q( \8 r, m( g) r - #define TCINTEN_SHIFT 20, q& G) H! i' |% ?, a I: K
- #define ITCINTEN_SHIFT 21
6 a0 e; Z3 G' g- ~* \, f - #define TCCHEN_SHIFT 22
$ \+ u- F0 j. A. u* _- l - #define ITCCHEN_SHIFT 237 T3 R( `+ v# ^$ ^# V0 r2 b
" V7 j8 d) V5 ~$ {: X) a% _0 z- static volatile int irqraised1 = 0;) I1 I5 i c" Z3 ^- V) T
- static volatile int irqraised2 = 0;4 z+ [8 M( b8 N5 q3 N/ @. U
% p8 A N+ U' y3 p5 E# h4 v2 A- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);* J8 E2 \! w) x5 b- N. T
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);; ^: N9 ^7 q8 Q. ` B
- int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);( {# E. N+ \ J& M1 W5 K, L
- 5 Y) n/ ^- L: _/ o- t+ m2 N" r
- dma_addr_t dmaphyssrc1 = 0;. L4 o s: ?/ O) {8 V. [) _: Q
- dma_addr_t dmaphyssrc2 = 0;
}- }3 A9 z6 v$ l8 \- I0 l- ^ - dma_addr_t dmaphysdest1 = 0;
5 R6 }5 \: I9 d& r% c9 d; | - dma_addr_t dmaphysdest2 = 0;' g$ q9 J5 T7 ]
+ _8 @: z4 z( }: I# l3 s- char *dmabufsrc1 = NULL;
. O6 \% D3 h, O6 K- \ - char *dmabufsrc2 = NULL;) j2 f* w' W5 P; H$ k
- char *dmabufdest1 = NULL;9 }" X# e x+ ~4 ]
- char *dmabufdest2 = NULL;
# Q8 v) @! b7 y1 i. L2 v - ! {6 P: _! d- p7 v5 N: {
- static int acnt = 512;8 Q8 `- b& ~( t; x& c
- static int bcnt = 8;
" G. m& _* S U: A# t- z - static int ccnt = 8;
1 m: `( C9 p" k5 k7 Z9 ] - - N: F) a/ S! U
- module_param(acnt, int, S_IRUGO);
: } N6 s/ Y3 C) G. u9 O4 _, M3 L - module_param(bcnt, int, S_IRUGO);+ R, U. O8 J k z/ r
- module_param(ccnt, int, S_IRUGO);
复制代码
# I3 m/ b0 c: k% o- Z
; d% I( b7 E3 ^+ B$ v6 O 这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用3 z! q3 C/ A* p
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
% T" l$ }: q- q" B4 [# M4 | 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。% |$ Z, `! L9 \" |+ q8 ?
( y) h0 s. D; w: {6 F* r9 C
0 u( I6 O- ^9 Z2 {( U |
|