|
|
本帖最后由 yyj 于 2018-1-30 11:01 编辑
% W8 B5 r3 D8 P. }# V$ V0 [; u- [code]EDMA sample test application
9 H2 S; U1 W2 Y d- { - /*4 j" r c7 _# s* c, _' `
- * edma_test.c
/ ~# W2 d* q+ B# J# R5 ~ - *' X7 R% a3 y/ a- Z, `/ a
- * brief EDMA3 Test Application K5 S/ u9 T+ ]4 e; _7 ^; _4 S
- *
$ C) x2 d. h* s+ ] - * This file contains EDMA3 Test code.
. p3 R! H b% I# J0 o - *
/ ~) E8 i3 D* T, ^* d* ~1 v - * NOTE: THIS FILE IS PROVIDED ONLY FOR INITIAL DEMO RELEASE AND MAY BE8 ~& w$ g! G, S3 Q. }% Q
- * REMOVED AFTER THE DEMO OR THE CONTENTS OF THIS FILE ARE SUBJECT; m* e2 s; c7 J1 m% W2 @) B# T1 W# h
- * TO CHANGE.
: B& ]) {/ A8 w7 p* l - *; Q, r* r) C; }" j. w3 q; i1 u: A# J
- * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
) V( `+ R3 x" }3 W) ]& L( m - *
8 k0 M0 I: a, H6 d - * This program is free software; you can redistribute it and/or) o& W4 Y2 _* }" R* s0 s
- * modify it under the terms of the GNU General Public License as
" @$ r" a5 {5 c3 @4 \+ k - * published by the Free Software Foundation version 2.5 I1 A: Q! W' C* |
- *
4 v o7 y$ W- Y( y: N - * This program is distributed "as is" WITHOUT ANY WARRANTY of any2 Y, I8 \4 F: Y, Y9 I S
- * kind, whether express or implied; without even the implied warranty5 d1 \* {/ {4 x6 W
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2 i* x! P7 O. M1 \. V: ]* | - * GNU General Public License for more details.7 Q, H/ r* m8 i% m( b7 N
- */
) i5 l6 E3 v* V9 X% e6 a - ( R, c( W1 V$ J8 |
- #include <linux/module.h>" n' C) P# C! Z5 ?3 X5 `
- #include <linux/init.h>" i. G6 M. d3 f4 V7 W
- #include <linux/errno.h>
f2 x* J% `0 u. f" O1 \: |, x: X2 ~ - #include <linux/types.h>
. r( t( i7 \. [6 v# [2 \- g - #include <linux/interrupt.h>0 j$ c8 O8 \0 K1 y' J9 B& i7 g" g
- #include <asm/io.h>" a: v1 p H: U# ~6 y
- #include <linux/moduleparam.h>
+ n. h+ w: L2 w$ y7 u - #include <linux/sysctl.h>
6 |9 F# S7 i, E+ |+ n7 f* m' f - #include <linux/mm.h>6 l" d: j! M8 ~2 K+ R A3 O
- #include <linux/dma-mapping.h>$ [8 _7 t0 ~1 w2 L! w! O- M* w, ^. j
- 7 i, S0 V. j& k" D( s( Y8 `+ J
- #include <mach/memory.h>* G; o7 t$ ] Z) R
- #include <mach/hardware.h>
( x' w" b& V$ H- c8 e - #include <mach/irqs.h>' J' `) [6 ~/ U3 K! g) r, T5 }
- #include <asm/hardware/edma.h>
- { @7 H& u* q) d |0 f& q% \, e
% L5 l! h- J2 ~7 J# Q# e. a- #undef EDMA3_DEBUG5 t I! A# y c! F' J5 N
- /*#define EDMA3_DEBUG*/
. X7 ^/ W8 V3 c2 D6 o8 y+ { - 5 J. x: |- |' n' r* j2 P4 ?
- #ifdef EDMA3_DEBUG
5 W( M$ i. g/ x+ B - #define DMA_PRINTK(ARGS...) printk(KERN_INFO "<%s>: ",__FUNCTION__);printk(ARGS)$ ~% b) G/ D2 L9 |. _- b) W
- #define DMA_FN_IN printk(KERN_INFO "[%s]: start\n", __FUNCTION__): q. I8 k2 C9 Z! N" N! l" T5 `0 d6 A& S
- #define DMA_FN_OUT printk(KERN_INFO "[%s]: end\n",__FUNCTION__)
$ x# ]+ k, d" G b1 |' E# R - #else0 u+ c- h! q: X! V9 @
- #define DMA_PRINTK( x... )
7 N- J' N* M# X, d - #define DMA_FN_IN! i2 Y6 \4 o s+ M! m& z e, O" ^
- #define DMA_FN_OUT
$ [% \3 }$ H6 Z+ r# [6 M - #endif! G% Q6 y/ c- F# r2 `, {
. `6 R3 j% l2 \$ n* L! o$ |- #define MAX_DMA_TRANSFER_IN_BYTES (32768)
) W8 D2 u9 H+ T) {" z, ?- o! { - #define STATIC_SHIFT 31 x w. n+ y6 _3 s1 W2 G
- #define TCINTEN_SHIFT 20
# y; a# y) @; M - #define ITCINTEN_SHIFT 21
7 T: {: o2 \1 l' ~- S# g - #define TCCHEN_SHIFT 229 _) W- \8 V* a0 A" ?- {
- #define ITCCHEN_SHIFT 231 g: t+ u1 U, q! ^! D8 J$ q$ m+ H2 D
- 7 ~, I6 M+ f8 q/ _
- static volatile int irqraised1 = 0;! N2 t- D+ i% _8 R
- static volatile int irqraised2 = 0;
7 z' q/ X0 B- E: x+ d - 9 `2 o* P5 ^. J5 H
- int edma3_memtomemcpytest_dma(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);3 R( A/ ]7 C3 `* c5 R% ]7 j/ z
- int edma3_memtomemcpytest_dma_link(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
. b* y* W. j" J7 i* @! W - int edma3_memtomemcpytest_dma_chain(int acnt, int bcnt, int ccnt, int sync_mode, int event_queue);
& y8 M2 V7 @7 k: p4 ~* X. ?3 K - % i( ^9 E; L" x
- dma_addr_t dmaphyssrc1 = 0;
, d- T5 J g' D8 x - dma_addr_t dmaphyssrc2 = 0;
$ Y# d l! ? `2 `1 [ - dma_addr_t dmaphysdest1 = 0;
% B% v' a- T- P% _ - dma_addr_t dmaphysdest2 = 0;
! S. ~* S5 n5 j2 p: Y# c2 x, x - 0 c# p: N- g, k D2 i, i
- char *dmabufsrc1 = NULL;
' ?7 d( N+ |, _: E - char *dmabufsrc2 = NULL;
. Y$ Z2 i5 V7 L _ - char *dmabufdest1 = NULL;8 H1 w2 |5 T8 S
- char *dmabufdest2 = NULL;9 O: |! X8 x( D' u h1 S" S& f# N
- , E2 |; ?% D. w! G3 A
- static int acnt = 512;( L$ y* M f/ B2 G
- static int bcnt = 8;
- {/ K( I8 I; ^' q% ?* S - static int ccnt = 8;7 b' x/ ], ]: V5 I+ P. {: F3 I
5 m3 A+ b# y( O# n/ i- module_param(acnt, int, S_IRUGO);
0 E$ L8 A3 B ~- h4 R/ U( O3 P - module_param(bcnt, int, S_IRUGO);/ M! X5 H* Z( e1 u7 U5 M
- module_param(ccnt, int, S_IRUGO);
复制代码 ) w! F/ d1 @! U. I1 N, F9 L
; Q5 K) Q/ f$ n! H. p4 i
这是在TI上找到的一个针对Davanci处理器简单的EDMA3驱动程序测试例程的一部分,我在编译的过程中是用4 ]- H7 `9 R7 Z6 u6 e% q
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这个命令来链接库文件进行编译,但是报的错误特别多,我又试着一个函数一个函数往进加,仍然是很多错误。
0 V+ j1 n! m8 O* I9 z! l" F$ t 我想问一下如何用一个简单的程序来测试一下EDMA3的驱动。
) l* J+ E$ Q8 u) x. e% Z+ z
7 B1 i5 K: U. H
, }; _2 c, ]& o- K |
|